akhauriyash/Code-Regression huggingface dataset:
/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/

#define VERNIY st();int ver=0,niy=0,hbk=0

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vpLL vector<pair<long long int,long long int>>
#define vLLU vector<unsigned long long int>
#define vpLLU vector<pair<unsigned long long int,unsigned long long int>>
#define pd pair<int,int>
#define pLL pair<long long int,long long int>
#define pLLU pair<unsigned long long int,unsigned long long int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define maxpqd priority_queue<int>
#define minpqd priority_queue<int, vector<int>, greater<int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein freopen("in.txt","r",stdin);
#define fileout freopen("out.txt","w",stdout);
#define setarr(a,b,c) memset(a,b,sizeof(c))

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}
inline void scllu(LLU &a){scanf("%I64u",&a);}
inline void scdllu(LLU &a,LLU &b){scanf("%I64u %I64u",&a,&b);}
inline void sctllu(LLU &a,LLU &b,LLU &c){scanf("%I64u %I64u %I64u",&a,&b,&c);}

template<class Ver>
inline void prd(Ver a){cout<<a<<"\n";};
template<class Ver>
inline void prdd(Ver a,Ver b){cout<<a<<" "<<b<<"\n";};
template<class Ver>
inline void prtd(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){printf("asd\n");}
template<class Ver>
inline void debugd(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debugdd(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debugtd(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
	int a[5];
	forin(i,0,3)
	scd(a[i]);
	sort(a,a+3);
	prd(a[0]+a[1]);
	

	return 0;
}

/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    //next_permutationで全探索
    V a(5);rep(i,5)cin>>a[i];
    V p(5);
    iota(ALL(p),0);
    int ans=inf;
    do{
        //p=01234
        int tmp=0;
        for(int i=0;i<5;i++){
            //printf("%d ",p[i]);
            tmp+=a[p[i]];
            if(i<4){
                tmp+=(10-a[p[i]]%10)%10;
            }
        }
        //cout<<endl;
        ans=min(ans,tmp);
    }while(next_permutation(ALL(p)));
    cout<<ans<<endl;
}



Measured memory_bytes: 256
import io.Source.stdin

object Main {

  def main(args: Array[String]) {
    for ((list) <- stdin.getLines().takeWhile(_ != "0 0").map(_.split(" ").map(_.toInt))) {
      val (h: Int, w: Int) = (list(0), list(1))
      printFrame(h, w)
    }
  }

  def printFrame(h: Int, w: Int) {
    for (i <- 1 to h) {
      for (j <- 1 to w) {
        printChar(isEdge(h, w, i, j))
      }
      println()
    }
    println()
  }
  
  def printChar(isEdge: Boolean) {
    if (isEdge) {
      print("#")
    } else {
      print(".")
    }
  }
  
  def isEdge(h: Int, w: Int, i: Int, j: Int): Boolean = {
    if (i == 1 || j == 1 || i == h || j == w) {
      true
    } else {
      false
    }
  }
}


Measured memory_bytes: 55464
import heapq

n = int(input())
edges = [None] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edges[l[0]] = set((c, j) for j, c in (l[i:i + 2] for i in range(2, l[1] * 2 + 2, 2)))

min_costs = [0] * n
visited = [False] * n
visited[0] = True
queue = list(edges[0])
heapq.heapify(queue)

while queue:
    total_cost, vertex = heapq.heappop(queue)
    if visited[vertex]:
        continue
    visited[vertex] = True
    min_costs[vertex] = total_cost
    for cost, vertex2 in edges[vertex]:
        if not visited[vertex2]:
            heapq.heappush(queue, (total_cost + cost, vertex2))

for r in enumerate(min_costs):
    print(*r)

Measured memory_bytes: 121888
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var map = new int[n + 1].Select(_ => new List<int>()).ToArray();
		foreach (var r in new int[n - 1].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()))
		{
			map[r[0]].Add(r[1]);
			map[r[1]].Add(r[0]);
		}

		var tour = new int[n + 1].Select(_ => new List<int>()).ToArray();
		var c = 0;
		var q = new Stack<int>();
		var parents = new Stack<int>();
		var u = new bool[n + 1];

		q.Push(1);
		parents.Push(0);
		while (q.Any())
		{
			var p = q.Peek();
			if (!u[p])
			{
				u[p] = true;
				var p0 = parents.Peek();
				if (p != 1) tour[p0].Add(++c);
				foreach (var x in map[p])
				{
					if (x == p0) continue;
					q.Push(x);
				}
				parents.Push(p);
			}
			else
			{
				if (p != 1) tour[p].Add(++c);
				q.Pop();
				parents.Pop();
			}
		}

		Console.WriteLine((tour.Select(l => Hole(l, n - 1)).Aggregate((x, y) => x + y) / 2).V);
	}

	static MInt Hole(List<int> l, int m)
	{
		if (l.Count < 2) return 0;

		MInt allWhite = 1, bSum = 0;
		for (int i = 0; i < l.Count; i++)
		{
			var c = ((l[(i + 1) % l.Count] - l[i]) / 2 + m) % m;
			var w = 1 / ((MInt)2).Pow(c);

			allWhite *= w;
			bSum += 1 / w - 1;
		}
		return 1 - allWhite * (1 + bSum);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 62484
#include <iostream>
using namespace std;
int h, w, a[55][55];
string s;
int main() {
	int i, j;
	cin>>h>>w;
	for(i=1; i<=h; i++) {
		cin>>s;
		for(j=1; j<=w; j++) a[i][j] = s[j-1]=='#';
	}
	for(i=1; i<=h; i++) for(j=1; j<=w; j++)
		if(a[i][j] && !(a[i-1][j] + a[i+1][j] + a[i][j-1] + a[i][j+1])) {cout<<"No"; return 0;}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	while(n) 
	{
		if(n % 10 == 2) ++ans;
		n /= 10;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	if (n <= 20) {
		for (int i = 0; i < n; i++) {
			cout << i << endl;
			string s;
			cin >> s;
			if (s == "Vacant") {
				break;
			}
		}
		return 0;
	}
	int l = 0, r = n;
	bool chair;
	{
		cout << l << endl;
		string s;
		cin >> s;
		if (s == "Vacant") {
			return 0;
		}
		chair = s == "Male";
	}
	for (int puni = 0; puni < 20; puni++) {
		int mid = (l + r) / 2;
		assert(0 <= mid && mid < n);
		int len = mid - l;
		cout << mid << endl;
		string s;
		cin >> s;
		if (s == "Vacant") {
			return 0;
		}
		bool i_state = s == "Male";
		if ((len % 2) == (chair != i_state)) {
			// [l, mid]には含まれていない
			l = mid;
			chair = i_state;
		} else {
			// [l, mid]に含まれている
			r = mid + 1;
		}
	}
	assert(false);
	return 0;
}

Measured memory_bytes: 852
import heapq
N=int(input())
ab=[list(map(int,input().split())) for _ in range(N)]
sab=[[-ab[i][0]-ab[i][1],i] for i in range(N)]
heapq.heapify(sab)

ans=0
for i in range(N):
  if i%2==0:
    ind=heapq.heappop(sab)[1]
    ans+=ab[ind][0]
  else:
    ind=heapq.heappop(sab)[1]
    ans-=ab[ind][1]
    
print(ans)

Measured memory_bytes: 41076
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0]:
            if j+m <= n and i+m <= n:
                if [a[i+k][j:j+m] for k in range(m)] == b:
                    print('Yes')
                    exit()
else:
    print('No')


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

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

    vector<int> x(N);
    vector<int> y(M);

    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < M; i++) cin >> y[i];

    int maxX = *max_element(x.begin(), x.end());
    int minY = *min_element(y.begin(), y.end());

    int Z = maxX + 1;
    if(Z > X && Z <= Y && Z <= minY) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int a[4];

