akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[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 long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main(){
    int N; cin >> N;
    ll M; cin >> M;
    vector<ll> a(N);
    ll cnt=0;
    ll lc=1;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    lc = a[0]/2;
    while(true){
        if(lc%2==0){
            lc = lc/2;
            cnt++;
        }else{
            break;
        }
    }
    for(int i=1;i<N;i++){
        ll tmp=a[i]/2;
        int c=0;
        while(true){
            if(tmp%2==0){
                tmp = tmp/2;
                c++;
            }else{
                break;
            }
        }
        if(cnt!=c){
            cout << 0 << endl;
            return 0;
        }
    }
    lc = a[0]/2;
    for(int i=1;i<N;i++){
        lc = lc/gcd(lc,a[i]/2)*a[i]/2;
    }
    if(lc>M){
        cout << 0 << endl;
        return 0;
    }
    cnt = M/lc;
    cout << (cnt+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
d, g = map(int, input().split())

p = [0] * 10
c = [0] * 10

for i in range(d):
    p[i], c[i] = map(int, input().split())

ans = float("inf")
for mask in range(1<<d):
    s = 0; num = 0; rest_max = -1
    for i in range(d):
        if mask >> i & 1:
            s += 100 * (i+1) * p[i] + c[i]
            num += p[i]
        else:
            rest_max = i

    if s < g:
        s1 = 100 * (rest_max + 1)
        need = (g - s +s1 - 1) // s1
        if need >= p[rest_max]:
            continue

        num += need

    ans = min(ans, num)
     
print(ans)




Measured memory_bytes: 3064
import java.util.Scanner

object Main {

  val scan = new Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val W = scan.nextInt()
    val H = scan.nextInt()
    val T = scan.nextInt()
    val p = scan.nextInt()
    val g = Array.ofDim[Int](H, W)
    for (i <- 0 until p) {
      val x = scan.nextInt()
      val y = scan.nextInt()
      val t = scan.nextInt()
      g(y)(x) += 1
    }
    var sum = 0
    for (i <- 0 until H; j <- 0 until W) {
      val s = scan.nextInt()
      sum += s * g(i)(j)
    }
    println(s"${sum}")
  }

}

Measured memory_bytes: 49924
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;


int main()
{
	fast;
	ll x;
	cin>>x;
	
	if(x)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int x, a, b;
int main() {
	cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x))cout << "A" << endl; else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 int max = a;
 int min = b+c;
 if(max < b){ max = b; min = a+c;}
 if(max < c){ max = c; min = a+b;}
 if(max == min) printf("Yes");
 else printf("No");

 return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""
import collections

NK = list(map(int,input().split()))
A = list(map(int,input().split()))

"""
TLE解法
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)
"""
def main(nk,a):
    k = nk[1]
    values,counts = zip(*collections.Counter(a).most_common())
    print(sum(counts)-sum(counts[:k]))
main(NK,A)

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int ans = __gcd(A[0], A[1]);
  for (int i = 2; i < N; i++)
    ans = __gcd(ans, A[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		HashSet<String> result = new HashSet<String>(N);

		for (int i = 0; i < N; i++) {
			String S = scan.next();
			result.add(S);
		}
		

		System.out.println(result.size());

	}

}

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

int main() {
  char c;
  cin >> c;

  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel"  << endl;   
  } else {
    cout << "consonant"  << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var ni = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(ni[0]-ni[1] + 1);
        }
    }
}


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

