akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <string>
#include <vector>

class Dice
{
public:
	Dice(int* pValue)
	{
		memcpy(m_value, pValue, sizeof(int) * 6);
	}

public:
	Dice Roll(char direction) const
	{
		Dice d = (*this);

		switch (direction)
		{
		case 'N':
		{
			d.m_value[0] = m_value[1];
			d.m_value[1] = m_value[5];
			d.m_value[4] = m_value[0];
			d.m_value[5] = m_value[4];
		}
		break;
		case 'E':
		{
			d.m_value[0] = m_value[3];
			d.m_value[2] = m_value[0];
			d.m_value[3] = m_value[5];
			d.m_value[5] = m_value[2];
		}
		break;
		case 'W':
		{
			d.m_value[0] = m_value[2];
			d.m_value[2] = m_value[5];
			d.m_value[3] = m_value[0];
			d.m_value[5] = m_value[3];
		}
		break;
		case 'S':
		{
			d.m_value[0] = m_value[4];
			d.m_value[1] = m_value[0];
			d.m_value[4] = m_value[5];
			d.m_value[5] = m_value[1];
		}
		break;
		default:
			break;
		}

		return d;
	}

	Dice Spin() const
	{
		Dice d = (*this);

		d.m_value[1] = m_value[2];
		d.m_value[2] = m_value[4];
		d.m_value[3] = m_value[1];
		d.m_value[4] = m_value[3];

		return d;
	}

	int GetTop() const
	{
		return m_value[0];
	}

	int GetFront() const
	{
		return m_value[1];
	}

	int GetRight() const
	{
		return m_value[2];
	}

	bool operator ==(const Dice& rhs) const
	{
		for (int i = 0; i < 6; ++i)
		{
			if (m_value[i] != rhs.m_value[i])
			{
				return false;
			}
		}

		return true;
	}

private:
	int m_value[6];
};

Dice FindTop(const Dice& dice, int top)
{
	if (dice.GetTop() == top)
	{
		return dice;
	}

	Dice d = dice.Roll('S');
	for (int i = 0; i < 3; ++i)
	{
		if (d.GetTop() == top)
		{
			return d;
		}

		d = d.Roll('S');
	}

	d = dice.Roll('E');
	if (d.GetTop() == top)
	{
		return d;
	}

	d = dice.Roll('W');
	if (d.GetTop() == top)
	{
		return d;
	}

	return dice;
}

Dice FindFront(const Dice& dice, int front)
{
	Dice d = dice;
	for (int i = 0; i < 4; ++i)
	{
		if (d.GetFront() == front)
		{
			return d;
		}

		d = d.Spin();
	}

	return d;
}

bool Find(const Dice& dice1, const Dice& dice2)
{
	Dice d2 = dice2;
	d2 = FindTop(d2, dice1.GetTop());
	if (d2.GetTop() != dice1.GetTop())
	{
		return false;
	}

	d2 = FindFront(d2, dice1.GetFront());
	if (d2.GetFront() != dice1.GetFront())
	{
		return false;
	}

	return d2 == dice1;
}

int main(int argc, char** argv)
{
	int count;
	std::cin >> count;

	std::vector<Dice> dices;
	for (int i = 0; i < count; ++i)
	{
		int val[6];
		std::cin >> val[0] >> val[1] >> val[2] >> val[3] >> val[4] >> val[5];
		dices.push_back(Dice(val));
	}

	bool sameDice = false;
	for (int i = 0; i < (count - 1) && (!sameDice); ++i)
	{
		for (int j = i + 1; (j < count) && (!sameDice); ++j)
		{
			sameDice = Find(dices[i], dices[j]);
			if (sameDice)
			{
				int a = 0;
			}
		}
	}

	std::cout << (sameDice ? "No" : "Yes") << std::endl;

	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;
    set<char> st;
    for(auto x:s)st.insert(x);
    if(st.size()==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
def main(n,k,a):
  for _ in range(k):
    b=[0]*(n+1)
    for i,j in enumerate(a):
      b[max(0,i-j)]+=1
      b[min(n,i+j+1)]-=1
    for i in range(n):
      b[i+1]+=b[i]
    if a==b:break
    a=b
  print(*a[:-1])
N,K,*A=map(int,open(0).read().split())
main(N,K,A)

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

using lint = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    lint ans = 0;
    lint w = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            b++;
        } else {
            ans += b;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<string, int>> play;
	
	for (int i=0; i<n; i++) {
		string s; int t;
		cin >> s >> t;
		play.push_back(make_pair(s, t));
	}
	string last; cin >> last;
	int answer = 0;
	for (int j=n-1; j>-1 && play[j].first != last; j--) {
		answer += play[j].second;
	}
	
	cout << answer << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] >= a[i]) {
      ans += a[i];
      b[i] -= a[i];
      a[i] = 0;
    } else {
      ans += b[i];
      a[i] -= b[i];
      b[i] = 0;
    }

    if (b[i] >= a[i+1]) {
      ans += a[i+1];
      b[i] -= a[i+1];
      a[i+1] = 0;
    } else {
      ans += b[i];
      a[i+1] -= b[i];
      b[i] = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int count = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        count += (r - l) + 1;
    }
    cout << count << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int i;
    for (i = 0; pow(2, i + 1) <= n; i++)
    {
    }
    cout << pow(2, i);