int main() {/*

	scanf("%d%d%d", &a[0],&a[1],&a[2]);

	sort(a, a + 3);

	if(a[0] + a[1] > a[2]) printf("Yes\n");
	else printf("No\n");

	return 0;*/
	scanf("%d%d%d", &a[0], &a[1], &a[2]);

	if (a[0] == a[1] && a[1] == a[2]) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    string f;
    bool reversed = false;
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
        } else {
            int p;
            char c;
            cin >> p >> c;
            if (reversed) {
                if (p == 2) {
                    f += c;
                } else {
                    s += c;
                }
            } else {
                if (p == 2) {
                    s += c;
                } else {
                    f += c;
                }
            }
        }
    }
    /* watch(f);
    watch(s); */
    reverse(f.begin(), f.end());
    s = f + s;
    if (reversed) {
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1196
#include <stdio.h>
const int N =305;
const int M =305;
int main()
{
	int m, n;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0; i < m ; i++)
			{
				printf("#");
			}
		printf("\n");
		
		for(int i = 0; i < n - 2 ; i++)
		{
			printf("#");
			for(int j = 0; j < m - 2 ; j++)
			{
				printf(".");
			}
			printf("#");
			printf("\n");
		}
	
		for(int i = 0; i < m ; i++)
			{
				printf("#");
			}
			printf("\n\n");
			
	}
}


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

