akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int a = 0;
    for (int i =0; i < S.length(); i++){
        if (S[i] == '+'){
            a += 1;
        }
        if (S[i] == '-'){
            a -= 1;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
import heapq
from collections import deque

N, M=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0], x[1]))
for i in range(N):
  AB[i][1]=-AB[i][1]
d=deque(AB)
ans=0
h=[]
for i in range(M+1):
  if not d and not h:
    break
  while d and d[0][0]<=i:
    heapq.heappush(h, d.popleft()[1])
  if h:
    ans-=heapq.heappop(h)
print(ans)

Measured memory_bytes: 87768
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
N  = int(input())
def divisor(n):
    div_list = []
    for i in range(1, int(1+ n**0.5)):
        if n%i == 0 and i**2 == n:
            div_list.append(i)
        elif n%i == 0:
            div_list.append(i)
            div_list.append(int(n/i))
    return div_list
counter = 0

for i in range(1,N+1):
    if len(str(i)) % 2 == 1:
        counter += 1
        
print(counter)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main()
{
    FAST
    FO
    FI
    string s;
    IN s;
    if(s=="SUN")
    {
        OUT 7;
    }
    else if(s=="MON")
    {
        OUT 6;
    }
    else if(s=="TUE")
    {
        OUT 5;
    }
    else if(s=="WED")
    {
        OUT 4;
    }
    else if(s=="THU")
    {
        OUT 3;
    }
    else if(s=="FRI")
    {
        OUT 2;
    }
    else if(s=="SAT")
    {
        OUT 1;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    vector<string> vs(n);
    map<char,ll> h;
    h['M'] = 0;
    h['A'] = 1;
    h['R'] = 2;
    h['C'] = 3;
    h['H'] = 4;
    ll cnt[5] = {};
    rep(i,n){
        cin >> vs[i];
        if(vs[i][0] == 'M' || vs[i][0] == 'A' || vs[i][0] == 'R' || vs[i][0] == 'C' || vs[i][0] == 'H'){
            cnt[h[vs[i][0]]]++;
        }
    }
    ll ans = 0;
    rep(i,5){
        FOR(j,i+1,5){
            FOR(k,j+1,5){
                ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans << endl;
}

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


int main(){
  int dp[10][10];
  
  int H,W;
  cin >> H >> W;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> dp[i][j];
    }
  }

  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
  }
  
  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int tmp;
      cin >> tmp;
      if(tmp != -1){
        ans += dp[tmp][1];
      }
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n - 1];
        for(int i = 0; i < n - 1; i++) {
        	b[i] = sc.nextInt();
        }
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
        	if(i == 0) {
        		a[i] = b[i];
        	}else if(i == n - 1) {
        		a[i] = b[i - 1];
        	}else {
        		a[i] = Math.min(b[i], b[i - 1]);
        	}
        }
        int sum = Arrays.stream(a).sum();
        System.out.println(sum);
	}

}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < (int)S.size(); i++) {
        S[i] = (S[i]-'A'+N)%26+'A';
    }
    cout << S << endl;
    return 0;
}

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

using namespace std;

const int module = 1e9 + 7;
void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

void solve() {
    string K;
    int D;
    cin >> K >> D;
    int n = (int)K.size();
    int F[n + 1][D][2];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < D; j++) {
            for (int k = 0; k < 2; k++) F[i][j][k] = 0;
        }
    }
    for (int i = 0; i < (K[0] - '0'); i++) F[0][i % D][0] += 1;
    int S = (K[0] - '0') % D;
    F[0][S][1] += 1;
    for (int i = 1; i < n; i++) {
        S = (S + (K[i] - '0')) % D;
        F[i][S][1] = 1;
        for (int d = 0; d < D; d++) {
            for (int j = 0; j < 10; j++) {
                for (int prev_equal = 0; prev_equal < 2; prev_equal++) {
                    bool GreaterOrEqual = j >= (K[i] - '0');
                    if (prev_equal & GreaterOrEqual) break;
                    ///cout << i - 1 << " " << ((d - j) % D + D) % D << " " << prev_equal << " " << F[i - 1][((d - j) % D + D) % D][prev_equal] << '\n';
                    F[i][d][0] = (F[i][d][0] + F[i - 1][((d - j) % D + D) % D][prev_equal]) % module;
                    ///cout << i << " " << d << " " << j << " " << equal << " " << F[i][d][equal] << '\n';
                }
            }
        }
    }
    int Res = (F[n - 1][0][0] + F[n - 1][0][1]) % module;
    Res = (Res - 1 + module) % module;
    cout << Res;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ///doc();
    solve();
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <math.h>

