akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin>>n;
	n*=2;

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

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

	int ans=0;
	for(int i=0;i<(n/2);++i) { ans+=skewers[i*2]; }
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
  vector<int> time;
  int a,b,c,d;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    time.push_back(b);
  }
  cin>>a;
  d=accumulate(time.begin(),time.end(),0);
  for(int i=0;i<a;i++){
    cin>>b>>c;
    cout<<d-time[b-1]+c<<endl;
  }
}



Measured memory_bytes: 256
S = list(input())
len = len(S)
flag = 0

for i in range(len):
    if i % 2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            continue
        else:
            flag = 1
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            continue
        else:
            flag = 1

if flag == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 38400
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n%10 == 3) {
			System.out.println("bon");
		} else if(n%10 == 0 ||n%10 == 1 ||n%10 == 6 ||n%10 == 8) {
			System.out.println("pon");
		} else {
			System.out.println("hon");
		}
	
		scan.close();
	}

}


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

int main(){
	int N,K,a[50],ans=0;
  	cin>>N>>K;
  	for(int i=0;i<N;++i)cin>>a[i];
  	sort(a,a+N);
  	for(int i=N-1;i>=N-K;--i)ans+=a[i];
  	cout<<ans<<endl;
  	return 0;
}

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

using namespace std;
int main() {
   int N,K,h;
   int ans=0;
   cin>>N>>K;
   for(int i=0;i<N;i++){
       cin>>h;
       if(h>=K){
           ans++;

       }
   }

   cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,k;
 	int a=1;
 	cin >> n>>k;
 	for (int i = 0; i < n; i++){
 		if(a>k){
 			a+=k;
 		}else{
 			a*=2;
 		}
 	}
 	cout << a << endl;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int l = 0, r = 0, ans = 0;
  while (l <= r) {
    while (r + 1 < n && a[r + 1] - a[l] <= 2) {
      r++;
    }
    ans = max(ans, r - l + 1);
    if (r + 1 < n && l == r) {
      r++;
    }
    l++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

get_numbers_2(0, _, []).
get_numbers_2(N1, N2, [X|Xs]) :- 
    get_numbers(N2, X), 
    N12 is N1 - 1, 
    get_numbers_2(N12, N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)

    include(f, Xs, Ys) : filter f

    findall(使う変数のタプル, (hoge), hogeが通るタプルのリスト)
*/

f(0, A, B, C, D) :- 
    write("AC x "),
    writeln(A),
    write("WA x "),
    writeln(B),
    write("TLE x "),
    writeln(C),
    write("RE x "),
    writeln(D).

f(N, A, B, C, D) :-
    get_string(X),
    f(N, A, B, C, D, X).

f(N, A, B, C, D, "AC") :- 
    N2 is N - 1, A2 is A + 1, f(N2, A2, B, C, D).

f(N, A, B, C, D, "WA") :- 
    N2 is N - 1, B2 is B + 1, f(N2, A, B2, C, D).

f(N, A, B, C, D, "TLE") :- 
    N2 is N - 1, C2 is C + 1, f(N2, A, B, C2, D).

f(N, A, B, C, D, "RE") :- 
    N2 is N - 1, D2 is D + 1, f(N2, A, B, C, D2).

main :-
    get_number(N),
    f(N, 0, 0, 0, 0).

    % statistics(inferences, IC), writeln(IC).


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

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
  string n;
  int sum = 0;
  cin >> n;
  for (int i=0; i<n.size(); i++) {
    sum += n[i] - '0';
  }

  auto result = (stoi(n) % sum == 0) ? YES : NO;
  cout << result << endl;
}


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

int main() {
  int k;
  cin >> k;
  int m=7%k;
  int res=1;
  vector<int> s(k,0);
  while (m!=0){
    m=(m*10+7)%k;
    res++;
    if (s[m]==1){
      cout << -1 << endl;
      return(0);
    }else{
      s[m]=1;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 7216
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL dfs(string s,int x,int until){
	if(x==N){
		cout << s << endl;
		return 0;
	}
	LL c=until+2;
	if(x==0) c--;
	REP(i,c){
		dfs(s+char('a'+i),x+1,max(i,until));
	}
	return 0;
}
LL solve(){
	cin >> N;
	dfs("",0,0);
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;
	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N); vector<vector<int>> x(N), y(N);
  REP(i, N) {
    int a; cin >> a;
    A[i] = a;
    REP(k, A[i]) {
      int X, Y; cin >> X >> Y;
      x[i].push_back(X); y[i].push_back(Y);
    }
  }
  int ans = 0;
  for(int bit = 0; bit < (1 << N); bit++) {
    bool flag = false;
    for(int i = 0; i < N; ++i) {
      if(!( bit & (1 << i) )) continue;
      // 1: 正直 0: 嘘つき
      REP(k, A[i]) {
        if(y[i][k] == 1) {
          if(bit & (1 << (x[i][k] - 1))) {

          } else {
            flag = true;
          }
        } else {
          if(bit & (1 << (x[i][k] - 1))) {
            flag = true;
          }
        }
      }
    }
    if(flag) continue;
    int res = __builtin_popcount(bit);
    if(ans < res) ans = res;
  }
  cout << ans << endl;
}


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

struct edge{
  int to;
  int cost;
};

using P = pair<int,int>;

const int MAX_N = 1e6;
const int INF = 1e9;
vector<edge> G[MAX_N];
vector<int> dist(MAX_N,INF);

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> PQ;
  dist[s] = 0;
  PQ.push(P(0,s));
  
  while(PQ.size()){
    P p = PQ.top();
    PQ.pop();
    int v = p.second; //from
    if(dist[v] < p.first){ //現在わかっている距離が更新できない
      continue;
    }
    for(int i=0; i<G[v].size(); i++){
      edge e = G[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        PQ.push(P(dist[e.to], e.to));
      }
    }
  }
}

int main(){
  int H, W, sx, sy, gx, gy;
  cin >> H >> W >> sx >> sy >> gx >> gy;
  vector<vector<char>> maze(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> maze[i][j];
    }
  }
  
  vector<int> dx = {0,1,2,-1,-2};
  vector<int> dy = {0,1,2,-1,-2};
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(maze[i][j] == '.'){
        for(int k=0; k<5; k++){
          for(int l=0; l<5; l++){
            if(i + dx[k] >= 0 && i + dx[k] < H && j + dy[l] >= 0 && j + dy[l] < W){
              if(abs(dx[k]) + abs(dy[l]) == 1){
                int t = (i+dx[k])*H + (j+dy[l]);
                edge add;
                add.to = t;
                add.cost = 0;
                G[i*H + j].push_back(add);
              }
              if(abs(dx[k]) + abs(dy[l]) > 1){
                int t = (i+dx[k])*H + (j+dy[l]);
                edge add;
                add.to = t;
                add.cost = 1;
                G[i*H + j].push_back(add);
              }
            }
          }
        }
      }
    }
  }
  sx--; sy--; gx--; gy--;
  dijkstra(sx*H + sy);
  if(dist[gx*H + gy] == INF){
    cout << -1 << endl;
  }
  else{
    cout << dist[gx*H + gy] << endl;
  }
}