int main(){
  int n;
  cin >> n;
  int Bstart = 0, Aend = 0, BandA = 0;
  int ans = 0;
  for(int i=0; i<n; ++i){
    string s;
    cin >> s;
    if(s[0] == 'B' && s[s.size()-1] == 'A') ++BandA;
    else if(s[0] == 'B') ++Bstart;
    else if(s[s.size()-1] == 'A') ++Aend;
    
    for(int i=0; i<s.size()-1; ++i){
      if(s[i] == 'A' && s[i+1] == 'B') ++ans;
    }
  }
  ans += min(Aend + BandA, BandA + Bstart);
  if(Aend == 0 && Bstart == 0 && BandA != 0) --ans;
  cout << ans << endl;
}

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

typedef long long int ll;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

        ll c = 0;
        for(ll i=1;i<=n;i++){
            if(arr[i-1]!=i){
                if(arr[arr[i-1]-1]==i){
                    c++;
                    swap(arr[i-1],arr[arr[i-1]-1]);
                }
                else{
                    cout<<"NO";return 0;
                }
            }
        }

        if(c<=1){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }



}


Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val a = int()
    val s = string()
    println(if (a >= 3200) s else "red")
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 29468
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)
cnt = 1
for i in 1..n-1
  visible = true
  for j in 0..i-1
    if h[i] < h[j]
      visible = false
    end
  end
  cnt += 1 if visible
end
puts cnt

Measured memory_bytes: 14272
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define f1 first
#define s1 second
#define N 1005
using namespace std;
 
void boost()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

 
int main(void){
    boost();
    ll n;
    cin>>n;
    vi v(n);
    rep(i,0,n)
        cin>>v[i];
    ll a[n][n];
    rep(i,0,n)
        a[i][i] = v[i];
    ll j;
    for ( int d1 = 2 ; d1 <= n ; d1++){
        for ( int i = 0; i < n - d1 + 1; i++){
            j = i + d1 - 1;
            if (d1 == 2){
                a[i][j] = abs(v[i] - v[j]);
                a[j][i] = abs(v[i] - v[j]);
            }
            else{
                a[i][j] = max(v[i] - a[i+1][j] , v[j] - a[i][j-1]); 
                a[j][i] = max(v[i] - a[i+1][j] , v[j] - a[i][j-1]); 
            }
        }
    }
    cout<<a[0][n-1];
    // rep(i,0,n){
    //     rep(j,0,n)
    //         cout<<a[i][j]<<" ";
    //     cout<<"\n";
    // }
}

