akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int i;
int j;
int A;
int B;
int tmp;
int tmp2;
int count = 0;
cin >> A >>B;
tmp=A*25/2;
if((A*25)%2==1)tmp++;
tmp2=(A+1)*25/2;
if(((A+1)*25)%2==1)tmp2++;
for(i=10*B;i<10*(B+1);i++){
    for(j=tmp;j<tmp2;j++){
    if(i==j){
        cout << i << endl;
        count++;
        break;
    }}
    if(count>0)break;
}
if(count==0)cout << "-1" << endl;
}

Measured memory_bytes: 256
using System;
class A{
static void Main(){string a=Console.ReadLine();
a=a.Replace("apple","RaAaYssdHOTATEISTHESTRONGEST");
a=a.Replace("peach","apple");
a=a.Replace("RaAaYssdHOTATEISTHESTRONGEST","peach");
Console.WriteLine(a);
 
 
 
}
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int A, B;
char grid[100][100];

void display() {
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
}

void init() {
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      grid[i][j] = (j < 50 ? '.' : '#');
    }
  }
}

void paintA() {
  int cnt = 1;
  for (int i = 0; i < 100; i += 2) {
    for (int j = 0; j < 49; j += 2) {
      if (cnt >= B) return;
      grid[i][j] = '#';
      cnt++;
    }
  }
}

void paintB() {
  int cnt = 1;
  for (int i = 0; i < 100; i += 2) {
    for (int j = 51; j < 100; j += 2) {
      if (cnt >= A) return;
      grid[i][j] = '.';
      cnt++;
    }
  }
}

int main() {
  // 入力
  cin >> A >> B;

  // 100 × 100のグリッドを半分に分けて1マスずつ連結成分を増やす
  init();
  paintA();
  paintB();

  // 解答
  cout << 100 << " " << 100 << endl;
  display();

  return 0;
}


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

int main(void) {
	int i;
	char we[8];

	fgets(we, sizeof(we), stdin);
	if(we[0] == 'R') {//R**
		if(we[1] == 'S') {//RS*
			printf("1\n");
		} else {
			if(we[2] == 'S') {//RRS
			printf("2\n");
			} else {//RRR
			printf("3\n");
			}
		}
	} else {//S**
		if(we[1] == 'S') {//SS*
			if(we[2] == 'S') {//SSS
				printf("0\n");
			} else {//SSR
				printf("1\n");
			}
		} else {//SR*
			if(we[2] == 'S') {//SRS
				printf("1\n");
			} else {//SRR
				printf("2\n");
			}
		}
	}

	return 0;
}


Measured memory_bytes: 1932
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
ll MOD = 1e9 + 7;

