akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;

// 辺に重みをつける場合 
struct Edge{
  int to;
  int weight;
  Edge(int t,int w) : to(t), weight(w) { }
};

using Graph = vector<vector<Edge>>;
int A[100010];

//深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v){
  seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto next_v : G[v]){
    if (seen[next_v.to]) continue; // next_v が探索済みだったらスルー
    if(next_v.weight % 2 == 0) A[next_v.to] = A[v];
    else{
      if(A[v] == 0) A[next_v.to] = 1;
      else A[next_v.to] = 0;
    }
    dfs(G, next_v.to); // 再帰的に探索
  } 
}

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

  int N; cin >> N;
  
  Graph G(N);
  for(int i=0;i<N-1;i++){
    int A, B, C;
    cin >> A >> B >> C;
    --A; --B;
    G[A].push_back(Edge(B, C));
    G[B].push_back(Edge(A, C));
  }

  seen.assign(N, false); // 全頂点を「未訪問」にして初期化
  A[0] = 0;
  dfs(G, 0);
  rep(i,N) cout << A[i] << endl;

}

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

int main(){
	int n;
  	cin >> n;
  	string ans;
  	if(n < 1200) ans = "ABC";
  	else if(n >= 1200 && n < 2800) ans = "ARC";
  	else ans = "AGC";
  	cout << ans << endl;
}

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

int H, W, A, B, x, y, a[maxn], b[maxn], pos[maxn];

inline bool cmp(int x, int y) { return b[x] > b[y]; }
char Ans[maxn];

int main() {
//	freopen("data.in","r",stdin);
  scanf("%d%d%d%d", &H, &W, &A, &B);
	y = -1;
	for(x = 0;x <= H;x ++) {
    int now = (2 * A - W) * x - A * H + B * W;
		int xs = 2 * B - H;
		if((now != 0) && (now % xs != 0)) continue;
		if(now / xs < 0) continue;
		y = now / xs;
		break;
	}
  if(y < 0) {
		puts("-1");
		return 0;
	}
	for(int i = 1;i <= x;i ++) a[i] = A;
	for(int i = x + 1;i <= H;i ++) a[i] = W - A;
	for(int i = 1;i <= y;i ++) b[i] = B;
	for(int i = y + 1;i <= W;i ++) b[i] = H - B;
	for(int i = 1;i <= W;i ++) pos[i] = i;
	for(int i = 1;i <= H;i ++) {
		sort(pos + 1,pos + W + 1,cmp);
		for(int k = 1;k <= W;k ++) {
			int j = pos[k];
			if(a[i] > 0 && b[j] > 0) {
//				putchar('0');
				Ans[j] = '0';
				b[j] --;
				a[i] --;
			}
			else Ans[j] = '1'; //putchar('1');
		}
		for(int j = 1;j <= W;j ++) putchar(Ans[j]);
		puts("");
	}
	return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int a[N+1],b[N+1];
    for(int i=1;i<=N;i++){
        cin >> a[i] >> b[i];
    }
    a[0]=-1;
    b[0]=-1;
    sort(a,a+N+1);
    sort(b,b+N+1);
    int ans;
    if(N%2==0){
        int B=b[N/2+1]+b[N/2];
        int A=a[N/2+1]+a[N/2];
        //cout << A << " " << B << endl;
        ans=B-A;
    }else{
        ans=b[(N+1)/2]-a[(N+1)/2];
    }
    cout << ans+1 << endl;
}


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

#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define FIN freopen("entrada.in", "r", stdin);
#define FOUT freopen("saida.sol", "w", stdout);

#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define MAX int(40)+10

const int INF = 0x3f3f3f3f;
using namespace std;

int main() {

    IO

    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << "\n";

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
    int a,b,c,x;
    int ac,bc,cc;
    int output=0;
    int i,j,k;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);

    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if(500*i+100*j+50*k==x)
                    output++;
            }
        }
    }

    printf("%d",output);

    return 0;

}

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		// ???????????\???????????????????????°??????????¨??????????????????????
		int digits_sum;

		while (true) {

			// ???????????\???
			String num = input.readLine();

			// ????????????????????????
			if (num.equals("0")) {

				break;

			}

			// int???????????????????????\????????????String????????°?????§????´?
			char[] digits_number_array = num.toCharArray();

			// ?????????????????°?????????????????????
			int d_line_num = digits_number_array.length;

			// ?????????sum????¶????????????????
			digits_sum = 0;

			// ??\??????????????°?????????????????????????¶???????????????????
			for (int digits_number_spot = 0; digits_number_spot < d_line_num; digits_number_spot++) {

				// char???int??????????????¨??§????¶??????????????????????
				int digits_num = Character.getNumericValue(digits_number_array[digits_number_spot]);


				// ???????????°???????¶???????????????????
				digits_sum += digits_num;

			}

			System.out.println(digits_sum);

		}

	}

}