int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    while (a > 0 && c > 0)
    {
        c -= b;
        if (c <= 0) {
            printf("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            printf("No");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1728
#python3
from collections import defaultdict
from operator import itemgetter

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    s = defaultdict(int)
    for i in a:
        s[i]+=1  
    
    t = []
    for i, j in s.items():
        t.append((i, j))

    t.sort(reverse=True,key=itemgetter(1))
    MAX = t[0][1]
    ans = []
    for i, j in t:
        if j == MAX:
            ans.append(i)
    ans.sort()
    for i in ans:
        print(i)
main()


Measured memory_bytes: 47668
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int n,m,x;
  int left=0,right=0;
  cin>>n>>m>>x;
  int a[m];
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    if(a[i]<x)left++;
    else right++;
  }
  cout<<min(left,right)<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
for i in range(len(a)):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    for k in range(n):
        if k != n-1:
            print(a[k], end=' ')
        else:
           print(a[k], end='') 
    print()


Measured memory_bytes: 5984
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n+1);
    fori(n+1) {
        cin>>a[i];
    }
    vi b(n);
    fori(n)
        cin>>b[i];

    ll ans=0;
    for(int i=n-1; i>=0; i--) {
        int m=min(b[i], a[i+1]);
        ans+=m;
        a[i+1]-=m;
        b[i]-=m;
        m=min(b[i], a[i]);
        ans+=m;
        a[i]-=m;
        b[i]-=m;
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 1024
open Core;;

let s = In_channel.(input_line_exn stdin)
let t = In_channel.(input_line_exn stdin)

let () = 
  let res =
    let n = String.length s in
    let m = String.length t in
    let dist x y =
      let rec cnt i = if (i < 0) then 0 else (if (Char.equal (String.get x i) (String.get y i)) then 0 else 1) + cnt (i - 1) in
      cnt ((String.length x) - 1)
    in
    List.range 0 (n - m + 1) |>
    List.map ~f:(fun i -> dist (String.sub ~pos:i ~len:m s) t) |>
    List.reduce_exn ~f:Int.min
  in
  printf "%d\n" res
;;


Measured memory_bytes: 13640
import sys
n, t = map(int, input().split())
T = [int(i) for i in input().split()]
x = 0
start = 0
finish = 0
for i,j in enumerate(T):
    if i == n-1:
        if j >= finish:
            x += finish - start + t
        else:
            x += j - start + t
        print(x)
        sys.exit()
    if j >= finish:
        x += finish - start
    else:
        x += j - start
    start = j
    finish = j + t

Measured memory_bytes: 25196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2,s3,s4;
    long long n,i,j,k,l,m;
    vector<string >vc;
    cin>>n;
    cin.ignore();
    for(i=0; i<n; i++)
    {
        cin>>s1;
        vc.push_back(s1);
    }
    if(vc.size()%2==0)
    {

        for(i=vc.size()-1; i>=1; i-=2)
        {
            cout<<vc[i]<<" ";
        }
        for(i=0;i<vc.size();i+=2)
        {
            cout<<vc[i]<<" ";
        }
    }
    else
    {
        for(i=vc.size()-1; i>=0; i-=2)
        {
            cout<<vc[i]<<" ";
        }
        for(i=1;i<vc.size();i+=2)
        {
            cout<<vc[i]<<" ";
        }

    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 15984
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()

def make_divisors(n):  # nの約数を列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

answer = 0
for i in range(1, N+1, 2):
    d = make_divisors(i)
    if len(d) == 8:
        answer += 1

print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
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;
}


int main(){
    ll N, W;
    cin >> N >> W;
    ll weight[110] = {0}, value[110] = {0};
    for(int i=0; i<N; ++i)cin >> weight[i] >> value[i];
    vector<vector<ll>> dp(N+1, vector<ll>(100100));
    for(int i=0; i<N+1; ++i)for (int j = 0; j < 100100; ++j) dp[i][j] = INF;

    dp[0][0] = 0;

    for (int i = 0; i < N; i++){
      for (int j = 0; j < 100100; j++){
        if (j >= value[i]) chmin(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
        chmin(dp[i + 1][j], dp[i][j]);
      }
    }
    ll out = 0;
    for (int i = 0; i < 100100; i++){
      if (dp[N][i] <= W) out = i;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 83240
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

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

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		int lx,ly,rx,ry;
		static char room[2][50][51];
		for(int i=0;i<h;i++){
			scanf("%s%s",room[0][i],room[1][i]);
			for(int j=0;j<w;j++){
				if(room[0][i][j]=='L')	lx=j,ly=i,room[0][i][j]='.';
				if(room[1][i][j]=='R')	rx=j,ry=i,room[1][i][j]='.';
			}
		}

		static bool visited[50][50][50][50];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			for(int k=0;k<h;k++)for(int l=0;l<w;l++)	visited[i][j][k][l]=false;
		}
		bool ok=false;
		visited[ly][lx][ry][rx]=true;
		queue< pair<pii,pii> > qu;	qu.push(mp(mp(ly,lx),mp(ry,rx)));
		while(!qu.empty()){
			pair<pii,pii> a=qu.front();	qu.pop();
			pii len=a.first,rin=a.second;
			bool bl=room[0][len.first][len.second]=='%';
			bool br=room[1][rin.first][rin.second]=='%';
			if(bl && br){ ok=true; break; }
			if(bl || br)	continue;

			for(int i=0;i<4;i++){
				int ly=len.first,lx=len.second;
				int ry=rin.first,rx=rin.second;
				int lyy=ly+dy[i],lxx=lx+dx[i];
				int ryy=ry+dy[i],rxx=rx-dx[i];
				if(0<=lyy && lyy<h && 0<=lxx && lxx<w && room[0][lyy][lxx]!='#')	ly=lyy,lx=lxx;
				if(0<=ryy && ryy<h && 0<=rxx && rxx<w && room[1][ryy][rxx]!='#')	ry=ryy,rx=rxx;
				if(!visited[ly][lx][ry][rx]){
					qu.push(mp(mp(ly,lx),mp(ry,rx)));
					visited[ly][lx][ry][rx]=true;
				}
			}
		}

		puts(ok?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 7804
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll n, m, k;
    cin>>n>>m>>k;
    vector<ll> a(n);
    vector<ll> b(m);
    rep(i, n) cin>>a[i];
    rep(i, m) cin>>b[i];
    vector<ll> va(n+1);
    vector<ll> vb(m+1);
    ll now = 0;
    rep(j, m){
        vb[j] = now;
        now += b[j];
    }
    vb[m] = now;
    now = 0LL;
    rep(i, n){
        va[i] = now;
        now+=a[i];
    }
    va[n] = now;
    ll ans = 0;
    rep(i, m+1){
        ll tmp = k - vb[i];
        if(tmp<0) break;
        if(tmp>va[va.size()-1]) continue;
        auto itr = upper_bound(va.begin(), va.end(), tmp);
        ll p = (ll)(itr-va.begin())-(ll)1+(ll)i;
        ans = max(p, ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9584
#include <iostream>
#include <cctype>
#include<cassert>
using namespace std;
size_t cur=0;
string S;



int digit(){
assert(isdigit(S[cur]));
int n=S[cur]-'0';
cur=cur+1;
return n;
}

int number(){
	int n=digit();
	while(cur<S.size() && isdigit(S[cur])){
		n=n*10+digit();
	}
	return n;
}

int expression();

int factor(){
	if(S[cur]!='(') return number();
	cur=cur+1;
	int n=expression();
	assert(S[cur]==')');
	cur=cur+1;
	return n;
}


int term(){
 int a=factor();
 while(cur<S.size() && (S[cur]=='*' || S[cur]=='/')){
 	char op = S[cur++];
 	int b= factor();
 	if (op== '*')a*=b;
 	else a/=b;
 }
return a;
}


int expression(){
	int a=term();
	while((S[cur]=='+'||S[cur]=='-')&&cur<S.size()){
		char op =S[cur++];
		int b=term();
		if (op=='+'){
			a=a+b;
		}
		else{
			a=a-b;
		}
	}
	return a;
}


int parse(){ return expression();}
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>S;
	cur=0;
	S.resize(S.size()-1);
int a=parse();
cout<<a<<endl;
}
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,m,l,x,y,build[1001][2],assign[1001],assign2[1001],prev[1001][1001];
double route[11][1001][1001];

void backtrack(int from,int to){
	int z=prev[from][to];
	if(z==from){
		printf("%d ",assign[from]);
		return;
	}
	backtrack(from,z);
	backtrack(z,to);
}

int main(){
	while(scanf("%d",&n)*n){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&assign[i],&build[i][0],&build[i][1]);
			assign2[assign[i]]=i;
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				l=(build[i][0]-build[j][0])*(build[i][0]-build[j][0])+(build[i][1]-build[j][1])*(build[i][1]-build[j][1]);
				if(l<=2500){
					route[0][i][j]=sqrt((double)l);
					route[0][j][i]=sqrt((double)l);
					prev[i][j]=i;
					prev[j][i]=j;
				}
				else{
					route[0][i][j]=999999999;
					route[0][j][i]=999999999;
				}
			}
		}

		for(l=1;pow(2.0,l)<n-1;l++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					route[l][i][j]=route[l-1][i][j];
					for(k=0;k<n;k++){
						if(route[l][i][j]>route[l-1][i][k]+route[l-1][k][j]){
							route[l][i][j]=route[l-1][i][k]+route[l-1][k][j];
							prev[i][j]=k;
						}
					}
				}
			}
		}

		l--;

		for(scanf("%d",&m);m>0;m--){
			scanf("%d %d",&x,&y);
			x=assign2[x];
			y=assign2[y];
			if(x==y){
				printf("%d\n",assign[y]);
			}
			else if(route[l][x][y]<999999999){
				backtrack(x,y);
				printf("%d\n",assign[y]);
			}
			else printf("NA\n");
		}

	}
	return 0;
}

Measured memory_bytes: 21528
#include<stdio.h>

int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<b) a^=b^=a^=b;
  if(a<c) a^=c^=a^=c;
  if(b<c) b^=c^=b^=c;
  a=(a-b)+(b-c);
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!
 