Measured memory_bytes: 70656
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

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

typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef long double           ldb;
const   ll   N = 2e5+5;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         nel            printf("\n");
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n";
#define         no             cout<<"NO"<<"\n";
#define         pb             push_back
#define         pii            pair< ll , ll >
#define         ppi            pair< pii , ll >
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int fact(int n)
{
   if(n==0)
      return(1);

   return(n*fact(n-1));
}
int prm(ll n)
{
    ll j=0;
    while (n % 2 == 0)
    {
        j++;
        n = n/2;
    }


    for (ll i = 3; i*i <= n ; i = i + 2)
    {
        while (n % i == 0)
        {
           j++;
            n = n/i;
        }
    }

    if (n > 2)
        j++;

    return j;
}

int main(){Faysal

    int ans,cnt,sum,mx,mn,chk;

    int n,q,a,b,x,y,i,j,k;

    cin>>n>>a;

    if(n%a==0)
        ans=n/a;
    else
        ans=(n/a)+1;
    cout<<ans<<'\n';
    return 0;

}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <limits>
using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  double prob = 0.;
  if (K - 1 < N)
    prob = N - (K - 1);
  for (int i = 1, _i = ((K - 1 < N) ? K - 1 : N); i <= _i; ++i)
  {
    auto j = i;
    double p = 1.;
    for (; ; )
    {
      j <<= 1;
      p *= .5;
      if (K <= j)
        break;
    }
    prob += p;
  }
  cout << setprecision(numeric_limits<double>::max_digits10) << prob/N;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m;
	while(true){
		cin>>n>>m;
		if(n==0&&m==0)
			break;
		int b[100]={0};
		int a,c;
		int best=0;
		for(int i=0;i<n;i++){
			cin>>a;
			for(int j=0;j<a;j++){
				cin>>c;
				b[c]++;
				if(best<b[c])
					best=b[c];
			}
		}
		if(best<m)
			cout<<"0"<<endl;
		else{
		int i=0;
		while(true){
			if(best==b[i]){
				cout<<i<<endl;
				break;
			}
			i++;
		}
		}
	}
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

int N; cin >> N;
VI a(N); invec(a);