Measured memory_bytes: 24360
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int

int main(void){
  ll koho[200];
  for (size_t i = 1; i < 201; i++) {
    koho[i-1] = i*(i+1)*(i+2)/6;
  }
  vector<ll> koho_odd;
  for(auto k: koho){
    if(k%2 == 1){
      koho_odd.push_back(k);
    }
  }

  vector<ll> dp;
  dp.assign(1000005,INT_MAX);
  dp[0] = 0;
  for (size_t i = 1; i < 1000005; i++) {
    for(auto k: koho){
      if(i<k){
        break;
      }else{
        dp[i] = min(dp[i],dp[i-k]+1);
      }
    }
  }

  vector<ll> dpo;
  dpo.assign(1000005,INT_MAX);
  dpo[0] = 0;
  for (size_t i = 1; i < 1000005; i++) {
    for(auto k: koho_odd){
      if(i<k){
        break;
      }else{
        dpo[i] = min(dpo[i],dpo[i-k]+1);
      }
    }
  }

  int N;
  while(true){
    cin >> N;
    if(N==0){
      break;
    }else{
      cout << dp[N] << ' ' <<  dpo[N] << endl;
    }
  }
}



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

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }

        static void MainStream()
        {
            //始点によって場合分け
            string[] x1_y1_x2_y2 = Console.ReadLine().Split(' ');
            int x1 = int.Parse(x1_y1_x2_y2[0]);
            int y1 = int.Parse(x1_y1_x2_y2[1]);
            int x2 = int.Parse(x1_y1_x2_y2[2]);
            int y2 = int.Parse(x1_y1_x2_y2[3]);

            int x_distance = x1 - x2;
            int y_distance = y1 - y2;

            int x3 = x2 + y_distance;
            int y3 = y2 - x_distance;
            int x4 = x1 + y_distance;
            int y4 = y1 - x_distance;

            Console.WriteLine($"{x3} {y3} {x4} {y4}");
        }



    }
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int a, b;
	cin>>a>>b;
	cout.precision(9);
	cout<<fixed<<1.*a/b<<'\n';
	return 0;
}

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

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

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

