akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  vector<ll> mark(n*m+1);
  for (ll i = 0; i <= n; ++i) {
    ll b = i*m;
    for (ll j = 0; j <= m; ++j) {
      ll bb = b - i*j + (n-i)*j;
      mark[bb] = 1;
    }
  }

  cout << (mark[k] ? "Yes" : "No") << endl;

  return 0;
}


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

class Dice{
public:
    int face[6];
    int temp;
    
    Dice(int f[6]){
        for(int i = 0; i < 6; i++){
            face[i] = f[i];
        }
    }
    
    void north(){
        temp = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = temp;
    }
    
    void south(){
        temp = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = temp;
    }
    
    void west(){
        temp = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = temp;
    }
    
    void east(){
        temp = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = temp;
    }
    
    void roll(char order){
        if(order == 'N') north();
        if(order == 'S') south();
        if(order == 'W') west();
        if(order == 'E') east();
    }
    
    void spin(){
        temp = face[1];
        face[1] = face[2];
        face[2] = face[4];
        face[4] = face[3];
        face[3] = temp;
    }
    
    void findTop(int top){
        string order = "NNNWNNN";
        for(int i = 0; i < 7; i++){
            if(face[0] == top) break;
            roll(order[i]);
        }
    };
    
    void findFront(int front){
        for(int i = 0; i < 4; i++){
            if(face[1] == front) break;
            spin();
        }
    }
    
    void rightSide(int top, int front){
        findTop(top);
        findFront(front);
        cout << face[2] << endl;
    }
    
    bool isSame(Dice dice1){
        string order = "EEESEEE";
        for(int i = 0; i < 7; i++){
            for(int j = 0; j < 4; j++){
                if(face[0] == dice1.face[0] && face[1] == dice1.face[1] && face[2] == dice1.face[2] && face[3] == dice1.face[3] && face[4] == dice1.face[4] && face[5] == dice1.face[5]){
                    return true;
                }
                spin();
            }
            roll(order[i]);
        }
        
        return false;
    }
};

int main(){
    int input[6];
    
    for(int i = 0; i < 6; i++){
        cin >> input[i];
    }
    Dice dice1(input);
    for(int i = 0; i < 6; i++){
        cin >> input[i];
    }
    Dice dice2(input);
    string res = dice1.isSame(dice2) ? "Yes" : "No";
    cout << res << endl;
}

Measured memory_bytes: 3152
import java.util.*;

// ABC 48-C
// http://abc048.contest.atcoder.jp/tasks/arc064_a

public class Main {
	
	static int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int[] candies = new int[n];
		int x = in.nextInt();
		
		for (int i = 0; i < n; i++) {
			candies[i] = in.nextInt();
		}
		
		long answer = 0;
		for (int i = 1; i < n; i++) {
			int sum = candies[i - 1] + candies[i];
			if (sum > x) {
				int diff = sum - x;
				answer += diff;
				if (diff <= candies[i]) {
					candies[i] -= diff;
				} else {
					candies[i] = 0;
				}
			}
		}
		
		System.out.println(answer);
	}
}

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

string s;
vector<int> a(4);
vector<char> op(2);
string res = "";