Measured memory_bytes: 164336
mod = 10**9 + 7
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    a.sort()
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if a[i] + a[j] > a[k] and a[i] != a[j] and a[j] != a[k]:
                    ans += 1
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1


Measured memory_bytes: 67644
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M,H;
vi a,b;
vector<pi>IN,IN2;
vvi dp;
bool pairCompare(const std::pair<float, int>& firstElem, const std::pair<float, int>& secondElem) {
    return firstElem.second > secondElem.second;
}

void input(){
	cin>>N>>H;
	rep(i,N){
		int t,t2;
		cin>>t>>t2;
		IN.pb(mp(t,t2));
		IN2.pb(mp(t,t2));
	}
}
/*int dfs(int ac,int bc,int e){
	if(dp[ac][bc]!=-1)return dp[ac][bc];
	int ret=dfs(ac+1,bc)
	if(e>=H)return 0;
	int ret=dfs(ac+1,bc,e-)
}*/
/*
int dfs(int p,int c,int h,vi t){
	if(dp[p][c]!=-1)return dp[p][c];
	//PP(p)P(h)
	if(h>=H){
		rep(i,t.size())PP(t[i])
		cout<<endl;
		return 0;
	}
	if(p>=N)return INF;
	t.pb(p);
	int ret=dfs(p,c+1,h+IN[p].first,t)+1;
	t.pop_back();
	for(int i=p;i<IN.size();i++){
		t.pb(i);
		ret=min(ret,dfs(p+1,c+1,h+IN[i].second,t)+1);
		t.pop_back();
	}
	return dp[p][h]=ret;
	//return ret;
}*/
int dfs(int now,int bc,int h){
	
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	sort(ALL(IN),greater<pi>());
	sort(ALL(IN2),pairCompare);
	//dp.resize(H/IN[0].first+1,vi(N+1,-1));
	//int ans=H/IN[0].first;
	int nh=H;
	//if(H%IN[0].first!=0)ans++;
	int cnt=0;
	rep(i,N){
		if(nh<=0)break;
		if(IN2[i].second>IN[0].first){
			nh-=IN2[i].second;
			cnt++;
		}
	}
	int ans=0;
	if(nh>0){
		ans=nh/IN[0].first;
		if(nh%IN[0].first!=0)ans++;
	}
	ans+=cnt;
	P(ans)
	return 0;
}



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

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

