akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

map<ll,ll>a;
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		ll z;
		cin>>z;
		z*=-1;
		a[z]++;
	}
	for(int i=0;i<m;i++){
		ll l,r;
		cin>>l>>r;
		r*=-1;
		a[r]+=l;
	}
	ll ans=0,cnt=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        ll now= itr->first;           // キーを表示
        ll bal= itr->second;    // 値を表示
        cnt+=bal;ans+=now*bal;
        if(cnt>=n){
        	ans-=now*(cnt-n);
        	break;
        }
    }
	cout <<ans*-1;
}

Measured memory_bytes: 12800
#include<stdio.h>
int i;
char s[101];
int main(){
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(i%2==0&&s[i]=='L'||i%2==1&&s[i]=='R'){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

ll mul(ll a, ll b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll sub(ll a, ll b) {
    ll aux = ((a % MOD) - (b % MOD)) % MOD;
    if(aux < 0) aux += MOD;
    return aux;
}

ll add(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll expMod(ll a, ll b) {
    if(b == 0) return 1;
    if(b == 1) return a;
    if(b & 1LL) return mul(a, expMod(a, b-1));
    ll aux = expMod(a, b/2LL);
    return mul(aux, aux);
}

int main() {
    ios_base::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    ll resp[k+1];
    for(ll i = k; i >= 1; i--) {
        ll contrib = expMod(k/i, n);
        for(ll j = 2; j * i <= k; j++) {
            contrib = sub(contrib, resp[i*j]);
        }
        resp[i] = contrib;
        contrib = mul(i, contrib);
        ans = add(ans, contrib);
    }
    cout << ans << "\n";
}


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

int main()
{
 int a,b;
  cin >> a >> b;
  
  string sa = "";
  for (int i = 0;i < b;i++)
  {
    sa += to_string(a);
  }
    string sb = "";
  for (int i = 0;i < a;i++)
  {
    sb += to_string(b);
  }
  if (sa < sb)
    cout << sa << endl;
  else
    cout << sb << endl;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){
    
    ll x;
    cin >> x;

    map<ll, int> m;

    rep(i, 305){
        m[i * i * i * i * i] = i;
        m[i * i * i * i * i * (-1)] = -1 * i;
    }

    for(auto tmp : m){
        ll tmpn = tmp.first;
        ll tmpi = tmp.second;

        if(m.find(x - tmpn) != m.end()){
            cout << m[x - tmpn] << " " <<  -1 * tmpi << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3672
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n, m, a;
		while (true) {
			n = sc.nextInt(); m = sc.nextInt(); a = sc.nextInt();
			if (n == 0) break;
			int[][] amida = new int[n+1][1001];
			for (int i = 0; i < m; i++) {
				int h = sc.nextInt(), p = sc.nextInt(), q = sc.nextInt();
				amida[p][h] = q;
				amida[q][h] = p;
			}
			int index = a;
			for (int i = 1000; i >= 0; i--) {
				if (amida[index][i] > 0)
					index = amida[index][i];
			}
			out.println(index);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 66796
#include <stdio.h>

#define MAXCOUNT 1000000
#define MAXINTERVAL 100

//一定の間隔の要素を並び替える
int insertion_sort(int array[MAXCOUNT], int size, int interval);

int main(void)
{
	//sizeは入力されるデータの個数、order_countはソートで計算した回数、interval_countはinsertion_sortを呼び出す回数
	int i, size, order_count, interval_count;
	//intervalは並び替える要素の間隔を格納
	int interval[MAXINTERVAL];
	static int array[MAXCOUNT];

	scanf("%d", &size);

	interval_count = 0;
	//最終的に間隔は1となる
	interval[0] = 1;
	//データの入力と間隔を設定
	for(i = 0; i < size; i++){
		scanf("%d", &array[i]);

		if(((3 * interval[interval_count] + 1) <= size)){
			interval[interval_count + 1] = 3 * interval[interval_count] + 1;
			interval_count++;
		}
	}

	//挿入ソートを呼び出し要素を並び替える
	order_count = 0;
	for(i = interval_count; i >= 0; i--){
		order_count += insertion_sort(array, size, interval[i]);
	}

	//挿入ソートを呼び出した回数を表示
	printf("%d\n", interval_count + 1);
	//並び替えた要素の間隔を表示
	for(i = interval_count; i > 0; i--){
		printf("%d ", interval[i]);
	}
	printf("%d\n", interval[i]);

	//計算した回数を表示
	printf("%d\n", order_count);

	//並び替えた結果を表示
	for(i = 0; i < size; i++){
		printf("%d\n", array[i]);
	}

	return 0;
}

int insertion_sort(int array[MAXCOUNT], int size, int interval)
{
	//i、jは繰り返し変数、countは計算回数を、tempは挿入するデータを格納
	int i, j, count, temp;

	count = 0;
	for(i = interval; i < size; i++){
		//コピーを取る
		temp = array[i];
		j = i - interval;
		while(j >= 0 && array[j] > temp){
			//データをずらす
			array[j + interval] = array[j];
			j -= interval;
			count++;
		}
		array[j + interval] = temp;
	}

	return count;
}


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    string s;
    int ans = 0;
    cin >> s;
    rep(i, s.size()/2){
        if(s[i]!=s[s.size()-i-1])ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
vector<ll> A;
const int MAX_M = 300010;
ll left_sum, right_sum;
priority_queue<pair<ll, ll>> left_que, right_que;
bool right_idx[MAX_M];
int main() {
  cin >> N;
  M = 3 * N;
  A.resize(M);
  for (auto &val : A) {
    cin >> val;
  }
  // left
  for (int i = 0; i < N; i++) {
    left_sum += A[i];
    left_que.emplace(mp(-A[i], i));
  }
  // right
  for (int i = N; i < M; i++) {
    right_que.emplace(mp(-A[i], i));
  }
  int cnt = 0;
  while (cnt < N) {
    auto p = right_que.top();
    right_que.pop();
    int val = -p.first;
    int idx = p.second;
    right_sum += val;
    right_idx[idx] = true;
    cnt++;
  }
  ll result = left_sum - right_sum;

  for (int i = N; i < M; i++) {
    if (left_que.empty() or right_que.empty()) {
      break;
    }
    if (right_idx[i] > 0) {
      right_sum -= A[i];
      right_idx[i] = false;
      auto right_min = right_que.top();
      right_que.pop();
      int right_min_val = -right_min.first;
      int right_min_idx = right_min.second;
      while (right_min_idx <= i) {
        if (right_que.empty()) {
          goto end;
        }
        auto right_min = right_que.top();
        right_que.pop();
        right_min_val = -right_min.first;
        right_min_idx = right_min.second;
      }
      right_sum += right_min_val;
      right_idx[right_min_idx] = true;
    }

    left_sum += A[i];
    left_que.emplace(mp(-A[i], i));
    auto left_min = left_que.top();
    left_que.pop();
    int left_min_val = -left_min.first;
    left_sum -= left_min_val;

    result = max(result, left_sum - right_sum);
  }
end:;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 10352
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
	int n,m,x;
	int s1=0,s2=0;
	cin>>n>>m>>x;
	while(m--){
		int a;
		cin>>a;
		if(a<x)s1++;
		else s2++;
	}
	cout<<min(s1,s2)<<endl;
}

Measured memory_bytes: 256
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

// http://noshi91.hatenablog.com/entry/2019/03/31/174006

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

using mint = modint<1000000000 + 7>;
mint solve(int r, int c) {
  auto n = r + c + 2;
  vector<mint> fac(n), inv(n);
  fac[0] = 1;
  for (int i = 1; i < n; i++) {
    // fac[i] = mint(i) * fac[i - 1];
    fac[i] = fac[i - 1] * i;
  }
  inv[n - 1] = mint(1) / fac[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1);
  }
  auto binom = [&](int a, int b) -> mint {
    if (a < 0 or b < 0) return 0;
    if (a < b) return 0;
    return fac[a] * inv[b] * inv[a - b];
  };
  auto countPath = [&](int a, int b) { return binom(a + b, b); };
  auto res = mint(0);
  for (int i = 0; i <= r; i++) {
    res = res + countPath(i + 1, c);
  }
  return res;
}

int main() {

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  auto ans = solve(r2, c2);
  ans = ans - solve(r1 - 1, c2);
  ans = ans - solve(r2, c1 - 1);
  ans = ans + solve(r1 - 1, c1 - 1);
  cout << ans.a << endl;

  return 0;
}


Measured memory_bytes: 31488
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int l,r,d;
	cin>>l>>r>>d;
	int x=(l+d-1)/d*d;
	int y=r/d*d;
	cout<<(y-x)/d+1;
}

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


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(void)
{
    int N;

    cin >> N;

    int cnt = 0;
    bool f = false;
    for (int i = 0; i < N; i++) {
        int D1, D2;
        cin >> D1 >> D2;
        if (D1 == D2) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            f = true;
        }
    }
    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

uint64_t gcd(uint64_t u, uint64_t v) {
  while (v != 0) {
    uint64_t r = u % v;
    u = v;
    v = r;
  }
  return u;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = gcd(a[0], a[1]);
  for (int i = 1; i < n; ++i) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << "\n";
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int K,X;

  cin>>K>>X;

  for(int i=X-K+1;i<X+K;i++){
    cout<<i;

    if(i==X+K-1){
      cout<<endl;
    }else{
      cout<<" ";
    }
  }
  
  
  return 0;

  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[3][3];
	for(int i=0;i<3;i++) for(int j=0;j<3;j++) cin>>a[i][j];
	for(int a0=0;a0<=100;a0++)
	{
		int b0=a[0][0]-a0;
		int b1=a[0][1]-a0;
		int b2=a[0][2]-a0;
		int a1=a[1][0]-b0;
		int a2=a[2][0]-b0;
		if(a1+b1==a[1][1] && a2+b2==a[2][2] && a1+b2==a[1][2] && a2+b1==a[2][1])
		{
            cout<<"Yes\n";
            return 0;
        }
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
int main(void){
     int count[26]={0}; 
     char ch; 
     int i, num; 
     while(scanf("%c", &ch)!=EOF){ 
         if(islower(ch)){ 
             num=ch-'a'; 
         }else if(isupper(ch)){ 
             num=ch-'A'; 
         }else{ 
             continue; 
         } 
         count[num]++; 
         } 
     for(i=0;i<26;i++){ 
         printf("%c : %d\n", 'a'+i, count[i]); 
     } 
     return 0; 
 } 




Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    int n,q; cin>>n>>q;
    multimap<int, int> tree;
    for(int i=0; i<n-1; i++){
        int a,b; cin>>a>>b;
        a--; b--;
        tree.emplace(a,b);
        tree.emplace(b,a);
    }
    ll count[n];
    for(int i=0; i<n; i++)
        count[i] = 0;
    for(int i=0; i<q; i++){
        int p; cin>>p;
        p--;
        ll x; cin>>x;
        count[p] += x;
    }
    bool flag[n];
    for(int i=0; i<n; i++)
        flag[i] = false;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int tmp = que.front();
        que.pop();
        flag[tmp] = true;
        auto p = tree.equal_range(tmp);
        for(auto itr=p.first; itr!=p.second; itr++){
            if(!flag[itr->second]){
                count[itr->second] += count[tmp];
                que.push(itr->second);
            }
        }
    }
    //for(int i=0; i<n; i++){
    //    auto p = tree.equal_range(i);
    //    for(auto itr=p.first; itr!=p.second; itr++)
    //        count[itr->second] += count[i];
    //}
    for(int i=0; i<n; i++)
        cout << count[i] << " ";
    cout << endl;
}


Measured memory_bytes: 23552
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    map<char, int> mci;
    int N;
    char c;

    cin >> N;
    REP(i, N) {
        cin >> c;
        mci[c]++;
    }
    if (mci.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
(N, Y) = map(lambda x: int(x), input().split(' '))
Y /= 1000

limit = 10*N

if limit < Y:
    print(-1, -1, -1) 
    exit(0)
elif Y == limit:
    print(N, 0, 0)
    exit(0)

_N = limit-Y
for i in range(0, int(_N/9)+1):
    yy = _N - 9*i 
        
    if yy % 5 == 0:
        k = int(yy/5)
        if N-k-i >= 0:
            print(N-k-i, k, i)
            exit(0)

print(-1, -1, -1) 

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",b+c-a>0?b+c-a:0);
	
	return 0;
}

Measured memory_bytes: 128
use whiteread::parse_line;

fn main() {
    let _n: u32 = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();
    let mut ans: u32 = std::u32::MAX;

    for mut x in a {
        let mut cnt: u32 = 0;
        while x % 2 == 0 {
            if cnt > ans {
                break;
            }
            x >>= 1;
            cnt += 1;
        }
        ans = ans.min(cnt);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2100
N, K = map(int, input().split())
H = list(map(int, input().split()))

if N <= K:
  print("0")
  exit()

ans = 0

def quicksort(a):
  if len(set(a)) < 2:
    return a
  left = []
  center = a.pop(0)
  right = []
  for i in a:
    if i > center:
      right.append(i)
    else:
      left.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left.extend(right)
  return left

H = quicksort(H)

for i in range(N-K):
  ans += H[i]

print(ans)
  

Measured memory_bytes: 179152
import java.util.Scanner;

//Polygonal Line Search
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int m = sc.nextInt();
			int[][] p = new int[m][2];
			int[][] r = new int[m][2];
			for(int i=0;i<m;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				p[i][0] = r[m-i-1][0] = x;
				p[i][1] = r[m-i-1][1] = y;
			}
			int[] d = new int[m-1];
			int[] rd = new int[m-1];
			for(int i=1;i<m;i++){
				d[i-1] = Math.abs(p[i][0]-p[i-1][0]) + Math.abs(p[i][1]-p[i-1][1]);
				rd[i-1] = Math.abs(r[i][0]-r[i-1][0]) + Math.abs(r[i][1]-r[i-1][1]);
			}
			int dir[] = new int[m-2];
			int k;
			if(p[1][0]==p[0][0])k = p[1][1] > p[0][1] ? 0 : 2;
			else k = p[0][0] < p[1][0] ? 1 : 3;
			for(int i=2;i<m;i++){
				int nk;
				if(p[i][0]==p[i-1][0])nk = p[i][1] > p[i-1][1] ? 0 : 2;
				else nk = p[i-1][0] < p[i][0] ? 1 : 3;
				dir[i-2] = (nk - k + 4)%4;
				k = nk;
			}
			int rdir[] = new int[m-2];
			for(int i=0;i<m-2;i++)rdir[i] = (dir[m-3-i]+2)%4;	
			for(int i=1;i<=n;i++){
				int t = sc.nextInt();
				int[] dt = new int[t-1];
				int[] dirt = new int[t-2];
				int x = sc.nextInt();
				int y = sc.nextInt();
				int kt = -1;
				for(int j=1;j<t;j++){
					int nx = sc.nextInt();
					int ny = sc.nextInt();
					dt[j-1] = Math.abs(x-nx)+Math.abs(y-ny);
					int nk;
					if(x==nx)nk = y < ny ? 0 : 2;
					else nk = x < nx ? 1 : 3;
					if(j>=2)dirt[j-2] = (nk-kt+4)%4;
					kt = nk;
					x = nx;
					y = ny;
				}
				if(m!=t)continue;
				boolean f = true;
				boolean f2 = true;
				for(int j=0;j<t-1;j++){
					if(dt[j]!=d[j])f = false;
					if(dt[j]!=rd[j])f2 = false;
				}
				for(int j=0;j<t-2;j++){
					if(dirt[j]!=dir[j])f = false;
					if(dirt[j]!=rdir[j])f2 = false;
				}
				if(f||f2)System.out.println(i);
			}
			System.out.println("+++++");
		}
	}
}

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

const int INF = 2100100100;

int R, C;
vector<vector<char>> maze; // 迷路の内容を保存する配列
vector<vector<int>> dist;  // 距離を記録しておく配列
int sx, sy, gx, gy;

int main()
{
    cin >> R >> C;
    cin >> sy >> sx;
    cin >> gy >> gx;
    sy--; // 0始まりに直す
    sx--;
    gy--;
    gx--;

    dist.assign(R, vector<int>(C, INF));  // 初期化
    maze.assign(R, vector<char>(C, '.')); // 初期化

    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
            cin >> maze[i][j];
    }

    deque<pair<int, int>> que;
    que.emplace_front(make_pair(sy, sx)); // sから探索する
    dist[sy][sx] = 0;
    while (que.size() != 0)
    {                                     // キューの要素がなくなったら終了
        pair<int, int> now = que.front(); // 現在の状態
        que.pop_front();

        if (now.first == gy && now.second == gx)
        { // 目的地にたどり着いたので終了
            //break;
        }

        int dy[4] = {0, 0, 1, -1}; // dx,dy は次の探索場所への距離を表す（４方向分）
        int dx[4] = {1, -1, 0, 0};
        for (int i = 0; i < 4; i++)
        {
            int ny = now.first + dy[i];  // 次の探索場所の行番号
            int nx = now.second + dx[i]; // 次の探索場所の列番号
            if (ny < 0 || R <= ny || nx < 0 || C <= nx)
                continue; // 迷路の外に出るならスルー
            if (maze[ny][nx] == '#')
                continue; // 障害物があればスルー
            //if (dist[ny][nx] != INF) continue;                     //探索済みならスルー
            if (dist[ny][nx] > dist[now.first][now.second])
            {
                que.push_front(make_pair(ny, nx));
            }
            dist[ny][nx] = min(dist[ny][nx], dist[now.first][now.second]);
        }
        for (int i = -2; i <= 2; i++)
        {
            for (int y = -2; y <= 2; y++)
            {
                int ny = now.first + i;  // 次の探索場所の行番号
                int nx = now.second + y; // 次の探索場所の列番号
                if (ny < 0 || R <= ny || nx < 0 || C <= nx)
                    continue; // 迷路の外に出るならスルー
                if (maze[ny][nx] == '#')
                    continue; // 障害物があればスルー
                //if (dist[ny][nx] != INF) continue;                     //探索済みならスルー
                if (dist[ny][nx] > dist[now.first][now.second] + 1)
                {
                    que.push_back(make_pair(ny, nx));
                }
                dist[ny][nx] = min(dist[now.first][now.second] + 1, dist[ny][nx]);
            }
        }
    }

    if (dist[gy][gx] > 1e7)
    {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            //cout<<dist[i][j]<<" ";
        }
        // cout<<endl;
    }

    cout << dist[gy][gx] << endl;

    return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if(a<b)
	{
		cout << "a < b"<< endl;
	}
	else if (a>b)
	{
		cout << "a > b" << endl;
	}
	else if (a == b)
	{
		cout << "a == b" << endl;
	}
}

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


int main(){
    int n;
    cin>>n;
    
    int s1=n/100;
    int s2=n%100;
    
    bool b1=s1>12||s1==0;
    bool b2=s2>12||s2==0;
    
    if(b1&&b2){
        cout<<"NA"<<endl;
    }
    if(b2&&!b1){
        cout<<"MMYY"<<endl;
    }
    if(b1&&!b2){
        cout<<"YYMM"<<endl;
    }
    if(!b1&&!b2){
        cout<<"AMBIGUOUS"<<endl;
    }
}


Measured memory_bytes: 256
import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
num_a=0
num_b=0
cnt=0
for v in itertools.permutations(list(range(1,n+1)), n):
    if v==a:
        num_a=cnt
    if v==b:
        num_b=cnt
    cnt+=1
print(abs(num_b-num_a))

Measured memory_bytes: 9016
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 24 18:22:54 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    Int m;
    std::cin >> m;
    std::vector<Int> b(m);
    REP(i, m) std::cin >> b[i];
    std::cout << (b > a) << std::endl;
}



Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int k,s,x,c;
int main(){
cin>>k>>s;
for(int i=0;i<=k;++i){
    for(int j=0;j<=k;++j){
        if(s-(i+j)>=0)
            x=s-(i+j);
        if(x+i+j==s&&x<=k)
            c++;
    }
}
cout<<c<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define rep(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	int n;
	cin >> n;
	int m = 1000006;
	VI a(n);
	REP(i, n)cin >> a[i];
	sort(ALL(a));
	VB b(1000006, false);
	VI cnt(1000006, false);
	REP(i, n) {
		b[a[i]] = true;
		cnt[a[i]]++;
	}

	REP(i, m) {
		if (!b[i])continue;
		for (int j = i * 2; j < m; j += i) {
			b[j] = false;
		}
	}
	int ans = 0;
	REP(i, m) {
		if (b[i]) {
			if (cnt[i] == 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;




}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N,A,B; cin>>N>>A>>B;
	vector<ll> x(N);
	rep(i,N) cin>>x[i];
	ll now=x[0],ans=0;
	rep(i,N-1){
		if((x[i+1]-x[i])*A<=B){
			ans+=(x[i+1]-x[i])*A;
		}
		else ans+=B;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Int

getInts :: IO [Int]
getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

f 0 = 1
f 1 = 1
f n = 1 + f (n `div` 2)

main :: IO ()
main = do
  h <- readLn :: IO Int64
  
  print $ 2 ^ (f h) - 1

Measured memory_bytes: 508
#include <stdio.h>

int main()
{
	int n, a[1000], i, max, min;

	scanf("%d", &n);

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

	max = min = a[0];
	for (i = 1; i < n; i++){
		if (max < a[i])
			max = a[i];
		if (min > a[i])
			min = a[i];
	}

	printf("%d", max - min);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long s[200005],sum[200005],a,b,c,d,maxx,minn,ans=1e18;
long long get(int l,int r){
    return sum[r]-sum[l-1];
}
int n;
int main(){
	scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&s[i]);
        sum[i]=s[i]+sum[i-1];
    }
    int l=1,r=3;
    for(int i=2;i<n-1;i++){
        while(l<=(i-2)&&abs(get(1,l)-get(l+1,i))>=abs(get(1,l+1)-get(l+2,i)))l++;
        while(r<=(n-2)&&abs(get(i+1,r)-get(r+1,n))>=abs(get(i+1,r+1)-get(r+2,n)))r++;
        a=get(1,l);
        b=get(l+1,i);
        c=get(i+1,r);
        d=get(r+1,n);
        maxx=max(max(a,b),max(c,d));
        minn=min(min(a,b),min(c,d));
        ans=min(ans,maxx-minn);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long x,y;
  cin >> x >> y;
  if(x%y==0){cout << -1 << endl; return 0;}
  for(long long i=x;i<=1000000000000000000;i+=x){
    if(i%y!=0){cout << i << endl; return 0;}
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    x, y = map(int, input().strip().split())
    ans = 0
    for i in [x, y]:
        if i == 3:
            ans += 100000
        elif i == 2:
            ans += 200000
        elif i == 1:
            ans += 300000
    if x == 1 and y == 1:
        ans += 400000
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int a,b;
  cin >> a>>b;
  vector<string> scr(a);
  for(int i=0;i<a;i++){
    cin>>scr.at(i);
  }
  for(int i=0;i<b+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i=0;i<a;i++){
    cout<<"#"<<scr.at(i)<<"#"<<endl;
  }
  for(int i=0;i<b+2;i++){
    cout<<"#";
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
    	if(i%3!=0 && i%5!=0){
        	sum+=i;
        }
    }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

int main() {
  int n;
  scanf("%d", &n);
  char cards1[n][3];
  char cards2[n][3];

  for (int i=0; i<n; i++) {
    char tmp[3];
    scanf("%s", tmp);
    strcpy(cards1[i], tmp);    
    strcpy(cards2[i], tmp);    
  }

  // バブルソート
  for (int i=0; i<n; i++) {
    for (int j=n-1; j>0; j--) {
      if (cards1[j][1]<cards1[j-1][1]) {
        char tmp[3];
        strcpy(tmp, cards1[j]);
        strcpy(cards1[j], cards1[j-1]);
        strcpy(cards1[j-1], tmp);
      }
    }
  }

  for (int i=0; i<n; i++) {
    if (i<n-1) printf("%s ", cards1[i]);
    else printf("%s\n", cards1[i]);
  }
  printf("Stable\n");

  // 選択ソート
  int flg=0;
  for (int i=0; i<n; i++) {
    int minj=i;
    for (int j=i+1; j<n; j++) {
      if (cards2[minj][1]>cards2[j][1]) {
        minj=j;
      } else if (cards2[minj][1]==cards2[j][1] && minj!=i) {
        flg=1;
      }
    }
    
    if (minj!=i) {
      char tmp[3];
      strcpy(tmp, cards2[i]);
      strcpy(cards2[i], cards2[minj]);
      strcpy(cards2[minj], tmp);
    }
  }

  for (int i=0; i<n; i++) {
    if (i<n-1) printf("%s ", cards2[i]);
    else printf("%s\n", cards2[i]);
  }
  if (flg) {
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  
  return 0;
}


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

using namespace std;

int main(void)
{
  int k;
  int tmp;
  int res=0;
  int bres;
  int a,b;

  cin>>k;

  for(int i=1;i<=k;i++)
  {
    for(int j=1;j<=k;j++)
    {
      for(int l =1;l<=k;l++)
      {
        if(j<l)
        {
          a=l;
          b=j;
        }
        else
        {
          a=j;
          b=l;
        }
        bres = gcd(a,b);

        if(i<bres)
        {
          a=bres;
          b=i;
        }
        else
        {
          a=i;
          b=bres;
        }
        res += gcd(a,b);
      }
    }
  }
  cout<<res<<endl;
}

int gcd(int a,int b)
{
  if(a%b == 0)
  {
    return b;
  }
  return gcd(b,a%b);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,i,j,cnt=1;
    cin>>a>>b;

    ll Gcd = __gcd(a,b);
    //cout<<Gcd<<"\n";

    for(i=2; Gcd>1 && Gcd>=i*i;)
    {
        for(j=0; Gcd%i==0; j++)
            Gcd/=i;
        if(j>0)
            cnt++;
        if(i==2)
            i++;
        else
            i+=2;
    }
    if(Gcd>=i)
        cnt++;

    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  ll A[N];

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

  sort(A, A+N);

  ll height = 0;
  ll wide = 0;

  int i= N-1;
  while(i>0){
    if(A[i]==A[i-1]){
      height = A[i];
      i -= 2;
      break;
    }
    i--;
  }
  while(i>0){
    if(A[i]==A[i-1]){
      wide = A[i];
      break;
    }
    i--;
  }
  
  cout << height*wide <<endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
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<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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#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())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

int N;
double rate,nh;
scanf("%d",&N);
if(N%2==0){
	rate=0.5;
} else {
	nh=N/2+1;
	rate=(nh/N);
}
printf("%f",rate);
 
//////////////////////////////////////////////////////
return 0;}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,s = 0;
  cin >> n;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
    s += v[i];
  }
  ll p,x,m;
  cin >> m;
  rep(i,m){
    cin >> p >> x;
    cout << s + (x - v[p-1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.14159265358979323846

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

    vector<Pll> eng;
    while (n--) {
        ll x, y;
        cin >> x >> y;
        if (x != 0 || y != 0) eng.emplace_back(x, y);
    }
    n = eng.size();
    vector<pair<double, int>> v;
    for (int i = 0; i < n; i++) {
        double x = eng[i].first, y = eng[i].second;
        double theta = atan(y / x);
        if (x < 0) theta += PI;
        if (x >= 0 && y < 0) theta += 2 * PI;
        v.emplace_back(theta, i);
    }
    sort(all(v));
    double mx = 0;
    for (int i = 0; i < n; i++) {
        double x = 0, y = 0;
        for (int j = i; j < i + n; j++) {
            int idx = v[j % n].second;
            x += eng[idx].first;
            y += eng[idx].second;
            mx = max(mx, sqrt(x*x + y*y));
        }
    }
    cout << fixed << setprecision(16) << mx << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

  if(c*c + a*a + b*b > 2*((a + b)*c + a*b) && c - a - b > 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
a = [0]* 1000001
m = 0
input()
for x in map(int, input().split()):
  m = max(m, x)
  a[x] += 1
m += 1
for i in range(1, m):
  if a[i]:
    for j in range(i + i, m, i):
      a[j] = 0
print(a.count(1))


Measured memory_bytes: 113344
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N >> K;
    
    ll count = 0;
    for (int b = K + 1; b <= N; b++) {
        int q = (int)(N / b);
        int r = N % b;
        count += (ll)(q * (b - K) + max(r - K + 1, 0));
        if (K == 0) count -= 1;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c,d;
    a=read(), b=read(), c=read(), d=read();
    if(a+b>c+d) puts("Left");
    else if(a+b<c+d) puts("Right");
    else puts("Balanced");
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll i,j,n;
      long double ans;
      cin>>n;
      long double x[n+1][n+1],h[n+1];
      for(i=1;i<=n;i++){
            cin>>h[i];
      }
      for(i=0;i<=n;i++){
            for(j=0;j<=n;j++){
                  if(i==0 && j==0){
                        x[i][j]=0;
                  }
                  else if(i==0 && j==1){x[i][j]=h[j];}
                  else if(i==1 && j==0){x[i][j]=1-h[i];}
                  else if(i==0){
                        x[i][j]=x[i][j-1]*h[j];
                  }
                  else if(j==0){
                        x[i][j]=x[i-1][j]*(1-h[i]);
                  }
                  else{
                        if(i+j<=n){
                              x[i][j]=x[i][j-1]*h[i+j]+x[i-1][j]*(1-h[i+j]);
                        }
                        else{x[i][j]=0;}
                  }
                 // cout<<x[i][j]<<"   ";
            }
           // cout<<"\n";
      }
      ans=0;
      for(i=0;i<=n;i++){
            for(j=0;j<=n;j++){
                  if(j>i){
                        if(i+j==n){ans=ans+x[i][j];}}
            }
      }
      printf("%0.15LF\n",ans);
}

Measured memory_bytes: 140928
N, K = map(int, input().split())
point = []
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))

ans = float('inf')
for lx, _ in point :
    for rx, _ in point :
        if lx > rx :
            continue
        for _, ly in point :
            for _, ry in point :
                if ly > ry :
                    continue
                count = 0
                for x, y in point :
                    if lx <= x <= rx and ly <= y <= ry :
                        count += 1
                if count >= K :
                    ans = min(ans, (rx - lx) * (ry - ly))

print(ans)

Measured memory_bytes: 52036
import java.io.*;
import java.util.*;

public class Main{
	
	static long mod=(long)1e9+7;
	
	public static void main(String[] args) throws IOException {
		Writer out=new Writer(System.out);
		Reader in=new Reader(System.in);
		int ts=1;
		
		outer: while(ts-->0) {	
			int x=in.nextInt();
			int y=in.nextInt();
			for(int i=0; i<=x; i++) {
				int l=y-i*4;
				int r=x-i;
				if(l>=0 && l==2*r) {
					out.println("Yes");
					continue outer;
				}
			}
			out.println("No");
		}
		out.close();		
		
	}

	static boolean tri(int a, int b, int c) {
		if(c<a+b && c>abs(a-b)) return true;
		return false;
	}
	
	
/*********************************** UTILITY CODE BELOW **************************************/	
		
	static int abs(int a) {
		return a>0 ? a : -a;
	}
	
	static int max(int a, int b) {
		return a>b ? a : b;
	}
	
	static int pow(int n, int m) {
		if(m==0) return 1;
		int temp=pow(n,m/2);
		long res=(((long)temp*temp)%mod);
		if(m%2==0) return (int)res;
		return (int)((res*n)%mod);
	}
	
	static class Pair{
		int u, v;
		
		Pair(int u, int v){this.u=u; this.v=v;}
		
		static void sort(Pair [] coll) {		
			List<Pair> al=new ArrayList<>(Arrays.asList(coll));
			Collections.sort(al,new Comparator<Pair>() {
				public int compare(Pair p1, Pair p2) {
					return p1.u-p2.u;
				}	
			});
			for(int i=0; i<al.size(); i++) {
				coll[i]=al.get(i);
			}
		}
		
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static int [] array(int n, int value) {	
		int a[]=new int[n];
		for(int i=0; i<n; i++) a[i]=value;
		return a;
	}
	
	static class Reader{
		
		BufferedReader br;
		StringTokenizer to;
		
		Reader(InputStream stream){
			br=new BufferedReader(new InputStreamReader(stream));
			to=new StringTokenizer("");
		}
		
		String next() {
			while(!to.hasMoreTokens()) {
				try {
					to=new StringTokenizer(br.readLine());	
				}catch(IOException e) {}
				
			}
			return to.nextToken();
			
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0; i<n ;i++) a[i]=nextInt();
			return a;
		}
		long [] readLongArray(int n) {
			long a[]=new long[n];
			for(int i=0; i<n ;i++) a[i]=nextLong();
			return a;
		}
		
	}
	
	static class Writer extends PrintWriter{
		Writer(OutputStream stream){
			super(stream);
		}
		void println(int [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
		void println(long [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
	}
	
}

Measured memory_bytes: 32984
class SegTree(object):
  def __init__(self,op,e,n,init_val):
    self.num = 1<<(n-1).bit_length() 
    self.S = [e]*self.num*2
    self.op = op
    self.e = e
    for i,v in enumerate(init_val): self.S[self.num+i] = v
    for i in range(self.num-1,0,-1):
      self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
      
  def set(self,index,value):
    idx = self.num+index
    self.S[idx] = value
    while idx>0:
      self.S[idx>>1] = self.op(self.S[idx],self.S[idx^1])
      idx>>=1
      
  def prod(self,l,r):
    res = self.e
    l = max(0,l)+self.num
    r = min(r,self.num-1)+self.num
    while l<r:
      if l&1:
        res = self.op(res,self.S[l])
        l += 1
      if r&1:
        res = self.op(self.S[r-1],res)
      l >>= 1
      r >>= 1
    return res
        
N,K = map(int,input().split())
ST = SegTree(max,0,300001,[0]*300001)
ans = 1
for i in range(N):
  A = int(input())
  l,r = max(0,A-K),min(A+K+1,300001)
  v = ST.prod(l,r)+1
  ans = max(ans,v)
  ST.set(A,v)
print(ans)

Measured memory_bytes: 82552
#include <bits/stdc++.h>
#define _xx ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long LL;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int c1=0,c2=0;
    for(int i=0;i<m;i++){
        int t;cin>>t;
        if(t<x) c1++;
        else c2++;
    }
    int ans=min(c1,c2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, c[100010], a[100010], l, r, ans;
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		scanf("%d%d", &l, &r);
		c[l]++;
		c[r + 1]--;
	}
	for(int i = 1; i <= n; ++i){
		a[i] = a[i - 1] + c[i];
		if(a[i] == m) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024