akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

main()
{
  int flag = 1, rest = 0;
  int n;
  int i;
  
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    char s[8];
    
    scanf(" %s", s);
    if (*s == 'A') ++rest;
    else --rest;
    if (rest < 0) flag = 0;
  }
  
  if (flag && rest == 0) {
    puts("YES");
  } else {
    puts("NO");
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 580
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long x, a, b;
    scan(x, a, b);
    auto z = abs(x - a) - abs(x - b);
    z = z / abs(z);
    auto ary = ["A", "", "B"];
    writeln(ary[z + 1]);
}


Measured memory_bytes: 256
function parseInt(x) parse(Int, x) end

function gcd(x,y)
	r = x%y
	while r > 0
		temp = r
		r = y%r
		y = temp
	end
	return(y)
end

function main()
	n = parseInt.(split(readline()))
	x = parseInt.(split(readline()))
	if n[1] == 1
		print(abs(x[1]-n[2]))
	else
		y = [0 for i in 1:n[1]]
		for i in 1:n[1]
			y[i] = abs(x[i]-n[2])
		end
		gcdd = gcd(y[1],y[2])
		if n[1] >= 3
			for i in 3:n[1]
				gcdd = gcd(gcdd, y[i])
			end
		end
		print(gcdd)
	end
end

main()

Measured memory_bytes: 143748
#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() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(12) << w * h / 2 << endl;
  if(2 * x == w && 2 * y == h) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

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

    int x[4][3][10];
    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                x[b][f][r] = 0;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;

        x[b - 1][f - 1][r - 1] += v;
    }

    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                cout << " " << x[b][f][r];
            }
            cout << endl;
        }
        if(b<3)
            cout << "####################" << endl;
    }
}


Measured memory_bytes: 3088
#include<iostream>

using namespace std;

