akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  int N, K;
  int ans = 0;
  cin >> N >> K;
  int a;
  rep(i, N){
    cin >> a;
    if(a >= K){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static List<Long> plist = new ArrayList<>();
    static List<Long> alllist = new ArrayList<>();
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();



        plist.add((long)1);
        alllist.add((long)1);
        for(int i = 1;i <= n;i++){
            plist.add(plist.get(i-1)*2 + 1);
            alllist.add(alllist.get(i-1)*2 + 3);
        }

        System.out.println(calcP(x,n));
    }

    public static long calcP(long x, int n){
        if(x == 0){
            return 0;
        }
        if(n == 0){
            return 1;
        }
        if(x <= alllist.get(n-1)+1){
            return calcP(x-1, n-1);
        } else {
            return plist.get(n-1) + 1 + calcP(x-alllist.get(n-1) -2, n-1);
        }
    }

}

Measured memory_bytes: 22736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Amazing Mazes
 */
public class Main {

	static final int DIR[][] = {
			{0, -1},
			{1, 0},
			{0, 1},
			{-1, 0},
	};

	static final int DIR2[][] = {
			{0, -2},
			{2, 0},
			{0, 2},
			{-2, 0},
	};

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int w, h;
			w = parseInt(line.substring(0, line.indexOf(' ')));
			h = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((w | h) == 0) break;

			w = w * 2 - 1;
			h = h * 2 - 1;
			int[][] maze = new int[h][w];

			for (int i = 0; i < maze.length; i++) {
				line = br.readLine();
				for (int j = 0; j < line.length(); j++) {
					if (line.charAt(j) == '1') maze[i][j] = 1;
				}
			}

			//solve
			Deque<int[]> q = new ArrayDeque<>();

			q.offer(new int[]{0, 0});
			maze[0][0] = 1;

			while (!q.isEmpty()) {

				int y, x;
				y = q.peek()[0];
				x = q.peek()[1];
				q.poll();

				if (y == h - 1 && x == w - 1) break;

				for (int i = 0; i < DIR.length; i++) {
					int ny, nx, ny2, nx2;
					ny = y + DIR[i][0];
					nx = x + DIR[i][1];
					ny2 = y + DIR2[i][0];
					nx2 = x + DIR2[i][1];

					if (0 <= ny2 && ny2 < h && 0 <= nx2 && nx2 < w) {
						if (maze[ny][nx] == 0 && maze[ny2][nx2] == 0) {
							q.offer(new int[]{ny2, nx2});
							maze[ny2][nx2] = maze[y][x] + 1;
						}
					}
				}
			}
			System.out.println(maze[h - 1][w - 1]);
		}
	}
}

Measured memory_bytes: 33416
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;


pair<ll,ll> P[300001];
ll ans;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	FOR(i, 0, A) {
		ll p; cin >> p;
		P[i].first = p;
		P[i].second = 0;
	}
	FOR(i, A, A + B) {
		ll q; cin >> q;
		P[i].first = q;
		P[i].second = 1;
	}
	FOR(i, A + B, A + B + C) {
		ll r; cin >> r;
		P[i].first = r;
		P[i].second = 2;
	}

	sort(P, P + A + B + C);
	reverse(P, P + A + B + C);

	ll cur = -1;
	ll Ccnt = 0;
	while (X+Y-Ccnt!=0) {
		cur++;
		if (P[cur].second == 0) {
			if (X == 0)continue;
			X--;
		}
		if (P[cur].second == 1) {
			if (Y == 0)continue;
			Y--;

		}
		if (P[cur].second == 2) {
			Ccnt++;

		}
		ans += P[cur].first;
	}
	cout << ans << endl;



	return 0;
}


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

using namespace std;

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

  string w;
  cin >> w;
  
  map<char, int> hsh;
  for (auto &c : w) {
    hsh[c]++;
  }
  bool ok = true;
  for (auto &h : hsh) {
    if (h.second%2 > 0) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}



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

using namespace std;

