akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static boolean containV(boolean arr[][],int y)
    {
        boolean flag = true;
           for(int i=0;i<3;i++) flag &=arr[i][y];
        return flag;
    }
    static boolean containH(boolean arr[][],int x)
    {
        boolean flag = true;
        for(int i=0;i<3;i++) flag &=arr[x][i];
        return flag;
    }
    static boolean containD(boolean arr[][])
    {
        boolean flag = true;
        for(int i=0;i<3;i++) flag &=arr[i][i];
        return flag;
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int arr[][] = new int[3][3];
        boolean bool[][] = new boolean[3][3];
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
                arr[i][j] = obj.nextInt();
        }
        int n = obj.nextInt();
        for(int i=0;i<n;i++)
        {
            int k = obj.nextInt();
            for(int u=0;u<3;u++)
            {
                for(int j=0;j<3;j++)
                    if(arr[u][j]==k)
                    {
                        bool[u][j] = true;
                        break;
                    }
            }
        }
        boolean flag = false;
        for(int i=0;i<3;i++)  flag |= containH(bool,i);
        for(int i=0;i<3;i++) flag |= containV(bool,i);
        flag |= containD(bool);
        System.out.println((flag || (bool[2][0] & bool[1][1] & bool[0][2]))?"Yes":"No");
    }
}


Measured memory_bytes: 23252
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop

Q = int(readline())
query = (tuple(map(int,line.split())) for line in readlines())

# 適当に番兵を入れておく
INF = 10**12
L = [INF] # -1倍していれる
R = [INF]
SL = 0; SR = 0

add = 0 # 全体に共通に加わってるもの

answer = []
for q in query:
    if len(q) == 1:
        # 値を求める
        x = -L[0]
        f = SR - SL + x * (len(L)-len(R))
        answer.append('{} {}'.format(x,f+add))
        continue
    # 更新
    a,b = q[1:]
    add += b
    
    b = -heappop(L); SL -= b
    c = heappop(R); SR -= c
    a,b,c = sorted([a,b,c])
    heappush(L,-a); SL += a
    heappush(R,c); SR += c
    if len(L) > len(R):
        heappush(R,b); SR += b
    else:
        heappush(L,-b); SL += b

print('\n'.join(answer))

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

int fa[100010];

int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main () {
	int n, m; scanf("%d%d", &n, &m);
	int tot = n - 1;
	for (int i = 1; i <= n; i++) {
		fa[i] = i;
	}
	for (int i = 1; i <= m; i++) {
		int x, y; scanf("%d%d", &x, &y);
		x = find(x), y = find(y);
		if (x == y) continue;
		tot--;
		fa[x] = y;
	}
	printf("%d\n", tot);
	return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  vector<int> vec(5);
    for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  for(int i=0;i<=4;i++){
  if (vec.at(i)==0)
    cout << i+1 << endl;
  }
}


Measured memory_bytes: 3576
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var arr = Console.ReadLine().ToCharArray();
			foreach(var i in Enumerable.Range(0, arr.Count() - 1))
			{
				if(arr[i] >= 'a' && arr[i] <= 'z')
				{
					arr[i] -= (char)0x20;
				}
			}
			Console.WriteLine(new string(arr));
		}
	}
}

Measured memory_bytes: 5464
package main

import (
	"fmt"
	"io"
	"os"
)

type point struct {
	t int
	x int
	y int
}

func (current *point) canGo(next *point) bool {
	dt := next.t - current.t
	dx := next.x - current.x
	dy := next.y - current.y
	if dx < 0 {
		dx = -dx
	}
	if dy < 0 {
		dy = -dy
	}
	d := dt - (dx + dy)
	if d < 0 {
		return false
	}
	return d%2 == 0
}

func proc(r io.Reader, w io.Writer) {
	var n, t, x, y int
	fmt.Fscanf(r, "%d", &n)

	arr := make([]*point, n+1)
	arr[0] = &point{t: 0, x: 0, y: 0}
	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d %d %d", &t, &x, &y)
		arr[i] = &point{t: t, x: x, y: y}
	}

	for i := 0; i < n; i++ {
		if !arr[i].canGo(arr[i+1]) {
			fmt.Fprintf(w, "No")
			return
		}
	}

	fmt.Fprintf(w, "Yes")
}

func main() {
	proc(os.Stdin, os.Stdout)
}