int n, k;
vector<int> G[100001];
int cnt[100001];
int gettt[100001];
int val[100001];
int ans = 0;

int dfs(int v, int p) {
	int ans = 1;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p) {
			ans += dfs(G[v][i], v);
		}
	}
	return (cnt[v] = ans);
}

void solve(int v, int p) {
	int maxi = -1;
	int tp = n;
	for (int i = 0; i < G[v].size(); i++) {
		int nv = G[v][i];
		if (nv != p) {
			solve(nv, v);
		}
	}
	for (int i = 0; i < G[v].size(); i++) {
		int nv = G[v][i];
		if (nv != p) {
			int cv = val[nv];
			if (cnt[nv] >= k) {
				cv--;
			}
			if (maxi <= cv) {
				if (maxi < cv)tp = cnt[v];
				else tp = min(cnt[v], tp);
				maxi = max(cv, maxi);
			}
		}
	}
	int tmp = 0;
	if (n - cnt[v] >= k)tmp++;
	ans = max(ans, maxi + tmp + gettt[v]);
	//printf("%d\n",maxi);

	val[v] = max(val[v], maxi+gettt[v]);
	//printf("%d an1=%d va=%d\n",v,ans,val[v]);
	maxi = -1;
	int maxi2 = -1;
	if (G[v].size() <= 2)return;
	for (int i = 0; i < G[v].size(); i++) {
		int nv = G[v][i];
		if (nv != p) {
			int cv = val[nv];
			if (cnt[nv] >= k) {
				cv--;
			}
			if (maxi < cv) {
				maxi2 = maxi;
				maxi = cv;
			} else if (maxi2 < cv) {
				maxi2 = cv;
			}
		}
	}
	//printf("%d %d %d %d\n",v,maxi,maxi2,gettt[v]);
	//printf("%d %d\n",val[v],tmp);
	ans = max(ans, maxi + maxi2 + tmp + gettt[v]);
	//printf("%d an2=%d\n",v,ans);
}

int main(void) {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--;
		v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < G[i].size(); j++) {
		}
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < G[i].size(); j++) {
			int nv = G[i][j];
			if (cnt[nv] < cnt[i]) {
				if (cnt[nv] >= k)gettt[i]++;
			}
		}
		val[i] = gettt[i];
	}
	solve(0, -1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 13964
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);

  int i = 1, x;
  for(i = 1; i <= n; ++i)
  {
    x = i;
    if(x%3 == 0){
      printf(" %d",i);
    }
    else{
      while(1)
      {
        if(x%10 == 3){
          printf(" %d",i);
          break;
        }
        x /= 10;
        if(x == 0){
          break;
        }
      }
    }
  }
  printf("\n");

  return 0;
}

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

#define int long long

using namespace std;

const int maxn = 1010, maxl = 10010;
int dp[maxn][maxl], n;

struct item
{
    int w, s, v;
} a[maxn];

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> a[i].w >> a[i].s >> a[i].v;
    sort(a, a + n, [](item u, item v) { return u.w + u.s > v.w + v.s; });

    for (int i = n - 1; ~i; i--)
        for (int j = 0; j < maxl; j++)
        {
            item u = a[i];
            dp[i][j] = dp[i + 1][j];
            if (j >= u.w)
                dp[i][j] = max(dp[i][j], dp[i + 1][min(j - u.w, u.s)] + u.v);
        }

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, dp[i + 1][a[i].s] + a[i].v);

    cout << ans;

    return 0;
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<string>
#include<string.h>
#include<map>
#include<math.h>

