akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 3010;
int n, a[N];
ll dp[N][N]; //dp[i][j] - best value of X-Y for segments i..j

ll rec(int l, int r) {
	if(l > r) return 0;
	ll& memo = dp[l][r];
	if(memo != -1) return memo;
	return memo = max(a[l]-rec(l+1, r), a[r]-rec(l, r-1));
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    cout << rec(1, n) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int n;
int a[N],b[N],c[N];
ll sum;

int main () {
        cin >> n;

        for (int i = 1; i <= n; i ++)
                cin >> a[i];

        for (int i = 1; i <= n; i ++)
                cin >> b[i];

        for (int i = 1; i <= n; i ++)
                cin >> c[i];

        sort (a + 1,a + n + 1);
        sort (b + 1,b + n + 1);
        sort (c + 1,c + n + 1);

        for (int i = 1; i <= n; i ++) {
                int pos = upper_bound(a + 1,a + n + 1,b[i] - 1) - a - 1;
                int ps = lower_bound(c + 1,c + n + 1,b[i] + 1) - c;
                sum += (pos * 1ll * (n - ps + 1));
        }
        cout << sum << endl;
}


Measured memory_bytes: 1536
# include <bits/stdc++.h>
using namespace std;
int main(){
	long long l , r;
	cin >> l >> r; 
	if(r - l + 1 >= 2019){
		cout << 0;
		return 0;
	}
	long long res = 2019;
	for(long long i = l; i <= r; i ++)
		for(long long j = i + 1; j <= r; j ++)
			res = min(res , (i * j) % 2019);
	cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int X, A;
	cin >> X >> A;
	if (X < A) cout << 0 << endl;
	else cout << 10 << endl;

	return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
l = []
for i in range(K):
  if A + i > 0 and A + i <= B:
    l.append(A + i)
  elif A + i > B:
    break
for x in range(K):
  if B-(K-1)+x > 0 and B-(K-1)+x >= A:
    l.append(B - (K - 1) + x)
  elif B - (K - 1) + x < A:
    break

for y in sorted(set(l), key = l.index):
  print(y)

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

long long A[100010];

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

int f(long long x){
    int ret = 0;
    while(x%2==0){
        ret++;
        x>>=1;
    }
    return ret;
}

int main(void){
    // freopen("aaa.in","r",stdin);
    long long N,M;
    scanf("%lld%lld",&N,&M);
    for (int i=1;i<=N;i++) scanf("%lld",&A[i]);
    // sort(A+1,A+1+N);
    // N = unique(A+1,A+N+1)-(A+1);
    for (int i=1;i<=N;i++) A[i]/=2;
    int tt = f(A[1]);
    for (int i=2;i<=N;i++){
        if (tt!=f(A[i])){
            cout<<0<<endl;
            return 0;
        }
    }
    long long gcdd = 0;
    // cout<<gcd(6,10)<<endl;    
    long long ans = 1;
    for (int i=1;i<=N;i++)
    {   
        gcdd = gcd(ans,A[i]);
        ans = ans/gcdd; 
        ans*=A[i];
        if (ans>M) break;
    // cout<<gcdd<<endl;
    }
    // cout<<ans<<"  "<<gcdd<<endl;
    long long anss = 0;
    if (ans<=M){
        M-=ans;
        anss++;
        if (ans>0) anss+=M/(ans*2);
    }
    cout<<anss<<endl;
    return 0;
}


Measured memory_bytes: 1024
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end

n = gets.to_s.to_i
# a = gets.to_s.split.map{|e|e.to_i}
# m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
# s = gets.to_s.chomp

puts n * 3.1415 * 2

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N, Q;
    std::string S;
    std::cin >> N >> Q;
    std::cin >> S;
    std::vector<int> ls(Q);
    std::vector<int> rs(Q);
    for (int i = 0; i < Q; i++) {
        std::cin >> ls.at(i) >> rs.at(i);
    }
    std::vector<int> acs{};
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == 'A' and S.at(i + 1) == 'C') {
            acs.emplace_back(i);
        }
    }
    for (int i = 0; i < Q; i++) {
        auto it_begin = std::lower_bound(acs.begin(), acs.end(), ls.at(i) - 1);
        auto it_end = std::upper_bound(acs.begin(), acs.end(), rs.at(i) - 2);
        std::cout << std::distance(it_begin, it_end) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	if(n%2==0) cout<<n<<endl;
	else cout<<2*n<<endl;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
  int n;
  cin>>n;
  if(n==1)
    cout<<0<<endl;
  else
    cout<<1<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;



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

    int low = max(a, c);
    int high = min(b, d);
    

    cout << max(0, high - low) << endl;
    
    return 0;
}

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

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> H(N);

	rep(i,N){
		cin >> H[i];
	}
	Graph G(N + 1);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		G[A].push_back(H[B - 1]);
		G[B].push_back(H[A - 1]);

	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ll h = H[i - 1]; //展望台iの高さ
		ll iMax = 0;

		for (int j = 0; j < G[i].size(); j++) {
			iMax = max(iMax, G[i][j]);
		}
		if (h > iMax) ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 9836
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1