import statistics
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = sorted([x - i - 1 for i, x in enumerate(A)])
med = int(statistics.median(A_dash))

print(sum([abs(x - med) for x in A_dash]))


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

int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's'){
    cout << s+"es" << endl;
  } else {
    cout << s+"s" << endl;
  }
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
human = N*[0]

for i in range(K):
    d = int(input())
    for j in list(map(int, input().split())):
        human[j-1] += 1

count = 0
for i in range(N):
    if human[i] == 0:
        count += 1

print(count)

Measured memory_bytes: 9128
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();
        for(int i=1;i<10;i++){
            if(n%i==0 && n/i<=9){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 25044
#include <iostream>

using namespace std;

int main()
{
	int h, w;
	while(cin >> h >> w, (h|w))
	{
		int r = h*h + w*w;
		int res_h, res_w, res_r;
		res_r = 10000000;
		for(int p=1; p*p*2<r; p++)
		{
			int q = 1;
			while(p*p+q*q<r || (p*p+q*q==r && p<=h)) q++;
			if(p*p+q*q<res_r)
			{
				res_h = p;
				res_w = q;
				res_r = p*p+q*q;
			}
		}
		cout << res_h << " " << res_w << endl;

	}
}

Measured memory_bytes: 3092
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int K;
	string S;
	cin >> K;
	cin >> S;

	if(S.size() > K){
		rep(i,K){
			cout << S[i];
		}
		cout << "..." << endl;
	}
	else{
		cout << S << endl;
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3640
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

cnt = [0] * n

for i in a:
    cnt[i - 1] += 1

for c in cnt:
    if k - (q - c) > 0:
        print('Yes')
    else:
        print('No')


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int n, m, a, b;
  cin >> n >> m;
  int result[n+1] = {0};
  rep(i, m){
    cin >> a >> b;
    result[a-1] += 1;
    result[b-1] += 1;
  }
  rep(i, n){
    puts(result[i])
  }
}


Measured memory_bytes: 256
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		double px1 = Double.parseDouble(tmpArray[0]);
		double py1 = Double.parseDouble(tmpArray[1]);
		double px2 = Double.parseDouble(tmpArray[2]);
		double py2 = Double.parseDouble(tmpArray[3]);

		Point2D p1 = new Point2D.Double(px1, py1);
		Point2D p2 = new Point2D.Double(px2, py2);

		int q = Integer.parseInt(br.readLine());

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");
			double x = Double.parseDouble(tmpArray[0]);
			double y = Double.parseDouble(tmpArray[1]);

			Point2D p = new Point2D.Double(x,y);

			Point2D result = calcProjection(p, p1, p2);
//			System.out.println(result.getX() + " "+ result.getY());
			System.out.printf("%.10f %.10f\n", result.getX(), result.getY());
		}

	}

	static Point2D calcProjection(Point2D p, Point2D p1, Point2D p2){
		double theta = Math.PI/2;

		if(p1.getX() != p2.getX()){
			theta = Math.atan((p1.getY() - p2.getY()) / (p1.getX() - p2.getX()));
		}

//		System.out.println("theta "+theta);

		AffineTransform affine = AffineTransform.getTranslateInstance(p1.getX(), p1.getY());

		Point2D result = new Point2D.Double();
//		result = affine.transform(p, result);
//		System.out.println("trans rev" + result.getX() + " " + result.getY());
		affine.concatenate(AffineTransform.getRotateInstance(theta));

//		result = new Point2D.Double();
//		result = affine.transform(p, result);
//		System.out.println("rotate rev" + result.getX() + " " + result.getY());
		//y座標を0にする
		affine.concatenate(new AffineTransform(1, 0, 0, 0, 0, 0));
//		result = new Point2D.Double();
//		result = affine.transform(p, result);
//		System.out.println("compress" + result.getX() + " " + result.getY());
		affine.concatenate(AffineTransform.getRotateInstance(-theta));
//		result = new Point2D.Double();
//		result = affine.transform(p, result);
//		System.out.println("rotate" + result.getX() + " " + result.getY());
		affine.concatenate(AffineTransform.getTranslateInstance(-p1.getX(), -p1.getY()));

//		result = new Point2D.Double();
		result = affine.transform(p, result);
//		System.out.println("trans" + result.getX() + " " + result.getY());

		return result;

	}

}