#define int long long
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define all(a) begin(a),end(a)
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define sz(x) ((int)x.size())
#define ins insert
#define rep(i,l,u) for(int i=l;i<=u;++i)
#define reb(i,l,u) for(int i=l;i>=u;--i)
using namespace std;
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
main(){
    int a[110];
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            for(int k=j+1;k<=n;++k){
                int mx=max({a[i],a[j],a[k]});
                int mi=min({a[i],a[j],a[k]});
                int md=a[i]+a[j]+a[k]-mx-mi;
                if(mx==md||mi==md)continue;
                if(mx<mi+md){
                    //cout<<i<<" "<<j<<" "<<k<<endl;
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}

int main() {
    int a[3][3], b[3][3] = { 0 };
    int n, v;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    while (n--) {
        cin >> v;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (a[i][j] == v)
                    b[i][j] = 1;
            }
        }
    }

    for (int i = 0; i < 3; ++i) {
        if (b[i][0] && b[i][1] && b[i][2])
            yes();
        if (b[0][i] && b[1][i] && b[2][i])
            yes();
    }
    if (b[0][0] && b[1][1] && b[2][2])
        yes();
    if (b[0][2] && b[1][1] && b[2][0])
        yes();

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N = input()
Nlen = len(N)
N = int(N)

def f(i, n, T, F, S):
  if i >= Nlen:
    return 1 if n <= N and T > 0 and F > 0 and S > 0 else 0
  n *= 10
  cnt = 0
  if n == 0:
    cnt += f(i+1, n, T  , F  , S  )
  cnt += f(i+1, n+3, T+1, F  , S  )
  cnt += f(i+1, n+5, T  , F+1, S  )
  cnt += f(i+1, n+7, T  , F  , S+1)
  return cnt

print(f(0, 0, 0, 0, 0))

Measured memory_bytes: 3064
import numpy as np
MOD = 1000000007

def mod_add(a, b):
  return (a+b)%MOD

def mod_sub(a, b):
  return (a+MOD-b)%MOD

def mod_mul(a, b):
  return a*b%MOD

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = (1,0,a)
    w = (0,1,b)
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return (w[0],w[1])

def mod_inv(a):
    x,  = extgcd(a, MOD)
    return (MOD+x%MOD)%MOD

def mod_div(a, b):
    return a*mod_inv(b)%MOD

def mod_pow(a, b):
    res = 1
    while b > 0:
        if b & 1:
            res = res * a * MOD
        a = a * a % MOD
        b >>= 1
    return res

MAX = 510000

fac  = [1,1]
finv = [1,1]
inv  = [1,1]

def COMinit():
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(MOD - inv[MOD%i] * (MOD // i) % MOD)
        finv.append(finv[i - 1] * inv[i] % MOD)

def mod_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

N, M, K = map(int, input().split())

res = 0
COMinit()
for d in range(1, N):
    tmp = mod_COM(M*N-2, K-2)
    tmp = mod_mul(tmp, d)
    tmp = mod_mul(tmp, (N-d)*M*M)
    res = mod_add(res, tmp)

for d in range(1, M):
    tmp = mod_COM(M*N-2, K-2)

    tmp = mod_mul(tmp, d)
    tmp = mod_mul(tmp, (M-d)*N*N)
    res = mod_add(res, tmp)


print(res)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    int a[10];
    while (cin >> s)
    {
        rep(i, 10)
        {
            a[i] = s[i] - '0';
        }
        int n = 9;
        rep(i, 10)
        {
            rep(i, n)
            {
                a[i] += a[i + 1];
            }
            n--;
        }
        OP(a[0] % 10);
    }
    return 0;
}


Measured memory_bytes: 3024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    int h, w;
    cin >> h >> w;
    map<int, int> mp;
    bool flag = true;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if (s[j] == '#' && mp[i+j] > 0) {
                flag = false;
                break;
            } else if (s[j] == '#') {
                mp[i+j]++;
            }
        }
    }
    string ans = flag ? "Possible" : "Impossible";
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, q; cin >> n >> q;
    fenwick_tree<ll> fw(n);
    for (int i = 0; i < n; i++) {
        ll a; cin >> a;
        fw.add(i, a);
    }

    while (q--) {
        int t; cin >> t;
        if (t == 0) {
            int p; ll x;
            cin >> p >> x;
            fw.add(p, x);
        } else {
            int l, r; cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
}

Measured memory_bytes: 8220
<?php

fscanf(STDIN,"%d %d",$n,$m);
$a = explode(" ",fgets(STDIN));
$a= array_map('trim', $a);
$a= array_map('intval', $a);
rsort($a);
if($a[$m-1]<(1/(4*$m))*array_sum($a)){
	echo "No";
}else{
	echo "Yes";
}

Measured memory_bytes: 4728
import sys

def solve():
    input = sys.stdin.readline
    K, N = map(int, input().split())
    A = [int(a) for a in input().split()]
    longestL = A[0] + (K - A[N - 1])
    for i in range(N - 1):
        longestL = max(longestL, A[i+1] - A[i])
    print(K - longestL)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 24908
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local X, Y = read.nn()
local k2 = Y - 2*X
if k2 % 2 == 1 or k2 < 0 then
    print("No")
    return
end
local t2 = 4*X - Y
if t2 % 2 == 1 or t2 < 0 then
    print("No")
    return
end
print("Yes")

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;

    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            count++;
        } else if (p[i + 1] > p[i] && p[i] > p[i - 1]) {
            count++;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define exchange(a,b) {typeof(a) __tmp=a;a=b;b=__tmp;}


char A[100001];
int B[100001];


int Partition(int A[], int p, int r) {
  int i,j;
  int x;
  x = A[r];
  i = p-1;
  for(j = p; j < r; ++j) {
    if(B[A[j]] <= B[x]) { // if(A[j] <= x) {
      i = i+1;
      exchange(A[i], A[j]);
    }
  }
  exchange(A[i+1], A[r]);
  return i+1;
}

void Quicksort(int A[], int p, int r) {
  int q;
  if(p < r) {
    q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}

int isStable(int A[], int n) {
  int i;
  for(i = 2; i <= n; ++i) {
    if(B[A[i-1]] == B[A[i]] && A[i-1] > A[i]) return 0;
  }
  return 1;
}

int main() {
  int i;
  int n;
  int C[100001];
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf(" %c %d", A+i,B+i);
    C[i] = i;
  }
  Quicksort(C,1,n);
  if(isStable(C,n)) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 1; i <= n; ++i) {
    printf("%c %d\n", A[C[i]], B[C[i]]);
  }
  return 0;
}


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

