akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
int dp[105][105][2];
signed main() {
    int H,W;
    cin >> H >> W;
    vector<string>S(H);
    for(int i = 0; i < H; i++) {
        cin >> S[i];
    }
    for(int i = 0; i < 105; i++) {
        for(int j = 0; j < 105; j++) {
            for(int k = 0; k < 2; k++) {
                dp[i][j][k] = INF;
            }
        }
    }
    if(S[0][0] == '#') {
        dp[0][0][1] = 1;
    }
    else {
        dp[0][0][0] = 0;
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(dp[i][j][0] != INF) {
                if(i+1 < H) {
                    if(S[i+1][j] == '#') dp[i+1][j][1] = min(dp[i+1][j][1],dp[i][j][0]+1);
                    else dp[i+1][j][0] = min(dp[i+1][j][0],dp[i][j][0]);
                }
                if(j+1 < W) {
                    if(S[i][j+1] == '#') dp[i][j+1][1] = min(dp[i][j+1][1],dp[i][j][0]+1);
                    else dp[i][j+1][0] = min(dp[i][j+1][0],dp[i][j][0]);
                }
            }
            if(dp[i][j][1] != INF) {
                if(i+1 < H) {
                    if(S[i+1][j] == '#') dp[i+1][j][1] = min(dp[i+1][j][1],dp[i][j][1]);
                    else dp[i+1][j][0] = min(dp[i+1][j][0],dp[i][j][1]);
                }
                if(j+1 < W) {
                    if(S[i][j+1] == '#') dp[i][j+1][1] = min(dp[i][j+1][1],dp[i][j][1]);
                    else dp[i][j+1][0] = min(dp[i][j+1][0],dp[i][j][1]);
                }
            }
        }
    }
    cout << min(dp[H-1][W-1][0],dp[H-1][W-1][1]) << endl;
}


Measured memory_bytes: 3756
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int x = read.to!int;
	int a = read.to!int;
	
	int ans;
	if(x < a) ans = 0;
	else ans = 10;
	
	ans.writeln;
	
	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[111111];
bool chk(){
	int l=strlen(s);
	for(int i=0; i+1<l; i++)
		if(s[i]==s[i+1]){
			printf("%d %d\n",i+1,i+2);
			return true;
		}
	for(int i=0; i+2<l; i++)
		if(s[i]==s[i+2]){
			printf("%d %d\n",i+1,i+3);
			return true;
		}
	return false;
}
int main(){
	scanf("%s",s);
	if(!chk())
		puts("-1 -1");
	return 0;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	string a, b, c;
	cin >> a >> b >> c;
	printf("A%cC\n", b[0]);
}


Measured memory_bytes: 256
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int n; cin >> n;
  bool ok = false;
  while(n) {
    if(n % 10 == 7) ok = true;
    n /= 10;
  }
  cout << (ok ? "Yes\n" : "No\n");
}

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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

double dist(pair<int,int> a, pair<int,int> b){
	double dx, dy;
	dx = a.first - b.first;
	dy = a.second - b.second;
	return sqrt(dx*dx + dy*dy);
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> to(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b; a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> one_case(n);
	rep(i,n) one_case[i] = i;
	int ans = 0;
	do {
		if (one_case[0] != 0) continue;
		bool visited = false;
		rep(i,n) {
			if (i == 0) continue;
			int pre_pos = one_case[i - 1], pos = one_case[i];
			for (auto x : to[pre_pos]) {
				if (x == pos) {
					visited = true;
					break;
				}
				else visited = false;
			}
			if (!visited) break;
		}
		if (!visited) continue;
		ans++;
	} while(next_permutation(one_case.begin(), one_case.end()));
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

const int MAX_N = 200005;

int N, P[MAX_N], mn[MAX_N * 4][2];

int _min(int x, int y) {
  return P[x] < P[y] ? x : y;
}

void build(int x, int l, int r) {
  if (l == r) {
    mn[x][l & 1] = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid), build(x << 1 | 1, mid + 1, r);
  mn[x][0] = _min(mn[x << 1][0], mn[x << 1 | 1][0]);
  mn[x][1] = _min(mn[x << 1][1], mn[x << 1 | 1][1]);
}

int query(int x, int L, int R, int l, int r, int op) {
  if (l <= L && R <= r)
    return mn[x][op];
  int mid = (L + R) >> 1, mn = 0;
  if (mid >= l) mn = query(x << 1, L, mid, l, r, op);
  if (mid < r) mn = _min(mn, query(x << 1 | 1, mid + 1, R, l, r, op));
  return mn;
}

class Data {
public:
  int l, r, k1, k2;
  inline friend bool operator < (const Data &a, const Data &b) {
    return P[a.k1] > P[b.k1];
  }
  Data() { }
  Data(int L, int R) {
    l = L, r = R;
    k1 = query(1, 1, N, l, r, l & 1);
    k2 = query(1, 1, N, k1, r, (l & 1) ^ 1);
  }
} ;

priority_queue<Data> Q;

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) 
    scanf("%d", &P[i]);
  
  P[0] = N + 1;
  
  build(1, 1, N);

  Data x = Data(1, N);

  Q.push(x);

  while (!Q.empty()) {
    Data x = Q.top();
    Q.pop();
    printf("%d %d ", P[x.k1], P[x.k2]);

    if (x.k1 > x.l) Q.push(Data(x.l, x.k1 - 1));
    if (x.k1 < x.k2 - 1) Q.push(Data(x.k1 + 1, x.k2 - 1));
    if (x.k2 < x.r) Q.push(Data(x.k2 + 1, x.r));
  }
  puts("");
  return 0;
}


