akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int N,X;
    cin >> N >> X;
    int x[N];
    for(int i=0; i<N; i++) cin >> x[i];
    for(int i=0; i<N; i++){
        x[i] = abs(x[i]-X);
    }
    int ans=0;
    for(int i=0; i<N; i++){
        ans = GCD(ans,x[i]);
    }
    cout << ans << endl;
}


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

using namespace std;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ALL( c ) (c).begin(), (c).end()

const double EPS = 1e-9;

struct Point
{
	double x, y;

	Point() : x( 0 ), y( 0 )
	{
		return;
	}

	Point( double x, double y ) : x( x ), y( y )
	{
		return;
	}

	Point operator + ( const Point &a ) const
	{
		return Point( x + a.x, y + a.y );
	}

	Point operator - ( const Point &a ) const
	{
		return Point( x - a.x, y - a.y );
	}

	Point operator * ( const double &a ) const
	{
		return Point( x * a, y * a );
	}

	Point operator / ( const double &a ) const
	{
		return Point( x / a, y / a );
	}

	bool operator < ( const Point &a ) const
	{
		return x == a.x ? y < a.y : x < a.x;
	}
};

// 外積
double cross( const Point &a, const Point &b )
{
	return a.x * b.y - a.y * b.x;
}

// グラハムスキャン
vector< Point > getConvex( vector< Point > ps )
{
	const int N = ps.size();

	sort( ALL( ps ) );

	int k = 0;
	vector< Point > convex( N * 2 );

	for ( int i = 0; i < N; i++ )
	{
		while ( 2 <= k && cross( convex[ k - 1 ] - convex[ k - 2 ], ps[i] - convex[ k - 1 ] ) <= EPS )
		{
			k--;
		}

		convex[ k++ ] = ps[i];
	}

	for ( int i = N - 2, t = k; 0 <= i; i-- )
	{
		while ( t < k && cross( convex[ k - 1 ] - convex[ k - 2 ], ps[i] - convex[ k - 1 ] ) <= EPS )
		{
			k--;
		}

		convex[ k++ ] = ps[i];
	}

	convex.resize( k - 1 );

	return convex;
}

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector< Point > ps( n );

		EACH( p, ps )
		{
			char d;

			cin >> p.x >> d >> p.y;
		}

		vector< Point > convex = getConvex( ps );

		cout << n - convex.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int N = intArray[0];
		int K = intArray[1];
		List<int> tree = new List<int>();

		for(int l = 0;l < N; l++)
		{
			tree.Add(int.Parse(Console.ReadLine()));
		}
		tree.Sort();

		int Hi;
		int low;
		int min = int.MaxValue;
		for (int i = 0; i < N - K + 1; i++)
		{
			low = tree[i];
			Hi = tree[i + K - 1];
			min = Math.Min(min, Hi - low);
		}
		Console.WriteLine(min);
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 18272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  string s; cin>>s;
  bool ans=true;
  int n= s.size();
  rep(i, n/2) {
    if(s.at(i)!=s.at(n-i-1)) {
      ans=false;
      break;
    }
  }
  rep(i, n/4) {
    if(s.at(i)!=s.at(n/2-i-1)) {
      ans=false; break;
    }
    if(s.at(n/2+1+i)!=s.at(n-i-1)) {
      ans=false; break;
    }
  }
  if(ans==true) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    lint y;std::cin>>y>>y;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    std::cout<<std::max(std::abs(y-a.at(n-1)),(n==1?0:std::abs(a.at(n-2)-a.at(n-1))))<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)


int main() {
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  else if(s=="MON")cout<<6<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="WED")cout<<4<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s=="FRI")cout<<2<<endl;
  else if(s=="SAT")cout<<1<<endl;

return 0;
}


Measured memory_bytes: 256
import random
import time
start=time.time()
h,w,m=map(int,input().split())
hh=[[0,i]for i in range(h)]
ww=[[0,i]for i in range(w)]
hw=set()
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  hh[a][0]+=1
  ww[b][0]+=1
  hw.add((a,b))