int main(){
  long x = 0, y = 0, num = 0, dis = 0, count = 0;
  
  cin >> num;
  cin >> dis;
  
  for(int i = 0; i < num; i++){
  	cin >> x;
    cin >> y;
    
    if((x * x) + (y * y) <= dis * dis){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    int r = 0;
    ll now = 0;
    ll ans = 0;
    rep(l,N) {
        while (r < N && (now&A[r]) == 0) {
            now ^= A[r];
            ++r;
        }
        now ^= A[l];
        ans += r - l;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4840
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

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

const int N=100000+10;

int n; char s[N];

int main() {
	scanf("%s",s+1); n=strlen(s+1);
	int ans=0;
	for (int i=1;i<n;++i) ans+=s[i]!=s[i+1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
long long dp[4000];
int main()
{
    long long n,i;
    cin>>n;
    //cout<<n<<endl;
    dp[0]=100;
    for(i=1;dp[i-1]<n;i++)
    {
        dp[i]=floor(dp[i-1]*1.01);
        //cout<<1<<endl;
    }
    cout<<i-1<<endl;
    return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<vector>
using namespace std;vector<vector<int> >a(11,vector<int>(331));void r(int n,int u,int s,int d){a[n][s]++;for(int i=10;i-->0;)if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);}main(){r(0,0,0,1);for(int n,s;cin>>n>>s;)cout<<a[n][s]<<"\n";}

Measured memory_bytes: 808
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

const ll MA = 1000005;

int main() {

	ll n;

	cin >> n;

	vector<ll> a(n);

	vector<int> to(MA,0);

	rep(i, n) {
		cin >> a[i];

		if (to[a[i]] != 0) {
			to[a[i]] = 2;
			continue;
		}

		for(int x=a[i];x<MA;x+=a[i]){
		
			to[x]++;
		
		}
	}

	ll ans = 0;

	for (auto p : a) {

		if (to[p] < 2)ans++;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
string s, t;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> t;
  int n = sz(s);
  FOR(i, 0, n){
    FOR(j, 0, n) if(s[(i+j)%n] != t[j]) goto bad;
    cout << "Yes" << endl;
    return 0;
    bad: ;
  }
  cout << "No" << endl;
  return 0;
}

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

short sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(*this % *this); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

Point Proj(Point P, Point P1, Point P2) { // Projection
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

int q;

int main() {
	Point P1 = gp(), P2 = gp();
	scanf("%d", &q);
	while (q--) {
		Point P = gp();
		wp(Proj(P, P1, P2)); enter;
	}
	return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

const int M=10007;

int main()
{
	int n;cin>>n;
	string s;cin>>s;
	int a[1000];
	for(int i=0;i<n;i++)
	{
		if(s[i]=='J')a[i]=0;
		else if(s[i]=='O')a[i]=1;
		else a[i]=2;
	}
	int dp[8][1000]={};
	for(int i=0;i<8;i++)
	{
		if(i&1&&i>>a[0]&1)dp[i][0]=1;
	}
	
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<8;j++)
		{
			if(j>>a[i]&1)
			{
				for(int k=0;k<8;k++)
				{
					if(j&k&1||j>>1&k>>1&1||j>>2&k>>2&1)dp[j][i]=(dp[j][i]+dp[k][i-1])%M;
				}
			}
		}
	}
	
	int ans=0;
	
	for(int i=0;i<8;i++)
	{
		ans=(ans+dp[i][n-1])%M;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{

    int n, t, a;
    cin >> n >> t >> a;
    int h[n];
    int ans;
    float min = 100000;
    float ta;
    float dif;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        ta = t - 0.006 * h[i];
        //cout << ta;  //
        dif = a - ta;
        if (dif < 0) {
            dif *= -1;
        }
        if (dif < min) {
            min = dif;
            ans = i;
        }
    }
    ans += 1;
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;

    long long log_n = floor(log2(k));

    vector<vector <long long> > next(log_n+1, vector<long long>(n+1));

    for(long long i = 1; i <= n; i++){
        cin >> next[0][i];
    }

    for(int k = 0; k < log_n; k++){
        for(int i = 1; i <= n; i++){
            if(next[k][i] == -1){
                next[k+1][i] = -1;
            }
            else{
                next[k+1][i] = next[k][next[k][i]];//2^k乗先を求める
            }
        }
    }

    long long p = 1;
    //printf("log_n %lld\n", log_n);
    for(long long j = log_n; j >=0; --j){
        //printf("p %lld\n", p);
        //printf("j %lld\n", j);
        if(p == -1){
            break;
        }

        if((k >> j) & 1){
            //printf("bit p %lld\n", p);
            //printf("bit j %lld\n", j);
            p = next[j][p];
        }
    }

    printf("%lld\n", p);

    return 0;

}

Measured memory_bytes: 98688
#include "bits/stdc++.h"
using namespace std;

int main() {

	string S;
	cin >> S;

	if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi")
		cout << "Yes";

	else
		cout << "No";
}

Measured memory_bytes: 256
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;
const int Q_MAX = 100002;
const int D_MAX = 12;

int n, m, q;

vector <int> edges[N_MAX];

struct Query
{
    int u, d, c;
};

Query queries[Q_MAX];

int best[N_MAX][D_MAX];

queue <pair <int, int> > qu;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    cin >> q;
    for(int i = 1; i <= q; i++)
        cin >> queries[i].u >> queries[i].d >> queries[i].c;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= 10; j++)
            best[i][j] = -1;
    for(int i = q; i >= 1; i--)
    {
        if(best[queries[i].u][queries[i].d] != -1)
            continue;
        best[queries[i].u][queries[i].d] = i;
        qu.push(make_pair(queries[i].u, queries[i].d));
        while(!qu.empty())
        {
            pair <int, int> f = qu.front();
            qu.pop();
            if(f.second <= 0)
                continue;
            for(int v : edges[f.first])
                if(best[v][f.second - 1] == -1)
                {
                    best[v][f.second - 1] = i;
                    qu.push(make_pair(v, f.second - 1));
                }
        }
    }
    for(int i = 1; i <= n; i++)
    {
        int mx = INT_MIN;
        for(int j = 0; j <= 10; j++)
            mx = max(mx, best[i][j]);
        if(mx == INT_MIN)
            cout << "0\n";
        else
            cout << queries[mx].c << "\n";
    }
    return 0;
}


Measured memory_bytes: 15792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		string s;
		for(int i=0;i<n;i++)
		s+='a';
		while(m--){
			int p,q;
			cin>>p>>q;
			if(s[p-1]=='a'){
				s[p-1]=q+'0';
			}
			else{
				int z=s[p-1]-'0';
				if(z!=q){
					cout<<-1;
					return 0;
				}
			}
		}
		if(s[0]=='0'&&s.size()!=1){
			cout<<-1;
			return 0;
		}
		for(int i=0;i<n;i++){
			if(s[i]=='a'){
				if(s.size()==1)
				s[i]='0';
				else if(i==0){
				s[i]='1';
				}
				else
				s[i]='0';
			}
		}
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
ll mm(ll a,ll b,ll mod){
    ll res = 0;
    a %= mod;
    while(b){
        if (b & 1) res = (res + a) % mod;
        a = (2 * a) % mod;
        b >>= 1; // b = b / 2
    }
    return res;
} 
 
int main()
{
    fastio;
    ll n;
cin>>n;
ll a[n],b[n]={0},sum=0;
b[n-1]=a[n-1];
for(ll i=0;i<n;i++){ cin>>a[i]; b[i]=a[i];}
for(ll i=n-2;i>=0;i--) b[i]=(b[i+1]+b[i])%M;
for(ll i=0;i<n-1;i++){
sum=(sum+mm(a[i],b[i+1],M))%M;
}
cout<<sum<<"\n";
  
    
}

Measured memory_bytes: 6760
gets
ar = gets.split.map(&:to_i)
n = ar.size
putout = ->{puts ar.join(" ")}

putout.()
1.upto(n - 1) do |i|
  v = ar[i]
  j = i - 1
  while j >= 0 and ar[j] > v
    ar[j + 1] = ar[j]
    j -= 1
  end
  ar[j + 1] = v
  putout.()
end



Measured memory_bytes: 6884
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
typedef pair<ll,int> P;
int n;
ll a[500000];

int use[500000];

int main(){
	cin >> n;
	REP(i,3 * n) {
		cin >> a[i];
	}

	priority_queue<P,vector<P>, greater<P> >  fi,sc;

	REP(i,n) {
		fi.push(P(a[i],i));
	}

	vector<P> b;
	FOR(i,n,3 * n) {
		b.pb(P(a[i],i));
	}

	sort(b.begin(),b.end());

	FOR(i,n,2 * n) {
		sc.push(b[i]);
	}

	ll fisum = 0,scsum = 0;
	REP(i,n) {
		fisum += a[i];
		scsum += b[i].fi;
		use[b[i].sc] = true;
	}

	ll ans = fisum - scsum;

	FOR(i,n,2 * n) {
		if(a[i] > fi.top().fi) {
			fisum += (a[i] - fi.top().fi);
			fi.pop();
			fi.push(P(a[i],i));
		}
		if(use[i]) {
			while(sc.top().sc <= i) {
				sc.pop();
			}
			scsum = scsum - a[i] + sc.top().fi;
			use[sc.top().sc] = true;
			sc.pop();
		}
		ans = max(ans,fisum - scsum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12524
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, L;
    cin >> N >> L;
    vector<string>s(N);
    for (int i=0; i<N; i++)cin >> s[i];
    sort(all(s));
    for (int i=0; i<N; i++)cout << s[i];
    cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<long long,long long> pl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n; //3<=n<=1000
vector<vi> a;
int main() {
    cin>>n;
    a.resize(n);
    REP(i,n){
        a[i].resize(n-1);
        REP(j,n-1) {
            cin>>a[i][j];
            a[i][j]--;
        }  
        reverse(ALL(a[i])); //vectorは先頭より末尾をeraseするほうが速いらしいよ
    }

    vector<pi> q;

    auto check = [&](int i){
        if(a[i].size() == 0) return;
        int j = a[i].back();
        if(a[j].size() == 0) return;
        if(a[j].back() == i){
            pi p = pi(i,j);
            if(p.first > p.second) swap(p.first, p.second);
            q.emplace_back(p);
        }
    };

    REP(i,n){
        check(i);
    }

    int ans = 0;

    while(q.size() > 0){
        ans++;
        sort(ALL(q));
        q.erase(unique(ALL(q)), q.end()); //重複要素を削除する
        int qsize = q.size();

        REP(i,qsize){
            a[q[i].first].pop_back();
            a[q[i].second].pop_back(); 
            check(q[i].first);
            check(q[i].second);
        }

        q.erase(q.begin(), q.begin()+qsize);
    }

    REP(i,n){
        if(a[i].size() > 0){
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
n = int(input())

t = input().split()
sum=0
for i in t:
    sum+=int(i)

m = int(input())
A = []
for j in range(m):
    p, x = map(int, input().split())
    A.append(sum-int(t[p-1]) + x)
for k in A:
    print(k)

Measured memory_bytes: 3060
import java.util.List;
import java.util.ArrayList;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> values = new ArrayList<Integer>();
        List<Integer> costs = new ArrayList<Integer>();
        sc.nextLine();

        for (int i=0;i<n;i++){
            values.add(sc.nextInt());
        }

        sc.nextLine();

        for (int i=0;i<n;i++){
            costs.add(sc.nextInt());
        }

        int maxValue = 0;
        for (int i=0;i<n;i++){
            if((values.get(i)-costs.get(i))> 0){
                maxValue += values.get(i)-costs.get(i);
            }
        }
        System.out.println(maxValue);
    }

}


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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> v;

    for(int i = 0; i < N; i++){
        int aux; cin >> aux;
        v.push_back(aux);
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    long long alice = 0, bob = 0;

    for(int i = 0; i < N; i+=2){
        alice+=v[i];
    }
    for(int i = 1; i < N; i+=2){
        bob+=v[i];
    }

    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
typedef long long ll;

ll ds(ll b, ll n) {
  return n < b ? n : ds(b, n / b) + n % b;
}

int main(void) {
  ll i, j, k, n, s, t;
  scanf("%lld%lld", &n, &s);
  for(i = 2; i <= sqrt(n); ++i) if(ds(i, n) == s) {
    printf("%lld", i);
    return 0;
  }
  t = (int)sqrt(n);
  if((int)sqrt(n) == sqrt(n)) t--;
  for(i = t; i > 0; --i) {
    ll nowu = n / i, nowl = n / (i + 1) + 1, now = i + (n % nowl) - s;
    if(now < 0) continue;
    if(!(now % i) && nowl + now / i <= nowu) {
      printf("%lld", nowl + now / i);
      return 0;
    }
  }
  if(n == s) printf("%lld", n + 1);
  else printf("-1");
  return 0;
}

Measured memory_bytes: 128
from math import ceil 
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
def check(x):
    c=0
    l1=[i-b*x for i in l]
    for i in l1: 
         if i<=0:
             continue 
         c+=ceil((i)/(a-b))
    return c<=x
lo=0 
ans=-1 
hi=10**9+4 
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)


Measured memory_bytes: 119128
#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> p(n),q(n);
  rep(i,n){
    cin >> p.at(i);
  }
  rep(i,n){
    cin >> q.at(i);
  }
  vector<int> r=p;
  sort(r.begin(),r.end());
  int cnt_1,cnt_2,i=1;
  do{
    bool is_p=true,is_q=true;
    if(r==p){
      cnt_1=i;
    }
    if(r==q){
      cnt_2=i;
    }
    i++;
  } while(next_permutation(r.begin(), r.end()));
  cout << abs(cnt_1-cnt_2);
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  map<string, ll> mp;
  rep(i, n) {
    string s;
    cin >> s;
    sort(all(s));
    mp[s]++;
  }
  ll ans = 0;
  for(auto v : mp) ans += v.second * (v.second - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 11432
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N, M;
	cin >> N;
	
	map<int, int> m;
	map<int, int>::iterator ite;
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		
		ite = m.find(num);
		if(ite == m.end()){
			m.insert(make_pair(num, 1));
		}else{
			m[num] = m[num] + 1;
		}
	}
	
	cin >> M;
	
	bool flag = true;
	
	for(int i = 0; i < M; i++){
		int num;
		cin >> num;
		
		ite = m.find(num);
		if(ite == m.end()){
			flag = false;
		}else{
			m[num]--;
			if(m[num] == 0){
				m.erase(num);
			}
		}
	}
	
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10752
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    long long x,y,ans=1;
    cin>>x>>y;
    long long player=x;
    for(;;)
    {
        player*=2;
        if(player>y)
        {
            cout<<ans;
            WAIT;
            rt0;
        }
        ans++;
    }
    WAIT;
    rt0;
}


Measured memory_bytes: 504
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int alt, anch, t, i;
    while(1)
    {
        scanf("%d %d", &alt, &anch);
        if(alt == 0 && anch == 0)
            break;
            for(t = 0;t < alt;t++)
            {
                for(i = 0;i < anch;i++)
                    printf("#");
                    printf("\n");
            }
            printf("\n");
    }
    return 0;
}





Measured memory_bytes: 2100
using System;
using System.Collections;
using System.Linq;

class Prog
{
    public static void Main(string[] args)
    {
        string[] numt = new string[9];
        for (int i = 0; i < 3; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            for (int j = 0; j < 3; j++)
            {
                //Console.WriteLine(i + j);
                numt[3 * i + j] = input[j];
            }
        }

        //Console.WriteLine("test");

        int[] num = new int[9];
        for (int i = 0; i < 9; i++)
        {
            //Console.WriteLine(numt[i]);
            num[i] = int.Parse(numt[i]);
        }

        //Console.WriteLine("test2");

        bool[] b = new bool[9];
        for (int i = 0; i < 9; i++) { b[i] = false; }

        int N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++)
        {
            int input = int.Parse(Console.ReadLine());
            for (int j = 0; j < 9; j++)
            {
                //Console.WriteLine(num[j] + " " + input);
                if (num[j] == input) b[j] = true;
                //Console.WriteLine(b[j]);
            }
        }

        if (b[0] && b[1] && b[2]) Console.WriteLine("Yes");
        else if (b[3] && b[4] && b[5]) Console.WriteLine("Yes");
        else if (b[6] && b[7] && b[8]) Console.WriteLine("Yes");
        else if (b[0] && b[3] && b[6]) Console.WriteLine("Yes");
        else if (b[1] && b[4] && b[7]) Console.WriteLine("Yes");
        else if (b[2] && b[5] && b[8]) Console.WriteLine("Yes");
        else if (b[0] && b[4] && b[8]) Console.WriteLine("Yes");
        else if (b[2] && b[4] && b[6]) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}
/*
         1 2 3
         4 5 6
         7 8 9
         */


Measured memory_bytes: 13140
input = gets.split
num_sum = 0

for target in 1..input[0].to_i
  num = target
  target_sum = 0
  while num > 0
    num_tmp = num.divmod(10)
    num = num_tmp[0]
    target_sum += num_tmp[1]
  end
  if target_sum.between?(input[1].to_i, input[2].to_i)
    num_sum += target
  else
    next
  end
end

puts num_sum


Measured memory_bytes: 14344
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt()/200;
        System.out.println(10-N);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35640
#include<cstdio>

int N,a,b,c,d;
char s[10];
int main(){
    scanf("%d",&N);
    for(int i = 1; i <= N; ++i){
        scanf("%s",s);
        if(s[0] == 'A') ++a;
        else if(s[0] == 'W')    ++b;
        else if(s[0] == 'T')    ++c;
        else    ++d;
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",b);
    printf("TLE x %d\n",c);
    printf("RE x %d\n",d);
    return 0;
}

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

using namespace std;

int main(){
  int n;
  int a,b,c;
  vector<int> list;
  vector< vector<int> > lists;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> a >> b >> c;
    list.clear();
    list.push_back(a);
    list.push_back(b);
    list.push_back(c);
    sort(list.begin(),list.end());
    lists.push_back(list);
  }

  for(int i=0; i<n; i++){
    list = lists[i];
    if(list[0]*list[0] + list[1]*list[1] == list[2]*list[2]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1260
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

    double sum = 0;
    for(int i = 0; i < n; i++){
        double x;
        string u;

        cin >>x >>u;
        if(u == "BTC"){
            sum += x * 380000;
        }else{
            sum += x;
        }
    }

    printf("%lf\n", sum);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int,int);

int main(void){
  int x,y;
  scanf("%d", &x);
  scanf("%d", &y);

  printf("%d\n",gcd(x,y));


  return 0;
}

int gcd(int x, int y){
  int big, small, temp;
  if(x>y){
    big = x;
    small = y;
  }
  else{
    big = y;
    small = x;
  }
  while(small!=0){
    temp=big%small;
    big=small;
    small=temp;

  }
  return big;

}



Measured memory_bytes: 2092
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve() {
    ll n, m;
    cin>>n>>m;
    char arr[n][m];
    for(int i = 0; i < n;i ++) {
        for(int j = 0; j < m ; j++) {
            cin>>arr[i][j];
        }
    }

    ll dp[n+1][m+1] ;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <=m ;j++) {
            dp[i][j] = 0;
        }
    }

    dp[1][1] = 1;
    for(int i =1; i <= n ; i++) {
        for(int j = 1; j <= m ;j++) {
            if(i == 1 && j == 1) {
                continue;
            }
            if(arr[i-1][j-1] == '.') {
                dp[i][j] = dp[i-1][j] % mod + dp[i][j-1] % mod;
                dp[i][j] = dp[i][j] % mod;
            }
        }
    }
    
    cout<<dp[n][m] % mod;
}
int main()
{
    ll t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
return 0;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define mem(a) memset(a,0,sizeof a)
#define ll long long 
int n;
int vis[100005];

int main() {

	scanf("%d", &n);
	mem(vis);
	int a;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a);
		vis[a]++;
		if(a) vis[a - 1]++;
		vis[a + 1]++;

	}
	int ans = 0;
	for (int i = 0; i <= 100000; i++) ans = max(ans, vis[i]);
	printf("%d\n", ans);
	//system("pause");

	return 0;
}

/*
100
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 

*/

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	vector<int> V(M);
	vector<int> Diff(M - 1);

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

	sort(all(V));

	for (int i = 0; i + 1 < M; i++)
	{
		Diff[i] = V[i + 1] - V[i];
	}

	sort(all(Diff));

	lint ans = 0;
	for (int i = 0; i + 1 < M - N + 1; i++)
	{
		ans += Diff[i];
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A <= C && C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double n = saori.Hayamin();
		n = n/3;
		System.out.println(n*n*n);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 19284
#include <stdio.h>

int main(){
        int a, b, t;
        scanf("%d %d %d\n", &a, &b, &t);
        int aa = 2*a;
        int tt = 2*t + 1;
        int ans = (tt / aa) * b;
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 128
import numpy as np
H,W=map(int,input().split())
S=np.array([list(input()) for _ in range(H)]) == "."

U=np.zeros((H,W), dtype=int)
D=np.zeros((H,W), dtype=int)
R=np.zeros((H,W), dtype=int)
L=np.zeros((H,W), dtype=int)

for i in range(H):
    if i==0:
        U[i,:]=S[i,:]
    else:
        U[i,:]=(U[i-1,:]+1)*S[i,:]

for i in range(H-1,-1,-1):
    if i==H-1:
        D[i,:]=S[i,:]
    else:
        D[i,:]+=(D[i+1,:]+1)*S[i,:]

for i in range(W):
    if i==0:
        L[:,i]=S[:,i]
    else:
        L[:,i]+=(L[:,i-1]+1)*S[:,i]
        
for i in range(W-1,-1,-1):
    if i==W-1:
        R[:,i]=S[:,i]
    else:
        R[:,i]+=(R[:,i+1]+1)*S[:,i]
    
print(np.max(U+D+R+L-3))

Measured memory_bytes: 219708
#include <stdio.h>

int main() {
	int N;
	int H[20];
	int i;
	int max = 0;
	int count = 1;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	max = H[0];

	for (i = 1; i < N; i++) {
		if (max <=H[i]) {
			max = H[i];
			count++;
		}
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    map<char, ll> init;
    rep(i, n) {
        string s;
        cin >> s;
        init[s[0]]++;
    }
    string t = "MARCH";
    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += init[t[i]] * init[t[j]] * init[t[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(0, a+1):
  for j in range(0, b+1):
    for k in range(0, c+1):
      if 500*i+100*j+50*k==x:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    pii p[N], q[N];
    rep(i, N){
        int a, b;
        cin >> a >> b;
        p[i] = pii(a, b);
    }
    sort(p, p+N);
    rep(i, N){
        int c, d;
        cin >> c >> d;
        q[i] = pii(c, d);
    }
    sort(q, q+N);
    bool used[N];
    fill_n(used, N, false);
    int ans = 0;
    rep(i, N){
        int c = q[i].first, d = q[i].second;
        int k = -1, M = -1;
        rep(j, N){
            int a = p[j].first, b = p[j].second;
            if(!used[j] && a < c && b < d && b > M){
                k = j;
                M = b;
            }
        }
        if(k != -1){
            used[k] = true;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 100005
int dp[MX];
int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; ++i)
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	cout << dp[n - 1] << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}

int main(){
  ll n=read(),a=read(),b=read(),ans=1e9,c=a-b;
  vector<ll> h(n);
  rep(i,n){
    h[i]=read();
  }
  ll left=1,right=1e9,mid,cnt=0;
  while (right!=left+1) {
    mid =(right+left)/2;
    cnt=0;
    rep(i,n){
      ll temp=h[i]-b*mid;
      if(temp>0){
        cnt+=ceil(1.0*temp/c);
      }
    }
    if(cnt<mid){
      right=mid;
    }else left=mid;
  }
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*right;
    if(temp>0){
      cnt+=ceil(1.0*temp/c);
    }
  }
  ans=min(ans,max(cnt,right));
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*left;
    if(temp>0){
      cnt+=ceil(1.0*temp/c);
    }
  }
  ans=min(ans,max(cnt,left));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#define MOD 1000000007LL

typedef long long ll; 

ll addm(ll a, ll b){
    ll x = (a%MOD+b%MOD)%MOD;
    if (x < 0) x+=MOD;
    return x;
}

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

ll pwm(ll x,ll n){
    x%=MOD;
    ll ans = 1;
    while(n){
        if(n&1) ans=mulm(ans,x);
        x=mulm(x,x);
        n>>=1;
    }
    return ans;
}
 
int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    ll ans=0;
    ll v[K];
    for(int i = K-1;i>=0;i--) {
        v[i] = pwm(K/(i+1),N);
        for(int j = 2*(i+1); j <= K;j+=(i+1)) v[i]=addm(v[i],-v[j-1]);
    }
    for(int i = 0; i<K; i++) ans=addm(ans,mulm(v[i],(addm(i,1LL))));
    printf("%lld\n",ans%MOD);
    return 0;
}

Measured memory_bytes: 2428
N = int(input())
count = 0
target = 0

for i in range(1, N + 1):
    if i % 2 == 0:
        continue
    for k in range(1, round(i ** (1/2))):
        if i % k == 0:
            count += 1
    if count == 4:
        target += 1
    count = 0

print(target)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll H, N;
    cin >> H >> N;
    ll S = 0;
    REP(i, N){
    	ll tmp;
    	cin >> tmp;
    	S += tmp;
    }

    cout << (S>=H ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  int t = 0;
  if (L < 0 && (N + L) > 0){
    for (int i = 0; i < N; i++){
      t += (L + i);
    }
  }
  else if (L < 0 && (N + L) <= 0){
    for (int i = 0; i < (N - 1); i++){
      t += (L + i);
    }
  }
  else{
    for (int i = 1; i < N; i++){
      t += (L + i);
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int F(long long int a,long long int b)
{
	int ta=0,tb=0;
	while(a>0)
	{
		a/=10;
		ta++;
	}
	while(b>0)
	{
		b/=10;
		tb++;
	}
	return ta>ta ? ta : tb;
}
int main()
{
	long long int n;
	cin>>n;
	long long int a,b,min=0x7fffffff;
	for(int i=1;i<=sqrt(n);i++)
	{
		if(n%i!=0)
		{
			continue;
		}
		a=i;
		b=n/i;
		if(F(a,b)<min)
		{
			min=F(a,b);
		}
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<math.h>

int main() {
	int a[4],s;
	scanf("%d", &s);
	for (int i = 0; i < 4; i++) {
		a[i] = s / (int)pow(10,3-i);
		s %= (int)pow(10, 3-i);
      #ifdef DEBUG
        printf("%d\n",a[i]);
      #endif DEBUG
	}
	
	for (int mask = 0; mask < pow(2, 3); mask++) {
		int sum = a[0] + a[1] + a[2] + a[3];
		char o[3] = { '+','+','+' };
		for (int i = 0; i <=2; i++) {
			if (mask & (int)pow(2,i)) {
				sum -= 2 * a[i + 1];
				o[i] = '-';
			}
		}
		if (sum == 7) {
			printf("%d%c%d%c%d%c%d=7", a[0], o[0], a[1], o[1], a[2], o[2], a[3]);
			break;
		}
	}

	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

bool solve(ll a, ll b, ll c, ll k) {
    if (a < b && b < c) {
        return true;
    }
    if (k == 0) {
        return false;
    }
    if (solve(a * 2, b, c, k - 1) || solve(a, b * 2, c, k - 1) ||
        solve(a, b, c * 2, k - 1)) {
        return true;
    } else {
        return false;
    }
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    bool ans = solve(a, b, c, k);
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3620
#abc333b
import sys

n=int(raw_input())
s=[]
for i in xrange(n):
 s.append(raw_input())
if len(s)!=len(set(s)):
 print 'No'
 sys.exit()
for i in xrange(n-1):
 if s[i][-1]!=s[i+1][0]:
  print 'No'
  sys.exit()
print 'Yes'


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;
 
 
 
int main(){
   int n; cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
 
    vector<ll> sum(n+1);
    rep(i,n){
        sum.at(i+1) = sum.at(i) + a.at(i);
    }
 
    map<ll,ll> nums;
    rep(i,n+1) nums[sum[i]] ++;
 
   
    ll ans=0;
    for(auto it:nums){
        ll num = it.second;
      ans += num*(num-1)/2;
    }
    cout << ans << endl;
}

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

using namespace std;

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

  string s;
  cin >> s;
  int t = count(s.begin(), s.end(), 'A');
  cout << (t == 0 or t == s.size() ? "No" : "Yes");

  return 0;
}

Measured memory_bytes: 256