print("AC x ", end="")
print(ac)
print("WA x ", end="")
print(wa)
print("TLE x ", end="")
print(tle)
print("RE x ", end="")
print(re)

Measured memory_bytes: 69832
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
vector<int> ret;
void dfs(vector<vector<int>>& adj, vector<int>& vis, int n, int ch, int par) {
	vis[ch] = 1;
	ret.push_back(ch);
	for(int i=0;i<adj[ch].size();i++) {
		if(vis[adj[ch][i]] == 1 || adj[ch][i] == par) continue;
		dfs(adj, vis, n, adj[ch][i], ch);
	}
}
int main() {
	fast;
	int n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	for(int i=0;i<m;i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	vector<int> vis(n + 1);
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(vis[i] == 0) {
			ret.clear();
			dfs(adj, vis, n, i, -1);
			ans = max(ans, (int)ret.size());
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 28392
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    ll sum = a[0];
    ll c = a[0];
    for(ll i = 1; i < n; i++){
        c = __gcd(sum, a[i]);
        sum = sum/c*a[i];
        //cout << c << endl;
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  T.pop_back();
  if(S == T){
    cout << "Yes" << endl;
  }
  else if (S != T){
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int N,SS=0,Mx=0;
    char S[100];
    cin >> N >> S;
    for (int i=0;i<N;i++){
        if (S[i] == 'I'){
            SS++;
        }else {
            SS--;
        }
        if (Mx < SS){
            Mx = SS;
        }
    }
    cout << Mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	string s;
	cin >> s;
	int cnt0 = 0, cnt1 = 0;
	rep(i, (int)s.size()) {
		if (s[i] == '0') {
			cnt0++;
		} else {
			cnt1++;
		}
	}

	int ans = cnt0+cnt1-abs(cnt1-cnt0);
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

int main(){

  ll n;cin>>n;
  ll ma=0;
  ll mi=INF;
  rep(i,0,n){
    ll a,b;cin>>a>>b;
    chmax(ma,a);
    chmin(mi,b);
  }

  out(ma+mi);

  return 0;
}


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

int main(){
	int a,b,c;
	cin>>a;
	while(cin>>a>>b>>c){
		if(a>b){
			if(c>a){
				if(c*c==a*a+b*b){
					cout<<"YES"<<endl;
				}else{
					cout<<"NO"<<endl;
				}
			}else{
				if(a*a==c*c+b*b){
					cout<<"YES"<<endl;
				}else{
					cout<<"NO"<<endl;
				}
			}
		}else{
			if(c>b){
				if(c*c==a*a+b*b){
					cout<<"YES"<<endl;
				}else{
					cout<<"NO"<<endl;
				}
			}else{
				if(b*b==c*c+a*a){
					cout<<"YES"<<endl;
				}else{
					cout<<"NO"<<endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
int main(void)
{
	char a[3];
	int s[5],d,i;
	for(i=1;i<=4;i++)	s[i]=0;
	while(scanf("%d,%s",&d,a)!=EOF){
		if(a[0]=='A'&&a[1]=='B'){
			s[3]++;
		}
		else if(a[0]=='A'){
			s[1]++;
		}
		else if(a[0]=='B'){
			s[2]++;
		}
		if(a[0]=='O'){
			s[4]++;
		}
		
	}
	for(i=1;i<=4;i++){
		printf("%d\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    Scanner in = new Scanner(System.in);
 
    int number = in.nextInt();
 
    long factorial = number;
    for(int i = 1; i < number; i++){
        factorial = factorial*(number - i);
    }
 
    System.out.println(factorial);
    }
}

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

using namespace std;
using ll = long long;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<ll> > g(n + 1, vector<ll>(m + 1));
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		cin >> g[a][b];
	}
	vector<vector<vector<ll>>> d(n + 1, vector<vector<ll>>(m + 1, vector<ll>(4)));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			ll x = 0;
			for(int e = 0 ; e < 4 ; e++)
				x = max(d[i - 1][j][e],x);
			d[i][j][0] = x;
			for (int e = 1; e < 4; e++) {
				d[i][j][e] = max(d[i][j - 1][e], d[i][j - 1][e - 1] + g[i][j]);
			}
			d[i][j][1] = max(d[i][j][1], x + g[i][j]);
		}
	}

	ll ans = 0;
	for (int i = 0; i < 4; i++)
		ans = max(d[n][m][i], ans);
	cout << ans << endl;
//	for (int i = 0; i <= n; i++) {
//		for (int j = 0; j <= m; j++) {
//			for (int e = 0; e < 4; e++) {
//				cout<<d[i][j][e]<<' ';
//			}
//			cout<<'\t';
//		}
//		cout<<endl;
//	}

}

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

using namespace std;

int n, m, k, rs, ct;

main() {
    cin >> n >> m >> k;
    if (k % n == 0 && k / n <= m) {
        cout << "Yes";
        return 0;
    }
    if (k % m == 0 && k / m <= n) {
        cout << "Yes";
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int x = (i * j) + ((n - i) * (m - j));
            if (x == k) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


Measured memory_bytes: 384
#include <iostream>

int main(){
  int N,D,X;
  int A[110];
  std::cin >> N >> D >> X;
  for(int i=0;i<N;i++){
    std::cin >> A[i];
  }

  int Eaten=0;

  for(int i=0;i<N;i++){
    for(int j=1;j<=D;j+=A[i]){
      Eaten++;
    }
  }

  std::cout << Eaten + X << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
template<typename T> void input(T a[], int n){for(int i=0;i<n;i++) cin>>a[i];}
template<typename T, typename U> void input(T a[], U b[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}
template<typename T, typename U, typename O> void input(T a[], U b[], O[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}

using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  ll n; cin>>n;
  ll a[n+1]={};
  for(int i=2;i<=n;i++) {
    ll nw = i;
    for(int j=2;j*j<=n;j++) {
      while(nw % j == 0) nw/=j, a[j]++;
    }
    if(nw!=1)a[nw]++;
  }
  ll an=1;
  for(int i=2;i<=n;i++) {
    an*=a[i]+1;
    an%=M;
  }
  cout<<an<<endl;
}
// Thank you for making problems and running the contest !!!

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+5;
            const ll mod = 1e9+7;
            const ll inf = 1e18;
            ll   n  , k  , m  , l , r  , x , y  , q , u , z  , a[N];

    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt ;
        if(n&1)
            pt *= a ;
        return pt;
    }

    bool check(ll mid)
    {
        ll steps  = 0;
        rep(i,0,n)
        {
            steps += (a[i]-1)/ mid;
        }
        return (steps <= k);
    }

    int main()
    {
         IOS;
         int ts =1;
         ///  cin >> ts ;
         while(ts--)
         {
            cin >> n >> k;
            rep(i,0,n) cin >> a[i];
            ll lo = 1 , hi = 1e9 , ans;
            while(lo <= hi)
            {
                ll mid = (lo + hi) >> 1;
                if(check(mid))
                {
                    hi = mid-1;
                    ans = mid;
                }
                else
                {
                    lo  = mid+1;
                }
            }
            cout << ans << endl;
         }
    }


Measured memory_bytes: 5120
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
struct edge{
    int to, cost;
    edge(int a = 0, int b = 0) : to(a), cost(b) {}
};
template<class E>
vector<ll> dijkstra(int s, const vector<vector<E>> &g){
    int n = (int)g.size();
    vector<ll> dist(n, 1LL<<60);
    using ll_i = pair<ll, int>;
    priority_queue<ll_i,vector<ll_i>,greater<ll_i>> pq;
    dist[s] = 0;
    pq.push({dist[s], s});
    while(!pq.empty()){
        auto a = pq.top();
        pq.pop();
        int v = a.second;
        if(a.first > dist[v])continue;
        for(auto &x : g[v]){
            if(dist[x.to] > dist[v] + x.cost){
                dist[x.to] = dist[v] + x.cost;
                pq.push({dist[x.to], x.to});
            }
        }
    }
    return dist;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, u, v;
    cin >> n >> u >> v;
    u--;v--;
    vector<vector<edge>> g(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].emplace_back(b,1);
        g[b].emplace_back(a,1);
    }
    auto d = dijkstra(u,g);
    auto dd = dijkstra(v,g);
    ll ans = 0;
    rep(i,n){
        if(d[i]> dd[i])continue;
        ans = max(ans, dd[i]-1);
    }
    cout << ans << endl;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

 int inf=1<<30;
 long long int infll=1LL<<62;
 double eps=1e-9;
 int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os,  vector<T> &vec){
    os << "[";
    for ( auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int h,w;
    cin >> h >> w;
    vector<vector<bool>> f(w,vector<bool>(h));
    for(int y=h-1; y>=0; --y) rep(x,0,w){
        char ch;
        cin >> ch;
        if(ch=='#') f[x][y]=true;
    }

    auto is_in_range=[&](int x,int y){
        return 0<=x and x<w and 0<=y and y<h;
    };

    auto is_flower=[&](int x,int y){
        return is_in_range(x,y) and f[x][y];
    };

    vector<pair<long double,bool>> events;
    rep(x,0,w+1) rep(y,0,h+1){
        if(!is_flower(x,y) and is_flower(x-1,y) and !is_flower(x-1,y-1)){
            events.push_back(make_pair(atan2l(y,x),true));
            continue;
        }
        if(is_flower(x,y) and is_flower(x,y-1) and is_flower(x-1,y-1) and !is_flower(x-1,y)){
            events.push_back(make_pair(atan2l(y,x),true));
            continue;
        }
        if(!is_flower(x,y) and is_flower(x,y-1) and !is_flower(x-1,y-1)){
            events.push_back(make_pair(atan2l(y,x),false));
            continue;
        }
        if(is_flower(x,y) and is_flower(x-1,y) and is_flower(x-1,y-1) and !is_flower(x,y-1)){
            events.push_back(make_pair(atan2l(y,x),false));
            continue;
        }
    }
    sort(events.begin(),events.end());

    int ans=0,cnt=1;
    for(auto &p:events){
        if(p.second) ++cnt;
        else --cnt;
        ans=max(ans,cnt);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 7108
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vsort(v);
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += v[i];
    }

    if (sum > v[n-1]) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n,k,a[111];
int dp[111][111111];
signed main(){
    cin>>n>>k;
    rep(i,0,n)cin>>a[i];
    rep(i,0,n+1)rep(j,0,k+1)dp[i][j]=0;
    dp[0][0]=1;
    rep(i,1,k+1)dp[0][i]+=dp[0][i-1];
    rep(i,1,n+1){
        rep(j,0,k+1){
            if(j>0)dp[i][j]=((dp[i][j-1]+dp[i-1][j])%mod-(j>a[i-1]?dp[i-1][j-a[i-1]-1]:0)+mod)%mod;
            else dp[i][j]=1;
            //cout<<dp[i][j]<<" ";
        }//cout<<endl;
    }
    cout<<(dp[n][k]-dp[n][k-1]+mod)%mod<<endl;
    return 0;
}

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

int main() {
    vector<int> input(3);
    rep(i, 3) cin >> input[i];
    rep(i, 3) {
        if (input[i] == input[(i + 1) % 3] &&
            input[(i + 1) % 3] != input[(i + 2) % 3]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(a > 0 && c > 0) {
		c -= b;
		if(c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if(a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;


void solve()
{
  string s;
  getline(cin,s);
  stack<int>st;
  int i=0;
	while(1){
    if(i>=s.size())break;
    string t="";
    while(s[i]!=' '){
      t+=s[i];
      ++i;
      if(i>=s.size())break;
    }
    char c;
    if(t.size()==1){
      c=t[0];
    }
    if((t.size()==1)&&(!isdigit(c))) {
      if(c=='+'){
        int x=st.top();
        st.pop();
        int y=st.top();
        st.pop();
        st.emplace(x+y);
      }
      else if(c=='-'){
        int y=st.top();
        st.pop();
        int x=st.top();
        st.pop();
        st.emplace(x-y);
      }
      else{
        int x=st.top();
        st.pop();
        int y=st.top();
        st.pop();
        st.emplace(x*y);
      }
    }
    else{
      st.emplace(stoi(t));
    }
    ++i;
  }
  cout<<st.top()<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3232
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()

	i := 0
	j := 0
	list := make([]int, 20)
	list[0] = 1

	for {
		if isOk(list, i, j) {
			printL(list, i)
			k--
			if k <= 0 {
				break
			}
		} else {
			list[j] = 9
			if j < i {
				j++
				continue
			}
		}
		if next(list, i, j) {
			i++
			j = 0
		}
	}
}

func isOk(list []int, i, j int) bool {
	n := calcN(list, i)
	sn := calcSn(list, i)
	for m := 0; m < j; m++ {
		sn *= 10
	}
	return n <= sn
}

func next(list []int, i int, j int) (top bool) {
	if list[j] == 9 {
		if i == j {
			for k := 0; k <= i; k++ {
				list[k] = 0
			}
			list[i+1] = 1
			return true
		} else {
			for k := j; true; k++ {
				if list[k] == 9 {
					list[k] = 0
				} else {
					list[k]++
					break
				}
			}
			if list[i+1] == 1 {
				return true
			}
			return false
		}
	} else {
		list[j]++
	}
	return false
}

func printL(list []int, i int) {
	for m := i; m >= 0; m-- {
		fmt.Print(list[m])
	}
	fmt.Println()
}

func calcN(list []int, i int) int {
	var sum int
	for k := i; k >= 0; k-- {
		sum *= 10
		sum += list[k]
	}
	return sum
}

func calcSn(list []int, i int) int {
	var sum int
	for _, v := range list[:i+1] {
		sum += v
	}
	return sum
}


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

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

    vector<int> h(n);
    rep(i, n)
    {
        cin >> h.at(i);
    }

    vector<int> dp(n, 0);
    rep(i, n - 1)
    {
        if (i == 0)
        {
            // 2番目の足場へのコスト
            dp.at(i + 1) = abs(h.at(i + 1) - h.at(i));
        }
        else
        {
            // 1個前からのジャンプ
            int c1 = dp.at(i) + abs(h.at(i + 1) - h.at(i));
            // 2個前からのジャンプ
            int c2 = dp.at(i - 1) + abs(h.at(i + 1) - h.at(i - 1));
            // i + 1 番目の足場への最小コスト
            dp.at(i + 1) = min(c1, c2);
        }
    }

    cout << dp.at(n - 1);
}


Measured memory_bytes: 1024
program forth
  implicit none
  integer, allocatable :: x(:), y(:)
  integer :: n, i
  integer :: tot, even, odd

  read(*,*) n
  allocate(x(n))
  allocate(y(n))

  read(*,*) x

  tot = 3 ** n ! biは3通り

  odd = 1
  do i = 1, n
     if (mod(x(i), 2) == 0) then
        odd = odd * 2
     else
        odd = odd * 1
     end if

  end do

  even = tot - odd

  write(*,*) even

  stop
end program forth


  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  string S, T;
  cin >> S >> T;
  map<char, int> dictS, dictT; // 文字列に登場する英小文字と登場回数
  for (int i=0; i<S.size(); i++) {
    if (dictS.count(S[i])) dictS[S[i]]++;
    else dictS[S[i]] = 1;
  }
  for (int i=0; i<T.size(); i++) {
    if (dictT.count(T[i])) dictT[T[i]]++;
    else dictT[T[i]] = 1;
  }
  vector<int> memoS, memoT; // mapのvalueのみ取り出した配列
  for (auto p: dictS) {
    auto value = p.second;
    memoS.push_back(value);
  }
  for (auto p: dictT) {
    auto value = p.second;
    memoT.push_back(value);
  }
  sort(memoS.begin(), memoS.end());
  sort(memoT.begin(), memoT.end());
  if (memoS==memoT) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  
  int N; cin >> N; vector<int> vec(N); int sum = 0;
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N - 1; i++) sum += vec.at(i);
  
  if (vec.back() < sum) cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
}

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

namespace AtCoderMake.ABC168
{
    class ABC168D
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select((x) => long.Parse(x)).ToArray();
            List<int>[] rooms = new List<int>[nm[0]];
            int[][] roots = new int[nm[0]][];
            for(int i = 0; i < nm[0]; i++) 
            {
                rooms[i] = new List<int>();
            }
            for(int i = 0; i < nm[1]; i++)
            {
                var ab = Console.ReadLine().Split().Select((x) => int.Parse(x) - 1).ToArray();
                rooms[ab[0]].Add(ab[1]);
                rooms[ab[1]].Add(ab[0]);
            }
            roots[0] = new int[2] { 0, 0 };
            roots = pathFind(rooms, new List<int>() { 0 }, roots, 1);
            bool checkFlag = true;
            //for(int i=1; i < nm[0]; i++)
            //{
            //    int[] roomMemo = new int[nm[0]];
            //    if(countRoot(rooms, new List<int>() { i }, roomMemo, 1) < roots[i][1])
            //    {
            //        checkFlag = false;
            //        break;
            //    }
            //}
            if (checkFlag)
            {
                Console.WriteLine("Yes");
                for (int i = 1; i < nm[0]; i++)
                {
                    Console.WriteLine(roots[i][0]+1);
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static int[][] pathFind(List<int>[] Pathes, List<int> findRoom,int[][] roots,int ordinal)
        {
            List<int> nextFind = new List<int>();
            int[][] newRoots = roots;
            foreach (int finding in findRoom)
            {
                foreach(int nextRoom in Pathes[finding])
                {
                    if (newRoots[nextRoom] == null)
                    {
                        newRoots[nextRoom] =new int[2] { finding, ordinal };
                        nextFind.Add(nextRoom);
                    }
                }
            }
            if (nextFind.Count > 0)
            {
               return pathFind(Pathes, nextFind, newRoots, ordinal + 1);
            }
            return newRoots;
        }

        static int countRoot(List<int>[] Pathes, List<int> findRoom, int[] rooms, int ordinal)
        {
            List<int> nextFind = new List<int>();
            int[] newRooms = rooms;
            foreach (int finding in findRoom)
            {
                foreach (int nextRoom in Pathes[finding])
                {
                    if (nextRoom == 0)
                    {
                        return ordinal;
                    }
                    if (newRooms[nextRoom] == 0)
                    {
                        newRooms[nextRoom] = 1;
                        nextFind.Add(nextRoom);
                    }
                }
            }
            if (nextFind.Count > 0)
            {
                return countRoot(Pathes, nextFind, newRooms, ordinal + 1);
            }
            return ordinal;
        }
    }
}


Measured memory_bytes: 68432
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;

string S, T;

int main()
{
    optimiza_io
    cin >> S >> T;
    T.pop_back();
    cout << ( S == T ? "Yes\n" : "No\n" ); 
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mod 1000000007
typedef long long int ll;
typedef long long  lint;
typedef pair<int,int> pii;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b ;
    return 0;
}

Measured memory_bytes: 3636
from math import sqrt,floor,ceil

a,b,n=map(int,input().split())

if(b>n):
    x=a*n
    print(floor(x/b))
elif(b==n):
    x=a*(n-1)
    x1=floor(x/b)
    y=floor(x/b)-a
    print(max(x1,y))
else:
    x=a*(b-1)
    print(floor(x/b))
        

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

int h, w, n, xi, yi;

int main(){
	scanf("%d %d %d", &h, &w, &n);
	
	set < pair <int, int> > s;
	for(int i = 0; i < n; i++){
		scanf("%d %d", &xi, &yi);
		xi--, yi--;
		
		s.insert(make_pair(yi, xi));
	}
	
	for(int i = 0; i < w; i++)
		s.insert(make_pair(i, h));
		
	int x = 0, y = 0, res = h;
	while(x < w){
		auto d = s.lower_bound(make_pair(x, y));
		res = min(res, d->second);
		
		bool moved = false;
		while(true){
			if(s.count(make_pair(x, y + 1))){
				break;
			}
			y++;
			
			if(!s.count(make_pair(x + 1, y))){
				x++;
				moved = true;
				break;
			}
		}
		
		if(!moved)break;
	}
	printf("%d\n", res);
	
	return 0;
}


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

int main()
{
    int N, K, X, Y, ans = 0;
    cin >> N >> K >> X >> Y;
    for (int i = 0; i < N; i++)
    {
        if (i < K)
        {
            ans += X;
        }
        else
        {
            ans += Y;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];

bool flag,dame;

void solve(ll p,ll q){
	num = 0;
	for(ll i=0;i<n;i++){
		bool exist = false;
		for(ll j=0;j<n;j++){
			if(x[j] == x[i] - p && y[j] == y[i] - q){
				exist = true;
				break;
			}
		}
		if(!exist)num++;
	}
	ans = min(ans,num);
	return ;
}


int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i];
	}
	ans = INF;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(i == j)continue;
			//iとjの差をpqとする
			ll p = x[i] - x[j];
			ll q = y[i] - y[j];
			if(p == 0 && q == 0)continue;
			solve(p,q);
			//ans = min(ans,solve(p,q));
		}
	}
	if(n == 1)ans = 1;
	p(ans);

	

	return 0;
}

Measured memory_bytes: 16512
#coding utf-8
import heapq
N,M=map(int,input().split())
AB= [[int(i) for i in input().split()] for i in range(N)]
AB.sort(reverse=True)
work=[]
heapq.heapify(work)
ans=0
for i in range(1,M+1):
  while AB and AB[-1][0] <=i:
      tmp=AB.pop()
      heapq.heappush(work,-tmp[1])
  if work:
    tmp=heapq.heappop(work)
    ans-=tmp
  
print(ans)

Measured memory_bytes: 21804
#include<stdio.h>
#include<math.h>
int main(void){
double a, b, C, S, L, h, l;
	double s;
	double c;
	
	scanf("%lf %lf %lf", &a, &b, &C);

	s = sin(C*3.1415926535/180);
	c = cos(C*3.1415926535/180);
	
	S = 0.5*a*b*s;
	
	l = (a*a)+(b*b)-(2*a*b*c);
	L = sqrt(l)+a+b;
	
	h = (2*S)/a;
	
	printf("%lf\n%lf\n%lf\n", S, L, h);
	
return 0;
}


Measured memory_bytes: 2032
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    dList = list(map(int, readline().rstrip().split()))
    m = int(readline().rstrip())
    tList = list(map(int, readline().rstrip().split()))
    dc = collections.Counter(dList)
    tc = collections.Counter(tList)
    tcKeys = list(tc.keys())
    for tcKey in tcKeys:
        if dc[tcKey] < tc[tcKey]:
            print("NO")
            return
    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 57120
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;

ll kz[534];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	ll n, m; cin >> n >> m;
	vector<queue<ll>> v(n);
	rep(i, n) {
		rep(j, m) {
			ll a; cin >> a; v[i].push(a);
		}
	}
	ll ans = n; vector<bool> visit(m + 1, false);
	ll a = 0, b = 0;//a:番号 b:数
	rep(ks, m) {
		//各人の今するスポーツ
		rep(i, n) {
			if (ks != 0 && v[i].front() != a) { continue; }
			while (true) {
				if (visit[v[i].front()]) { v[i].pop(); }
				else { kz[v[i].front()]++; break; }
			}
		}
		//各スポーツの数
		a = 0; b = 0;
		rep2(i, m) {
			if (b < kz[i]) { a = i; b = kz[i]; }
		}
		//cout << b << endl;
		kz[a] = 0; ans = min(ans, b); visit[a] = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int X, Y;
	cin >> X >> Y;
	bool isOK = false;
	for (int i = 0; i <= X; i++) {
		int j = X - i;
		if (2 * i + 4 * j == Y)isOK = true;
	}
	if (isOK)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll a[55];
ll tempcheck[55];
ll n;
bool check(ll t)
{
	for (int i = 1; i <= n; ++i)
		tempcheck[i] = (a[i] + t) / (n + 1LL);
	ull ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans += tempcheck[i];
		if (ans > t)return 0;
	}
	if (ans < t)return 1;
	else return 0;
}
int tt[60];
bool fit(ll t)
{
	for (int i = 1; i <= n; ++i)
		tempcheck[i] = (a[i] - n + t) / (n + 1LL);
	ull ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += tempcheck[i];
	for (int i = 1; i <= n; ++i)
		tt[i] = a[i] - tempcheck[i] * (n + 1) + ans;
	int flag = 1;
	while (flag)
	{
		for (int i = 1; i <= n; ++i)
		{
			if (tt[i] >= n)
			{
				tt[i] -= n;
				tempcheck[i]++;
				for (int j = 1; j <= n; ++j)
				{
					if (i != j)tt[j]++;
				}
			}
		}
		flag = 0;
		for (int i = 1; i <= n; ++i)
			if (tt[i] >= n)flag = 1;
	}
	ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += tempcheck[i];
	if (ans == t)return 1;
	else return 0;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll l = 0, r = 1000000000000000000LL;
	while (r - l > 1)
	{
		ll mid = (l + r) >> 1;
		if (check(mid))r = mid;
		else l = mid;
	}
	l -= 2000;
	r += 2000;
	for (ll i = max(l, 0LL); i <= r; ++i)
		if (fit(i)) { cout << i << endl; break; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

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

    if(s == "Sunny")
        cout << "Cloudy" << endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 3556