Measured memory_bytes: 6016
/*==============================================*\
Codeforces ID:    mdshihab
 Atcoder ID :   mdshihab                                                 |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}
//ll arr[10000000];
int main()
{
    fast
   // FI(); /// skip this line for compile
    ///brute force solution
    /*
    ll n,l,j=0,ans=1;
    ll sum=0;
    cin >> n;

    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            arr[j]++;
        }
    }

    for(ll i=1;i<=n;i++){
        sum+=i*arr[i];
    }
    cout << sum << endl;*/

    /// optimize solution
   /* ll cnt,ans=0,sum,n;
    cin >> n;
    for(ll i=1;i<=n;i++){
        cnt = n/i;
        sum = (cnt+1) * cnt/2;
        ans+=sum*i;
    }
    cout << ans << endl;*/

    /// more optimize solution
    ll n,ans=0;
    cin >> n;
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
import numpy as np
N = int(input())
#A = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))
if sum(A) < sum(B):
    print(-1)
    exit()
d = A-B
sd = np.sort(d)[::-1]
negsum = np.sum(sd[sd < 0])
negcnt = np.sum(sd < 0)
cnt = 0
for i in sd:
    if i <= 0:
        break
    if negsum >= 0:
        break
    negsum += i
    cnt += 1
ans = negcnt + cnt
print(ans)

Measured memory_bytes: 23856
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int  i=0;i<n;i++)
    {
cin>>arr[i];
    }
    sort(arr,arr+n);
    lld sum=0;
    for(int i=0;i<k;i++)
    sum+=arr[i];
    cout<<sum;
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

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

fn main() {
    let s = scan!();
    for (i, c) in s.chars().enumerate() {
        for c1 in s[i + 1..].chars() {
            if c == c1 {
                println!("no");
                return;
            }
        }
    }
    println!("yes")
}


Measured memory_bytes: 4352
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
struct str{
    char c; int a;
};
str inp[4005],org[4005];
int idx[2][4005];
int tree[5005];
int dp[2005][2005];
void update(int i,int v){
    if(!i) return;
    while(i<5005){
        tree[i]+=v;
        i+=i&-i;
    }
}
int find(int i){
    int ret=0;
    while(i){
        ret+=tree[i];
        i-=i&-i;
    }
    return ret;
}
int cost[2][2005][2005];
int main(){
    int N; scanf("%d",&N);
    for(int i=1;i<=2*N;i++){
        scanf(" %c %d",&inp[i].c,&inp[i].a);
        org[i]=inp[i];
        idx[inp[i].c=='W'][inp[i].a]=i;
        update(i,1);
    }
    for(int b=0;b<=N;b++){
        for(int w=1;w<=N;w++){
            cost[1][b][w-1]=find(idx[1][w])-1;
            update(idx[1][w],-1);
        }
        for(int w=1;w<=N;w++)
            update(idx[1][w],1);   
        update(idx[0][b+1],-1);
    }
    memset(tree,0,sizeof tree);
    for(int i=1;i<=2*N;i++){
        update(i,1);
    }

    for(int w=0;w<=N;w++){
        for(int b=1;b<=N;b++){
            cost[0][b-1][w]=find(idx[0][b])-1;
            update(idx[0][b],-1);
        }
        for(int b=1;b<=N;b++)
            update(idx[0][b],1);   
        update(idx[1][w+1],-1);
    }

    memset(dp,50,sizeof dp);
    dp[0][0]=0;
    for(int b=0;b<=N;b++){
        for(int w=0;w<=N;w++){
            dp[b][w+1]=min(dp[b][w+1],dp[b][w]+cost[1][b][w]);
            dp[b+1][w]=min(dp[b+1][w],dp[b][w]+cost[0][b][w]);
        }
    }
    printf("%d",dp[N][N]);
}

Measured memory_bytes: 47360
/*  ex9_2
    Y_Aizaki  */

#include <stdio.h>
#include <stdlib.h>

#define SIZE 100000

typedef struct node{
    char num;
    struct node *next;
}stack;

void push(stack **first, char elem);
char pop(stack **first);

int main(void){
    stack *stk;
    char input[SIZE];
    int i;
    int removed = 0; // 除かれたキューブの数

    scanf("%s", input);
    stk = NULL; // stkの初期化

    for (i=0;input[i]!='\0';i++){ // inputを前から見ていくループ
        if (stk == NULL){ // stkが空の時
            push(&stk, input[i]);
        }
        else{ // stkに要素があるとき
            if (stk->num != input[i]){ // inputで見ている要素と、stkの中身が違う時
                pop(&stk); // stkから消去
                removed += 2;
            }
            else{ // inputで見ている要素と、stkの中身が同じ時
                push(&stk, input[i]); // stkに追加
            }
        }
    }

    printf("%d\n", removed);

    return 0;
}

