akhauriyash/Code-Regression huggingface dataset:
t=int(input())

for count in range(t):
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    
    diff=[] 
    if n<=k:
        print(0)
        continue
    
    for i in range(n-1):
        diff.append(x[i+1]-x[i])
        
    diff.sort()
    ans=0
    for i in range(max(0,n-k)):
        ans+=diff[i]
    
    print(ans)



Measured memory_bytes: 21304
#include <stdio.h>
void swap(int *a, int *b)
{
	int c;
	c = *a;
	*a = *b;
	*b = c;
}
int bubblesort(int a[], int N, int count)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (a[j] < a[j - 1])
			{
				swap(&a[j], &a[j - 1]);
				++count;
			}
		}
	}
	return count;
}

void print(int a[], int N)
{
	for (int i = 0; i < N; i++)
	{
		printf("%d", a[i]);
		if (i != N - 1)
		{
			printf(" ");
		}
	}
	printf("\n");
}

int main()
{
	int count = 0;
	int a[100];
	int N;
	scanf("%d", &N);

	getchar();

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}



	count = bubblesort(a, N, count);
	print(a, N);
	printf("%d\n", count);


	return 0;
}


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

using namespace std;

#define MAX_N 100
#define MAX_M 50
#define INF (1<<29)

int main()
{
    int N, M;
    double L;
    cin >> N >> M >> L;
    vector<double> P(N), T(N), V(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i] >> T[i] >> V[i];
        P[i] /= 100;
    }
    double p[MAX_N][MAX_M+1][MAX_M+1];
    memset(p, 0, sizeof(p));

    for (int i = 0; i < N; i++) {
        p[i][0][0] = 1;
        for (int j = 0; j < M; j++) {
            for (int k = 0; k < M; k++) {
                p[i][j+1][k]   += p[i][j][k] * (1 - P[i]);
                p[i][j+1][k+1] += p[i][j][k] * P[i];
            }
        }
    }
    
    for (int i = 0; i < N; i++) {
        double res = 0;
        for (int j = 0; j <= M; j++) {
            double r = 1;
            bool win = 1;
            for (int k = 0; k < N; k++) {
                if (i == k) {
                    continue;
                }
                double rr = 0;
                bool ok = 0;
                for (int l = M; l >= 0; l--) {
                    if (V[k]*L+V[k]*V[i]*T[i]*j <
                        V[i]*L+V[i]*V[k]*T[k]*l) {
                        ok = 1;
                        rr += p[k][M][l];
                    } else {
                        break;
                    }
                }
                if (!ok) {
                    win = 0;
                    break;
                }
                r *= rr;
            }
            res += (win ? r * p[i][M][j] : 0);
        }
        printf("%.8f\n", res);
    }
    return 0;
}

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

struct Edge{
    int from,to;
    double cost;
};
using Edges=vector<Edge>;

class UnionFind{
    vector<int> par;
    vector<int> rank;
    public:
    UnionFind(int n):par(n,0),rank(n,0){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    int merge(int x,int y){
        x=find(x),y=find(y);
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }
    }
    bool same(int x,int y){return find(x)==find(y);}
};

double MST(int n,Edges &edges){
    double res=0;
    UnionFind u(n);
    sort(begin(edges),end(edges),[](Edge lhs,Edge rhs){return lhs.cost<rhs.cost;});
    for(int i=0;i<edges.size();i++){
        if(!u.same(edges[i].from,edges[i].to)){
            res+=edges[i].cost;
            u.merge(edges[i].from,edges[i].to);
        }
    }
    return res;
}

