akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret);
  if(n%2)((ret *= a));
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}

vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll 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;
}


////////////////////////////////////////////////////////////////////

int h,w,a[100][100],b[100][100],c[100][100];
bool dp[85][85][20000];
signed main(){
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>a[i][j];
  rep(i,h)rep(j,w)cin>>b[i][j];
  rep(i,h)rep(j,w)c[i][j] = abs(a[i][j] - b[i][j]);
  dp[0][0][abs(c[0][0])] = true; 
  rep(i,h){
    rep(j,w){
      rep(d,15000){
        if(!dp[i][j][d])continue;
        dp[i][j+1][d+c[i][j+1]] = j+1 < w;
        dp[i][j+1][abs(d-c[i][j+1])] = j+1 < w;
        dp[i+1][j][d+c[i+1][j]] = i+1 < h;
        dp[i+1][j][abs(d-c[i+1][j])] = i+1 < h;
      }
    }
  }
  rep(i,15000){
    if(dp[h-1][w-1][i]){
      cout << i << endl;return 0;
    }
  }
}


Measured memory_bytes: 136064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n;
char s[maxn];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=n%2==0;
	FOR(i,1,n){
		if(i%2==0 && s[i]!='i') flag=false;
		if(i%2==1 && s[i]!='h') flag=false;
	}
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    char a,b;
    cin>>a>>b;
    char ans='H';
    if(a=='H'&&b=='H')ans='H';
    if(a=='H'&&b=='D')ans='D';
    if(a=='D'&&b=='H')ans='D';
    if(a=='D'&&b=='D')ans='H';
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
    ☁ ☁         ☀     ☁☁
            ☁ ✈    ☁☁

🌳🌲_________🌳___🌳____🌲___🌳
     /    |    \
    /       🚔\
    /     |      \ С ДОРОГИ МЕНТЫ ЕДУТ ПАЦАНЫ
   /        🚘  \
   /             \ 
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define ppb pop_back
#define re return
#define forn(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, n) for (int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n); i >= 1; i--)
#define forde(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forr(i, l, r) for (int i = (int)(l); i <= (int)(r); i++)
#define fz(a) memset((a), 0, sizeof((a)))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)((x).size())
#define zhfs main

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void gn(int &x) { scanf("%d", &x); }
void gn(long long &x) { scanf("%lld", &x); }
void pi(int x) { printf("%d ", x); }
void pi(long long x) { printf("%lld ", x); }

int zhfs() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; i++) {
    int a = i, b = n - i;
    if (a > b) swap(a, b);
    if (k >= m * a) {
      int more = k - m * a;
      int del = b - a;
      if (more == 0) {
        puts("Yes");
        return 0;
      }
      if (del != 0 && more % del == 0 && more / del <= m) {
        puts("Yes");
        return 0;
      }
    }
  }
  swap(n, m);
  for (int i = 0; i <= n; i++) {
    int a = i, b = n - i;
    if (a > b) swap(a, b);
    if (k >= m * a) {
      int more = k - m * a;
      int del = b - a;
      if (more == 0) {
        puts("Yes");
        return 0;
      }
      if (del != 0 && more % del == 0 && more / del <= m) {
        puts("Yes");
        return 0;
      }
    }
  }

  puts("No");
}




Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
int dp[M][4];
int a[M];
 main()

{
    fast
    dp[0][0]=1;
    string s;
    cin>>s;
    int n=s.size();
    f(i,0,n-1)
    {
        if(s[i]=='?')a[i+1]=3;
        else a[i+1]=s[i]-'A';
    }
    f(i,1,n)
    {
        if(a[i]==3)
        {
            f(j,0,3)
            {
                dp[i][j]=ad(dp[i][j],gun(3,dp[i-1][j]));
            }
        }
        else
        {
             f(j,0,3)
             {
                 dp[i][j]=ad(dp[i][j],dp[i-1][j]);
             }
        }
        if(a[i]==0 || a[i]==3)dp[i][1]=ad(dp[i][1],dp[i-1][0]);
        if(a[i]==1 || a[i]==3)dp[i][2]=ad(dp[i][2],dp[i-1][1]);
        if(a[i]==2 || a[i]==3)dp[i][3]=ad(dp[i][3],dp[i-1][2]);

    }
    cout<<dp[n][3]<<endl;
    return 0;

}




