int main(){
    int H, W; cin >> H >> W;

    vector<string> S(H); rep(i, H) cin >> S[i]; // スタート

    // dpテーブルの初期化
    long long dp[H * W][H * W];
    for(int i = 0; i < H * W; ++i) {
        for(int j = 0; j < H * W; ++j) {
            dp[i][j] = INF;
        }
    }
     
    // グラフをつくる
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            // あるマスが「.」の場合、4方向を見る
            if(S[i][j] == '.') {
                for(int k = 0; k < 4; ++k) { // あるマスの4方向を確認する
                    if(i + dy[k] < 0 || j + dx[k] < 0 || i + dy[k] >= H || j + dx[k] >= W) {
                        continue;
                    }

                    if(S[i + dy[k]][j + dx[k]] == '#') {
                        continue;
                    }

                    dp[ i * W + j ][ (i + dy[k]) * W + (j + dx[k]) ] = 1;
                    dp[ (i + dy[k]) * W + (j + dx[k]) ][ i * W + j ] = 1;
                }
            }
        }
    }

    // ワーシャルフロイド法
    for (int k = 0; k < H * W; k++){       // 経由する頂点
        for (int i = 0; i < H * W; i++) {    // 始点
            for (int j = 0; j < H * W; j++) {  // 終点
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                if(i == j) {
                    dp[i][j] = 0;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < H * W; ++i) {
        for(int j = 0; j < H * W; ++j) {
            if(dp[i][j] != INF) {
                if(ans < dp[i][j]) {
                    ans = dp[i][j];
                }
            }
        }
    }

    /*
    for(int i = 0; i < H * W; ++i) {
        for(int j = 0; j < H * W; ++j) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    } */

    cout << ans << endl;
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	string S;
	cin >> S;
	int N = S.size();
	vector<int> A(N, 0);
	int now = 0;
	int mul = 1;
	const int mod = 2019;
	for (int i = N-1; i >=0; --i) {
		now = now  + (S[i] - '0')*mul;
		now %= mod;
		mul = (mul * 10) % mod;
		A[i] = now;
	}
	map<int,int> B;
	B[0]++;
	LL ans = 0;
	for (int i = N-1; i>=0; --i) {
		LL res = B[A[i]];
		ans += res;
		B[A[i]]++;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 4420
while True:
    n = int(input())
    if n == 0:
        break
    c = list(input().split())
    hyou = [0] * 26
    isTie = True
    for i in range(0,n):
        hyou[ord(c[i]) - ord('A')] += 1
        ma1,ma2 = 0,0
        mai1,mai2 = 0,0
        for j in range(0,26):
            if ma2 < hyou[j]:
                ma2 = hyou[j]
                mai2 = j
            if ma1 < ma2:
                ma1,ma2 = ma2,ma1
                mai1,mai2 = mai2,mai1
        if ma2 + n - i - 1 < ma1:
            isTie = False
            print(chr(mai1 + ord('A')),i + 1)
            break
    if isTie:
        print("TIE")



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

using namespace std;
 
int main()
{
   string s;
   cin >> s;

   int N = s.size();

   for (int i = 0; i < (N+1)/2; i++)
   {
        cout << s.at(2*i) ;
   }
   
   cout << endl;
   
}

Measured memory_bytes: 512
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# 圧倒的爆速だった
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []  # ヒープといっても順序を工夫したただのリスト

from heapq import heapify, heappop, heappush, heappushpop
heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))

ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = heappop(heap)
    # print(heap_max)
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i+di, j+dj, k+dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        tmp = (-(A[i_new]+B[j_new]+C[k_new]), i_new, j_new, k_new)
        if tmp not in heap:
            heappush(heap, tmp)


print(*ans, sep='\n')


Measured memory_bytes: 52956
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define int long long
#define ll long long
#define inf  1000000007
#define mod 1000000007
#define PI acos(-1)
#define pa pair<int,int>
#define pal pair<ll,ll>
#define ppa pair<int,pa>
#define EPS (1e-6)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y) {}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(x*a,y*a);}
  Point operator / (double a) {return Point(x/a,y/a);}
  double absv() {return sqrt(norm());}
  double norm() {return x*x+y*y;}
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x: y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};

double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());

}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

Point inter(Point a1, Point a2, Point b1, Point b2) {
  Point a = a2 - a1;
   Point  b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ru[11]={1,2,4,8,16,32,64,128,256,512,1024};

ll frac[100010];
ll inv[100010];

ll saikif(ll a,int n){
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=100000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=100000;i++) inv[i]=saikif(frac[i],mod-2);
}