Measured memory_bytes: 34804
#include <iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

string S,T;
vint idx[111111];
signed main(){
	cin>>S>>T;
	rep(i,S.size())idx[S[i]-'a'].pb(i);

	int cur=0;
	int ans=0;
	for(auto c:T){
		int x=c-'a';
		if(idx[x].size()==0){
			cout<<-1<<endl;
			return 0;
		}
		int k=lower_bound(all(idx[x]),cur)-idx[x].begin();
		if(k==idx[x].size()){
			ans+=S.size();
			k=0;
		}
		cur=idx[x][k]+1;
	}
	cout<<ans+cur<<endl;
	return 0;
}

Measured memory_bytes: 4284
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	int p;
	int fee_x;
	int fee_y;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &p);
	
	fee_x = a * p;
	
	if (c < p){
		fee_y = b + (p - c) * d;
	}
	else {
		fee_y = b;
	}
	if (fee_x < fee_y){
		printf("%d\n", fee_x);
	}
	else if (fee_x > fee_y){
		printf("%d\n", fee_y);
	}
	
	return (0);
}

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

int N,M;
const int MAX_N = 100005;
int r[MAX_N],cnt[MAX_N];

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

	cin >> N >> M;
	r[1] = 1;
	for(int i=1;i<=N;i++){
		cnt[i] = 1;
	}
	for(int i=0,x,y;i<M;i++){
		cin >> x >> y;
		if(r[x])r[y]=1;
		cnt[x]--;
		cnt[y]++;
		if(cnt[x]==0)r[x]=0;
	}

	int ans = 0;
	for(int i=1;i<=N;i++){
		if(r[i])ans++;
	}
	cout << ans << endl;

	return 0;
}

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

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

  int x = -1;
  int y = -1;
  int z = -1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int k = N - i - j;
      int total = i * 10000 + j * 5000 + k * 1000;
      if (total == Y) {
        x = i;
        y = j;
        z = k;
        break;
      }
    }
  }

  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define A break;