Measured memory_bytes: 9204
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    l = inputList()
    
    l.sort()
    ll = l[::-1]
    
    ans = 0
    #print(ll)
    for i in range(K):
        #print(i)
        ans += ll[i]
    
    print(ans)
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int n;
vector <bool> lt_mae(1e6, false);
vector <bool> lt_usiro(1e6, false);
vector <int> nums(1e6, 0);



int main(void){
    string s; cin >> s;
    n = s.size() + 1;
    REP(i, n-1){
        if (s[i] == '>'){
            lt_usiro[i] = true;
        } else {
            lt_mae[i+1] = true;
        }
    }
    int num = 0;
    REP(i, n){
        if (lt_mae[i]){
            nums[i] = max(nums[i], nums[i-1]+1);
        }
    }
    REP(j, n){
        int i = n - j - 1;
        if (lt_usiro[i]){
            nums[i] = max(nums[i], nums[i+1]+1);
        }
    }
    ll ans = 0;
    REP(i, n){
        ans += nums[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4996
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main() {
	long long  n,ans,min;
	vector<long long> a(5);
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	min= *min_element(a.begin(), a.end());
	if (n%min == 0) {
		ans = n / min+4;
	}
	else {
		ans = n / min + 5;
	}

	cout << ans << endl;
}

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


long long int gcd(long long int a, long long int b){ while (a && b){ (a < b) ? b %= a : a %= b; } return a + b; }
long long int lcm(long long int a, long long int b){ return (a / gcd(a, b)) * b; }

int main(){
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << B - (B / C + B / D - B / lcm(C, D)) - ((A-1) - ((A-1) / C + (A-1) / D - (A-1) / lcm(C, D))) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
int main()
{
	int n,a[100]={0},b[100]={0},c[100]={0};
	ll sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n-1;i++)scanf("%d",&c[i]);
	sum+=b[a[0]];
	for(int i=1;i<n;i++)
	{
		sum+=b[a[i]];
		if(a[i]==a[i-1]+1)sum+=c[a[i-1]];
	}
	printf("%lld\n",sum);
}

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

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

  int num=1;
  while(num<=N){
    num*=2;
  }

  cout << num/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int n,q;
string s;
int l[200000],r[200000],c[200000];
vector<int>a(200000);
signed main(){
    cin>>n>>q>>s;
        int le=s.size();
    rep(i,le-1){
        if(s.substr(i,2)=="AC")a[i]++;
    }
    c[0]=0;
    for(int i=1;i<=n;i++){
        c[i]=c[i-1]+a[i-1];
    }
    rep(i,q){
        cin>>l[i]>>r[i];
        l[i]=max((int)(0),l[i]-1);
        r[i]--;
        int ans=c[r[i]]-c[l[i]];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 5888
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        long px=sc.nextInt();
        long sx=0,sy=0;
        for (int i=1; i<n; i++) {
            long e=sc.nextInt();
            sx+=(e-px)*i*(n-i)%mod;
            sx%=mod;
            px=e;
        }
        px=sc.nextInt();

        for (int i=1; i<m; i++) {
            long e=sc.nextInt();
            sy+=(e-px)*i*(m-i)%mod;
            sy%=mod;
            px=e;
        }

        out.println(sx*sy%mod);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 44588
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> divisor;



string swap19(string s){
	for (int i = 0; i < s.length(); i++){
		if (s[i] == '9'){
			s[i] = '1';
		}else if(s[i] == '1'){
			s[i] = '9';
		}
	}
	return s;
}

int main(){
	string s;
	cin >> s;
	cout << swap19(s) << endl;
}

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

int main(void)
{	
	int n, i;
	double date[1000], ave = 0, bun = 0;

	while(1)
	{
		scanf("%d", &n);

		if(n == 0)
		{
			break;
		}

		for(i=0; i<n; i++)
		{
			scanf("%lf",&date[i]);
			
			ave = ave + date[i] / n;
		}

		for(i=0; i<n; i++)
		{
			bun = bun + (date[i] - ave) * (date[i] - ave) / n;
		}

		printf("%f\n",sqrt(bun));

		ave = 0;
		bun = 0; 

	}

	return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,x;
int cnt =0;
cin >> N >> x;


vector<int> a(N);
for(int i =0;i<N;i++){
	cin >> a.at(i);
}

sort(a.begin(),a.end());//小さい順に

for(int i =0;i<N;i++){
	cin >> a.at(i);
	if(x >= a.at(i) && i!=N-1){
	x -= a.at(i);
	cnt++;
	}else if(i==N-1){
	if(x == a.at(i)){
	cnt++;
	}else{
	break;
	}
	}
	else{
	break;
	}
}

cout << cnt << endl;
}

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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  if(2 * K >= B - A + 1) {
    for(int i = 0;i < B - A + 1;i++) {
      cout << i + A << endl;
    }
  }
  else {
    for(int i = 0;i < K;i++) {
      cout << i + A << endl;
    }
    for(int j = 0;j < K;j++) {
      cout << B - K + j + 1 << endl;
    }
  }
}

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

int main() {
    long long x; cin >> x;
    for(int i = -54; i < 120; i++) {
        for(int j = -54; j < 120; j++) {
            if(i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <string>
#include <iostream>
using namespace std;
int n, a[1009], dp[1009][8]; string s;
int main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'O') a[i] = 1;
		if (s[i] == 'I') a[i] = 2;
	}
	for (int i = 1; i < 8; i += 2) {
		if (i & (1 << a[0])) dp[0][i] = 1;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 8; j++) {
			if (!(j & (1 << a[i]))) continue;
			for (int k = 0; k < 8; k++) {
				if (j & k) dp[i][j] += dp[i - 1][k];
			}
			dp[i][j] %= 10007;
		}
	}
	int ret = 0;
	for (int i = 0; i < 8; i++) ret += dp[n - 1][i];
	cout << ret % 10007 << endl;
	return 0;
}

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



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

Measured memory_bytes: 256
s = int(input())
l = []    
a = input()
l.append(a)
i = 1
for i in range(s-1):
    b = input()
    if l[-1][-1] != b[0]:
        break
    l.append(b)

ans = set(l)
if len(ans) == s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = 16;
		int limit = 45;
		final int[] d = {4, -4, -1, 1};
		
		char[] s = new char[n];
		for (int i = 0; i < n; i++) {
			s[i] = (char)('0' + sc.nextInt());
		}
		
		String ans = "123456789:;<=>?0";

		hs = new HashSet<String>();
		
		Queue<Panel> q = new PriorityQueue<Panel>(11, new PanelComparator());
		hs.add(toString(s));
		q.add(new Panel(toString(s), 0, getMin(toString(s))));

		while (!q.isEmpty()) {
			Panel u = q.remove();
			if (u.s.equals(ans)) {
				System.out.println(u.count);
				System.exit(0);
			}

			if (u.count + u.min > limit) {
				continue;
			}
			
			StringBuffer str = new StringBuffer(u.s);
			int zero = str.indexOf("0");
			assert (zero != -1);
			for (int i = 0; i < d.length; i++) {
				if (zero + d[i] >= 0 && zero + d[i] < n && !(d[i] == -1 && (zero + d[i]) % 4 == 3) && !(d[i] == 1 && (zero + d[i]) % 4 == 0)) {
					str.setCharAt(zero, str.charAt(zero + d[i]));
					str.setCharAt(zero + d[i], '0');
					String tmps = str.toString();
					if (!hs.contains(tmps)) {
						hs.add(tmps);
						q.add(new Panel(tmps, u.count + 1, getMin(tmps)));
					}
					str.setCharAt(zero + d[i], str.charAt(zero));
					str.setCharAt(zero, '0');
				}
			}
		}
		
        sc.close();
	}

	private static HashSet<String> hs;

	private static String toString(char[] s) {
		String ret = "";
		for (int i = 0; i < s.length; i++) {
			ret += s[i];
		}
		
		return ret;
	}
	
	private static int getMin(String s) {
		char[] c = s.toCharArray();
		int ret = 0;
		for (int i = 0; i < c.length; i++) {
			int tmp = c[i] - '0';
			if (tmp != 0) {
				int x = (tmp - 1) % 4;
				int y = (tmp - 1) / 4;
				ret += Math.abs(x - i % 4) + Math.abs(y - i / 4);
			}
		}
		
		return ret;
	}
	
	private static class Panel {
		String s;
		int count;
		int min;
		
		Panel (String s, int count, int min) {
			this.s = s;
			this.count = count;
			this.min = min;
		}
	}
	
	private static class PanelComparator implements Comparator<Panel>{
		@Override
		public int compare(Panel o1, Panel o2) {
			return o1.count + o1.min - o2.count - o2.min;
		}
	}
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

vector<int> to[100005];
int N;

vector<int> dist;

void dfs(int v, int d = 0, int p = -1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d + 1, v);
    }
}

vector<int> calcDist(int s) {
    dist = vector<int>(N);
    dfs(s);
    return dist;
}

int main() {
    int u, v;
    cin >> N >> u >> v;
    u--;
    v--;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vector<int> distU = calcDist(u);
    vector<int> distV = calcDist(v);

    int mx = 0;
    rep(i, N) {
        if (distU[i] < distV[i]) {
            chmax(mx, distV[i]);
        }
    }

    int ans = mx - 1;
    cout << ans << endl;
}

Measured memory_bytes: 10744
#include <stdio.h>
int main(void){
    int w,h,i,b;
    scanf("%d %d ",&w,&h);
    char c=getchar();
    for(i=1;i<=h;i++){
        if(i==1||i==h){
            printf("+");
            for(int a=0;a<(w-2)/2;a++){
                printf("--");
            }
            printf("-+\n");
        }else{
            if(i==h/2+1){
                printf("|");
                for(b=2;b<w;b++){
                    if(b==w/2+1){
                        printf("%c",c);
                    }else{
                        printf(".");
                    }
                }
                printf("|\n");
            }else{
                printf("|");
                for(int d=0;d<(w-2)/2;d++){
                    printf("..");
                }
                printf(".|\n");
            }
        }
    }
    return 0;
}


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

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){
  int n;
  while(cin>>n){
    if(n==-1) break;
    double x = 1, y = 0;
    for(int i=1; i<n; i++){
      double theta = atan2(y,x) + M_PI/2;
      x += cos(theta);
      y += sin(theta);
    }
    printf("%.2f\n%.2f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
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;}

template<class T> vector<T> inarr(int s,int e, T init){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){cin>>x;v.push_back(x);}
	return v;
}
// vi P = inarr<int>(0,N,0);
// vi P = inarr<int>(1,N+1,INT_MAX);
// vs P = inarr<int>(0,N,"");

template<class T>void outarr(int s,int e,vector<T> &V){
	for(int i=s;i<e;i++)cout<<V[i]<<(i<e-1?" ":"\n");
}
// outarr<int>(0,V.size(),V);
// outarr<ll>(0,V.size(),V);

// #define NMAX 1000000000
int K,a,b,c;
string S, T;
int V[]={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};

auto solve(){
	auto ans = 0;
	ans = V[K-1];
	return ans;
}

int main(){
	cin>>K;
	cout<< solve() <<endl;
	// printf("%f\n",solve());
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
m = 10**9+7
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    if i+1 not in a:
        dp[i+1] = (dp[i+1] + dp[i]) % m
    if i < N-1 and i+2 not in a:
        dp[i+2] = (dp[i+2] + dp[i]) % m
print(dp[N])

Measured memory_bytes: 94516
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int num = 753;
    for(int i=0;i<s.size()-2;i++){
        string s2;
        s2.push_back(s.at(i));//新たな要素を末尾に追加
        s2.push_back(s.at(i+1));
        s2.push_back(s.at(i+2));
        
        int h = stoi(s2);//文字列を数値に変換
        num = min(abs(753-h), num);
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;
  string s, t;
  cin >> n >> s >> t;
  ll oh = n;
  rep(i, n) {
    // cerr << s.substr(i, n - i) << " " << t.substr(0, n - i) << endl;
    if (s.substr(i, n - i) == t.substr(0, n - i)) break;
    oh--;
  }
  cout << 2 * n - oh << endl;

  return 0;
}


Measured memory_bytes: 256
const main = (input) => {
  input = input.split(' ');
  const X = parseInt(input[0], 10);
  const t = parseInt(input[1], 10);
  
  if (X-t<=0){
    console.log(0);
  }else{
    console.log(X-t);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> masu(H);
  for(int i = 0; i < H; i++){
      cin >> masu.at(i);
  }
   vector<bool> row(H,false);
   vector<bool> col(W,false);
  for(int i = 0; i < H; i++){
   for(int k = 0; k < W; k++){
     if(masu[i][k] == '#'){
       row[i] = true;
       col[k] = true;
     }
  }
  }
  for(int i = 0; i < H; i++)if(row[i]){
    for(int k = 0; k < W; k++)if(col[k]){
      cout << masu[i][k];
    }
   cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int N, M;
int H[100005], A[100005], B[100005], X[100005];
int main()
{
    cin >> N >> M;
    
    rep(i, N){
        cin >> H[i];
        X[i] = 1;
    }
    
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        if (H[a] > H[b]){
            X[b] = 0;
        } else if (H[b] > H[a]){
            X[a] = 0;
        } else {
            X[a] = X[b] = 0;
        }
    }
    int ans = 0;
    rep(i, N){
        if (X[i])ans++;
    }
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 4376
a, b, c = map(int, input().split())

cnt = 0

while True:
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b and b == c and c == a:
        cnt = -1
        break

    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    cnt += 1

print(cnt)


Measured memory_bytes: 9252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 1000000;

int check(string str, char c){
    int ok[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};
    REP(i, 8){
        int cnt = 0;
        REP(j, 3) if(str[ok[i][j]] == c) ++cnt;
        if(cnt == 3) return true;
    }
    return false;
}

int main(){
    string str;
    while(cin >>str){
        if(check(str, 'o')) cout <<'o' <<endl;
        else if(check(str, 'x')) cout <<'x' <<endl;
        else cout <<'d' <<endl;
    }
    return 0;
}

Measured memory_bytes: 1180
local n=io.read("n","l")
local s=io.read()

local precheck=true
local t={s:byte(1,2*n)}
table.sort(t)
for i=1,2*n-1,2 do
    if t[i]~=t[i+1] then
        precheck=false
    end
end
if not precheck then
    print(0)
    return
end

local rmap={}
local bmap={}
local bit=require("bit")
local lshift=bit.lshift
local band=bit.band
for bit=0,lshift(1,n)-1 do
    local r1=""
    local r2=""
    local b1=""
    local b2=""
    for i=0,n-1 do
        if band(bit,lshift(1,i))>0 then
            local r=i+1
            local b=i+1+n
            r1=r1..s:sub(r,r)
            b2=s:sub(b,b)..b2
        else
            local r=i+1
            local b=i+1+n
            b1=s:sub(b,b)..b1
            r2=r2..s:sub(r,r)
        end
    end
    local rkey=r1.." "..r2
    local bkey=b1.." "..b2
    rmap[rkey]=(rmap[rkey] or 0)+1
    bmap[bkey]=(bmap[bkey] or 0)+1
end

local combination=0
for k,_ in pairs(rmap) do
    combination=combination+rmap[k]*(bmap[k] or 0)
end
print(combination)

Measured memory_bytes: 57560
#include <stdio.h>
int main () {
    char S[100];
    scanf("%s", S);
    char Y[] = "YAKI";
    for (int i = 0; i < 4; i++) {
        if (S[i] != Y[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAX=310;
int n,x;
int A,B,C;
double memo[MAX][MAX][MAX];
double E(double a,double b,double c){
	//cout<<a<<" "<<b<<" "<<c<<"\n";
	if(a+b+c==0.0) return 0.0;
	double &ret=memo[(int)a][(int)b][(int)c];
	if(ret!=-1.0) return ret;
	double sum=a+b+c;
	ret=n/sum;
	if(a>=1.0) ret+=(a/sum)*E(a-1.0,b,c);
	if(b>=1.0) ret+=(b/sum)*E(a+1.0,b-1.0,c);
	if(c>=1.0) ret+=(c/sum)*E(a,b+1.0,c-1.0);
	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			for(int k=0;k<MAX;k++){
				memo[i][j][k]=-1.0;
			}
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x==1) A++;
		else if(x==2) B++;
		else if(x==3) C++;
	}
	printf("%.10lf",E(A,B,C));
	return 0;
}

Measured memory_bytes: 233088
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D, X[10][10];
    cin >> N >> D;
    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }
    int res = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, N, 1) {
            int sum = 0;
            REP(k, D) {
                int d = X[i][k] - X[j][k];
                sum += d * d;
            }
            int sq = sqrt(sum);
            bool f = false;
            REP(x, sq + 1) {
                f |= x * x == sum;
            }
            if (f) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	long long int i,n,sum = 0;
	
	scanf("%lld",&n);
	
	for(i = 1;i <= n;i++)
	{
		if(!(i % 3 == 0||i % 5 == 0))
			sum += i;
	}
	
	printf("%lld\n",sum);
	
	return 0;
}

Measured memory_bytes: 1736
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
add = 0
a1 = a[:-1]
for i, m in enumerate(a1):
    if m+1 == a[i+1]:
        add += c[m-1]
print(sum(b)+add)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

    int k = sqrt(2 * n) + 1;

    if (k * (k - 1) / 2 != n) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    cout << k << endl;

    vector<vector<int>> rem(k);
    int current = 1;
    for (int i = 0; i < k; ++i) {
        cout << k - 1;
        for (int j = 0; j < i; ++j) {
            cout << " " << rem[j][i - j - 1];
        }
        while(rem[i].size() < k - 1 - i) {
            cout << " " << current;
            rem[i].push_back(current++);
        }

        cout << endl;
    }
    assert(current == n + 1);

    return 0;
}

Measured memory_bytes: 1920
n = gets.chomp.to_i
rod = gets.chomp.split(" ").map(&:to_i).sort
ans = 0
n.times do |a|
    (a+1).upto(n-1) do |b|
        tmp = rod[a] + rod[b]
        c = rod.bsearch_index{|x| x >= tmp} || n
        ans += [c-(b+1), 0].max
    end
end

puts ans

Measured memory_bytes: 1912
/// referenced: https://beta.atcoder.jp/contests/abc066/submissions/2252964
#include <bits/stdc++.h>

#define MOD 1000000007

int64_t pow(int64_t x,int64_t e){
  if(e==1) return x%MOD;
  if(e==0) return 1;
  return pow(x*x%MOD,e/2)*(e%2==0?1:x)%MOD;
}
int64_t inv(int64_t i){
  return pow(i,MOD-2);
}
int64_t fact[100002],factinv[100002];
int64_t C(int64_t n,int64_t r){
  return fact[n]*factinv[r]%MOD*factinv[n-r]%MOD;
}

int main(){
  int64_t n,a;
  bool c[100002];
  std::cin >> n;
  for(int64_t i=1;i<=n;i++) c[i]=false;
  int64_t p[100002];
  int64_t x,y;

  for(int64_t i=0;i<=n;i++){
    std::cin >> a;
    if(c[a]){
      x=p[a];
      y=i;
    }
    c[a]=true;
    p[a]=i;
  }


  fact[0]=1;
  for(int64_t i=1;i<=n+1;i++) fact[i]=i*fact[i-1]%MOD;
  for(int64_t i=0;i<=n+1;i++) factinv[i]=inv(fact[i]);

  for(int64_t i=1;i<=n+1;i++){
    int64_t ans;
    ans=C(n+1,i);
    if(i-1<=n-(y-x)) ans+=MOD-C(n-(y-x),i-1);
    std::cout << (ans%MOD) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> G(N);
	for (int i = 1; i < N; i++) {
		int A;
		cin >> A;
		A--;
		G[A].push_back(i);
	}
	vector<int> count(N, 0);
	for (int i = 0; i < N; i++) {
		for (int j : G[i]) {
			count[i]++;
		}
	}
	for (int i = 0; i < N; i++) cout << count[i] << endl;
	return 0;
}

Measured memory_bytes: 14692
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
    static int r = sc.nextInt();
    static int g = sc.nextInt();
    static int b = sc.nextInt();
    static int n = sc.nextInt();


    public static void main(String[] args) {
        int ans = 0;
        for(int i = 0; i <= 3000; i++){
            if(i*r>n)break;
            for(int j = 0; j <= 3000; j++){
                int v = i*r + j*g;
                if(n >= v && (n-v)%b==0)ans++;
            }
        }  
        System.out.println(ans);     

    }


}


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

int main() {
    int n,m,k,tmp;
    cin >> n >> m;
    vector<int> s(m+1);
    for(int i = 1; i < m+1; i++) s[i] = 0b0;

    for(int i = 1; i < m+1; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> tmp; 
            s[i] |= (1 << (tmp-1));
        }
    }
    vector<int> p(m+1);
    for(int i = 0; i < m; i++){
        cin >> p[i+1];
    }

    int num_conbi = 0;
    bool flag;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        flag = true;
        for(int i = 1; i < m+1; i++){
            int oncount = __builtin_popcount(bit & s[i]);
            if(oncount % 2 != p[i]){
                flag = false;
                break;
            }
        }
        if(flag) num_conbi++;
    }
    cout << num_conbi << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    from bisect import bisect
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    m=map(int,b.read().split())
    c=[0]*(n+1)
    d*=2
    z=sorted(zip(m,m),key=itemgetter(0))
    y=[x for x,_ in z]
    s=0
    for i,(x,h)in enumerate(z):
        c[i]+=c[i-1]
        h-=c[i]
        t=-h//a
        if t>0:t=0
        c[i]-=t*a
        c[bisect(y,x+d)]+=t*a
        s-=t
    print(s)
main()

Measured memory_bytes: 55624
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    int n,a,b;
    
    scanf("%d %d %d",&n,&a,&b);
    int ans1=n*a;
    int ans2=b;

    if(ans1>ans2)printf("%d\n",ans2);
    else printf("%d\n",ans1);
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>
#include <queue>

using namespace std;

#define INF 100000

typedef pair<int, int> P;
 
int H, W;
int sx, sy;
int gx, gy;
char m[100][100];
int d[100][100];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int i, j;
 
int bfs(void){
	
	queue<P> que;
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			d[i][j] = INF;  //  INFで初期化
		}
	}
	
    //  スタート位置
	que.push( P(sx, sy) );
	d[sy][sx] = 0;
	
	while( que.size() ){

		P p = que.front();
		que.pop();

		if(p.first == gx && p.second == gy){
			break;
		}

		for(i = 0; i < 4; i++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

            //  壁を越えないかつ、行ったことのない場所なら
			if(0 <= nx && nx <= W-1 && 0 <= ny && ny <= H-1 && m[ny][nx] != '#' && d[ny][nx] == INF){   
				que.push( P(nx, ny) );
				d[ny][nx] = d[p.second][p.first] + 1;
			}

		}

	}

    if(d[gy][gx] == INF) d[gy][gx] = -1;
	return d[gy][gx];
}

int main(){
    int block = 0;
    cin >> H >> W;
    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){
            cin >> m[i][j];
            if(m[i][j] == '#') block++;
        }
    }

    sx = sy = 0;
    gx = W-1;
    gy = H-1;

    int res = bfs();
    
    int ans;
    if(res != -1) ans = H * W - block - res - 1;
    else ans = res;
    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		//N＋1個の箱
		//n+1個の左からの宛名0,1,....,Nとなる
		//現在位置X左右自由に移動可
		//宛名0とN(0<N<100)で終了
		//関所Ai(i = 1,2,.....,M(0<M<100)) == aの時1コスト
		//Ai と 0,X,Nは==でない
		//
		//nもしくは0に近い方にいく(0+N)/2>Amの時,
		//(0+N)/2<Amの時でxの位置確認
		//１、まずXの位置だす

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt()+1;//箱
		int m = sc.nextInt();//関所の住所
		int x = sc.nextInt();//Xの位置と配列の誤差を消す
		int evalu[] = new int[m];
		int a[] = new int[m];
		int light = 0;
		int left = 0;
		for(int i = 0;i < m;i++){
			a[i] = sc.nextInt();//A1からAmゲット
		//１、まずXの位置だす
			if(a[i]>x){//Xの位置より右にいくつ料金所があるか算出

				light++;
			}else if(a[i]<x){//Xの位置より左にいくつ料金所があるか算出
				left++;
			}
		}
		//１、まずXの位置だす
		if (light == left){
			System.out.println(left);	
		}else if(light > left){
			System.out.println(left);
		}else if(light < left){
			System.out.println(light);
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX*2]={};
  
  map<ll, ll> f;
  map<ll, ll> cnt;
  for(i=0; i<N; i++) {
    cin >> a[i];
    f[a[i]]=1;
    cnt[a[i]]++;
  }
  
  ll ans=0;
  for(i=1; i<MAX*10; i++) {
    if(f[i]==0) continue;
    for(j=i*2; j<MAX*10; j+=i) f[j]=0;
  }
  
  
  for(i=0; i<N; i++) if(cnt[a[i]]==1 && f[a[i]]) ans++;
  pt(ans);
  
  
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,ans;