//------------kokomade--tenpure---------
vector<int> ve;
signed main(){
int n,d;
	string s;
	string t="";
	cin>>n>>s>>d;
	t=s;
	for(int i=0;i<n;i++){
		if(d==0) break;
		if(s[i]=='0'){
			t[i] ='2';
			d--;
		}
		else{
			t[i] ='1';
		}
	}
	for(int i=n-1;i>=0;i--){
		if(d==0) break;
		if(s[i]=='1'){
			t[i]='0';
			d--;
		}
	}
	//cout<<t<<endl;
	for(int i=0;i<n;i++){
		if(t[i]>'0') cout<<"1";
		else cout<<"0";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1212
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n, a, b, c, x;
	int y[101];
	while (cin >> n >> a >> b >> c >> x&&n) {
		for (int i = 0; i < n; i++) {
			cin >> y[i];
		}
		int cont = 0, icont = 0;
		if (x == y[0])icont++;
		while (cont <= 10000 && icont<n) {
			x = (a*x + b) % c;
			if (x == y[icont]) {
				icont++;
			}
			cont++;
		}
		if (cont > 10000) {
			cout << -1 << endl;
		}
		else cout << cont << endl;
	}
}

Measured memory_bytes: 3108
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val a = sc.nextInt()
    val b = sc.nextInt()

    for (i in 1..1000) {
        val c = Math.floor(i * 0.08).toInt()
        val d = Math.floor(i * 0.10).toInt()
        if (a == c && b == d) {
            println(i)
            return
        }
    }
    println(-1)
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string res = "";
    rep(i,200){
        if (i%2 == 0) {
            c -= b;
        } else {
            a -= d;
        }

        if (a <= 0) {
            res = "No";
            break;
        }
        if (c <= 0) {
            res = "Yes";
            break;
        }
    }
    cout << res << endl;
    return 0;
}


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

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

  float A[N];

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

  float ans = 0;
  for(int i=0;i<N;i++) {
    ans += 1/A[i];
  }

  ans = 1/ans;

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(
    array: &mut Vec<usize>,
    n: usize,
    cur: usize,
    queries: &Vec<Vec<(usize, usize, i64)>>,
    m: usize,
) -> i64 {
    if cur == n {
        return 0;
    }
    let mut cands_point = HashMap::new();
    cands_point.insert(array[cur - 1], 0);
    for &(a, c, d) in queries[cur].iter() {
        let cand = array[a] + c;
        if cand <= m && cand >= array[cur - 1] {
            *cands_point.entry(cand).or_insert(0) += d;
        }
    }
    let mut ret = 0;
    for &cand in cands_point.keys() {
        array[cur] = cand;
        let temp = dfs(array, n, cur + 1, queries, m);
        ret = max(ret, temp + cands_point[&cand]);
    }

    ret
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m, q) = (v[0], v[1], v[2]);
    let mut queries = vec![vec![]; n];
    for i in 0..q {
        let v = read_vec::<i64>();
        let (a, b, c, d) = (v[0] as usize - 1, v[1] as usize - 1, v[2] as usize, v[3]);
        queries[b].push((a, c, d));
    }
    let mut array = vec![1; n];
    let ans = dfs(&mut array, n, 1, &queries, m);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2208
n = gets.to_i

sum = (1 + n) * n / 2

sum3 = (3 + n / 3 * 3) * (n / 3) / 2
sum5 = (5 + n / 5 * 5) * (n / 5) / 2
sum15 = (15 + n / 15 * 15) * (n / 15) / 2

puts sum - sum3 - sum5 + sum15


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