#ifdef LOCAL
    cout << "\ni:" << i;
#endif
    return 0;
}

Measured memory_bytes: 256
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);


int main() {
	fast;
	read(a)
	read(m)
	readarr(arr,a);
	sort(arr,arr+a);
	ll sum=0;
	loop(j,0,a)sum+=arr[j];
	loop(i,0,a){
		if((arr[i])>=ceil(double(sum)/(4*m))){
			ll p=a-i;
			if(p>=m) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
			exit(0);
		}
	}
	if(m==0) cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int a,b,c,sum;

int main(void){
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0,temp;i<a;i++){
		scanf("%d",&temp);
		if(temp<b||temp>=c)
			sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define INF 2000000000
using namespace std;

typedef long long ll;


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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll> a(n+1), b(n);
  REP(i, n+1) cin >> a[i];
  REP(i, n) cin >> b[i];

  REP(i, n) {
    ll m;
    m = min(b[i], a[i]);
    a[i]-=m;
    b[i]-=m;
    ans+=m;

    if (b[i] > 0) {
      m = min(b[i], a[i+1]);
      a[i+1]-=m;
      ans+=m;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int n, m, ans = 0;
vector<int> par;
vector<int> siz;

int root(int x) {
  while (x != par[x]) {
    x = par[x];
  }
  return x;
}

bool merge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return false;
  if (siz[x] < siz[y]) swap(x, y);
  siz[x] += siz[y];
  par[y] = x;
  return true;
}

int main() {
  cin >> n >> m;
  par.resize(n);
  siz.resize(n);
  rep(i, n) par[i] = i;
  rep(i, n) siz[i] = 1;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a, b);
  }
  rep(i, m) {
    par.resize(n);
    siz.resize(n);
    rep(k, n) par[k] = k;
    rep(k, n) siz[k] = 1;
    rep(j, m) {
      if (i == j) continue;
      merge(p[j].first, p[j].second);
    }
    if (root(p[i].first) != root(p[i].second)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[101][4][4][4];
 
int main(){
  int N;
  cin>>N;
  dp[0][3][3][3] = 1;
  
  for(int len = 0; len < N; len++){
    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < 4; k++){
          if(dp[len][i][j][k] == 0)continue;
          
          for(int a = 0; a < 4; a++){
            if(a == 2 and i == 1 and j == 0)continue;
             if(a == 2 and i == 0 and j == 1)continue;
             if(a == 1 and i == 2 and j == 0)continue;
             if(a == 2 and i == 1 and k == 0)continue;
             if(a == 2 and j == 1 and k == 0)continue;
            
            dp[len + 1][a][i][j] += dp[len][i][j][k];
            dp[len + 1][a][i][j] %= 1000000007;
          }
        }
      }
    }
  }
  int ans = 0;
   for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < 4; k++){
          ans += dp[N][i][j][k];
          ans %= 1000000007;
        }
      }
   }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  long long W0, R0, C, R;
  while (cin >> R0 >> W0 >> C >> R) {
	if (W0 == 0) break;
	if (R0 >= C * W0) {
	  cout << 0 << endl;
	}
	else {
	  // find minimum x subject to (R0 + R*x) / Wo >= C
	  long long x = (C * W0 - R0 + R-1) / R;
	  cout << x << endl;
	}
  }
}



Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,c5=0,c7=0;
  cin>>a>>b>>c;
  if(a==5)
    c5++;
  else if(a==7)
    c7++;
  if(b==5)
    c5++;
  else if(b==7)
    c7++;
  if(c==5)
    c5++;
  else if(c==7)
    c7++;
  if(c5==2&&c7==1)
    cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int prime(int n) {
	for (int i = 2 ; i < n ; i++) if (n % i == 0) return 0;
	return 1;
}
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int t, x, y;
    int a = 0, b = 0, l = 0;
	for (int i = 0 ; i < n ; i++) {
		cin >> t >> x >> y;
		int k = abs(a - x) + abs(b - y);
		if (t - l < k || ( k - t + l ) % 2) {
			cout << "No";
			return 0;
		}
		a = x;
		b = y;
		l = t;
	}
	cout << "Yes";
}