void push(stack **first, char elem){
    stack *new = calloc(1, sizeof(stack));
    if (new == NULL) exit(1);
    new->num = elem;
    new->next = *first;
    *first = new;
}


char pop(stack **first){
    char elem;
    stack *tmp = *first;
    if (tmp == NULL) exit(1);
    elem = tmp->num;
    *first = tmp->next;

    free(tmp);
    return elem;
}

Measured memory_bytes: 4884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

	string s;
	cin>>s;
	
	ll ans=0;
	ll c=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			ans+=(s.size()-1LL-c)-i;
			c++;
		}
		
	}
	cout<<ans<<"\n";




}


Measured memory_bytes: 640
n = int(input())

S = list(map(int, input().split(" ")))

q = int(input())

T = list(map(int, input().split(" ")))

def binary_search(target, key):
    left = 0
    right = len(S)

    while(left < right):
        mid = (left + right) // 2
        if S[mid] == key:
            return True
        elif S[mid] < key:
            left = mid + 1
        else:
            right = mid

    return False

cnt = 0
for t in T:
    if binary_search(S, t): cnt += 1

print(cnt)

Measured memory_bytes: 18724
import numpy as np
import itertools


def pd(s):
    # print(s)
    pass


# input
H, W, M = map(int, input().split())
ms = [
    [int(i) for i in input().split()]
    for m in range(M)
]
pd(f"{H=} {W=} {M=}")
pd(f"{ms=}")

rows = [0]*(H+1)
cols = [0]*(W+1)
targets = {}
for h, w in ms:
    rows[h] += 1
    cols[w] += 1
    targets[f"{h},{w}"] = True

rmax = max(rows)
cmax = max(cols)
rmax_hs = [i for i, v in enumerate(rows) if v == rmax]
cmax_wh = [i for i, v in enumerate(cols) if v == cmax]

for h, w in itertools.product(rmax_hs, cmax_wh):
    if f"{h},{w}" not in targets:
        print(rmax + cmax)
        exit()
print(rmax + cmax - 1)


Measured memory_bytes: 139368
import sys, heapq
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
A = list(map(int, input().split()))
a = [(-i, 1) for i in A]
heapq.heapify(a)

for i in range(M):
	b, c = map(int, input().split())
	heapq.heappush(a, (-c, b))
	
ans = 0

for i in range(N):
	pop = heapq.heappop(a)
	ans += pop[0]
	if pop[1] != 1:
		heapq.heappush(a, (pop[0], pop[1] - 1))

ans *= -1
print(ans)

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

struct node{
    int left,right;
}nodes[100];

int n,pre[105],in[105],inloc[105],cnt=0;

int rec(int s,int e){
    if(s<e){
        int m=inloc[pre[cnt++]];
        int l=rec(s,m-1);
        int r=rec(m+1,e);
        nodes[in[m]].left=l;
        nodes[in[m]].right=r;
        return in[m];
    }
    else if(s==e){cnt++;return in[s];}
    else {return 0;}
}

void post(int r){
    if(nodes[r].left!=0)post(nodes[r].left);
    if(nodes[r].right!=0)post(nodes[r].right);
    cout<<r;
    if(r!=pre[0])cout<<" ";
}

int main()
{
    memset(nodes,0,sizeof(nodes));
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        cin>>pre[i];
    }
    for(i=0;i<n;i++){
        cin>>in[i];
        inloc[in[i]]=i;
    }
    int mm=rec(0,n-1);
    post(pre[0]);
    cout<<endl;
    return 0;
}
//
//int main(){
//    int a[10]={1,2,3,4,5,32,62,23,8,33};
//    int *b=find(a,a+10,62);
//    int c=distance(a,b);
//    cout<<c;
//}

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