int main() {
    int n, x;
    cin >> n >> x;
    int ans = 1;
    int p = 0;
    rep(i,n) {
      int l;
      cin >> l;
      p += l;
      if (p > x) break;
      ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3512
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, X, Y = mapint()
As = list(mapint())

if N==1:
    print(abs(Y-As[0]))
else:
    print(max(abs(Y-As[-1]), abs(As[-2]-As[-1])))

Measured memory_bytes: 64312
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dump_l(x) dump(x) << endl
#else
const bool test = false;
#define dump(x)
#define dump_l(x)
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
    {
			v.push_back(buffer);
    }
	return v;
}

string reverse_str(string input) {
  string res = input;
  reverse(all(res));
  return res;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

int H = 20, W = 30;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

void solve();

class Solver {
public:
	int N;
	int T[MAX];

	int gcd(int m, int n) {
		if (m % n == 0) return n;
		else return gcd(n, m % n);
	}

	int lcm(int m, int n) {
		return m / gcd(m, n) * n;
	}
	
  void solve() {
		cin >> N;
		rep(i, N) cin >> T[i];
		int res = T[0];
		// dump_l(gcd(T[0], T[1]));
		// dump_l(lcm(T[0], T[0]));
		// dump_l(lcm(T[0], T[1]));
		rep(i, N) res = lcm(res, T[i]);
		cout << res << endl;
  }
};
 
signed main()
{
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	// while (true) {
	//   auto ptr = new Solver();
	//   ptr->solve();
	//   delete ptr;
	// }
	return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'
 


Measured memory_bytes: 1792
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int> v(n, 0);
  for(auto& e: v) cin >> e;
  vector<int> dp(n, 1e9 + 5);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j : {i + 1, i + 2}) {
      if (j < n) {
        dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
      }
    }
  }
  cout << dp.back() << '\n';
  return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 10000
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int N;
deque<int> AA;
vector<int> B;

int solve(deque<int> A)
{
  B.clear();
  B.push_back(A[(A.size()-1)/2]);
  A.erase(begin(A) + (A.size()-1)/2);

  while(A.size()) {
    if(A.size()) {
      B.push_back(A.back());
      A.pop_back();
    }
    if(A.size()) {
      B.push_back(A.front());
      A.pop_front();
    }
  }

  int ans = 0;
  REP(i,B.size()-1) {
    ans += abs(B[i] - B[i+1]);
  }

  return ans;
}

signed main()
{
  cin >> N;
  REP(i,N) {
    int a;
    cin >> a;
    AA.push_back(a);
  }

  sort(begin(AA), end(AA));

  deque<int> tmpA = AA;
  reverse(begin(tmpA), end(tmpA));

  cout << max(solve(AA), solve(tmpA)) << endl;

  return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    long long N,M;
    cin >> N >> M;
    if (N == M){
        unsigned long long ans = 1;
        unsigned long long tmp = M;
        for(long long i = N;i > 0;i--){
            ans = (i * tmp * ans) % (1000000000 + 7);
            tmp--;
        }
        ans *= 2;
        ans = ans % (1000000000 + 7);
        cout << ans << endl;
    }else if(N - 1 == M){
        long long ans = 1;
        long long tmp = N;
        for(long long i = M;i > 0;i--){
            ans = ((i * tmp)% (1000000000 + 7) * (ans % (1000000000 + 7)) % (1000000000 + 7));
            tmp--;
        }
        cout << ans % (1000000000 + 7) << endl;
    }else if(M - 1 == N){
        long long ans = 1;
        long long tmp = M;
        for(long long i = N;i > 0;i--){
            ans = ((i * tmp)% (1000000000 + 7) * (ans % (1000000000 + 7)) % (1000000000 + 7));
            tmp--;
        }
        cout << ans % (1000000000 + 7) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int k, x;
  cin >> k >> x;
  int idx = x - k + 1;
  for (int i = idx; i < x + k; i++)
    cout << i << " ";

}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
S=list(input())
s=S[::-1]
#print(S)
#print(s)
for i in range(len(S)):
    if S[i]=="b":
        if s[i]!="d":
            print("No")
            exit()
    if S[i]=="d":
        if s[i]!="b":
            print("No")
            exit()
    if S[i]=="p":
        if s[i]!="q":
            print("No")
            exit()
    if S[i]=="q":
        if s[i]!="p":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 50288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int cnt = 0;
  if(A == B)
    cnt++;
  if(A == C)
    cnt++;
  if(B == C)
    cnt++;
  if(cnt == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;;
}


Measured memory_bytes: 256
import copy

INFTY=1000000000
def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L=[ A[left+i] for i in range(n1)]
    R=[ A[mid+i] for i in range(n2)]
    L.append((INFTY,INFTY))
    R.append((INFTY,INFTY))
    i=0
    j=0
    for k in range(left,right):
        if int(L[i][1])<=int(R[j][1]):
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
    return right-left

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        t1=mergeSort(A,left,mid)
        t2=mergeSort(A,mid,right)
        return merge(A,left,mid,right)+t2+t1
    return 0

def partition(A,p,r):
    x=int(A[r][1])
    i=p-1
    for j in range(p,r):
        if int(A[j][1])<=x:
            i+=1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[r]=A[r],A[i+1]
    return i+1

def quickSort(A,p,r):
    if p<r:
        q=partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

n=int(input())
A=[input().split() for _ in range(n)]
B=copy.deepcopy(A)

quickSort(A,0,n-1)
mergeSort(B,0,n)
if A==B:
    print("Stable")
else:
    print("Not stable")

for i in range(n):
    print(' '.join(A[i]))


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	LL D;
	cin >> N >> D;
	vector<LL> X(N), Y(N);
	rep(i,N) cin >> X[i] >> Y[i];
	int ans=0;
	rep(i,N){
		if(X[i]*X[i]+Y[i]*Y[i]<=D*D) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6296
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int L = sc.nextInt();

        int sum = 0;
        if(L>=0)  {
            for(int i=2; i<=N; i++) {
                sum += L + i -1;
            } 
        } else {
            if(N > -L) {
                for(int i=1; i<=N; i++) {
                    sum += L + i -1;
                }
            } else {
                    for(int i=1; i<N; i++) {
                        sum+= L + i -1;
                    }
            }
            
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 200001;
char s[N], t[N];
int last[N], las[N], l[26], ll[26], n;
 
int main() {
	scanf ("%s%s", s, t);
	n = strlen(s);
	for (int i = 0; i < n; i++) {
	  last[i] = l[s[i] - 'a'];
	  l[s[i] - 'a'] = i + 1;
	  las[i] = ll[t[i] - 'a'];
	  ll[t[i] - 'a'] = i + 1;
	}
	for (int i = 0; i < n; i++) {
	  if (last[i] != las[i]) {
		  cout<<"No\n";
		  return 0;
		}
	}
	cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(x) sort(x, x+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sync2 cout<<fixed<<setprecision(10)
const ll inf=1e9+7;
#define pi 3.14159265358979323846
#define REP(i,j,n) for (int i = (int)j; i <=(int)n; i++)
#define REPD(i,n,j) for (int i = (int)n; i>=(int)j; i--)
#define all(vv) vv.begin(),vv.end()
//priority_queue <int, vector<int>, greater<int>> mnheap;

ll arr[200005],brr[200005];
ll ans=0;
int n;

int main()
{
    sync;
    cin>>n;
    REP(i,0,n-1)
        cin>>arr[i];
    REP(i,0,n-1)
        cin>>brr[i];
    queue<int> qq;
    REP(i,0,n-1)
        qq.push(i);
    while(!qq.empty())
    {
        int id=qq.front();
        qq.pop();
        int r=(id+1)%n;
        int l=(id-1+n)%n;
        ll tot=(brr[l]+brr[r]);
        ll used=max(0ll,(brr[id]-arr[id])/tot);
        ans+=used;
        brr[id]-=used*tot;
        if(used)
        {
            qq.push(l);
            qq.push(r);
        }
    }
    REP(i,0,n-1)
    {
        //cout<<arr[i]<<" "<<brr[i]<<endl;
        if(arr[i]!=brr[i])
            ans=-1;
    }
    cout<<ans<<endl;
}
/*
3
RRRGGGBBB
*/

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] l = new int[N];
		int[] r = new int[N];
		for(int i = 0 ; i < N ; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		int[] person = new int[1001001];
		for(int i = 0 ; i < N ; i++) {
			for(int j = l[i] - 1 ; j <= r[i] - 1 ; j++) {
				person[j] = 1;
			}
		}
		int ans = 0;
		for(int i = 0 ; i < person.length ; i++) {
			if(person[i] == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 30000
def p_d():
    N, W = map(int, input().split())
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i in range(1, N + 1):
        w, v = map(int, input().split())
        for j in range(1, W + 1):
            if j - w >= 0:
                dp[i][j] = max(v + dp[i - 1][j - w], dp[i][j], dp[i - 1][j])
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j])

    print(max(dp[N]))


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 118256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int a, s = 0, i = 10;
	while (i--)
		fscanf(stdin, "%d", &a), s += a;
	P(d, s);
	return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";



void work(){
	ll n,k;
	cin >> n >> k;
	n=n%k;
	cout << min(n,k-n) << "\n";
	
	return;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 	
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

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


	string s; cin >> s;

	string p = "";
	string t = "";
	int k = 0;
	rep(i, 0, s.size()) {
		t += s[i];
		if (t == p)continue;
		p = t;
		t = "";
		k++;
	}
	cout << k << endl;


	return 0;
}

Measured memory_bytes: 720
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, ans, p;
double sum;
int arr[105];

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    sum = 0;
    forn(i,n){
        cin >> arr[i];
        sum += arr[i];
    }
    sum = sum/n;
    sum += 0.5;
    p = (int)sum;

    ans = 0;

    forn(i,n){
        ans += ( (arr[i]-p) * (arr[i]-p) );
    }

    int temp = 0;

    forn(i,n){
        temp += ( (arr[i]-p+1) * (arr[i]-p+1) );
    }

    ans = min(ans,temp);

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 105
#define INF (1e8)
int K,N,M;
int T;
  
bool g[MAX][MAX];
int G[MAX][MAX];
int C[MAX];
int tmp[MAX][MAX];
  
bool visited[MAX];
bool used[MAX];
  
void copyA(){
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      tmp[i][j]=G[i][j];
}
void copyB(){
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      G[i][j]=tmp[i][j];
}
  
  
  
int dfs(int pos,int ti,int f){
  if(pos==ti)return f;
  visited[pos]=true;
  for(int tt=0;tt<=T;tt++){
    int to=tt;
    if(to==-1)to=T;
      
    if(visited[to])continue;
    if(G[pos][to]==0)continue;
      
    int k=dfs(to,ti, min(f,G[pos][to]) );
    if(k>0){
      G[pos][to]-=k;
      G[to][pos]+=k;
      return k;
    }
  }
  return 0;
}
  
int maxFlow(int si,int ti){
  if(si==ti)return INF;
  int res=0;
  while(1){
    memset(visited,false,sizeof(visited));
    int f=dfs(si,ti,INF);
    if(f==0)break;
    res+=f;
  
  }
  return res;
}
int calcC(int id){
  if(C[id]!=-1)return C[id];
  copyA();
  if(used[id]){
    C[id]=maxFlow(T,id);
  }else{
    C[id]=maxFlow(id,0);
  }
  copyB();
  return C[id];
}
  
int main(){
  memset(C,-1,sizeof(C));
    
  bool isOverfuro=false;
  cin>>K>>N>>M;
  T=N+K+1;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0&&1<=b&&b<=K){
      isOverfuro=true;
    }
    if(b==0&&1<=a&&a<=K){
      isOverfuro=true;
    }
    G[a][b]+=c;
    G[b][a]+=c;
    g[a][b]=true;
    g[b][a]=true;
  }
    
  for(int i=1;i<=K;i++){
    G[T][i]=INF;
  }
  
  if(isOverfuro){
    cout<<"overfuro"<<endl;
    return 0;
  }
  
  int F=maxFlow(T,0);
  assert(F>0);
    
  memset(visited,false,sizeof(visited));
  dfs(T,0,INF);
    
  for(int i=0;i<=T;i++){
    used[i]=visited[i];
  }
  
  C[0]=INF;
    
  int ans=0;
  for(int i=0;i<T;i++){
    for(int j=0;j<T;j++){
      if(i==j)continue;
      if(G[i][j]==0&&g[i][j]==true && used[i]==true && used[j]==false ){
        calcC(i);
        calcC(j);
        ans=max(ans, min(C[i],C[j]) );
      }
    }
  }
  cout<<F+ans<<endl;
  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
    string p;
    
    getline(cin, s);
    getline(cin, p);
    
    // s += s;

    // for(int i=0;i<s.size();i++){
    //     if(s.substr(i, p.size())==p){
    //         cout << "Yes" << endl;
    //         return 0;
    //     } 
    // }

    string tmp;
    for(int i=0;i<s.size();i++){
        if(s.size()-i < p.size()){
            tmp = s.substr(i,s.size()-i) + s.substr(0, i+p.size()-s.size());
        }else{
            tmp = s.substr(i, p.size());
        }
        if(tmp==p){
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;
}


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

using namespace std;

class UnionFind
{
public:
	vector<int> uni;
	UnionFind(int s) : uni(s, -1) { }

	//頂点aが所属するグループを調べる
	int root(int a)
	{
		if (uni[a] < 0) return a;
		return uni[a] = root(uni[a]);
	}

	//頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
	bool connect(int a,int b)
	{
		a = root(a);
		b = root(b);
		if (a == b) return false;

		if (uni[a] > uni[b])
		{
			a ^= b;
			b ^= a;
			a ^= b;
		}

		uni[a] = uni[a] + uni[b];
		uni[b] = a;
		return true;
	}

	//頂点a,bが同じグループであるかを調べる
	bool isConnect(int a,int b)
	{
		return root(a) == root(b);
	}

	//頂点aを含むグループの頂点数を調べる
	int size(int a)
	{
		return -uni[root(a)];
	}

};

int main() {

	int n,m; cin >> n >> m;
	
	vector<int> p(n);
	for (int i = 0;i < n;i++){
		cin >> p[i];
	}

	UnionFind u(n+1);
	int x,y;

	for (int i = 0;i < m;i++){
		cin >> x >> y;
		u.connect(x,y);
	}

	int ans = 0;

	for (int i = 0;i < n;i++){
		if(u.isConnect(i+1,p[i])) ans++;
	}

	cout << ans << endl;

	return 0;

}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

class Combination{
    private:
        vector<long long> fac, finv, inv;
    
    public:
        Combination(){
            fac = finv = inv = vector<long long> (MAX);

            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[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 long getCom(int n, int k){
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
        }
};

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

    vector<int> A(N + 1);
    rep(i, N + 1) cin >> A[i];

    vector<int> cnt(N + 1);
    int l = 0, r = N;
    rep(i, N + 1) {
        cnt[ A[i] ]++;
        if (cnt[ A[i] ] == 2) r = i;
    }

    rep(i, N + 1) {
        if (A[i] == A[r]) {
            l = i;
            break;
        }
    }

    Combination C = Combination();
    rep(k, N + 1) {
        ll A = C.getCom(N + 1, k + 1);
        ll B = C.getCom(l + N - r, k);
        ll ans = A - B;
        if (ans < 0) ans += MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n,W;
std::vector<long int> val,w;
long long int max(long long int a,long long int b){
    return a>b?a:b;
}
long long int solve(){
    long long int dp[n+1][W+1];
    int i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=W;j++){
        dp[i][j]=0;}}
    for(i=1;i<=n;i++){
        for(j=0;j<=W;j++){
            if(w[i-1]<=j){
                dp[i][j]=max(val[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }else
            dp[i][j]=dp[i-1][j];
        }
    }
    return dp[n][W];
}

int main() {
    int t,i,j;long int x;
    cin>>n>>W;
    for(i=0;i<n;i++){
             cin>>t>>x;
             w.pb(t);val.pb(x);
        }long long int y;
        y=solve();
        cout<<y;
        val.clear();
        w.clear();
	return 0;
}

Measured memory_bytes: 79104
//#include "pch.h"
#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <queue>

#include <set>
#include <vector>

using namespace std;
using ll = long long;
#define FOR(i,N) for(auto i=0; i<N; ++i)

int main() {

  ll V, E; cin >> V >> E;

  vector<vector<ll > > children(V + 1);
  map<pair<ll, ll>, ll> edge_cost;
  priority_queue< tuple<ll, ll, ll> > Q;
  FOR(i, E ) {
	  ll s, t, w;
	  cin >> s >> t >> w;
	  if (s > t) swap(s, t);
	  children[s].push_back(t);
	  children[t].push_back(s);

	  edge_cost[make_pair(s, t)] = w;
	  edge_cost[make_pair(t, s)] = w;
  }
  ll NumRemainEdges = V - 1;
  ll weightSum = 0;
  set<ll> Vertices; Vertices.insert(1);
  
  for (auto chil : children[1]) {
	  auto cost = edge_cost[make_pair(1, chil)];
	  Q.push( make_tuple(-cost, 1, chil));
  }

  while (NumRemainEdges != 0) {
	  //auto v = Q.top(); Q.pop();
	  
	  ll cost, s, t; tie(cost, s, t) = Q.top(); Q.pop();
	  if (!Vertices.count(t)) {
		  weightSum += cost;
		  NumRemainEdges -= 1;
		  Vertices.insert(t);

		  // t の子供の分を足す
		  for (auto tchil : children[t]) {
			  if (Vertices.count(tchil)) continue;
			  auto tcost = edge_cost[make_pair(t, tchil)];
			  Q.push(make_tuple(-tcost, t, tchil));
		  }
	  }
  }
  cout << -weightSum << endl;
  
  

  return 0;
}



Measured memory_bytes: 21464
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

//↑template↑


int main() {
	string h, ans = "Sunny";
	cin >> h;
	if (h == "Sunny") { ans = "Cloudy"; }
	if (h == "Cloudy") { ans = "Rainy"; }

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

class UnionFind {
public:
  vector<int> Parent;
  
  UnionFind(int N) {
    Parent = vector<int>(N, -1);
  }
  
  int root(int A) {
    if (Parent[A] < 0) {
      return A;
    }
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A) {
    return -Parent[root(A)];
  }
  
  bool connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    
    if (size(A) < size(B)) {
      swap(A, B);
    }
    
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  vector<ll> ans(M);
  ans[M - 1] = (ll) N * (N - 1) / 2;
  
  UnionFind uf(N);
  
  for (int i = M - 1; i >= 1; i--) {
    ans[i - 1] = ans[i];
    if (uf.root(A[i]) != uf.root(B[i])) {
      ans[i - 1] -= (ll) uf.size(A[i]) * uf.size(B[i]);
      uf.connect(A[i], B[i]);
    }
  }
  
  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std ;
typedef long long int ll ;
ll mod = 1e9 + 7 ;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	ll sum = 0 , n , ans = 0 ;
	cin >> n ;
	vector<ll> v(n, 0);

	for(auto &i : v) {
		cin >> i ;
		sum += i ;
	}
	for(auto &i : v){
		sum -= i ;
		sum = (sum+mod)%mod;
		ans = (ans + (i*sum)%mod)%mod;
	}
	ans = (ans + mod)%mod;
	cout << ans ;

}

Measured memory_bytes: 4708
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[][] c1 = new int[3][3];
        int[][] c2 = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c1[i][j] = in.nextInt();
                c2[i][j] = c1[i][j];
            }
        }

        for (int i = 0; i < 3; i++) {
            c1[i][2] -= c1[i][0];
            c1[i][1] -= c1[i][0];
            c1[i][0] -= c1[i][0];
        }

        for (int j = 0; j < 3; j++) {
            if (!(c1[0][j] == c1[1][j] && c1[1][j] == c1[2][j])) {
                System.out.println("No");
                return;
            }
        }

        for (int i = 0; i < 3; i++) {
            c2[2][i] -= c2[0][i];
            c2[1][i] -= c2[0][i];
            c2[0][i] -= c2[0][i];
        }

        for (int j = 0; j < 3; j++) {
            if (!(c2[j][0] == c2[j][1] && c2[j][1] == c2[j][2])) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 35664
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int count=0;
	for(int i=min(a,b); i>0; i--){
		if(!(a%i)&&!(b%i))
			count++;
		if(count == k){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], lp[N * 10], ans;
int us[N * 10], cnt[N * 10];
main() {
  file("threesum");
  ios;
  cin >> n;
  fo(i, 1, n, 1) cin >> a[i], ++cnt[a[i]];
  sort(a + 1, a + n + 1);
  fo(i, 1, n, 1) {
    bool flag = (cnt[a[i]] > 1);
    for (int j = 1; j * j <= a[i]; ++j) {
      if (a[i] % j == 0) {
        flag |= (us[j] | us[a[i] / j]);
      }
    }
    us[a[i]] = 1;
    ans += (!flag);
  }
  cout << ans;
  return 0;
}
/**
num of i
a[i]%a[j]!=0
3 8 11 16 24

33 18 45 28 8 19 89 86 2 4
*/


Measured memory_bytes: 12156
n = int(input())
slist = list(map(int, input().split()))

#print(slist)
score=0
while len(slist)>=2:
	m1 = min(slist)
	slist.remove(m1)
	m2 = min(slist)
	slist.remove(m2)
#	print(m1,m2)
	slist.append((m1+m2)/2)
#	print((m1+m2)/2)
#	print(slist)
print(slist[0])

Measured memory_bytes: 3060
import math
nums = list(map(float, input().split()))
h = nums[1] * math.sin(nums[2] * math.pi / 180)
s = nums[0] * h / 2
c = math.sqrt(nums[0]**2 + nums[1]**2 - 2 * nums[0] * nums[1] * math.cos(nums[2] * math.pi / 180))
l = c + nums[0] + nums[1]
print(s, l, h, sep = '\n')


Measured memory_bytes: 5692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,i;
    cin >> n>>i;
    cout << n-i+1<<endl;
    return 0;
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n, t, a;
vector<int> vh;
double min_div_t;
int i_min;

void input() {
	cin >> n >> t >> a;
	for (int i = 1; i <= n; i++) {
		int h;
		cin >> h;
		vh.push_back(h);
	}
}

void solve() {
	min_div_t = 1000;
	i_min = -1;

	for (int i = 1; i <= n; i++) {
		double t_i = (double)t - ((double)vh.at(i - 1) * 0.006);
		double div_t_i = abs((double)a - t_i);
		if (div_t_i < min_div_t) {
			min_div_t = div_t_i;
			i_min = i;
		}
	}
}

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

	input();

	solve();
	cout << i_min << "\n";

	return 0;
}

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

int main() {
  int n, m, s = 0;
  scanf("%d %d", &n, &m);
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s += a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  for(int i = 0; i < m; i++) {
    if(4 * m * a[i] < s) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	bool inc = false, dec = false;
	ll ans = 0;
	for (ll i = 1; i < n; i++) {
		if (!inc && !dec) {
			if (a[i] > a[i - 1]) inc = true;
			if (a[i] < a[i - 1]) dec = true;
		}
		if (inc) {
			if (a[i] < a[i - 1]) {
				ans++;
				inc = false;
			}
		}
		if (dec) {
			if (a[i] > a[i - 1]) {
				ans++;
				dec = false;
			}
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using graph = vector<vector<ll>>;
using vll = vector<ll>;
 
template <class type> void printVector(vector<type> vec){
    stringstream ss;
    for(ll i=0;i<vec.size();i++)
    {
        ss<<vec[i]<<" ";
        if(i!=vec.size()-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}


//vector<pair<ll,ll> > prime_factorize(ll n) {
    //vector<pair<ll,ll>> res;
    //for (long long p = 2; p * p <= n; ++p) {
        //if (n % p != 0) continue;
        //int num = 0;
        //while (n % p == 0) { ++num; n /= p; }
        //res.push_back(make_pair(p, num));
    //}
    //if (n != 1) res.push_back(make_pair(n, 1));
    //return res;
//}
 
vector<pair<ll,ll>> prime_factorize(ll num)
{
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=num;++p){
        if(num%p!=0)continue;
        ll ex=0;
        while(num%p==0){
            ++ex;
            num/=p;
        }
        res.push_back({p,ex});
    }
    if(num!=1)res.push_back({num,1});
    return res;
}


ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

void solve(){
    ll A,B;
    cin>>A>>B;
    ll gcd=GCD(A,B);
    ll res=prime_factorize(gcd).size()+1;
    cout<<res;
}
 
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
vector<int> v;






int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;

    if(n%2==0){
        int so = n / 2,se=1;
        foo(i,1,m+1){
            if(i%2==0){
                cout << se << " " << se+n- i << endl;
                se++;
            }
            else{
                cout << so << " " << so+i << endl;
                so--;
            }
        }
    }
    else{
        int so = 1, se = n / 2;
        foo(i,1,m+1){
            if(i%2==0){
                cout << se << " " << se + i << endl;
                se--;
            }
            else{
                cout << so << " " << so +n- i << endl;
                so++;
            }
        }
    }

}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        HashSet<String> dict = new HashSet<>();
        try {
            String line;
            String arg;
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                String cmd = st.nextToken();
                if (cmd.equals("insert")) {
                    arg = st.nextToken();
                    dict.add(arg);
                } else if (cmd.equals("find")) {
                    arg = st.nextToken();
                    if(dict.contains(arg)){
                        System.out.println("yes");
                    }else{
                        System.out.println("no");
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 131852