ww.sort(reverse=1)
s=ww[0][0]
w=[]
for x,j in ww:
  if x==s:w.append(j)
hh.sort(reverse=1)
t=hh[0][0]
hhh=[]
for x,i in hh:
  if x==t:hhh.append((x,i))
ans=[]
random.shuffle(w)
for j in w:
  for x,i in hhh:
    if (i,j) in hw:
      ans.append(s+x-1)
    else:
      exit(print(s+x))
  if time.time()-start>=1.7:
    m=ans[0]
    if h-50000<=len(hhh)<=h-random.randint(10,100):m+=1
    exit(print(m))
print(ans[0])

Measured memory_bytes: 187800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;
int V,cmp[MAX];
vector<int> G[MAX],rG[MAX],vs;
bool used[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

int main(){

    int E;cin>>V>>E;
    for(int i=0;i<E;i++){
        int a,b;cin>>a>>b;
        add_edge(a,b);
    }
    
    scc();
    
    set<int> se;
    
    for(int i=0;i<V;i++){
        se.insert(cmp[i]);
    }
    
    if(se.size()!=V) cout<<1<<endl;
    else cout<<0<<endl;
    
}




Measured memory_bytes: 7944
#include<stdio.h>
int main(void)
{
  int i,score[5],average;
  
  average = 0 ;

  for(i=0;i<5;i++){
    scanf("%d",&score[i]);

     if(score[i]<40){
       score[i] = 40 ;
     }
     
     average = average + score[i];
  }
  
  average = average / 5 ;
  
  
  printf("%d\n",average);
  
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K, C;
string S;
int L[200010];
int R[200010];


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K >> C >> S;
    
    int cnt = 0;
    int idx = 0;
    while(cnt < K && idx < N){
        if(S[idx] == 'o'){
            cnt++;
            L[cnt] = idx;
            idx += C;            
        }
        idx++;
    }

    cnt = K + 1;
    idx = N - 1;
    while(cnt > 0 && idx >= 0){
        if(S[idx] == 'o'){
            cnt--;
            R[cnt] = idx;
            idx -= C;
        }
        idx--;
    }
    for(int i = 1; i <= K; i++){
        if(L[i] == R[i]){
            cout << L[i] + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int a;
    int b;
    int k;
    cin >> a >> b >> k;
    for(int i = min(a, b); i >= 1; i--){
        if(a % i == 0){
            if(b % i == 0){
                k--;
            if(k == 0){
                cout << i << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b;
	bool flag=false;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			flag=true;
			break;
		}
	}
	if(flag)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
  return 0;
}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}




int dp[3005][3005];


int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);





     string s1,s2;
     cin>>s1>>s2;
     s1='9'+s1;
     s2='8'+s2;
     string ans;

     for(int i=1;i<s1.size();i++){
        for(int j=1;j<s2.size();j++){
              if(s1[i]==s2[j]){
                dp[i][j]=dp[i-1][j-1]+1;
              }
              else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
              }
        }
     }

     int i=s1.size()-1;
     int j=s2.size()-1;
     while(i>0&&j>0){
        if(s1[i]==s2[j]){
            ans+=s1[i];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
     }

     reverse(ans.begin(),ans.end());
     cout<<ans;






     return 0;

}


Measured memory_bytes: 38832
n=int(input())
AB=[]
for i in range(n):
    x,l=map(int,input().split())
    a=x-l
    b=x+l
    AB.append((a,b))
cnt=1
AB.sort(key=lambda L:L[0],reverse=True)
simekiri=AB[0][0]
for i in range(1,n):
    migi=AB[i][1]
    hidari=AB[i][0]
    if migi<=simekiri:
        cnt+=1
        simekiri=hidari
print(cnt)

Measured memory_bytes: 18188
#include <bits/stdc++.h>
using namespace std;
long long dp[110][1000000];
int w[110];
int v[100];


int main()
{
    long long N, W, mx=0;
    cin>> N >> W;
    for(int i=1;i<=N ;i++)
        cin>> w[i] >> v[i];

    for(int i=0;i<N;i++)
        for(int j=0;j<W;j++)
        {
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+w[i+1]<1000000)
            dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
        }
        for(int j=1;j<=W;j++)
        {
            mx=max(mx,dp[N][j]);
        }
    cout<< mx;
}


Measured memory_bytes: 329984
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int x, t;
  cin >> x >> t;
  cout << max(0, x-t) << endl;
}






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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -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; }