int main(){
    int n;
    cout<<setprecision(3)<<fixed;
    while(cin>>n,n){        
        vector<double> x(n),y(n),z(n),r(n);
        for(int i=0;i<n;i++){
            cin>>x[i]>>y[i]>>z[i]>>r[i];
        }
        auto dbl=[](double v){return v*v;};
        auto dist=[&](int i,int j){
            return sqrt(dbl(x[i]-x[j])+dbl(y[i]-y[j])+dbl(z[i]-z[j]));
        };
        Edges edges;
        for(int i=0;i<n;i++){
            for(int j=0;j<i;j++){
                edges.push_back(Edge{i,j,max(double(0),dist(i,j)-r[i]-r[j])});
            }
        }
        cout<<MST(n,edges)<<endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >>n;
    int c[n-1],s[n-1],f[n-1];
    for(int i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int j=0;j<n;j++){
        long long t = 0;
        for(int i=j;i<n-1;i++){
           // cout << t <<endl;
            if(t<=s[i]){
                t += s[i]-t;
            }
            else{
                if((t-s[i])%f[i] !=0){
                    t += f[i]-(t-s[i])%f[i];
                }
                 
            }
            t += c[i];
        } 
        cout << t << endl;  
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int ans = 0;
  int current = n;
  while (current > 0) {
    ans += t;
    current = current - x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3184
a,b = map(int,input().split())
'''
floor(x * 1.08) = a -> x = a/1.08
floor(x * 1.10) = b -> x = b/1.10
少数や切り捨てがめんどくさい・・・全探索か
'''
ans = -1
for n in range(10000):
    if n * 8 // 100 == a and n * 10 // 100 == b:
        ans = n
        break
print(ans)

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

int main(){
  int vecx[100], vecy[100];
  int n;

  scanf("%d", &n);

  for(int i = 0; i < n; i++)scanf("%d", &vecx[i]);
  for(int i = 0; i < n; i++)scanf("%d", &vecy[i]);

  double d[4];
  for( int i = 0; i < 4; i++) d[i] = 0.0;

  for (int p = 1; p < 4; p++ ){
    for ( int i = 0; i < n; i++ ){
      d[p] += pow(fabs(vecx[i]-vecy[i]), p);
    }
    d[p] = pow(d[p], 1.0/p);
  }

  for ( int i = 0; i < n; i++ ){
    d[0] = (d[0] < fabs(vecx[i]-vecy[i])?fabs(vecx[i]-vecy[i]):d[0]);
  }

  printf("%lf\n", d[1]);
  printf("%lf\n", d[2]);
  printf("%lf\n", d[3]);
  printf("%lf\n", d[0]);

  return 0;
}

Measured memory_bytes: 1972
H, W, K = map(int, input().split())
a = [0]
b = [1]
c = [1]
P = 10**9+7

X = [0 for i in range(W)]
X[0] = 1

for i in range(W):
    a.append(b[i])
    b.append(a[i] + b[i])
    c.append(a[-1]+b[-1])

for h in range(H):
    Y = [0 for i in range(W)]
    for w in range(W):
        t = X[w] * b[w]*b[W-w-1]
        if w>0:
            t += X[w-1] * b[w-1] * b[W-w-1]
        if w<W-1:
            t += X[w+1] * b[w] * b[W-w-2]
        
        t %= P
        Y[w] = t
    X = Y
    

print(X[K-1])


Measured memory_bytes: 3064
x,k,d=map(int, input().split())
if abs(x)//d>=k:
    #print("ひ")
    print(abs(x)-d*k)
elif (k-abs(x)//d)%2==0:
    #print("fu")
    print(abs(x)%d)
else:
    #print("mi")
    print(d-abs(x)%d)



Measured memory_bytes: 9076
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()).Distinct().Count());

    }
}

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

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

    int res = 0;
    //i+1<Nを条件に常に入れることが大事
    for (int i = 0; i < N; ++i){
        // same を抜ける
        while (i+1 < N && A[i] == A[i+1]) ++i;

        // up
        if (i+1 < N && A[i] < A[i+1]) {
            while (i+1 < N && A[i] <= A[i+1]) ++i;
        }
        // down
        else if (i+1 < N && A[i] > A[i+1]) {
            while (i+1 < N && A[i] >= A[i+1]) ++i;
        }
        ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 3784
#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>;

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 long long INF = 1LL << 60;

int main(void){
	int a,b;cin >> a >> b;
	int ans = 0;int x = 1;
	while(x<b){
		x += a-1;
		ans++; 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    if (i + j > n) {
                        continue;
                    }
                    int k = n - (i + j);
                    int r = i * 10000 + j * 5000 + k * 1000;
                    if (y == r) {
                        System.out.println(i + " " + j + " " + k);
                        return;
                    }
                }
            }
            int dead = -1;
            System.out.println(dead + " " + dead + " " + dead);
        }
    }
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    long long M;
    std::cin >> M;
    std::vector<std::string> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    std::vector<std::string> B(M);
    for (int i = 0; i < M; i++) {
        std::cin >> B[i];
    }
    bool f = false;
    rep(yn, N - M + 1) rep(xn, N - M + 1) {
        bool fm = true;
        rep(ym, M) rep(xm, M) {
            if (A[yn + ym][xn + xm] != B[ym][xm]) fm = false;
        }
        if (fm) {
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll w_limit = 100'001;
    ll n, w;
    cin >> n >> w;
    vector<pair<int, long long>> sack(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> sack[i].first >> sack[i].second;
    }
    sort(sack.begin(), sack.end());
    vector<vector<long long>> dp(w + 1, vector<long long>(n + 1));
    for (int i = 0; i <= w; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            dp[i][j] = dp[i][j - 1];
            if (i >= sack[j].first)
            {
                dp[i][j] = max(dp[i][j], sack[j].second + dp[i - sack[j].first][j - 1]);
            }
        }
    }
    cout << dp[w][n];
    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n, m;
    cin >> n >> m;
    Graph G(n);
    int a, b;
    rep(i, m){
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> use(n, 0);
    auto check = [&](int v){
        repe(i, G[v]){
            if(!use[i]) return i;
        }
        return -1;
    };

    deque<int> ans;
    ans.push_front(a);
    ans.push_back(b);
    use[a] = 1;
    use[b] = 1;
    while(1){
        int nxt = check(a);
        if(nxt != -1){
            a = nxt;
            ans.push_front(a);
            use[a] = 1;
            continue;
        }
        nxt = check(b);
        if(nxt != -1){
            b = nxt;
            ans.push_back(b);
            use[b] = 1;
            continue;
        }
        break;
    }
    cout << ans.size() << endl;
    repe(i, ans){
        cout << i+1 << " ";
    }
    cout << endl;

}

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

using namespace std;


int main() {
    int n ; cin >> n;
    bool ok = false;
    vector<int>v(n) , mark(n + 1);
    for(int& i : v){
        cin >> i;
        if(i % 2 == n % 2)ok = true;
        mark[i]++;
        if(mark[i] > 2){
            ok = true;
        }
    }
    int z = count(v.begin() , v.end() , 0);
    if(z && n % 2 == 0){
        cout << 0 << endl;
        return 0;
    }
    if(z > 1 || ok){
        cout << 0 << endl;
        return 0;
    }
    const int M = 1e9 + 7;
    auto qpow = [&](long long x , int n){
        long long res = 1;
        for(;n;n>>=1){
            if(n&1)res = (res * x) % M;
            x = (x * x) % M;
        }
        return res;
    };
    cout << qpow(2 , n / 2) << endl;

    
}

Measured memory_bytes: 3908
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





class unionfind
{
private:
    vector<ll> par;
    vector<ll> rank;
    vector<ll> counter;
public:
    unionfind(ll n);
    ll find(ll x);
    void unite(ll x, ll y);
    bool same(ll x, ll y);
    ll count(ll x);
};

// 初期化
unionfind::unionfind(ll n){
    for (ll i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
        counter.push_back(1);
    }
}

// 木の根を求める
ll unionfind::find(ll x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unionfind::unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y)return;
    
    if (rank[x] < rank[y]) {
        counter[y] += counter[x];
        counter[x] = counter[y];
        par[x] = y;
    }
    else {
        counter[y] += counter[x];
        counter[x] = counter[y];
        par[y] = x;
        if (rank[x] == rank[y]) {
            rank[x]++;
        }
    }
}