cout << (all_of(ALL(a), [](int i){return i%2 == 0;}) ? "second\n" : "first\n");

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    vector<string > vec(h);
    int black=0;
    vector<pair<int,int> > pos;
    for(int i=0;i<h;i++)
    {
         cin>>vec[i];
        for(int j=0;j<w;j++)
        {
           
            if(vec[i][j]=='#') {black++;
            }
        }
    }
    int ans=0;
    int mask1,mask2;
    mask1=(1<<h)-1;
    mask2=(1<<w)-1;
   // cout<<black<<endl;
 // cout<<mask1<<mask2<<endl;
 int f=0;
    for(int i=mask1;i;i=(i-1)&(mask1))
    {
        for(int j=mask2;j;j=(j-1)&(mask2))
        {
            if(i==mask1||j==mask2)
            {
               // if(!f&&black==k) {ans++;f=1;}
                continue;
            }

             vector<vector<int> > vis(h,vector<int>(w,0));
            int cnt=0;

            for(int i1=0;i1<h;i1++)
            {
                if(i&(1<<i1))
                {
                     for(int j1=0;j1<w;j1++)
                     {
                         if(vec[i1][j1]=='#'&&!vis[i1][j1])
                         {
                             cnt++;
                             vis[i1][j1]=1;
                         }
                     }
                }

            }
         //   cout<<cnt<<endl;
           int cnt1=0;
            for(int i1=0;i1<w;i1++)
            {
                if(j&(1<<i1))
                {
                     for(int j1=0;j1<h;j1++)
                     {
                         if(vec[j1][i1]=='#'&&!vis[j1][i1])
                         {
                             cnt1++;
                             vis[j1][i1]=1;
                         }
                     }
                }

            }
          //  cout<<cnt1<<endl;
            if(black-(cnt+cnt1)==k) {ans++;}
        }
    }
    for(int i=mask1;i;i=(i-1)&(mask1))
    {
         int cnt=0;

            for(int i1=0;i1<h;i1++)
            {
                if(i&(1<<i1))
                {
                     for(int j1=0;j1<w;j1++)
                     {
                         if(vec[i1][j1]=='#')
                         {
                             cnt++;
                             //vis[i1][j1]=1;
                         }
                     }
                }

            }
            if(black-cnt==k) ans++;

    }



     for(int j=mask2;j;j=(j-1)&(mask2))
     {
          int cnt1=0;
            for(int i1=0;i1<w;i1++)
            {
                if(j&(1<<i1))
                {
                     for(int j1=0;j1<h;j1++)
                     {
                         if(vec[j1][i1]=='#')
                         {
                             cnt1++;
                             //vis[j1][i1]=1;
                         }
                     }
                }

            }
            if(black-cnt1==k) ans++;
     }
    if(black==k) ans++;
    cout<<ans<<endl;


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<long> A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  long m=1000;
  long k=0;
  for(int i=0;i<N-1;i++){
    //cout<<A[i]<<":";
    if(k==0){
      if(A[i]<A[i+1]){
        k=m/A[i];
        m-=k*A[i];
        //cout<<"buy "<<k<<endl;
      }
    }else{
      if(A[i]>A[i+1]){
        m+=k*A[i];
        k=0;
        //cout<<"sold"<<endl;
      }
    }
    //cout<<endl;
  }
  m=max(m,m+k*A[N-1]);
  cout<<m<<endl;
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-

'''
100000
99990
90000
'''

K = int(input())
# K = 100000 - K

# c = list(str(3234566667))
# c = [int(i) for i in c][::-1]
c = 1

for i in range(K -1):
    str_c = list(str(c))
    str_c = [int(i) for i in str_c][::-1]

    keta = len(str_c)
    # print(c)
    # print(str_c)

    if set(str_c) == set([9]):
        c = c + 1
        continue

    for ket in range(keta):
        # 次の桁を見る
        if ket == keta - 1:
            str_c[ket] += 1

            for j in range(ket):
                # print(str_c)
                if str_c[ket - j] == 0:
                    str_c[ket - j - 1] = 0
                else:
                    str_c[ket - j - 1] = str_c[ket - j] - 1

            str_c = [str(i) for i in str_c][::-1]
            c = int(''.join(str_c))
            break

        if str_c[ket] == str_c[ket + 1] + 1:
            continue

        # 大きくできるところがあれば増やす
        if abs(str_c[ket] - str_c[ket + 1]) <= 1:
            if str_c[ket] < 9:
                str_c[ket] += 1
                for j in range(ket):
                    if str_c[ket - j] == 0:
                        str_c[ket - j - 1] = 0
                    else:
                        str_c[ket - j - 1] = str_c[ket - j] - 1
                str_c = [str(i) for i in str_c][::-1]
                c = int(''.join(str_c))
                break


print(c)


Measured memory_bytes: 3064
S = gets.chomp
D = S.downcase
if [S[0] == 'A', S[2 .. S.size-2].count('C') == 1, S.size.times.count{|i| S[i] == D[i] } == S.size - 2 ].all?
  puts "AC"
else
  puts "WA"
end


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double EPS=1e-9;
const long long INF = 100001000010000100ll;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

int N;

int dp[2][2][10010];
const int A=0;

vi l;

void rec(int i, int A, int w, int k){
}