void trace(vector<double> &vd) {
    for (int i = 0; i < vd.size() - 1; i++) {
        for (int j = i + 1; j < vd.size(); j++) {
            cout << vd[i] << " " << vd[j] << " ==> ";
            cout << (vd[i] + vd[j]) / 2 << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vector<double> vd;
    for (int i = 0, input; i < N; i++) {
        cin >> input;
        vd.push_back((double)input);
    }

    // trace
    // trace(vd);
    // sort DESC
    sort(vd.begin(), vd.end());

    double sum = vd.at(0);
    for (int i = 1; i < vd.size(); i++) {
        sum = (sum + vd.at(i)) / 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    cnt=0
    for i in range(1,N+1):
        ds=0
        for j in range(5):
            ds+=(int(i//(10**j)))%(10)
        if A<=ds<=B:
            cnt+=i
    print(cnt)
    
if __name__=="__main__":
    main()


Measured memory_bytes: 8920
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <functional>
#include <cstdlib>
#include <iomanip>
#include <climits>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 2e9 + 1e8;
const ll INF = 2e18 + 1e17;
const int mod = 998244353;
const int MOD = 1e9 + 7;
 
ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}
bool is_prime(ll x) {
	if (x == 1 || (x % 2 == 0 && x > 2))     return false;
	for (int i = 3; i*i <= x; i += 2) {
		if (!(x % i)) {
			return false;
		}
	}
	return true;
}
 
/**************************************************************************************
***************************************************************************************/
const int MAXN = 100010;

int N, M;

int main (){
    ios_base::sync_with_stdio(false);   cin.tie(false);
    cin>>N>>M;
    cout<<(N == M ? "Yes" : "No")<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;



void run_case() {
    int n; cin >> n;
    vector<pll> a;
    for(int i = 1; i <= n; ++i) {
        LL t; cin >> t;
        a.emplace_back(t, 1LL*i);
    }
    sort(a.begin(), a.end(), [&](pll a, pll b) {
        return a.first > b.first;
    });
    vector<vector<LL>> dp(n+2, vector<LL>(n+2));
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= i; ++j) {   // len = r - l + 1, len = n - i
            int l = j+1, r = n - i + l - 1;
            if(r+1<=n) dp[l][r] = max(dp[l][r], dp[l][r+1]+abs(r+1-a[i-1].second)*a[i-1].first);
            if(l-1>=1) dp[l][r] = max(dp[l][r], dp[l-1][r]+abs(l-1-a[i-1].second)*a[i-1].first);
        }
    }
    LL ans = 0;
    for(int i = 1; i <= n; ++i) ans = max(ans, dp[i][i-1]);
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 34604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		br.close();

		if (s[0] == s[1]) {
			System.out.println("1 2");
			return;
		}
		for (int i = 2; i < s.length; i++) {
			if (s[i - 1] == s[i]) {
				System.out.println(i + " " + (i + 1));
				return;
			}
			if (s[i - 2] == s[i]) {
				System.out.println((i - 1) + " " + (i + 1));
				return;
			}
		}
		System.out.println("-1 -1");
	}
}


Measured memory_bytes: 22612
import java.util.*;

public class Main {
    static int MAX = 100;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        // n = 5;
        
        long inv2 = 500000004;
        
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
        }
        
        long parta = 0;
        for (int i = 0; i < n; i++) {
            parta += array[i];
            parta %= MOD;
        }
        parta = (parta * parta) % MOD;
        if (parta < 0) parta += MOD;
        // System.out.println(parta);
        
        long partb = 0;
        for (int i = 0; i < n; i++) {
            partb += (array[i] * array[i]) % MOD;
            partb %= MOD;
        }
        if (partb < 0) partb += MOD;
        // System.out.println(partb);
        
        long ans = 0;
        ans = parta - partb;
        if (ans < 0) ans += MOD;
        ans %= MOD;
        ans *= inv2;
        ans %= MOD;
        System.out.println(ans);
    }
    
    public static long modpow(long num, long n) {
        // ex. 3^10
        // 3^10 = 3^(0b1010)
        // = 3^8が1個 * 3^4が0個 * 3^2が1個 * 3^1が0個
        // (次の桁の値は(前の桁)^2になる)
        
        long res = 1;
        long digit = num;
        
        while (n > 0) {
            long lsb = n & 1;
            if (lsb == 1) {
                res *= digit;
                res %= MOD;
            }
            
            digit = digit * digit;
            digit %= MOD;
            n = n >> 1;
        }
        
        return res;
    }
}


Measured memory_bytes: 61568
using System;


namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] D1 = Console.ReadLine(). Split(' ');
            int n = int.Parse(D1[0]);
            int m = int.Parse(D1[1]);
            int[,] D2 = new int[n,m];
            int[] D3 = new int[m];
            
            //????????????
            for (int i = 0; i < n; i++ )
            {
                String[] D4 = Console.ReadLine().Split(' ');
                //m?????????
                for (int j = 0; j < m; j++)
                {
                     int a = int.Parse(D4[j]);
                     D2[i,j] = a ;
                }
   
            }
            for (int j = 0; j < m; j++ )
            {
                String D5 = Console.ReadLine();
                int b = int.Parse(D5);
                D3[j] = b;
            }
            for (int i = 0; i < n; i++)
            {
                int sum = 0;
                for (int j = 0; j < m; j++)
                {
                    int Sum = D2[i , j] * D3[j];
                    sum = Sum + sum;
                }
                Console.WriteLine(sum);
            }

        }
    }
}

Measured memory_bytes: 9300
N, W = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w-goods[i][0] >= 0:
            dp[i+1][w] = max(dp[i+1][w], dp[i][w-goods[i][0]] + goods[i][1])
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])        
print(dp[-1][-1])

Measured memory_bytes: 172696
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  string s, t;
  cin >> s >> t;
  using T = pair<i64, pair<i64, i64>>;
  vector<vector<T>> dp(s.size() + 1, vector<T>(t.size() + 1));
  for(i64 i = 0;i < s.size();i++) {
    for(i64 j = 0;j < t.size();j++) {
      T a = {dp[i + 1][j].first, { i + 1, j }};
      T b = {dp[i][j + 1].first, { i, j + 1 }};
      T c = {dp[i][j].first + !!(s[i] == t[j]), {i, j}};
      dp[i + 1][j + 1] = max({ a, b, c });
    }
  }
  i64 x = s.size();
  i64 y = t.size();
  string ans;
  while(x > 0 && y > 0) {
    i64 n = dp[x][y].second.first;
    i64 m = dp[x][y].second.second;
    if(dp[n][m].first + 1 == dp[x][y].first) {
      ans.push_back(s[n]);
    }
    x = n;
    y = m;
  }
  reverse(all(ans));
  cout << ans << endl;
}


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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>s;
    if(s<="2019/04/30")
        cout<<"Heisei";
    else
    {
        cout<<"TBD";
    }
    
	
	return 0;
}
	

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define sz(x) (int)x.size()
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void solution()
{
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    int ma = a[0];
    for (int i = 0; i < n; i++)
    {
        ma = max(ma, a[i]);
        ans += (ma - a[i]);
    }
    cout << ans << endl;
    return;
}
int32_t main()
{
    run();
    solution();
    return 0;
}