// xとyが同じ集合に属していたらtrue
bool unionfind::same(ll x, ll y) {
    return find(x) == find(y);
}

// xと同じ集合に属している要素数を返す
ll unionfind::count(ll x){
    return counter[find(x)];
}


int main() {
    ll n;
    int m;
    scanf("%lld %d", &n, &m);
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }
    unionfind uni(n);
    vector<ll> ans(m);
    ll res = n * (n - 1) / 2;
    for(int i = m - 1; i >= 0; i--){
        ans[i] = res;
        if(uni.same(a[i], b[i])) continue;
        ll c1 = uni.count(a[i]), c2 = uni.count(b[i]);
        uni.unite(a[i], b[i]);
        res -= c1 * c2;
    }
    for(ll &v : ans){
        printf("%lld\n", v);
    }
}


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

int main(){
		int n;
		scanf("%d",&n);
		int a[100002],i,ans=0;a[0]=0;
		for(i=1;i<=n;i++){
				scanf("%d",&a[i]);
				ans+=abs(a[i]-a[i-1]);
		}
		ans+=abs(a[n]);
		a[n+1]=0;
		for(i=1;i<n+1;i++){
		//		printf("%d\t",i);
				if(a[i]-a[i-1]>0){
						if(a[i+1]-a[i]>=0){
								printf("%d\n",ans);
						}
						if(a[i+1]-a[i]<0){
								if(a[i+1]>=a[i-1])printf("%d\n",ans-2*abs(a[i]-a[i+1]));
								else printf("%d\n",ans-2*abs(a[i]-a[i-1]));
						}
				}else
				if(a[i]-a[i-1]<0){
						if(a[i+1]-a[i]<=0){
								printf("%d\n",ans);
						}
						if(a[i+1]-a[i]>0){
								if(a[i+1]<=a[i-1])printf("%d\n",ans-2*abs(a[i]-a[i+1]));
								else printf("%d\n",ans-2*abs(a[i]-a[i-1]));
						}
				}else
				if(a[i]-a[i-1]==0)printf("%d\n",ans);
		}
		//for(i=0;i<=n+2
		return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
struct Ans{
    int a,b,c;
};
int main()
{
    int n,k;
    cin>>n>>k;
    if(n<2*k-1) puts("-1");
    else{
        vector<Ans> ans;
        int c=k+2*n,b=k+n+n/2-(n%2==0);
        for(int i=k;i<k+n;i+=2)
        {
            ans.push_back(Ans{i,b,c});
            c++;b--;
        }
        b=k+2*n-1;
        for(int i=k+1;i<k+n;i+=2)
        {
            ans.push_back(Ans{i,b,c});
            c++;
            b--;
        }
        for(auto u:ans) {
            cout<<u.a<<" "<<u.b<<" "<<u.c<<'\n';
        }

    }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;
    cout << ceil((float)n/1000)*1000-n << endl;
    
    return 0;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] s = new String[H + 1];
		String[][] a = new String[H + 1][W + 1];
		int count = 1;
		
		for(int i = 1; i <= H; i++) {
			s[i] = sc.next();
		}
		
		for(int i = 1; i <= H; i++) {
			count = 1;
			for(int j = 1; j <= W; j++) {
				a[i][j] = s[i].substring(j - 1, j);
				if(j >= 2) {
					if((a[i][j].equals(a[i][j - 1])) && (a[i][j].equals("."))) {
						count++;
					}
				}
			}
			if((count == W) && (W >= 2)) {
				for(int k = 1; k <= W; k++) {
					a[i][k] = "n";
				}
			} else if((W == 1) && (a[i][1].equals("#"))) {
				a[i][1] = "#";
			} else if((W == 1) && (a[i][1].equals("."))) {
				a[i][1] = ".";
			}
		}
		
		for(int i = 1; i <= W; i++) {
			count = 0;
			for(int j = 1; j <= H; j++) {		
				if(((a[j][i].equals(".")) || (a[j][i].equals("n")))) {
					count++;
				}	
			}
			if(count == H) {
				for(int k = 1; k <= H; k++) {
					a[k][i] = "n";
				}
			}
		}
		
		for(int i = 1; i <= H; i++) {
			int count2 = 0;
			for(int j = 1; j <= W; j++) {
				if(!(a[i][j].equals("n"))) {
					System.out.print(a[i][j]);
				} else {
					count2++;
				}
				if((j == W) && (count2 != j)) {
					System.out.println();
				}
			}
		}
	}
}