int main(){
	cin >> N;
	l.pb(0);
	rep(i, N-1){
		int t;
		cin >> t;
		l.pb(t);
	}
	fill_n(**dp, 2*2*10010, inf);
	dp[0][A][0]=0;
	for(int i=1;i<=N;i++){
		for(int w=1;w<=i;w++){
			dp[i & 1][A][w]  = min(dp[(i - 1) & 1][A][w-1], dp[(i - 1) & 1][!A][w-1] + l[i-1]);
			dp[i & 1][!A][w] = min(dp[(i - 1) & 1][!A][w], dp[(i - 1) & 1][A][w] + l[i-1]);
		}
		dp[i&1][A][0]=inf;
	}
	cout << min(dp[(N)%2][A][N/2], dp[(N)%2][!A][N/2]) << endl;



}

Measured memory_bytes: 1480
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnStrs();
        var __ = LnInts();
        var ___ = LnStr();
        print(___ == _[0] ? (__[0] - 1) + " " + __[1] : __[0] + " " + (__[1] - 1));
    }


public static long SumAtoB(long a,long b){var length = b - a + 1;return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0);}
public static long PowLite(long n, long p, int mod = (int)1e9 + 7){long ans = 1;long now = n;for (; p > 0; p >>= 1){if ((p & 1) == 1){ans *= now;ans %= mod;}now *= now;now %= mod;}return ans;}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}


Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int h,w; cin>>h>>w;
    vector<string>hoge(h);
    rep(i,h)cin>>hoge[i];
    rep(i,w+2)cout<<"#";
    cout<<endl;
    rep(i,h){
        cout<<"#"; cout<<hoge[i]; cout<<"#"<<endl;
    }
    rep(i,w+2)cout<<"#";
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    double A;
    double B;
    double ans;
    std::cin >> A;
    std::cin >> B;

    double window_size = A;
    double curtain_size = B;

    if(window_size-2*curtain_size <0){
        ans = 0;
    }else{
        ans = window_size-2*curtain_size;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[10001],count=0;
int s(int b,int n){
    int j;
    for(j=0;j<n;j++){
        if(a[j]==b){
            count++;
            break;
        }
    }
    return count;
}
int main(void){
    int n,m,i,b,count;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d",&b);
        count = s(b,n);
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0;i<N;i++){
		cin >> H[i];
	}
	int ans = 1;
	for(int i=1;i<N;i++){
		int check = 1;
		for(int j = 0;j<i;j++){
			if(H[j] > H[i]) check=0;
		}
		if(check) ans++;
	}
	cout << ans << endl;
}

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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;


#include <cstdio>

#define MAX 100010

int par[MAX], ranks[MAX];
int n;

void init(int par[], int V){
  for(int i = 0; i < V; ++i)
    par[i] = i;
}

int find(int x, int par[]){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x], par);
  }
}

void unite(int x, int y, int par[], int rank[]){
  x = find(x, par);
  y = find(y, par);

  if(x == y)
    return;

  if(rank[x] > rank[y]){
    par[y] = x;
  }else{
    par[x] = y;
    if(rank[x] == rank[y])
      rank[y]++;
  }
}

bool same(int x, int y, int par[]){
  return find(x, par) == find(y, par);
}


int main(){

  int m;
  scanf("%d %d", &n, &m);
  vector<int> p, x(m), y(m);
 
  init(par, n);
  SV(n,p);
  REP(i,m){
    scanf("%d %d", &x[i], &y[i]);
    unite(x[i]-1, y[i]-1, par, ranks);
  }

  llong ans = 0;
  REP(i,n){
    if(same(p[i]-1,par[i],par)){
      ans++;
    }
  }


  printf("%lld\n", ans);
  
  return 0;
}



Measured memory_bytes: 2424
a,b,c,x,y = map(int,input().split())

if x >= y:
  onlyab = 2*x*c
  minab = 2*y*c + (x-y)*a
  aandb = x*a + y*b
else:
  onlyab = 2*y*c
  minab = 2*x*c + (y-x)*b
  aandb = x*a + y*b
  
