akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 3003;
ll i,n;
long double tot,p[N],dp[N][N];
long double solve(ll i,ll j)
{
    if(dp[i][j] != -1) return dp[i][j];
    
    if(i == 0)
        return dp[i][j] = (j == 0 ? 1 : 0);
    
    long double res = 0;
    res += solve(i - 1,j) * (1 - p[i]);
    if(j > 0)
        res += solve(i - 1,j - 1) * p[i];
    
    return dp[i][j] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    rep(i,1,n + 1) cin>>p[i];
    rep(i,n / 2 + 1,n + 1)
        tot += solve(n,i);
    cout<<setprecision(12)<<fixed<<tot;
    return 0;
}

Measured memory_bytes: 141440
times = [ int(input()) for _ in range(5) ]

next_times = [0] * 5

for i, time in enumerate(times):
    next_times[i] = (time + 9) // 10 * 10

ans = 0xdeadbeef

for i in range(5):
    time = sum(next_times) - next_times[i] + times[i]
    ans = min(ans, time)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <typeinfo>
using namespace std;

typedef long long ll;
const int mod = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    for(int i = 0; i < m; ++i){
        cin >> y[i];
    }
    
    ll x_sum = 0, y_sum = 0;
    for(int k = 0; k < n; ++k){
        x_sum = (x_sum + k * x[k] - (n - k - 1) * x[k]) % mod;
    }
    for(int k = 0; k < m; ++k){
        y_sum = (y_sum + k * y[k] - (m - k - 1) * y[k]) % mod;
    }
    cerr << x_sum << endl << y_sum << endl;

    ll ans = x_sum * y_sum % mod;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll gcd(ll a, ll b){
	if(a<b){
		return gcd(b,a);
	}else if(!b){
		return a;
	}else{
		return gcd(b,a%b);
	}
}