Measured memory_bytes: 4792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
string s; int k;
vector<string> stf;

int main(void)
{
	cin>>s>>k; int i, j;
	for(i=0 ; i<s.length() ; i++)
	{
		for(j=1 ; j<=k ; j++)
			stf.push_back(s.substr(i,j));
	}
	sort(stf.begin(),stf.end());
	stf.erase(unique(stf.begin(),stf.end()),stf.end());
	cout<<stf[k-1]; return 0;
}

Measured memory_bytes: 1660
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (long long)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
const ll MOD = 1e9+7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}


const int N = 100;
vi adj[N];



int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;cin>>n;
ll a[n+1];
ll sum = 0;
reps(i,n){
	cin>>a[i];
	sum+=a[i];
	}

ll ans = 0;
ll cur = 0;
for(ll i = 1; i<n ; i++){
	cur+=a[i];
	
	ans+=((a[i]%MOD)*((sum-cur)%MOD))%MOD;
	
	ans = (ans+MOD)%MOD;
	
	
	}
ans = (ans+MOD)%MOD;
cout<<ans;

}





	
	




		



Measured memory_bytes: 5176
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		int answer = s.Length;
    int sCount = 0;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == 'S') sCount++;
      else if(sCount > 0)
      {
        answer -= 2;
        sCount--;
      }
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
#include<stdio.h>

const int MAX_V = 10000;
int prime[10001];

int main(){
	int v, q1;
	for(int i = 2;i <= MAX_V;i++){
		prime[i] = 1;
	}
	for(int i = 2; i * i <= MAX_V;i++){
		if(prime[i]){
			for(int k = 2 * i;k <= MAX_V; k += i){
				prime[k] = 0;
			}
		}
	}
	while(scanf("%d", &v) != EOF){
		if(v == 0) break;
		for(int i = v;i >= 2;i--){
			if(prime[i]){
				if(prime[i-2]){
					q1 = i;
					break;
				}
			}
		}
		printf("%d %d\n", q1 - 2, q1);
	}
	return 0;
}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    int a = n;
    while(a > 0){
        sum += a % 10;
        a /= 10;
    }
    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if(n != 100){
            System.out.println((int)(n * Math.pow(100,d)));
        }else{
            System.out.println((int)((n+1) * Math.pow(100,d)));
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll dp[2][201][10001] = {0};
int main() {
	int N, W; cin >> N >> W;
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end(), greater<int>());
/*
	vector<int> s(N);
	for (int i = 0; i < N; ++i) {
		s[i] = v[i];
	}
	for (int i = N-1; i > 0; --i) {
		s[i-1] += s[i];
	}
	s.push_back(0);
*/
	dp[0][0][0] = 1;
	for (int i = 0; i < N; ++i) {
		fill(&dp[i+1&1][0][0], &dp[i+1&1][0][0]+201*10001, 0);
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= W; ++k) {
				if (dp[i&1][j][k]) {
					if (k + v[i] <= W) {
						dp[i+1&1][j][k+v[i]] = (dp[i+1&1][j][k+v[i]] + dp[i&1][j][k]) % MOD;
					}
					dp[i+1&1][i+1][k] = (dp[i+1&1][i+1][k] + dp[i&1][j][k]) % MOD;
				}
			}
		}
	}

	ll ans = 0;
	for (int j = 0; j <= N; ++j) {
		for (int k = 0; k <= W; ++k) {
			if (dp[N&1][j][k] && (j == 0 || k + v[j-1] > W)) {
				ans = (ans + dp[N&1][j][k]) % MOD;
			}
		}
	}

	cout << ans << endl;
}

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

