akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX_PIC 4
#define MAX_RANK 13


// ????????????2?¬??????????[??????][?????????]
int card[MAX_PIC][MAX_RANK];

// ??????????????????????????????????????????0????????????????????????
void CardInitialize(void){
	int i, j;
	
	for(i = 0; i < MAX_PIC; i++){
		for(j = 0; j < MAX_RANK; j++){
			card[i][j] = 0;
		}
	}
	
}

// ??\??????????????????????????§??????????????????
void CheckCards(int card_num){
	int i, picture_num, rank;
	char picture;
	
	for(i = 0; i < card_num; i++){
		// C?¨?????????????????§?
		scanf(" %c", &picture);
		scanf("%d", &rank);
		
		// ???????????????????????°?????????????????????
		switch(picture){
		case 'S': picture_num = 0; break;
		case 'H': picture_num = 1; break;
		case 'C': picture_num = 2; break;
		case 'D': picture_num = 3; break;
		}
		card[picture_num][rank-1] = 1;
	}
	
}

// ?¶????????????????????????¨?????????
void ShowCards(void){
	int i, j;
	char picture;
	
	for(i = 0; i < MAX_PIC; i++){
		for(j = 0; j < MAX_RANK; j++){
			if(card[i][j] == 0){
				// ??°??????????????????????????????????????????
				switch(i){
				case 0: picture = 'S'; break;
				case 1: picture = 'H'; break;
				case 2: picture = 'C'; break;
				case 3: picture = 'D'; break;
				}
				printf("%c %d\n", picture, j + 1);
			}
		}
	}
}


int main(void){
	// 2?¬?????????????for?????¨
	int i, j;
	// ??????(S,H,C,D)
	char picture;
	// ??\???????????????????????°????????????????????°???????????????
	int card_num, picture_num, rank;
	
	// ?????????
	CardInitialize();
	
	// ??????????????°?????\???
	scanf("%d", &card_num);
	
	// ??\?????????????????????????????????????????????1????????£??\??????
	CheckCards(card_num);
	
	// ???????????¨??¨??????????´¢??????0?????¨???????????¨?????????
	ShowCards();
	
	return 0;
}

Measured memory_bytes: 596
N,M = map(int,input().split())

H = list(map(int,input().split()))
good = [1]*N

for i in range(M):
    a,b = map(int,input().split())

    if H[a-1] > H[b-1]:
        good[b-1] = 0
    elif H[a-1] < H[b-1]:
        good[a-1] = 0
    else:
        good[a-1] = 0
        good[b-1] = 0


print(sum(good))

Measured memory_bytes: 20012
import java.util.Scanner;
import java.util.HashMap;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			HashMap<Integer, LinkedBlockingQueue<Character>> table = new HashMap<Integer, LinkedBlockingQueue<Character>>();
			int points[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				Character name = sc.next().charAt(0);
				int total = 0;
				for (int j = 0; j < n - 1; j++)
				{
					switch (sc.nextInt())
					{
					case 0:
						total += 100;
						break;
					case 1:
						total--;
						break;
					case 2:
						break;
					}
				}
				points[i] = total;
				LinkedBlockingQueue<Character> sta = table.get(total);
				if (sta == null)
				{
					sta = new LinkedBlockingQueue<Character>();
				}
				sta.offer(name);
				table.put(total, sta);
			}
			Arrays.sort(points);
			for (int i = n-1; i >= 0; i--)
			{
				LinkedBlockingQueue<Character> sta = table.get(points[i]);
				System.out.println(sta.poll());
			}
		}
	}
}

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

int main()
{
    int n,x=0,y=0;
    string s;
    cin>>n;
    cin>>s;
    for(int i=0 ; i<n ; i++)
    {
        if(s[i]=='I') {x+=1; y=max(y,x);}
        else          {x-=1; y=max(y,x);}
    }
    cout << y << endl;
    return 0;
}


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