int main()
{
    int n,m;
    cin>>m>>n;
    vector<int> reg;
   // cout<<sqrt(n)<<endl;
    for(int i=1;i<=(int)sqrt(n);i++){
        //cout<<i<<endl;
        if(n%i==0){
            reg.push_back(i);
        }
    }//*/
   // divi.push_back(n);
   int x=reg.size();
   
    for(int i=0;i<x;i++){
        reg.push_back(n/reg[i]);
    }
    sort(reg.begin(),reg.end());
    for(int i=0;i<reg.size();i++){
        if(n%reg[i]==0&&reg[i]>=m){
            cout<<n/reg[i]<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    int to_start = 0;
    int to_goal = 0;
    
    for(int i = 0; i < m; i++){
        int b;
        cin >> b;
        if(x > b){
            to_start++;
        } else {
            to_goal++;
        }
    }
    cout << min(to_goal, to_start) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,m,a[110],ans=0,sum=0,amin=INF;
	cin>>n>>m;
	REP(i,n){
		cin>>a[i];
		amin=min(a[i],amin);
		sum+=a[i];
	}
	ans+=n;
	m-=sum;
	ans+=m/amin;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n,k=map(int, input().split())

def mymult(i):
    if i%2==0:
        a=i//2
        return a*(i-1)
    else:
        a=(i-1)//2
        return a*i

def mymult2(n,i):
    tmp=n*2-i+1
    if tmp%2==0:
        a=tmp//2
        return a*i
    else:
        a=i//2
        return tmp*a

ans=0
for i in range(k,n+2):
    minim=mymult(i)
    maxim=mymult2(n,i)
    ans=ans+(maxim-minim)+1

print(ans%1000000007)

Measured memory_bytes: 9216
#include<stdio.h>

int main(){
  int i, n, money = 100000;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    money += money / 20;
    if(money % 1000 != 0){
      money = (money / 1000 + 1) * 1000;
    }
  }
  printf("%d\n", money);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int Count = 0;
  for(int i = 0; i < N - 2; i++){
      if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
          Count++;
      }
  }
  cout << Count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ba=0,ma=0,t;
	cin>>n;
	for(t=1;t<=n/10;t=t*100)
	{
		ba=ba+t*9;
		//cout<<"t="<<t<<" "<<"ba="<<ba<<" ";
	}
	for(int i=1;n/i!=0;i=i*10)
	{
		ma++;
	}
	if(ma%2==1)
	{
		ba=ba+(n/t-1)*t+n%t+1;
	}
	cout<<ba;
	return 0;
} 

Measured memory_bytes: 256
import numpy as np
n = int(input())
a = np.empty(n+2, dtype=np.int)
a[0] = 0
a[n+1] = 0
a[1:n+1] = np.int64(input().split())
da = np.absolute(a[1:] - a[:-1])
gain = da[1:] + da[:-1]
loss = np.absolute(a[2:] - a[:-2])
s = da.sum()
for i in range(n):
    print(s+loss[i]-gain[i])

Measured memory_bytes: 22056
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
vector<vi> e;
double dp[600][600];
double rec(int c, int use){
	double &res = dp[c][use];
	if(res >= 0) return res;
	int k = e[c].size();
	if(k == 0) return res = 0;
	if(k == 1) return res = 1 + rec(e[c].back(), use);
	
	if(c != use){
		double sum = 0;
		for(int i : e[c]) sum += rec(i, use);
		return res = sum / k + 1;
	}
	
	vector<double> r;
	for(int i : e[c]) r.pb(rec(i, use));
	sort(all(r));
	
	return res = 1 + (accumulate(all(r), 0.0) - r.back()) / (r.size() - 1);
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	e.resize(n);
	rep(i, m){
		int s, t; cin >> s >> t;
		e[s - 1].pb(t - 1);
	}
	memset(dp, -1, sizeof(dp));
	double ans = INF;
	rep(i, n) ans = min(ans, rec(0, i));
	printf("%.20f\n", ans);
	return 0;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>

template <class Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const edge<value_type> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
    (*this)[dst].emplace_back(dst, src, cost);
  }
};

template <class Tp, class Compare>
using priority_queue = std::priority_queue<Tp, std::deque<Tp>, Compare>;

template <class Tp>
constexpr Tp inf = Tp(1) << (8*sizeof(Tp)-3);

template <class Weight>
std::vector<Weight> shortest(const graph<Weight>& g, size_t s) {
  // based on Dijkstra algorithm
  std::vector<Weight> res(g.size(), inf<Weight>);
  priority_queue<std::pair<Weight, size_t>, std::greater<>> q;
  res[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    Weight w;
    size_t v;
    std::tie(w, v) = q.top();
    q.pop();
    if (w > res[v]) continue;

    for (const auto& e: g[v]) {
      if (res[e.dst] > w + e.cost) {
        res[e.dst] = w + e.cost;
        q.emplace(res[e.dst], e.dst);
      }
    }
  }
  return res;
}

template <class Weight>
size_t diameter(const graph<Weight>& g) {
  auto tmp = shortest(g, 0);
  size_t r = std::max_element(tmp.begin(), tmp.end()) - tmp.begin();
  tmp = shortest(g, r);
  return *std::max_element(tmp.begin(), tmp.end());
}

int main() {
  size_t N;
  scanf("%zu", &N);

  graph<int> g(N);
  for (size_t i = 1; i < N; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a;
    --b;
    g.connect_with(a, b);
  }

  size_t diam = diameter(g);

  std::vector<bool> res(N+1);
  res[0] = true;
  res[1] = false;
  for (size_t i = 2; i <= N; ++i)
    if (!res[i-2] || !res[i-1])
      res[i] = true;

  puts(res[diam]? "First":"Second");
}


Measured memory_bytes: 20780
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