Measured memory_bytes: 7640
n = int(input())
ans = 0
count_BA = 0
count_A = 0
count_B = 0
for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        count_BA += 1
    elif s[0] == "B":
        count_B += 1
    elif s[-1] == "A":
        count_A += 1

if count_BA > 0:
    ans += count_BA - 1
if count_BA > 0 and count_B > 0:
    ans += 1
    count_B -= 1
if count_BA > 0 and count_A > 0:
    ans += 1
    count_A -= 1
while count_A > 0 and count_B > 0:
    ans += 1
    count_A -= 1
    count_B -= 1

print(ans)


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

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

 string S;
 vector<long long> ch_num(5);
 for(int i = 0; i < N; i++) {
   cin >> S;
   if(S.at(0) == 'M') ch_num.at(0)++;
   else if(S.at(0) == 'A') ch_num.at(1)++;
   else if(S.at(0) == 'R') ch_num.at(2)++;
   else if(S.at(0) == 'C') ch_num.at(3)++;
   else if(S.at(0) == 'H') ch_num.at(4)++;
 }

 long long ans = 0;
 for(int i = 0; i < 3; i++) {
   for(int j = i + 1;j < 4; j++) {
     for(int k = j + 1;k < 5;k++) {
       ans += ch_num.at(i) * ch_num.at(j) * ch_num.at(k);
     }
   }
 }

cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c1 = sc.nextInt();
        int c2 = sc.nextInt();
        int c3 = sc.nextInt();
        int c4 = sc.nextInt();
        int c5 = sc.nextInt();
        int c6 = sc.nextInt();
        int c7 = sc.nextInt();
        int c8 = sc.nextInt();
        int c9 = sc.nextInt();
        int sum1 = c1 + c5 + c9;
        int sum2 = c1 + c6 + c8;
        int sum3 = c2 + c4 + c9;
        int sum4 = c2 + c6 + c7;
        int sum5 = c3 + c4 + c8;
        int sum6 = c3 + c5 + c7;
        if (sum1 == sum2 && sum2 == sum3 && sum3 == sum4 && sum4 == sum5 && sum5 == sum6) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 22740
from collections import Counter

n = int(input())

e = []
o = []
for i, v in enumerate(input().split(' ')):
    if i % 2 == 0:
        e.append(int(v))
    else:
        o.append(int(v))

if len(set(e + o)) == 1:
    print(int(len(e + o) / 2))
    exit()

if Counter(o).most_common()[0][0] == Counter(e).most_common()[0][0]:
    ans = min(len(o) - Counter(o).most_common()[1][1] + len(e) - Counter(e).most_common()[0][1], len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[1][1])
    print(ans)
else:
    print(len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[0][1])



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a*b%2==0 ? "Even" : "Odd") << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
    ll n,k;
    cin>>n>>k;
    init(n);
    rep(i,1,min(n-k+2,k+1)) cout<<comb(n-k+1,i)*comb(k-1,i-1)%MOD<<endl;
    if(n-k+2<k+1) rep(i,0,2*k-n-1) cout<<0<<endl;
}


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

#define int long long

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

string S;

signed main() {
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] != S[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a>=b){
		c(10)
	}
	else{
		c(0)
	}
}				

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;

typedef pair<int,int> P;
int W,H;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char ma[21][21];
int sx,sy;

int bfs(){
  int count=1;
  int d[21][21];
  queue<P> que;
   for(int i=0;i<W;i++)
   for(int j=0;j<H;j++) d[i][j]=1000000;
  que.push(P(sx,sy));
  d[sx][sy]=0;

  while(!que.empty()){
    P p=que.front(); que.pop();
    for(int i=0;i<4;i++){
	int nx=p.first+dx[i],ny=p.second+dy[i];
	if(0<=nx && nx<W && 0<=ny && ny<H && ma[nx][ny]!='#' &&
	   d[nx][ny] == 1000000){
	  que.push(P(nx,ny));
	  d[nx][ny]=0;
	  // cout<<nx<<"  "<<ny<<endl;
	  count++;
      }
    }
  }
    return count;
  }


int main(){
  while(1){
  cin>>H>>W;
  if(H+W==0) break;
  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      cin>>ma[i][j];
      if(ma[i][j]=='@') {
	sx=i;
	sy=j;
      }
    }
  }
  
  int ans =bfs();
  cout<<ans<<endl;
  }
  return 0;
}

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