int  main () { 
    long  N,Weight_req;
    cin>>N>>Weight_req;
    long  weight[N],price[N+1];
    long dp[Weight_req+1];
    memset(dp,0,sizeof(dp));
    for(long  i=0;i<N;i++){
        cin>>weight[i]>>price[i];
    }

    for(long  i=0;i<N;i++){
        for(long  j=Weight_req;j>=0;--j){
            if(j+weight[i]<=Weight_req)dp[j+weight[i]]=max(dp[j+weight[i]],dp[j]+price[i]);
        }
    }
    cout<<*max_element(dp,dp+Weight_req+1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int aa;
		cin >> aa;
		if (aa % 2 == 0) {
			if (aa % 3 != 0 && aa % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}    
	cout << "APPROVED" << endl;
    return 0;
}


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

int main(){
    int L, R;
    cin >> L >> R;
    if(R-L>=2019){
        cout << 0 << endl;
    }
    else if (R/2019 != L/2019){
        cout << 0 << endl;
    }
    else{
        int l = L % 2019;
        int r = R % 2019;

        int saisyou = 2018;
        for(int i=l; i<=r; i++){
            for(int j=i+1; j<=r; j++){
                saisyou = min(saisyou, (i*j)%2019);
            }
        }
        cout << saisyou << endl;
    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    stack<char> s;
    char c;
    for(int i=0;i<n;i++)
    {
        cin>>c;
        if(s.empty())
        {
            s.push(c);
        }
        else if(!s.empty() && s.top()!=c)
        {
            s.push(c);
        }
        else if(!s.empty() && s.top()==c)
        {
            continue;
        }
    }
    cout<<s.size()<<endl;
}

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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(3*N);
    FOR(i, 0, 3*N){
        cin >> A.at(i);
    }
    sort(ALL(A), greater<ll>());

    ll sum = 0;
    for(int i=1; i<2*N; i+=2){
        sum += A[i];
    }
    p(sum);

    return 0;
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"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 {
	n := readInt()
	return 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 minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt()
	M := readInt()
	G := make([][]int, N+1)
	for i := 0; i < M; i++ {
		a := readInt()
		b := readInt()
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}

	cost := make([]int, N+1)
	for i := range cost {
		cost[i] = math.MaxInt32
	}

	q := make([]int, 0)
	push := func(x int) {
		q = append(q, x)
	}
	pop := func() int {
		x := q[0]
		q = q[1:]
		return x
	}

	push(1)
	cost[1] = 0
	for len(q) != 0 {
		v := pop()
		if cost[v] > 2 {
			break
		}
		for _, u := range G[v] {
			nc := cost[v] + 1
			if nc < cost[u] {
				cost[u] = nc
				push(u)
			}
		}
	}
	if cost[N] < 3 {
		println("POSSIBLE")
	} else {
		println("IMPOSSIBLE")
	}

}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    ll ans = infll;

    for (int i = 0; i < N; i++)
    {
        ll sum = 0;
        for (int j = 0; j < N; j++)
        {
            if (i == 0)
                b[j] = a[j];
            else
                b[j] = min(b[j], a[(N + j - i) % N]);
            sum += b[j];
        }
        ans = min(sum + x * i, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template<ll mod>
class Fp {
public:
	ll val;

private:
	inline void calc_mod(ll& v) {
		if (v >= mod)v -= mod;
	}
public:
	Fp() { val = 0; }
	Fp(ll v) :val(v%mod) {
		if (val < 0)val += mod;
	}

	Fp operator+=(const Fp &in) {
		val += in.val;
		calc_mod(val);
		return *this;
	}

	Fp operator+(const Fp &in) const {
		return Fp(*this) += in;
	}

	Fp &operator-=(const Fp &in) {
		val -= in.val;
		calc_mod(val);
		if (val < 0)val += mod;
		return *this;
	}

	Fp operator-(const Fp &in) const {
		return Fp(*this) -= in;
	}

	Fp& operator*=(const Fp& in) {
		val = val * in.val % mod;
		return *this;
	}

	Fp operator*(const Fp &in) const {
		return Fp(*this) *= in;
	}

	Fp& operator/=(const Fp& in) {
		*this *= modpow(in, mod - 2);
		return *this;
	}

	Fp operator/(const Fp& in) const {
		return Fp(*this) /= in;
	}

	bool operator==(const Fp&in)const {
		return val == in.val;
	}

	bool operator!=(const Fp&in)const {
		return val != in.val;
	}

	friend Fp modpow(const Fp& in, ll n) {
		if (n == 0)return 1;
		if (n & 1) {
			return in * modpow(in*in, n / 2);
		}
		else {
			return modpow(in*in, n / 2);
		}
	}
};
using modll = Fp<mod>;

class Factorial {
public:
	vector<modll> fact, finv;
	Factorial(ll n) :fact(n + 1, modll(1)), finv(n + 1, modll(1)) {
		for (int i = 2; i <= n; i++) {
			modll tmp(i);
			fact[i] = fact[i - 1] * tmp;
			finv[i] = finv[i - 1] / tmp;
		}
	}

	modll com(const ll& n, const ll& k) {
		if (n < k || n < 0 || k < 0)return modll(0);
		return fact[n] * finv[k] * finv[n - k];
	}
};


int main() {
	modll ans = 0;
	modll dp[102][4][4][4];
	cin >> N;
	/*for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				if (j == 0 && k == 1 && l == 2) continue;
				if (j == 1 && k == 0 && l == 2) continue;
				if (j == 0 && k == 2 && l == 1) continue;
				dp[3][j][k][l] = 1;
			}
		}
	}*/
	dp[0][3][3][3] = 1;
	for (int n = 0; n < N; n++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					for (int l = 0; l < 4; l++) {
						if (i == 0 && j == 1 && l == 2)continue;
						if (i == 0 && k == 1 && l == 2) continue;
						if (j == 0 && k == 1 && l == 2) continue;
						if (j == 1 && k == 0 && l == 2) continue;
						if (j == 0 && k == 2 && l == 1) continue;
						dp[n + 1][j][k][l] += dp[n][i][j][k];
					}
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += dp[N][i][j][k];
			}
		}
	}
	cout << ans.val << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
   double v = 100000;
   double r;
   int n;

   cin >> n;

   for(int i = 0; i < n; i++) {       
       v += v * 0.05;
       r = fmod(v, 1000.0);          
        if(r != 0) {
            v += (1000 - r);
        }
   }
n = v;

   cout << n << endl;

    return 0;

}

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

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

int main() {

    ll n,w; cin >> n >> w;
    vector<ll> w_ary(n);
    vector<ll> v_ary(n);
    rep(i, n) cin >> w_ary[i] >> v_ary[i];

    vector<vector<ll>> dp(110, vector<ll>(100005));
    for(int i=0; i <= w; i++) dp[0][i] = 0;

    rep(i, n) for(int j=0; j <= w; j++) {
        if(j >= w_ary[i]) dp[i+1][j] = max(dp[i][j-w_ary[i]] + v_ary[i], dp[i][j]);
        else dp[i+1][j] = dp[i][j];
    }

    cout << dp[n][w] << endl;

    return 0;
}


Measured memory_bytes: 87424
#include <string>
#include <iostream>
#include <bitset>
using namespace std;

bitset <200> used;

bool check(string s, char last) {
	for (int i = 'a'; i <= 'z'; ++i) {
		used[i] = false;
	}
	for (char c : s) {
		used[c] = true;
	}
	for (int i = last + 1; i <= 'z'; ++i) {
		if (!used[i]) {
			cout << s << (char)i << "\n";
			exit(0);
		}
	}
}

int main()
{
	string s;
	cin >> s;
	char last = 'a' - 1;
	while (s != "") {
		check(s, last);
		last = s.back();
		s.pop_back();
	}
	check(s, last);
	cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N,K;
  cin>>N>>K;
ll ans=0;
ll a=0;
ll count1=0;
ll count2=0;
if(K%2==0){
  a=K/2;
  while(1){
    if(a<=N){count1++;}
    else{break;}
    a=a+K;
  }
}
  

  
a=0;
while(1){
a=a+K;
if(a<=N){
  count2++;
}
else{break;}
}

  
ans=count2*count2*count2+count1*count1*count1;
cout<<ans<<endl;

  
}


Measured memory_bytes: 3628
s = []
min = 10
sum = 0
for i in range(5):
  s.append(int(input()))
  if min>s[i]%10 and s[i]%10 != 0:
    min = s[i]%10    
for j in s:
  if j%10 != 0:
    sum += (j//10+1)*10
  else:
    sum += j

print(sum-(10-min))

Measured memory_bytes: 3060
from collections import deque

n = int(input())

d = deque([3, 5, 7])
res = 0
while True:
    v = d.popleft()
    if v > n:
        break
    if len(set(str(v))) == 3:
        res += 1
    d.append(v * 10 + 3)
    d.append(v * 10 + 5)
    d.append(v * 10 + 7)

print(res)

Measured memory_bytes: 75692
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n; cin>>n;
  vector<int>A(n);
  for(int i=0;i<n;i++){
    int a; cin>>a;
    A[i]=a;
  }
  sort(A.begin(),A.end());
  cout<<A[n-1]-A[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,N; cin>>H>>N;
    vector<ll> A(N);
    ll sum=0;
    rep(i,N) cin>>A[i];
    rep(i,N) sum+=A[i];
    cout<< ( sum>=H ? "Yes" : "No" )<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func r() []byte {
	sc.Scan()
	return sc.Bytes()
}

func main() {
	sc.Split(bufio.ScanWords)

	ans := make([]byte, 0, 10)
	for _, v := range r() {
		switch v {
		case 48, 49:
			ans = append(ans, v)
		case 66:
			if len(ans) != 0 {
				ans = ans[:len(ans)-1]
			}
		}
	}

	fmt.Println(string(ans))
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    ll a[112345];

    cin >> n;
    REP(i, n)
    {
        cin >> a[i + 1];
    }

    a[n + 1] = 0;

    ll dp[112345][2];

    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[1][0] = a[1];
    dp[1][1] = -1e18;

    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = a[i] + max(dp[i - 1][0], dp[i - 1][1]);
        dp[i][1] = max(-a[i] - a[i - 1] + max(dp[i - 2][0], dp[i - 2][1]), -a[i] + a[i - 1] * 2 + dp[i - 1][1]);
    }

    cout << max(dp[n][0], dp[n][1]) << endl;

    return 0;
}

Measured memory_bytes: 2688
import java.util.*;

public class Main{  
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> sales = new ArrayList<>();
        
        int n = sc.nextInt();
        
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            int count = 0;
            
            switch(a){
                case 0:
                    sales.add(sc.nextInt());
                    count ++;
                    break;
                case 1:
                    System.out.println(sales.get(sc.nextInt()));
                    break;
                case 2:
                    sales.remove(sales.size() -1);
                    break;                        
            }
        }
    }
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> n; 
	for(int i = 1 ; i <= 9 ; i++){
		for(int j =1 ; j <= 9 ; j++){
			if(( i* j ==n)){
				coY();
				return 0;
				
			}
		}
	}
	coN();



}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    while(true) {
        val str = (readLine() ?: break).trim().filter(Char::isLetter).map(Char::toUpperCase).joinToString(" ")
        val palindrome = longestOddPalindrome(str)
        val odd = palindrome.indices.filter{str[it] != ' ' && palindrome[it] >= 3}.map{str.substring(it, it + palindrome[it]).filter(Char::isLetter)}.sorted()
        val even = palindrome.indices.filter{str[it] == ' ' && palindrome[it] >= 4}.map{str.substring(it, it + palindrome[it]).filter(Char::isLetter)}.sorted()

        println(
                (odd.indices.filter{it + 1 !in odd.indices || odd[it].length > odd[it + 1].length || odd[it] != odd[it + 1].substring(0, odd[it].length)}.map{odd[it].reversed() + odd[it].drop(1)} + even.indices.filter{it + 1 !in even.indices || even[it].length > even[it + 1].length || even[it] != even[it + 1].substring(0, odd[it].length)}.map{even[it].reversed() + even[it]}).joinToString(" ")
        )
    }
}
fun longestOddPalindrome(state: String): IntArray {
    val result = IntArray(state.length){1}
    var i = 0
    while (i < result.size) {
        while ((i - result[i]) in state.indices && (i + result[i]) in state.indices && state[i - result[i]] == state[i + result[i]])
            ++result[i]
        for (k in 1 .. result[i]) {
            if (i - k in result.indices && result[i - k] + k < result[i]) {
                result[i + k] = result[i - k]
            }else {
                if (k != result[i]) result[i + k] = result[i] - k
                i += k
                break
            }
        }
    }
    return result
}


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