Measured memory_bytes: 3672
#include <stdio.h>

int main (void)
{
  int i, s, t, n, x, count;
for(;;){

  scanf("%d %d", &n, &x);
  if(n ==0 && x ==0){break;}
count = 0;
for(i =1; i<= n; i++){

  for(t = i+1; t <= n; t++ ){

    for(s = t+1; s <= n; s++){
      if(i + s+ t == x){
  
        count += 1;
      }
    }
  }
}
printf("%d\n", count);

}


  return 0;
}

Measured memory_bytes: 1776
#include <iostream>

using namespace std;

int main()
{
    int n, m, counter = 0;
    cin >> n;
    for (int i = 1 ; i <= n ; i++)
    {
        cin >> m;
        if (m%2 == 1 && i%2 == 1)
            counter++;
    }
    cout << counter;
    return 0;
}


Measured memory_bytes: 3576
N,M=map(int,input().split())
H=list(map(int,input().split()))

import collections
G=collections.defaultdict(list)
for _ in range(M):
    A,B=map(int,input().split())
    G[A].append(B)
    G[B].append(A)

i=1
j=0
while i <=N:
    J=[0]
    for a in G[i]:
        J.append(H[a-1])
    if H[i-1] > max(J):
            j+=1
    i+=1
    
print(j)

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

int a[300001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=3*n;i++)
		cin>>a[i];
	long long int ans=0;
	sort(a+1,a+n+n+n+1);
	for(int i=n+1;i<=3*n;i+=2)
		ans+=a[i];
	cout<<ans<<endl;
}


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

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

int main(void){
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans1, ans2, ans3, ans;
    ans1 = a+b;
    ans2 = b+c;
    ans3 = a+c;
    ans = ans1;
    if(ans > ans2){
        ans = ans2;
    }
    if(ans > ans3){
        ans = ans3;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc133/tasks/abc133_d

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;

struct C {
    vector<ll> V_;
    explicit C(vector<ll> V) : V_(move(V)) {}
    vector<ll> f() {
        vector<ll> R;
        ll u0 = 0;
        ll N = V_.size() ;
        for (int i=0; i < (N-1) / 2; ++i) {
           u0 += V_[2*i] - V_[2*i+1];
        }
        u0 += V_[N-1];
        u0 /= 2;

        R.emplace_back(u0);

        for (int i=1; i < N; ++i) {
            R.emplace_back(V_[i-1] - R[i-1]);
        }
        vector<ll> ret;
        transform(R.begin(), R.end(), back_inserter(ret), [](auto x){ return x*2;});
        return ret;
    }
};

int main() {
    ll N;
    cin >> N;
    vector<ll> v;
    v.resize(N);
    for (int i=0; i < N; ++i) {
        cin >> v[i];
    }
    C c{move(v)};
    auto R = c.f();
    for (auto&& r : R) {
        cout << r << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3316
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
    long long a; cin >> a;
    string s; cin >> s;
    
    long long b = s[0] - '0';
    b = b * 10 + s[2] - '0';
    b = b * 10 + s[3] - '0';
    
    cout << (a * b) / 100;
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n,ans,du[N],f[N];
vector<int>g[N];
char s[N];
queue<int>q;
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1)+1;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='<')
		{
			g[i].push_back(i+1);
			du[i+1]++;
		}
		else{
			g[i+1].push_back(i);
			du[i]++;
		}
	}
	for(int i=1;i<=n;i++)
		if(du[i]==0)q.push(i);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=0;i<g[u].size();i++)
		{
			int v=g[u][i];
			du[v]--;
			f[v]=max(f[v],f[u]+1);
			if(du[v]==0)q.push(v);
		}
	}
	for(int i=1;i<=n;i++)ans+=f[i];
	cout<<ans;
}