int main(){
	stack<int> st;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
  	if(s[i]=='B'){
      if(st.size()!=0) st.pop();
    }
    else{
      st.push(s[i]-'0');
    }
  }
  vector<int> v;
  while(st.size()){
  	v.push_back(st.top());
    st.pop();
  }
  for(int i=v.size()-1;i>=0;i--){
  	cout<<v[i];
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long
#define pii pair<int,int>
#define x first
#define y second

const int N=105;
pii a[N];
char s[N];
int k,ans,n;

signed main(){
	scanf("%s",s+1);
	read(k);
	for(int i=1;s[i];i++){
		if(s[i]==s[i-1]) a[n].y++;
		else a[++n]={s[i]-'a',1};
	}
	if(n==1) return write(k*strlen(s+1)>>1),0;
	for(int i=1;i<=n;i++) ans+=a[i].y>>1;
	ans*=k;
	if(a[1].x==a[n].x&&(a[1].y&1)&&(a[n].y&1)) ans+=k-1;
	write(ans);
}

Measured memory_bytes: 3680
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		int N = int.Parse(Console.ReadLine());
		string a = Console.ReadLine();
		string ans = "";
		for(var i=0;i<a.Length;i++){
			int a1 = s.IndexOf(a.Substring(i,1));
			a1 = (a1+N)%26;
			string a2 = s.Substring(a1,1);
			Console.Write(a2);
		}
	}
}

Measured memory_bytes: 13408
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <cstring>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int n;
char S[55][55];
int c[55][55];
string ans;

int main(void) {
    scanf("%d", &n);
    rep(i, 0, n) {
        scanf("%s", S[i]);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (int)strlen(S[i]); j++) {
            int ch = S[i][j] - 'a';
            c[ch][i]++;
        }
    }

    rep(ch, 0, 26) {
        int cnt = 1000000000;
        rep(i, 0, n) {
            cnt = min(cnt, c[ch][i]);
        }
        rep(i, 0, cnt) ans += 'a' + ch;

    }
    
   

  
    printf("%s\n", ans.c_str());

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(I,N) for(int I=0;I<N;I++)
using ll=long long int;
using namespace std;
const int M=1000005;
int su=0;
int main(){
	ll n;
	cin>>n;
	vector<int> cnt(M);
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	for(int x : a){
		if(cnt[x]!=0){
			cnt[x]=2;
			continue;
		}
		for(int i=x;i<M;i=i+x){
			cnt[i]+=1;
		}
	}
	for(int x:a){
		if(cnt[x]==1)su+=1;
	}
	cout<<su;
}

Measured memory_bytes: 7988
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int n;
char sentences[100][15];
int main() {
	int flag = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", sentences[i]);
		if(i != 0 && sentences[i - 1][strlen(sentences[i - 1]) - 1] != sentences[i][0]) {
			// printf("%c %c\n", sentences[i - 1][strlen(sentences[i - 1]) - 1], sentences[i][0]);
			flag = 1;
		}
		for(int j = 0; j < i; j++) {
			if(strcmp(sentences[i], sentences[j]) == 0) {
				flag = 1;
			}
		}
	}
	if(flag == 1) {
		printf("No\n");
		return 0;
	}
	else {
		printf("Yes\n");
	}

}


Measured memory_bytes: 128
N, K = map(int,input().split())
MOD = 10**9 + 7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2,200010):
    fac[k] = (fac[k-1]*k)%MOD
    inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
    finv[k] = (finv[k - 1] * inv[k]) % MOD;
def nCr(n,r):
    return (fac[n]*finv[r]*finv[n-r])%MOD

for k in range(1,K+1):
    if k <= N-K+1:
        print((nCr(N-K+1,k)*nCr(K-1,k-1))%MOD)
    else:
        print(0)


Measured memory_bytes: 27160
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[100100];

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    rep(i,100100) dp[i] = INF;
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    srep(i,2,N) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1148
n = int(input())
x = list(map(int, input().split()))
if max(x)-min(x)==0:
    print(0)