int main() {
    int n;
    cin >> n;
    int minval = 1000000001;
    int maxval = -1;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a < minval) minval = a;
        if (a > maxval) maxval = a;
    }
    cout << maxval - minval << endl;

    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; i < (int)(n); i++)
/*
*/
using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
 
//繰り返し二乗法
ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
  
}

int main(){
  ll n;
  cin >> n;
  vector<ll> S(n);
  rep(i,n){
    cin >> S[i];
  }
  ll q;
  cin >> q;
  vector<ll> T(q);
  rep(i,q){
    cin >> T[i];
  }
  ll ans = 0;
  rep(i,q){
    ll k = T[i];
    //S[i] >= kとなる最小のiをにぶたんする
    ll lb  = -1;
    ll ub = n;
    while(ub - lb > 1){
      ll mid = (lb + ub)/2;
      if(S[mid] >= k) ub = mid;
      else lb = mid;
    }
    if(S[ub] == k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3900
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll X;
	cin >> X;
	ll an = 1;
	for (ll i = 2; i * i <= X; i++) {
		ll k = i * i;
		while (k <= X) {
			an = max(an, k);
			k *= i;
		}
	}
	cout << an << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp[300000][60]={};
ll dp2[300000][60]={};
int main() {
	int x;
	cin>>x;
	bool flg=true;
	while(flg){
		rep(i,1000){
			if(x<(i+2)*(i+2)){
				flg=false;
				break;
			}else if(x%(i+2)==0){
				break;
			}
		}
		if(flg)x++;
	}
	cout<<x;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp> 
using namespace std; 

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long N, K;
    cin >> N >> K;
    N %= K;
    long d = abs(N - K);
    if (d < N){
        cout << d << endl;
    }
    else {
        cout << N << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>

using namespace std;

#define For(i, start, end) for(ll i = (start); i < (end); i++)
#define rep(i, n) For(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ctoi(c) c - '0'
#define tos(s) to_string(s)

typedef long long ll;

int main() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) {
        cin >> a[i];
    }

    for(ll i = k; i < n; i++) {
        if (a[i-k] < a[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC                                                                              
                                   ******,  .,, .,, ,,,    ****.**              
                                   ** . .,,,,,,,,,,,,,,,,,,,,,. .,*             
                                   **,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.            
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                    ****      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,      
              ***************,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,    
         ********************,,,,,,,,,,,,,,@@@,,,,,,,,,,,/@@@,,,,,,,,,,,,,,,    
        ******************,,,,,,,,,,,,,,,,,,(,,.         ,,,,,,,,,,,,,,,,,,,    
       ********************,,,,,,,,,,,*,,,,,.     %&&&     .,,,,*,,,,,,,,,,,,.  
       ***,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,               ,,,,,,,,,,,,,,,,,   
       ,,,,,,,,,,,,,,,,,,,**,,,,,,,,,,.......      ##(     ........,,,,,,,,,,.  
     .,,,,,,,,,,,,,,,,,,**,,,,,,,,,,..............    ..............,,,,,,,,    
    .,,,,,,,,,,,,,,,,,,,**,,,,,,,,,.................................,,,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,***,,,,,,,....................................,,,,,,,,,  
   ,,,,,,,,,,,,,,,,,,,,**,,,,,,,,.....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,**,,,,,,,,....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,,,     
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,.,,,,,     
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,        
     ,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................................,,,        
      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,          
       ..,,,,,,,,,,,,,,,,,,,,,,,,,,.................................,           
       .........**.....       ,,,,,..............................               
        .......*......                  ****,**,       ,..****                  
        .......*,....                   .......        ......                   
          .......*....                   .....          .....                   
                                         ......          .....                  
*/

Measured memory_bytes: 4636
/*
　うちしあわせぇっしあわせぇっ！！　しあわせみるくがでちゃううっ！！
　やっやあぁらめえっ、たっ…たまぁ…！！　タマタマはぁ…あはぅっ！！
　そっそこいじられると…く…なるぅ…ブリジットのちんぽみるくこくなっちゃうんでしゅぅッ！！
　んあっ！！　んあおっ！！　つっ強いよおぉたまもみつよいのおっ！！！
　あﾞあっでるっ…！！　たまみるくでるっ！！　でっでるうっブリジットのこくまろみるくぅ！！
　おしりほられて変態みるくがきちゃうのおぉっ！！！！！
　ブリジットぴょんぴょんすきっ、ぴょんぴょんちゅき～～っ！
　みっ見てぇっ！！　でるよぉ精子ッ、ブリジットのあかちゃん汁がでるよおおッッ！！
　ブリジットきもちいすぎてバンザイしちゃうぅっ　バンザイっ、ばんじゃいっばんじゃいﾞっ
　ぱゃんにﾞゃんじゃんじゃいぃぃっ！！
*/
#include <iostream>
#include <math.h>
#include <cstring>
using namespace std;
 
bool field[10][10000];
bool binary[10];
long flag;
int r,c,ans;
 
long FlagMake(void);
void Count(int area);
 
int main(void){
    cin >> r >> c;
    while(r!=0&&c!=0){
        for(long i=0;i<r;i++){
            for(long j=0;j<c;j++){
                cin >> field[i][j];
            }
        }
 
        ans=0;
        memset(binary,0,sizeof(binary));
 
        for(long i=0;i<pow(2,r);i++){
            if(i!=0){Count(0);}
            FlagMake();
            if(ans<flag)ans=flag;
        }
 
        cout << ans << endl;
 
        cin >> r >> c;
    }
}
 
long FlagMake(){
    int low,high;
     
    flag=0;
     
    for(long i=0;i<c;i++){
         
        low=0;high=0;
         
        for(int j=0;j<r;j++){
            if(binary[j]==1){
                if(field[j][i]==0){high++;}
                else{low++;}
            }
            else{
                if(field[j][i]==0){low++;}
                else{high++;}
            }
        }
        if(low>high){flag+=low;}
        else{flag+=high;}
    }
    return flag;
}
 
void Count(int area){
    if(binary[area]==0){binary[area]=1;}
    else{
        binary[area]=0;
        Count(area+1);
    }
}


Measured memory_bytes: 3360
#include<iostream>
int main(){int n,c=0,l[100];std::cin>>n;bool f=0;for(int i=0;i<n;i++)std::cin>>l[i],i>0?l[i-1]==l[i]&&f==0?c++,f=1:f=0:0;std::cout<<c<<"\n";}

Measured memory_bytes: 256
def fac(n):
    dic = {}
    cur = n
    for i in range(2,(int(n**0.5)+2)):
        if cur % i == 0:
            count = 0
            while cur % i == 0:
                count += 1
                cur //= i
            dic[i] = count
            if cur == 1:
                break
    if cur != 1:
        dic[cur] = 1
    return dic

def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(a-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num * pow(den,c-2,c) % c

n,m = map(int,input().split())
mod  = 10**9 + 7
dic = fac(m)
ans = 1
for i in dic.keys():
    x = dic[i]
    ans *= cmb(x+n-1,x,mod)
    ans %= mod
print(ans)

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

int main() {
int N;
cin>>N;
vector <int> vec(N);
for(int i =0;i<N;i++){
cin>>vec.at(i); //1の行先はvec[0]
}
int cnt=0;
int j=1; //今いる場所
while(j!=2&&cnt<N){
j=vec.at(j-1);
cnt+=1;}
if(cnt>=N){
cout<<-1;}
else{
cout<<cnt;}
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c,d;
string s;
cin>>s;
a=int(s[0]-'0');
b=int(s[1]-'0');
c=int(s[2]-'0');
d=int(s[3]-'0');

int n=pow(2,3);
char proc[3];
int total;
rep(i,n){
    total=a;
    if(i&(1<<0)){
        total+=b;
        proc[0]='+';
    }
    else{
        total-=b;
        proc[0]='-';
    }
    if(i&(1<<1)){
        total+=c;
        proc[1]='+';
    }
    else{
        total-=c;
        proc[1]='-';
    }
    if(i&(1<<2)){
        total+=d;
        proc[2]='+';
    }
    else{
        total-=d;
        proc[2]='-';
    }

    if(total==7){
        break;
    }
}
s.insert(s.begin()+1,proc[0]);
s.insert(s.begin()+1+2,proc[1]);
s.insert(s.begin()+1+2+2,proc[2]);
s+="=7";
cout<<s<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//





ll modadd(long long a, long long b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(long long a, long long b){return a%MOD*b%MOD%MOD;}
ll modexp(long long a, long long n){if (a==0) return 0; if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(long long n){return modexp(n%MOD,MOD-2);}
ll modfact(long long n){long long res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(long long n, long long r){long long numer=1;long long denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}



int main() {

    int N; cin >> N;
    int a[N]; rep(i,N) cin >> a[i];

    int cnt[N]; rep(i,N) cnt[i] = 0;
    rep(i,N) cnt[a[i]]++;
    bool ok = true;
    if (N%2 == 0) {
        for (int i = 1; i < N; i+=2) {
            if (cnt[i] != 2) {
                ok = false;
            }
        }
    } else {
        for (int i = 2; i < N; i+=2) {
            if (cnt[i] != 2) {
                ok = false;
            }
        }
        if (cnt[0] != 1) {
            ok = false;
        }
    }
    
    ll ans = modexp(2, N/2);
    if (ok) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }


    return 0;
}





Measured memory_bytes: 4312
#include<stdio.h>
int main(){
  int width,high,i,j;

  while(1){
    scanf("%d %d",&high,&width);
    if(width == 0 && high == 0) break;
    for(i=0;i<high;i++){
      for(j=0;j<width;j++){
        if(i %2 == 0 && j %2 == 0) printf("#");
        else if(i % 2 == 1 && j % 2 == 1) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2128
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
import bisect


#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	L = getlist()
	L = sorted(L)
	ans = 0
	for i in range(N):
		for j in range(i + 1, N):
			x = L[i] + L[j]
			ans += bisect.bisect_left(L, x) - j - 1
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 43932
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <cmath>
 

using namespace std;

int64_t gcd(int64_t a, int64_t b)
{
  int64_t c;
  while(a)
  {
     c = a; a = b%a; b = c;
  }
  return b;
}
 
int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int64_t n;
    cin >> n;
    
    vector<int64_t> xs(n+1);
    for(auto& x : xs)
        cin >> x;
    
    sort(begin(xs), end(xs));

    vector<int64_t> dxs(n);
    for(size_t i = 0; i < dxs.size(); ++i)
        dxs[i] = abs(xs[i+1] - xs[i]);
        
    cout << accumulate(begin(dxs), end(dxs), dxs[0], gcd) << '\n';
    
    return 0;
}


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

int main(){
    int t; cin >> t;
    while (t--) {
        long long n, m, a, b; cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << "\n";
    }
    return 0;
}

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

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

    double ans = 2 * M_PI * r;


    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
#include <map>

using namespace std;
using namespace std::chrono;

const int INF = 1e+9 + 10;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> a(n + 1);
  a[0] = 0;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  vector<long long> ans(n + 1, 0);

  map<int, int> mp;
  for (int i = n; i >= 0; --i)
    mp[a[i]] = i;

  auto iter = mp.rbegin();
  int cval = iter->first;
  int pos = iter->second;

  map<int, int> right;
  for (int i = n; i >= pos; --i)
    ++right[a[i]];

  while (cval > 0) {
    ++iter;
    while (iter->second >= pos)
      ++iter;
    const int nval = iter->first;
    const int npos = iter->second;
    const int opos = pos;

    while (pos > npos)
      ++right[a[--pos]];

    //cout << "pos = " << pos << " npos = " << npos << endl;
    auto riter = right.rbegin();
    while (riter->first > nval) {
      ans[opos] += 1LL * (riter->first - a[npos]) * riter->second;
      right[a[npos]] += riter->second;
      right.erase(riter->first);
    }

    cval = nval;
  }

  for (int i = 1; i <= n; ++i)
    cout << ans[i] << '\n';

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S; cin >> S;
	int N; N = S.size();
	int num[N];
	for (int i = 0; i < N; i++) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
			num[i] = 1;
		}
		else {
			num[i] = 0;
		}
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int temp = 0;
		for (int j = i; j < N; j++) {
			if (num[j] == 1) temp++;
			else break;
		}
		cnt = max(cnt, temp);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
 
int main() {
    int a,b; cin >> a >> b;
    int cnt = 1;
    int ans = 0;
    while (cnt < b) {
        cnt--;
        cnt += a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k; cin >> n >> k;

    std::vector<int> p(n); rep(i,n) cin >> p[i];

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

    int ans = 0;
    rep(i,k) ans += p[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int N,Y;
    int i,j;
    cin>>N>>Y;
    for(i=0;i<=N;i++ ){
    for(j=0;j<=N;j++ ){
    if(Y==10000*i+5000*j+1000*(N-i-j)&&i+j<=N)
    {cout<<i<<" "<<j<<" "<<N-i-j<<endl;
     goto A;
    }
    }}
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    A:;
    }


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int[] t = new int[n+1];
        int[] x = new int[n+1];
        int[] y = new int[n+1];
        // 初期値
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        // 入力値
        for (int i = 1; i <= n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        int dt, dist, diff;
        for (int i = 0; i < n; i++) {
            // dt = t[i+1] - t[i];
            // dist = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]);
            // if (dt < dist || (dist % 2 != dt % 2)) {
            //     // 出力
            //     System.out.println("No");
            //     return;
            // }
            diff = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]) - t[i+1] + t[i];
            if (diff > 0 || (diff % 2 != 0)) {
                // 出力
                System.out.println("No");
                return;
            }
        }

        // 出力
        System.out.println("Yes");
    }
}


Measured memory_bytes: 92828
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
#define pi 3.1415926535897932

//http://geeksforgeeks.org/calculate-angle-hour-hand-minute-hand/
int min(int x, int y)  
{  
    return (x < y)? x: y;  
}  
  
double calc(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
    double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  
    return angle;  
}  
 
int32_t main()
{
    IOS;
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double ang=calc(h*1.0,m*1.0);
    cout<<fixed<<setprecision(12)<<sqrt(a*a+b*b-2*a*b*cos(pi*ang/180));
}

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

int check(int number);

int main(){
    int N;
    cin >> N ;
    int ans=0 ;
    for(int i=1;i<=N;i+=2){
        if(check(i) == 8) ans++ ;
    }
    cout << ans << "\n";
}

int check(int number){
    int res = 0;
    for(int i=1;i * i <= number ;i++){
        if(i * i == number) {
            res +=1 ;
            continue;
        }
        if(number % i == 0) res += 2 ;
    }
     return res;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

constexpr int Nmax = 20;

bool solve(const int* const A, const int& n, const int& i, const int& m) {
    if (m == 0) { return true; }
    if (m < 0 or i >= n) { return false; }
    return solve(A, n, i + 1, m) || solve(A, n, i + 1, m - A[i]);
}

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

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

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        if (solve(A, n, 0, m)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n;
int a[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < 2 * n; i++)
		cin >> a[i];
}

void solve()
{
	sort(a, a + 2 * n);
	int ans = 0;
	for(int i = 0; i < 2 * n; i += 2)
		ans += min(a[i], a[i + 1]);

	cout << ans << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sort(int *,int *);
int main(void){
int n,m;
  scanf("%d%d",&n,&m);
  int p[m+1][2];
  char s[m+1][3],ws[3];
  for(int i=0;i<m;i++){
scanf("%d%s",&p[i][0],s[i]);
  }
  for(int i=0;i<m;i++){
    p[i][1]=i;
  }
  qsort(p,m,sizeof(int)*2,sort);
  /*for(int i=0;i<m;i++){
    printf("%d %d %s\n",p[i][0],p[i][1],s[p[i][1]]);
  }*/
  int flag=0,AC=0,WA=0,i=0,WAcount=0;
  char ac[2]="AC";
  while(i<m){//11
  // printf("%d------\n",i);
	if(strcmp(s[p[i][1]],"AC")==0){//1
      flag=1;
      AC++;
     // printf("正解\n");
      if(i==m-1){
         printf("%d %d",AC,WA);
        return 0;
      }
    }         //1   
   else  {WAcount++;
          if(p[i][0]!=p[i+1][0])WAcount=0;
    //printf("不正解\n");
         }
    
    if(flag==1){//33
      WA+=WAcount;
      WAcount=0;
      while(p[i][0]==p[i+1][0]){//22
        i++;
     //   printf("%d\n",i);
        if(i==m-1){
          printf("%d %d",AC,WA);
        return 0;
        }
                  }//22
      flag=0;
    }//33
    i++;
  }//11
    printf("%d %d",AC,WA);
    
    return 0;
  }
int sort(int *a, int *b){
return *a-*b;
}

Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		int INF = Integer.MAX_VALUE;
		Scanner sc = new Scanner(System.in);
		//char[] c = sc.next().toCharArray();
		//int N = A.length;
		int N = Integer.parseInt(sc.next());
		int[] d = new int[N];
		for(int i=0; i<N; i++){
			d[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(d);
		
		int low = d[N/2-1];
		int high = d[N/2];
		
		System.out.println(high-low);
		
	}
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c/b);
	}
}



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

int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if ((h | w) != 0) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					cout << "#";
				}
				cout << endl;
			}
			cout << endl;
		} else {
			break;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long LL;
#define N 2200

const LL mod=924844033;
LL n,m,ans,fac[N],ifac[N],f[N][N],g[N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

void trans(LL len){
	for (LL i=n;~i;--i)
		for (LL j=1;j<=len&&j<=i;++j)
			upd(g[i],g[i-j]*f[len][j]);
}

LL inv(LL x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}

LL C(LL x,LL y){return x<y||y<0?0:fac[x]*ifac[y]%mod*ifac[x-y]%mod;}

int main(){
	scanf("%lld%lld",&n,&m);
	fac[0]=1; for (LL i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	ifac[n]=inv(fac[n]); for (LL i=n-1;~i;--i) ifac[i]=ifac[i+1]*(i+1)%mod;
	f[0][0]=1;
	for (LL i=1;i<=n;++i)
		for (LL j=0;j<=i;++j)
			f[i][j]=(f[i-1][j]+(i>1&&j>0?f[i-2][j-1]:0))%mod;
	g[0]=1;
	for (LL i=1;i<=m;++i){
		LL len=(n-i)/m+1;
		trans(len); trans(len);
	}
	for (LL i=0;i<=n;++i)
		upd(ans,g[i]*fac[n-i]*(i&1?-1:1));
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 33664