Measured memory_bytes: 50176
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, b , m = IN()
	al=list(IN())
	bl=list(IN())
	mm=min(al)+min(bl)
	for _ in range(m):
		x,y,c=IN()
		cc = al[x-1]+bl[y-1]-c
		mm = min(mm,cc)
	return mm
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 67948
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Set<Integer> set = new HashSet<>();
		int gcd = a[0];
		boolean p = true;
		for (int i = 0; i < n; i++) {
			Map<Integer, Integer> map = bunkai(a[i]);
			for (Integer o : map.keySet()) {
				if (!set.add(o)) {
					p = false;
				}
			}
			gcd = gcd(gcd, a[i]);
		}
		if (p) {
			System.out.println("pairwise coprime");
		} else if (gcd == 1) {
			System.out.println("setwise coprime");
		} else {
			System.out.println("not coprime");
		}
	}

	static Map<Integer, Integer> bunkai(int n) {
		Map<Integer, Integer> soinsu = new HashMap<>();
		int end = (int) Math.sqrt(n);
		int d = 2;
		while (n > 1) {
			if (n % d == 0) {
				n /= d;
				if (soinsu.containsKey(d)) {
					soinsu.put(d, soinsu.get(d) + 1);
				} else {
					soinsu.put(d, 1);
				}
				end = (int) Math.sqrt(n);
			} else {
				if (d > end) {
					d = n - 1;
				}
				d++;
			}
		}
		return soinsu;
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}


Measured memory_bytes: 143544
import java.util.*;
import java.io.*;
public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		double d=inp.nextDouble();
		double t=inp.nextDouble();
		double s=inp.nextDouble();
		System.out.println(d/s<=t?"Yes":"No");
		
	}
    
    
		
}


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

public class Main {
	public static void main(String[] args) {
		int xmin=0,ymin=0;
		Scanner sc=new Scanner(System.in);
		Integer[] info=Arrays.asList(sc.nextLine().split(" ")).stream().map(Integer::valueOf).toArray(Integer[]::new);
		int xmax=info[0],ymax=info[1];
		while(sc.hasNextLine()) {
			String[] action=sc.nextLine().split(" ");
			int xi=Integer.parseInt(action[0]);
			int yi=Integer.parseInt(action[1]);
			switch(action[2]) {
			case "1":
				xmin=xmin>xi?xmin:xi;
				break;
			case "2":
				xmax=xmax<xi?xmax:xi;
				break;
			case "3":
				ymin=ymin>yi?ymin:yi;
				break;
			case "4":
				ymax=ymax<yi?ymax:yi;
				break;
			}
		}
		int area=(xmax-xmin>0&&ymax-ymin>0)?(xmax-xmin)*(ymax-ymin):0;
		System.out.println(area);
	}
}

Measured memory_bytes: 27464
#include <stdio.h>

int n, k;
int cnt;

int main(void) {
    cnt=1;
    scanf("%d%d", &n, &k);
    
    for(int i=1; i<n; i++) {
        cnt*=(k-1);
    }
    cnt*=k;
    
    printf("%d", cnt);
    
    return 0;
}

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
}


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

int main() {
	// your code goes here
   int n, j=0,x,p=0;
   cin>>n;
   string s;
   cin>>s;
   while(j<(n-2)){
   	if(s[j]=='A' && s[j+1]=='B' && s[j+2]=='C')
   	{
   		p++;
   		j=j+3;
   	}
   	else
   	j++;
   }
   cout<<p;
	return 0;
}

Measured memory_bytes: 3600
a = int(input())
b = input().split()
b.append(10**10)
c = []
n = 0
for i in range(a):
  if int(b[i]) >= int(b[i+1]):
    n += 1
  else:
    c.append(n)
    n = 0
print(max(c))
    
    

Measured memory_bytes: 11132
N,X=map(int,input().split())
m = [0]*N
for i in range(N):
    m[i] = int(input())