Measured memory_bytes: 25024
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, m;
    
    scanf("%d%d", &n, &m);
    
    printf("%d", (n-1)*(m-1));
    
    return 0;
}



Measured memory_bytes: 1660
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>
#include<deque>

using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
long long MOD = 1000000007;
long double a[200000];
int b[200000];
long long int aa[200000];
int two[200000];
int five[200000];
int main() {

	int n;
	cin >> n;
	int i,j,k;
	long double ab;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		aa[i] = a[i] * 1000000000 + 0.5;

		//if (a[i] - (int)a[i] == 0) {
		//	b[i] = 1;//整数だった
		//	aa[i] = (long long int)a[i];
		//	cout << aa[i] << endl;
			

		//}

		//else {
		//	b[i] = 0;
		//	a[i] = a[i] - (int)a[i];
		//	//cout << a[i] << endl;
		//	aa[i] = a[i] * 1000000000 + 0.5;
		//	cout << aa[i] << endl;
			//while (1) {
			//	ab = a[i] * 10;
			//	if (ab - (int)ab != 0) {
			//		a[i] = a[i] * 10;
			//		a[i] = a[i] - (int)a[i];
			//		two[i]++;
			//		five[i]++;
			//	}
			//	else {
			//		if ((long long int)ab % 5 == 0) {
			//			two[i]++;
			//			break;
			//		}
			//		else if ((long long int)ab % 2 == 0) {
			//			five[i] ++;
			//			break;
			//		}
			//		else {
			//			two[i]++;
			//			five[i]++;
			//			break;
			//		}
			//	}
			//}

		//}
		while (aa[i] % 2 == 0) {
			two[i]++;
			if (two[i] > 18) {
				two[i] = 18;
				break;
			}
			aa[i] = aa[i] / 2;
		}
		while (aa[i] % 5 == 0) {
			five[i]++;
			if (five[i] > 18) {
				five[i] = 18;
				break;
			}
			aa[i] = aa[i] / 5;
		}
		//cout  << two[i] << ' ' << five[i] << endl;
	}
	long long int counter = 0;
	long long int totalcounter = 0;
	//for (i = 0; i < n; i++) {
	//	if (b[i] == 1)counter++;
	//}
	//totalcounter = (counter * (counter - 1))  / 2 ;
	//cout << totalcounter << endl;
	long long int counter2;
	for (i = 0; i <= 18; i++) {
		for (j = 0; j <= 18; j++) {
			counter = 0;
			counter2 = 0;
			for (k = 0; k < n; k++) {
				if ((two[k] == i) && (five[k] == j)) {
					counter++;
				}
			}
			for (k = 0; k < n; k++) {
				if ((two[k] + i>= 18) && (five[k] + j >= 18)) {
					counter2++;
				}
			}
			totalcounter = totalcounter + counter * counter2;
			//cout << i << ' ' << j << ' ' << counter << ' ' << counter2 << endl;
		}
	}
	for (i = 0; i < n; i++) {
		if ((two[i] * 2 >= 18) && (five[i] * 2 >= 18)) {
			totalcounter--;
		}
	}
	totalcounter = totalcounter / 2;
	cout << totalcounter << endl;
	return 0;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 9888
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int maxLength = 0;	
		int sum =0;
		for(int i=0;i<n;i++){
			int l = sc.nextInt();
			maxLength = Math.max(l, maxLength);
			sum +=l;
		}

		if(sum-maxLength >maxLength){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}


	}
}


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