/*
vector<ll> v(N);
iota(v.begin(), v.end(), 0);
do{

}while(next_combination(v.begin(),v.begin() + K,  v.end()));
*/
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
	 /* Credits: Thomas Draper */
	 if ((first == last) || (first == k) || (last == k))
			return false;
	 Iterator itr1 = first;
	 Iterator itr2 = last;
	 ++itr1;
	 if (last == itr1)
			return false;
	 itr1 = last;
	 --itr1;
	 itr1 = k;
	 --itr2;
	 while (first != itr1)
	 {
			if (*--itr1 < *itr2)
			{
				 Iterator j = k;
				 while (!(*itr1 < *j)) ++j;
				 iter_swap(itr1,j);
				 ++itr1;
				 ++j;
				 itr2 = k;
				 rotate(itr1,j,last);
				 while (last != j)
				 {
						++j;
						++itr2;
				 }
				 rotate(k,itr2,last);
				 return true;
			}
	 }
	 rotate(first,k,last);
	 return false;
}

int main()
{
	ll N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<ll>> mat(Q, vector<ll>(4, 0));
	REP(i, Q) {
		cin >> mat[i][0] >> mat[i][1] >> mat[i][2] >> mat[i][3];
	}
	vector<ll> v(N+M-1);
	iota(v.begin(), v.end(), 0);
	vector<ll> A(N);
	ll ans = 0;
	do{
		REP(i, N) {
			A[i] = v[i] - i + 1;
		}
		ll tmp = 0;
		REP(i, Q) {
			if (A[mat[i][1]-1] - A[mat[i][0]-1] == mat[i][2]) tmp += mat[i][3];
		}
		ans = max(ans, tmp);
	}while(next_combination(v.begin(),v.begin() + N,  v.end()));
	PRINT(ans);
	return 0;
}


Measured memory_bytes: 3636
N,Y=[int(i) for i in input().split()]
#a=万 b=五千 c=千
a=0
while a*10000<=Y:
  c=0
  while a*10000+c*1000<=Y:
    if a+c>N:break
    B=Y-a*10000-c*1000
    if B%5000==0:
      b=B//5000
      if a+b+c==N:
        print(a,b,c)
        exit()
    c+=1
  a+=1
else :print(-1,-1,-1)

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