int main()
{
    string input;
    int marbleCount = 0;

    cin >> input;

    for(int i = 0; i < input.length(); i++)
    {
        if(input[i] == '1')
        {
            marbleCount++;
        }
    }

    cout << marbleCount << endl;
}

Measured memory_bytes: 256
N = int(input())
As = [int(x) for x in input().split(" ")]

maxA = 0
count = 0
for a in As:
    # print(a)
    if a >= maxA:
        pass
    else:
        # print("count up : ", maxA - a)
        count += maxA - a
    maxA = max(a, maxA)
    # print("max : ", maxA)
    
print(count)



Measured memory_bytes: 32184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 998244353;


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


    int n, K;
    cin>>n>>K;

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

    vector<int> dp(n, INT_MAX);

    dp[0]=0;
    for(int i=1; i<n; i++){

    	for(int j=1; j<=K; j++){

    		if(j<=i){
    			dp[i] = min(dp[i], dp[i-j] + abs(height[i-j]-height[i]));
    		}
    	
    	}
    }

    cout<<dp[n-1]<<endl;

	return 0;
}		


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(i,v) for (auto i=v.begin();i!=v.end();++i)
using namespace std;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}

bool operator<(const string&a,const string&b) {
   int n=a.size(),m=b.size();
   if(b[m-1]=='$')return false;
   if(n<m)return true;
   if(n>m)return false;
   if(a<=b)return true;
   return false;
}
signed main()
{
   int N, M; cin >> N >> M;
   set<int> A;
   REP(i, M) {
      int a; cin >> a;
      A.insert(a);
   }
   V<int> num{-1,2,5,5,4,5,6,3,7,6};
   V<string> dp(N+1, "$");   // dp[i]: the max string using i matches.
                             //        '$' represents impossible string.
   dp[0] = "";
   REP(i, N) {
      EACH(j, A) {
         int a = *j;
         if (i + num[a] <= N) {
            chmax(dp[i + num[a]], to_string(a)+dp[i]);
         }
      }
   }
   cout << dp[N] << endl;
   return 0;
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using LL = long long ;
#define ALL(v) (v).begin(),(v).end()
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)