print(min(onlyab,minab,aandb))

Measured memory_bytes: 3060
#include<stdio.h>

int main() {

  int n, x, count = 0;
  int a;
  int i, j, k;
  while(1) {
  scanf("%d %d", &n, &x);
  if(n == 0 && x == 0) break;
  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      for(k = 1; k <= n; k++) {
	  if(i == j || j == k || k == i) {
	    continue;
	  } else if(i + j + k == x) {
	  count++;
	  }
	}
      }
    }
  printf("%d\n", count / 6);
  count = 0;
  }
  return 0;
}

Measured memory_bytes: 600
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
Q = int(input())

tot = sum(A)
cnt = Counter(A)

for _ in range(Q):
    b,a = map(int,input().split())
    tot += (a - b) * cnt[b]
    cnt[a] += cnt[b]
    cnt[b] = 0
    
    print(tot)

Measured memory_bytes: 24248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		//Input
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		sc.close();

		//logic
		if(X < A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
		
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define cin fin
#define cout fout
#endif
using namespace std;
ifstream fin("in.txt");
ofstream fout("out.txt");
int n,m;
const double pi=acos(-1);
int x,sum;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x;
		sum+=x;
	}
	cout<<max(-1,n-sum);
}

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

int main () {
	int s,h,m;
	cin >> s ;
	h=s/3600;
	s=s-h*3600;
	m=s/60;
	s=s-m*60;
	cout << h << ":" << m << ":" << s <<endl;
	return 0;
}	

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

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	int res = 0;
	for (int i = 1; i <= 3; i++)
	{
		res = A * B * i;
		if (res % 2 != 0)
		{
			printf("Yes");
			return 0;
		}
	}

	printf("No");

	return 0;
}


Measured memory_bytes: 128
#include <string.h>
#include <ctype.h>
#include <iostream>
#include <string>


using namespace std;