#全部一個作る
kona = 0
for i in range(N):
    kona += m[i]
donuts = N

minkona = min(m)
donuts += int((X-kona)/minkona)
print(donuts)


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

int N, A, B, C, mini = 100000, l[8];

void loop(int a, int b, int c, int mp, int num){
	if(num == N){
		if(a == 0 || b == 0 || c == 0)
			return;
		else{
			mp += (abs(A-a)+abs(B-b)+abs(C-c));
			mini = mp < mini ? mp : mini;
			return;
		}
	}
	else{
		if(a != 0)
			loop(a+l[num], b, c, mp+10, num+1);
		else
			loop(a+l[num], b, c, mp, num+1);
		if(b != 0)
			loop(a, b+l[num], c, mp+10, num+1);
		else
			loop(a, b+l[num], c, mp, num+1);
		if(c != 0)
			loop(a, b, c+l[num], mp+10, num+1);
		else
			loop(a, b, c+l[num], mp, num+1);
		loop(a, b, c, mp, num+1);
	}
}

int main(void) {
	cin >> N >> A >> B >> C;
	for(int i = 0; i < N; i++){
		cin >> l[i];
	}
	loop(0,0,0,0,0);
	cout << mini << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = int(1e9+7)

h, w = map(int, input().split())
dp = [[0]*w for i in range(h)]
dp[-1][-1] = 1

g = []

for i in range(h):
    g.append([i for i in input()])

for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if i == h-1 or j == w-1:
            if g[i][j] == "#":
                dp[i][j] = 0
            elif i == h-1 and j != w-1:
                dp[i][j] = dp[i][j+1]
            elif j == w-1 and i != h-1:
                dp[i][j] = dp[i+1][j]
        else:
            if g[i][j] == "#":
                dp[i][j] = 0
            else:
                dp[i][j] = dp[i+1][j] + dp[i][j+1]
                
        dp[i][j] %= MOD
                
                
print(dp[0][0])
                

Measured memory_bytes: 90844
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            int[] h = new int[n];
            str= Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++) h[i] = int.Parse(str[i]);

            int[] good = new int[n];
            for (int i = 0; i < n; i++) good[i] = 1;

            for(int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0])-1;
                int b = int.Parse(str[1])-1;
                if (h[a] <= h[b]) good[a] = 0;
                if (h[b] <= h[a]) good[b] = 0;
            }

            Console.WriteLine(good.Sum());
            //ここまで
        }

        static long Max(long a, long b)
        {
            if (a > b) return a;
            else return b;
        }


    }

}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n);
    int max1 = 0;
    int max2 = 0;
    rep (i, 0, n) {
	cin >> a[i];
	if (max1 <= a[i]) {
	    max2 = max1;
	    max1 = a[i];
	} else if (max2 <= a[i]) {
	    max2 = a[i];
	}
    }

    rep (i, 0, n) {
	if (a[i] == max1)
	    cout << max2 << endl;
	else
	    cout << max1 << endl;
    }

    return 0;
}


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

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    
    int a_min(1000000),b_min(1000000),a[A],b[B];
    for(int i=0;i<A;i++){
        cin >> a[i];
        a_min = min(a[i],a_min);
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
        b_min = min(b[i],b_min);
    }
    
    int ans = a_min + b_min;
    
    for(int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >> c;
        
        ans = min(ans,a[x-1]+b[y-1]-c);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4392
#include<iostream>

int main(){
 int W, H, x, y, r;
 std::cin>>W>>H>>x>>y>>r;
 if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
 std::cout<<"Yes"<<"\n";
 } else {
 std::cout<<"No"<<"\n";
 }

 return 0;
}
 

Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

char a[110];
int b[110];

int main()
{
    int l,i;
    scanf("%d",&l);
    scanf(" %s",a);
    for(i=0;i<=l;i++)
    {
        if(a[i]=='I') b[i+1]=b[i]+1;
        else if(a[i]=='D') b[i+1]=b[i]-1;
    }
    sort(b,b+l+1);
    printf("%d",b[l]);
    return 0;
}

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

