akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m);
  rep(i,m) cin >> a[i];
  ll ans = 0;
  rep(i,m) ans += a[i];
  if (ans <= n) {
    cout << n - ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
 


Measured memory_bytes: 3244
#include <iostream>
#include <cstring>

using namespace std;

void a() {
	int x;
	cin >> x;
	cout << ((x == 3 || x == 5 | x == 7) ? "YES" : "NO") << endl;
}

void b() {
	char s[11];
	cin >> s;
	int min = 999;
	for (int i = 0; i <= (signed)(strlen(s) - 3); i++) {
		int t = 0;
		t += (s[i] - '0') * 100;
		t += (s[i + 1] - '0') * 10;
		t += (s[i + 2] - '0') * 1;
		int tmin = (t > 753) ? t-753: 753-t;
		if (tmin < min)
			min = tmin;
	}
	cout << min << endl;
}

int main()
{
	b();
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int N = 5;
    vector<int> time = {a, b, c, d, e};
    vector<int> nexttime(N);
    rep(i, N){
        if(time[i] % 10 == 0) nexttime[i] = time[i];
        else nexttime[i] = time[i] - time[i] % 10 + 10;
    }

    int besttime = 99999999;
    rep(i, N){
        int sumtime = 0;
        rep(j, N){
            if(i == j){ //一番最後の加算（最後の料理を注文してから届くまでの時間を加算する）時の操作
                sumtime += time[j];
            }else{ //一番最後以外の、time以上の10の倍数をsumtimeに加算する操作
                sumtime += nexttime[j];
            }
        }
        besttime = min(besttime, sumtime);
    }
    cout << besttime << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
 
# dp[i][j] := Sのi文字目, Tのj文字目まで見た場合のLCS
dp = [[0] * (len(T) + 1) for i in range(len(S) + 1)]
 
for i in range(1, len(S) + 1):
    for j in range(1, len(T) + 1):
        if S[i - 1] == T[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
 
ans = ''
i, j = len(S), len(T)
while i > 0 and j > 0:
    if S[i - 1] == T[j - 1]:
        ans += S[i - 1]
        i, j = i - 1, j - 1
    elif dp[i][j - 1] > dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
 
print(ans[::-1])

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

int main(){
  int N,ans;
  cin >> N;
  ans=0;
  for(int i=0;i<N;i++){
    int j,t;
    j=i+1;
    t=((N+j-1)/j)-1;
    ans+=t;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3628
#include<iostream> 
using namespace std; 
int main(){
    int W,H ,x,y,r; 
    cin>>W>>H>>x>>y>>r;
    if(x-r>=0 && W>=x+r && 0<=y-r && y+r<=H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
    
}


Measured memory_bytes: 3104
import sys
from collections import Counter


class Poker(object):
    def __init__(self, cards):
        # ?????????????????????????????????????????§?????????(??????)???????????????
        self.cards = cards[:]
        self.cards.sort(reverse=True)

    def evaluate_hand(self):
        """ ???????????????????????????????????????????????????
        ????????????????????\??????????????????????????????????????§?????????????????\???????????¬????????????????????\???????????????????????¬????????????????????\?????±????????????
        - null
        - one pair
        - two pair
        - three card
        - straight
        - full house
        - four card
        """
        if (self.cards[0] == self.cards[1]+1 == self.cards[2]+2 == self.cards[3]+3 == self.cards[4]+4) or \
            (self.cards[0] == 13 and self.cards[1] == 12 and self.cards[2] == 11 and self.cards[3] == 10 and self.cards[4] ==1):
            return 'straight'
        else:
            c = Counter(self.cards)
            hand = c.most_common()  # ????????°?????????????????°????????????????????????(???: ????????????)?????????????????????????????????
            if hand[0][1] == 4:
                return 'four card'
            elif hand[0][1] == 3 and hand[1][1] == 2:
                return 'full house'
            elif hand[0][1] == 3:
                return 'three card'
            elif hand[0][1] == 2 and hand[1][1] == 2:
                return 'two pair'
            elif hand[0][1] == 2:
                return 'one pair'
            else:
                return 'null'


if __name__ == '__main__':
    # ??????????????\???
    for line in sys.stdin:
        cards = [int(x) for x in line.strip().split(',')]

        # ??????????????????
        p1 = Poker(cards)
        result = p1.evaluate_hand()

        # ???????????¨???
        print(result)

Measured memory_bytes: 7908
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,x;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b>c+d)	printf("Left\n");
	else if(a+b==c+d)	printf("Balanced\n");
	else printf("Right\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	cout << (min(a + b + 1, c) + b);
	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++)
#define REPI(i,a,b) for(int i=int(a);i<=int(b);++i)

void solve(long long A, long long B){
  long long count = 0;
  REPI(i,A,B){
    string s = to_string(i);

    bool isr = true;
    REP(j, 2) {
      if(s[j] != s[4-j]) isr = false;
    }
    if(isr) count++;
  }

  cout << count << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int D = Integer.parseInt(sc.next());
		int G = Integer.parseInt(sc.next());
		int[][] p = new int[D][2];
		for(int i=0; i<D; i++){
			p[i][0] = Integer.parseInt(sc.next());	//問題数
			p[i][1] = Integer.parseInt(sc.next());	//ボーナス点
		}
		
		int ans = Integer.MAX_VALUE;
		
		for(int i=0; i<(1<<D); i++){
			int solve = 0;
			int need = G;
			for(int j=0;j<D;j++){
				if((i>>j & 1)==1){
					solve += p[j][0];
					need -= ((j+1)*100*p[j][0] + p[j][1]);
				}
			}
			
			if(need>0){
				for(int k=D-1; k>=0; k--){
					if(((i>>k) & 1)== 1)continue;
					int count=0;
					while(p[k][0]>count){
						need -= (k+1)*100;
						solve++;
						count++;
						if(need<=0)break;
					}
					if(need>0)solve=Integer.MAX_VALUE;
					break;
				}
			}
			if(solve < ans)ans = solve;
		}		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22740
#include <stdio.h>

#define STUDENTS 39

int main(void) 
{
	int candy, student;

	while (scanf("%d", &candy) != EOF) {
		student = candy % STUDENTS;

		if (student == 0) 
			student = STUDENTS;

		printf("3C%02d\n", student);
	}

	return 0;
}

Measured memory_bytes: 608
package main

import (
	"bytes"
	"fmt"
)

func bytesReverse(a []byte) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return
}

func main() {
	var input string
	fmt.Scan(&input)
	s := []byte(input)
	bytesReverse(s)

	words := [][]byte{[]byte("maerd"), []byte("remaerd"), []byte("esare"), []byte("resare")}

	ok := true
	for len(s) > 0 {
		canDivide := false
		for _, word := range words {
			if bytes.HasPrefix(s, word) {
				s = bytes.TrimPrefix(s, word)
				canDivide = true
				break
			}
		}
		if !canDivide {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

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

/*********** TEMPLATE ENDS HERE *************/

main()
{
	int x, a, b;
	cin >> x >> a >> b;
	
	cout << (x - a) % b;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, q;
int a[100], b[100], c[100], d[100];
int s[20], ans;
void dfs(int cur, int lst) {
	if (cur > n) {
		int cnt = 0;
		for (int i = 1; i <= q; i++) {
			if (s[b[i]] - s[a[i]] == c[i]) {
				cnt += d[i];
			}
		}
		ans = max(ans, cnt);
		return;
	}
	for (int i = lst; i <= m; i++) {
		s[cur] = i;
		dfs(cur + 1, i);
	}
}
int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(1, 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3588
str = gets.chomp.split('')
uniq = str.uniq

if uniq.length != 2
    puts 'No'
    exit
end

flag = true
uniq.each {|chr|
    flag = false if str.select{|c| c == chr}.length != 2
}

if flag
    puts 'Yes'
else
    puts 'No'
end


Measured memory_bytes: 1788
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for n in range(N)]
sum,count = 0,0

for i in range(N):
	for j in range(M):
		sum += A[i][j]*B[j]
	if sum+C > 0:
		count += 1
	sum = 0
print(count)

Measured memory_bytes: 9148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  _l=LI()

  l=[]
  for i,x in enumerate(_l):
    l.append(x-(i+1))

  l.sort()
  if n%2==1:
    x=l[n//2]
  else:
    x=(l[n//2]+l[n//2-1])//2

  ans=0
  for y in l:
    ans+=abs(y-x)

  return ans

# main()
print(main())


Measured memory_bytes: 27820
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
using namespace std;


int main() {
    int n;
    cin>>n;
    while(n>=0){
      if(n%4==0){
        Yes;
        return 0;
      }
      n-=7;
    }
    No;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		boolean ans = false;

		ans = ans || str.matches("k.*eyence");
		ans = ans || str.matches("ke.*yence");
		ans = ans || str.matches("key.*ence");
		ans = ans || str.matches("keye.*nce");
		ans = ans || str.matches("keyen.*ce");
		ans = ans || str.matches("keyenc.*e");

		if (ans)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector <pair <int , int>> a(n);
  for (int i=0 ; i<n ; i++){
    int b ;
    cin >> b;
    a.at(i) = make_pair(b,i+1) ;
  }
  sort ( a.begin() , a.end() ) ;
  for ( int i = 0 ; i< n ; i++){
    int c,b;
     tie(c,b)=a.at(i) ;
    cout << b << ' ';
  }
  cout << endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

int main(void)
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> grid(h, vector<int>(w, 0));
	rep(i, h) {
		rep(j, w) {
			cin >> grid[i][j];
		}
	}
	vector<vector<ll>> dp(h, vector<ll>(w, 1));
	ll width = 0;
	rep(i, h) {
		rep(j, w) {
			if (!grid[i][j]) {
				width = 1;
			}
			else {
				dp[i][j] = 0;
			}
		}
	}
	rep(i, h-1) {
		rep(j, w-1) {
			if (!grid[i + 1][j + 1]) {
				ll p = min(dp[i][j], min(dp[i][j + 1], dp[i + 1][j]));
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], p + 1);
			}
			width = max(width, dp[i + 1][j + 1]);
		}
	}
	cout << width * width << endl;
	return 0;
}



Measured memory_bytes: 25756
# C
# 初期N人の参加者がK点のポイントを持っている
N,K,Q = map(int,input().split())
answers = [K-Q]*N
for _ in range(Q):
  a = int(input())
  answers[a-1] += 1

for ans in answers:
  if ans > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 11704
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 3000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
    ll n, t, q, a; cin >> n >> t >> q;
    vector<vector<ll>> hito(n + 1, vector<ll>(2));
    vector<ll> v; v.push_back(0 - 1 - INF);
    for (int h = 1; h <= n; h++) {
        cin >> hito[h][0] >> hito[h][1];
    }
    for (int h = 2; h <= n; h++) {
        if (hito[h - 1][1] == 1 && hito[h][1] == 2) {
            v.push_back((hito[h - 1][0] + hito[h][0]) / 2);
        }
    }
    v.push_back(INF + 1);
    for (int h = 0; h < q; h++) {
        cin >> a; ll b = hito[a][0], c = lower_bound(v.begin(), v.end(), b) - v.begin();
        if (hito[a][1] == 1) {//右
            cout << min(b + t, v[c]) << endl;
        }
        else {
            cout << max(b - t, v[c - 1]) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8704
N,A = map(int,input().split())
X = map(int,input().split())
X = [x-A for x in X]
dp = [[0]*(5001) for _ in range(N+1)]
dp[0][2500] = 1
for i in range(1,N+1):
    x = X[i-1]
    for j in range(5001):
        dp[i][j] += dp[i-1][j]
        if 0<=j-x<5001:
            dp[i][j] += dp[i-1][j-x]

print(dp[-1][2500]-1)



Measured memory_bytes: 41584
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int INF=0x3f3f3f3f;
const int N=2e5+10,M=N*400,mod=1e9+7;
int n;
struct node{
    LL x,h;
    bool operator<(const node t)const{
        return x<t.x;
    }
}s[N];
LL a,d;
LL p[N];//前缀
int main()
{
    cin>>n>>d>>a;
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&s[i].x,&s[i].h);
    }
    sort(s+1,s+1+n);
    int r=0;
    LL ans=0;
    for(int l=1;l<=n;l++){


        p[l]+=p[l-1];s[l].h+=p[l];
        //cout<<s[l].x<<' '<<p[l]<<' '<<s[l].h<<' ';
        while(r<n&&s[r+1].x<=s[l].x+2*d)r++;
        if(s[l].h<0)s[l].h=0;
        LL k=s[l].h/a+(s[l].h%a>0);
        ans+=k;
        p[l]-=k*a;
        p[r+1]+=k*a;
        //cout<<l<<' '<<r<<' '<<ans<<' '<<p[l]<<endl;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 1e5+5;




void solve(){
  int n;
  cin>>n;
  ll ans=0;n--;
  for (int i = 1; i <=n; ++i){
    ans+=(n/i);
  }
  cout<<ans<<'\n';
    
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout); 
    #endif
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        int T=1;
        //cin>>T;
        while(T--){
          solve();
        }
        return 0;
        
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int64_t ans=0;
  for(int i=0;i<(n-k);i++){
    ans+=a.at(i);
  }
  cout<<ans<<endl;
}
  
  


Measured memory_bytes: 4020
#include <iostream>
#include<string>
using namespace std;
int main() {
    string week[]={"", "SAT","SUN", "MON", "TUE", "WED", "THU", "FRI"};
    string s;
    cin>>s;
    int i=1;
    while(i<=7){
        if(s==week[i]){
            break;
        }
        i++;
    }
    if(i==1){
        cout<<1<<endl;
    }
    else{
        int ns=(7-i)+2;
        cout<<ns;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{

  int N,C,K;cin>>N>>C>>K;

  int ANS = 0;
  int CNT= 0;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec));
    int NOW = 0;
      int PREV = vec[0];

  for (int i = 0; i < N; i++)
  {
    int X = vec[i];
    NOW = X;
    if(NOW - PREV > K || CNT >= C)
    {
      PREV = NOW;CNT = 0;
      ANS++;
    }
      CNT++;
    
    
  }
  if(CNT != 0)
  ANS++;
  cout<<ANS<<endl;;
  

  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main(void){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  bool k = true;
  for(int i = 0; i < n-1; i++){
    if(a.at(i) == a.at(i+1)){
      k = false;
    }
  }
  if(k) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    long long N, A, B;

    scanf("%lld%lld%lld", &N, &A, &B);

    long long X[N];

    for(long long i = 0; i < N; i++){
        scanf("%lld", &X[i]);
    }

    long long ans = 0;

    for(long long i = 1; i < N; i++){
        if(A * (X[i] - X[i-1]) < B){
            ans += A * (X[i] - X[i-1]);
        }else{
            ans += B;
        }
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 2460
#include<iostream>
int main(){
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++){
		int a=0,b=0,c=0;
		std::cin>>a>>b>>c;
		if(a>b&&a>c&&a*a==b*b+c*c){
			std::cout<<"YES"<<std::endl;
		}else if(b>a&&b>c&&b*b==a*a+c*c){
			std::cout<<"YES"<<std::endl;
		}else if(c>a&&c>b&&c*c==a*a+b*b){
			std::cout<<"YES"<<std::endl;
		}else std::cout<<"NO"<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
class Array
  
  def dice_expected_value
    map{|x| (x + 1 ) / 2.0 }
  end
  def cumsum; s = 0; map{|k| s += k } end
end

n, k = gets.to_s.split.map{|t|t.to_i}
d = gets.to_s.split.map{|t|t.to_i}
c = d.dice_expected_value.cumsum.unshift(0)

ans = 0
k.upto(n) do |t|
  
  tmp = c[t] - c[t-k]
  ans = tmp if ans < tmp
end

puts ans

Measured memory_bytes: 18828
n = gets.to_i
cards = []
n.times do
  cards.push(gets.to_s)
end

for c in ["S", "H", "C", "D"]
  for i in 1..13
    puts c + " " + i.to_s if !cards.include?(c + " " + i.to_s + "\n")
  end
end



Measured memory_bytes: 6856
import java.util.Scanner;

public class Main {
    static int n;
    static int state[];
    static int a[];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        state = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        for(int i=0; i<q; i++){
            int m = sc.nextInt();
            boolean f_res = search(0, 0, m);
            if(f_res){
                System.out.println("yes");
            }else{

                System.out.println("no");
            }
        }
    }
    static boolean search(int idx, int sum, int res){
        if(sum == res){
            return true;
        }
        if(idx==n){
            return false;
        }
        //??????
        if(search(idx+1, sum, res)){
            return true;
        }
        //??????
        sum += a[idx];
        if(search(idx+1, sum, res)){
            return true;
        }
        return false;
    }
}

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

int main()
{
	int h, w, k;
	cin >> h >> w >> k;

	vector<string> s(h);
	for (int i = 0; i < h; ++i) cin >> s[i];

	int ans = h + w - 2;

	for (int horizonPat = 0; horizonPat < 1 << (h - 1); ++horizonPat)
	{
		vector<int> cutPos;
		cutPos.clear();
		cutPos.emplace_back(0);

		int tmpAns = 0;

		for (int i = 0; i < h; ++i)
		{
			if (horizonPat >> i & 1)
			{
				tmpAns++;
				cutPos.emplace_back(i + 1);
			}
		}

		cutPos.emplace_back(h);

		vector<vector<int>> a;
		vector<int> b;
		a.clear();
		b.clear();

		for (int i = 0; i < cutPos.size() - 1; ++i)
		{
			b.clear();

			for (int column = 0; column < w; ++column)
			{
				int cnt = 0;

				for (int row = cutPos.at(i); row < cutPos.at(i + 1); ++row)
				{
					if (s[row][column] == '1') cnt++;
				}

				b.emplace_back(cnt);
			}

			a.emplace_back(b);
		}

		int startColumnIdx = 0;
		for (int verticalIdx = 0; verticalIdx < w; ++verticalIdx)
		{
			for (int i = 0; i < a.size(); ++i)
			{
				int checkVal = 0;

				for (int j = startColumnIdx; j <= verticalIdx; ++j)
				{
					checkVal += a.at(i).at(j);

					if (checkVal > k)
					{
						if (startColumnIdx == verticalIdx)
						{
							i = a.size();
							verticalIdx = w;
							tmpAns = h + w - 2;
							break;
						}
						else
						{
							startColumnIdx = verticalIdx;
							tmpAns++;
							break;
						}
					}
				}
			}
		}

		if (ans > tmpAns) ans = tmpAns;
	}

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define LIMIT 200001 //制約より、1≤|S|≤200000  
int main()
{
	//変数を定義
	char s[LIMIT], t[LIMIT], c1, c2;
	
	//文字列を入力
	scanf("%s", s, LIMIT);
	scanf("%s", t, LIMIT);

	//配列の文字数を取得する
	int numberLetter = strlen(s);

	//s[i]をc1、t[i]をc2として比較、処理をする
	for (int i = 0; i < numberLetter; i++) {
		//s[i]とt[i]が異なった時は操作を行う
		if (s[i] != t[i]) {
			c1 = s[i]; //s[i]をc1として操作
			c2 = t[i]; //t[i]をc2として操作
			for (int j = 0; j < numberLetter; j++) {
				//c1、c2をsの最初の文字から比較
				if (s[j] == c1 || s[j] == c2) {
					//c1かc2と同じ文字がi番目より前にある場合は同じ文字列に出来ないので処理終了
					if (j < i) {
						printf("No\n");
						return 0;
					}
					//操作を行う
					if (s[j] == c1) {
						s[j] = c2;
					}
					else {
						s[j] = c1;
					}
				}
			}
		}
	}
	//ループを抜けた場合はsをtに一致させる事ができるのでYesを出力
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	ll a, b, c; cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		printf("0\n"); return 0;
	}else{
		ll mi = min(a, min(b, c));
		ll ma = max(a, max(b, c));
		ll mannnaka = a + b + c - mi - ma;
		printf("%lld\n", mi * mannnaka);
	}

	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int c[5];

  while(scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
    int n[13] = {};
    REP(i, 5) n[c[i]-1]++;

    int first = 0, second = 0, straight = 0;
    REP(i, 13) {
      if(n[i] > 0 && n[(i+1)%13] > 0) 
	straight++;
      if(first < n[i]) {
	second = first;
	first = n[i];
      } else if(second < n[i]) {
	second = n[i];
      }
    }

    if(first == 4) cout << "four card" << endl;
    else if(first == 3) {
      if(second == 2) cout << "full house" << endl;
      else cout << "three card" << endl;
    }
    else if(straight == 4 ) {
      if(n[12] > 0 && n[0] > 0 && n[1] > 0) cout << "null" << endl;
      else cout << "straight" << endl;
    }
    else if(first == 2 && second == 2) cout << "two pair" << endl;
    else if(first == 2) cout << "one pair" << endl;
    else cout << "null" << endl;
  }
}

Measured memory_bytes: 1204
N,K = map(int,input().split())
count = 0
if K == 0:
    print(N*N)
else:
    for b in range(K+1,N+1):
        x = N // b
        y = N % b
        count = count + (b-K)*x
        if y >= K:
            count = count + y-K+1
    print(count)

Measured memory_bytes: 3060
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let mut tmp = h;
    let mut result: usize = 0;
    let mut cnt: usize = 1;
    while tmp > 0 {
        //    println!("{} {}", tmp, result);
        tmp /= 2;
        result += cnt;
        cnt *= 2;
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    ll a;
    vector<ll> A;

    cin >> N;

    for(ll i = 0; i < N; i++){
        cin >> a;
        A.push_back(a);
    }

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

    for(ll i = 0; i < N - 1; i++){
        if(A[i] == A[i + 1]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  
  int x[110];
  int y[110];//これ使ってなくない
  rep(i,n)cin>>x[i];
  
  int ans=1000000000;
  
  for(int k=0;k<=100;k++){
    int check=0;
  for(int j=0;j<n;j++){
   	check +=(k-x[j])*(k-x[j]);
    }
      ans=min(ans,check);
  }
  cout<<ans<<endl;

  
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  ll r,d,x;
  cin>>r>>d>>x;

  for(int i=1;i<=10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }

  return 0;
}


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

int main(){
    int N;
    string S,F,B;
    cin >> N >> S;
    if(N%2 == 1){
        cout << "No" << endl;
    }else{
        F = S.substr(0,N/2);
        B = S.substr(N/2);
        cout << (F==B ? "Yes" : "No") << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll X,Y;
  cin >> X >> Y;
  if(Y>=2*X&&Y<=4*X&&Y%2==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int ans =0;
  int n;
  cin>>n;
  for(int i=1; i<=n; i++){
    int tmp;
    cin>>tmp;
    if(i%2 ==1 && tmp %2 ==1 ) ans++;
  }
  cout<<ans<<endl;
//    cout << fixed << setprecision(10);
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}
int mx=0;
void cal(vector <int> a,int index,int val,int n,int m,vector <vector <int>  > &v,int q);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt(),q=nxt();
    vector <vector <int>  > v(q,vector <int> (4));
    for(int i=0;i<q;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2]>>v[i][3];

    vector <int> a(n);
    cal(a,0,1,n,m,v,q);
    cout<<mx<<endl;

    
    return 0;   
}

void cal(vector <int> a,int index,int val,int n,int m,vector <vector <int>  > &v,int q)
{
    if(index==n)
    {
        int temp=0;
        for(int i=0;i<q;i++)
        {
            if(a[v[i][1]-1]-a[v[i][0]-1]==v[i][2])
                temp+=v[i][3];
        }
        mx=max(temp,mx);
    }
    else
    {
        for(int i=val;i<=m;i++)
        {
            a[index]=i;
            cal(a,index+1,i,n,m,v,q);
        }
    }
}




 
 


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  long long int in;
  while(cin>>in,in){
    long long int sum=0;
    double tmp=sqrt(in);
    int co;
    if(tmp-(int)tmp!=0.0)co=(int)tmp+1;
    else co=(int)tmp+2;
    loop(i,1,co)if(in%i==0){
      if(in!=i*i)sum+=in/i+i;
      else sum+=i;
    }
    sum-=in;
    if(sum==in)cout<<"perfect number"<<endl;
    else if(sum<in)cout<<"deficient number"<<endl;
    else cout<<"abundant number"<<endl;
  }


}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 18;
int arr[1 << MAX], max_subset[1 << MAX];
int n;

int main() {
	scanf("%d", &n);
	fori(i, 0, 1 << n) {
		scanf("%d", arr + i);
	}

	int best = 0;
	fori(mask, 1, 1 << n) {
		int cur_best = arr[mask];
		for(int sub = (mask - 1) & mask; sub > 0; sub = (sub - 1) & mask) {
			best = max(best, cur_best + arr[sub]);
			cur_best = max(cur_best, arr[sub]);
		}
		best = max(best, cur_best + arr[0]);
		printf("%d\n", best);
	}

	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s,t;
  cin>>s>>t;int c=0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i])c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (X, Y, Z) = (input[0], input[1], input[2])
print((X-Z)/(Y+Z))


Measured memory_bytes: 7524
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);

    for(long long i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    vector<bool> divide(1000001, false);
    vector<bool> seen(1000001, false);

    for(long long i = 0; i < n; i++){
        if(seen[a[i]] == true){
            divide[a[i]] = true;
            continue;
        }

        seen[a[i]] = true;

        for(long long j = 2 * a[i]; j <= 1000000; j += a[i]){
            seen[j] = true;
            divide[j] = true;
        }
    }
    long long cnt = 0;

    for(long long i = 0; i < n; i++){
        if(divide[a[i]] == false) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5088
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<int,int>
const int maxn=1e6+5;
signed main() { 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> arr(n),num(1000000),div(1000000);
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
    	num[arr[i]]++;
    }
    for(int i=1;i<=1000000;i++)
    {
    	for(int j=i;j<=1000000;j+=i)
    		div[j]+=num[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	if(div[arr[i]]==1)ans++;
    }
    cout<<ans;
}

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

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> size;
	
	UnionFind(int N) : par(N), rank(N), size(N){
		rep(i,N){
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
	}
	
	int root(int x) {
		if (par[x] == x) return x;
		par[x] = root(par[x]);
		return par[x];
	}
	
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		if(rank[rx] < rank[ry]){
			par[rx] = ry;
			size[ry] += size[rx];
		}else{
			par[ry] = rx;
			size[rx] += size[ry];
			if(rank[rx] == rank[ry]) rank[rx]++;
		}
	}
	
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

vector<int> block[100005];
vector<int> tomo[100005];

int main(){
	int N,M,K;
	cin >> N >> M >> K;
	UnionFind uf(N);
	rep(i,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		uf.unite(a,b);
		tomo[a].push_back(b);
		tomo[b].push_back(a);
	}
	
	rep(i,K){
		int c,d;
		cin >> c >> d;
		c--;d--;
		block[c].push_back(d);
		block[d].push_back(c);
	}
	
	rep(i,N){
		int ans = uf.size[uf.root(i)] - 1 - tomo[i].size();
		for (auto v : block[i]){
			if(uf.same(i,v)) ans--;
		}
		cout << ans << " ";
	}
	cout << endl;
	
    return 0;
}

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

int main() {

    int N;
    cin >> N;

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int ans = H[0];

    for (int i = 0; i < N - 1; i++) {
        ans += max(0, H[i + 1] - H[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

struct Inversions{// tentosu
	// after init,u can get number of inversions num_inverstion(A)
	vector<ll> L,R;
	void initsize(ll n){//input size of A
		L.resize(n/2+2);
		R.resize(n/2+2);
	}
	ll merge(vector<ll> &A,ll n,ll left,ll mid,ll right){
		ll i,j,k;
		ll cnt = 0;
		ll n1 = mid - left;
		ll n2 = right - mid;
		for(i=0;i<n1;i++)L[i]=A[left+i];
		for(i=0;i<n2;i++)R[i]=A[mid+i];
		L[n1]=R[n2]=INT_MAX;//
		i=j=0;
		for(k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i++];
			}else{
				A[k]=R[j++];
				cnt += n1-i;
			}
		}
		return cnt;
	}
	ll mergeSort(vector<ll> &A,ll n,ll left,ll right){
		ll mid;
		ll v1,v2,v3;
		if(left+1<right){
			mid = (left+right)/2;
			v1 = mergeSort(A,n,left,mid);
			v2 = mergeSort(A,n,mid,right);
			v3 = merge(A,n,left,mid,right);
			return v1+v2+v3;
		}else return 0;
	}
	ll num_inverstion(vector<ll> A){
		vector<ll> B=A;
		return mergeSort(B,B.size(),0,B.size());
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	FOR(i,0,n)cin>>a[i];
	if(n==1){
		cout<<a[0]<<endl;
		return 0;
	}
	ll l = 1,r = 1e9+1;
	Inversions in;
	in.initsize(n+1);
	while(r-l>1){
		ll mid = (r+l)/2;
		vector<ll> m,t;
		m = a;
		FOR(i,0,n){
			if(m[i]<mid)m[i] = -1;
			else m[i] = 1;
		}
		t.push_back(0);
		ll wa = 0;
		FOR(i,0,n){
			wa += m[i];
			t.push_back(wa);
		}
		ll ten = in.num_inverstion(t);
		if( (n*(n+1)/4+1) >= ten){
			l = mid;
		}else{
			r = mid;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 5264
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int n = scan.nextInt();
		int[][] data = new int[m][n];
		int[] datac = new int[n];
		int sum = 0;
		for(int i = 0 ; i < m ; i++){
			for(int j = 0 ; j < n ; j++){
				data[i][j]=scan.nextInt();
			}
		}
		for(int i = 0 ; i < n; i ++){
			datac[i]=scan.nextInt();
		}
		for(int i = 0 ; i < m ; i++){
			for(int j = 0 ; j < n ; j++){
				sum+=data[i][j]*datac[j];
			}
			System.out.println(sum);
			sum=0;
		}
	}
}

Measured memory_bytes: 31796
use proconio::{input,marker::Usize1};

fn main() {
   input! {
      n:usize,
      mut k:usize,
      mut a:[Usize1;n],
   }

   let mut ans = 0;
   while k != 0 {
      if k & 1 == 1 {
         ans = a[ans];
      }
      let b = a.clone();
      for j in 0..n {
         a[j] = b[a[j]];
      }
      k >>= 1;
   }

   println!("{}", ans+1);
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    int x = s.size();
    for (int i = 0; i < x; i++) {
        if (s.at(i) != t.at(i)) {
            cnt++;
        }
    }
    cout << cnt << endl;
return 0;
}

Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool sorting(const pair<ll,ll >&a,const pair<ll,ll>&b)
{
    return a.second<b.second;
}
int main()
{
    ll n,i,j,k,l,m,s,c;
    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    vector<pair <ll,ll> >vc;
    cin>>n>>k;
    c=0;
    for(i=0; i<n; i++)
    {
        cin>>l;
        if(mp[l]==0)
        {
            c++;
        }
        mp[l]++;
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        vc.push_back( make_pair(it->first,it->second));
    }
    sort(vc.begin(),vc.end(),sorting);
    s=0;
    for(i=0;i<(c-k);i++)
    {
        s+=vc[i].second;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 17392
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
    string s;
    cin>>s;
  
    int n = s.length(); 
    char char_array[n + 1]; 
  
    strcpy(char_array, s.c_str()); 
  
  if(s[2]==s[3] && s[4]==s[5]){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
    	
  
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int main(){
    int n; cin >> n;
    int a[2][n];
    rep(i,2){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    int mx = -1;
    for(int i =0;i<n;i++)
    {

        int sum =0;
        for (int j=0;j<=i;j++) sum+=a[0][j];
        for (int j=i;j<n;j++) sum +=a[1][j];
        if (mx<sum)
            mx=sum;
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 632
{-
C++??????????§????
/*
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2104
?????????: Country Road
????????????: ??¶?????¨??¨????????§????????????????¢?????????????????????¢?????????????????????????¶????????????????
??????????????¨: ?§?????????????????????¨?????????Haskell??§????????¨????????????????????¬??????
*/
-}
import Data.List(sort)

toInts :: String -> [Int]
toInts = map read . words

main = do
 t <- fmap read getLine
 sequence_ . replicate t $ do
  [n,k] <- fmap toInts getLine
  xs <- fmap toInts getLine
  print . sum . drop (k-1) . reverse . sort . makeDiff $ xs

makeDiff [_] = []
makeDiff (x:y:xs) = (y-x) : makeDiff (y:xs)

Measured memory_bytes: 38944