int main()
{
	char W[10 + 1] = { 0 };
	char Ti[1000 + 1] = { 0 };
	int W_len = 0;
	int Ti_len = 0;
	int count = 0;

	cin >> W;
	W_len = strlen(W);
	for (int i = 0; i < W_len; i++)
		W[i] = toupper(W[i]);
	
	while(true)
	{
		cin >> Ti;
		if (strcmp(Ti, "END_OF_TEXT") == 0) break;
		Ti_len = strlen(Ti);
		int i = 0, limit = W_len < Ti_len ? W_len + 1 : Ti_len + 1;
		for (; i < limit; i++) {
			Ti[i] = toupper(Ti[i]);
			if (Ti[i] != W[i]) break;
		}
		if (i == limit) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()


int main(){
  string N;
  cin >> N;
  ll k=0;
  rep(i,(ll)N.size()){
    k+=N.at(i)-'0';
  }
  if(k%9==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
          
          
        
  

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	switch (X)
	{
	case 3:
	case 5:
	case 7:
		cout << "YES" << endl;
		break;
	default:
		cout << "NO" << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
#include <cassert>
#include <bit>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    string S;cin>>S;
    int n=S.size();
    vector<ll> val(2019,0);
    ll fac=1,cur=0;
    val[cur]++;
    rep(i,n){
        ll add=S[n-1-i]-'0';
        cur=(cur+fac*add)%2019;
        fac=(fac*10)%2019;
        val[cur]++;
    }
    ll res=0;
    rep(i,val.size()){
        res+=val[i]*(val[i]-1)/2;//nC2
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3648
import heapq
def main():
    n,m=map(int, input().split()) 
    a = list(map(lambda x: int(x)*(-1), input().split())) 
    heapq.heapify(a)

    for i in range(m):
        tmp_min = heapq.heappop(a)
        heapq.heappush(a, -1*(-tmp_min//2))
    print(-sum(a))

if __name__ == '__main__':
    main()

Measured memory_bytes: 72088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60; 

int main()
{
  int H, N; cin >> H >> N;
  int sum = 0;
  vector<int> A(N);
  rep(i,N)
  {
    cin >> A[i];
    sum += A[i];
  }
  if(sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
n = gets.chomp.to_i
s = []

n.times do
  s << gets.chomp.split('')
end

sa = []


s.each_with_index do |a|
  poyo = Hash.new(0)
  a.each do |b|
    poyo[b] += 1
  end
  sa << poyo
end

('a'..'z').each do |al|
  num = []
  sa.each do |a|
    num << a[al]
  end
  num.min.times do
    print al
  end
end

puts


Measured memory_bytes: 1916
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		String tmp = String.valueOf(n);
		int digit = tmp.length();
		int ans = 0;
		for (int i = 1; i < digit; i += 2) {
			int tmp1 = (int) Math.pow(10, i);
			ans += tmp1 - (tmp1 / 10);
		}
		if(digit % 2 != 0) {
			int tmp2 = (int)Math.pow(10, digit - 1);
			ans += n - tmp2 + 1;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
import scala.io.StdIn

object Main {

  case class Shop(cost: Long, store: Long)

  def main(args: Array[String]): Unit = {

    val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
    val abs = (1 to n).foldLeft(Vector.empty[Shop]){(v, _) =>
      val Array(a, b) = StdIn.readLine().split(' ').map(_.toInt)
      v :+ Shop(a, b)
    }

    val costSorted: Vector[Shop] = abs.sortBy(_.cost)
    val ans: Long = costSorted.foldLeft((0l, 0l))((acc, shop) =>
      if (acc._2 >= m) {
        acc
      } else if (acc._2 + shop.store >= m) {
        (acc._1 + (m - acc._2) * shop.cost, m)
      } else {
        (acc._1 + shop.store * shop.cost, acc._2 + shop.store)
      })._1
    println(ans)
  }

}


Measured memory_bytes: 75340
h,w = map(int, raw_input().split(' '))

M = [[0 for x in range(w)] for y in range(h)]
for i in range(h):
    I = raw_input()
    for j in range(w):
        M[i][j] = I[j]

for i in range(h*2):
    print ",".join(M[i/2]).replace(",","")


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

using ll = long long;

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

  double a = (double(L))/3; 

  double ans = a*a*a;

  //cout << ans << endl;
  printf("%.8f",ans);
}

/*
直感だと長さ/3した正6面体がさいだいっぽい
*/

Measured memory_bytes: 256
# D - String Formation
# 2020-05-21 08:17
from collections import deque


def main():
    chars = deque(input())
    chars_append = chars.append
    chars_appendleft = chars.appendleft
    n = int(input())
    direction = 1
    for _ in range(n):
        query = input().split()
        if query[0] == '1':
            direction *= (-1)  # reverse
        else:
            if query[1] == '1':
                # if head-adding: 1, tail: -1
                head = direction
            else:
                head = (-direction)
            if head == 1:
                chars_appendleft(query[2])
            else:
                chars_append(query[2])

    if direction == -1:
        chars.reverse()
    return ''.join(chars)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 8428
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;


int main(){
    int N;
    cin >> N;
    map<string, int> m;
    string S;
    rep(i, N){
        cin >> S;
//        cout << m.count(S) << endl;
        if (m.count(S) == 0) {
            m[S] = 1;
        } else {
            m[S] += 1;
        }
    }
    pair<int, string> a[N];
    int c = 0;
    for (auto const& entry: m)
    {
        a[c] = make_pair(entry.second, entry.first);
        c++;
    }

    sort(a, a+c);
    reverse(a, a+c);
    int ma = a[0].first;
    string s[c];
    int j = 0;
    rep(i, c){
        if (ma == a[i].first) {
            s[j] = a[i].second;
            j++;
        }
    }
    sort(s, s+j);
    rep(i, j){
        cout << s[i] << endl;
    }


}


Measured memory_bytes: 29952