int main() {
  op.at(0) = '+'; op.at(1) = '-';
  cin >> s;
  rep(i ,4){ a.at(i) = s.at(i) -'0'; }
  rep(S, 8){
    int ans = a.at(0);
    rep(i, 3){
      if(S >> i & 1){
        ans -= a.at(i + 1);
      }else{
        ans += a.at(i + 1);
      }
    }
    if(ans == 7){
      res = "0-0-0-0";
      rep(i, 4){
        res.at(i * 2) = '0' + a.at(i);
      }
      rep(i, 3){
        res.at(i * 2 + 1) = op.at( S >> i & 1);
      }
    }
  }
  cout << res << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main(){
	int N;
	cin >> N;
	map<int, int> a;
	int tmp;
	for(int i=0; i<N; i++){
		cin >> tmp;
		a[tmp] += 1;
	}

	int pre=0,
		next=0,
		res=0;
	for(int i=0; i<=100000; i++){
		pre = 0;
		next = 0;
		if(i!=0) pre = a[i-1];
		if(i!=100000) next = a[i+1];
		
		if(res < (pre+next+a[i]))
			res = pre + next + a[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll ok(ll i){
    ll cnt=0;
    while(i>0){
        cnt++;
        i=i/10;
    }
    if(cnt%2==1) return 1;
    else return 0;
}

int main(){
   ll i,j;
   ll n;
   cin>>n;

   ll ans=0;

   for(i=1;i<=n;i++) ans+=ok(i);
   cout<<ans<<endl;


   
   return 0;
}


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

int x[100005];

int main(){
	int n; cin>>n;
	memset(x,0,sizeof(x));
	for(int i=1;i<=n;i++){
		int a,b;  cin>>a>>b;
		x[a]++; x[b+1]--;
	}
	int sum=0;
	for(int i=1;i<=100000;i++){
		x[i]+=x[i-1];
		sum+=x[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y,z;
};
Point operator-(const Point& a,const Point& b)
{
  Point ret={a.x-b.x,a.y-b.y,a.z-b.z};
  return ret;
}
double dot(Point a,Point b)
{
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
Point cross(Point a,Point b)
{
  Point ret={a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
  return ret;
}
double norm(Point a)
{
  return a.x*a.x+a.y*a.y+a.z*a.z;
}

int Stoi(string num)
{
  int ret;
  stringstream s;
  s << num;
  s >> ret;
  return ret;
}

int getNum(string &s,int *i)
{
  int n=0;
  while(s[(*i)]!= ']')
    {
      n*=10;
      n+=s[*i]-'0';
      (*i)++;
    }
  return n;
}

int analyze(string &s, int *i)
{
  if(s[(*i)] !='[')
    {
      cerr << "error!" << endl;
      return -1;
    }
  if(s[++(*i)] != '[')
    {
      return getNum(s,i)/2 +1 ;
    }
  vector<int> a;
  while(s[(*i)]=='[')
    {
      a.push_back(analyze(s,i));
      (*i)++;
    }
  sort(a.begin(),a.end());
  int ans=0;
  for(int k=0;k<a.size()/2 +1;k++) ans+=a[k];
  return ans;
}
int main(int argc,char const* argv[])
{
  int n;
  string s;
  getline(cin,s);
  sscanf(s.c_str(),"%d",&n);
  for(int data=0;data<n;data++)
    {
      getline(cin,s);
      int i=0;
      cout << analyze(s,&i) << endl;
    }
  return 0;
}



Measured memory_bytes: 3248
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)

n = II()
a = LI()

# 2の倍数であり、4の倍数でない
two = sum(number % 2 == 0 and number % 4 != 0 for number in a)
# 4の倍数である
four = sum(number % 4 == 0 for number in a)

if two % 2 == 1:
    print('Yes') if len(a) - two <= 2 * four else print('No')
else:
    print('Yes') if len(a) - two - 1 <= 2 * four else print('No')


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

string toUpper( string s ){
	string t = s;
	for( int i = 0; i < s.size(); i++){
		t[i] = toupper(s[i]);
	}
	return t;
}

int main(){
	string target , source;

	cin >> target;
	target = toUpper(target);

	int cnt = 0;

	while(1){
		cin >> source;
		if( source == "END_OF_TEXT" )break;
		source = toUpper(source);
		if( target == source) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>

int main(void){  

int a=0;  

int W,H,x,y,  

r=0;  

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);  

if(x-r>=0&&x+r<=W){    

if(y-r>=0&&y+r<=H){      

a=1;    

}  

}  

else{    

a=0;  

}  

if(a==1){    

printf("Yes\n");  

}  

else if(a==0){    

printf("No\n");  

}  

return 0;

}

Measured memory_bytes: 584
import math
d,g=map(int,input().split())
pc=[[int(i)for i in input().split()]for _ in range(d)]
a=1000
for i in range(2**d):
    c=0
    s=0
    m=0
    for j in range(d):
        if (i>>j)&1:
            s+=(j+1)*100*pc[j][0]+pc[j][1]
            c+=pc[j][0]
        else:
            m=j
    if s>=g:
        a=min(a,c)
    elif (m+1)*100*(pc[m][0]-1)+s>=g:
        a=min(a,c+math.ceil((g-s)/((m+1)*100)))
print(a)

Measured memory_bytes: 40816
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    for (int i=0; i<k; i++) cout << s << ' ';
    if (s == (int) 1e9) s = 1;
    else s++;
    for (int i=k; i<n; i++) cout << s << (i < n-1 ? ' ' : '\n');
    return 0;
}

Measured memory_bytes: 1280
w,a,b=map(int,input().split())
if a<b:
  if a+w<b:
    print(b-a-w)
  else:
    print(0)
elif a>b:
  if b+w<a:
    print(a-b-w)
  else:
    print(0)
else:
  print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
using ll=long long;
const long long mod = 998244353;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > s;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    s.emplace_back(a, b);
  }
  
  
  ll dp[200000];
  // dp
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    dp[i] = dp[i-1];
    for (int j = 0; j < s.size(); j++) {
      int a = i - s[j].first;
      int b = i - s[j].second - 1;
      if (a >= 0) {
        dp[i] += dp[a];
        dp[i] %= mod;
      }
      if (b >= 0) {
        dp[i] -= dp[b];
        dp[i] %= mod;
      }
    }
  }
  cout << (dp[n] - dp[n-1] + mod) % mod;
}

Measured memory_bytes: 5216
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int f( int x ) {
	return x * x;
}

int main(void){

	int d;
	while( scanf("%d",&d) != EOF ) {
		unsigned long long int ans = 0;
		for( int i = d; i <= 600 - d; i += d )
			ans += f( i ) * d;
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void)
{
	long long N;
	long long result = 0;

	cin >> N;

	for (int i = 1; i < N ; i++)
	{
		result += i;
	}

	cout << result << endl;

	return 0;
}

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

int main() {
  int N,n,alice = 0,bob = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  n = N / 2;
  for(int i = 0;i < n;i++)
    bob += A.at(2 * i + 1);
  if(N % 2 == 1)
    n++;
  for(int j = 0;j < n;j++)
    alice += A.at(2 * j);
  cout << alice - bob << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;

constexpr int MAX = 2000100;
long fac[MAX], inv[MAX], finv[MAX];
void CombInit(){
  fac[0] = inv[0] = finv[0] = 1;
  fac[1] = inv[1] = finv[1] = 1;
  for(int i=2; i<MAX; ++i){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

long Comb(int n,int k){
  if(n < 0 || k < 0 || n < k) return 0;
  return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD;
}
int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  ll X, Y; cin >> X >> Y;
  CombInit();
  if((X + Y) % 3 != 0 || X * 2 < Y || Y * 2 < X) {
    cout << 0;
  } else {
    ll Z = abs(X - Y);
    ll W = (min(X, Y) - Z)/ 3;
    cout << Comb(Z + W * 2, W);
  }
  return 0;
}

Measured memory_bytes: 47104
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
bool z[105];
int y[3][3];
int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, i, j;
	bool b;
	while (cin >> y[0][0] >> y[0][1] >> y[0][2])
	{
		b = 0;
		for (i = 1;i <= 100;i++)
			z[i] = 0;
		for (i = 1;i < 3;i++)
			for (j = 0;j < 3;j++)
				cin >> y[i][j];
		cin >> n;
		for (i = 1;i <= n;i++)
		{
			cin >> j;
			z[j] = 1;
		}
		if (z[y[0][0]] == 1 && z[y[0][1]] == 1 && z[y[0][2]] == 1)
			b = 1;
		if (z[y[1][0]] == 1 && z[y[1][1]] == 1 && z[y[1][2]] == 1)
			b = 1;
		if (z[y[2][0]] == 1 && z[y[2][1]] == 1 && z[y[2][2]] == 1)
			b = 1;


		if (z[y[0][0]] == 1 && z[y[1][0]] == 1 && z[y[2][0]] == 1)
			b = 1;
		if (z[y[0][1]] == 1 && z[y[1][1]] == 1 && z[y[2][1]] == 1)
			b = 1;
		if (z[y[0][2]] == 1 && z[y[1][2]] == 1 && z[y[2][2]] == 1)
			b = 1;


		if (z[y[0][0]] == 1 && z[y[1][1]] == 1 && z[y[2][2]] == 1)
			b = 1;
		if (z[y[2][0]] == 1 && z[y[1][1]] == 1 && z[y[0][2]] == 1)
			b = 1;

		if (b == 1)
			cout << "Yes" << '\n';
		else
			cout << "No" << '\n';
	}
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			A[i] = A[i] - i;
		}

		Arrays.sort(A);

		int mid = (N % 2 == 0) ? A[N / 2 - 1] : A[N / 2];

		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(A[i] - mid);
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 64892
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
ans = 0
l = k*(k-1)//2
r = ((n-k+1)+n)*k//2
dl = k
dr = n-k
for i in range(k,n+2):
    ans += r-l+1
    ans %= mod
    l += dl
    r += dr
    dl += 1
    dr -= 1
print(ans)

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        uf.unite(A - 1, B - 1);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string y[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
 
  while(1){
    int m,d;
    cin >> m >> d;
    if( m == 0 && d == 0 ) break;
    while( m != 0 ){
      d += mon[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX_N=100100;

int par[MAX_N];
int ran[MAX_N];
ll ans=0;

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ran[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	ans++;
	if(ran[x]<ran[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int n,m;
int x[100100],y[100100],z[100100];
bool rk[100100];

int main(){
	cin>>n>>m;
	REP(i,m)
		cin>>x[i]>>y[i]>>z[i];
	init(100100);
	REP(i,m){
		unite(x[i],y[i]);
	}
	cout<<n-ans<<endl;
	return 0;
}
	


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

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

    string res = "Christmas";

    if(d == 22)
    {
        cout << res + " Eve Eve Eve" << "\n";
    } 
    if(d == 23)
    {
        cout << res + " Eve Eve" << "\n";
    }
    if(d == 24)
    {
        cout << res + " Eve" << "\n";
    }
    if(d == 25)
    {
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 3628
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        m: usize,
        a: [i64;m]
    }
    let mut ans:i64 = n;
    for i in 0..m {
        ans-=a[i];
    }
    if ans < 0 {
        println!("-1");
    }else{
        println!("{}", ans);
    }
}


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

int main(){
   int n;
   string s;
   cin>>n>>s;
   char t[1000];
   int j=500;
   int k=499;
   stack<int> st;
   for(int i=0;i<n;i++){
       t[j++]=s[i];
       if(s[i]=='('){
           st.push(1);
       }
       else if(st.empty()){
           t[k]='(';
           k--;
       }
       else{
           st.pop();
       }
   }
   if(!st.empty()){
       for(int i=0;i<st.size();i++){
           t[j++]=')';
       }
   }
   for(int i=k+1;i<j;i++){
       cout<<t[i];
   }
   cout<<endl;
}

Measured memory_bytes: 256
//School of Killifish
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner();
		int INF = Integer.MAX_VALUE;
		int[][] min = new int[1000][1000];
		for(;;){
			int R = sc.nextInt(), C = sc.nextInt(), Q = sc.nextInt();
			if((R|C|Q)==0)break;
			int h = (int) Math.ceil(Math.sqrt(R)), w = (int) Math.ceil(Math.sqrt(C));
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)min[i][j]=INF;
			int[][] a = new int[R][C];
			for(int i=0;i<R;i++)for(int j=0;j<C;j++){
				a[i][j] = sc.nextInt();
				int I = i/h, J = j/w;
				min[I][J] = Math.min(min[I][J], a[i][j]);
			}
			while(Q--!=0){
				int r1 = sc.nextInt(), c1 = sc.nextInt(), r2 = sc.nextInt(), c2 = sc.nextInt(), res = INF;
				for(int i=r1/h;i<=r2/h;i++){
					int y1 = Math.max(r1, i*h), y2 = Math.min(r2, i*h+h-1);
					for(int j=c1/w;j<=c2/w;j++){
						if(res <= min[i][j])continue;
						int x1 = Math.max(c1, j*w), x2 = Math.min(c2, j*w+w-1);
						if(y1==i*h && y2==(i+1)*h-1 && x1 == j*w && x2 == (j+1)*w-1)res = Math.min(res, min[i][j]);
						else{
							for(int y=y1;y<=y2;y++)for(int x=x1;x<=x2;x++)
								res = Math.min(res, a[y][x]);
						}
					}
				}
				System.out.println(res);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 38000
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a;
    int b;
    cin >> a >> b;

    int c;
    int d;
    int e;
    if(a == 1)
    {
        c = 0;
    }
    else
    {
        c = a * (a-1)/2;
    }
    
    if(b == 1)
    {
        d = 0;
    }
    else
    {
        d = b * (b-1)/2;
    }
    
    e = c + d;
    
    cout<< e;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string x;

	cin >> x;

	if (x[0] == '9' || x[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define M 1000000007
#define ll long long
#define ldb long double
#define pi acos(-1)
using namespace std;
ll t,n,k,l,r,a[N],ans=1e18,sum,ans1;
char s[N];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>t>>k;
	if(n>t*k)
	cout<<"No";
	else
	cout<<"Yes"; 
	return 0;
}

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

int main(){
  int N,ans=0;
  cin >> N;
  vector<int> L(N);
  for(int i=0; i<N; i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  for(int i=0; i<N; i++){
    int k=i+2;
    for(int j=i+1; j<N; j++){
      while(L[k]<L[i]+L[j]&&k<N){
        k++;
      }
      ans+=k-j-1;
    }
  }
  cout << ans << 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 A = sc.nextInt();
        int B = sc.nextInt();
        
        char grid[][] = new char[100][100];
        for(int i = 0 ; i < 100; i++ ) {
            for(int j = 0; j < 100; j++ ) {
                if( i < 50 ) {
                    grid[i][j] = '.';
                } else {
                    grid[i][j] = '#';
                }
            }
        }
        
        A--;
        B--;
        
        for(int i = 0; i < 100; i++) {
            for(int j = 0; j < 100; j++) {
                if( A > 0 ) {
                    if( 50 <= i && i % 2 == 1 && j % 2 == 1 ) {
                        A--;
                        grid[i][j] = '.';
                    }
                }
                
                if( B > 0 ) {
                    if( i < 50 && i % 2 == 1 && j % 2 == 1 ) {
                        B--;
                        grid[i][j] = '#';
                    }
                }
            }
        }
        
        System.out.println( 100 + " " + 100 );
        for(int i = 0; i < 100; i++) {
            for(int j = 0; j < 100; j++ ) {
                System.out.print(grid[i][j]);
            }
            System.out.println();
        }
    }
}


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

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

using ll = long long;

string to_bits(ll x) {
    if (x <= 1) return to_string(x);
    return to_bits(x / 2) + to_string(x % 2);
}

int main() {
    ll N;
    cin >> N;
    string bits = to_bits(N);    // テスト用に

    const ll MOD = 1e9 + 7;
    static ll dp[70][2][2];
    dp[0][0][0] = 1;

    int n = bits.size();
    rep (i, n) rep (less, 2) rep (carry, 2) {
        if (dp[i][less][carry] == 0) continue;

        rep (x, 2) {
            rep (ncarry, 2) {
                if (carry == 1 and x == 1 and ncarry == 0) continue;
                if (carry == 0 and x == 1 and ncarry == 1) continue;

                int b = x ^ ncarry;
                if (!less and b > bits[i] - '0') continue;
                (dp[i + 1][less | (b < bits[i] - '0')][ncarry] += dp[i][less][carry]) %= MOD;
            }
        }
    }

    ll ans = 0;
    rep (less, 2) (ans += dp[n][less][0]) %= MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
bool solve(int n)
{
    while(n>0)
    {
        int d=n%10;
        if(d==7)
        {
            return true;
        }
        n=n/10;

    }
    return false;
}
int main()
{
    lli n;
	cin>>n;
	if(solve(n))
    {
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> t(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	
	int m;
	cin >> m;
	
	vector<int> p(m);
	vector<int> x(m);
	for(int i = 0; i < m; i++)
	{
		cin >> p[i] >> x[i];
	}
	
	for(int i = 0; i < m; i++)
	{
		int ans = 0;
		for(int j = 0; j < n; j++)
		{
			if((p[i] - 1) == j)
			{
				ans += x[i];
			}
			else
			{
				ans += t[j];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import queue
import itertools
r,c=map(int,input().split())
s=[list(input()) for i in range(r)]
ans=0
for i1 in range(r):
    for i2 in range(c):
        p=0
        a=[[s[j][i] for i in range(c)] for j in range(r)]
        sy,sx=i1,i2
        if a[sy][sx]=="#":
            continue
                #print(sy,sx,gy,gx)
        q = queue.Queue()
        d=[(-1,0),(1,0),(0,-1),(0,1)]
        a[sy][sx]=0
        for i in d:
            if 0<=sy+i[0]<r and 0<=sx+i[1]<c and a[sy+i[0]][sx+i[1]]==".":
                a[sy+i[0]][sx+i[1]]=1
                q.put((sy+i[0],sx+i[1]))
        while not q.empty():
            y,x=q.get()
            for i in d:
                if 0<=y+i[0]<r and 0<=x+i[1]<c and a[y+i[0]][x+i[1]]==".":
                    a[y+i[0]][x+i[1]]=a[y][x]+1
                    q.put((y+i[0],x+i[1]))
        for i in range(r):
            for j in range(c):
                if type(a[i][j])==int:
                    p=max(p,a[i][j])
        ans=max(p,ans)
print(ans)



Measured memory_bytes: 67284
#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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(1) {
      c-=b;
      if(c<=0) {
          cout << "Yes" << endl;
          return 0;
      }
      a-=d;
      if(a<=0) {
          cout << "No" << endl;
          return 0;
      }
  }
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MAX=1e6+10;
int a[MAX];
bool prime[100000];
int ji = 0;
void init()
{
    memset(prime, true, sizeof(prime));
    for(int i = 2; i <= 10000; i++)
    if(prime[i])
    {
        for(int j = i*2; j <= 10000; j+=i)
        {
            prime[j] = false;
        }
    }
    for(int i = 2; i <= 60000; i++){
        if(prime[i]){
//            cout << i << ' ';
            if(i%10 == 1)a[ji++] = i;
        }
    }
//    cout << a[ji-1] << endl;
//    cout << ji << endl;
}
int main()
{
//    srand(time(0));
    int n;
    init();
//    cout << rand() << endl;
    cin >> n;
    for(int i = 1; i <= n; i++)
    cout << a[i-1] << endl;
    return 0;
}


Measured memory_bytes: 384
import sys

h, w = [int(x) for x in sys.stdin.readline().split()]

def printer(h,w):
	for _ in range(h):
		s = input()
		s = s.replace(' ','')
		print('#'+s+'#')

print('#'*(w+2))
printer(h, w)
print('#'*(w+2))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int N, K;
  cin >> N >> K;
  
  //配列
  int l[N];
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }
  
  //降順ソート
  sort(l, l + N, greater<int>());
  
  //大きいほうからK個取り出して合計する
  int ans = 0;
  rep(i, K) ans += l[i];
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
short xfie[4100][16700];
short yfie[4100][16700];
int main(){
    xfie[0][8200]=1;
    yfie[0][8200]=1;
    string S;
    cin>>S;
    int x,y;
    cin>>x>>y;
    int xnow=0,ynow=0;
    int cou=0;
    for(int i=0;i<S.size()+1;i++){
        if(S.size()==i){
            if(xnow==ynow){
                for(int j=0;j<16000;j++){
                    if(xfie[xnow][j]==1){
                        xfie[xnow+1][j+cou]=1;
                        if(xnow!=0)xfie[xnow+1][j-cou]=1;
                    }
                }
                cou=0;
                xnow++;
            }
            else if(xnow!=ynow){
                for(int j=0;j<16000;j++){
                    if(yfie[ynow][j]==1){
                        yfie[ynow+1][j+cou]=1;
                        yfie[ynow+1][j-cou]=1;
                    }
                }
                cou=0;
                ynow++;
            }
        }
        else if(S[i]=='T'){
            if(xnow==ynow){
                for(int j=0;j<16000;j++){
                    if(xfie[xnow][j]==1){
                        xfie[xnow+1][j+cou]=1;
                        if(xnow!=0)xfie[xnow+1][j-cou]=1;
                    }
                }
                cou=0;
                xnow++;
            }
            else if(xnow!=ynow){
                for(int j=0;j<16000;j++){
                    if(yfie[ynow][j]==1){
                        yfie[ynow+1][j+cou]=1;
                        yfie[ynow+1][j-cou]=1;
                    }
                }
                cou=0;
                ynow++;
            }
        }
        else if(S[i]=='F'){
            cou++;
        }
    }
    if(xfie[xnow][8200+x]==1&&yfie[ynow][8200+y]==1)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 260608
// High above the clouds there is a rainbow...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

string s;

void tell(bool x){
    cout<<(x ? "Yes\n" : "No\n"),exit(0);
}
bool ok(int a,int b){
    while(a<b){
	if(s[++a]=='#') ++a;
	if(s[a]=='#') return 0;
    }
    return 1;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,a,b,c,d;cin>>n>>a>>b>>c>>d; --a,--b,--c,--d;
    cin>>s;
    if(d==c) tell(0);
    if(c<d) tell( ok(a,c) && ok(b,d) );
    if( (ok(a,c) && ok(b,d))==0 ) tell(0);
    if(s[d-1]!='#' && s[d+1]!='#') tell(1);
    while(b<d){
	if(s[b-1]!='#' && s[b+1]!='#') tell(1);
	if(s[++b]=='#') ++b;
    }
    tell(0);
    return 0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 592
using System;

class Program
{
    static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int ans = 0;
        ans += (x / 500) * 1000;
        x = (x % 500);
        ans += (x / 5) * 5;
        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String[] tenki = {"Sunny","Cloudy","Rainy"};

			String n = scanner.next();
			int i;
			for (i = 0; i < 3; i++) {
				if (tenki[i].equals(n)) {
					break;
				}
			}
			System.out.println(i == 2 ? tenki[0] : tenki[i+1]);
		}
	}
}


Measured memory_bytes: 20812
N,M =map(int,input().split())
slist =[]
nfin = True
for i in range(M):
  sc = list(map(int,input().split()))
  slist.append(sc)
if N == 3 or N == 2:
  for l in slist:
    s,c = l
    if s==1 and c ==0:
      print(-1)
      nfin = False
      break
if nfin:
  for l in slist:
    if not(nfin):
      break
    s1,c1 = l
    for l2 in slist:
      s2,c2 = l2
      if s1 == s2 and not(c1==c2):
        print(-1)
        nfin = False
        break
if nfin:
  ans = [1,0,0] if N==3 else [1,0] if N==2 else [0]
  for l in slist:
    s,c = l
    ans[s-1] = c
  st =''
  for i in ans:
    st += str(i)
  print(st)



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

int main() {
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == T[i]) {
			if (i == S.size() - 1)
				cout << "Yes" << "\n";
			continue;
		}
		else if (S[i] != T[i])
			cout << "No" << "\n";
		break;
	}

	return 0;
}

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

int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;

  int pass = 0, overseas = 0;
  for (int i = 0; i < N; i++) {
    bool ans = false;
    if (S[i] == 'a') {
      if (pass < A + B) {
        ans = true;
        pass++;
      }
    } else if (S[i] == 'b') {
      overseas++;
      if (pass < A + B && overseas <= B) {
        ans = true;
        pass++;
      }
    }
    cout << (ans ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 896
#include <stdio.h> 
int main(){
  
  char s[4];
  int i,a=0;
 
  for (i=0; i<3; i++){
    scanf("%c",&s[i]);
    if (s[i] == '1')
      a++;
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 256
while 1:
  R0,W0,C,R=map(int,input().split())
  if not R0 and not W0 and not C and not R:break
  n=0
  while 1:
    if W0>1 and int((R0+R*n)/W0)>=C:break
    elif W0==1 and (R0+R*n)>=C:break 
    n+=1
  print(n)




Measured memory_bytes: 5592
import functools
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


mat = mat[:, ~get_bool(mat, '.', 0)]
mat = mat[~get_bool(mat, '.', 1)]
print('\n'.join([''.join(row) for row in mat]))


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;

void solve() {
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i <= n+1; ++i) {
        auto min_t = (i*(i+1))/2;
        auto max_t = (i*(2*n+3 - i))/2;
        ans = ans + (max_t - min_t + 1)%M;
        ans %= M;
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}


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

int main(){
  ll N,N_cp;cin>>N;N_cp=N;
  string S="";
  vector<ll> ans;
  while(N!=0){
    ll i=0,left=0,right=0;
    if(N>0){
      while(right<N){
        if(i%2==0) right += pow(-2,i);
        ++i;
      }
    }
    if(N<0){
      while(left>N){
        if(i%2!=0) left += pow(-2,i);
        ++i;
      }
    }
    N -= pow(-2,i-1);
    ans.push_back(i-1);
  }

  if(N_cp==0)cout << 0 << endl;
  else{
    sort(ans.begin(),ans.end(),greater<ll>());
    for(int i=ans[0];i>=0;i--){
      bool flag=false;
      rep(j,ans.size()){
        if(i==ans[j]) flag=true;
      }
      if(flag) cout<<1;
      else cout<<0;
    }
  }
  cout << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long Fibonacci(int n)   
{   
	long long One = 2,Two = 1,N = 0;  
    int result[] = {2,1,3};  
    if (n < 2)  
    return result[n];  
    else 
	{ 
        for (int i = 2; i <= n; i++) 
		{  
            N = Two + One;  
            One = Two;  
            Two = N;  
        }  
    }  
    return N;       
}  
int main()
{
	int n;
	scanf("%d",&n);
	printf("%lld\n",Fibonacci(n));
}

Measured memory_bytes: 128
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()

MAX = 10 ** 6


def main():
    A.sort()
    s = set()
    ans = N
    for i in range(N):
        a = A[i]
        if a in s:
            ans -= 1
            continue
        if i < N - 1 and A[i + 1] == a:
            ans -= 1
        n = MAX // a
        for i in range(1, n + 1):
            s.add(a * i)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 174492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
ll n,k;
vector<ll>neg,pos;
int main()
{
#ifndef ONLINE_JUDGE
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	cin>>n>>k;
    	for(ll i=0;i<n;i++)
    	{
    		ll x;
    		cin>>x;
    		if(x>=0)
    			pos.push_back(x);
    		else
    			neg.push_back(x);
    	}
    	sort(pos.begin(),pos.end());
    	sort(neg.begin(),neg.end());
    	ll ans=1;
    	if(pos.size()==0 and k%2)
    	{
    		vector<ll>fin;
    		fin=neg;
    		ll i=fin.size()-1;
    		for(;i>=0 and k>0;i=i-1)
    		{
    			ll s=(fin[i])%mod;
    			ans=(ans*s)%mod;
    			k-=1;
    		}
    		// cout<<ans<<endl;
    	}
    	else
    	{
    		
    		reverse(neg.begin(),neg.end());
    		ll i=pos.size()-1,j=neg.size()-1;
    		if(k%2)
    		{
    			ans=pos[i];
    			i--;
    			k--;
    		}

    		while(k>0 and (i-1>=0 or j-1>=0))
    		{
    			ll x=-1,y=-1;
    			if(i-1>=0)
    				x=pos[i]*pos[i-1];
    			if(j-1>=0)
    				y=neg[j]*neg[j-1];
    			if(x>y)
    			{
    				x=x%mod;
    				ans=(ans*x)%mod;
    				i=i-2;
    			}
    			else
    			{
    				y=y%mod;
    				ans=(ans*y)%mod;
    				j=j-2;
    			}
    			k-=2;
    			// cout<<i<<" "<<j<<endl;
    		}
    		if(k>0)
    		{
    			ans=(ans*neg[j])%mod;
    			ans=(ans*pos[i])%mod;
    			k-=2;
    		}
    	}
    	if(ans<0)
    		ans=(ans+mod)%mod;

    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 5584
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; string s, t; cin >> n >> s >> t;
    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;

return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(){
    double pai=3.14;
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b;
	double h, m;
	cin >> a >> b >> h >> m;
	m /= 5;
	h += m / 12;
	double degree = min(fabs(h - m), 12 - fabs(h - m)) * 360 / 12;
	//cout << degree << '\n';
	double rad = degree *  3.14159265358979323846 / 180;
	printf("%.20f", sqrt(a * a + b * b - 2.0 * a * b * (double)cos(rad)));   
}

Measured memory_bytes: 4084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
//constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

ll rui(ll a,ll b, ll MOD){
     ll ans=1;
     while(b>0){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b/=2;
    }
     return ans;
}

int main(){
  int n; string x; cin >> n >> x;
  
  int popcount = count(all(x), '1');
  int pp = popcount+1, pm = popcount-1;
  int mod_plus = 0, mod_minus = 0;
  rep(i, n){
    if(x[n-1-i]=='1'){
      mod_plus = (mod_plus + rui(2, i, pp)) % pp;
      if(pm)mod_minus = (mod_minus + rui(2, i, pm)) % pm;
      else mod_minus = 0;
    }
  }
  //cout << mod_plus << " " << mod_minus << ln;
  vector<int> res;
  rep(i, n){//前からi番目のビットを反転
    int m;
    if(x[n-1-i]=='1' && popcount == 1){res.push_back(0); continue;};
    if(x[n-1-i]=='1') m = (mod_minus + pm - rui(2, i, pm)) % pm;
    else m = (mod_plus + rui(2, i, pp))% pp;
    if(m==0){
      res.push_back(1); continue;
    }
    int cnt = 1;
    //cout << "i:" << i << " m:" << m << ln;
    while(m!=0){
      int tmp = m, pc = 0;
      while(tmp>0){
        if(tmp&1)pc++;
          tmp/=2;
        }
        if(pc==0)break;
        m %= pc;
        cnt++;
    }
    res.push_back(cnt);
  }
  reverse(all(res));
  for(int a: res) cout << a << ln;
}


Measured memory_bytes: 4520