akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long

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

string S;
bool ap[4] = {};

signed main() {
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        switch (S[i]) {
        case 'N':
            ap[0]++;
            break;
        case 'S':
            ap[1]++;
            break;
        case 'W':
            ap[2]++;
            break;
        case 'E':
            ap[3]++;
            break;
        }
    }
    if (ap[0] == ap[1] && ap[2] == ap[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

// 最大公約数を求める
template <typename T>
inline T gcd(T a, T b) noexcept {
  if (a < b) std::swap(a, b);
  while (b > 0) {
    const T tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}

// 公約数は最大公約数の素因数から組み合わせられる値である。（gcd = 2^a * 3^b * 5^c * ...）
// 選ばれる約数は他すべてと互いに素となるので、素因数が重複する値は選べない。（2を選ぶと4や6は選べなくなる）
// 問題とされるのは最大の個数なので、素因数をひとつだけ持つ値を選ぶと良い。（6を選ぶより2と3を選ぶほうが個数が多い）
// ⇒最大公約数の素因数の数を数えれば良い。
//
// Tips:
// - mから素因数由来の要素を取り除くことでループ回数を最適化する
// - AとBは10^12>2^32なので64ビット整数を使う
// - mに素因数iが含まれているかはループの条件式をi^2<=mとして調べれば良い
//   - mに素因数が2つ以上含まれている場合、mはi^2より大きいので、確実に処理できる
//   - mに素因数が1つだけ含まれている場合、
//     - それが二乗以上ならば、mはi^2以上なので、確実に処理できる
//     - そうでなくても、そのmはsqrt(m)以下のiで割り切れないことから素数であることがわかる
int main() {
  uint64_t A, B;
  std::cin >> A >> B;

  // 最大公約数を求める
  uint64_t m = gcd(A, B);

  // 最大公約数の素因数の個数を数える
  if (m == 1) {
    // AとBが互いに素であれば、公約数は1だけしかない
    std::cout << '1';
  } else {
    // 最終的なmが素数であることを判定したいので、i^2<=mを条件として繰り返す
    uint64_t result = 1;  // 1はかならず選ばれるのであらかじめ計上する
    for (uint64_t i = 2; i * i <= m; ++i) {
      // 素因数かどうかを調べる
      if (m % i == 0) {
        result++;

        // mからiの累乗を取り除く
        do {
          m /= i;
        } while (m % i == 0);

        // すべての素因数を取り除いたら終了
        if (m == 1) break;
      }
    }

    // 処理しきれなかった素因数を計上する
    if (m > 1) result++;

    // 結果発表
    std::cout << result;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
const int val= 1e4;
void solve()
{
    int n,cnt=0;
    map<int,int>mp;
    cin>>n;
    for(int i=1;i<101;++i){
        for(int j=1;j<101;++j){
            for(int k=1;k<101;++k)
            {
                int ans=i*i+j*j+k*k+i*j+j*k+k*i;
                if(ans<=val)
                {
                    mp[ans]++;
                }
            }}}
    for(int i=1;i<=n;++i)
    {
        cout<<mp[i]<<"\n";
    }
}

int main()
{
    fast;
    int t;
    solve();
}



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

int n, a, b;
string s;
int main()
{
    cin >> n >> a >> b;
    int ans = 0, abr = 0;
    cin >> s;
    rep(i, 0, n)
    {
        if (s[i] == 'a')
        {
            if (ans < a + b)
            {
                cout << "Yes" << endl;
                ans++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else if (s[i] == 'b')
        {
            if (ans < a + b && abr < b)
            {
                cout << "Yes" << endl;
                abr++;
                ans++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string s ;
  int k , j, count = 0;
  bool ok  = false ;
  char ch = 'a' ;
  vector<string> v ;
  cin >> s >> k ;
  while(count<k){
    for(int i = 0 ;i<s.size() ; i++){
      if(s[i] == ch) {
        ok = true ;
        string new_string ;
        new_string.pb(ch) ;
        v.pb(new_string) ;
        count++ ;
        break ;
      }
    }

    while(ok && count< k){
      char temp = 'z' + 1 ;

      for(int i = 0 ;i<s.size() ;i++){
        j = 0 ;
        if(s[i] == v[count-1][j]){
          int temp2 = i ;
          while(s[temp2] == v[count-1][j]){
            temp2++,j++ ;
          }
          if(j == v[count-1].size()){
            if(s[temp2] < temp)
              temp = s[temp2] ;
          }
        }
      }
      if(temp < 'z' +1){
        string s = v[count-1] + temp ;
        v.pb(s) ;
        count++ ;
      }
      else ok = false ;
    }
    ch = ch + 1 ;
  }

  cout << v[count-1] << endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	c := readInt()
	b := make([]int, m)
	for i := range b {
		b[i] = readInt()
	}
	var ans int
	for i := 0; i < n; i++ {
		a := 0
		for j := 0; j < m; j++ {
			a += readInt() * b[j]
		}
		a += c
		if a > 0 {
			ans++
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.toLowerCase();
var a = input.split('\n');
var W = a[0];
var result = [];
for(var i=1;i<a.length;i++){
    b = a[i].split(' ');
    var count = 0;
    for(var j=0;j<b.length;j++){
        if(b[j] === 'END'){
            break;
        }
        if(b[j] === W){
            count += 1;
            result.push(count);
        }
    }
}
console.log(result.length);



Measured memory_bytes: 15136
import java.util.*;

public class Main {

		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int result = 0;
	        int[] array = new int[5];
	        for(int i = 0; i<5; i++) {
	        	array[i] = sc.nextInt();
	            if(array[i]==0) result = i+1;

	        }





	        System.out.println(result);
	}
}


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int flag_5 = 0;
  int flag_7 = 0;
  
  for(int i = 0; i < 3; i++){
    if(a[i] ==5){
      flag_5++;
    }
    else if(a[i] ==7){
      flag_7++;
    }
  }
  
  if(flag_5 ==2 && flag_7 == 1){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include<stdio.h>
 
int H,W,total=0,maxm=0;
 
char t[1005][1005];
char u[5][5];
char v[]={'J','O','I'};
 
 
int check(int y,int x){
  if(y<0 || x<0)return 0;
  if(y+1>=H || x+1>=W)return 0;
   
  int i,j;
  for(i=0;i<2;i++)
    for(j=0;j<2;j++)
      if(t[y+i][x+j]!=u[i][j])
        return 0;
  return 1;
}
 
int count(int y,int x){
  int i,j,cnt=0;
  for(i=-1;i<=0;i++){
    for(j=-1;j<=0;j++){
      cnt+=check(y+i,x+j);
    }
  }
  return cnt;
}
 
int main(){
  int i,j,k,a,b;
  char tmp;
   
  scanf("%d %d",&H,&W);
  for(i=0;i<H;i++)scanf("%s",t[i]);
  for(i=0;i<2;i++)scanf("%s",u[i]);
   
  for(i=0;i+1<H;i++)
    for(j=0;j+1<W;j++)
      total+=check(i,j);
 
 
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
    
      a=count(i,j);
      tmp=t[i][j];
       
      for(k=0;k<3;k++){
        t[i][j]=v[k];
        b=count(i,j);
        if(maxm<b-a)maxm=b-a;
      }
       
      t[i][j]=tmp;
    }
  }
  printf("%d\n",total+maxm);
  return 0;
}

Measured memory_bytes: 1584
// abc122_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> cumsum(N);
    cumsum[0] = 0;
    REPN(i, 1, N){
        if (S[i-1] == 'A' && S[i] == 'C') {
            cumsum[i] = cumsum[i-1] + 1;
        } else {
            cumsum[i] = cumsum[i-1];
        }
    }


    REP(i, Q){
        int l,r;
        cin >> l >> r;
        l--; r--;
        int ans = cumsum[r] - cumsum[l];
        print(ans);

    }

    return 0;
}



Measured memory_bytes: 1488
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int t[]=new int[N+1];
		int x[]=new int[N+1];
		int y[]=new int[N+1];
		
		boolean f=true;
		
		for(int i=1;i<=N;i++) {
			t[i]=sc.nextInt();
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			
			int a=t[i]-t[i-1];
			int b=x[i]+y[i]-x[i-1]-y[i-1];
			
			int ama=a-b;
			
			if(a<b||ama%2!=0) {
				f=false;
			}
			
			
		}
		if(f)p("Yes");
		else p("No");
		
		
		
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 90144
#include <stdio.h>
int main(){
  int n,a[100],cnt=0,j,flag=1,tmp;

  scanf("%d",&n);

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

  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  }
  
  for(j=0;j<n-1;j++) printf("%d ",a[j]);

  printf("%d\n%d\n",a[n-1],cnt);

  return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
ll get(ll &num, ll &cnt){
    ll v=num;
    ll ret=cnt-1;
    while(v>=10){
        ret+=v/10;
        v=v%10+v/10;
    }
    num=v, cnt=1;
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n),c(n);
    ll ans=0,cnt=0;
    rep(i,n){
        cin>>a[i]>>c[i];
        ans+=a[i]*c[i];
        cnt+=c[i];
    }
    puta(get(ans,cnt));
    // rep(i,n){
    //     cin>>a[i]>>c[i];
    //     ans += get(a[i],c[i]);
    // }
    // puta(ans);
    // rep(i,n)puta(a[i],c[i]);
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;

void dfs(string s, char mx) {
    if(s.size() == N) {
        cout<<s<<endl;
    } else {
        for(char c = 'a'; c <= mx;c++) {
            dfs(s+c,c == mx ? mx+1 : mx);
        }
    }
}
int main(void) {
    cin>>N;

    dfs("",'a');

    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;

int main()
{
	char szStr[100];
	int x;
	cin >> x;


	if (22 == x)
		strcpy(szStr, "Christmas Eve Eve Eve");
	else if (23 == x)
		strcpy(szStr, "Christmas Eve Eve");
	else if (24 == x)
		strcpy(szStr, "Christmas Eve");
	else if (25 == x)
		strcpy(szStr, "Christmas");

	cout << szStr;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var L = new int[M];
            var R = new int[M];
            for (int i = 0; i < M; i++)
            {
                var LR = Console.ReadLine().Split().Select(int.Parse).ToArray();
                L[i] = LR[0];
                R[i] = LR[1];
            }

            var sum = R.Min() - L.Max();
            Console.WriteLine(sum >= 0 ? sum +1: 0);
        }
    }
}


Measured memory_bytes: 17984
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int h,n,a;
  int sum=0;
  cin>>h>>n;
  while(n--){
  	cin>>a;
  	sum+=a;
  }
  if(sum>=h)
  cout<<"Yes";
  else
  cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main() {
    ll n,p;
    cin>>n>>p;
    
    ll ans=1;
    ll k=(ll)sqrt(p)+10;
    for(ll i=2;i<k;i++){
        ll cnt=0;
        if(p%i!=0) continue;
        while(p%(ll)i==0){
            p/=(ll)i;
            cnt++;
        }
        ans*=(ll)pow(i,(cnt/n));
    }
    ans*=(ll)pow(p,(1/n));
    
    cout<<ans<<endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

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

	int p;

	vector<int> num;

	for (int i = 0; i < 301; i++) {
		num.push_back(i - 150);
	}

	for (int i = 0; i < N; i++) {
		cin >> p;
		for (int j = 0; j < 301; j++) {
			if (p == num.at(j)) {
				num.at(j) = -100;
				break;
			}
		}
	}

	int min = 150;
	int min_num;
	for (int i = 0; i < 301; i++) {
		if (abs(X - num.at(i)) < min) {
			min = abs(X - num.at(i));
			min_num = num.at(i);
		}
	}

	cout << min_num << endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	int a,b;
	cin>>a>>b;
	cout<<(a/b)+(a%b!=0);
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mx = 3005 ;
ll grid[3005][3005] ;
ll dp[3005][3005][5] ;

ll r, c, kk;

ll solve(ll i , ll j , ll k) {
	if (i == r || j == c) {
		return 0;
	}
	if (dp[i][j][k] != -1) return dp[i][j][k];
	ll ans  = 0;
	if (grid[i][j] ==  0) {
		ans = max(solve(i + 1, j, 0) , solve(i, j + 1, k));
	} else {
		ll value = grid[i][j];
		if (k < 3) {
			ans = max(ans , value + solve(i, j + 1, k + 1));
			ans = max(ans , value + solve(i + 1, j, 0));
		}
		ans = max(ans , solve(i, j + 1, k));
		ans = max(ans , solve(i + 1, j, 0));
	}
	return dp[i][j][k] =  ans;
}


ll _solve(ll i , ll j , ll k) {
	if (i == r || j == c) {
		return 0;
	}
	if (dp[i][j][k] != -1) return dp[i][j][k];
	ll ans  = 0;
	ll value = grid[i][j];
	if (k < 3) {
		ans = max(ans , value + solve(i, j + 1, k + 1));
		ans = max(ans , value + solve(i + 1, j, 0));
	}
	ans = max(ans , solve(i, j + 1, k));
	ans = max(ans , solve(i + 1, j, 0));

	return dp[i][j][k] =  ans;
}


int main() {
	memset(dp, -1, sizeof(dp));
	cin >> r >> c >> kk;
	for (ll i = 0; i < kk; i++) {
		ll x, y;
		cin >> x >> y;
		ll val;
		cin >> val;
		grid[x - 1][y - 1] = val;
	}
	cout << _solve(0, 0, 0) << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

ll n;
vvll co;
vvll exist;

void update(ll x, ll y) {
  ll new_cost = co[y][x];

  queue<P> que;
  if (x > 0) {
    que.emplace(x - 1, y);
  }
  if (x < n - 1) {
    que.emplace(x + 1, y);
  }

  if (y > 0) {
    que.emplace(x, y - 1);
  }
  if (y < n - 1) {
    que.emplace(x, y + 1);
  }

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    ll x = p.first;
    ll y = p.second;
    if (exist[y][x]) {
      chmin(new_cost, co[y][x] + 1);
    } else {
      chmin(new_cost, co[y][x]);
    }
  }

  ll current_cost = co[y][x];
  co[y][x] = new_cost;

  que.emplace(x, y);
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    ll x = p.first;
    ll y = p.second;
    ll c = co[y][x];

    if (exist[y][x]) {
      c = co[y][x] + 1;
    }

    if (x + 1 < n && c < co[y][x + 1]) {
      co[y][x + 1] = c;
      que.emplace(x + 1, y);
    }
    if (x - 1 > 0 && c < co[y][x - 1]) {
      co[y][x - 1] = c;
      que.emplace(x - 1, y);
    }

    if (y + 1 < n && c < co[y + 1][x]) {
      co[y + 1][x] = c;
      que.emplace(x, y + 1);
    }
    if (y - 1 > 0 && c < co[y - 1][x]) {
      co[y - 1][x] = c;
      que.emplace(x, y - 1);
    }
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cin >> n;

  vll p(n * n);
  rep(i, n * n) {
    cin >> p[i];
  }

  co = vvll(n, vll(n, INF));
  exist = vvll(n, vll(n, 1));

  rep(y, n) {
    rep(x, n) {
      chmin(co[y][x], y);
      chmin(co[y][x], n - 1 - y);
      chmin(co[y][x], x);
      chmin(co[y][x], n - 1 - x);
    }
  }

  ll ans = 0;
  for (ll it : p) {
    it--;
    ll x = it % n;
    ll y = it / n;
    ll c = co[y][x];
    ans += c;
    exist[y][x] = 0;
    update(x, y);
  }

  cout << ans << endl;

  return 0;
}


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

int n;
int k[10000];

int main()
{
	while (scanf("%d", &n), n){
		memset(k, 0, sizeof(k));
		
		for (int i = 0; i < n; i++){
			scanf("%d", k + i);
		}
		
		int sum = 0;
		int maxi = 0;
		for (int i = 0; i < n; i++){
			sum += !!k[i];
			maxi = max(maxi, k[i]);
		}
		
		if (maxi <= 1) puts("NA");
		else printf("%d\n", sum + 1);
	}
}

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

#define INF (1LL<<60)

int main(){
	int n;	cin>>n;
	vector<long long> a(n);	for(int i=0;i<n;i++)cin>>a[i];

	for(int i=1;i<n;i++)a[i]+=a[i-1];
	long long sum=a[n-1];

	long long ans=INF;
	for(int i=0;i<n;i++){
		long long X=a[i];
		long long Y=sum-a[i];

		ans=min(ans,abs(X-Y));
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
#include <ctime>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d", &(x))

#define eps 1e-8
#define mod 1000000007

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int a, b, c;

int main() {
    cin >> a >> b >> c;
    cout << (a ^ b ^ c);

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  ll a[3];
  REP(i, 3) a[i] = nextInt();
  int k = nextInt();
  sort(a, a+3);
  REP(i, k) a[2] *= 2;
  cout << accumulate(a, a+3, 0LL) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int n;
int main(){
    ll ans = 0;
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i<n;i++){
        cin >> v[i];
    }
    for(int i = 1;i<n;i++){
        if(v[i]< v[i-1]) {
            ans += (v[i-1] - v[i]);
            v[i] = v[i-1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4048
def gcd(a,b):
    if b > a:
        a,b = b,a
    if b== 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a = list(map(int,input().split()))
lcm = 0
ans = 0
for i in range(1,len(a)):
    if i == 1:
        lcm = (a[0]*a[1]) // gcd(a[0],a[1])
    else:
        lcm = (lcm*a[i]) // gcd(lcm,a[i])
for i in range(0,len(a)):
    ans += (lcm-1)%a[i]
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
using namespace std;
int alignment(string s,string t){


	int a[1001][1001];
	int n=s.size();
	int m=t.size();
	a[0][0]=0;
	for(int i=0;i<n;i++){
		a[i+1][0]=a[i][0]+1;
	}
	for(int i=0;i<m;i++){
		a[0][i+1]=a[0][i]+1;
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i]==t[j]){
				a[i+1][j+1]=min(a[i][j],min(a[i+1][j]+1,a[i][j+1]+1));
			}else{
					a[i+1][j+1]=min(a[i][j]+1,min(a[i+1][j]+1,a[i][j+1]+1));
			}
		}
	}
	return a[n][m];
}

int main(void){

	string s;
	string t;
	cin >> s >> t;
	cout << alignment(s,t) <<endl;
	
}


Measured memory_bytes: 7068
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;


int main(){
        int N,j=0;
        cin >> N;
        vector <int> a(N),b(N);
        for(int i=0; i<N; i++) {
                cin >> a[i];
        }
        for(int i=N; i>N/2; i--) {
                b[N-i]=a[N-j-1];
                j++;
                b[i-1]=a[N-j-1];
                j++;
        }
        if(N%2==1) {
                b[N/2]=a[0];
        }

        for(int i=0; i<N; i++) {
                cout << b[i] << ' ';
        }
        cout << endl;

        return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  int M = max(H,W);
  cout << ceil((double)N/M) << endl;
}
  

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


Measured memory_bytes: 1664
# D - Cake 123

import heapq
import itertools
from collections import defaultdict

x, y, z, k = map(int, input().split())

A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

hq = []
hqAns = []
d = defaultdict(int)

heapq.heappush(hq, ((A[0]+B[0]+C[0])*-1, 0, 0, 0))
d[(0,0,0)] = 1

while len(hqAns)<k :
    val, l, m, n = heapq.heappop(hq)
    heapq.heappush(hqAns, val)
 
    if d[(l+1, m, n)]==0 and l+1 < x:
        heapq.heappush(hq, ((A[l+1]+B[m]+C[n])*-1, l+1, m, n))
        d[(l+1, m, n)] = 1

    if d[(l, m+1, n)]==0 and m+1 < y:
        heapq.heappush(hq, ((A[l]+B[m+1]+C[n])*-1, l, m+1, n))
        d[(l, m+1, n)] = 1
 
    if d[(l, m, n+1)]==0 and n+1 < z:
        heapq.heappush(hq, ((A[l]+B[m]+C[n+1])*-1, l, m, n+1))
        d[(l, m, n+1)] = 1

for i in range(k):
    print(heapq.heappop(hqAns)*-1)

'''
# ans.2 #

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

hq = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i+1)*(j+1)*(l+1)<=k:
                heapq.heappush(hq, (A[i]+B[j]+C[l])*-1)
            else:
                break

for _ in range(k):
    print(heapq.heappop(hq)*-1)

'''

'''

# ans.1 #

hq = []
for i, j in itertools.product(A, B):
    heapq.heappush(hq, (i+j)*-1)

AB = []
while len(hq)>0 and len(AB)<=k:
    AB.append(heapq.heappop(hq)*-1)

hq = []
for i, j in itertools.product(AB, C):
    heapq.heappush(hq, (i+j)*-1)

for _ in range(k):
    print(heapq.heappop(hq)*-1)

'''


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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 10000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

int a[mx];
map<int,int>odd,even;
vector<pair<int,int> >o,e;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];

    for(int i=1;i<=n;i++)
    {
        if(i%2==0)even[a[i]]++;
        else odd[a[i]]++;
    }

    for(auto v:even)
    {
        e.push_back({v.second,v.first});
    }    
    
    for(auto v:odd)
    {
        o.push_back({v.second,v.first});
    }

    sort(e.begin(),e.end(),greater<>());
    sort(o.begin(),o.end(),greater<>());

    if(e.size()==1)
       e.push_back({0,mx+1});
    if(o.size()==1)
       o.push_back({0,mx+2});
    int ans=0;   
    if(e[0].second==o[0].second)
    {
        ans=max(e[0].first+o[1].first,e[1].first+o[0].first);
    }
    else
        ans=e[0].first+o[0].first;
    cout<<n-ans<<"\n";          
    return 0;
}


Measured memory_bytes: 6524
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

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

int main() {
    while (true) {
        int N;

        cin >> N;
        if (!N) { break; }

        vector<P> ps;
        ps.push_back(make_pair(0, 0));
        for (int i = 1; i < N; i++) {
            int n, d;
            cin >> n >> d;
            int x = ps[n].first + dx[d];
            int y = ps[n].second + dy[d];
            ps.push_back(make_pair(x, y));
        }

        int x_max, x_min, y_max, y_min;
        x_max = y_max = -10000000;
        x_min = y_min = 10000000;
        for (int i = 0; i < N; i++) {
            x_max = max(x_max, ps[i].first);
            x_min = min(x_min, ps[i].first);
            y_max = max(y_max, ps[i].second);
            y_min = min(y_min, ps[i].second);
        }

        cout << (x_max - x_min + 1) << " " << (y_max - y_min + 1) << endl;
    }
    return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

vector<int> v[101010];
int c[101010];

int f(int x)
{
    int r = 0;
    vector<int> tt;
    for(int y : v[x])
    {
        tt.pb(f(y));
    } sort(all(tt)); reverse(all(tt));

    for(int i=0; i<tt.size(); i++)
    {
        r = max(r, tt[i]+i+1);
    }

    return r;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n; in >> n;
    REPE(i, 2, n)
    {
        int x; in >> x;
        v[x].pb(i);
        c[x]++;
    }

    out << f(1) << endl;

    return 0;
}


Measured memory_bytes: 13952
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int N;

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double maxPercent = 0.0;
    int maxSugarWater = 100 * A, maxSugar = 0;
    // ありうる組み合わせを全探索する
    // 高々30^4=O(10^5)
    for (int a = 0; 100 * A * a <= F; ++a)
    {
        for (int b = 0; 100 * A * a + 100 * B * b <= F; ++b)
        {
            int water = 100 * A * a + 100 * B * b;
            for (int c = 0; water + C * c <= F; ++c)
            {
                for (int d = 0; water + C * c + D * d <= F; ++d)
                {
                    int sugar = C * c + D * d;
                    if (sugar <= water / 100 * E)
                    {
                        double percent = 100.0 * static_cast<double>(sugar)
                            / static_cast<double>(water + sugar);
                        if (percent > maxPercent)
                        {
                            maxPercent = percent;
                            maxSugarWater = water + sugar;
                            maxSugar = sugar;
                        }
                    }
                }
            }
        }
    }
    cout << maxSugarWater << ' ' << maxSugar << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NMAX 500
#define MMAX 50000
struct edge {
  int a;
  int b;
  int weight;
};
int ufp[NMAX], ufr[NMAX], etsize;
struct edge ed[MMAX], et[MMAX];

int compare(const void*, const void*);
void UF_init(int);
int UF_find(int);
void UF_union(int, int);
int Kruskal(int, int);

int main(void)
{
  int i, j, v, e, s, t, w, cost, tcost, eans = 0, cans = 0;
  scanf("%d %d", &v, &e);
  UF_init(v);
  for (i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &w);
    ed[i].weight = w;
    ed[i].a = s - 1;
    ed[i].b = t - 1;
  }
  qsort(ed, e, sizeof(struct edge), compare);
  cost = Kruskal(v, e);
  for (i = 0; i < etsize; i++) {
    UF_init(v);
    tcost = 0;
    for (j = 0; j < e; j++) {
      int jea = UF_find(ed[j].a), jeb = UF_find(ed[j].b);
      if (jea != jeb && !(et[i].a == ed[j].a && et[i].b == ed[j].b)) {
        UF_union(jea, jeb);
        tcost += ed[j].weight;
      }
    }
    if (cost != tcost) {
      eans++;
      cans += et[i].weight;
    }
  }
  printf("%d %d\n", eans, cans);
}

int compare(const void *a, const void *b)
{
  int wa = ((struct edge*)a)->weight, wb = ((struct edge*)b)->weight;
  return wa - wb;
}

void UF_init(int v)
{
  int i;
  for (i = 0; i < v; i++) {
    ufp[i] = i;
    ufr[i] = 0;
  }
}

int UF_find(int a)
{
  if (ufp[a] == a) return a;
  else {
    ufp[a] = UF_find(ufp[a]);
    return ufp[a];
  }
}

void UF_union(int a, int b)
{
  if (ufr[a] < ufr[b]) ufp[a] = b;
  else {
    ufp[b] = a;
    if (ufr[a] == ufr[b]) ufr[a]++;
  }
}

int Kruskal(int size, int esize)
{
  int i, selected = 0, cost = 0;
  for (i = 0; i < esize; i++) {
    int ea = UF_find(ed[i].a), eb = UF_find(ed[i].b);
    if (ea != eb) {
      UF_union(ea, eb);
      cost += ed[i].weight;
      et[etsize++] = ed[i];
      selected++;
    }
    if (selected == size - 1) break;
  }
  return cost;
}


Measured memory_bytes: 2720
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ld a,b,h,w;
    static const double pi = 3.141592653589793;
    cin>>a>>b>>h>>w;
    ld dis=abs(h*30+w*(0.5)-w*6);
    dis=min({360-dis,dis});
   // cout<<dis<<endl;
   // cout<<dis/180.00*pi<<endl;
    cout<<sqrt(a*a+b*b-2*a*b*cos(dis/180.00*pi))<<endl;
}


Measured memory_bytes: 4188
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
int const mod = 1e9+7;
#define END {cout<<(ans)<<'\n'; return 0;}
#define ALL(vec) vec.begin(),vec.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,s,n) for(int i=s; i<n; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,(n)-1)cout<<a[i]<<' '; cout<<a[(n)-1]<<'\n';
#define prip(p) cout<<(p).first<<' '<<(p).second<<'\n'
template<class T> inline bool cmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool cmax(T& a, T b) { if (a < b) { return a = b; } return false; }
 
int n,m,q,_,x,y;
string s,sb;
bool ok;
char ch;
 
int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
 
  cin>>n; unordered_map<int,bool>a;
  rep(i,n){cin>>x; a[x]=1;}
  cin>>m; int ans=0;
  rep(i,m){cin>>x; ans+=a[x];}
  END
}


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

#define ll long long

int P[100001];

int main() {
    ll n,a,q,b,c;
    cin >> n;
    ll zb=0;
    for (int i=0; i<n; i++) {
        cin >> a;
        P[a]++;
        zb+=a;
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        cin >> b >> c;
        zb=zb-(P[b]*b)+(P[b]*c);
        P[c]+=P[b];
        P[b]=0;
        cout << zb << endl;
    }
}


Measured memory_bytes: 4000
'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const d = args.slice(1, n + 1).map(arg => parseInt(arg, 10))
	let before = 101
	let cnt = 0

	for (let i = 0; i < n; i++) {
		let _max = 0

		for (let j = 0; j < n; j++) {
			if (d[j] < before) {
				_max = Math.max(_max, d[j])
			}
		}

		if (_max > 0) {
			before = _max
			cnt++
		}
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll A, B;
    cin >> A >> B;

    if (A > B) swap(A, B);

    if (A == B) {
        print(0);
        return 0;
    } else {
        if (~(A + B) & 1) {
            ll k = (A + B) / 2;
            if (A <= k && k <= B) {
                print(k);
                return 0;
            }
        }
    }

    print("IMPOSSIBLE");
    
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
inline void getInt(int* p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
std::vector<int> v[maxn];
int n;
int vis[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    gbtb;
    cin >> n;
    int a, b;
    repd(i, 2, n)
    {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vis[1] = 1;
    vis[n] = 1;
    int cntf = 0;
    int cnts = 0;
    queue<pii> q;
    q.push(mp(1, 0));
    q.push(mp(n, 1));
    pii temp;
    int flag = 1;
    while (!q.empty())
    {
        temp = q.front();
        if (temp.se == flag)
        {
            q.pop();
        } else
        {
            flag = !flag;
            continue;
        }
        for (auto x : v[temp.fi])
        {
            if (!vis[x])
            {
                vis[x] = 1;
                q.push(mp(x, flag));
                if (!flag)
                {
                    cntf++;
                } else {
                    cnts++;
                }
            }
        }
    }
    if (cntf > cnts)
    {
        cout << "Fennec" << endl;
    } else 
    {
        cout << "Snuke" << endl;
    }
    // db(cntf);
    // db(cnts);
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 29312
abc = gets.chop.split.map(&:to_i)
abc.sort!

diff21 = abc[2] - abc[1]
diff10 = abc[1] - abc[0]
if diff10.odd?
  count = diff21 + (diff10 + 1) / 2 + 1
else
  count = diff21 + diff10 / 2
end

puts count


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

int main() {
  int h, n;
  cin >> h >> n;
  while ( n-- > 0 ) {
    int a;
    cin >> a;
    h -= a;
  }
  string ans = ( h <= 0 ) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600