int main() {
  string s; cin >>s;
  char buf = 'a';
  bool ans = false;
  for (int i=0; i<26; i++){
    bool exist = false;
    for (int j=0; j<s.size(); j++){
      if (s.at(j) == buf){
        exist = true;
        break;
      }
    }
    if (exist){
      buf++;
    }else{
      ans = true;
      break;
    }
  }
  
  if (ans) cout <<buf <<endl;
  else cout <<"None" <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5+2;

int par[MAX];
int rk[MAX];
//初期化
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rk[i]=0;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(rk[x]<rk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
	}
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int N,M;
	cin>>N>>M;
	int p[MAX];
	rep(i,N){
      cin>>p[i];
      p[i]--;
    }
//  	rep(i,N)cout<<p[i];
//  	cout<<endl;
  	init(N);
	rep(i,M){
		int x,y;
		cin>>x>>y;
		unite(x-1,y-1);
	}
	int ans=0;
	rep(i,N){
//      	cout<<same(i,p[i]);
		if(same(i,p[i]))ans++;
	}
//  cout<<endl;
	cout<<ans;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	ll n, ans=0;
	cin>>n;
	vector<pi>A(n+1), v;
	FOR(i,1,n){
		ll a,b;cin>>a>>b;
		v.eb(a,i), v.eb(b,-i);
		A[i]={a,b};
	}
	sort(all(v));
	vector<vector<bool>> vis(n+1, vector<bool>(2,0));
	FOR(i,0,n-1)vis[llabs(v[i].s)][v[i].s < 0 ? 1 : 0]=1;
	ll zo=0, type1=0, type2=0;
	FOR(i,1,n)zo += vis[i][0] ^ vis[i][1], type1 += vis[i][0] && !vis[i][1], type2 += !vis[i][0] && vis[i][1];
	if(zo == n && type1 != n && type2 != n){// not a single same
		ll one=LLINF, zero=-LLINF;
		ans=LLINF;
		FOR(i,1,n){
			ll cur1=vis[i][0] ? A[i].f : A[i].s, cur0=vis[i][0] ? A[i].s : A[i].f;
			ans=min(ans,-cur1 + one);
			ans=min(ans,cur0 - zero);
			// one shld be as small as possible
			// zero shld be as big as possible
			zero=max(zero,cur1);
			one=min(one,cur0);
		}
	}
	FOR(i,1,n)ans+=A[i].f*vis[i][0]+A[i].s*vis[i][1];
	cout<<ans<<'\n';
}


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

int main() {

  int N ;
  cin >> N ;

    vector<int> vec(N) ;
for(int i = 0;i < N ; i++){
    cin >> vec[i] ;
}
    sort(vec.begin(), vec.end());

  int dannsu = N;
for (int i = 0 ; i<N ;i++){
  if ( vec[i] == vec[i+1]){
    dannsu -= 1;
                    }
                           }
    cout << dannsu <<endl;
    
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var cat0 = "mew";
        var s = Console.ReadLine().Trim();
        while (true)
        {
            if (s == cat0) { Console.WriteLine("Cat"); break; }
            var s2 = s.Replace(cat0, "x");
            if (s2.IndexOf("xx") != -1) { Console.WriteLine("Rabbit"); break; }
            var s3 = s2.Replace("x", "");
            if (s3.IndexOf("x") != -1) { Console.WriteLine("Rabbit"); break; }
            if (s == s3) { Console.WriteLine("Rabbit"); break; }
            else s = s3;
        }
    }
}

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

using namespace std;
long long n,a,b;