else:
    k=max(x)-min(x)
    box=[0]*k

    for i in range(0,k):
        aa=0
        for j in range(0,n):
           aa = aa+(x[j]-min(x)-i)**2
        box[i]=aa


    print(min(box))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);


	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3);
	if((a[0]==a[1]) && (a[1]!=a[2])){
		cout<<"Yes";
	}
	else if((a[0]!=a[1]) && (a[1]==a[2])){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A1 = [int(i) for i in input().split()]
    A2 = [int(i) for i in input().split()]
    a1 = A1[0]
    a2 = sum(A2)
    ans = a1 + a2
    for i in range(1, N):
        a1 += A1[i]
        a2 -= A2[i - 1]
        ans = max(ans, a1 + a2)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 62008
#include<iostream>
using namespace std;
int main(){
	int sum=0,num=0,f;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>f;
		if(f%4==0)sum++;
		else if(f%4==2)num++;
		else sum--;
	}
	if(sum>=0)cout<<"Yes";
	else if(sum==-1){
		if(num!=0)cout<<"No";
		else cout<<"Yes";
	}
	else cout<<"No";
}


Measured memory_bytes: 384
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

sys.setrecursionlimit(10**6)
# def solve():
# 	n, m = read()
# 	graph = [[] for i in range(n+1)]
# 	for _ in range(m):
# 		u, v = read()
# 		graph[u].append(v)
# 	visited = [0 for i in range(n+1)]
# 	def dfs(node):
# 		if visited[node]:
# 			return(visited[node])
# 		if not graph[node]:
# 			visited[node] = 0
# 			return(0)
# 		m = 0
# 		for i in graph[node]:
# 			m = max(m, dfs(i))
# 		visited[node] = 1 + m#ax(dfs(i) for i in graph[node])
# 		# print(node, visited[node])
# 		return(visited[node])

# 	ans = 0
# 	for i in range(1, n+1):
# 		ans = max(ans, dfs(i))
# 	# print(visited)
# 	print(ans)


def grid():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	# dic = {}
	dp = [-1]*m*n
	# print(dp, len(dp))
	def count_paths(i, j):
		# key = str(i)+"-"+str(j)
		# if key in dic:
		# 	return(dic[key])
		key = (i*m + j)
		# print(key)
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		if dp[key] > -1:
			return(dp[key])
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))

def grid2():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	dp = {}
	# print(dp, len(dp))
	def count_paths(i, j):
		key = str(i)+"-"+str(j)
		if key in dp:
			return(dp[key])
		# key = (i*m + j)
		# print(key)
		if key in dp:
			return(dp[key])
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))



if __name__ == "__main__":
	# solve()
	grid()

Measured memory_bytes: 142364
#include<cstdio>

char s[111111];
char cur;
int ans;

int main() {
	scanf("%s", s);
	cur = 'g';
	ans=0;
	for(int i=0;s[i];i++) {
		if(s[i]=='g' && cur =='p') ans++;
		if(s[i]=='p' && cur == 'g') ans--;
		cur = 'g'+'p' - cur;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define mod (int)(1e9 + 7)

int factors(int p, int N){
	if(N < p){
		return 0;
	}
	else{
		return factors(p, N/p) + N/p;
	}
}

int main(){
	int N, i, j;
	long long int res = 1;
	scanf("%d", &N);
	int p[N + 1];
	for(i = 0; i <= N; i++){
		p[i] = i;
	}
	for(i = 2; i <= N; i++){
		if(p[i] != 0){
			for(j = 1; i*j <= N; j++){
				p[i*j] = 0;
			}
			res = (res * (factors(i, N) + 1))%mod;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 128
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    vector<ll> v(100010); // value -> num of values
    ll n,k;
    cin>>n>>k;
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        v[a]+=b;
    }

    vector<PLL> t; // {value, num of values}
    rep(i,0,100010){
        if(v[i]>0){
            t.emplace_back(i, v[i]);
        }
    }
    sort(begin(v),end(v));

    for (auto &e: t){
        if (k <= e.second) {
            cout<<e.first<<endl;
            return 0;
        }
        k -= e.second;
    }
    return 0;
}


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

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    int sum = N;
    for ( int i = 0 ;i < M ; ++i )
    {
        cin >> A.at(i);
        sum = sum - A.at(i);
    }
    if ( sum < 0 )
    {
        cout << "-1" << endl;
    }else{
        cout << sum << endl;
    }
    return 0;
}


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

const int maxn = 100005;

double w,h,x,y;

int main(){
    cin>>w>>h>>x>>y;
    double s=w*h/2;
    int flag;
    if(x==w/2&&y==h/2)flag=1;
    else flag=0;
    cout<<s<<" "<<flag<<endl;
    //printf("%f %d",s,flag);
}


Measured memory_bytes: 256