int main() {
    int n;
    scanf("%d",&n);
    std::vector<int> A(2 * n);
    for (int i = 0; i < 2 * n; ++ i) {
        scanf("%d",&A[i]);
    }
    std::sort(ALL(A));
    int result = 0;
    for (int i = 0; i < 2 * n; i += 2) result += A[i];
    printf("%d\n",result);
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n+1)
	b := make([]int, n)

	for i := 0; i < n+1; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])
	}

	ans := 0
	var nokori int
	for i := 0; i < n; i++ {
		if a[i] >= b[i] {
			a[i] -= b[i]
			ans += b[i]
		} else {
			nokori = b[i] - a[i]
			ans += a[i]
			if a[i+1] >= nokori {
				a[i+1] -= nokori
				ans += nokori
			} else {
				ans += a[i+1]
				a[i+1] = 0
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');
            int N = int.Parse (str[0]);

            str = Console.ReadLine ().Split (' ');

            var A = new List<int> ();
            var B = new bool[1000001];
            var C = new int[1000001];

            for (int i = 0; i < N; i++)
            {
                A.Add (int.Parse (str[i]));
                C[int.Parse (str[i])] += 1;
            }

            var U = new List<int> ();

            for (int i = 0; i < 1000001; i++)
            {
                if (C[i] == 1) U.Add (i);
            }

            foreach (int i in A.Distinct ().ToList<int> ())
            {
                for (int j = 2 * i; j < 1000001; j += i)
                {
                    B[j] = true;
                }
            }

            int count = 0;
            foreach (int i in U)
            {
                if (B[i] == true) continue;
                count++;
            }

            Console.WriteLine (count);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 53148
k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

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

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> high(n);
    vector<bool> peak(n, true);

    for (size_t i = 0; i < n; i++) cin >> high[i];
    for (size_t i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (high[a] >= high[b]) peak[b] = false;
        if (high[a] <= high[b]) peak[a] = false;
    }

    int ans = 0;
    for (size_t i = 0; i < n; i++) {
        if (peak[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3752
N = gets.to_i
A = N.times.map { gets.to_i }.sort

a = A.dup
b = A.dup

listA = Array.new(N, -1)
listB = Array.new(N, -1)

1.step(N - 1, 2) do |i|
  listA[i] = a.pop
  listB[i] = b.shift
end

2.step(N - 1, 2) do |i|
  listA[i] = a.shift
  listB[i] = b.pop
end

listA[0] = a.pop
listB[0] = b.pop

sumA = listA.each_cons(2).map { |i, j| (i - j).abs }.inject(:+)
sumB = listB.each_cons(2).map { |i, j| (i - j).abs }.inject(:+)

puts [sumA, sumB].max


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w", stdout);
    #endif
	FAST();
	rs(s)
	if(s.back()=='s')cout<<s<<"es";
	else cout<<s<<"s";
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<P> items(N);
    rep(i, Q) cin >> items[i].first >> items[i].second;
    vector<ll> acc(N + 1, 0);
    rep2(i, 1, N) {
        if (S[i] == 'C' && S[i - 1] == 'A') {
            acc[i + 1] += acc[i] + 1;
        } else {
            acc[i + 1] += acc[i];
        }
    }
//    print(acc);
    rep(q, Q) {
        P p = items[q];
        ll ans = acc[p.second] - acc[p.first];
        cout << ans << '\n';
    }
}

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


Measured memory_bytes: 3408
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

struct interval{
    int l , r;
    bool friend operator <(interval a , interval b){
        return a.r < b.r;
    }
};

int n;
int m;
int bit[N];
vector < interval > q;

void update( int k, long long v ) {
      if(k == 0)
        return;
      while (k <= n) {
        bit[k] += v;
        k += k & -k;
      }
}

long long query( int k ) {
      long long ret = 0;
      while(k > 0) {
        ret += bit[k];
        k -= k & -k;
      }
      return ret;
}


int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 0; i < m; i++){
        int a , b;
        scanf("%d%d" , &a , &b);
        q.push_back({a , b});
    }
    int ans = 0;
    sort(q.begin() , q.end());
    for(int i = 0; i < m; i++){
        int cnt = query(q[i].r) - query(q[i].l);
        if(cnt == 0){
            ans++;
            update(q[i].r , 1);
        }
    }
    printf("%d\n" , ans);
}

Measured memory_bytes: 1524
#a, b, c, d = (int(i) for i in input().split())  

#a = [int(i) for i in input().split()] 

r, D, x_past = (int(i) for i in input().split())  

for i in range(10):
    x_next = r*x_past -D
    print(x_next)
    x_past = x_next
    
# if A <= 5:
#     print(0)
# elif 5 < A and A <= 12:
#     print(int(B/2))
# else:
#     print(B)


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

int main(){
    int A ,B,C,K;
    cin>>A>>B>>C>>K;
while(K!=0){
    if(B<=A){
        B*=2;
        K--;
    }
    else{
        break;
    }
}
while(K!=0){
    if(C<=A||C<=B){
        C*=2;
        K--;
    }
    else{
        break;
    }
}
if(C>B&&C>A&&B>A){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
return 0;
}


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

int a[100100];

int main()
{
int n, k;
	cin >> n >> k;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	if( n <= k ) {
		cout << "1" << endl;
	} else {
		if( ((n-1) % (k-1))==0 ) {
			cout << (n-1)/(k-1) << endl;
		} else {
			cout << (n-1)/(k-1)+1 << endl;
		}
	}
}


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

vector<int> memo(100000);

int dfs(vector<int> &arr, int num, int t) {
  if (memo[num] == 1) return -1;
  if (arr[num] == t) return 1;
  memo[num] = 1;
  int tmp   = dfs(arr, arr[num], t);
  if (tmp == -1) return -1;
  return 1 + tmp;
}

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  cout << dfs(arr, 0, 1) << endl;
}

Measured memory_bytes: 2560
from collections import deque

class Grid():
    def __init__(self,i,j,isblack):
        self.i=i
        self.j=j
        self.isblack=isblack
        self.distance=0

H,W=map(int,input().split())

g=[]
for i in range(H):
    Ai=input()
    gi=[]    
    for j in range(W):
        gi.append(Grid(i,j,Ai[j]=='#'))
    g.append(gi)

d=deque()

# 黒マスのreachedをTrueにし，dequeに入れる
for row in g:
    for grid in row:
        if grid.isblack:
            d.append(grid)

while d:
    tg=d.popleft()
    i=tg.i
    j=tg.j
    if i>0 and not g[i-1][j].isblack:
        g[i-1][j].isblack=True
        g[i-1][j].distance=tg.distance+1
        d.append(g[i-1][j])
    if i<H-1 and not g[i+1][j].isblack:
        g[i+1][j].isblack=True
        g[i+1][j].distance=tg.distance+1
        d.append(g[i+1][j])
    if j>0 and not g[i][j-1].isblack:
        g[i][j-1].isblack=True
        g[i][j-1].distance=tg.distance+1
        d.append(g[i][j-1])
    if j<W-1 and not g[i][j+1].isblack:
        g[i][j+1].isblack=True
        g[i][j+1].distance=tg.distance+1
        d.append(g[i][j+1])

'''
for row in g:
    for grid in row:
#        print(grid.distance,end=' ')
#    print()
'''

print(max([max([grid.distance for grid in row]) for row in g]))

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

long mpow(long x,long a){
	long ans=1,cur=x,mod=1000000007;
	long i=0;
	while((1<<i)<=a){
		if(a&(1<<i)){
			ans=(ans*cur)%mod;
		}
		cur=(cur*cur)%mod;
		i++;
	}
	return ans;
}

int main() {
	long n,k,i,j,ans,mod=1000000007;
	cin >> n >> k;
	vector<long> cur(k+1,0);
	for(i=1; i<=k; i++){
		cur[i]=mpow(k/i,n);
	}
	/*
	for(i=1; i<=k; i++){
		cout << cur[i] << ' ';
	}
	*/
	for(i=k; i>=1;i--){
		for(j=2; i*j<=k; j++){
			cur[i]-=cur[i*j];
			if(cur[i]<0){
				cur[i]+=mod;
			}
		}
	}
	
	ans=0;
	/*
	for(i=1; i<=k; i++){
		cout << cur[i] << ' ';
	}
	*/
	for(i=1; i<=k; i++){
		ans+=(cur[i]*i)%mod;
		ans%=mod;
	}
	cout << ans%mod;
	return 0;
}

Measured memory_bytes: 4040
def linear_search(A, key):
    N = len(A)
    A[N - 1] = key
    i = 0
    while A[i] != key:
        i += 1
    return i != (N - 1)

if __name__ == "__main__":
    N = int(input())
    num_list = list(map(int, input().split()))
    M = int(input())
    target_list = list(map(int, input().split()))

    count = 0
    for target in target_list:
        if(linear_search(num_list, target)):
            count += 1
    print(count)



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

int main() 
{
	string s,t;
	cin>>s>>t;
	int x=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
			x++;
	}
	cout<<x<<endl;
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    int x;
    bool flag = false;
    rep(i, 50001){
        if(i*108/100 == n){
            flag = true;
            x = i;
            break;
        }
        if(i*108/100 > n) break;
    }
    
    string s = ":(";
    if(flag){
        cout << x << endl;
    } else {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
a, b, k = gets.chomp.split.map(&:to_i)

n = [a, b].min

n.downto(1) do |i|
  if a % i == 0 && b % i == 0
    k -= 1

    if k == 0
      puts i
    end
  end
end


Measured memory_bytes: 14372
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define repl(i, l, r) for (int i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
const int MAX = 1000005;
int n, P[MAX], Q[MAX];
int main() {
	scanf("%d", &n);
	int a[n];
	rep(i, n) {
		scanf("%d", a + i);
		Q[a[i]]++;
	}
	sort(a, a + n);
	int ans = 0;
	rep(i, n) {
		if (P[a[i]]) continue;
		if (Q[a[i]] == 1) ans++;
		for (int j = 1; j * a[i] < MAX; j++) P[j * a[i]] = 1;
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

template< typename T >
T mod_pow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> C(N);
    for(int i=0; i<N; i++) {
        cin >> C[i];
    }
    sort(C.begin(), C.end());
    // vector<int> D(N+1);
    // for(int i=1; i<=N; i++) {
    //     D[i] = D[i-1]
    // }

    int64_t ans = mod_pow(2L, 2*N-2);
    int64_t tmp = 0;
    for(int i=0; i<N; i++) {
        tmp = (tmp + (N+1-i) * C[i]) % MOD;
    }
    cerr << tmp << " " << ans << endl;
    cout << (tmp * ans) % MOD << endl;
    return 0;
}


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

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

Measured memory_bytes: 3628
import java.util.*;
class Main{
  public static int gcd(int a, int b){
    if(b > a)
      return gcd(b,a);
    else if(b == 0)
      return a;
    else
      return gcd(b, a%b);
  }
  public static int gcd3(int a, int b, int c){
    return gcd(gcd(a, b), c);
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int ans = 0;
    
    for(int i=1;i<=k;i++){
      for(int j=1;j<=k;j++){
        for(int l=1;l<=k;l++){
          ans += gcd3(i,j,l);
        }
      }
    }
    System.out.println(ans);    
  }
}

Measured memory_bytes: 35916
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	int n, k, num = 0;

	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		if (i == 0) {
			num = k;
		}
		else {
			num *= (k - 1);
		}
		
	}

	cout << num << "\n";

	return 0;
}

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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<long long>v(n);
  for(auto& x:v)cin >> x;
  sort(v.begin(),v.end());
  long long ret = 1e9+7; 
  for(int i=0;i<=n-k;i++)ret = min(ret,v[i+k-1]-v[i]);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int n;

	while(scanf("%d",&n)!=EOF){
		int a,b,c,d,count;
		count=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if((n-a-b-c-d)==0){
							count++;
						}
					}
				}
			}
		}

		printf("%d\n",count);
	}


}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    for(int i=0; i < n; i++){
        string m;
        int l, r;
        cin >> m >> l >> r;
        if(m == "replace"){
            string re;
            cin >> re;
            for(int j=0; j < re.size(); j++)s[l+j] = re[j];
        }
        else if(m == "reverse")reverse(s.begin()+l,s.begin()+r+1);
        else if(m == "print"){
            for(int j=0; j < r-l+1; j++)cout << s[l+j];
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(){


int a,b,c,d,p;
    cin >>a >>b >>c >>d >>p;
    if(c<p){
        
        if(b+d*(p-c)<a*p){
            cout <<  b+d*(p-c)<<endl; 
        }else{
            cout <<  a*p << endl;
        }
    }else{
        if(b<a*p){
           cout <<b <<endl; 
        }else{
           cout << a*p << endl;
        }
    }


return 0;
}


Measured memory_bytes: 3080
n, k = map(int, input().split())

snuke = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))

    for j in a:
        snuke[j-1] += 1