int main() {
  int K,N;
  cin>>N>>K;
  int64_t Z=4167167167167167167;
  vector<int64_t> p(N+1);
  vector<int64_t> q(N+1);
  for(int i=0;i<N;i++){
    cin>>p[i]>>q[i];
  }
  p[N]=-2001167167;
  q[N]=-2001167167;
  vector<int64_t> x=p;
  vector<int64_t> y=q;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  vector<vector<int>> rui(N+1,vector<int>(N+1));
  for(int i=0;i<N;i++){
    int a=lower_bound(x.begin(),x.end(),p[i])-x.begin();
    int b=lower_bound(y.begin(),y.end(),q[i])-y.begin();
    rui[a][b]=1;
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<N;j++){
      rui[i][j+1]+=rui[i][j];
    }
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<N;j++){
      rui[j+1][i]+=rui[j][i];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<=N;j++){
      for(int k=0;k<N;k++){
        for(int l=k+1;l<=N;l++){
          if(K<=rui[j][l]+rui[i][k]-rui[j][k]-rui[i][l]){
            Z=min(Z,(x[j]-x[i+1])*(y[l]-y[k+1]));
          }
        }
      }
    }
  }
  cout<<Z<<endl;    
}

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

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

    vector<long long> A(N);
    vector<long long> B(N);
    vector<long long> C(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long count = 0;
    for (long long b : B) {
        long long a_count = lower_bound(A.begin(), A.end(), b) - A.begin();
        long long c_count = C.size() - (upper_bound(C.begin(), C.end(), b) - C.begin());
        count += a_count * c_count;
    }

    cout << count << endl;
    return 0;
}


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  cout << n * n << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+7;
int main()
{
    int n,k;
    cin >> n >> k;
    int arr[n];
    for(int i=0;i<n;i++){
    	cin >> arr[i];
	}
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
//	dp[1]=abs(arr[1]-arr[0]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k;j++){
			if(j<n)dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j])); 
		}
	}
	cout << dp[n-1] << "\n";
    return 0;
}

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

int main(){
  string s;cin >> s;
  int l_p = 0;
  int r_p = int(s.size()) -1;
  int ans = 0;
  if(s.size()==1){
    cout << 0 << endl;
    return 0;
  }
  while(true){
    if(s.at(l_p)==s.at(r_p)){
      l_p++;
      r_p--;
    }else if(s.at(l_p)=='x'){
      ans++;
      l_p++;
    }else if(s.at(r_p)=='x'){
      ans++;
      r_p--;
    }else{
      cout << -1 << endl;
      return 0;
    }
    if(r_p<=l_p){
      cout << ans << endl;
      return 0;
    }
  }
}

        

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