int main(){
	
	ll x; cin>>x;
	ll a{100};
	int j{1};
	while(1){
		a += a/100;
		if(a>=x) {
			cout << j << endl;
			return 0;
		}
		j++;
	}
	
	
}

Measured memory_bytes: 3636
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));
  const A = s[0];
  const B = s[1];
  const C = s[2];
  const D = s[3];

  const status = [...Array(101)].fill(0);

  for (let i = A + 1; i <= B; i++) {
    status[i] += 1;
  }

  for (let i = C + 1; i <= D; i++) {
    status[i] += 1;
  }

  const answer = status.filter(n => n === 2).length;
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

bool g[777][777];
int n,x[777],bc,wc;

bool dfs(int v, int c){
	int i;
	x[v] = c;
	if(c>0){
		++bc;
	}else{
		++wc;
	}
	for(i=0; i<n; ++i){
		if(!g[v][i]){
			continue;
		}
		if(x[i]==c){
			return false;
		}else if(x[i]==0 && (!dfs(i,-c))){
			return false;
		}
	}
	return true;
}

bool dp[2][777];

int main(void){
	int m,a,b,cnt,i,j,ans=INF,p=0,q=1;
	fill(g[0],g[777],true);
	fill(dp[0],dp[2],false);
	dp[0][0] = true;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		g[i][i] = false;
	}
	for(i=0; i<m; ++i){
		cin >> a >> b; --a; --b;
		g[a][b] = false;
		g[b][a] = false;
	}
	for(i=0; i<n; ++i){
		if(x[i]){
			continue;
		}
		bc = 0; wc = 0;
		if(!dfs(i,1)){
			cout << "-1" << endl;
			return 0;
		}
		for(j=bc; j<=n; ++j){
			if(dp[p][j-bc]){
				dp[q][j] = true;
			}
		}
		for(j=wc; j<=n; ++j){
			if(dp[p][j-wc]){
				dp[q][j] = true;
			}
		}
		for(j=0; j<=n; ++j){
			dp[p][j] = false;
		}
		swap(p,q);
	}
	for(j=0; j<=n; ++j){
		if(dp[p][j]){
			ans = min(ans,n*(n-1)/2-j*(n-j));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
// Aizu Vol-1 0133: Rotation of a Pattern
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char a[2][10][20];
char *s[3] = { "90", "180", "270" };

int main()
{
	int r, c;
	int i, k1, k2;

	for (r = 0; r < 8; r++) gets(a[0][r]);
	for (i = k1 = 0, k2 = 1; i < 3; i++, k2 = k1, k1 = !k1) {
		puts(s[i]);
		for (r = 0; r < 8; r++) for (c = 0; c < 8; c++)	a[k2][c][7-r] = a[k1][r][c];
		for (r = 0; r < 8; r++) puts(a[k2][r]);
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		char[] b=new char[a.length()];

		for(int i=0; i<a.length(); i++) {
			b[i]=a.charAt(i);
		}

		int mojisu=a.length();
		if(mojisu%2==1) {
			int cut=1;
			boolean bb=true;
			for(int i=0; i<(a.length()-1)/2; i++) {
				bb=true;
				for(int j=0; j<(mojisu-cut)/2; j++) {
					if(b[j]!=b[j+(mojisu-cut)/2]) {
						bb=false;
						break;
					}
				}

				if(bb==true) {
					System.out.println(mojisu-cut);
					System.exit(0);
				}

				cut+=2;
			}
		}
		else if(mojisu%2==0) {
			int cut=2;
			boolean bb=true;
			for(int i=0; i<(a.length())/2-1; i++) {
				bb=true;
				for(int j=0; j<(mojisu-cut)/2; j++) {
					if(b[j]!=b[j+(mojisu-cut)/2]) {
						bb=false;
						break;
					}
				}

				if(bb==true) {
					System.out.println(mojisu-cut);
					System.exit(0);
				}
				cut+=2;
			}
		}
	}
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

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

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {

	int N, A[100005], count = 0;
	bool check = true;

	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> A[i];

	}

	sort(A, A + N);
	for (int i = 1; i < N; i++) {

		if (A[i] != A[i - 1]) {

			if (check)count++;
			check = true;

		}
		else {

			if (check)check = false;
			else check = true;

		}

	}
	if (check)count++;

	cout << count << endl;

	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    int n; cin >> n;
    ll a[n]; rep(i,0,n) cin >> a[i];
    ll all = 0;
    rep(i,0,n) all = all^a[i];
    rep(i,0,n){
        ll t = all^a[i];
        cout << t;
        if(i != n-1) cout << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 5176
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;
    
    while(N > 0){
      N /= K;
      ans++;
    } 
    System.out.println(ans);
  }
}
      

Measured memory_bytes: 35612
# -*- coding: utf-8 -*-
# B - ∵∴∵
# 標準入力の取得
O = input()
E = input()

# 求解処理
password = ""
for n in range(len(O)):
    password += O[n]
    if n < len(E):
        password += E[n]

print(password)

Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int k = 2;
    int[] heights = new int[n];
    int[] dp = new int[n];
    for(int i = 0; i < n; i++){
      heights[i] = sc.nextInt();
      dp[i] = 2000000001;
    } 
    dp[0] = 0;

    for(int i = 0; i < n; i++){
      for(int j = 1; j <= k && i + j < n; j++){
        if(dp[i+j] > dp[i] + Math.abs(heights[i] - heights[i+j])){
          dp[i+j] = dp[i] + Math.abs(heights[i] - heights[i+j]);
        }
      }
    }

    System.out.println(dp[n-1]);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

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

    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    A--;
    B--;
    C--;
    D--;
    S[A] = 'A';
    S[B] = 'B';

    bool can_reach_A = true;
    bool can_reach_B = true;

    // cout << "A: " << A << ", B: " << B << endl;
    // cout << S << endl;

    while (A < C)
    {
        if (S[A + 1] == '.')
        {
            S[A] = '.';
            A++;
            S[A] = 'A';
        }
        else if (S[A + 2] == '.')
        {
            S[A] = '.';
            A += 2;
            S[A] = 'A';
        }
        else if ((S[A + 1] == 'B' || S[A + 2] == 'B') && B != D)
        {
            if (S[B + 1] == '.')
            {
                S[B] = '.';
                B++;
                S[B] = 'B';
            }
            else if (S[B + 2] == '.')
            {
                S[B] = '.';
                B += 2;
                S[B] = 'B';
            }
            else
            {
                can_reach_B = false;
                break;
            }
        }
        else
        {
            can_reach_A = false;
            break;
        }

        // cout << "A: " << A << ", B: " << B << endl;
        // cout << S << endl;

        if (A == C)
        {
            break;
        }
    }

    if (!(can_reach_A && can_reach_B))
    {
        // cout << "A: " << can_reach_A << endl;
        // cout << "B: " << can_reach_B << endl;

        cout << "No" << endl;
        return 0;
    }

    // cout << "##########" << endl;
    // cout << "A: " << A << ", B: " << B << endl;
    // cout << S << endl;

    while (B < D)
    {
        if (S[B + 1] == '.')
        {
            S[B] = '.';
            B++;
            S[B] = 'B';
        }
        else if (S[B + 2] == '.')
        {
            S[B] = '.';
            B += 2;
            S[B] = 'B';
        }
        else
        {
            can_reach_B = false;
            break;
        }

        // cout << "A: " << A << ", B: " << B << endl;
        // cout << S << endl;
    }

    if (!(can_reach_A && can_reach_B))
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[202020];
int d[1010101];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[a[i]]++;
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(d[a[i]] != 1) continue;
		bool ok = 1;
		for(int j = 1; j * j <= a[i]; j++){
			if(a[i] % j) continue;
			if((d[j] && j != a[i]) || (d[a[i]/j] && j != 1)){
				ok = 0;
				break;
			}
		}
		ans += ok;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 8184
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<math.h>
using namespace std;

	bool sok(int* a,int n){
		for(int i=1;i<n;i++){
			if(a[i-1]>a[i])return false;
		}
		return true;
	}

int main(){
	int a[100],n;
	cin>>n;int cnt=0;
	
		for(int i=0;i<n;i++)cin>>a[i];
		int mini=0;
	for(int i=0;i<n;i++){
		mini=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[mini]){
			mini=j;
			}
		}
		//if (sok(a,n))break;
		if(a[i]>a[mini]){
		swap(a[i],a[mini]);
		cnt++;
		}
	}
	
	for(int i=0;i<n-1;i++)cout<<a[i]<<" ";
	cout<<a[n-1]<<endl<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	REP(i,n) cin >> a[i];
	REP(i,n) cin >> b[i];
	REP(i,n) cin >> c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	vector<ll> B(n),SB(n+1);
	REP(i,n){
		if(b[i] >= c[n-1]){
			B[i] = 0;
			continue;
		}
		int ok,ng,mid;
		ok = 1;
		ng = n+1;
		while(abs(ok-ng)>1){
			mid = (ok+ng)/2;
			if(b[i]<c[n-mid]){
				ok = mid;
			}else{
				ng = mid;
			}
		}
		B[i] = ok;
	}
	
	SB[n]=0;
	for(int i=n-1; i>=0; i--) SB[i] = SB[i+1]+B[i];
	
	vector<ll> A(n);
	REP(i,n){
		if(a[i] >= b[n-1]){
			A[i] = 0;
			continue;
		}
		int ok,ng,mid;
		ok = 1;
		ng = n+1;
		while(abs(ok-ng)>1){
			mid = (ok+ng)/2;
			if(a[i]<b[n-mid]){
				ok = mid;
			}else{
				ng = mid;
			}
		}
		A[i] = SB[n-ok];
	}
	
	ll ans = 0;
	REP(i,n) ans += A[i];
	cout << ans << endl;
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int n;
    cin>>n;
    int m=n,s=0;
    while(n){
        s+=n%10;
        n/=10;
    }
    if(m%s==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    string ans;
    for (ll i = 0; i < (ll)S.size(); i += 2) {
        ans += S[i];
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstdlib>

#define SIZE 8
#define WIDTH 4

using namespace std;

int distances[SIZE][SIZE][SIZE][SIZE][SIZE][SIZE][SIZE][SIZE];
int way[4] = { -1, 1, -WIDTH, WIDTH };

typedef struct{
	int v[SIZE];
} field_t;

void solve(){
	queue<field_t> q;

	q.push({ { 0, 1, 2, 3, 4, 5, 6, 7 } });

	while (!q.empty()){
		field_t a = q.front();
		q.pop();

		for (int i = 0; i < SIZE; i++){
			if (a.v[i] == 0){
				for (int j = 0; j < 4; j++){
					int newpos = i + way[j];
					if (newpos < 0 || newpos >= SIZE || abs(newpos%WIDTH - i%WIDTH) > 1) continue;
					int dist = distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]];
					a.v[i]		= a.v[newpos];
					a.v[newpos]	= 0;
					if (distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]]) {
						a.v[newpos] = a.v[i];
						a.v[i]		= 0;
						continue; 
					}
					distances[a.v[0]][a.v[1]][a.v[2]][a.v[3]][a.v[4]][a.v[5]][a.v[6]][a.v[7]] = dist + 1;
					q.push(a);
					a.v[newpos] = a.v[i];
					a.v[i]		= 0;
				}
				break;
			}
		}
	}
	distances[0][1][2][3][4][5][6][7] = 0;
}