int main () {
  vector<vector<long long> > ans;
  long long n, m;
  cin >> n >> m;
  ans.resize(n);
  vector<long long> ss, yy;
  for (long long  i = 0; i < m; i++) {
    long long sub, year;
    cin >> sub >> year;
    ss.push_back(sub);
    yy.push_back(year);
    ans[sub - 1].push_back(year);  
  } 
  for (long long i = 0; i < n; i++) {
    sort(ans[i].begin(), ans[i].end());    
  }
  vector<map<long long, long long> >  order;
  order.resize(n);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < ans[i].size(); j++) {
      order[i][ans[i][j]] = j;
    }  
  }
  for (int i = 0; i < m; i++) {
    string last = to_string(order[ss[i] - 1][yy[i]] + 1);
    while (last.size() <= 5) {
      last = "0" + last;    
    }
    string first = to_string(ss[i]);
    while (first.size() <= 5) {
      first = "0" + first;  
    }
    cout << first + last << endl;
  }
}

Measured memory_bytes: 19432
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    IN(ll, K);
    REP(i, K)
    {
        if (C <= B)
        {
            C *= 2;
        }
        else if (B <= A)
        {
            B *= 2;
        }
    }
    YES(C > B and B > A);
}

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

struct StGate
{
  StGate() : 
    m_nPassLow(0), m_nPassHigh(0) { }

  int m_nPassLow;
  int m_nPassHigh;
};

void fnInput(vector<StGate>& rvoGate)
{
  int  nPassSiz, nGateSiz;
  cin >> nPassSiz >> nGateSiz;
  rvoGate.resize(nGateSiz);

  for (StGate& roGate : rvoGate)
    cin >> roGate.m_nPassLow >> roGate.m_nPassHigh;
}

int fnAlmightyPass(const vector<StGate>& cnrvoGate)
{
  int nAlmightyPassLow = 0;
  int nAlmightyPassHigh = 100001;

  for (StGate oGate : cnrvoGate)
  {
    nAlmightyPassLow  = max(nAlmightyPassLow,  oGate.m_nPassLow);
    nAlmightyPassHigh = min(nAlmightyPassHigh, oGate.m_nPassHigh);
  }
  return max(0, nAlmightyPassHigh - nAlmightyPassLow + 1);
}
  
int main()
{
  vector<StGate> voGate;

  fnInput(voGate);
  cout << fnAlmightyPass(voGate) << endl;

  return 0;
}

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

int main() {
  int N, X, m[110];
  int p = 0;
  int min = 1010;
  cin >> N >> X;
  for(int i = 0; i < N; ++i){
    cin >> m[i];
    p += m[i];
    if(m[i] < min) min = m[i];
  }
  int rest = X - p;
  int b = rest/min;
  cout << b+N << endl;
}

Measured memory_bytes: 256
import fs = require('fs')
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')

const [N, X] = input[0].split(' ').map(Number)


const L = input[1].split(' ').map(Number)