int main()
{
    ///{}
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    long long n,a;
    cin>>n>>a;
    vector<vector<vector<long long> > >dp(n+5,vector<vector<long long> >(n+5,vector<long long>(3000)));
    vector<long long>v(n);
    for(long long i=0;i<n;i++){
        cin>>v[i];
    }
    dp[0][0][0]=1;
    for(long long i =1;i<=n;i++){
        for(long long j=0;j<=n;j++){
            for(long long k=0;k<3000;k++){
                if(dp[i-1][j][k]){
                    dp[i][j+1][k+v[i-1]]+=dp[i-1][j][k];
                }
                dp[i][j][k]+=dp[i-1][j][k];
            }
        }
    }
    long long ans=0ll;
    for(long long i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<'\n';
    return 0;
}
/**
10
0 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 0
*/


Measured memory_bytes: 75488
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    int r;
    cin >> r;
    if(r < 1200)cout << "ABC";
    else if(r < 2800)cout << "ARC";
    else cout << "AGC";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=305;
string s;
int dL[]={-1,0,1,0};
int dC[]={0,-1,0,1};
int a[2*nmax][2*nmax];
int ss[2*nmax][2*nmax];
int n,m,t,i,j,dist,A1,A2,B1,B2,lim;
long long ans=0;
void conv()
{
    for(j=1;j<=m;j++)
        if(s[j]=='#')
    {
        a[i-j+t][i+j]=1;
    }
}
int abss(int x)
{
    if(x<0) return -x;
    return x;
}
int man(int A1,int B1,int A2,int B2)
{
    return max(abss(A1-A2),abss(B1-B2));
}
bool ok(int A1,int B1)
{
    return (A1>=1&&A1<=2*t&&B1>=1&&B1<=2*t&&a[A1][B1]);
}
int chk(int A,int B,int D,int d1,int d2)
{
    A1=A+dL[d1]*D;B1=B+dC[d1]*D;
    A2=A+dL[d2]*D;B2=B+dC[d2]*D;
    if((!ok(A2,B2))) return 0;
    if(man(A1,B1,A2,B2)!=D)
        return 0;
    return 1;
}
int sum(int A1,int B1,int A2,int B2)
{
    if(A1<=0||A2>2*t) return 0;
    if(B1<=0||B2>2*t) return 0;
    if(A1>A2||B1>B2) return 0;
    return ss[A2][B2]-ss[A2][B1-1]-ss[A1-1][B2]+ss[A1-1][B1-1];
}
void cat(int A,int B,int D)
{
    A1=A-D;B1=B;
    if(ok(A1,B1))
    {
        ans+=1LL*sum(A1+1,B-D,A-1,B-D);
        ans+=1LL*sum(A1+1,B+D,A-1,B+D);
    }
    A1=A;B1=B-D;
    if(ok(A1,B1))
    {
        ans+=1LL*sum(A-D,B1+1,A-D,B-1);
        ans+=1LL*sum(A+D,B1+1,A+D,B-1);
    }
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    t=max(n,m);
    for(i=1;i<=n;i++)
    {
        cin>>s;
        s=" "+s;
        conv();
    }
    for(i=1;i<=2*t;i++)
        for(j=1;j<=2*t;j++)
          ss[i][j]=ss[i-1][j]+ss[i][j-1]-ss[i-1][j-1]+a[i][j];
    for(i=1;i<=2*t;i++)
        for(j=1;j<=2*t;j++)
            if(a[i][j])
    {
        lim=max(max(i,j),max(2*t-i,2*t-j));
        for(dist=1; dist<=lim; dist++)
        {
            for(int i1=0; i1<4; i1++)
               if(ok(i+dL[i1]*dist,j+dC[i1]*dist))
                for(int i2=i1+1; i2<4; i2++)
                    ans+=1LL*chk(i,j,dist,i1,i2);
            cat(i,j,dist);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3200
def main():
	n = int(input())
	sl=[]
	sl=["".join(sorted(input())) for _ in range(n)]
	sl.sort()
	b=sl[0]
	l=1
	ans=0
	for i in range(1,n):
		if sl[i]==b:
			l+=1
			if i==n-1 and l >1:
				ans+=l*(l-1)/2
		else:
			if l>1:
				ans+=l*(l-1)/2
			b=sl[i]
			l=1
	print (int(ans))

main()


Measured memory_bytes: 10640
import itertools

n,m,q = map(int,input().split())
sc = []
for i in range(q):
    a,b,c,d = map(int,input().split())
    sc.append([a,b,c,d])

nums = [(i+1) for i in range(m)]
ans = 0
for balls in itertools.combinations_with_replacement(nums, n):
    tp = 0
    # print(balls)
    for i in range(q):
        if balls[sc[i][1]-1]-balls[sc[i][0]-1] == sc[i][2]:
            tp += sc[i][3]
    if tp > ans:
        ans = tp

print(ans)

Measured memory_bytes: 68132
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A[] = new int[N];
		double interval[] = new double[N-1];
		double length=0;
		for(int i=0;i<N;i++) {
			A[i] = Integer.parseInt(sc.next());
			if(i==0) interval[i] = A[i];
			else if(i!=N-1) interval[i] = interval[i-1] + A[i];
			length += A[i];
		}
		for(int i=0; i<N-1;i++) {
			interval[i] -= length/2;
			if(interval[i]<0) {
				interval[i] = -interval[i];
			}
		}
		Arrays.sort(interval);
		
		int result = (int)(interval[0] * 2);
		
		System.out.println(result);
	}
}

Measured memory_bytes: 63604
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using int_t = double;

double calcBinomLog(int_t n, int_t r) {
    if (r * 2 > n) {
        return calcBinomLog(n, n - r);
    }
    double logBinom = 0.0;
    for (int_t k = r; k >= 1; k--) {
        logBinom += log((double)(n-k)/(double)(r-k));
    }
    return logBinom;
}

vector<int_t>::iterator findBestRItForN(vector<int_t>& Ais, vector<int_t>::iterator& nIt) {
    int_t n = *nIt;
    auto firstItThanNHalf = lower_bound(Ais.begin(), nIt + 1, n/2.0);
    if (firstItThanNHalf == Ais.begin()) {
        return firstItThanNHalf;
    } else if (firstItThanNHalf == nIt) {
        return firstItThanNHalf - 1;
    } else {
        auto prevFirstItThanNHalf = firstItThanNHalf - 1;
        double halfN = n / 2.0;
        if (abs(*firstItThanNHalf - halfN) <= abs(*prevFirstItThanNHalf - halfN)) {
            return firstItThanNHalf;
        } else {
            return prevFirstItThanNHalf;
        }
    }
}

int main() {
    int N;
    scanf("%d", &N);
    vector<int_t> Ais;
    Ais.reserve(N);
    for (int i = 0; i < N; i++) {
        int Ai;
        scanf("%d", &Ai);
        Ais.push_back(Ai);
    }
    sort(Ais.begin(), Ais.end());
    auto bestN = Ais.end() - 1;
    auto bestR = findBestRItForN(Ais, bestN);
    printf("%d %d", (int)(*bestN), (int)(*bestR));
    printf("\n");
    return 0;
}



Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
)

var alphabetList = [26]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "n", "w", "x", "y", "z"}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()
	var idx int

	for i, d := range alphabetList {
		if d == s {
			idx = i
			break
		}
	}

	fmt.Print(alphabetList[idx+1])
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