signed main() {
    cin >> n;
    int hoge = (int)sqrt(n);
    rep1(i,hoge) {
        int tmp = (n-1)/i;
        if (!tmp) continue;
        if (n/tmp == n%tmp) ans += tmp;
    }
    cout << ans << endl;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
	int n; cin >> n;
	puts(n >= 30 ? "Yes" : "No");
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 3764
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    double T,X;
    cin>>T>>X;
    std::cout<<std::fixed<<std::setprecision(10);
    cout<<T/X<<endl;

    return 0;
}

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

int main(){
    long long int n,a,b;
    cin>>n>>a>>b;
    long long int c=min(n-a,b-1);
    long long int d=(n-a==min(n-a,b-1)) ? n-b+1+(b-a-1)/2 : a-1+1+(b-a-1)/2;
    if((b-a)%2) cout<<d;
    else cout<<(b-a)/2;
}

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

int N, W, v[110], w[110], dp[20000];

int main()
{
	cin >> N >> W;

	for (int i = 1; i <= N; i++)
		cin >> v[i] >> w[i];

	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= N; i++)
		for (int j = W; j >= w[i]; j--)
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
	

	cout << dp[W] << endl;
	return 0;
}




Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int f[100][10], p[100][11];

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 10; ++j)
      cin >> f[i][j];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 11; ++j)
      cin >> p[i][j];

  int nmax = -1e9;
  for (int bit = 1; bit < (1 << 10); ++bit)
  {
    int cnt[100] = {};
    for (int i = 0; i < 10; ++i)
    {
      if (bit & (1 << i))
      {
        for (int j = 0; j < n; ++j)
        {
          if (f[j][i])
            cnt[j]++;
        }
      }
    }
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
      sum += p[i][cnt[i]];
    }
    nmax = max(nmax, sum);
  }
  cout << nmax << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(P,Q,R);
    cout << P+Q+R - max({P,Q,R}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, K;
    cin >> N >> K;
    ll ans = 1;
    while(1){
        if(pow(K, ans) > N) break;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq

K,T = map(int, input().split())

A = list(map(int, input().split()))
if T == 1:
    print(K-1)
    exit()

q = []
for i in range(len(A)):
    heapq.heappush(q, -1*A[i])


while len(q) > 1:
    x = heapq.heappop(q)
    y = heapq.heappop(q)
    heapq.heappush(q, x-y)

print(max(0, -q[0]-1))


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

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	string s,_;cin>>s>>_;
	long long ans;
	int i, last;
	if (s.size()==1) {cout<<3<<endl;return 0;}
	if (s[0]==s[1]) {ans=6;i=2;last=1;}
	else {ans=3;i=1;last=2;}
	for(;i<s.size();i++){
		if(i+1<s.size()) {
			if(last==1 && s[i]==s[i+1]) {ans=(ans*3)%MOD;i++;}
			else if(last==1 && s[i]!=s[i+1]) {last=2;}
			else if(last==2 && s[i]==s[i+1]) {ans=(ans*2)%MOD;i++;last=1;}
			else if(last==2 && s[i]!=s[i+1]) {ans=(ans*2)%MOD;}
		}
		else {
			if(last==2) ans=(ans*2)%MOD;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256