let s = 1
let p = 0
for (const l of L) {
    p += l
    if (p > X) { break }
    s++
}
console.log(s)

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  string s;
  cin >> s;

  for(ll i = 0; i < s.size(); i += 2){
    string t = s.substr(i, 2);
    if(t == "hi") continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
using namespace std;

complex<double> crd[1000];

void set(){
    crd[0] = complex<double>(1,0);
    complex<double> u(0, 1);
    for(int i = 0; i < 999; i++){
        crd[i+1] = crd[i] + crd[i]*u/abs(crd[i]);
    }
}

int main(){
    set();
    int n;
    while( scanf("%d", &n), n > 0 ){
        printf("%.2lf\n%.2lf\n", crd[n-1].real(), crd[n-1].imag());
    }
    return 0;
}

Measured memory_bytes: 1104
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n;
char mat[650][650];
ll count(ll x, ll y) {// count on diagonal
	ll bad = 0, cnt = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			bad += mat[i+x][j+y]!=mat[j+x][i+y];
	cnt += (bad == 0);
	while(x+1<n&&y+1<n) {
		for(int i = 0; i < n; i++)
			bad -= mat[x][y+i]!=mat[x+i][y];
		for(int i = 0; i < n; i++)
			bad += mat[x+n][y+i]!=mat[x+i][y+n];
		++x, ++y;
		cnt += (bad == 0);
	}
	return cnt;
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++) {
			cin >> mat[i][j];
			mat[n+i][n+j]=mat[n+i][j]=mat[i][n+j]=mat[i][j];
		}
	ll ans = 0;
	for(int i = 0; i < n; i++)
		ans += count(0, i);
	for(int i = 1; i < n; i++)
		ans += count(i, 0);
	cout << ans;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int e;

    while (cin >> e, e) {
        int min_a = 1000000;
        int z_, y_;

        for (int z = 0; z * z * z <= e; z++)
            for (int y = 0; y * y + z * z * z <= e; y++) {
                if (min_a > z + y + e - y * y - z * z * z)  {
                    min_a = z + y + e - y * y - z * z * z;
                    z_ = z;
                    y_ = y;
                }
            }
        cout << e - y_ * y_ - z_ * z_ * z_ + y_ + z_ << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<unordered_map>
#include<utility>
template<typename T>
class UnionFind {
 public:
  void unite(const T& a, const T& b) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y);
    parent_[y] = x;
    if(rank_[x] == rank_[y]) rank_[x] += 1;
  }
  T find(const T& x) {
    if(!parent_.count(x)) {
      rank_[x] = 1;
      return parent_[x] = x;
    }
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> rank_;
};

#include<bits/stdc++.h>
using namespace std;

int sum(auto v) {
  return accumulate(begin(v), end(v), 0, [](auto sum, auto i) {return sum ^= i;});
}

bool neq(auto a, auto b) {
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  return a != b;
}

int solve(auto a, auto b) {
  a.emplace_back(sum(a));
  b.emplace_back(sum(b));

  if(neq(a, b)) return -1;

  auto res = 0;
  set<int> used;
  UnionFind<int> g;
  for(auto i = 0; i < a.size() - 1; ++i) if(a[i] != b[i]) {
    ++res;
    used.emplace(a[i]);
    used.emplace(b[i]);
    g.unite(b[i], a[i]);
  }
  used.emplace(a.back());
  used.emplace(b.back());
  g.unite(b.back(), a.back());
  return res + count_if(begin(used), end(used), [&](auto i) {return i == g.find(i);}) - 1;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for(auto p: {&a, &b}) for(auto& i: *p) cin >> i;
  cout<< solve(a, b) << endl;
}


Measured memory_bytes: 14732
#include<bits/stdc++.h>
using namespace std;
#define    bit(a)          __builtin_popcount(a)
#define    all(x)           x.begin(), x.end()
#define    minv(v)         *min_element(all(v))
#define    maxv(v)         *max_element(all(v))
#define    unq(v)           sort(all(v)),v.erase(unique(all(v)),v.end())
#define    w(x)             while(x--)
#define    rep(i,a,b)       for(i=a;i<=b;i++)
#define    ll               long long
#define    pb               push_back
#define    vii              vector<int>
#define    vll              vector<ll>
#define    vcc              vector<char>
#define    sii              set<int>
#define    sll              set<ll>
#define    scc              set<char>
#define    li               list<int>
#define    pii              pair<int,int>
#define    pll              pair<ll,ll>
#define    mii              map<int,int>
#define    mll              map<ll,ll>
#define    fill(arr,x)      memset(arr,x,sizeof(arr))
#define    gcd(a,b)         __gcd(a,b)
#define    lcm(a,b)        (a*(b/gcd(a,b)))
#define    srtc(a,b)        sort(a,a+b,greater<int>())
#define    pi               acos(-1.00)
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*
//find the position of 0 or 1 in binary representation
int zero(int n)
{
    int i=1,pos=0;
    while(n)
    {
        if(n%2==0)pos=i;
        n/=2;
        i++;
    }
    return pos;
}
*/
int t;
string s;
int main()
{
    _ios;
    ll n,mx=-1,x;
    cin>>n;
    mll mark;
    sll s;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        mx=max(mx,x);
        mark[x]++;
        s.insert(x);
    }
    for(auto it:s)
    {
        if(mark[it]>1)n-=mark[it];
        for(ll i=it*2;i<=mx;i+=it)
        {
            if(mark[i])
            {
                n-=mark[i];
                mark[i]=0;
            }
        }
    }
    cout<<n<<endl;
    return 0;
}




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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  if (A*N >= B) {
    cout << B << endl;
  }
  
  if (A*N < B) {
    cout << A*N << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
listH=list(map(int,input().split()))
costH=[0,abs(listH[0]-listH[1])]
for i in range(2,N):
  costH+=[min(costH[i-1]+abs(listH[i]-listH[i-1]),costH[i-2]+abs(listH[i]-listH[i-2]))]
ans=costH[N-1]
print(ans)

Measured memory_bytes: 13928
import bisect
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
ans = 0

for i in range(0,n-1): #aにたいし
  for j in range(i+1,n):
    #print(i,j)
    tmp1 = List2[i]
    tmp2 = List2[j]
    
    a=bisect.bisect_left(List2,tmp1+tmp2)
    ans += a -j-1
    #print(a,List2,tmp1,tmp2,j,ans)
print(ans)


Measured memory_bytes: 43868
import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser [(Int,Int)]
parse = do
    n<-parseInt
    replicateM n parseInt2

main=do
    tas<-fromJust.evalStateT parse <$> B.getContents
    print.liftM2 (+) fst snd.foldl1 f $ tas

f (u,v) (t,a) = (t*n, a*n)
    where
        n = maximum [(u+v+t+a-1)`div`(t+a), (u+t-1)`div`t, (v+a-1)`div`a]


Measured memory_bytes: 1276
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
//const int mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	string n;cin>>n;
	if(n[0]=='7'||n[1]=='7'||n[2]=='7'){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    char a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    if(a == f && b == e && c == d){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    string s;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        if(s[i]!='h'||s[i+1]!='i'){
            fin("No");
            return 0;
        }
    }
    fin("Yes");

}


Measured memory_bytes: 256
local day = io.read("*n")
local c = {}
for i = 1, 26 do
  c[i] = io.read("*n")
end
local s = {}
for id = 1, day do
  s[id] = {}
  for i = 1, 26 do
    s[id][i] = io.read("*n")
  end
end

local scores = {}
local penalties = {}
for i = 1, 26 do
  scores[i] = 0
  penalties[i] = 0
end
local function solveAll(t)
  local lastday = {}
  for i = 1, 26 do lastday[i] = 0 end
  for id = 1, day do
    local pid = t[id]
    scores[pid] = scores[pid] + s[id][pid]
    lastday[pid] = id
    for i = 1, 26 do
      penalties[i] = penalties[i] + c[i] * (id - lastday[i])
    end
  end
end
local function solveDiff(t, iday, pto)
  local pfrom = t[iday]
  scores[pfrom] = scores[pfrom] - s[iday][pfrom]
  scores[pto] = scores[pto] + s[iday][pto]
  t[iday] = pto
  penalties[pfrom] = 0
  penalties[pto] = 0
  local ld = {}
  for i = 1, 26 do ld[i] = 0 end
  for id = 1, day do
    local p = t[id]
    ld[p] = id
    for ip = pfrom, pto, (pto - pfrom) do
      penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])
    end
  end