int N;
ll W, weight[MAX_N], value[MAX_N];

ll dp[MAX_N][MAX_V];

int main() {
	cin >> N >> W;
	for(int i=0; i<N; i++) cin >> weight[i] >> value[i];

	for(int i=0; i<MAX_N; i++) for(int j=0; j<MAX_V; j++) dp[i][j] = INF;

	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
			// i番目の品物を選ぶ場合
			if (sum_v - value[i] >= 0) {
				chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			}
			// i番目の品物を選ばない場合
			chmin(dp[i+1][sum_v], dp[i][sum_v]);
		}
	}

	ll res = 0;
	for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
		if(dp[N][sum_v] <= W) res = sum_v;
	}

	cout << res << endl;
}


Measured memory_bytes: 86272
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main () {
    int a, b, c;
    cin >> a >> b >> c;
    cout << fixed << setprecision(4) << a * b * sin(c * M_PI / 180) / 2 << "\n" << sqrt(a * a + b * b - 2 *a * b * cos(c * M_PI / 180)) + a + b << "\n" << sin(c * M_PI / 180) * b << "\n";
}


Measured memory_bytes: 3612
calc :: (Int, Int, Int, Int) -> Int
calc (a, b, c, x) = sum [1| a'<-[0..a], b'<-[0..b], c'<-[0..c], 500*a'+100*b'+50*c' == x]
                        
main :: IO ()
main = do
  ps <- (,,,) <$> readLn <*> readLn <*> readLn <*> readLn
  print $ calc ps


Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int x,a,b;
	cin >> x >> a >> b;
	x-=a;
	while(x>=b){
		x-=b;
	}
	cout << x << "\n";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
para = [[i for i in map(int,input().split())] for j in range(N)]
para.sort(key=lambda x:x[1])
time = 0 
for i in range(N):
    time += para[i][0]
    if time > para[i][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 41236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  unsigned int D, X, a, b, c, temp, ans;
  
  cin >> D;
  if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }else if(D==24){
    cout << "Christmas Eve" << endl;
  }else if(D==25){
    cout << "Christmas" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;

set <string> s;
int main(){
	int n;
	string str;
	scanf("%d" , &n);
	for(int i = 0 ; i < n ; i++){
		cin>>str;
		s.insert(str);
	}
	printf("%ld\n" , s.size());


}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='I'){
            count++;
        }
        else{
            count--;
        }
        ans=max(ans,count);
    }
    cout << ans << endl;
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
int main(){
int a, b;
cin >> a >> b;
int ans = (a + (b - 1)) / b;
print(ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++){
    L d=I->first;d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33460
#include <bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
 
int main() {
 
    int n;
    cin >> n;

    int ans = n / 2 + n % 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    string s = "keyence", t;

    cin >> t;

    int n = t.size();

    if (t == s) {

        cout << "YES";
        return 0;
    }

    for (int i = 0; i < n; i++) {

        for (int j = i; j < n; j++) {

            string tmp = "";

            for (int k = 0; k < n; k++) {

                if (k >= i && k <= j) continue;

                tmp += t[k];

            }

             if (tmp == s) {

                cout << "YES";
                return 0;
            }
        }
    }

    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,n,z,x;
	a=0;
	scanf("%d",&n);
	b=n;
	char qq[n];
    scanf("%s",qq);
	for(z=0;z<n-1;z++){
		
		if(qq[z]==qq[z+1]){
			   
			   b--;
		}
		
		
	}
	printf("%d",b);
	
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, 0, n) cin >> h[i];
    for (int i = n - 1; i >= 1; i--) {
        if (h[i - 1] > h[i]) h[i - 1]--;
    }
    rep(i, 0, n - 1) {
        if (h[i] - h[i + 1] >= 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, K, ps):
    ps.sort()
    return sum(ps[:K])


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))


Measured memory_bytes: 9452
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    let heights = input.split(/\s/).map(v => +v);
    heights = heights.slice(0, heights.shift());

    let min = heights[0];
    let sum = 0;
    for (const heght of heights) {
        sum += Math.max(0, min - heght);
        min = Math.max(min, heght);
    }
    console.log(sum);
})();


