akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
char c;
int main()
{
	cin>>c;
	switch(c)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u': puts("vowel"); break;
		default: puts("consonant");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    
    int p=0;
    if(a<=k) {k-=a;p+=a;} else {p=k;k=0;}
    if(b<=k) {k-=b;     } else {k=0;}
    if(c<=k) {k-=c;p-=c;} else {p-=k;k=0;}
    cout << p;

}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> h(n);
	rep(i,n) scanf("%d",&h[i]);

	sort(h.begin(),h.end());

	int ans=h[n-1]-h[0];
	rep(i,n-k+1) ans=min(ans,h[i+k-1]-h[i]);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 640
import Control.Monad
import Data.Bool
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=putStrLn.solve.B.lines=<<B.getContents
solve[ns,s]=if null r then "-1" else fromJust(head r)where
  r=filter isJust.map(\ab->g ab.B.foldr f ab$s).replicateM 2$"SW"
  n=fst.fromJust.B.readInt$ns
  f s r@(a:b:cs)=(bool 'W' 'S'$(a==b)==(s=='o')):r
  g[c,d](a:b:cs)=bool Nothing(Just$take n$b:cs)$a==c&&b==d

Measured memory_bytes: 26116
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> A(H);
  for(int i=0;i<H;++i){
    cin>>A[i];
  }
  map<int, int> amap;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(A[i][j]=='#') amap[i+j]++;
    }
  }
  bool ans = true;
  for(int i=0;i<H+W-1;++i){
    if(amap[i]>1) ans = false;
  }
  if(ans) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 3584
x,y = map(int, input().split())
if x==2:
  print('No')
elif x==4 or x==6 or x==9 or x==11:
  if y==6 or y==9 or y==11:
    print('Yes')
  else: print('No')
else:
  if y==3 or y==5 or y==7 or y==8 or y==10 or y==12:
    print('Yes')
  else: print('No')

Measured memory_bytes: 3064
import numpy as np
N = int(input())
num_list = [int(input()) for i in range(N)]
a = max(num_list)
if num_list.count(a) > 1:
  for j in range(N):
    print(a)
else:
  b = np.sort(num_list)
  c = b[-2]
  for k in range(int(num_list.index(a))):
    print(a)
  print(c)
  for l in range(N-int(num_list.index(a))-1):
    print(a)

Measured memory_bytes: 23328
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ascii_uppercase: Vec<_> = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect();

    let ans = S
        .iter()
        .map(|&c| {
            ascii_uppercase[((0..26).find(|&i| ascii_uppercase[i] == c).unwrap() + N) % 26]
                .to_string()
        })
        .collect::<Vec<_>>()
        .join("");

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<string> A(H);
  for(string &S:A)
    cin>>S;
  vector<int> C(0);
  vector<vector<int>> D(0);
  int k=0;
  for(int i=0;i<H;i++){
    vector<int> B(0);
    for(int j=0;j<W;j++)
      if(A[i][j]=='#')
        B.push_back(j);
    if(B.size()!=0){
      C.push_back(i);
      vector<int> E(W);
      B.push_back(W);
      for(int j=0;j<B[0];j++)
        E[j]=k;
      for(int j=0;j<B.size()-1;j++){
        for(int l=B[j];l<B[j+1];l++)
          E[l]=k;
        k++;
      }
      D.push_back(E);
    }
  }
  C.push_back(H);
  vector<vector<int>> E(H,vector<int>(W));
  for(int i=0;i<C[0];i++)
    E[i]=D[0];
  for(int i=0;i<C.size()-1;i++)
    for(int j=C[i];j<C[i+1];j++)
      E[j]=D[i];
  for(vector<int> &v:E)
    for(int i=0;i<W;i++){
      cout<<v[i]+1;
      if(i==W-1)
        cout<<endl;
      else
        cout<<' ';
    }
}