end

local function solveSum()
  local z = 0
  for i = 1, 26 do z = z + scores[i] - penalties[i] end
  return z
end

local t = {}
for id = 1, day do
  t[id] = io.read("*n")
  -- t[id] = 1 + (id % 26)
end
solveAll(t)
local score = solveSum()
local m = io.read("*n")
for i = 1, m do
  local d, q = io.read("*n", "*n")
  solveDiff(t, d, q)
  print(solveSum())
end
os.exit()

math.randomseed(1)
local iter = 1
local random = math.random
while os.clock() < 1.85 do
  iter = iter + 1
  local changeday = random(1, 365)
  local changeto = random(1, 25)
  local changefrom = t[changeday]
  if changefrom <= changeto then
    changeto = changeto + 1
  end
  solveDiff(t, changeday, changeto)
  local tmp = solveSum()
  if score < tmp then
    score = tmp
  else
    solveDiff(t, changeday, changefrom)
  end
end
-- print(iter)
print(table.concat(t, "\n"))


Measured memory_bytes: 3116
<?php
list($x, $n) = explode(" ", trim(fgets(STDIN))); 
$p = explode(" ", trim(fgets(STDIN)));
$max = $x;
$min = $x;
for($i=0; $i<101; $i++){
  if(in_array($max, $p)) $max++;
  if(in_array($min, $p)) $min--;
}
if($x-$min > $max-$x) echo $max;
else echo $min;

Measured memory_bytes: 16156