Measured memory_bytes: 58416
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
#define qwq 100007
int n;
int val[qwq];
bool Map[30];
int ans;
int dp[1<<20];
int dfs(int s){
	if(s==0)return 0;
	if(dp[s]!=0x3f3f3f3f)return dp[s];
	for(int i=1;i<=16;++i){
		if(!(s&(1<<i)))continue;
		for(int j=1;j<=16;++j){
			if(i==j)continue;
			if(!(s&(1<<j)))continue;
			int x=i^j;
			if(s&(1<<x))dp[s]=std::min(dp[s],dfs(s^(1<<i)^(1<<j)^(1<<x))+2);
			else dp[s]=std::min(dp[s],dfs(s^(1<<i)^(1<<j)^(1<<x))+1);
		}
	}
	return dp[s];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int a,b,v;
		scanf("%d%d%d",&a,&b,&v);
		++a;++b;
		val[a]^=v;val[b]^=v;
	}
	for(int i=1;i<=n;++i){
		if(val[i]==0)continue;
		if(!Map[val[i]])Map[val[i]]=true;
		else ++ans,Map[val[i]]=false;
	}
	memset(dp,0x3f,sizeof(dp));
	int s=0;
	for(int i=1;i<=16;++i){
		s+=Map[i]<<i;
	}
	printf("%d\n",ans+dfs(s));
	return 0;
} 

Measured memory_bytes: 6196
r,g,b,n = gets.split.map(&:to_i)
box = [r,g,b]
ans = 0
check = [0,0]
while box[0]*check[0] <= n
  while box[0]*check[0]+box[1]*check[1] <= n
    ans += 1 if (n - (box[0]*check[0]+box[1]*check[1]))%box[2] == 0
    check[1] += 1
  end
  check[0] += 1
  check[1] = 0
end
puts ans


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


def main():
    sc = Scan()
    N = sc.intarr()[0]
    T = []
    S = []
    for i in range(N):
        title, sec = sc.strarr()
        S.append(int(sec))
        T.append(title)
    X = sc.strarr()[0]
    idx = -1
    ans = 0
    for i in range(N):
        if idx != -1:
            ans += S[i]
        if T[i] == X:
            idx = i

    print(ans)


def perm(p):
    if len(p) == 1:
        return [p]
    else:
        s = []
        for i in range(len(p)):
            q = p[i]
            r = perm(p[:i]+p[i+1:])
            for t in r:
                s.append([q] + t)
        return s


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()


Measured memory_bytes: 3192
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	fmt.Println(solve(x, y))
}

func solve(x int, y int) int {
	c := 0

	for x <= y {
		x *= 2
		c++
	}

	return c
}


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