int main()
{
    int a=0,b=0,i=0,temp;
    while (cin >> a >> b)
    {
        i++;
        if (a == 0 && b == 0) break;

        if (a>b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << "\n";
    }
    return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>
int main(){
  int n,a,i,j,b[7];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(j=0;j<7;j++) b[j]=0;
    for(i=0;i<n;i++){
      scanf("%d",&a);
      if(a<10) b[0]++;
      else if(a<20)b[1]++;
      else if(a<30)b[2]++;
      else if(a<40)b[3]++;
      else if(a<50)b[4]++;
      else if(a<60)b[5]++;
      else b[6]++;
    }
    for(j=0;j<7;j++){
      printf("%d\n",b[j]);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

int a[11];
int b[11];

int n, m;
int rec(int i){
	if (i == n){
		int sum = 0;
		rep(j, n) sum += a[b[j]];
		return sum <= m;
	}

	rep(j, 10){
		b[i] = j;
		if (rec(i + 1)) return true;
	}
	return false;
}

int main(){	
	cin >> n >> m;
	rep(i, 10) cin >> a[i];

	bool ret = rec(0);
	if (ret){
		string res;
		rep(i, n) res += '0' + b[i];
		sort(ALL(res));
		cout << res << endl;
	}
	else{
		cout << "NA" << endl;
	}

	return 0;
}


Measured memory_bytes: 1196
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define int long long int
#define inf 1000000000
int32_t main()
{
	int k;
	cin>>k;
	string str;
	cin>>str;
	if(str.size()<=k)
	{
		cout<<str<<endl;
	}
	else
	{
		int j;
		for(j=0;j<k;j++)
		  cout<<str[j];
		cout<<"..."<<endl;
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ll n = N/i;
        ans += i*(n+1)*n/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-07 16:30:54
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    int a , b ;
    cin >> a >> b;
    cout << a*a-b << endl;
    
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

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

int main() {
  int N, M, s = 0;
  cin >> N >> M;
  vector<int> A(M);
  for(int i=0;i<M;i++) {
    cin >> A.at(i);
    s += A.at(i);
  }
  if(s<=N)
    cout << N-s << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3636
h,w = map(int,input().split())
a = []
a.append("."*(w+2))
for i in range(h):
    a.append("." + input() + ".")
a.append("."*(w+2))
ans = "Possible"
for i in range(h+2):
    for j in range(w+2):
        if a[i][j] == "#":
            if i==1 and j==1:
                if [a[i+1][j],a[i][j+1]].count("#")!=1:
                    ans = "Impossible"
            elif i==h and j==w:
                if [a[i-1][j],a[i][j-1]].count("#")!=1:
                    ans = "Impossible"
            else:
                if [a[i-1][j],a[i][j-1]].count("#")!=1 or [a[i+1][j],a[i][j+1]].count("#")!=1:
                    ans = "Impossible"
print(ans)

Measured memory_bytes: 38384
x1, y1, x2, y2 = list(map(int, input().split()))
vec = [x2 - x1, y2 - y1]
vec = [-vec[1], vec[0]]
x3 = x2 + vec[0]
y3 = y2 + vec[1]
vec = [-vec[1], vec[0]]
x4 = x3 + vec[0]
y4 = y3 + vec[1]
print(x3, y3, x4, y4)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
const int N = 2e5+5;
int n, a[N], b[N], cnt[N];
deque<int> q;

int32_t main() {
    // freopen("in.txt", "r", stdin);
    IOS;
    cin >> n;
    for(int i=0; i<n; i++) {
        int x; cin >> x;
        cnt[x]++; 
        a[i] = x;
    }
    for(int i=0; i<n; i++) {
        int x; cin >> x;
        cnt[x]++;
        q.push_back(x);
    }
    for(int i=0; i<n; i++) {
        if(cnt[a[i]] > n) {
            cout << "No";
            exit(0);
        }
    }
    cout << "Yes\n";
    int t = 0;
    for(int i=0; i<n; i++) {
        if(q.front() != a[i]) {
            b[i] = q.front();
            q.pop_front();
        } else {
            if(q.back() != q.front()) {
                while(q.front() == a[i]) {
                    int v = q.front();
                    q.pop_front();
                    q.push_back(v);
                }
                b[i] = q.front();
                q.pop_front();
            } else {
                b[i] = b[t];
                b[t] = q.front();
                t++; q.pop_front();
            }
        }
    }
    for(int i=0; i<n; i++) cout << b[i] << " ";
}

Measured memory_bytes: 9512
#include <iostream>

using namespace std;

int main()
{
    int A,B;//Alice if Alice will win. Print Bob if Bob will win. Print Draw
    cin >>A>>B;
    if (A==B)
        cout <<"Draw";
    else if (A==1)
        cout << "Alice";
    else if (B==1)
        cout << "Bob";
    else if (A>B)
        cout <<"Alice";
    else
        cout<< "Bob";
            return 0;
}

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

int main() {
  int64_t n, k, mod = 1000000007;
  cin >> n >> k;
  vector<int64_t> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int64_t> add(k + 1, 0);
    for (int j = 0; j <= k; j++) {
      (add[j] += dp[i][j]) %= mod;
      if (j + as[i] + 1 <= k) {
        (add[j + as[i] + 1] += (mod - dp[i][j]) % mod) %= mod;
      }
    }
    for (int j = 1; j <= k; j++) {
      (add[j] += add[j - 1]) %= mod;
    }
    dp[i + 1] = add;
  }
  cout << dp[n][k] << endl;
  return 0;
}


Measured memory_bytes: 80256
import sys
input = sys.stdin.readline

def main():

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

    V = []

    for i in range(n):
        s, t, x = map(int, input().split())
        V.append((s-x, x, 1)) #1: insert
        V.append((t-x, x, 0)) #0: delete

    D = []
    for i in range(q):
        d = int(input())
        V.append((d, i, 2)) #2: query

    V.sort(key=lambda x:(x[0], x[2]))
    se = set()
    hq = []
    import heapq
    heapq.heapify(hq)
    ans = [-1]*q
    for t, v, p in V:
        if p == 1:
            se.add(v)
            heapq.heappush(hq, v)
        elif p == 0:
            se.discard(v)
        else:
            while hq and hq[0] not in se:
                heapq.heappop(hq)
            if hq:
                ans[v] = hq[0]

    for i in range(q):
        print(ans[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 130292
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, l=35, up[101010][36], timer=0, tin[101010], tout[101010] , x, y, q, dist[101010] ;
vpi adj[101010] ;

void dfs(int s, int p){

    tin[s] = ++timer;
    up[s][0]=p;

    for(auto t: adj[s] ){
        if(t.fs!=p){
            dist[t.fs] = dist[s]+t.sc;
            dfs(t.fs, s);
        }
    }

    tout[s] = ++timer;

}



bool is_ancestor(int u, int v){

    return tin[v]>=tin[u] && tout[u]>=tout[v];

}

void init(){

    for(int i = 1; i<=l; i++){
        for(int j = 1; j<=n; j++){
            up[j][i] = up[up[j][i-1]][i-1];
        }
    }

}

int lca(int u, int v){


    if(is_ancestor(u, v))return u;
    if(is_ancestor(v, u))return v;

    for(int i = l; i>=0; i-- ){
        if(!is_ancestor(up[u][i] , v ))u = up[u][i];
    }

    return up[u][0];

}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

cin >> n;
for(int i=1;i<n;i++){
    int w;
    cin >> x >> y >> w;
    adj[x].pb({y,w});
    adj[y].pb({x,w});
}

int k;
cin >> q >> k;
dfs(k,k);
init();

while(q--){
    cin >> x >> y;
    int lc = lca(x,y);
    //cout << lc << endl;
    int ans = dist[x]+dist[y];
    cout << ans << endl;
}

return 0;
}
///....


Measured memory_bytes: 44032
#include <bits/stdc++.h>
using namespace std;
const int maxn = 111;
int f[maxn][maxn][maxn], g[maxn][maxn][maxn], a[maxn];
int solve(int l, int r, int op){
	if(op == 0) return 0;
	if(l > r) return 0;
	int & ans = f[l][r][op];
	if(g[l][r][op]) return ans;
	ans = 0;
	ans = max(ans, a[l] + solve(l + 1, r, op - 1));
	ans = max(ans, a[r] + solve(l, r - 1, op - 1));
	if(op > 1) ans = max(ans, solve(l + 1, r, op - 2));
	if(op > 1) ans = max(ans, solve(l, r - 1, op - 2));
	g[l][r][op] = 1;
	return ans;
}
int main(){
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	cout << solve(0, n - 1, k) << endl;
	return 0;
}



Measured memory_bytes: 7040
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> m;
  rep(i, m) {
    cin >> a;
    ans -= a;
  }
  ans += n;
  if (ans < 0)
    Cout(-1);
  else
    Cout(ans);
  return 0;
}

Measured memory_bytes: 3656
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static class Edge {
		int e1, e2;
		public Edge (int e1, int e2) {
			this.e1 = e1;
			this.e2 = e2;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		Edge[] c = new Edge[m];
		int ans = 0;
		for (int i = 0; i < m; i++)
			c[i] = new Edge(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
		for (int i = 0; i < m; i++) {
			Edge[] d = new Edge[m - 1];
			for (int j = 0; j < i; j++)
				d[j] = c[j];
			for (int j = i; j < m - 1; j++)
				d[j] = c[j + 1];
			ans += search(n, d);
		}
		System.out.println(ans);
	}

	public static int search(int n, Edge[] d) {
		int[] already = new int[n + 1];
		Deque<Integer> p = new ArrayDeque<Integer>();
		already[d[0].e1] = 1;
		p.push(d[0].e1);
		int count = 1;
		while(!p.isEmpty()) {
			int here = p.pop();
			for (int i = 0; i < d.length; i++) {
				if (d[i].e1 == here && already[d[i].e2] != 1) {
					already[d[i].e2] = 1;
					p.push(d[i].e2);
					count++;
				}
				else if (d[i].e2 == here && already[d[i].e1] != 1) {
					already[d[i].e1] = 1;
					p.push(d[i].e1);
					count++;
				}
			}
		}
		if (count == n)
			return 0;
		else
			return 1;
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Measured memory_bytes: 102688
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    long long num = 0, bnum = 0;
    scanf("%d", &n);
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());
    auto cite = c.begin();
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        for (; b[j] > a[i] && j < n; j++)
        {
            cite = lower_bound(cite, c.end(), b[j], greater<int>());
            bnum += cite - c.begin();
        }
        num += bnum;
    }
    printf("%lld\n", num);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"SUN", "MON","TUE","WED","THU","FRI","SAT"};

int main(){
    string now;
    cin >> now;
    for(int i = 0; i < 7; i++){
        if(day[i] == now){
            cout << 7 - i << endl;
            return 0;
        }
    }
}


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

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

  if (N <= 1999 && (N== 1000 || N == 1110 || N == 1111 || N == 1112 || N == 1113 || N == 1114|| N == 1115 || N == 1116 || N == 1117 || N == 1118 || N == 1119|| N == 1222 || N == 1333 || N == 1444 || N == 1555 || N == 1666 || N == 1777 || N == 1888 || N == 1999)) {
    cout << "Yes" << endl;
  }
  else if (2000 <= N <= 2999 && (N== 2000 || N == 2220 || N == 2221 || N == 2222 || N == 2223 || N == 2224|| N == 2225 || N == 2226 || N == 2227 || N == 2228 || N == 2229 || N == 2111 || N == 2333 || N == 2444 || N == 2555 || N == 2666 || N == 2777 || N == 2888 || N == 2999)){
    cout << "Yes" << endl;
  }
  else if (3000 <= N <= 3999 && (N== 3000 || N == 3330 || N == 3331 || N == 3332 || N == 3333 || N == 3334|| N == 3335 || N == 3336 || N == 3337 || N == 3338 || N == 3339 || N == 3111 || N == 3222 || N == 3444 || N == 3555 || N == 3666 || N == 3777 || N == 3888 || N == 3999)){
    cout << "Yes" << endl;
  }
  else if (4000 <= N <= 4999 && (N== 4000 || N == 4440 || N == 4441 || N == 4442 || N == 4443 || N == 4444|| N == 4445 || N == 4446 || N == 4447 || N == 4448 || N == 4449 || N == 4111 || N == 4333 || N == 4222 || N == 4555 || N == 4666 || N == 4777 || N == 4888 || N == 4999)){
    cout << "Yes" << endl;
  }
   else if (5000 <= N <= 5999 && (N== 5000 || N == 5555 || N == 5550 || N == 5551 || N == 5552 || N == 5553 || N == 5554 || N == 5556 || N == 5557 || N == 5558 || N == 5559 || N == 5111 || N == 5333 || N == 5222 || N == 5444 || N == 5666 || N == 5777 || N == 5888 || N == 5999)){
    cout << "Yes" << endl;
  }
   else if (6000 <= N <= 6999 && (N== 6000 || N == 6666 || N == 6660 || N == 6661 || N == 6662 || N == 6663 || N == 6664 || N == 6665 || N == 6667 || N == 6668 || N == 6669 || N == 6111 || N == 6333 || N == 6222 || N == 6444 || N == 6555 || N == 6777 || N == 6888 || N == 6999)){
    cout << "Yes" << endl;
    }
   else if (7000 <= N <= 7999 && (N== 7000 || N == 7777 || N == 7770 || N == 7771 || N == 7772 || N == 7773 || N == 7774 || N == 7775 || N == 7776 || N == 7778 || N == 7779 || N == 7111 || N == 7333 || N == 7222 || N == 7444 || N == 7666 || N == 7555 || N == 7888 || N == 7999)){
    cout << "Yes" << endl;
  }
   else if (8000 <= N <= 8999 && (N== 8000 || N == 8888 || N == 8880 || N == 8881 || N == 8882 || N == 8883 || N == 8884 || N == 8886 || N == 8887 || N == 8885 || N == 8889 || N == 8111 || N == 8333 || N == 8222 || N == 8444 || N == 8666 || N == 8777 || N == 8555 || N == 8999)){
    cout << "Yes" << endl;
  }
   else if (9000 <= N <= 9999 && (N== 9000 || N == 9999 || N == 9990 || N == 9991 || N == 9992 || N == 9993 || N == 9994 || N == 9996 || N == 9997 || N == 9998 || N == 9995 || N == 9111 || N == 9333 || N == 9222 || N == 9444 || N == 9666 || N == 9777 || N == 9888 || N == 9555)){
    cout << "Yes" << endl;
  }
  else{
     cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

template<typename T> struct segment_tree {
private :
	int N;
	std::vector<T> value;
public :
	const std::function<T(T, T)> op;
	const T id;

	segment_tree(const std::vector<T>& a, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int n = a.size(), m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
		for (int i = 0; i < n; i++) value[N + i] = a[i];
		for (int i = N - 1; i > 0; i--) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	segment_tree(const int& n, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
	}

	inline const int& size()const{return N;}

	void point_update(int i, const T& t) {
		i += N;
		value[i] = t;
		while (i /= 2) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	T range_fold(const int& L, const int& R, const int& i = 1, const int& l = 0, int r = -1) {
		if (r == -1) r = N;
		if (L <= l && r <= R) return value[i];
		if (r <= L || R <= l) return id;
		return op(
			range_fold(L, R, i * 2, l, (l + r) / 2),
			range_fold(L, R, i * 2 + 1, (l + r) / 2, r)
		);
	}

	inline const T& operator[](const int& i)const{return value[N + i];}
};

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

	segment_tree<long long> sg(a, [](long long a, long long b){return a + b;}, 0);
	while (q--) {
		int op;
		std::cin >> op;
		if (op == 0) {
			int p; long long x;
			std::cin >> p >> x;
			sg.point_update(p, sg[p] + x);
		} else {
			int l, r;
			std::cin >> l >> r;
			std::cout << sg.range_fold(l, r) << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 16428
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] += value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx){
        if(!mDirty[idx]) return;
        mVal[idx] += mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return max(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int N, M; cin >> N >> M;
    const int INF = 1 << 30;
    LazySegTree<int> seg(M+2, 0, -INF);
    for(int i=1;i<=M;i++) seg.update(1, i+1, -1);
    int res = max(0, N-M);
    vector<pair<int, int>> vp;
    for(int i=0;i<N;i++){
        int L, R; cin >> L >> R;
        vp.emplace_back(L, R);
    }
    sort(vp.begin(), vp.end());
    for(auto& p : vp){
        seg.update(1, p.second+1, 1);
        res = max(res, seg.get(p.first+1, M+2) - p.first);
    }
    cout << res << endl;
}

Measured memory_bytes: 11532
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ld long double
#define eps 1e-9
#define maxp 99940000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
string rot(string s){
	string ret="";
	ll i;
	for(i=1;s[i];i++){
		ret+=s[i];
	}
	ret+=s[0];
	return ret;
}
ll power(ll x,ll y,ll p)
{
	ll ret=1;
	while(y>0)
	{
		if(y&1)
			ret=(ret*x)%p;
		y/=2;
		x=(x*x)%p;
	}
	return ret%p;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll n,i;
	cin>>n;
	vll vec(n);
	map<ll,bool>pres;
	map<ll,ll>freq;
	map<ll,vector<ll> >facs;
	nfl(i,n){
		cin>>vec[i];
		freq[vec[i]]++;
		pres[vec[i]]=1;
	}
	ll ans=0;
	nfl(i,n){
		if(freq[vec[i]]>1){
			continue;
		}
		vll fac;
		if(facs[vec[i]].size()){
			fac=facs[vec[i]];
		}else{
			fac=divs(vec[i]);
			facs[vec[i]]=fac;
		}	
		bool f=0;
		for(auto it:fac){
			if(pres[it]){
				if(it==vec[i]){
					if(freq[it]>1){
						f=1;
						break;
					}
				}else{
					f=1;
					break;
				}
			}
		}
		if(f==0)
			ans++;
	}
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 72632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  unsigned int k;
  string s;
  cin >> k >> s;
  string ans;
  if(s.size() <= k) {
    ans = s;
  }
  else {
    ans = s.substr(0, k) + "...";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in(){int x;cin>>x;return x;}
int n;
vector<int> a,b,c;

int main ()
{
	cin>>n;
	while(n--)
	{
		double ax,ay,ar,bx,by,br;
		cin>>ax>>ay>>ar>>bx>>by>>br;
		double half=sqrt((bx-ax)*(bx-ax)+(by-ay)*(by-ay));

		if(half-ar-br>0)
		{
			cout<<"0"<<endl;
		}
		else if(half+br<ar)cout<<2<<endl;
		else if(half+ar<br)cout<<-2<<endl;
		else cout<<1<<endl;

	}

	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = Integer.parseInt(scan.next());
        }
        int q = Integer.parseInt(scan.next());
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        int ans = 0;
        for (int i = 0; i < q; i++) {
            ans += binarySearch(s, t[i]);
        }
        System.out.println(ans);
    }

    private static int binarySearch(int[] s, int t) {
        int left = -1;
        int right = s.length;

        while (right - left > 1) {
            int mid = (right + left) / 2;
            if (s[mid] >= t) {
                right = mid;
            } else {
                left = mid;
            }
        }

        if (right == s.length) {
            return 0;
        }

        if (s[right] == t) {
            return 1;
        } else {
            return 0;
        }
    }
}



Measured memory_bytes: 70572
buf = $stdin.gets.chop

res = false
if buf == buf.reverse then
  i = ((buf.length-1)/2).floor
  if buf[0,i] == buf[0,i].reverse then
    i = ((buf.length+2)/2).ceil
    if buf[i..-1] == buf[i..-1].reverse then
      res = true
    end
  end
end

puts res ? "Yes" : "No"

Measured memory_bytes: 1788
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N, K; cin >> N >> K;

    long long ans = 0;
    if (K & 1) {
        if (N >= K) {
            long long n = N / K;
            ans = n*n*n;
        }
    }
    else {
        if (N >= K) {
            long long n = N / K;
            ans = n*n*n;
        }
        if (N >= K/2) {
            long long n = (N-K/2) / K + 1;
        ans += n*n*n;;
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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





Measured memory_bytes: 3096