ans = 0

for i in range(n):
    if snuke[i] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9196
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  rep(i,m) cin >> b[i];
  int a[n][m];
  rep(i,n){
    rep(j,m){
      cin >> a[i][j];
    }
  }
  int cnt = 0;
  int sum;
  rep(i,n){
    sum = c;
    rep(j,m){
      sum += a[i][j]*b[j];
    }
    if(sum > 0) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	int x = 0;
	rep(i, M) {
		int A;
		cin >> A;
		x += A;
	}
	cout << (x <= N ? N - x : -1) << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<vector<int>> val(3);
    int mod3 = 1;
    for(int i = 1; i <= N; ++i){
        val[mod3++].emplace_back(i);
        if(mod3 == 3)   mod3 = 0;
    }
    vector<vector<int>> idx(2);
    auto dfs = [&](auto&& self, int from = 0, int group = 0, int par = -1) -> void {
        idx[group].emplace_back(from);
        group ^= 1;
        for(int to : graph[from]){
            if(to == par)   continue;
            self(self, to, group, from);
        }
    };
    dfs(dfs);
    vector<int> ans(N, -1);
    if(idx[0].size() >= val[1].size() + val[2].size()){
        int cur = 0;
        for(int x : val[1]) ans[idx[0][cur++]] = x;
        for(int x : val[2]) ans[idx[0][cur++]] = x;
        int cur_idx = 0;
        while(cur < (int)idx[0].size()) ans[idx[0][cur++]] = val[0][cur_idx++];
        for(int v : idx[1]) ans[v] = val[0][cur_idx++];
    }
    else if(idx[1].size() >= val[1].size() + val[2].size()){
        int cur = 0;
        for(int x : val[1]) ans[idx[1][cur++]] = x;
        for(int x : val[2]) ans[idx[1][cur++]] = x;
        int cur_idx = 0;
        while(cur < (int)idx[1].size()) ans[idx[1][cur++]] = val[0][cur_idx++];
        for(int v : idx[0]) ans[v] = val[0][cur_idx++];
    }
    else{
        if(idx[0].size() < val[1].size())   swap(idx[0], idx[1]);
        int cur = 0;
        for(int x : val[1]) ans[idx[0][cur++]] = x;
        int cur_idx = 0;
        while(cur < (int)idx[0].size()) ans[idx[0][cur++]] = val[0][cur_idx++];
        cur = 0;
        for(int x : val[2]) ans[idx[1][cur++]] = x;
        while(cur < (int)idx[1].size()) ans[idx[1][cur++]] = val[0][cur_idx++];
    }
    for(int i = 0; i < N; ++i){
        cout << ans[i];
        cout << ((i == N - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 25640
#include <iostream>
using namespace std;
int main()
{
    int R, G, B, N, cnt = 0;
    cin >> R >> G >> B >> N;
    for (int i = 0; i * R <= N; i++)
    {
        for (int j = 0; i * R + j * G <= N; j++)
        {
            if ((N - (i * R + j * G)) % B == 0)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(snip_i, n) cin >> l.at(snip_i);
  sort(l.begin(), l.end());
  ll ans = 0;
  rrep(i, n){
    int a = l.at(i);
    for(int j = i-1; j >= 0; j--){
      int b = l.at(j);
      int mc = a - b;
      int co = upper_bound(l.begin(), l.end(), mc) - l.begin();
      co = n - co;
      co -= n - j;
      // cerr << a << " " << b << " " << co << endl;
      if(co < 0) continue;
      ans += co;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int a1 = scan.nextInt();
        float total = 0;
        float f[] = new float[50];
        for(int i = 0; i < a1; i++){
            f[i] = scan.nextFloat();
            total += 1/f[i];
        }
        Arrays.sort(f);
        float vv = 0; 
        for(float i :f){
            if(i!=0){
                if(vv == 0){
                    vv= i;
                }
                else{
                    vv = (vv+i)/2;
                }
            }
        }
        
        System.out.println(vv);
    }
}


Measured memory_bytes: 25428
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = list(map(int, input().split()))

# ループ解析
step_on = [-1] * N
current = 1
min_mv_count = 0
i = 0
for i in range(N + 1):
    #print(current)
    if i == K:
        print(current)
        exit()
    if step_on[current - 1] == -1:
        step_on[current - 1] = i
        current = A[current - 1]
        i += 1
    else:
        #print("else")
        period = i - step_on[current - 1]
        pre_mv = i - period
        min_mv_count = pre_mv + ((K - pre_mv) % period)
        #print("period {} pre_mv {}".format(period, pre_mv))
        #print("min_mv_count {}".format(min_mv_count))
        break

current = 1
#for i in range(K + 1): # 正攻法
for i in range(min_mv_count):
    current = A[current - 1]
print(current)

Measured memory_bytes: 32176
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if((c - a - b) < 0) {
        cout << "No" << endl;
    } else if(4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

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

Int A,B,C,D;

Int gcd(Int x, Int y) {
    if (y == 0)
        return x;

    return gcd(y, x % y);
}

int main(void) {
    cin>>A>>B>>C>>D;
    
    Int sumc = (B-B/C)-(A-1-(A-1)/C);
    Int sumd = (B-B/D)-(A-1-(A-1)/D);
    Int m = gcd(C,D);
    Int e = (C*D)/m;
    Int sumc_d = (B-B/e) - (A-1-(A-1)/e);

    cout<<sumc+sumd-sumc_d<<endl;

    return 0;
}


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

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

main(){
  string s,c="CODEFESTIVAL2016";
  cin >> s;
  int ans=0;
  for (int i=0;i<16;i++){
    if (s.at(i)!=c.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int n,k;
using Graph=vector<vector<int>>;
Graph G;
ll ans=0;
ll MOD=1e9+7;
vector<int>d;
vector<int>subtree_size;
int dfs(int v,int p){
    int use_c;
    if(p==-1) use_c=k-1;
    else use_c=k-2;
    if(k<G[v].size()) {
        return 0;
    }
    else{
        ll cnt=1;
    for( auto nv: G[v] ){
        if(nv==p) continue;
        cnt*=use_c;
        use_c--;
        cnt%=MOD; 
    }
    for(auto nv: G[v]){
        if(nv==p) continue;
        cnt*=dfs(nv,v);
        cnt%=MOD;
    }
    return cnt;
    }
}

signed main(){
    
    cin >> n >> k;
    G.assign(n,vector<int>());
   // d.assign(n,0);
   //subtree_size.assign(n,0);

    for (int i = 0; i < n-1; i++)
    {
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
   cout<< (k* dfs(0,-1)) % MOD <<endl;
  
    
    return 0;
}

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

int main(){
 int n,m,ans=0;
 cin >> n >> m;
 vector<int> a(m);
 vector<int> b(m,0);

 for(int i=0;i<m;i++){
	 cin >> a.at(i);
 }
 sort(a.begin(),a.end());

 for(int i=0;i<m-1;i++){
	 b.at(i)=a.at(i+1)-a.at(i);
 }
 sort(b.rbegin(),b.rend());

	for(int i=n-1;i<m-1;i++){
		ans+=b.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;

    for(int i = 0;i<s.length();i++){
        if((s[i+2] == s[i+3]) &&(s[i+4] == s[i+5])){
            cout<<"Yes";
            break;
        }
        else{
            cout<<"No";
            return 0;
        }
    }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	ans=k;
	n--;
	while(n--)
		ans*=(k-1);
	cout<<ans;
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
        return 0;
    }
    cout<<"win"<<endl;
}


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

int main() {
    int A, B, C, M, sum=0;
    int K;
    cin >> A >> B >> C;
    cin >> K;
    
    M = max(A, B);
    M = max(M, C);
    sum = A + B + C;
    
    for(int i=0; i<K; i++){
        sum += M;
        M *= 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 100;

int N;
int F[Nmax][5][2];
int P[Nmax][11];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 2; k++) {
				cin >> F[i][j][k];
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	int ans = -1000000000;
	for (int s = 1; s <= 1023; s++) {
		int value = 0;
		for (int i = 0; i < N; i++) {
			int buf = 0;
			for (int j = 0; j < 10; j++) {
				if ((s&(1 << j)) == (1 << j) && F[i][j / 2][j % 2] == 1) {
					buf++;
				}
			}
			value += P[i][buf];
		}
		ans = max(ans, value);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	vector<bool>ans(N + 1, false);
	rREP(i, 1, N + 1) {
		int cnt = 0, k = i * 2;
		while (k < ans.size()) {
			cnt += (ans[k] ? 1 : 0);
			k += i;
		}
		if (a[i - 1] == 0) {
			if (cnt % 2 == 1)ans[i] = true;
		}
		else {
			if (cnt % 2 == 0)ans[i] = true;
		}
	}
	int cnt = 0;
	vector<int>vec;
	rep(i, 1, ans.size()) {
		if (ans[i]) {
			cnt++;
			vec.push_back(i);
		}
	}
	cout << cnt << "\n";
	rep(i, 0, vec.size()) {
		cout << vec[i];
		cout<< (i < vec.size() - 1 ? " " : "\n");
	}

	return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define maxn 100050
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	string s;
	cin>>s;
	if((s[0]-'0')==(s[2]-'0')) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define rep(i, n) for(int i=0; i<n; i++)

int main() {
    int n; cin >> n;
    vector<int> p(n); rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, n){
        if(i == n-1) ans += p[i]/2;
        else ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];

		for (int i=0; i<N; i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int keiro = 1;
		for (int i=1; i<=N; i++){
			keiro *= i;
		}
		int kyoriCase = 0;
		for (int i=1; i<N; i++){
			kyoriCase += i;
		}
		int jyufuku = (keiro * (N-1)) / kyoriCase;

		double kyori=0;
		for (int i=0; i<N; i++){
			for (int j= i+1; j<N; j++){
				kyori += Math.sqrt(Math.pow(x[i] - x[j],2) + Math.pow(y[i] - y[j],2));
			}
		}

		System.out.println((jyufuku * kyori) / keiro);
	}
}

Measured memory_bytes: 23764
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var input2 = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var input3 = input2[1].split(" ");
  
  var sum = 0
  	for(var i=0;i<parseInt(input2,10); i++){
      sum = sum + 1/input3[i]
    }
  sum = 1 / sum	
  
  console.log(sum)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
llong N;
int main() {
	cin >> N;
	llong ans = N * (N - 1) / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		if(n%500<=a) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}

}


Measured memory_bytes: 20052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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 ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;

}


Measured memory_bytes: 3580
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	if (M % 2 == 0 && M >= N * 2 && M <= N * 4)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

using namespace std;

int main(){
    string s;
    int a;
    int b;
    cin >> s;
    string result = "No";
    if(s[0] == s[2] || s[0] == s[1] || s[1] == s[2]){
        result = "Yes";
    }
    if(s[0] == s[1] && s[1] == s[2] && s[0] == s[2]){
        result = "No";
    }
    cout << result << endl;
}

Measured memory_bytes: 256
n , k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
loop = []
visit = [(-1,-1) for i in range(n)]
cou = -1
for i in range(n):
    if visit[i] != (-1,-1):
        continue
    cou += 1
    tyu  = [i]
    now = i
    visit[i] = (cou,0)
    t = 1
    while True:
        nex = p[now] - 1
        if nex == i:
            break
        visit[nex] = (cou,t)
        tyu.append(nex)
        now = nex
        t += 1
    loop.append(tyu)

ans = []

for i in range(n):
    p = loop[visit[i][0]][visit[i][1]:] + loop[visit[i][0]][:visit[i][1]]
    kar = [0]
    kouho = []
    losum = 0
    lokz = len(p)
    for j in p:
        losum += c[j]
        kar.append(kar[-1] + c[j])
    if losum >= 0:
        for l in range(lokz+1):
            if l > k:
                break
            cou = losum*((k-l)//lokz) + kar[l]
            kouho.append(cou)
    elif losum < 0:
        for l in range(1,lokz+1):
            if l > k:
                break
            cou = kar[l]
            kouho.append(cou)
    ans.append(max(kouho))
print(max(ans))


Measured memory_bytes: 112048
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

#define num 1000000001
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    map<int, int> m;
    rep(i, n) {
      int a;  cin >> a;
      m[a]++;
    }
    for (auto const& entry: m) {
      if (entry.first > entry.second) {
        ans += entry.second;
      } else {
        ans += entry.second - entry.first;
      }
    }
    cout << ans << '\n';

    return 0;
}


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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    numbers = list(input())
    a = numbers[0]
    b = numbers[1]
    c = numbers[2]
    d = numbers[3]
    
    # See:
    # https://abc079.contest.atcoder.jp/submissions/1917934
    ops = ['+', '-']

    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                expression = a + op1 + b + op2 + c + op3 + d
                
                if eval(expression) == 7:
                    print(expression + '=7')
                    exit()


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

def dfs(s):
  ret = 0
  if s == '':
    pass
  elif int(s) > n:
    return 0
  else:
    if '7' in s and '5' in s and '3' in s:
      ret = 1
  
  for c in ['7', '5', '3']:
    ret += dfs(s+c)
  
  return ret

print(dfs(''))

Measured memory_bytes: 3060