int main(void){
	int n,i,zero,two,three,four,cnt=0;
	ll sum = 0ll,j;
	bool flag = false,one,five;
	vector<ll> s;
	cin >> n;
	zero = n/4 + (n%2);
	two = n/4+((n%4>1)?1:0);
	three = n/4;
	four = n/4+((n%4>1)?1:0);
	if(n == 3){
		cout << "2 5 63" << endl;
		return 0;
	}else if(n == 4){
		cout << "2 5 20 63" << endl;
		return 0;
	}
	if(three%2){
		--three;
		++zero;
	}
	if(three==0){
		three += 2;
		zero -= 2;
	}
	if(zero > 5000){
		zero -= 2;
		++two;
		++four;
	}
	if(two > 5000){
		--two;
		--four;
		three += 2;
	}
	for(i=1; i<=zero; ++i){
		s.push_back(6*i);
	}
	for(i=0; i<two; ++i){
		s.push_back(6*i+2);
	}
	for(i=0; i<three; ++i){
		s.push_back(6*i+3);
	}
	for(i=0; i<four; ++i){
		s.push_back(6*i+4);
	}
	for(i=0; i<n; ++i){
		cout << ((i)?" ":"") << s[i];
		if(s[i]>30000){
			cnt++;
		}
		sum += s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
vvl G;
ll dfs(int v){
  ll res=1;
  for(auto nv:G[v]){
    res+=dfs(nv);
  }
  return res;
}
    
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  int h,w;
  cin >> h  >> w;
  vector<string>vec(h);
  rep(i,h) cin >> vec[i];
  rep(i,h){
    rep(j,w){
      if(vec[i][j]=='.')continue;
      bool ok=false;
      rep(k,4){
        int ni=i+dy[k],nj=j+dx[k];
        if(ni<0 || h<=ni || nj<0 || w<=nj)continue;
        if(vec[ni][nj]=='#')ok=true;
      }
      if(!ok){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
        
}


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


int main() {
	
	string s;
	cin>>s;
	
	if(s=="ARC")
	{
		cout<<"ABC"<<endl;
	}
	else
	{
		cout<<"ARC"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
//typedef vector<int> vi;
//typedef vector<vi> vvi;
//typedef vector<string> vs;
//typedef pair<int, int> pii;
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}



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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	(c + b - 1) / b <= (a + d - 1) / d ? puts("Yes") : puts("No");

}

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

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    
    int i;
    for(i = 1; i <= k; i++){
        if(i % 2 == 1){
            a /= 2;
            b += a;
        }else{
            b /= 2;
            a += b;
        }
    }
    
    printf("%d %d\n", a, b);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)

ll mpow(ll a, ll n){
    ll res = 1;
    while (n > 0){
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main(){
    int n, k, tmp; sc(n), sc(k);
    double ans = 0;
    for (int i = 1; i <= n; i++){
        tmp = 0;
        while (i*mpow(2, tmp) < k) tmp++;
        ans += (double) 1 / mpow(2, tmp);
    }
    ans = (double) ans / n;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,h;
  scanf("%ld %ld", &n, &h);
  long a[n],b[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  qsort(a, n, sizeof(long), cmpnum);
  qsort(b, n, sizeof(long), cmpnum);
  long attack = 0;
  for (long i = 0; i < n; i++) {
    if (b[i] > a[0]) {
      h -= b[i];
      attack++;
    } else {
      break;
    }
    if (h <= 0) {
      printf("%ld\n", attack);
      return 0;
    }
  }
  attack += h/a[0];
  if (h%a[0] != 0) {
    attack++;
  }
  printf("%ld\n", attack);

  return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
 
int main() {
    LL n; cin >> n;
    LL t, a;
    t = a = 1;
    for (int i = 0; i < n; i++) {
        LL tt, ta;
        cin >> tt >> ta;
        LL m = max((t-1) / tt, (a-1) / ta) + 1;
        t = tt * m, a = ta * m;
    }
    cout << t + a << endl;
}

Measured memory_bytes: 256
# print(count)
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if L ==0:
    ans = 0
elif R == L+1:
    ans = R*L%2019
elif R-L > 2019:
    ans = 0
else:
    if l >= r:
        r += 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9

int main(){
  int N, M, i, j;
  scanf("%d%d", &N, &M);
  vector<vector<int>> g(N, vector<int>(0));
  for(i = 0; i < M; i++){
    int s, t;
    scanf("%d%d", &s, &t);
    s--;
    t--;
    g[s].push_back(t);
  }
  double ans = inf;
  for(int x = 0; x < N; x++){
    if(g[x].size() == 1){
      continue;
    }
    vector<double> E(N, 0);
    for(i = N - 2; i >= 0; i--){
      double nextEmax = 0;
      double nextEsum = 0;
      for(j = 0; j < g[i].size(); j++){
        nextEsum += E[g[i][j]];
        nextEmax = max(nextEmax, E[g[i][j]]);
      }
      if(i == x){
        E[i] = (nextEsum - nextEmax) / (g[i].size() - 1);
      }
      else{
        E[i] = nextEsum / g[i].size();
      }
      E[i] = E[i] + 1;
    }
    ans = min(ans, E[0]);
  }
  printf("%.10lf\n", ans);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, X;
vector<ll> L;
vector<ll> bound;

signed main()
{
    cin >> N >> X;
    L.resize(N);
    bound.push_back(0);
    REP(i, N) {
        cin >> L[i];
        ll cur = bound[bound.size()-1];
        bound.push_back(cur + L[i]);
    }

    ll ans = 0;
    REP(i, bound.size()) {
        if(bound[i] <= X) { ans++; }
    }
    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print('3')
elif A == 1 and B == 3:
  print('2')
elif A == 2 and B == 1:
  print('3')
elif A == 2 and B == 3:
  print('1')
elif A == 3 and B == 1:
  print('2')
elif A == 3 and B == 2:
  print('1')



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


def main():
    n = int(input())
    a = int(input())
    # i = list(map(int,input().split()))
    # j = list(map(int,input().split()))

    check = n % 500
    # print(check)

    if check <= a:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    vector<ll> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
        
    }
    cout << ans << endl;
    
}


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

class Main {

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

        try {

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

            List<String> numbers = Arrays.asList(br.readLine().split(""));
            numbers.stream().forEach(s -> System.out.print(s.equals("9") ? "1" : "9"));
            System.out.println();
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 26196
import numpy as np
from itertools import product
s = input()
n = int(s)

digit = len(s)

selected_num = []
for order in range(3, 10, 1):
    for i in product('753', repeat = order):
        concat_str = "".join(i)
        if(('7' in concat_str) and ('5' in concat_str) and ('3' in concat_str)): 
            selected_num.append(int(concat_str))

selected_num_array = np.array(selected_num)

print(np.sum(selected_num_array <= n))


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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
      fastio;

      ll a,b;
      cin>>a>>b;
      ll gd=__gcd(a,b);
      cout<<(a*b)/gd<<endl;
    }

Measured memory_bytes: 3656
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        long[][] c = new long[10][10];
        for (int i = 1; i <= N; i++) {
            int s = i;
            while (s > 9) s /= 10;
            int e = i % 10;
            c[s][e]++;
        }


        long ans = 0;
        for (int i = 1; i < 10; i++)
            for (int j = 1; j < 10; j++)
                ans += c[i][j] * c[j][i];

        System.out.println(ans);
    }

}



Measured memory_bytes: 23380
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a, b, c, d = map(int, readline().split())
    if abs(a-c)<=d:
        print('Yes')
    else:
        if a<=b<=c and b-a<=d and c-b<=d:
            print('Yes')
        elif c<=b<=a and b-c<=d and a-b<=d:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
// template<class t, class u>
// ostream& operator<<(ostream& os, const pair<t, u>& p) {
//   return os << "{" << p.first << ", " << p.second << "}";
// }
// template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
//   os << "{";
//   rep(i, v.size()) { if(i) os << ", "; os << v[i]; }
//   return os << "}";
// }
// template<class t> ostream& operator<<(ostream& os, const set<t>& se) {
//   os << "{";
//   auto itr = se.begin();
//   rep(i, se.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
// template<class t, class u>
// ostream& operator<<(ostream& os, const map<t, u>& mp) {
//   os << "{";
//   auto itr = mp.begin();
//   rep(i, mp.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  int cnt = 0;
  int mn = N+1;
  rep(i, N) {
    if(P[i] < mn) {
      cnt++;
      mn = P[i];
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void swap(int *x,int *y);
void maxHeapify(int i);
int extract();
void insert(int key);

int main(void)
{
  int key;
  char com[10];
    
  while(1)
    {
      scanf("%s",com);
	
      if(com[0]=='e'&&com[1]=='n')
	{
	  break;
	}
	
      if(com[0]=='i')
	{
	  scanf("%d",&key);
	  insert(key);
        }
      else
	{
	  printf("%d\n",extract());
        }
    }
  return 0;
}

void swap(int *x,int *y)
{
  int tmp;

  tmp=*x;

  *x=*y;

  *y=tmp;
}

void maxHeapify(int i)
{
  int l,r,largest;
  
  l=2*i;
  
  r=2*i+1;

  if(A[l]>A[i]&&l<=H)
    {
      largest=l;
    }

  else
    {
      largest=i;
    }

  if(A[r]>A[largest]&&r<=H)
    {
      largest=r;
    }

  if(largest!=i)
    {
      swap(&A[i],&A[largest]);

      maxHeapify(largest);
    }

}

int extract()
{
  int maxv;
    
  if(H<1)
    {
      return -INFTY;
    }
    
  maxv=A[1];
    
  A[1]=A[H--];
    
  maxHeapify(1);
    
  return maxv;
}


void increaseKey(int i,int key)
{
  if(key<A[i])
    {
      return;
    }
    
  A[i]=key;
    
  while(i>1&&A[i/2]<A[i])
    {
      swap(&A[i],&A[i/2]);
	
      i=i/2;
    }
}


void insert(int key)
{
  H++;
  A[H]=-INFTY;
  increaseKey(H, key);
}



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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#endif
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

#define int              long long
#define ll               long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
#define rep(i,n)         for(int i=0;i<n;i++)
#define fr(i,a,b)          for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
#define tr(a,x)          for(auto& a:x)
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const ll inf = 1e18;
const int N = 2e5 + 10;

void solve(int tc)
{
	int n;
	cin >> n;
	vi cnt(1000000 + 1, 0);
	rep(i, n)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	int ans = 0;
	vi vis(1000000 + 1, 0);
	fr(i, 1, 1000000)
	{
		if (cnt[i] == 0 || vis[i]) continue;
		//number i is not present ,or if present,then there is divisor of i already in the array
		if (cnt[i] == 1 && !vis[i]) ans++;
		// cnt[i] must be strictly 1 ,otherwise there will be copies of i in the array which will divide i
		//!vis[i] denotes that there is not divisor of i
		for (int j = i; j <= 1000000; j += i) vis[j] = 1;
		//if cnt[i]>=1 ,then we will not consider all its multilples in the answer
	}
	cout << ans << endl;

}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;

	fr(i, 1, t) solve(t);

	return 0;
}

Measured memory_bytes: 18788
#include<iostream>
#include<algorithm>	
#define rep(i,a) for(int i=0;i<a;i++) 
using namespace std;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		int mi=inf;
		rep(i,110)rep(j,1010)mi=min(mi,(n<i*i*i+j*j?inf:i+j+n-i*i*i-j*j));
		cout<<mi<<endl;
	}
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int N,M;
  int A;
  
  cin>>N>>M;
  
  for(int i=0;i<M;i++){
      cin>>A;
      N=N-A;
  }
  
  if(N>=0){
      cout<<N;
      
  }
  else{
      cout<<"-1";
  }

  
  return 0;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

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


def main():
    n,k = LI()
    xs = set()
    ys = set()
    a = []
    for _ in range(n):
        x,y = LI_()
        a.append((x,y))
        xs.add(x)
        ys.add(y)
    xd = {}
    yd = {}
    for x,i in zip(sorted(list(xs)), range(n)):
        xd[x] = i
    for y,i in zip(sorted(list(ys)), range(n)):
        yd[y] = i
    xis = sorted(list(xs))
    yis = sorted(list(ys))

    b = []
    for x,y in a:
        b.append((xd[x],yd[y]))

    if k == 1:
        return 0

    r = inf
    for i in range(n):
        xi = xis[i]
        for j in range(n-1,i-1,-1):
            xj = xis[j]
            xf = True
            for l in range(n):
                yl = yis[l]
                for m in range(n-1,l-1,-1):
                    t = 0
                    for x,y in b:
                        if i <= x <= j and l <= y <= m:
                            t += 1
                    if t >= k:
                        tr = (xj-xi) * (yis[m]-yl)
                        if tr < r:
                            r = tr
                        xf = False
                    else:
                        break
            if xf:
                break

    return r


print(main())




Measured memory_bytes: 68840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    string T;
    cin >> T;
    for (int i = 0; i < T.length(); ++i)
        if (T[i] == '?')
            T[i] = 'D';

    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n,k,ans=0;
  cin>>n>>k;
  rep(i,n){
    int l;
    cin>>l;
    if(l>=k) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    char s[100];
    int k,l;
    cin>>k>>s;
    l = strlen(s);
	if(k>=l) cout<<s;
	else {
		for(int i = 0;i<k;i++)cout<<s[i];
		cout<<"...";
	}
    
    
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<int, int>  ii;
typedef pair<double, double>  iidb;
#define iii pair<ii, nodo*>
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 300000
#define offset 3000
#define ptr nodo*


using namespace std;
string txt[20];
int n;
int dp[tam][10][10];
const int MOD=1e9+7;
int f(int pos,int col1,int col2)
{
	if (pos==n)
		return 1;
	if (pos>n)
		return 0;
	if (dp[pos][col1][col2]!=-1)
		return dp[pos][col1][col2];
	int ways=0;
	if (txt[0][pos]==txt[1][pos])
	{
		forr(col,1,4)
		{
			if (col!=col1 && col!=col2)
				ways+=f(pos+1,col,col),ways%=MOD;
		}
		
	}
	else
	{
		forr(colx,1,4)
		{
			forr(coly,1,4)
			{
				if (colx==coly)continue;
				if (colx!=col1 && coly!=col2)
					ways+=f(pos+2,colx,coly),ways%=MOD;
			}
		}
	}
	
	//acout<<pos<<" "<<col1<<' '<<col2<<' '<<' '<<ways<<endl;
	return dp[pos][col1][col2]=ways;
}
int main()
{	
	
	cin>>n;
	memset(dp,-1,sizeof dp);
	cin>>txt[0]>>txt[1];
	cout<<f(0,0,0)<<endl;
}

Measured memory_bytes: 120828
use proconio::input;

fn main() {
    input!{
        s:String,t:String
    }   

    let mut ans=0 ;
let ss:Vec<char>=s.chars().collect();
let tt:Vec<char>=t.chars().collect();
    for i in 0..3 {
        if ss[i] == tt[i] {
        ans+=1;
        }
    } 
   println!
       ("{}",ans);


}


Measured memory_bytes: 2120
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())




    const int MAX_V = 2010;
    
    int V; // 左の頂点数。忘れずに設定すること。
    // ちなみに、Vは左右合わせた全部の頂点数でも問題ない。（左が終わった後に右からのをチェックしても、マッチ数は絶対増えない）
    
    
    VI G[MAX_V]; // ちゃんとGもケースごとに全部clear。
    int match[MAX_V];
    bool used[MAX_V];
    
    void add_edge(int u, int v){
        G[u].PB(v);
        G[v].PB(u);
    }
    
    bool dfs(int v){
        used[v] = true;
        REP(i, SZ(G[v])){
            int u = G[v][i], w = match[u];
            if(w < 0 || (!used[w] && dfs(w))){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
    
    int bipartite_matching(){
        int res = 0;
        MSET(match, -1);
        REP(v, V){
            if(match[v] < 0){
                MSET(used, 0);
                if(dfs(v)) res++;
            }
        }
        return res;
    }
    
    
    
int INF = (1<<29);

int n, m, l;
int g[110][110];
int p[1010], t[1010];

void init() {
}

void input() {
	REP(i, 110) REP(j, 110) g[i][j] = INF;
	REP(i, n) g[i][i] = 0;
	REP(i, m){
		int u, v, d;
		cin >> u >> v >> d;
		g[u][v] = d, g[v][u] = d;
	}
	REP(k, n) REP(i, n) REP(j, n) chmin(g[i][j], g[i][k]+g[k][j]);
	REP(i, l) cin >> p[i] >> t[i];
}

void solve() {
	V = l*2;
	REP(i, V) G[i].clear();
	REP(i, l) REP(j, l) if(i != j){
		if(t[i] + g[p[i]][p[j]] <= t[j]) add_edge(i, j+l);
		if(t[j] + g[p[j]][p[i]] <= t[i]) add_edge(j, i+l);
	}
	cout << l - bipartite_matching() << endl;
}

int main() {
	init();
	while(cin >> n >> m >> l){
		if(n == 0) break;
		input();
		solve();
	}
	return 0;
}

Measured memory_bytes: 18284
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	vector<char> n;
	char c;

	for (int i = 0; i < 3; i++) {
		cin >> c;
		n.push_back(c);
	}
	if (n[0] == n[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
W = list(map(int, input().split()))
Wtotal = 0
S1 = 0
S2 = 0
Wdf = [0] * N

for i in range(len(W)):
	Wtotal += W[i]

for j in range(len(W)):
	S1 += W[j]
	S2 = Wtotal - S1
	Wdf[j] = abs(S1 - S2)

print(min(Wdf))	

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int a, b, c, x, y, z;
	cin >> a >> b >> c;
	if (a>b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	if (y>c) {
		z = y;
		y = c;
	} else {
		z = c;
	}
	if (x>y) {
		cout << y << " " << x << " " << z << endl;
	} else {
		cout << x << " " << y << " " << z << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	vector<ull> base;
	vector<vector<ull>> hashvalue, basepower;
	int length;
	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
public:
	rollinghash(T s) {
		length = s.size();
		base = { 200004 };
		hashvalue = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			for (int i = 0; i < length; i++) {
				hashvalue[i + 1][j] = modulo(multiply(hashvalue[i][j], base[j]) + s[i]);
			}
		}
		basepower = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			basepower[0][j] = 1;
			for (int i = 1; i <= length; i++) {
				basepower[i][j] = modulo(multiply(basepower[i - 1][j], base[j]));
			}
		}
	}
	ull hash(ll l, ll r, ll i) {
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r][i] + mod61 * 3 - multiply(hashvalue[l][i], basepower[r - l][i]));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (j + ans > n || ans != 0 && rol.hash(i, i + ans, 0) != rol.hash(j, j + ans, 0)) continue;
			int ok = ans, ng = j - i + 1;
			while (ng - ok > 1) {
				int mid = (ok + ng) / 2;
				bool flag = true;
				rep(k, 1) {
					if (j + mid > n || rol.hash(i, i + mid, k) != rol.hash(j, j + mid, k)) flag = false;
				}
				if (flag) ok = mid;
				else ng = mid;
			}
			chmax(ans, ok);
		}
	}
	cout << ans << '\n';
}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


const int maxn = 1e5+10;
char s[maxn];
int a[maxn], b[maxn], n, sum[maxn];
inline bool valid(int mid)
{
  memcpy(a, b, sizeof(a));
  memset(sum, 0, sizeof(sum));
  for (int i = 1; i <= n-mid+1; ++i)
    {
      sum[i] ^= sum[i-1];
      if (a[i]^sum[i])
	{
	  sum[i] ^= 1;
	  sum[i+mid] ^= 1;
	  a[i] ^= 1;
	}
    }
  for (int i = n-mid+2; i <= n; ++i)
    {
      sum[i] ^= sum[i-1];
      a[i] ^= sum[i];
    }
  for (int i = n-mid+2; i <= n; ++i)
    if (a[i] == 1)
      {
	if (i-mid<=0)
	  {
	    return false;
	  }
	while (i <= n && a[i]==1)
	  ++i;
	--i;
      }
  return true;
}

int main()
{
  scanf("%s", s);
  n = strlen(s);
  for (int i = 1; i <= n; ++i)
    b[i] = s[i-1] == '1';
  int l = 1, r = n, mid, ans = 1;
  while (l <= r)
    {
      mid = (l+r)>>1;
      if (valid(mid))
	{
	  ans = mid;
	  l = mid+1;
	}
      else
	r = mid-1;
    }
  printf("%d\n", ans);
}
/*
deque<int> g[300];

const int maxn = 2e5+1;
char s[maxn];
int n;
inline void no()
{
  puts("-1");
  exit(0);
}
int main()
{
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; ++i)
    g[s[i]].push_back(i);
  char center;
  if (n%2==0)
    {
      for (char c = 'a'; c <= 'z'; ++c)
	if (((int)dq[c].size())%2)
	  no();
    }
  else
    {
      int cnt = 0;
      for (char c = 'a'; c <= 'z'; ++c)
	if (((int)dq[c].size())%2)
	  ++cnt, center = c;
      if (cnt != 1)
	no();
    }
  int ans = 0;
  
}
*/


Measured memory_bytes: 1536
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct BipartiteMatching {
    vector<vector<int> > G;
    vector<int> match;
    vector<bool> used;

    int V;
    BipartiteMatching(int V):V(V){
        G.resize(V);
        match.resize(V);
        used.resize(V);
    }

    void add_edge(int u,int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }

    bool dfs(int v) {
        used[v]=true;
        for(int i=0;i<G[v].size();i++){
            int u=G[v][i];
            int w=match[u];
            if(w<0||!used[w]&&dfs(w)) {
                match[v]=u;
                match[u]=v;
                return true;
            }
        }
        return false;
    }

    int operator() () {
        int res=0;
        match.assign(V,-1);
        for(int v=0;v<V;v++){
            if(match[v]<0) {
                used.assign(V,0);
                if(dfs(v)) res++;
            }
        }
        return res;
    }
};

int m,n;
int b[502];
int r[502];

void solve() {
    rep(i,m) cin>>b[i];
    rep(i,n) cin>>r[i];
    BipartiteMatching bm(m+n);

    rep(i,m) rep(j,n) {
        if(__gcd(b[i],r[j])>1) {
            bm.add_edge(i,j+m);
            bm.add_edge(j+m,i);
        }
    }

    cout<<bm()<<endl;

}

int main() {
    while(cin>>m>>n) {
        if(n+m==0) break;
        solve();
    }

    return 0;
}

Measured memory_bytes: 4060
#include <iostream>
 
using namespace std;
 
int main(){
  int s;
 
  cin >> s;
  int h = s / 3600; s %= 3600;
  int m = s / 60; s %= 60; 
  cout << h << ":" << m << ":" << s << endl;
 
  return 0;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int ed[10][10];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	MEM(ed, 0);
	int n, m; cin >> n >> m;
	vector<int> ord(n);
	REPU(i, 0, n) ord[i] = i;
	REPU(i, 0, m) {
		int a, b; cin >> a >> b;
		--a, --b;
		ed[a][b] = ed[b][a] = 1;
	}
	int ans = 0;
	do {
		if (ord[0] == 0) {
			bool good(true);
			REPU(i, 1, n) {
				if (!ed[ord[i]][ord[i - 1]]) {
					good = false; break;
				}
			}
			if (good) ans++;
		}
	} while (next_permutation(ALL(ord)));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n; string s;
    cin >> n >> s;
    
    
    vector<int> is(n);    
    rep(i, n){
        if (s[i] == 'R') is[i] = 0;
        else if (s[i] == 'G') is[i] = 1;
        else is[i] = 2;
    }

    ll ans = 0;
    rep1(j, n-2){
        //真ん中の数字をjとする。

        int l[2] = {0};
        for(int i = j-1; i>=0; i--){
            if (is[i] == is[j]) continue;
            if ((is[i]+1)%3 == is[j]) l[0]++;
            else l[1]++; 
        }
        int r[2] = {0};
        for(int i = j+1; i<n; i++){
            if (is[i] == is[j]) continue;
            if ((is[i]+1)%3 == is[j]) r[0]++;
            else r[1]++; 
        }

        int com = 0;
        for(int move = 1; move<=min(j,(n-1)-j); move++){
            if (is[j+move] != is[j] && is[j-move] != is[j] && is[j+move] != is[j-move]){
                com++;
            }
        }
        int tans = (l[0]*r[1]) + (l[1]*r[0]) - com;
        //cout << com << ":" << tans << endl;
        ans += tans;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll h, w;
  cin >> h >> w;
  ll ans = 0;
  if (h==1 && w==1) {
    cout << "1" << endl;
    return 0;
  }
  if (min(h, w)==1) {
    ans = h*w-2;
    cout << ans << endl;
    return 0;
  }
  ans = (h-2)*(w-2);
  cout << ans << endl;
  return 0;
}

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

const int MAX = 110;
const int INF = INT_MAX;

int edge[MAX][MAX];
int dist[MAX];

void dijkstra(int s, int n)
{
  queue<int> que;

  dist[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int u = que.front(); que.pop();
    for (int v = 0; v < n; v++) {
      if (edge[u][v] != -1 && (dist[v] == INF || dist[v] > dist[u] + edge[u][v])) {
        dist[v] = dist[u] + edge[u][v];
        que.push(v);
      }
    }
  }
}

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

  memset(edge, -1, sizeof(edge));
  fill(dist, dist+n, INF);

  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v, c; cin >> v >> c;
      edge[u][v] = c;
    }
  }

  dijkstra(0, n);

  for (int i = 0; i < n; i++)
    cout << i << " " << dist[i] << endl;

  return EXIT_SUCCESS;
}




Measured memory_bytes: 3132
#include<iostream>
#define N 50000
using namespace std;

bool isP[N+1];

void make_isP(){
  isP[0]=isP[1]=false;
  for(int i=2;i<=N;i++)isP[i]=true;
  for(int i=2;i*i<=N;i++){
    if(!isP[i])continue;
    for(int j=i*i;j<=N;j+=i)isP[j]=false;
  }
}

int main(){
  make_isP();
  //for(int i=0;i<=20;i++)cout<<i<<" "<<isP[i]<<endl;
  int n,cnt;
  while(cin>>n&&n){
    
    cnt=0;
    for(int i=0;i<=n/2;i++){
      if(isP[i]&&isP[n-i]){
	cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    int x3=(y1-y2+x2),y3=(-x1+x2+y2);
    int x4=(y2-y3+x3),y4=(-x2+x3+y3);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#define MAX 500001
using namespace std;

int cnt = 0;
void merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int L[MAX], R[MAX];
	
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];

	}

	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	
	}
	
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}


void mergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n, A[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	
	mergeSort(A, 0, n);
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 7020
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1



int main()
{

    map<ll,ll> v;
    map<ll,ll> :: iterator it;
    ll n, p;
    cin >> n >> p;
        ll r, t;
    while(n--)
    {
        cin >> r >> t;
        if(v.count(r)==0) v[r] = 0;

        v[r] += t;

    }

  it= v.begin();
  r = it->S;

    while(r<p)
    {
        it++;
//        cout << it->S<< endl;
        r += it->S;
    }
//    if(it!=v.end())
    cout << it->F;

    return 0;
}


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

int main()
{
    int X, Y;
    int score;
    cin >> X >> Y;
    score = 0;
    if(X == 3) {
        score += 100000;
    } else if(X == 2) {
        score += 200000;
    } else if(X == 1) {
        score += 300000;
    }
    if(Y == 3) {
        score += 100000;
    } else if(Y == 2) {
        score += 200000;
    } else if(Y == 1) {
        score += 300000;
    }
    if(X == 1 && Y == 1) {
        score += 400000;
    }

    cout << score << endl;

    return 0;
}

Measured memory_bytes: 256
def main():

    from math import gcd
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    alst = list(map(int, input().split()))
    aa = alst[0]
    for a in alst:
        aa = gcd(aa, a)
    if aa != 1:
        print("not coprime")
        exit()
    
    max_n = 10 ** 3 + 1
    div = [True for _ in range(max_n)]
    div[0] = div[1] = False
    prime_lst = []
    for i in range(2, int(max_n ** 0.5 + 1)):
        if not div[i]:
            continue
        prime_lst.append(i)
        for j in range(i * 2, max_n, i):
            div[j] = False
    tf = [False for _ in range(max_n)]
    for i in range(n):
        for pr in prime_lst:
            if alst[i] % pr == 0:
                if tf[pr]:
                    print("setwise coprime")
                    exit()
                while alst[i] % pr == 0:
                    alst[i] //= pr
                    tf[pr] = True
    alst.sort()
    bef = 1
    for a in alst:
        if a == 1:
            continue
        elif a == bef:
            print("setwise coprime")
            exit()
        bef = a
    print("pairwise coprime")
main()

Measured memory_bytes: 185040