int main()
{
        int count;
        while(scanf("%d",&count),count){
                int d[3];
                d[0]=1;d[1]=2;d[2]=3;
                int f=1,b=0,i;
                char a,dir[6];
                getchar();
                for(;count--;){
                        scanf("%s",dir);
                        switch(dir[0]){
                        case 'N':b=d[1];d[1]=7-d[0];d[0]=b;A
                        case 'E':b=d[2];d[2]=d[0];d[0]=7-b;A
                        case 'W':b=d[0];d[0]=d[2];d[2]=7-b;A
                        case 'S':b=d[1];d[1]=d[0];d[0]=7-b;A
                        case 'R':b=d[1];d[1]=d[2];d[2]=7-b;A
                        case 'L':b=d[1];d[1]=7-d[2];d[2]=b;A
                        }
                        f+=d[0];
                }
                printf("%d\n",f);
        }
        return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  long long sum=1;
  for(int i=0;i<N;i++){
    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
    if(sum>1000000000000000000/A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    sum*=A.at(i);
  }
  cout << sum << endl;
}
    
  

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

namespace ABC143B_TAKOYAKI_FESTIVAL_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int sum = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if (i != j)
                    {
                        sum += d[i] * d[j];
                    }
                }
            }

            Console.WriteLine(sum / 2);
        }
    }
}


Measured memory_bytes: 13396
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a >=0 and b>=0 :
    if a+v*t >= b+ w*t:
        print("YES")
    else:
        print("NO")
elif a <0 and b >=0:
    if a+v*t >= b + w*t:
        print("YES")
    else :
        print("NO")
else :
    if -a+v*t >= -b + w*t:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
#include<iostream>

using namespace std;
  int a,b;
  cin >> a >> b;
  string c[a];
  char f ='#';
  for(int i = 0;i < a;i++){
    cin >> c[i];
  }
  for(int i = -1;i < a+1;i++){
    if(i >= 0 && i < a)
      cout << f << c[i] << f << endl;
    else{
      for(int j = 0;j < b+2;j++)
        cout << f;
      
      cout << endl;
    }
  }
}

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

using namespace std;
int main(){
    double a,b,c,d,e,f;
    while((cin>>a>>b>>c>>d>>e>>f)){
        double x = (c*e-b*f)/(a*e-b*d);
        double y = (c*d-a*f)/(b*d-a*e);
        x = round(1000*x) / 1000;
        y = round(1000*y) / 1000;
        if(x==0)x=0;
        if(y==0)y=0;
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 0
r=k=0
n,c=gets.split.map &:to_i
x,v=n.times.map{gets.split.map &:to_i}.transpose
l=v.reduce :+
(n-1).downto(m=0){|i|l-=v[i];r+=v[i];k=[k,l-x[i-1]*(i>0?2:0)+m=[m,r-c+x[i]].max].max}
m=0;n.times{|i|l+=v[i];r-=v[i];k=[k,r-(c-(x[i+1]||0))*(i<n-1?2:0)+m=[m,l-x[i]].max].max}
p k

Measured memory_bytes: 13180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

const int N = 26;

vector<vector<int>> graph;
vector<int> pre;
string str;

string back(int u, int last) {
	stack<char> S;
	while (u) {
		S.push(str[u - 1]);
		u = pre[u];
	}
	string ans;
	while (!S.empty()) {
		ans += S.top();
		S.pop();
	}
	ans += 'a' + last;
	return ans;
}

string bfs() {
	queue<int> Q;
	Q.push(0);
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = 0; i < N; i++) {
			int v = graph[u][i];
			if (v == -1) return back(u, i);
			if (pre[v] == -1) {
				pre[v] = u;
				Q.push(v);
			}
		}
	}
}