int main(void)
{
    char a,b;
    cin >> a >> b;

    if(a==b)
    {
        cout << "H" << endl;
    }
    else
    {
        cout << "D" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

struct Wside{
	int vertex;
	int weight;
	Wside(int a, int b){
		vertex=a; weight=b;
	}
};

vector<Wside>* info;
vector<int> scanned;
int* result, *candidates;
int n;

bool isScanned(int v){
	for(int i=0,sz=scanned.size(); i<sz; ++i){
		if(v==scanned[i]) return 1;
	}
	return 0;
}

int scan(){
	int nextvtx;
	for(int j=0, scn=scanned[scanned.size()-1], sz=info[scn].size(); j<sz; ++j){
		int vtx = info[scn][j].vertex;
		if(isScanned(vtx)) continue;
		int wgh = info[scn][j].weight;

		result[vtx] = result[vtx] > result[scn] + wgh ? (result[scn] + wgh) : result[vtx];
		candidates[vtx] = result[vtx];
	}

	int minimum=0xfffffff;
	for(int i=0; i<n; ++i){
		if(candidates[i]==-1) continue;
		nextvtx = minimum<candidates[i]? nextvtx : i;
		minimum = result[nextvtx];
	}
	candidates[nextvtx]=-1;
	scanned.push_back(nextvtx);
	return 0;
}

int main()
{
	scanf("%d",&n);
	scanned.reserve(n);
	info = new vector<Wside> [n];
	result = new int [n];
	candidates = new int [n];
	for(int i=0; i<n; ++i){
		result[i] = 0xfffffff;
		candidates[i] = -1;
	}

	int org,k,v,c;
	for(int i=0; i<n; ++i){
		scanf("%d %d",&org,&k);
		info[org].reserve(k);
		for(int j=0; j<k; ++j){
			scanf("%d %d",&v,&c);
			info[org].push_back(Wside(v,c));
		}
	}

	scanned.push_back(0);
	result[0] = 0;
	while(scanned.size()!=n){
		scan();
	}

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

	delete[] info;
	delete[] result;
	delete[] candidates;

	return 0;
}



Measured memory_bytes: 6960
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ll INF=1e9;
int main(){
      int n;
      while(cin>>n&&n){
            int cnt=0,a[100000],h=n;
            REP(i,n)cin>>a[i];
            int k=1;bool f=true;
            while(cnt<=10000){
                  bool f=true;
                  REP(i,h){
                        if(a[i]!=i+1)f=false;
                  }
                  if(f)break;
                  int now=0;
                  REP(i,h)a[i]--;
                  REP(i,h){
                        if(a[i]>0){
                              a[now]=a[i];
                              now++;
                        }
                  }
                  a[now]=h;
                  h=now+1;
                  cnt++;
            }
            if(cnt>10000)cout<<-1<<endl;
            else cout<<cnt<<endl;
      }
}

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

int main(){
  int n;
  cin >> n;
  string s;
  bool a = true;
  
  rep(i,n){
    cin >> s;
    if(s=="Y"){
      cout << "Four" << endl;
      a=false;
      break;
    }
  }
  if (a){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-21 15:12:08
 */
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

const int N = 1e7 + 105;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");
int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n - 1; ++i){
        ans += (n - 1) / i;
    }
    cout << ans << endl;
    // system("pause");
}


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

const int MAX_N = 1e+5 + 1;
const int INF = 1 << 30;

int h[MAX_N], dp[MAX_N];

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < N; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = max(i - K, 0); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

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

typedef long long ll;
ll N, K;

int main(){
    scanf("%lld%lld", &N, &K);
    ll ans;
    if(K%2){
        ans = pow(N/K, 3);
    }else{
        ll k = K/2;
        ans = pow(N/K, 3);
        ans += pow((N+k)/K, 3);
    }
    printf("%lld\n", ans);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

struct dat{
	ll d,from,to;
	bool operator<(const dat& another) const {
		return d < another.d;
	}
};

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

	ll N; cin >> N;
	vector<P> G[500]; // to, dist
	vector<dat> B;
	ll A[305][305];

	ll ans = 0;

	for (int i = 0;i < N;i++){
		for (int j = 0;j < N;j++){
			cin >> A[i][j];
			if(i < j){
				B.push_back({A[i][j],i,j});
			}
		}
	}

	sort(B.begin(),B.end());

	for (int i = 0;i < B.size();i++){
		dat t = B[i];
		ll dist[500]; fill(dist,dist+N,LLONG_MAX);
		priority_queue<P,vector<P>,greater<P>> que;
		dist[t.from] = 0;
		que.push(P(0,t.from));
		while(que.size()){
			P p = que.top(); que.pop();
			ll now = p.second; ll nowdist = p.first;
			if(dist[now] < nowdist) continue;
			for (int i = 0;i < G[now].size();i++){
				ll to = G[now][i].first, len = G[now][i].second;
				if(dist[to] > nowdist+len){
					dist[to] = nowdist+len;
					que.push(P(dist[to],to));
				}
			}
		}
		if(dist[t.to] < t.d){
			cout << -1 << endl; return 0;
		}else if(dist[t.to] > t.d){
			G[t.from].push_back(P(t.to,t.d));
			G[t.to].push_back(P(t.from,t.d));
			ans += t.d;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e9;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    ll n,m; cin>>n>>m;
    ll h[n+2]; for (ll i=1; i<=n; i++) cin >> h[i];
    set <ll> s;
    for (int i=0; i<m; i++) {
        ll a, b; cin >> a >> b;
        if (h[a]>h[b]) s.insert(b);
        else if (h[a]<h[b]) s.insert(a);
        else {
            s.insert(a);s.insert(b);
        }
    }
    nout(n-s.size());
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

int main(void)
{
    irep(i, 5) {
        int t;
        cin >> t;
        if(t==0) { cout << i+1 << endl; }
    }
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3588
<?php
$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));
$b = explode(' ', trim(fgets(STDIN)));
$c = explode(' ', trim(fgets(STDIN)));

$result = 0;
for ($i = 0; $i < $n; $i++) {
    $result += $b[$a[$i] - 1];
    if ($i == $n - 1) break;
    if ($a[$i] == $a[$i + 1] - 1) {
        $result += $c[$a[$i] - 1];
    }
}
echo $result;

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

using namespace std;
int main(){
    string n;
    cin >> n;
    bool test=true;
    for(int i=0; i<3; i++){
       if(n[i]=='7')
            test = false;
   }
    if(test) cout << "No" << endl;
            else cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.14159265359;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll n,m,k;
    cin>>n>>m>>k;
    vll a(n);
    vll b(m);
    f(i,0,n) cin>>a[i];
    f(i,0,m) cin>>b[i];

    vll ak(n);
    ak[0]=a[0];

    for(ll i=1;i<n;i++){
        ak[i]=ak[i-1]+a[i];
    }
    vll bk(m);
    bk[0]=b[0];
    for(ll i=1;i<m;i++){
        bk[i]=bk[i-1]+b[i];
    }
    ll cnt=0;
    for(ll i=0;i<=n;i++){
        ll temp;
        if(i!=0) temp=ak[i-1];
        else temp=0;
        if(temp>k) break;
        k-=temp;
        auto it =upper_bound(all(bk),k);
        k+=temp;
        if(it==bk.begin()){
            cnt=max(cnt,i);
            continue;
        }
        it--;

        ll diff=it-bk.begin();

        if(cnt<i+diff+1){
            cnt=i+diff+1;
            //cout<<"hello"<<i<<" "<<diff+1<<endl;
        }

        //cnt=max(cnt,i+diff+1);
    }

    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 9592
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int ans = 1;
  while (ans * ans <= n)
  {
    ans++;
  }
  cout << (ans - 1) * (ans - 1) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define soa(arr,n) sort(arr,arr+n)
#define sov(arr) sort(arr.begin(),arr.end())
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    while(t--) {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(b*d,max(a*c,max(a*d,b*c)))<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
/**************
*	Shell Sort
*************/

#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>	//??£?¨?
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){
//	*cnt =0;
//	int m = A->size();
//	vector<int> G(1,m);
	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
	vector<int> G;
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6724
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[13];
        int[] c = new int[13];
        int[] h = new int[13];
        int[] d = new int[13];
        for(int i=0;i<n;i++){
            String str = sc.next();
            int a = sc.nextInt();
            if(str.equals("S")) s[a-1] = 1;
            if(str.equals("C")) c[a-1] = 1;
            if(str.equals("H")) h[a-1] = 1;
            if(str.equals("D")) d[a-1] = 1;  
        }
        for(int i=0;i<13;i++){
            if(s[i]!=1) System.out.println("S "+(i+1));
        }
        for(int i=0;i<13;i++){
            if(h[i]!=1) System.out.println("H "+(i+1));
        }
        for(int i=0;i<13;i++){
            if(c[i]!=1) System.out.println("C "+(i+1));
        }
        for(int i=0;i<13;i++){
            if(d[i]!=1) System.out.println("D "+(i+1));
        }
        sc.close();
    }
}


Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  string x;
  cin >> x;
  int e=0,n=0,s=0,w=0;;
  for(int i=0;i<x.size();i++){
    if(x[i]=='E'){
      e++;
    }
    if(x[i]=='N'){
      n++;
    }
    if(x[i]=='S'){
      s++;
    }
    if(x[i]=='W'){
      w++;
    }
  }
  if(e>0&&w==0){
    cout << "No" << endl;
  }
  else if(w>0&&e==0){
    cout << "No" << endl;
  }
  else if(n>0&&s==0){
    cout << "No" << endl;
  }
  else if(s>0&&n==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        if(h == 1 || w == 1)System.out.println(1);
        else System.out.println((h*w+1)/2L);
        sc.close();

    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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 long long INF = 1LL << 60;
int main()
{
	int N;cin >> N;
	int k = 0;
	for (int i = 0;i < N;i++) {
		int a;
		cin >> a;
		if (a % 2 == 1) {
			k++;
		}
	}
	if (k % 2 == 1)cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int W = scanner.nextInt();
  int H = scanner.nextInt();
  int x = scanner.nextInt();
  int y = scanner.nextInt();
  int r = scanner.nextInt();
  boolean i = W >= x + r && H >= y + r;
  boolean j = x >= 0 && y >= 0;
  if(i && j){
      System.out.println("Yes");
  } else {
      System.out.println("No");
  }
  }
}

Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int a,b; cin >> a >> b;
  COUT(a*b);

  return 0;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string input;
    cin >> input;
    if (input[0] == input[1] || input[1] == input[2] || input[2] == input[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

// const auto &pf = prime_factorize(N);
vector<pair<ll, ll> > prime_factorize(ll n){
    vector<pair<ll, ll> > res;
    for(ll i = 2; i * i <= n; i++){
        if(n % i != 0) continue;
        ll ex = 0;
        while(n % i == 0){
            ex++;
            n /= i;
        }
        res.push_back({i, ex});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}

int main() {
    ll n; cin >> n;
    V<P<ll, ll> > v;
    v = prime_factorize(n);

    ll ans = 0;
    for(int i = 0; i < (int)v.size(); i++){
        for(ll j = 1; j <= v[i].second; j++){
            if(n % (ll)pow(v[i].first, j) == 0){
                n /= (ll)pow(v[i].first, j);
                ans++;
            }else{
                break;
            }
        }
        if(n == 1) break;
    }
    cout << ans << endl;
}


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

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

int main(){
	int d, x, ans;
	while(cin >>d){
		ans = 0;
		for(int i = 1; (i * d) <= (600 - d); i++){
			x = i * d;
			ans += d * f(x);
		}
		
		cout <<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(void) {
  int n, l;
  cin >> n >> l;
  int total = n*l+n*(n-1)/2;

  if (l > 0) {
    cout << total-l << endl;
  } else if (l+n-1 < 0) {
    cout << total-(l+n-1) << endl;
  } else {
    cout << total << endl;
  }

  return 0;
}


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

int main() {

	string s;
	cin >> s;

	if(s == "SUN") printf("7\n");
	if(s == "MON") printf("6\n");
	if(s == "TUE") printf("5\n");
	if(s == "WED") printf("4\n");
	if(s == "THU") printf("3\n");
	if(s == "FRI") printf("2\n");
	if(s == "SAT") printf("1\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

ll rec(ll x){
	if(x == 1) return 1;
	return 1 + 2 * rec(x / 2);
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	ll x;
	cin >> x;

	ll res = rec(x);

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;


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

  int n;
  cin >> n;
  map<int,int>vis , Cnt;
  vector<int>A(n);
  for(int i=0;i<n;i++){
      cin >> A[i];
      Cnt[A[i]]++;
  } 
  sort(A.begin() , A.end());
  int Mx = A[n-1];
  int ans = 0;
  for(int i=0;i<n;i++){
      if(vis[A[i]]) continue;
      ans++;
      for(int j = A[i];j <= Mx;j+=A[i]){
          vis[j] = 1;
      }
      if(Cnt[A[i]] > 1) ans--;
  }
  cout << ans << '\n';

}

Measured memory_bytes: 76004
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      double N = sc.nextInt();
      if(N%2==0){
        System.out.println(0.5);
      }else{
        System.out.println(((N+1)/2)/N);
      }
    }
}

Measured memory_bytes: 36068
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()

	s := ""
	if a < b {
		for i := 0; i < b; i++ {
			s += fmt.Sprintf("%d", a)
		}
	} else {
		for i := 0; i < a; i++ {
			s += fmt.Sprintf("%d", b)
		}

	}
	fmt.Fprintln(stdout, s)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


vector<ll> reduce(vector<ll> l) {
  vector<ll> basis;
  ll use[70] = {}; // use[i] keeps the mask of the vector whose f value is i
  for (ll mask : l) {
    for (int i = 0; i < 60; i++) {
      if ((mask & 1ll << i) == 0) continue; // continue if i != f(mask)
      if (!use[i]) { // If there is no basis vector with the i'th bit set, then insert this vector into the basis
        use[i] = mask;
        basis.push_back(mask);
        break;
      }
      mask ^= use[i]; // Otherwise subtract the basis vector from this vector
    }
  }
  return basis;
}

void solve() {
  int n;
  cin >> n;
  ll a[300];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  vector<ll> curset;
  int cur = 0;
  int sz = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] - '0' != cur) {
      curset = reduce(curset);
      if (cur == 1) {
        if (curset.size() != sz) {
          cout << "1\n";
          return;
        }
      }
      sz = curset.size();
      cur = !cur;
    }
    curset.push_back(a[i]);
  }

  curset = reduce(curset);
  if (cur == 1) {
    if (curset.size() != sz) {
      cout << "1\n";
      return;
    }
  }
  sz = curset.size();
  cout << "0\n";
}

int main() {
#ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  int t;
  cin >> t;
  while (t--) {
    solve();
  }

	return 0;
}

Measured memory_bytes: 3648
s = input().split()
n = int(s[0])
x = int(s[1])

donuts = []


for i in range(n):
    p = input()
    q = int(p)
    donuts.append(q)

donuts.sort()

min_donuts = donuts[0]
answer = len(donuts)

price = 0
for i in range(len(donuts)):
    price += donuts[i]

y = x - price
count = int(y / min_donuts)
answer += count
print(answer)



Measured memory_bytes: 8988
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;

#define INF 1000000
#define MAX_V 10000
#define MAX_N 10000
#define MAX_E 100000000
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V, E;
struct union_find_tree {
	int par[MAX_N]; // 親
	int depth[MAX_N]; // 木の深さ

	// n要素で初期化
	void init(int n) {
		rep(i, 0, n) {
			par[i] = i;
			depth[i] = 0;
		}
	}

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

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(depth[x] < depth[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
struct edge {
	int u, v, cost;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
edge es[MAX_E];
union_find_tree uft;

int prim() {
	rep(i, 0, V) {
		mincost[i] = INF;
		used[i] = false;
	}

	mincost[0] = 0;
	int res = 0;
	while(true) {
		int v = -1;
		rep(u, 0, V) {
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		rep(u, 0, V) mincost[u] = min(mincost[u], cost[v][u]);
	}
	return res;
}

int kruskall() {
	sort(es, es + E, comp);
	uft.init(V);
	int res = 0;
	rep(i, 0, E) {
		edge e = es[i];
		if(!uft.same(e.u, e.v)) {
			uft.unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}
		

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

	cin >> V >> E;
	
	rep(i, 0, E) {
		int s, t, w;
		cin >> s >> t >> w;
		es[i].u = s;
		es[i].v = t;
		es[i].cost = w;
	}

	cout << kruskall() << endl;
}



Measured memory_bytes: 4376
using System;using System.Linq;
class A{
 static void Main(){
     while(true){
         int []n=Console.ReadLine().Split().Select(int.Parse).ToArray();
         if(n[0]==0&&n[1]==0){break;}
         int []a=Console.ReadLine().Split().Select(int.Parse).ToArray();
         Array.Sort(a);
         int max=-1;
         for(int i=a.Length-1;i>=0;i--){
             for(int k=i-1;k>=0;k--){
                if(a[i]+a[k]<=n[1]){max=Math.Max(a[i]+a[k],max);}
             }
             
         }
         if(max==-1){Console.WriteLine("NONE");continue;}
         Console.WriteLine(max);
     }
     
 }   
}

Measured memory_bytes: 10028