Measured memory_bytes: 5208
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n;
	while(cin>>n,n){
		vvi in;
		in.pb({0,inf});
		rep(i,n){
			string c;int a;
			cin>>c>>a;
			a*=2;
			if(c=="n")a++;
			in.pb({c=="y",a});
		}
		in.pb({0,inf});
		rep(i,in.size()-1){
			if(in[i][0]==in[i+1][0]){
				if(in[i][0])cmin(in[i][1],in[i+1][1]);
				if(!in[i][0])cmax(in[i][1],in[i+1][1]);
				in.erase(in.begin()+i+1);
				i--;
			}
		}
		int out=0;
		while(in.size()>=2){
			int mi=inf,t;
			rep(i,in.size())if(mi>in[i][1]){
				mi=in[i][1];
				t=i;
			}
			if(in[t][0]){
				out++;
				in.erase(in.begin()+t);
				t--;
				cmax(in[t][1],in[t+1][1]);
				in.erase(in.begin()+t+1);
			}else{
				in.erase(in.begin()+t);
				t--;
				cmin(in[t][1],in[t+1][1]);
				in.erase(in.begin()+t+1);
			}
		}
		cout<<out<<endl;
		break;
	}
}








Measured memory_bytes: 3284
import math


def main():
    N, K = [int(a) for a in input().split()]

    b = int(math.pow(N // K, 3))

    if K % 2 != 0:
        print(b)
        return

    b2 = math.pow(((N - K // 2) // K) + 1, 3)
    print(int(b + b2))


if __name__ == '__main__':
    main()


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

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

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

  int ans = 1000000000;
  for (int i = 0; i < n-1; i++)
  {
    int sum1=0,sum2=0;
    for (int k = 0; k <= i; k++)
    {
      sum1+=w[k];
    }
    for (int j = i+1; j < n; j++)
    {
      sum2+=w[j];
    }
    ans = min(ans,abs(sum1-sum2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys


N, *A = map(int, open(0).read().split())
MOD = 10 ** 9 + 7

A.sort()

ret = 1
if N % 2 == 0:
  for i, (a1, a2) in enumerate(zip(*[iter(A)]*2)):
    i = 2*i + 1
    if i == a1 and i == a2:
      ret *= 2
      ret %= MOD
    else:
      print(0)
      sys.exit()
else:
  if A[0] != 0:
    print(0)
    sys.exit()
  else:
      for i, (a1, a2) in enumerate(zip(*[iter(A[1:])]*2), 1):
        i *= 2
        if i == a1 and i == a2:
          ret *= 2
          ret %= MOD
        else:
          print(0)
          sys.exit()
          
print(ret)

Measured memory_bytes: 59952
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
const ll mod =  998244353;
int n,s;
ll q;
int dp[3001][2];
ll binpow(ll a, ll p){
    if(!p)
        return 1;
    if(p&1)
        return (a*binpow(a,p-1))%mod;
    ll b = binpow(a,p/2);
    return (b*b)%mod;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    cin >> n >> s;
    q = binpow(2,mod-2);
    dp[0][0] =binpow(2,n);
    for(int i =0 ;i < n;i++){
        int l = i%2;
        int r = (l+1)%2;
        ll a;
        cin >> a;
        for(int i =0;i <= s;i++)
            dp[i][r] = dp[i][l];
        for(int i =0 ;i+a <= s;i++){
            dp[(i+a)][r]+=((dp[i][l]*q)%mod);
            dp[(i+a)][r]%=mod;
       //      cout << a <<" "<< i <<" "<< dp[i][l] <<" "<<dp[i+a][r] <<"\n";
        }
    }
  //  cout << dp[s][n%2] <<"\n";
    ll ans = dp[s][n%2];
    cout << (ans)%mod;
  return  0;    
}

Measured memory_bytes: 3148
program ABC154_A
  character(10)::S,T,U
  integer::A,B
  read(*,*)S,T
  read(*,*)A,B
  read(*,*)U
  if(S==U) then
     write(*,*)A-1,B
  else
     write(*,*)A,B-1
  end if
end program ABC154_A

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

	while (1) {
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			break;
		}

		for (i = 1; i <= H; i++) {
			for (j = 1; j <= W; j++) {
				if (i == 1 || i == H || j == 1 || j == W) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if( 1 != a && 1!= b){
        cout << 1 << endl;
    }else if( 2 != a && 2 != b){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
}




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

#define lli long long int

lli dp[105][100005];

int main()
{
lli n,w;
cin>>n>>w;
vector<vector<lli> > v(n,vector<lli> (2));
for(lli i=0;i<n;i++)
cin>>v[i][0]>>v[i][1];
memset(dp,0,sizeof(dp));
for(lli i=0;i<=n;i++)
{
for(lli j=0;j<=w;j++)
{
if(i==0||j==0)
dp[i][j]=0;
else if(j>=v[i-1][0])
{
    lli m=v[i-1][1]+dp[i-1][j-v[i-1][0]];
dp[i][j]=max((m),dp[i-1][j]);
//cout<<v[i-1][1]<<" "<<dp[i-1][j-v[i-1][0]]<<" "<<m<<" "<<dp[i-1][j]<<" "<<i<<" "<<j<<endl;
}
else
dp[i][j]=dp[i-1][j];
}
}
cout<<dp[n][w]<<endl;
return 0;
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
#define ll long long
using namespace std;

char mat[1000][1000];
int bio[1000][1000];
int a, h, w, ch, cw, dh, dw, x, x2, y, y2;
deque<pair<int,int>> DQ;

int main() {
    cin >> h >> w >> ch >> cw >> dh >> dw;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j];
        }
    }

    DQ.push_back({ch - 1, cw - 1});
    bio[ch - 1][cw - 1] = 1;
    while (!DQ.empty()) {
        x = DQ.front().first;
        y = DQ.front().second;
        DQ.pop_front();
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (i == 0 && j == 0) {continue;}
                x2 = x + i;
                y2 = y + j;
                if (x2 < 0 || y2 < 0 || x2 >= h || y2 >= w) {continue;}
                if (mat[x2][y2] == '#') {continue;}
                if (abs(x2 - x) + abs(y2 - y) == 1) {
                    if (bio[x2][y2] > 0 && bio[x2][y2] <= bio[x][y]) {continue;}
                    bio[x2][y2] = bio[x][y];
                    DQ.push_front({x2, y2});
                }
                else {
                    if (bio[x2][y2] > 0 && bio[x2][y2] <= bio[x][y] + 1) {continue;}
                    bio[x2][y2] = bio[x][y] + 1;
                    DQ.push_back({x2, y2});
                }
            }
        }
    }

//    for (int i = 0; i < h; i++) {
//        for (int j = 0; j < w; j++) {
//            cout << bio[i][j];
//        }
//        cout << endl;
//    }

    cout << bio[dh - 1][dw - 1] - 1 << endl;
}


Measured memory_bytes: 8588
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x)
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a >= b {
		fmt.Println("delicious")
	} else if a+x >= b {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(a: i32, b:i32, x:i32) -> bool {
    if x < a { return false }

    if (a+b) < x { return false }

    true
}

fn main() {
    let (a,b,x) = parse_line!(i32, i32, i32);
    println!("{}", if solve(a,b,x) { "YES"} else {"NO"});
}

#[test]
fn solve_test() {
    assert_eq!(solve(3,5,4), true);
    assert_eq!(solve(2,2,6), false);
    assert_eq!(solve(5,3,2), false);
}


Measured memory_bytes: 4352
/************************Code by Hardik Aggarwal!!!!***********************************/

#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
int main()
{

    IOS
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll pre[n+2],suf[n+2];
    memset(pre,0,sizeof(pre));
    memset(suf,0,sizeof(suf));

    
    for(ll i=1;i<=n;i++)
    {
        pre[i]=__gcd(pre[i-1],a[i-1]);
    }
    for(ll i=n;i>=1;i--)
    {
        suf[i]=__gcd(suf[i+1],a[i-1]);
    }
    ll maxi=0;
    for(ll i=1;i<=n;i++)
    {
        maxi=max(maxi,__gcd(pre[i-1],suf[i+1]));
    }

    cout<<maxi<<endl;



    

    
}
    
 
    
    



Measured memory_bytes: 2560
def lcs(x, y):
    dp = [[0]* (len(y)+1) for _ in range(len(x)+1)]
    

    for r in range(len(x)+1):
        for c in range(len(y)+1):
            if r == 0 or c == 0:
                dp[r][c] = 0
            elif x[r-1] == y[c-1]:
                dp[r][c] = dp[r-1][c-1] + 1
            else:
                dp[r][c] = max(dp[r-1][c], dp[r][c-1])
    
    
    lcs = []
    r = len(x)
    c = len(y)
    
    while r>0 and c>0:
        if x[r-1] == y[c-1]:
            lcs.append(x[r-1])
            r-=1
            c-=1
        elif dp[r-1][c] > dp[r][c-1]:
            r-=1
        else:
            c-=1
    print(''.join(lcs[::-1]))

x = input()
y = input()
lcs(x, y)


Measured memory_bytes: 111452
#include <bits/stdc++.h>
 
using namespace std;
#define endl "\n"
 
int main()
{
	char x;
	cin >> x;
	if(x== 'A') cout << "T"<< endl;
	else if(x == 'T') cout << "A" << endl;
	else if(x == 'G') cout <<"C" << endl;
	else cout<< "G" << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n;
    int i = 1;
    while (i * 2 <= n) {
        i *= 2;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3652
//96 B - Maximum Sum 2018/05/05

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    int k;
    cin >> k;
    a[2]*=pow(2,k);
    cout << a[0]+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
angle1 = 360 / 60 * m
angle2 = (60 * h + m) * 360 / (60 * 12)
angle3 = angle2 - angle1
c = math.radians(angle3)
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c))
print(ans)


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

int main(){
    int N; cin >> N;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    
    int sum=0;
    rep(i,N) sum+=A[i];
    int hint1=sum/2;
    
    int ans=1e9;
    int Sum=0;
    int cnt=0;
    rep(i,N){
        Sum+=A[i];
        if (abs(hint1-Sum)<abs(ans)){
            ans=hint1-Sum;
            cnt++;
        } 
        else break;
    }
    
    int sum1=0;
    int sum2=0;
    rep(i,cnt) sum1+=A[i];
    for (int i=cnt; i<N; i++) sum2+=A[i];
    
    cout << abs(sum1-sum2);
    
    
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  vector<ll> v(N,0);
  cinv(v,0,N);
  sortAl(v);
  ll num=0,amo=0,res=0;
  FOR(i,0,N){
    if(v[i]==num){
      amo++;
      //cout<<"a";
    }
    else{
      if(amo>num) res+=amo-num;
      else if(amo<num) res+=amo;
      num=v[i];
      amo=1;
      //cout<<"w";
    }
  }
  if(amo>num) res+=amo-num;
  else if(amo<num) res+=amo;

  cout<<res<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int P[5010];
ll C[5010], s[5010];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i){
	    cin >> P[i];
	    --P[i];
	}
	for(int i=0; i<N; ++i) cin >> C[i];
	ll ans=-1e18;
	for(int i=0; i<N; ++i){
	    s[0]=0;
	    int now=P[i], j;
	    for(j=0; true; ++j){
	        s[j+1]=s[j]+C[now];
	        if(now==i){
	            ++j;
	            break;
	        }
	        now=P[now];
	    }
	    ll cand=-1e18;
	    if(s[j]<0){
	        for(int k=1; k<=min(j, K); ++k) cand=max(cand, s[k]);
	    }
	    else{
	        if(K<j){
	            for(int k=1; k<=K; ++k) cand=max(cand, s[k]);
	        }
	        else{
	            ll a=-1e18, b=-1e18;
	            for(int k=0; k<=K%j; ++k) a=max(a, s[k]);
	            a += s[j]*(K/j);
	            for(int k=1; k<=j; ++k) b=max(b, s[k]);
	            b += s[j]*(K/j-1);
	            cand=max(a, b);
	        }
	    }
	    ans=max(ans, cand);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin>>a;
  if(a=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(a=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else if(a=="Rainy"){
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

#define ll long long

int main() {
  int N, K;
  cin >> N >> K;
  cout << max(0, N - K + 1) << endl;
  return 0;
}


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

int main(void)
{
    int64_t A[3][3];
    for (int64_t i = 0; i < 3; ++i) {
        for (int64_t j = 0; j < 3; ++j) {
            std::cin >> A[i][j];
        }
    }

    int64_t N;
    std::cin >> N;

    auto set = [&](int64_t v){
        for (int64_t i = 0; i < 3; ++i) {
            for (int64_t j = 0; j < 3; ++j) {
                if (A[i][j] == v) A[i][j] = 0;
            }
        }
    };

    for (int64_t i = 0; i < N; ++i) {
        int64_t b;
        std::cin >> b;
        set(b);
    }

    auto check = [&](){
        if (A[0][0] == 0 && A[0][1] == 0 && A[0][2] == 0) return true;
        if (A[1][0] == 0 && A[1][1] == 0 && A[1][2] == 0) return true;
        if (A[2][0] == 0 && A[2][1] == 0 && A[2][2] == 0) return true;
        if (A[0][0] == 0 && A[1][0] == 0 && A[2][0] == 0) return true;
        if (A[0][1] == 0 && A[1][1] == 0 && A[2][1] == 0) return true;
        if (A[0][2] == 0 && A[1][2] == 0 && A[2][2] == 0) return true;
        if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) return true;
        if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) return true;
        return false;
    };

    std::cout << (check() ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

n, m, q = map(int, readline().split())
lr = [list(map(int, readline().split())) for _ in range(m)]
cnt = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    cnt[l][r] += 1
cnt = np.cumsum(cnt, axis=0).cumsum(axis=1).tolist()
for _ in range(q):
    p, q = map(int, readline().split())
    p -= 1
    ans = cnt[q][q] + cnt[p][p]
    ans -= cnt[q][p] + cnt[p][q]
    print(ans)


Measured memory_bytes: 68496
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
#define pb push_back
#define MP(a,b) make_pair((a),(b))
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const int INF = 1<<30;
const ll LINF = 1LL<<60;
const int MOD = 1e9+7;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if((A<C&&C<B)||(A>C&&C>B)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
  
public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            String line = br.readLine();
            st = new StringTokenizer(line);
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            int l = Integer.parseInt(st.nextToken());
            long[][] matrixA = new long[n][m];
            long[][] matrixB = new long[m][l];
            long[][] matrixC = new long[n][l];
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < m; j++) {
                    matrixA[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < m; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < l; j++) {
                    matrixB[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < l; j++) {
                    for (int k = 0; k < m; k++) {
                        matrixC[i][j] += matrixA[i][k]*matrixB[k][j];
                    }
                }
            }
            printMatrix(matrixC);
  
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
      
    private static void printMatrix(long[][] matrix){
        for (long[] longs : matrix) {
            StringBuilder sb = new StringBuilder();
            for (long anLong : longs) {
                sb.append(anLong).append(" ");
            }
            System.out.println(sb.toString().trim());
        }
    }
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < m;++j) {
            if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i][j]+1,max(dp[i+1][j],dp[i][j+1]));
            else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    string ans = "";
    int i = n,j = m;
    while (i && j) {
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            i--;j--;
            ans = s[i]+ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
 int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y ;
  int AB = min(X, Y) * 2 * C 
    + (X - min(X, Y)) * A 
    + (Y - min(X, Y)) * B;
  int D = X * A + Y * B;
  int E = max(X, Y) * 2 * C;
  cout << min(min(AB, D), E);
  
  return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

const int MOD = 1000000007;
struct mi {
    ll v; explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mi& a, const mi& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mi& a, const mi& b) { 
        return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { 
        return a.v < b.v; }
   
    mi& operator+=(const mi& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mi& operator-=(const mi& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mi& operator*=(const mi& m) { 
        v = v*m.v%MOD; return *this; }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi pow(mi a, ll p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mi inv(const mi& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mi operator-() const { return mi(-v); }
    mi& operator++() { return *this += 1; }
    mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

ll P(ll n, ll m){
    ll r = 1, mod = 1e9 + 7;
    while(m){
        if(m&1){
            r *= n;
            r %= mod;
        }
        m /= 2;
        n *= n;
        n %= mod;
    }
    return r;
}
void doit(){
    ll n, mod = 1e9 + 7;
    cin >> n;
    mi ans = P(10,n) - P(9,n) - P(9,n) + P(8,n);
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   //  cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int z=n-k;
  int w=k;
  if(n-k<0){
    z=0;
    w=n;
  }
  cout << x*w+z*y;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Node{
public:
	int value;
	int max_val;

	Node() : value(-1), max_val(-1){
		return;
	}
	~Node(){
		return;
	}
};

int main(int argc, char **argv){
	std::string buf;
	std::vector<std::vector<Node> > vec;


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		std::vector<Node> cur_vec;
		std::istringstream stream(buf);
		while(std::getline(stream, buf, ',')){
			Node n;
			n.value = std::stoi(buf);
			cur_vec.push_back(n);
		}
		vec.push_back(cur_vec);
	}

	vec[0][0].max_val = vec[0][0].value;
	for(int i = 1; i < vec.size(); i++){
		if(i <= vec.size() / 2){
			vec[i][0].max_val = vec[i - 1][0].max_val + vec[i][0].value;
			for(int j = 1; j < vec[i].size() - 1; j++){
				vec[i][j].max_val = std::max(vec[i - 1][j - 1].max_val, vec[i - 1][j].max_val) + vec[i][j].value;
			}
			vec[i].back().max_val = vec[i - 1].back().max_val + vec[i].back().value;
		}
		else{
			for(int j = 0; j < vec[i].size(); j++){
				vec[i][j].max_val = std::max(vec[i - 1][j].max_val, vec[i - 1][j + 1].max_val) + vec[i][j].value;
			}
		}
	}

	std::cout << vec.back().back().max_val << std::endl;
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    set<char> s;
    for(int i = 0; i < N; i++){
        char S;
        cin >> S;
        s.insert(S);
    }
    int n = s.size();
  	if(n == 3) cout << "Three" << endl;
  	else cout << "Four" << endl;
}

Measured memory_bytes: 3584
program main
  implicit none
  integer :: n, x, y, i, j, dist, k
  integer, allocatable :: cnt(:)
  read (*, *) n, x, y
  allocate (cnt(n - 1))
  cnt(:) = 0
  do i = 1, n - 1
    do j = i + 1, n
      dist = j - i
      dist = min(dist, abs(j - y) + abs(i - x) + 1)
      dist = min(dist, abs(j - x) + abs(i - y) + 1)
      cnt(dist) = cnt(dist) + 1
    end do
  end do

  do k = 1, n - 1
    write (*, "(i0)") cnt(k)
  end do
end program main


Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main()
{
	int n;
	cin >> n;
	long long ans = 1;
	rep(i, n) {
		 ans = ((i + 1) * ans )% 1000000007;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long H;
    cin >> H;
    long long ans = 0;
    for(int i=60; i>=0; i--){
        if(H&(1LL<<i)){
            ans = (1LL<<(i+1))-1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <string>
#include <math.h>
#include <stdint.h>
#include <bitset>
#include <iomanip>

using namespace std;


int main() {
  char C;
  cin >> C;

  string list = "abcdefghijklmnopqrstuvwxyz";
  string result;
  for (int i=0; i<25; i++) {
    if(C == list[i]) {
      result = list[i+1];
    }
  }
  cout << result << endl; 

}

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

int power(int x, int y) {
 int ans = 1;
 for (int i = 0; i < y; i++) {
    ans *= x;
 }
 return ans;
}

int f(int n) {
    int curr = 0;
    if (n == 0) {
        return 0;
    }
    for (int len = 1; len <= 15; len++) {
        if (curr + power(26, len) >= n) {
            return len;
        }
        curr += power(26, len);
    }
}

void get_ans(int n, int pos) {
    if (pos == -1) {
        return;
    }
    for (int i = 1; i <= 26; i++) {
        if (f(n - power(26, pos) * i) < f(n)) {
            cout << (char)(i + 'a' - 1);
            get_ans(n - power(26, pos) * i, pos - 1);
            break;
        }
    }
}
int32_t main() {
 int n;
 cin >> n;
 get_ans(n, f(n) - 1);
 return 0;
}


Measured memory_bytes: 3624
n = int(input())
ls = list(map(int, input().split()))
c = 0

for l in ls:
    for other_l1 in [i for i in ls if i != l]:
        for other_l2 in [i for i in ls if i not in [l, other_l1]]:
            new_l = [l, other_l1, other_l2]
            new_l.sort()
            if new_l[0] + new_l[1] > new_l[2]:
                c += 1

print(int(c / 6))


Measured memory_bytes: 9124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

int exp_mod(long long a, long long b, int m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (int)res;
}

int fact_mod(int n, int m) {
	long long res = 1;
	for (int i=n; i>0; --i)
		res = (res * i)%m;
	return (int)res;
}

int comb_mod(int n, int r) {
	long long res = 1;
	for (int i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

struct Pony
{
    long s, t, x;

    Pony(long s_, long t_, long x_)
    {
        s = s_;
        t = t_;
        x = x_;
    }

    bool operator<(const Pony &another) const
    {
        return x < another.x;
    };
};

struct Mura
{
    long d, idx, res;

    Mura(long d_, long idx_, long res_)
    {
        d = d_;
        idx = idx_;
        res = res_;
    }

    bool operator<(const Mura &another) const
    {
        return d < another.d;
    };

    bool operator>(const Mura &another) const
    {
        return idx < another.idx;
    };
};

struct mystruct_comparer
{
    bool operator ()(Mura const &ms, std::int64_t const i) const
    {
        return ms.d < i;
    }
};

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

  int n;

  cin >> n;

  cout << (n*180-360) << endl;

  
}


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

int main(){
  int N;
  cin >> N;
  
  long long sum = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    sum += i;
  }

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
    ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll x,n,ans;
    cin >> x >> n;
    bool p[110];
    fill(p,p+110,true);
    for (ll i=0;i<n;i++){
        ll y;
        cin >> y;
        p[y]=false;
    }
    for (ll i=0;i<100;i++){
        if (x-i>=0 and p[x-i]){
            ans=x-i;
            break;
        }else if (x+i<110 and p[x+i]){
            ans=x+i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e9;
const int MAXN = 2e5 + 10;
ll mod = 1e9;
vector<int> c(18, 0);
vector<int> ans;
vector<int> fact;
int getnum(vector<int> &a, int n){
    int delta=0;
    vector<bool> was(n, false);
    for(int i=0;i<a.size();i++){
        int h=0;
        for(int j=1;j<a[i];j++){
            if(!was[j]) h++;
        }
        delta+=h*fact[n-i-1];
        was[a[i]]=true;
    }
    return delta;
}
void solve() {
    string s;
    int n;
    cin>>n;
    cin>>s;
    int ans=0;
    for(int i=0;i+2<s.size();i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout<<ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = 1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

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


int gcd(int a, int b) 
{ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
} 

int main()
{
    int n;
    ll res = 0;
    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= n; ++j)
        {
            for(int k = 1; k <= n; ++k) 
                res += gcd(gcd(i, j), k);
        }
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

template<class T> class segtree {
    int n = 1;
    vector<T> dat;
    T def = 0; //Default value

public:
    segtree(int _n) {
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
    }
    segtree(vector<T> a) {
        int _n = a.size();
        while (n < _n)n *= 2;
        dat.resize(2 * n - 1, def);
        REP(i, 0, _n)dat[i + n - 1] = a[i];
        rREP(i, 0, n - 1)dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
    }


    //sum,min,max,etc...
    T fun(T x, T y) { return x | y; }

    //assignment,chmin,chmax,etc...
    void update(int i, T a) {
        i += n - 1;
        dat[i] = a;
        while (i > 0) {
            --i /= 2;
            dat[i] = fun(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }


    T value(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a)return def;
        if (a <= l && r <= b)return dat[k];
        T s = value(a, b, 2 * k + 1, l, (l + r) / 2);
        T t = value(a, b, 2 * k + 2, (l + r) / 2, r);
        return fun(s, t);
    }
    T value(int a, int b) { return value(a, b, 0, 0, n); }

    T operator[](int k) { return dat[k + n - 1]; }
};

int main() {
	init();

    int N; cin >> N;
    string s; cin >> s;
    segtree<bitset<26>>seg(N);
    rep(i, N) {
        int a = s[i] - 'a';
        seg.update(i, (1LL << a));
    }
    int Q; cin >> Q;
    rep(i, Q) {
        int a;cin >> a;
        if (a == 1) {
            int b; cin >> b;
            --b;
            char c; cin >> c;
            int x = c - 'a';
            seg.update(b, (1LL << x));
        }
        else {
            int l, r; cin >> l >> r;
            bitset<26>bit = seg.value(l - 1, r);
            cout << bit.count() << "\n";
        }
    }


	return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int AC[100010], BC[100010];
int AT[100010], BT[100010];

int main() {
	string S, T;
	cin >> S;
	cin >> T;
	for (int i = 1;i <= S.size();i++) {
		if (S[i - 1] == 'A')AC[i] = 1, BC[i] = 0;
		else AC[i] = 0, BC[i] = 1;
	}
	for (int i = 1;i <= T.size();i++) {
		if (T[i - 1] == 'A')AT[i] = 1, BT[i] = 0;
		else AT[i] = 0, BT[i] = 1;
	}

	for (int i = 1;i <= S.size();i++) {
		AC[i] += AC[i - 1];
		BC[i] += BC[i - 1];
	}
	for (int i = 1;i <= T.size();i++) {
		AT[i] += AT[i - 1];
		BT[i] += BT[i - 1];
	}

	int Q, a, b, c, d, x, y;
	cin >> Q;
	for (int i = 0;i < Q;i++) {
		cin >> a >> b >> c >> d;
		x = AC[b] - AC[a - 1] + (BC[b] - BC[a - 1]) * 2;
		y = AT[d] - AT[c - 1] + (BT[d] - BT[c - 1]) * 2;
		if (x % 3 == y % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool check(string s){
	rep(i,s.size()){
		if(!isalpha(s[i]))return true;
	}
	return false;
}

int main(){
	string s;
	getline(cin,s);
	int size=s.size();
	vector<int> bre;
	bre.push_back(0);
	rep(i,size){
		if(!isalpha(s[i]) && s[i]!='\'')bre.push_back(i);
	}
	vector<string> spot;
	rep(i,bre.size()-1){
		spot.push_back(s.substr(bre[i],bre[i+1]-bre[i]));
	}
	//cout<<"debug"<<endl;
	vector<string> ans;
	rep(i,spot.size()){
		rep(j,spot[i].size()){
			if(!isalpha(spot[i][j]) && spot[i][j]!='\'')spot[i].erase(j,1);
		}
		if(spot[i].size()>2 && spot[i].size()<7 /*&& /*!check(spot[i])*/)ans.push_back(spot[i]);
	}
	//cout<<"debug2 "<<ans.size()<<endl;
	cout<<ans[0];
	for(int i=1;i<ans.size();i++){
		cout<<" "<<ans[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
  int x,y;
  cin>>x>>y;
  if(y%2==1)cout<<"No"<<endl;
  else if(y<2)cout<<"No"<<endl;
  else if(y/2<x)cout<<"No"<<endl;
  else if(y/4>x)cout<<"No"<<endl;
  else if(y%4==2&&y/4+1>x)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int x;
    cin >> x;
    cout << !x << endl;
    return 0;
}

Measured memory_bytes: 3628