bool solve(int testNumber) {
	if (!(cin >> str)) return false;
	int n = str.size();
	graph.assign(n + 1, vector<int>(N));
	vector<int> nex(N, -1);
	pre.assign(n + 1, -1);
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j < N; j++) graph[i] = nex;
		if (i) nex[str[i - 1] - 'a'] = i;
	}
	string ans = bfs();
	printf("%s\n", ans.c_str());
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

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


Measured memory_bytes: 27924
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int T;cin>>T,T;){
		vector<int> t(T);
		for(int i=0;i<T;i++) cin>>t[i];
		vector<vector<int>> ok(100,vector<int>(T,1));
		int N; cin>>N;
		for(int i=0;i<N;i++){
			int D,M; cin>>D>>M;
			for(int j=0;j<T;j++)
				ok[D-1][j]&=M>=t[j];
		}
		
		const int INFTY=1<<29;
		vector<vector<int>> dp(100,vector<int>(T,INFTY));
		dp[0][0]=0;
		for(int i=0;i<99;i++){
			for(int j=0;j<T;j++){
				dp[i+1][0]=min(dp[i+1][0],dp[i][j]+1);
				if(ok[i+1][(j+1)%T])
					dp[i+1][(j+1)%T]=min(dp[i+1][(j+1)%T],dp[i][j]);
			}
		}
		
		cout<<*min_element(begin(dp[99]),end(dp[99]))<<endl;
	}
}

Measured memory_bytes: 1236
import math
N, K = map(int, input().split())

log_list = list(map(int, input().split()))

maxx = 10**9
minx = 0

while (maxx - minx != 1):
    midx = (maxx + minx) // 2
    cut_n = sum([math.ceil(length / midx)-1 for length in log_list])
    if cut_n > K:
        minx = midx
    else:
        maxx = midx


print(maxx)


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

const int Maxn = 200005;
int n, root1, root2, cnt, e[Maxn], deg[Maxn], head[Maxn];
struct edg
{
	int nxt, to, dir;
} edge[3 * Maxn];
void add(int x, int y)
{
	deg[x]++, deg[y]++;
	edge[++cnt] = (edg){head[x], y, -1};
	head[x] = cnt;
	edge[++cnt] = (edg){head[y], x, -1};
	head[y] = cnt;
}
void dfs(int u)
{
	for (int &i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		if (edge[i].dir != -1) continue;
		edge[i].dir = 1, edge[((i - 1) ^ 1) + 1].dir = 0;
		dfs(to);
	}
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if (x != -1) add(i, x);
		else root1 = i;
	}
	
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if (x != -1) add(1 + n + i, 1 + n + x);
		else root2 = 1 + n + i;
	}
	add(n + 1, root1), add(n + 1, root2);
	for (int i = 1; i <= n; i++)
		if ((deg[i] & 1) != (deg[n + 1 + i] & 1))
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	puts("POSSIBLE");
	for (int i = 1; i <= n; i++)
		if (deg[i] & 1) add(i, n + 1 + i), e[i] = cnt - 1;
	for (int i = 1; i <= 2 * n + 1; i++)
		while (head[i]) dfs(i);
	for (int i = 1; i <= n; i++)
		if (e[i]) printf(edge[e[i]].dir ? "-1 " : "1 ");
		else printf("0 ");
	return 0;
}