int main(){
 int a, b, c, k;
  cin >> a >> b >> c >> k;
  int t =0;
  while(a >=b){
    b *= 2;
    t++;
  }
  while(b >= c){
    c *= 2;
    t++;
  }
  

  if(t <= k ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  }
  
 

Measured memory_bytes: 3612
using System;
    using System.Collections.Generic;
    using static System.Console;
    using System.Linq;


class Program
{

    static void Main(string[] Args) {
        ReadLine();
        var a = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        var renzoku = new List<int>();

        for (int Count = 0; Count < a.Count(); Count++) {
            int tmp = 0;
            int first = a[Count];
            for(tmp = 1; ; tmp++) {
                try {
                    if (a[Count + tmp] != first) break;
                } catch(Exception) { break; }
            }
            Count += tmp - 1;
            renzoku.Add(tmp);
        }

        int Result = 0;

        foreach(int ele in renzoku) {
            if (ele % 2 == 0) Result += ele / 2;
            else Result += (ele - 1) / 2;
        }

        WriteLine(Result);

        ReadLine();
    }
}

Measured memory_bytes: 13396
import math

N = int(input())
PN = list(map(int, input().split()))
QN = list(map(int, input().split()))

def listCount(_list):
    length = len(_list)

    lessList = []
    for i in range(length):
        lessCount = 0
        for j in range(i):
            if _list[i] > _list[j]:
                lessCount += 1
        lessList.append((_list[i] - 1) - lessCount)

    result = 0
    for i in range(length):
        result += (lessList[i]) * math.factorial(length-i-1)

    return result

PNCount = listCount(PN)
QNCount = listCount(QN)
print(abs(PNCount - QNCount))

Measured memory_bytes: 38384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
ll dp[22][1<<22];
int a[22][22];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&a[i][j]);
    for(int i=0;i<n;i++)
    {
        for(int mask = (1<<(i+1))-1;mask<(1<<n);)
        {
         //   dbg2(i,mask);
            for(int j=0;j<n;j++)
            {
                if((mask&(1<<j))&&a[i][j]==1)
                {
                    if(i==0) dp[i][mask]=1;
                    else dp[i][mask]=(dp[i][mask]+dp[i-1][mask-(1<<j)])%Mod;
                }
            }
          //  dbg(dp[i][mask]);
            int tmp=mask & -mask;
            mask = (mask + tmp) | (((mask^(mask+tmp))>>2)/tmp);
        }
    }
    printf("%lld\n",dp[n-1][(1<<n)-1]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 319744
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long 
int N;
int T[13];
bool used[48];
int ans;
std::vector<int> t;
void dfs(int n) {
	if (n == t.size()) {
		int res = 100;
		std::vector<int> copy = t;
		std::sort(copy.begin(), copy.end());
		for (int i = 1; i < copy.size(); i++) {
			res = std::min(res, copy[i] - copy[i - 1]);
		}
		res = std::min(res, copy[0] + 24 - copy[copy.size()-1]);
		ans = std::max(res, ans);
		return;
	}
	if (T[t[n]] == 2) {
		dfs(n + 2);
		return;
	}
	if (t[n] == 12) {
		dfs(n + 1);
		return;
	}
	dfs(n + 1);
	t[n] = 24 - t[n];
	dfs(n + 1);
	t[n] = 24 - t[n];
	return;
}
int main() {
	T[0]++;
	std::cin >> N;
	if (N == 1) {
		int tmp;
		std::cin >> tmp;
		std::cout << tmp << std::endl;
		return 0;
	}
	for (int i = 1; i <= N; i++) {
		int tmp;
		std::cin >> tmp;
		T[tmp]++;
	}
	if (T[0] > 1 || T[12] > 1) {
		std::cout << 0 << std::endl;
		return 0;
	}
	for (int i = 0; i <= 12; i++) {
		if (T[i] >= 1)t.emplace_back(i);
		if (T[i] >= 2)t.emplace_back(24 - i);
		if (T[i] >= 3) {
			std::cout << 0 << std::endl;
			return 0;
		}
	}
	dfs(1);
	std::cout << ans << std::endl;
	return 0;
}

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

const int MN = 501;
int a[MN * MN], mx[MN], ptr, lst[MN];
void add(int v, bool b) {
	while (a[ptr])
		ptr++;
//	cerr << v << 'p' << ptr << 'b' << b << 'l' << lst[v] << endl;
	a[ptr] = v;
	if (!b) {
		if (ptr > lst[v])
			cout << "No\n", exit(0);
	} else
		if (ptr < lst[v])
			cout << "No\n", exit(0);
	ptr++;
}

int main() {
	int n;
	cin >> n;
	pair <int, int> x[MN];
	for (int i = 0; i < n; i++) {
		cin >> x[i].first;
		a[--x[i].first] = i + 1;
		x[i].second = i + 1;
		lst[i + 1] = x[i].first;
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) 
		for (int j = 1; j < x[i].second; j++)
			add(x[i].second, false);
	for (int i = 0; i < n; i++) 
		for (int j = x[i].second; j < n; j++)
			add(x[i].second, true);
	cout << "Yes" << endl;
	for (int i = 0; i < n * n; i++)
		cout << a[i] << endl;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }

  int maxcnt = -(1<<28);
  for(auto s:mp){
    chmax(maxcnt,s.second);
  }

  for(auto s:mp){
    if(s.second==maxcnt)cout<<s.first<<endl;
  }

}

Measured memory_bytes: 25216
#include<iostream>
#include<string>

using namespace std;

int MAX_N = 100;

int main()
{
    // スペース区切りの整数の入力
    int s;
    cin >> s;

    if (s%10==7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    s = s/10;
    if (s%10==7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    s = s/10;
    if (s%10==7)
    {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632