using namespace std;
 
int main(){
  int x[10],tmp,i,j;

  for(i=0; i<10; ++i)
    cin >> x[i];

  sort(x,x+10,greater<int>());

  /*
  for(i=0; i<10; ++i){
    for(j=i+1; j<10; ++j){
      if(x[i] < x[j]){
	tmp = x[i];
	x[i] = x[j];
	x[j] = tmp;
      }
    }
  
  }
  */

  for(i=0; i<3; ++i)
    cout << x[i] << "\n";

    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
bool isOK(const string& s,int i,int m,int f){
    string memo=s.substr(m-i+f,i);
    reverse(memo.begin(),memo.end());
    return memo==s.substr(m+1,i);
}
//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    string a;
    cin>>a;
    int ans=a.size()*(a.size()-1)/2+1;
    map<char,int> mp;
    rep(i,a.size())mp[a[i]]++;
    for(auto it:mp)ans-=it.second*(it.second-1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 720
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	int k,mm=0;
	vector<int>n(3);
	rep(i, 3)cin >> n[i];
	cin >> k;
	sort(all(n));
	mm += n[0] + n[1];
	rep(i, k) {
		n[2] *= 2;
	}

	mm += n[2];
	cout << mm << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
	int a,b,c;
	int i,n;
	n = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if((c%i) == 0)
			n++;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;
}

bool f[100010];
int cnt[100010];

int main(int argc, char const *argv[]) {
  int Q;
  cin >> Q;

  for(int i=2; i<=100000; i++){
    f[i]=isprime(i);
  }

  for(int i=1; i<=100000; i++){
    if(f[i] && f[(i+1)/2] ) cnt[i]=1;
    cnt[i]+=cnt[i-1];
  }

  while(Q--){
    int l,r;
    cin >> l >> r;
    int ans = cnt [r] - cnt[l-1];
    cout << ans << endl;
  }

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,K;
ll mo=1000000007;
ll combi(ll N_, ll C_) {
	const int NUM_=1000001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	
	ll ret=0;
	ll C=1,L=0,R=0;
	for(int i=N;i<=N+M+K;i++) {
		ll a=combi(i-1,N-1)*modpow(3,N+M+K-i) % mo;
		if(i>N) C=C*2%mo;
		if(i==N+M+1) L=1;
		if(i>N+M+1) L=(L*2+combi(i-N-1,i-N-M-1))%mo;
		if(i==N+K+1) R=1;
		if(i>N+K+1) R=(R*2+combi(i-N-1,i-N-K-1))%mo;
		ret += a*(C-L-R+mo+mo) % mo;
	}
	
	
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


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

int a[111],b[111],c[111],n,s;

int main()
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for (i=1;i<=n;i++)
	{
		cin>>b[i];
		s+=b[i];
	}
	for (i=1;i<n;i++)
	{
		cin>>c[i];
	}
	for (i=1;i<n;i++)
	{
		if (a[i+1]==a[i]+1)
		{
			s+=c[a[i]];
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0),cout<<fixed<<setprecision(15);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;
const ll mx =1e18;
int main()
{
    _SAD()
    int n;
    cin>>n;
    long double l=0;
    ll ans=1;
    vii a(n);
    rep(i,n)
    {
        cin>>a[i];
        l+=log10(a[i]);
        if(a[i]==0)
        {
            cout<<0<<nl;
            return 0;
        }
       if(ans>0)
       {
           ans*=a[i];
           if(ans>mx)ans=-1;
       }
    }
    if(l>18.1)cout<<-1<<nl;
    else cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll mod=1000000007;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N,K;
	cin>>N>>K;
    vector<ll> V(N);
    for (int i=0;i<N;i++) cin>>V[i];

    long long res=0;
    for(int p=0;p<=min(K,N);p++){
        for(int q=0;p+q<=min(K,N);q++){
            vector<ll> v;
            ll cur=0;
            for(int i=0;i<p;i++) v.push_back(V[i]),cur+=V[i];
            for(int i=0;i<q;i++) v.push_back(V[N-1-i]),cur+=V[N-1-i];
               
            sort(v.begin(),v.end());
            for(int i=0;i<min(K-p-q,(int)v.size());i++){
                if(v[i]<0)cur-=v[i];
            }
            res=max(res,cur);
        }
    }
    cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] c = input.ToCharArray();
            int count = 0;

            foreach (var item in c)
            {
                if (item == '1')
                    count++;
            }

            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int a[M];
vector<int>dig;
main()
{
	int n;
	cin>>n;
	int tmp=n+1;
	int dig=0;
	while(tmp>=10)tmp/=10,dig++;
	cout<<tmp-1+dig*9;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef	tuple<int,int,int>T;
typedef vector<T>VT;
int main(void){
	int n;
	int box[101][101];
	int i,j;
	int per[101];
	int ran[101];
	int x,y;
	int sum;
	VT v;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cin>>box[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(box[i][j]!=-1){
				v.push_back(make_tuple(box[i][j],i,j));
			}
		}
	}
	sort(v.begin(),v.end());
	for(i=1;i<=n;i++){
		per[i]=i;
		ran[i]=1;
	}
	sum=0;
	for(i=0;i<v.size();i++){
		x=get<1>(v[i]);
		y=get<2>(v[i]);
		while(x!=per[x])	x=per[x];
		while(y!=per[y])	y=per[y];
		if(x!=y){
			sum+=get<0>(v[i]);
			if(ran[x]>ran[y])		per[y]=x;
			else if(ran[x]<ran[y])	per[x]=y;
			else{
				per[x]=y;
				ran[x]++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}
				
	



Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}


int main(){
	int n;
	cin >> n;
	int a[n];
	unordered_map<int, int> freq;
	FOR0(i, n) {
		cin >> a[i];
		freq[a[i]]++;
	}
	sort(a, a + n);
	int ans = 0;
	set<int> vis;
	FOR0(j, n){
		bool chk = true;
		if (freq[a[j]]!=1) chk = false;
		for(int i = 1; i <= sqrt(a[j]); i++){
			if (chk==false) break;
			if (a[j]%i == 0){
				if (vis.find(i) != vis.end() || vis.find(a[j]/i) != vis.end()){
					// if (i == 2) cout << 
					chk = false;
					break;
				}
			}
		}
		if (chk) ans++;
		vis.insert(a[j]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 21560
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007
long long int result[1001][5001] = {};

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > v;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		int c = 0;
		for(int j = 0; j < b; j++){
			int tmp;
			cin >> tmp;
			tmp--;
			c |= (1 << tmp);
		}
		v.push_back(make_pair(a, c));
	}

	for(int i = 0; i < m; i++){
		for(int j = 0; j < (1 << n); j++){
			result[i][j] = mod;
		}
	}

	result[0][0] = 0;
	result[0][v[0].second] = v[0].first;
	for(int i = 0; i < m; i++){
		for(int j = 0; j < (1 << n); j++){
			if(i > 0) result[i][j] = min(result[i - 1][j], result[i][j]);
			if(result[i][j] == mod) continue;
			result[i + 1][(j | v[i + 1].second)] = min(result[i + 1][(j | v[i + 1].second)], result[i][j] + v[i + 1].first);
		}
	}
	if(result[m - 1][(1 << n) - 1] == mod) cout << -1 << endl;
	else cout << result[m - 1][(1 << n) - 1] << endl;
}

Measured memory_bytes: 39168
let s = stdin.ReadLine() |> int64

// (長方形の面積A - 長方形の内部の長方形Bの面積)=S なる三角系を作成することができる
let sqrtInt64 x = 
    match x with
    | 0L -> 0L
    | 1L -> 1L 
    | _ -> sqrt (float x) |> ceil |> int64

let squareALength = sqrtInt64 s

let rectangularBLength =
    (squareALength * squareALength - s) 
    |> function
    | 0L -> 0L, 0L
    | 1L -> 1L, 1L
    | x -> 
        seq{sqrtInt64 x .. -1L .. 1L} |> Seq.find (fun y -> x % y = 0L)
        |> fun y -> y, x/y

[ 0L; 0L; fst rectangularBLength; squareALength; squareALength; snd rectangularBLength ]
|> Seq.iter stdout.WriteLine

Measured memory_bytes: 13396
input = gets.chomp.split
n = input[0].to_i
m = input[1].to_i

a = gets.chomp.split(" ").map(&:to_i)
bc = []

for i in 1..m do
    bc.push(gets.chomp.split(" ").map(&:to_i))
end

a.sort!
bc.sort! {| x,y | y[1] <=> x[1]}

i = 0
j = 0
while i < m
    b = bc[i][0]
    c = bc[i][1]
    for k in 1..b 
        if a[j] < c
            a[j] = c
            j += 1
            if j >= n 
                i = m
                break
            end
        else
            i = m
            break
        end
    end
    i += 1
end

sum = 0
for i in 1..n do
    sum += a[i-1]
end
p sum


Measured memory_bytes: 20672
#include <cstdio>
const int N=200005,mo=1000000007;
int a[N],b[N],c[N],w[N],cnt[N];

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

int main(){
	int n,X,Y;
	scanf("%d%d%d",&n,&X,&Y);
	for (int i=0;i<=n;i++) a[i]=mo;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&c[i],&w[i]);
		if (w[i]<a[c[i]]) a[c[i]]=w[i],b[c[i]]=i;
	}
	int c1=0,c2=0;
	for (int i=1;i<=n;i++)
		if (a[i]<a[c1]) c2=c1,c1=i;
			else if (a[i]<a[c2]) c2=i;
	for (int i=1;i<=n;i++)
		if ((c[i]!=c1 && w[i]+a[c1]<=Y)||(c[i]!=c2 && w[i]+a[c2]<=Y)||
			((w[i]+a[c[i]]<=X) && a[c[i]]+a[c1]<=Y)) cnt[c[i]]++;
	int ans1=1,ans2=1;
	for (int i=1,j=0;i<=n;i++)
		for (int k=1;k<=cnt[i];k++){
			ans1=1ll*ans1*(++j)%mo;
			ans2=1ll*ans2*k%mo;
		}
	ans1=1ll*ans1*ksm(ans2,mo-2)%mo;
	printf("%d\n",ans1);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,i,sum=0;
  cin>>n;
  vector<long long> vec(n+1),a(n+1);
  for(i=0;i<n;i++){
    scanf("%lld",&vec[i]);
    a[vec[i]]++;
  }for(i=0;i<=n;i++){
    sum+=(a[i]*(a[i]-1)/2);
  }for(i=0;i<n;i++){
    cout<<(sum-a[vec[i]]+1)<<"\n";
  }
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

int A, B;

int main()
{
	in >> A >> B;
	out << (A + B) % 24 << std::endl;
	return 0;
}

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

int main(){
    ull a; string b; cin >> a >> b;
    ull ans = 0;
    ull tmp = 0;
    ull back = 0;
    rep(i, 4){
        if(b[i] == '.') continue;
        tmp = a*(b[i] - '0');
        if(i == 2) {
            string s = to_string(tmp);
            int last = s.back() - '0';
            tmp = (tmp - last)/10;
            back += 10*last;
        }
        if(i == 3) {
            string s = to_string(tmp);
            if(s.size() >= 3){
                string last = "";
                last += s[s.size() - 2];
                last += s[s.size() - 1];
                int tmp2 = stoi(last);
                tmp = (tmp - tmp2)/100;
                back += tmp2;
            } else {
                back += tmp;
                tmp = 0;
            }
        }
        ans += ull(tmp);
    }
    string sback = to_string(back);
    if(sback.size() == 3) ans += sback[0] - '0';
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, D;
  vector<lpair> v;

  cin >> N >> D;
  v.resize(N);
  llong ans = 0;
  for (auto &in: v) {
    cin >> in.first >> in.second;
    ans += in.first * in.first + in.second * in.second <= D * D;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define N 100005
using namespace std;

int n,l,a[N];

void ok(int yer) {

  printf("Possible\n");
  for(int i=1;i<yer;i++) {
    printf("%d\n",i);
  }
  for(int i=n-1;i>=yer+1;i--) {
    printf("%d\n",i);
  }
  printf("%d",yer);
  exit(0);

}

int main() {

  scanf("%d %d",&n,&l);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
  }
  for(int i=1;i<n;i++) {
    if(a[i]+a[i+1]>=l) {
      ok(i);
    }
  }
  printf("Impossible");

}


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

int main()
{
  int d;

  while (cin >> d){
    int sum = 0, j = 1;
    for (int i = 1; i * d <= 600 - d; i++){
      sum += i * i * d * d * d;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<ll> f(60001,0);
    rep2(x,1,101)rep2(y,1,101)rep2(z,1,101){
        f[x*x+y*y+z*z+x*y+y*z+z*x]++;
    }
    int n; cin>>n;
    rep2(i,1,n+1){
        cout<<f[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3660