Measured memory_bytes: 22072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxm = 17;
const int maxn = (1 << 16) + 10;
int a[maxn];
ll f[maxm][maxn], g[maxm][maxn];
ll fac[maxn], inv[maxn], facinv[maxn], bin[maxn];
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
	bin[0] = 1; for(int i = 1; i < maxn; ++i) bin[i] = bin[i - 1] * 2 % mod;
}
ll C(int n, int m) { return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;}
int main()
{
	pre();
	int N, m;
	scanf("%d%d", &N, &m);
	int n = bin[N], S = (1 << N) - 1;
	for(int i = m; i; --i) 
	{
		scanf("%d", &a[i]);
		a[i] = n - a[i];
	}
	f[0][0] = 1;
	for(int i = 0; i<= m; ++i) g[i][0] = 1;
	ll ans = fac[n], cof = n;
	for(int i = 1; i < N; ++i) cof = cof * fac[bin[i]] % mod;
	for(int i = 1; i <= m; ++i)
		for(int s = 1; s <= S; ++s)
		{
			ll tmp = 1, tot = S - s;
			for(int cur = 1; cur <= S; cur <<= 1)
				if(s & cur)
				{
					tmp = (mod - tmp) % mod;
					/*
					for(int j = 0; j < i; ++j)
						f[i][s] = (f[i][s] + f[j][s - cur] * C(a[i] - (s - cur), cur) % mod) % mod;
					*/
					f[i][s] = (f[i][s] + g[i - 1][s - cur] * C(a[i] - (s - cur), cur - 1) % mod) % mod;
					g[i][s] = (g[i - 1][s] + f[i][s]) % mod;
				}
				else
				{
					tmp = tmp * C(tot, cur) % mod;
					tot -= cur;
				}
			//cout << i << ' ' << s << ' ' << f[i][s] << ' ' << tmp << ' ' << cof << endl;
			ans = (ans + tmp * f[i][s] % mod * cof % mod) % mod; 
		}
	printf("%lld\n", ans);
	return 0;
}
/*
2 3
2 3 4
*/

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 2e5 + 7;
int n;
int a[N];
int b[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  if (n % 2 == 1) {
    int f = a[n / 2 + 1], s = b[n / 2 + 1];
    cout << s - f + 1 << "\n";
  } else {
    int f = a[n / 2] + a[n / 2 + 1], s = b[n / 2] + b[n / 2 + 1];
    cout << s - f + 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 5228
#include<stdio.h>
#include<stdlib.h>
 struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
 
Node root;

void ins(int k){
  Node y = NULL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> l = NULL;
  z -> r = NULL;
 while(x != NULL){
    y = x;
    if(z -> key < x -> key)x = x-> l;
    else x = x->r;
  }
  z -> p = y;
 if(y == NULL)root = z;
  else if(z -> key < y -> key)y -> l = z;
  else y -> r = z;
 
 
}
 
void ino(Node u){
 
  if (u != NULL){
 
    ino(u -> l);
    printf(" %d",u-> key);
    ino(u -> r);
  }
}
void pre(Node u){
 
  if (u != NULL){
 
    printf(" %d",u -> key);
    pre(u -> l);
    pre(u -> r);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      ins(x);
    } else if ( com[0] == 'p' ){
    ino(root);
    printf("\n");
    pre(root);
    printf("\n");
    } 
}
return 0;
}

Measured memory_bytes: 24036
input_data = [input().split() for l in range(2)]

total_num = int(input_data[0][0])
select_num = int(input_data[0][1])

price_list = []
for price in input_data[1]:
  price_list.append(int(price))

min_price = 0
for p in sorted(price_list)[:select_num]:
  min_price += p

print(min_price)

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


int main(void){

int k[1000];
int p[1000];
int n;
int ans[1000];

cin >> n;

for(int i =0; i < n; i++){
    cin >> k[i] >> p[i];
    ans[i] = k[i] % p[i];
    
    if(ans[i] == 0)
      ans[i] = p[i];
    
    cout  <<ans[i] << endl;
}

}


Measured memory_bytes: 3108
# https://yamamucho.hatenadiary.org/entry/20090622/1245667210
#
# n個の点全てを含む円のうち半径が最小である円の
# 中心座標と半径を求める
class SolvCircle

    LOOP_MAX = 100

    # 移動距離がこの値以下になったら処理を終了させる
    CONVRGV = 1.0e-9

    #
    #=== 円の中心座標と半径を求める
    #
    #_pt_x_ :: n個の点のx座標の配列
    #_pt_y_ :: n個の点のy座標の配列
    # 
    #返り値::配列を返す。[中心点のx座標, 中心点のy座標, 円の半径]
    #
    def solv_circle(pt_x, pt_y)
        mv_rate  = 1.0 # 移動係数(徐々に半減)
        max_dist = 0.0 # 中心点から最遠点までの距離
        xsv      = 0.0 # 中心点のx座標
        ysv      = 0.0 # 中心点のy座標
        cx       = 0.0 # 仮中心点のx座標
        cy       = 0.0 # 仮中心点のy座標
        k        = 0
        cvgflg   = false

        while (cvgflg == false)
            mv_rate /= 2.0
            LOOP_MAX.times { |t|
                # 最遠点を求める
                max_dist = 0.0
                pt_x.length.times { |i|
                    dist = distance(cx, cy, pt_x[i], pt_y[i])
                    if (dist > max_dist)
                        max_dist = dist
                        k        = i
                    end
                }

                # 仮の中心点を計算
                cx += (pt_x[k] - xsv) * mv_rate
                cy += (pt_y[k] - ysv) * mv_rate

                # 移動距離が境界値を下回っていればループを抜ける
                if (distance(cx, cy, xsv, ysv) <= CONVRGV)
                    cx     = xsv
                    cy     = ysv
                    cvgflg = true
                    break
                end

                xsv = cx
                ysv = cy
            }
        end

        return [cx, cy, max_dist]
    end

    #
    #=== 二点の距離を求める
    #
    def distance(x1, y1, x2, y2)
        dx = x2 - x1
        dy = y2 - y1
        Math.sqrt(dx * dx + dy * dy)
    end
end

N = gets.to_i
x = Array.new(N)
y = Array.new(N)
N.times{|i| x[i],y[i] = gets.split.map(&:to_i)}

sc = SolvCircle.new
ans = sc.solv_circle(x, y)
puts ans[2]

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

static const int MAX = 10000;

int P[MAX], H[MAX];

void unite(int u1, int u2) {
	while (P[u1] != u1) u1 = P[u1];
	while (P[u2] != u2) u2 = P[u2];
	if (H[u1] < H[u2]) P[u1] = u2;
	else if (H[u1] > H[u2]) P[u2] = u1;
	else {
		P[u2] = u1;
		H[u1]++;
	}
} 

int same(int n1, int n2) {
	while (P[n1] != n1) n1 = P[n1];
	while (P[n2] != n2) n2 = P[n2];
	if (n1 == n2) return 1;
	else return 0;
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)	{
		P[i] = i;
		H[i] = 0;
	}

	for (int i = 0 ; i < q; i++) {
		int cmd, f, s;
		cin >> cmd >> f >> s;
		if (cmd) cout << same(f, s) << endl;
		else unite(f, s);
	}
	return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long int64;

const int MAXN = 100000 + 10;

struct Cow {
    int64 p;
    int64 a;
    bool operator<(const Cow b) { return p < b.p; }
};

Cow cow[MAXN];

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("c.in", "r", stdin);
    // freopen("c.out", "w", stdout);
    // #endif

    int i, j;
    int n, m;
    int64 cost = 0;

    scanf("%d %d", &m, &n);
    for (i = 0; i < m; i++)
        scanf("%lld %lld", &cow[i].p, &cow[i].a);

    sort(cow, cow + m);

    for (i = 0; n > cow[i].a; i++) {
        n -= cow[i].a;
        cost += cow[i].a * cow[i].p;
    }
    cost += n * cow[i].p;
    printf("%lld", cost);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long int ll;

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

  int N;
  cin >> N;
  vector<double> p(N);
  for (auto &x: p) cin >> x;

  vector<vector<double> > dp(N+2, vector<double>(N+2));
  dp[0][0] = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double prob = 0.0;
  for (int j = N/2+1; j <= N; j++) prob += dp[N][j];

  cout << setprecision(16) << prob << endl;

  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll x, ans;
ll r[11] = {0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2};
int main(void){
 cin >> x;
 ans += x/11*2 +r[x%11];
 cout << ans << endl;
 return 0;
}

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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var V = ReadIntArray();
            var C = ReadIntArray();
            var list = new List<int>();
            for (int i = 0; i < N; i++)
            {
                if (V[i] >= C[i]) list.Add(V[i] - C[i]);
            }

            Out(list.Sum());
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 13396
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    a,b = input().split()
    a = int(a)
    s = b[0]
    t = b[2:4]
    b = int(s+t)
    print(a*b//100)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
	const int MAX_N=1005;
    int n,m,p[MAX_N];
	int x[MAX_N*MAX_N];
	while(true){
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)return 0;
		for(int i=0;i<n;i++)scanf("%d",&p[i]);
		p[n]=0;
		n++;

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				x[i*n+j]=p[i]+p[j];
			}
		}
		sort(x,x+n*n);

		int ans=0;
		for(int i=0;i<n*n;i++){
			int mp=m-x[i];
			if(mp<0)continue;
			int l=0,r=n*n-1;
			int y=0;
			while(r-l>=1){
				int c=(r+l)/2;
				if(x[c]==mp){
					y=x[c];
					break;
				}
				else if(x[c]<mp){
					y=x[c];
					l=c+1;
				}
				else r=c;
			}
			ans=max(ans,y+x[i]);
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 5124
#include <stdio.h>

int main(void){
  int n;
  char s[100], t[100];
  scanf("%d", &n);
  scanf("%s %s", s, t);
  for(int i=0; i<n; i++){
    printf("%c%c", s[i], t[i]);
  }
  return 0;
}

Measured memory_bytes: 128
def l(a, b):
  if a > b:
    a, b = b, a
  return l(a, b % a) if b % a else a

def g(a, b):
  return a * b // l(a, b)

N = int(input())
res = 1
for n in range(N):
  res = g(res, int(input()))

print(res)

Measured memory_bytes: 3060
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()

A = FLI()

flg = len(set(A)) == n

print("YES" if flg else "NO")

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

int main() {
    string S;
    cin>>S;
    bool ans = true;
    for(int i=0;i<S.size();++i){
        if(i%2==0 & S[i]!='h'){
            ans = false;
        }
        if(i%2==1 & S[i]!='i'){
            ans = false;
        }
    }
    if(S.size()%2!=0)ans=false;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>

using namespace std;
const double PI = acos(-1.0);

int main() {
    int R;
    scanf("%d", &R);
    printf("%.3lf\n", 2 * PI * R);
    return 0;
}


Measured memory_bytes: 3828