int main(){
	solve();

	int a[SIZE];
	while (~scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]))
		printf("%d\n", distances[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][a[7]]);

}

Measured memory_bytes: 65180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
    vl v(n+1),w(n+1);
    ll k=log2(n)+1;
    ll mid=k/2;
    repl(i,1,n+1){
       scanf("%lld%lld",&v[i],&w[i]);
    }
    vvl g((1<<mid),vl(100010,0));
    repl(i,1,(1<<mid)){
        rep(j,100010){
            if(j+w[i]<=100000)chmax(g[i][j+w[i]],g[i/2][j]+v[i]);
            chmax(g[i][j],g[i/2][j]);
        }
    }
    ll q;cin >> q;
    while(q--){
        ll s,l;cin >> s >> l;
        if(s<(1<<mid)){
            printf("%lld\n",g[s][l]);
            continue;
        }
        ll res=0;
        vpl use;
        while(s>=(1<<mid)){
            use.pb({w[s],v[s]});
            s/=2;
        }
        ll t=use.size();
        vl tv,tw;
        rep(bit,1<<t){
            ll a=0,b=0;
            rep(i,t){
                if(bit&(1<<i)){
                    a+=use[i].fi;
                    b+=use[i].se;
                }
            }
            tw.pb(a);tv.pb(b);
        }
        rep(i,tw.size()){
            if(tw[i]>l)continue;
            chmax(res,tv[i]+g[s][l-tw[i]]);
        }
        printf("%lld\n",res);
    }
}

Measured memory_bytes: 409864
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

odd = len([a for a in A if a % 2 == 1])

if P == 1 and odd == 0:
    print(0)
elif P == 0 and odd == 0 :
    print(2 ** N)
else:
    print(2 ** (N - 1))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
ll bpow(ll,ll,ll);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;
int main()
{
  ll cnt=0,b=0,w=0;
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S[i] == 'W')
      cnt += b;
    if(S[i] == 'W')
      w++;
    else
      b++;
  
  }
  cout << cnt << endl;
  return 0;
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}


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

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		String[][] grid = new String[40][100];
		for (int i = 0; i < 20; i++)
			Arrays.fill(grid[i], "#");
		for (int i = 20; i < 40; i++)
			Arrays.fill(grid[i], ".");

		for (int i = 0; i < A - 1; i++) {
			grid[i / 50 * 2][i % 50 * 2] = ".";
		}
		for (int i = 0; i < B - 1; i++) {
			grid[i / 50 * 2 + 21][i % 50 * 2] = "#";
		}

		System.out.println(40 + " " + 100);
		for (int i = 0; i < grid.length; i++) {
			for (int j = 0; j < grid[i].length; j++)
				System.out.print(grid[i][j]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 24148