inline void rotate(char* dst, const char* src, size_t len, int h) {
  memmove(dst, src + h, len - h);
  memmove(dst + len - h, src, h);
}

int main() {
  char buf1[200];
  char buf2[200];

  for (;;) {
    cin >> buf1;
    if (buf1[0] == '-')
      break;
    const size_t len = strnlen(buf1, 200);

    int m;
    cin >> m;
    int h;

    const char* src = buf1;
    char* tgt = buf2;
    for (int i = 0; i < m; ++i) {
      cin >> h;

      if (i % 2 == 1) {
        src = buf2;
        tgt = buf1;
      } else {
        src = buf1;
        tgt = buf2;
      }
      rotate(tgt, src, len, h);
    }
    printf("%s\n", tgt);
  }

  return 0;
}

Measured memory_bytes: 3100
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

// long long 用の pow (MAX ll 9,223,372,036,854,775,807 -> 19桁)
ll myLongLongPow(ll base, ll times) {
    ll acc = 1;
    rep(i, times) acc *= base;
    return acc;
}

int main() {
    int X, Y;
    cin >> X >> Y;

    string ans = "No";
    for (int a = 0; a <= X; a++) {
        if (a * 2 + (X - a) * 4 == Y) ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	int a = -1, b;
	for (int i = 0;; i++) {
		char c = getchar_unlocked();
		if (c == '\n')break;
		if (c == 'A'&&a == -1)a = i;
		if (c == 'Z')b = i;
	}
	printf("%d\n", b - a + 1);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const double eps = 1e-10;
const double pi = acos(-1);
pair<double, double> deg[2000];
double tmp[4];

int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
	{
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		tmp[0] = atan2(y1, x1);
		tmp[1] = atan2(y1, x2) - pi * 2;
		while (fabs(tmp[1] - tmp[0]) > pi) tmp[1] += pi * 2;
		tmp[2] = atan2(y2, x1) - pi * 2;
		while (fabs(tmp[2] - tmp[0]) > pi) tmp[2] += pi * 2;
		tmp[3] = atan2(y2, x2) - pi * 2;
		while (fabs(tmp[3] - tmp[0]) > pi) tmp[3] += pi * 2;
		sort(tmp, tmp + 4);
		deg[i].first = tmp[0] - pi * 2;
		deg[i].second = tmp[3] - pi * 2;
		while (deg[i].first < 0) deg[i].first += pi * 2;
		while (deg[i].second < deg[i].first) deg[i].second += pi * 2;
	}
	sort(deg, deg + N);
	int ans = N;
	for (int i = 0; i < N; ++i)
	{
		int cnt = 0;
		double last = -1e9;
		for (int j = i; j < i + N && cnt < ans; ++j)
		{
			if (deg[j % N].first + j / N * 2 * pi > last + eps)
			{
				cnt++;
				last = deg[j % N].second + j / N * 2 * pi;
			}
			else if (deg[j % N].second + j / N * 2 * pi < last)
				last = deg[j % N].second + j / N * 2 * pi;
		}
		ans = min(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
	double x1,x2,x3,x4,y1,y2,y3,y4;
	while(cin >> x1)
	{
		cin >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		x2 -= x1; y2 -= y1;
		x4 -= x3; y4 -= y3;

		cout << ( fabs(x2*x4+y2*y4)<1e-10 ? "YES" : "NO") << endl;

	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
     int n,k,sum=0;
     cin>>n>>k;
     int a[n];
     for (int i=0;i<n;i++) cin>>a[i];
     sort(a,a+n);
     for (int i=n-1;i>=n-k;i--)
            sum+=a[i];
    cout<<sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (s.charAt(0)==s.charAt(1)&&s.charAt(1)==s.charAt(2)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23764
A,B,C,D,E,F = map(int, input().split())

ws = set()
i = j = 0
while True:
    j = 0
    if B*i > F//100: break
    while True:
        w = B*i + A*j
        if w > F//100: break
        ws.add(w)
        j += 1
    i += 1
ws = list(ws)
ws.sort()

ss = set()
i = j = 0
while True:
    j = 0
    if D*i > F: break
    while True:
        s = D*i + C*j
        if s > F: break
        ss.add(s)
        j += 1
    i += 1
ss = list(ss)
ss.sort()

limit = E / (100+E)
water = A*100
sugar = rate = 0
for w in ws:
    w = w*100
    if w == 0: continue
    if w > F: break
    for s in ss:
        if w+s > F: break
        r = s / (w+s)
        if r > limit: break
        if r > rate:
            rate = r
            water = w
            sugar = s
print(water+sugar, sugar)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
int N,M,S,T;
vector<ll> dijkstra(int s, vector<vector<P> > &g){
    vector<ll> dist(N,INF);
    dist[s] = 0;
    //<cost, (座標)>
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, s));
    while(!que.empty()){
        auto cost = que.top().first;
        auto now = que.top().second;
        que.pop();

        // if(dist[now.first][now.second] < c) continue;
        for(auto p:g[now]){
            if(dist[p.first] <= cost + p.second)continue;
            dist[p.first] = cost + p.second;
            que.push(P(dist[p.first], p.first));
        }
    }
    return dist;
}
main(){
    cin >> N >> M >> S >> T;
    S--,T--;
    vector<vector<P>> g1(N), g2(N);
    rep(i,0,M){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        a--,b--;
        g1[a].emplace_back(b,c);
        g1[b].emplace_back(a,c);
        g2[a].emplace_back(b,d);
        g2[b].emplace_back(a,d);
    }
    auto v1 = dijkstra(S, g1);
    auto v2 = dijkstra(T, g2);
    /*
    cout << "---" << endl;
    for(auto i:v1)cout << i << endl;
    cout << "---" << endl;
    cout << "---" << endl;
    for(auto i:v2)cout << i << endl;
    cout << "---" << endl;
    */
    ll mini = INF;
    vector<ll> ans(N);
    for(int i = N-1;i >= 0;i--){
        mini = min(mini, v1[i] + v2[i]);
        ans[i] = mini;
    }
    rep(i,0,N)cout << (ll)1e15 - ans[i] << endl;
}

Measured memory_bytes: 19012
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-27 10:45:46 +0900
# LastModified: 2020-06-27 11:10:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    current = [0, 0, 0]
    flag = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        if flag == 1:
            continue
        judge = int(abs(x-current[1]))+int(abs(y-current[2]))
#        print(judge)
        if t-current[0] < judge:
            flag = 1
        elif t-current[0] == judge:
#            print(t,x,y)
            current[0] = t
            current[1] = x
            current[2] = y
        else:
            ama = t-current[0]
            if (ama-judge)%2 != 0:
                flag = 1
            else:
                current[0] = t
                current[1] = x
                current[2] = y

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



if __name__ == "__main__":
    main()


Measured memory_bytes: 9248
#include <iostream>
#include <vector>

signed main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n, 0);
  int ans = 0;
  for(int i = 0; i < n; i++) {
    std::cin >> a[i];

    if(a[a[i]-1] == i+1)
      ans++;
  }

  std::cout << ans << std::endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int dsum(int x) {
	int ret = 0;
	while(x) {
		ret += x%10;
		x /= 10;
	}
	return ret;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, ans = 10000;
	cin >> N;
	for(int i = 1; i < N; i++) ans = min(ans, dsum(i)+dsum(N-i));
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
def combination_formula(n, r):
    """nCrは、O(min(n-r, r))で実装する
    Notes:
        分子と分母がかなり大きな値になった場合、計算は遅くなるので注意
        求める値がmodをとった値でいい場合、フェルマーの小定理を使った方法が速い。
    """
    if r > n:
        return 0

    r = min(n-r, r)
    bunsi, bunbo = 1, 1
    for i in range(r):
        bunsi = bunsi*(n-i)
        bunbo = bunbo*(i+1)
    return bunsi//bunbo


def solve():
    N, M = list(map(int, input().split()))

    # 奇数＋奇数 または偶数＋偶数
    ans = combination_formula(N, 2) + combination_formula(M,2)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    /*if(a%2==0&&c%2!=0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }*/
    int x;
    int ans=0;
    for(int i=1;i<=b;i++){
        x=i*a;
        if(x%b==c){ 
            ans++;
            break;
        }
    }
    if(ans==0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int length = S.size();
    int sum1 = 0;
    int sum2 = 0;
    bool flag1 = true;
    bool flag2 = false;

    for ( int i = 0; i < length ; i++){
        if  (flag1 == true) {

            if ( (int)(S[i] - '0')  != 1) {
                sum1 += 1;
            }
            flag1 = false;
        } else {
            if ( (int)(S[i] - '0')  != 0) {
                sum1 += 1;
            }
            flag1 = true;
        }
        if  (flag2 == true) {

            if ( (int)(S[i] - '0')  != 1) {
                sum2 += 1;
            }
            flag2 = false;
        } else {
            if ( (int)(S[i] - '0')  != 0) {
                sum2 += 1;
            }
            flag2 = true;
        }
    }

    if ( sum1 < sum2){
        cout << sum1 << endl;
    } else {
        cout << sum2 << endl;
    }
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int n;
vector<vector<bool>> a;
vector<bool> d;
vector<int> s(2);
vector<int> z;

bool ok;

void dfs(int x, int c) {
//    cout << x << " " << c << "\n";
    if (z[x] != 0) {
        if (z[x] != c + 1) {
            ok = false;
        }
    } else {
        z[x] = c + 1;
        s[c]++;
        for (int y = 0; y < n; y++) {
            if (y != x && !a[x][y]) {
                dfs(y, 1 - c);
            }
        }
    };
}

int main() {
    std::ios::sync_with_stdio(false);

    int m;
    cin >> n >> m;
    a.assign(n, vector<bool>(n));
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        a[x][y] = a[y][x] = true;
    }
    d.resize(n + 1);
    z.resize(n);
    d[0] = true;
    ok = true;
    for (int i = 0; i < n; i++) {
        if (z[i] == 0) {
            s[0] = s[1] = 0;
            dfs(i, 0);
//            cout << s[0] << " " << s[1] << "\n";
            for (int j = n; j >= 0; j--) {
                if (d[j]) {
                    d[j] = false;
                    for (int k = 0; k < 2; k++) {
                        d[j + s[k]] = true;
                    }
                }
            }
        }
    }
    if (!ok) {
        cout << "-1\n";
    } else {
        int res = MAX_INT;
        for (int j = 0; j <= n; j++) {
            if (d[j]) {
//                cout << j << " " << (j * (j - 1) + (n - j) * (n - j - 1)) / 2 << "\n";
                res = std::min(res, (j * (j - 1) + (n - j) * (n - j - 1)) / 2);
            }
        }
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
 
// #define LOG(...) printf(__VA_ARGS__)
#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};

#define MAX_W 20
#define MAX_H 20
#define INF INT_MAX

int d[MAX_H][MAX_W];
int w,h,res;

void dfs(int x,int y,int cost){
	REP(i, 4){
		for(int n=1;;n++){
			if(min(10,res)<=cost)
				return;
			int sx=x+dx[i]*n;
			int sy=y+dy[i]*n;
			if(sx<0||w<=sx||sy<0||h<=sy)
				break;
//			LOG("%d %d\n",sx,sy);
			if(d[sy][sx]==3){
				LOG("goal %d\n",cost+1);
				res=min(res,cost+1);
				return;
			}
			if(d[sy][sx]==1){
				int ssx=x+dx[i]*(n-1);
				int ssy=y+dy[i]*(n-1);
	 REP(yy, h){
	 	REP(xx, w){
	 		LOG("%d ",xx==ssx&&yy==ssy?9:d[yy][xx]);
	 	}
		 LOG("  --cost  %d \n",cost);
	}
				if(n>1){
					d[sy][sx]=0;
					dfs(ssx, ssy, cost+1);
					d[sy][sx]=1;
				}
				break;
			}
		}
	}
}

int main(){
	while(cin >> w >> h, w|h){
		fill_n((int*)d, MAX_W*MAX_H, 0);
		int sx,sy;
		res=INF;
		REP(y, h){REP(x, w){
			cin >> d[y][x];
			if(d[y][x]==2){
				sx=x;
				sy=y;
			}
		}}

		dfs(sx, sy, 0);
		if(res==INF)
			cout << -1 << endl;
		else
			cout << res << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

bool isPrime[1000001];
vector<int> primes;
int main(){
   long long N;
   cin >> N;
   memset(isPrime,true,sizeof(isPrime));
   for(int i = 2; i< 1000001; i++){
      if(isPrime[i]==true){
         primes.emplace_back(i);
         for(int j=i+i; j<1000001; j+=i){
            isPrime[j]=false;
         }
      }
   }
   int ans =0;
   for(int p: primes){
      int nxt=0;
      int offset=1;
      int cur=0;
      if(N < p) break;
      if(N%p==0){
         while(N%p==0){
            if(cur==nxt){
               ans++;
               offset++;
               nxt+=offset;
            }
            cur++;
            N/=p;
         }
      }
   }
   if(N!=1) ans++;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 4880
import java.util.Scanner;

public class Main {

	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) p[i] = sc.nextInt() - 1;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(p[i] == i && i != n - 1) {
				ans++;
				swap(p, i);
			} else if(p[i] == i && i == n - 1) {
				ans++;
				swap(p, i);
			}
		}
		System.out.println(ans);
	}

	static int[] swap(int[] p, int pos) {
		if(pos != n - 1) {
			int w = p[pos];
			p[pos] = p[pos + 1];
			p[pos + 1] = w;
		} else {
			int w = p[pos - 1];
			p[pos - 1] = p[pos];
			p[pos] = w;
		}
		return p;
	}

}


Measured memory_bytes: 52796
#include <bits/stdc++.h>
using namespace std;
#define maxn 300000
int n, m, ans, a[maxn], cnt[maxn], f[maxn];

int read() {
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); } 
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k; 
}

int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	for(int i = 1; i <= n; i ++) cnt[a[i]] ++;
	for(int i = 1; i <= n; i ++) {
		if(!cnt[i]) continue;
		for(int j = max(0, i - cnt[i]); j < i; j ++) f[j] ++; 
	}
	for(int i = 0; i < n; i ++) if(!f[i]) ans ++;
	for(int i = 1; i <= m; i ++) {
		int x = read(), y = read();
		if(a[x] - cnt[a[x]] >= 0) {
			f[a[x] - cnt[a[x]]] --; 
			if(!f[a[x] - cnt[a[x]]]) ans ++;
		}
		cnt[a[x]] --; a[x] = y;
		if(y - cnt[y] - 1 >= 0) {
			f[y - cnt[y] - 1] ++;
			if(f[y - cnt[y] - 1] == 1) ans --;
		}
		cnt[y] ++; printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3712
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
    const nums = readNums();
    immutable n = nums[0];
    immutable x = nums[1];
    const m = readRows(n).map!(to!int).array;
    immutable minm = m.minElement;
    writefln("%d", m.length + (x - m.sum) / minm);
}

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

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

NewAB = sorted(AB, key=lambda x: x[1])

for i in range(N):
    time += NewAB[i][0]

    if time > NewAB[i][1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 55256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main() {


	//C
	long long int n;
	long long int MOD = 1000000007;
	cin >> n;
	int i;
	long long int a, b, c;
	a = 1; b = 2; c = 1;
	for (i = 0; i < n; i++) {
		a = a * 10; b = b * 9; c = c * 8;
		a = a % MOD; b = b % MOD; c = c % MOD;
	}
	a = (a - b + MOD) % MOD;
	a = (a + c) % MOD;
	cout << a << endl;
	return 0;

	//B
	/*long long int a, b, c, d;
	cin >> a >> b >> c >> d;

	long long int x[4];
	x[0] = a * c;
	x[1] = a * d;
	x[2] = b * c;
	x[3] = b * d;
	sort(x, x + 4);
	
	
	cout << x[3] << endl;

	return 0;*/
	

	//A
	/*int x;
	cin >> x;
	if (x == 1) {
		cout << 0;
	}
	else {
		cout << 1;
	}
	cout << endl;
	return 0;
	*/

}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

}

class Magatro
{
    private int N;
    private int[] A;

    private void Scan()
    {
        var sc=new Scanner();
        N = sc.NextInt();
        A=new int[N];
        for(int i=0;i<N;i++)
        {
            A[i]=sc.NextInt();
        }
    }

    public void Solve()
    {
        Scan();
        int m=1;
        int a=1;
        foreach(int i in A)
        {
            a*=3;
            if(i%2==0)
            {
                m*=2;
            }
        }
        Console.WriteLine(a-m);
    }

    static public void Main()
    {
        new Magatro().Solve();

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

typedef vector <int> vi;

const greater <int> gt;

int main() {
    int n; cin >> n;
    vi A;
    int u;
    
    while(n--) {
        cin >> u;
        auto it = upper_bound(A.begin(), A.end(), u, gt);
        if(it == A.end()) A.push_back(u);
        else *it = u;
    }
    
    cout << A.size();
    
    return 0;
}

Measured memory_bytes: 892
from math import ceil, log2

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

ans = 0
for i in range(1, N + 1):
    if i >= K:
        ans += 1
    else:
        ans += 1 / (2 ** ceil(log2(K / i)))
    # 最後にNで割る
ans /= N
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    int d,t,s;
    cin >> d >> t >> s;
    if ((d+s-1)/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
double a[maxn];
int main() 
{
	int n,k,x;
	double f;
	cin>>n>>k;
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		f=(double)(x+1)/2.0f;
		a[i]=a[i-1]+f;
	}
	double ans=0;
	for(int i=k;i<=n;i++)
	{
		ans=max(ans,a[i]-a[i-k]);
	}
	printf("%0.12f",ans);
	return 0;
}
	

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M;
    cin >> N >> M;
    vec A(N), s(N+1, 0);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    Rep (i, N) s[i+1] = s[i] + A[i];

    ll ok = 0, ng = 2e5+10;
    while (abs(ok-ng) > 1) {
        ll mid = (ok+ng)/2;
        ll cnt = 0;
        Rep (i, N) {
            cnt += A.end() - lower_bound(A.begin(), A.end(), mid-A[i]);
        }
        if (cnt >= M) ok = mid;
        else ng = mid;
    }

    ll ans = 0, cnt = 0;
    Rep (i, N) {
        ll idx = lower_bound(A.begin(), A.end(), ng-A[i]) - A.begin();
        cnt += N - idx;
        ans += s[N] - s[idx] + (N-idx) * A[i];
    }

    ans += ok * (M - cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int b;
    int c;
    int m;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> m;
    int ans = 0;
    
    for (int x = 0;x < a+1;x++){
        for (int y = 0;y < b+1;y++){
            for (int z = 0;z < c+1;z++){
                if (x*500+y*100+z*50 == m){
                    ans ++;
                } 
            }
        }
    }
    
    cout << ans << endl;
}


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

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
	int a[20],w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
	for (int i = 0; i < 20; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 10; i++) {
		if (w3 < a[i])w3 = a[i];
		if (w2 < w3)swap(w2, w3);
		if (w1 < w2)swap(w2, w1);
	}
	for (int i = 10; i < 20; i++) {
		if (k3 < a[i])k3 = a[i];
		if (k2 < k3)swap(k2, k3);
		if (k1 < k2)swap(k2, k1);
	}
	cout<<w3+w2+w1<<" "<<k1+k2+k3<<endl;
return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<int> cnt(1000001, 0);
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ++cnt[arr[i]];
    }
    sort(all(arr));
    arr.erase(unique(all(arr)), end(arr));
    if (cnt[1] > 0) {
        RET(cnt[1] == 1);
    }
    int ans = n;
    for (int x : arr) {
        if (cnt[x] > 1) {
            ans -= cnt[x];
            continue;
        }
        for (int i = 2; i * i <= x; ++i) {
            if (x % i == 0 && cnt[i] + cnt[x / i] > 0) {
                --ans;
                break;
            }
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

#define ll long long int

typedef pair<ll,ll> pii;

#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vvl vector<vector<ll,ll> >
#define vvs vector<vector<string> >
#define pb push_back
#define mk make_pair
#define sbit(a)  __builtin_popcount(a)
#define f(i,a,n) for(i=a;i<n;i++)
#define fb(i,a,n) for(i=a;i>=n;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define nextp(s) next_permutation(s.begin(), s.end()); 
#define ignor cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define bsearch(a,x) binary_search(a.begin(),a.end(),x)
#define ini ll i,j,k,l,m,n,x,y,sm=0,cnt=0
const ll mod=1e9+7;
const double pi=acos(-1);


bool prime[1000000];
void sieve(ll n) 
{ 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 



ll bs(ll arr[], ll l, ll r, ll x)
{
   if (r >= l)
   {
        ll mid = l + (r - l)/2;
        if (arr[mid] == x)  
            return mid;
        if (arr[mid] > x) 
            return bs(arr, l, mid-1, x);
        return bs(arr, mid+1, r, x);
   }
   return -1;
}




ll moex(ll x,ll n,ll mod)

{
    
	if(n==0)
        
       		return 1;
    
	else if(n%2 == 0)   
        	
		return moex((x*x)%mod,n/2,mod);
    
	else 
              return (x*moex((x*x)%mod,(n-1)/2,mod))%mod;

}


ll modi(ll a, ll m) 
{ 
      	ll k=moex(a, m-2, m); 
	return k;
} 
const ll maximum=99999;
void subString(string s, int n) 
{
    for (int i = 0; i < n; i++) 
        for (int len = 1; len <= n - i; len++)
            cout << s.substr(i, len) << endl;
}


int main()
{
    fast;
    ll n,i,j,k,l;
    cin>>n;
    vector<pair<ll,ll> > points;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        points.pb(mk(j,k));
    }
    
    sort(points.begin(),points.end());
    ll ans = INT_MAX;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            ll p = points[j].first - points[i].first;
            ll q = points[j].second - points[i].second;
            
            // cout<<"P = "<<p<<"  Q = "<<q<<endl;
            
            bool vis[n] = {false};
            memset(vis,false,sizeof(vis));
            ll cost = 0;
            // cout<<"**"<<endl;
            for(k=0;k<n;k++)
            {
                ll x = points[k].first + p;
                ll y = points[k].second + q;
                if(!vis[k])
                {
                    cost++;
                }
                vis[k] = 1;
                
                for(ll ii=k+1;ii<n;ii++)
                {
                    if(points[ii].first == x && points[ii].second == y)
                    {
                        vis[ii] = 1;
                        // cout<<"II = "<<ii<<endl;
                        break;
                    }
                }
            }
            // cout<<"COST = "<<cost<<endl;
            ans = min(ans,cost);
        }
    }
    
    if(n == 1)
        ans = 1;
        
    cout<<ans<<endl;
    
    
    
    
    
    
    return 0;
}

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

const long long INF=1e15;

long long dp[110][100005];

int main(){
    int N,W; cin >> N >> W;
    int w[N],v[N];
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<100002;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=100001;j>=0;j--){
            if(j-v[i]>=0){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            }
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    int ans=0;
    /*
    for(int i=0;i<=N;i++){
        for(int j=0;j<=100;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    for(int i=0;i<100001;i++){
        if(dp[N][i]<=W){
            ans=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 80128
# coding: utf-8

N = int(input())
W = list(map(int, input().split()))
ans = 1e9
sum = 0
sum2 = 0

for i in range(0,N):
    sum += W[i]
    
for i in range(0,N):
    sum2 += W[i]
    if(abs(abs(sum2-sum) - sum2)<ans):
        ans = abs(abs(sum2-sum) - sum2)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>

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

//const ll inf=1000000000000000;

using namespace std;



int main(){
    string S,T;
    cin>>S>>T;
    cout<<T+S<<endl;
}

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

int main() {
	int N, W;
	cin >> N >> W;
	int V = N*1000;
	vector<int> dp(V+1, W+1);
	dp[0] = 0;
	
	for (int i = 0; i < N; ++i) {
		int wi, vi;
		cin >> wi >> vi;
		for (int v = V-vi; v >= 0; --v) {
			dp[v+vi] = min(dp[v+vi], dp[v] + wi);
		}
	}

	int best = 0;
	for (int v = 0; v <= V; ++v) {
		if (dp[v] <= W) {
			best = max(best, v);
		}
	}
	
	cout << best << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int ans1 = 0, ans2 = 0;
  rep(i, m){
    int a;
    cin >> a;
    if(x > a){
      ans1++;
    }else{
      ans2++;
    }
  }
  int ans = min(ans1, ans2);
  cout << ans << endl;
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    cin>>S;
    int size=S.length();
    string P;
    REP(i,size){
        P.push_back('x');
    }
    cout<<P<<endl;
}

Measured memory_bytes: 256