akhauriyash/Code-Regression huggingface dataset:
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

struct point {
    int64_t x;
    int64_t y;
};

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000
)");
#endif
    int N, M;
    in >> N >> M;
    vector<point> students(N);
    vector<point> checkpoints(M);

    for (int i = 0; i < N; ++i) {
        int64_t a, b;
        in >> a >> b;
        students[i].x = a;
        students[i].y = b;
    }

    for (int i = 0; i < M; ++i) {
        int64_t c, d;
        in >> c >> d;
        checkpoints[i].x = c;
        checkpoints[i].y = d;
    }

    for (int i = 0; i < N; ++i) {
        int64_t min_dist = static_cast<int64_t>(1e16);
        int min_index = -1;
        for (int j = 0; j < M; ++j) {
            int64_t dist = abs(students[i].x - checkpoints[j].x) + abs(students[i].y - checkpoints[j].y);
            if (dist < min_dist) {
                min_dist = dist;
                min_index = j;
            }
        }

        cout << min_index + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
ll a[1000], b[1000], c[1000];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 1; i <= n; i++)
    {
        long long sum = 0;
        for(int j = i; j < n; j++)
        {
            if(sum <= b[j])sum = b[j];
            else
            {
                sum=b[j]+((sum-b[j])/c[j]+(bool)((sum-b[j])%c[j]))*c[j];


            }
            sum += a[j];
        }
        if(i ==  n)sum = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool isplin(string s){
    int l=0,h=s.size()-1;
    while(l<h){
        if(s[l]==s[h]) {
            l++;
            h--;
            continue;
        }
        else return false;
    }
    return true;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     string s;
     while(cin>>s){
            int n=s.size();
        string t=s.substr(0,(n-1)/2);
        string ant=s.substr(((n+3)/2)-1,n-(((n+3)/2)-1));
        if(isplin(s) && isplin(t) && isplin(ant)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long h[100010],a[100010],maxx=-1; 
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
		a[i]=h[i];
		if(maxx-h[i]>=2)
		{
			cout<<"No";
			exit(0);
		}
		maxx=max(maxx,a[i]);
	}
	cout<<"Yes";
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  bitset<100> isdivisbleA;
  bitset<100> isdivisbleB;

  rep(i,A){
    if(A%(i+1)==0){
      isdivisbleA.set(i);
    }
  }
  rep(i,B){
    if(B%(i+1)==0){
      isdivisbleB.set(i);
    }
  }
  int ans;
  bitset<100> isok= isdivisbleA & isdivisbleB;
  int m=0;
  for(int i=99;i>=0;i--){
    if(isok[i]){
      m++;
      if(m==K){
        ans= i+1;
        goto end;
      }
    }
  }
  end:
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    if(b / a > c) cout << c << endl;
    else cout << b / a << endl;
    
}

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

typedef long long i64;

i64 n;
i64 x;


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

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

	cout << 3LL * (n - ::gcd(n,x));
	return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cctype>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#define LL long long
#define ULL unsigned  long long
#define maxn (LL)1e5
#define INF 0x3f3f3f3f
#define inf 0x7fffffff
#define PI  acos(-1.0)
#define pb push_back
#define re register LL
const double eps = 0.0000001;
using namespace std;
typedef pair<LL,LL> pii;
inline LL sgn(double x)
{
    return (x > eps) - (x < -eps);
}
const int N=1e6+2;
int f[N];
int main()
{
    int m,d,num=0;
    cin>>m>>d;
    for(int i=1; i<=m; i++)
        for(int j=22; j<=d; j++)
        {
            if(((j/10)*(j%10)==i)&&(j/10>=2&&j%10>=2))
            {
                num++;
            }
        }
    cout<<num;
}


Measured memory_bytes: 256
H, W = [int(_) for _ in input().split()]
a = [[int(_) for _ in input().split()] for i in range(H)]

x, y = 0, 0

result = []

while 1:
    if y % 2 == 0:
        if x < W - 1:
            dx, dy = 1, 0
        else:
            dx, dy = 0, 1
    else:
        if x > 0:
            dx, dy = -1, 0
        else:
            dx, dy = 0, 1
    tx, ty = x + dx, y + dy
    if ty >= H:
        break
    v = a[y][x]
    if v % 2 == 1:
        a[y][x] = 0
        a[ty][tx] += v
        result.append((y+1, x+1, ty+1, tx+1))
    x, y = tx, ty

print(len(result))
for r in result:
    print(*r)


Measured memory_bytes: 26592
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;

const int N = 2e5+10;
const int MOD = 998244353;
ll fac[N], inv[N];
ll fpow(ll a, ll k) { ll b = 1; for (; k; k>>=1,a=a*a%MOD) if (k&1) b=b*a%MOD; return b; }
ll C(ll x, ll y) { return x < 0 || y < 0 || x < y ? 0 : 1ll * fac[x] * inv[y] % MOD * inv[x-y] % MOD; }

int main(){
    IOS;
    fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for (int i = 2; i < N; i++)fac[i] = i * fac[i-1] % MOD, inv[i] = (MOD-MOD/i) * inv[MOD%i] % MOD;
    for (int i = 2; i < N; i++)inv[i] = inv[i-1] * inv[i] % MOD;
    int n,m,k;cin>>n>>m>>k;
    ll ans=0;
    for(int i=0;i<=k;i++)ans=(ans+m*fpow(m-1,n-i-1)%MOD*C(n-1,n-i-1)%MOD)%MOD;
    cout<<ans<<endl;
      
    return 0;
}

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  vector< vector<bool> > dp1(n + 1, vector<bool>(k, false));
  vector< vector<bool> > dp2(n + 1, vector<bool>(k, false)); 
  dp1[0][0] = dp2[n][0] = true;
  for (int i = 0; i < n; i++) {
    dp1[i + 1] = dp1[i];
    for (int j = k - 1; j >= a[i]; j--) {
      dp1[i + 1][j] = dp1[i + 1][j] or dp1[i][j - a[i]];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    dp2[i] = dp2[i + 1];
    for (int j = k - 1; j >= a[i]; j--) {
      dp2[i][j] = dp2[i][j] or dp2[i + 1][j - a[i]];
    }
  }
  auto needed = [&](int i) {
    if (a[i] >= k) return true;
    int x = 0, y = k - 1;
    while (true) {
      while (x < k and not dp1[i][x]) x++;
      if (x == k) break;
      while (x + y >= k - a[i]) {
        if (y >= 0 and dp2[i + 1][y]) return true;
        y--;
      }
      x++;
    }
    return false;
  };
  int l = -1, r = n;
  while (true) {
    int m = (l + r) / 2;
    if (needed(m)) r = m;
    else l = m;
    if (r - l == 1) break;
  }
  cout << r << '\n';
  return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,INF=0x3f3f3f3f;
int n,m,a[N],fa[N],vis[N],mi[N];
typedef pair<int,int> pii;
priority_queue<pii, vector<pii >, greater<pii > >Q;
int find(int x)
{
    return x==fa[x]?x:(fa[x]=find(fa[x]));
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>a[i],fa[i]=i,mi[i]=INF;
    for(int i=0,u,v; i<m; i++)
    {
        cin>>u>>v,u=find(u),v=find(v);
        if(u!=v)fa[u]=v;
    }
    for(int i=0; i<n; i++)find(i);
    for(int i=0; i<n; i++)
        mi[fa[i]]=min(a[i],mi[fa[i]]),Q.push(make_pair(a[i],fa[i]));
    sort(fa,fa+n);
    int tn=unique(fa,fa+n)-fa;
    if(tn==1)
        cout<<0;
    else if((tn-1)*2>n)
        cout<<"Impossible";
    else
    {
        long long s=0;
        for(int i=0; i<tn; i++)
            s+=mi[fa[i]];
        while(!Q.empty())
        {
            if(tn==2)break;
            pii t=Q.top();
            Q.pop();
            if(!vis[t.second])
            {
                vis[t.second]=1;
                continue;
            }
            s+=t.first,--tn;
        }
        cout<<s;
    }
    return 0;
}

Measured memory_bytes: 2676
fun main(args: Array<String>) {
    val str = readLine()!!
    var result: Long = 0

    for (i in 0 until str.length) {
        val no = Integer.parseInt(str[i].toString())
        for (j in 0 until str.length - i) {
            val temp = (no.toDouble()
                    * Math.pow(10.0, j.toDouble())
                    * Math.pow(2.0, i.toDouble())
                    * Math.pow(2.0, Math.max(str.length - 2 - j - i, 0).toDouble())
                    ).toLong()
            result += temp
            //println("i:$i,j:$j,no:$no,temp:$temp")
        }
    }
    println(result)
}

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

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

    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int ans = 0;
    int count = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (h[i] >= h[i+1]) {
            ++count;
        } else {
            count = 0;
        }
        ans = max({ans, count});
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define MAX 24

int N,x[MAX],y[MAX],r[MAX],c[MAX];

int dist(int a,int b){
    return (x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]);
}

bool check(int a,int b){
    int d = dist(a,b);
    int add = r[a]+r[b],sub = r[a]-r[b];
    return ((sub*sub < d && d < add*add) || d <= sub*sub);
}

int main(){
    while(cin >> N, N){
        for(int i = 0 ; i < N ; i++){
            cin >> x[i] >> y[i] >> r[i] >> c[i];
        }
        int bit[MAX] = {0};
        for(int i = 0 ; i < N ; i++){
            for(int j = 0 ; j < i ; j++){
                if(check(i,j)) bit[i] |= (1<<j);
            }
        }
        vector<bool> dp(1<<N,0);
        dp[(1<<N)-1] = 1;
        int res = 0;
        for(int i = (1<<N)-1 ; i >= 0 ; i--){
            if(dp[i] == 0) continue;
            if(N%2 == 0 && __builtin_popcount(i) % 2 == 1) continue;
            if(N%2 == 1 && __builtin_popcount(i) % 2 == 0) continue;
            for(int j = 0 ; j < N ; j++){
                if(__builtin_popcount(i&bit[j]) > 0) continue;
                for(int k = j+1 ; k < N ; k++){
                    if(c[j] != c[k]) continue;
                    if(__builtin_popcount(i&bit[k]) > 0) continue;
                    int S = i & ~((1<<j) | (1<<k));
                    dp[S] = 1;
                    res = max(res,N-__builtin_popcount(i));
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        for k in range(j+1, len(l)):
            if l[i] == l[j]:
                continue
            elif l[i] == l[k]:
                continue
            elif l[j] == l[k]:
                continue
            elif l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                ans += 1
print(ans)


Measured memory_bytes: 9208
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//ll d,x,ans;
//vector<ll>vec,res;
//ll next(ll a)
//{
//	ll cnt=10;
//	while(a%10==0)
//	{
//		a/=10;
//		cnt*=10;
//	}
//	if(a<100)return -1;
//	return a/100*cnt;
//}
//void dfs(int x,ll k)
//{
//	cout<<x<<' '<<k<<endl;
//	if(x==vec.size())
//	{
//		if(k==0)
//		{
//			ll cnt=1;
//			for(int i=0;i<res.size();i++)
//				cnt*=9ll-res[i];
//			ans+=cnt;
//		}
//		return;
//	}
//	res.push_back(k%10);
//	dfs(x+1,abs(k-k%10*vec[x])/10);
//	res.pop_back();
//	if(k%10!=0)
//	{
//		res.push_back(10-k%10);
//		dfs(x+1,abs(k+(10-k%10)*vec[x])/10);
//		res.pop_back();
//	}
//}
//int main()
//{
//	cin>>d;
//	if(d%9!=0)
//	{
//		cout<<0;
//		return 0;
//	}
//	d/=9;
//	for(int i=2;;i++)
//	{
//		x*=10ll;
//		x++;
//		ll y=x;
//		vec.clear();
//		res.clear();
//		vec.push_back(x);
//		while(next(y)!=-1)
//		{
//			vec.push_back(next(y));
//			y=next(y);
//		}
//		for(int j=0;j<vec.size();j++)cout<<vec[j]<<' ';
//		cout<<endl;
//		if(vec[vec.size()-1]>d)
//		{
//			if(i%2==1)dfs(0,d);
//			cout<<ans;
//			return 0;
//		}
//		dfs(0,d);
//	}
//	return 0;
//} 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll rt[30];
int main()
{
	ll D;
	cin>>D;
	rt[0]=1;
	for(int i=1;i<30;i++)rt[i]=rt[i-1]*10ll;
	ll ret=0;
	for(int i=2;i<=20;i++)
	{
		int k=i/2;
		for(int S=0;S<1<<k;S++)
		{
			ll way=i%2==1?10:1,zan=D;
			for(int j=0;j<k;j++)
			{
				ll d=llabs(zan)%10ll;
				if(zan<0)
				{
					d=10-d;
					d%=10;
				}
				if(S>>j&1)
				{
					ll nm=10ll-d;
					if(j==0)nm--;
					way*=nm;
					zan+=d*rt[i-2*j-1];
					zan-=d;
				}
				else
				{
					ll nm=d;
					if(j==0)nm--;
					if(nm<0)
					{
						way=0;
						break;
					}
					way*=nm;
					zan-=(10ll-d)*rt[i-2*j-1];
					zan+=10ll-d;
				}
				zan/=10ll;
			}
			if(zan==0)ret+=way;
		}
	}
	cout<<ret<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;

int main() {
  int n;
  bool flag = true;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
      flag = false;
    }
  }

  if (flag) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>

int main() {
  int d = 0;
  scanf("%d", &d);

  char *e = "Eve", *s = "Christmas";

  int x = fabs(25 - d);

  printf("%s", s);
  while (x--) {
    printf(" %s", e);
  }

  return 0;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
	}
	
	const int N=1e6+10;
	ll solve(int n,int wt)
	{
		//debug("solve(%d,%d)=%d\n",n,wt,C(n-1,n-wt-1));
		return C(n-1,n-wt-1)*C(n,wt)%MOD;
	}
	ll CC(int n,int m)
	{
		ll ret=1;fo(i,1,m) ret=ret*invm(i)%MOD;
		fd(i,n,n-m+1) ret=ret*i%MOD;return ret;
	}
	void main()
	{PRE();
		int n=qread(),a=qread(),b=qread();
		ll ans=qpower(2,n)-1-CC(n,a)-CC(n,b);
		write((ans%MOD+MOD)%MOD);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"\n---------------------Zory-------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 78336
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100;
int n;
int x[N],y[N];
map <pair <int,int>,int> a;
int main(){
	int n=read(),k=read();
	if (k==1)
		cout<<0;
	else 
		cout<<n-k;
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define Icin(s) ll (s);cin>>(s);
#define Scin(s) ll (s);cin>>(s);
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    e=e/(100+e)*100;
   // cout<<e<<endl;
    ld MS=e*f/100;
    vector<ld> vec;
    //cout<<MS<<endl;
    rep(i,3005){
        if(i*c>MS)break;
        rep(j,3005){
            if(i*c+j*d>MS)break;
            vec.push_back(i*c+j*d);
        }
    }
   // rep(i,vec.size())cout<<vec[i]<<" ";
//    cout<<endl;
    sort(all(vec));
     decltype(vec)::iterator result = std::unique(all(vec));
    vec.erase(result, vec.end());
   //  rep(i,vec.size())cout<<vec[i]<<" ";
    //cout<<vec.size()<<endl;
    vector<ld> water;
    rep(i,105){
        if(a*i*100>f)break;
        rep(j,105){
            if(a*i*100+b*j*100>f)break;
            water.push_back(a*i*100+b*j*100);
        }
    }
    ld res_w=0;
    ld res_s=0;
    ld den=0;
    //cout<<water.size()<<" "<<vec.size()<<endl;
    rep(i,water.size()){
        rep(j,vec.size()){
            if((vec[j])/(water[i]+vec[j])*100<=e&&vec[j]+water[i]<=f&&(vec[j]+water[i])/water[i]*100>den){
                den=(vec[j]+water[i])/water[i]*100;
                res_w=water[i];
                res_s=vec[j];
            }
        }
    }
    cout<<res_w+res_s<<" "<<res_s<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
int H,W,A,B;
int rx[1005],ry[1005];
int main(){
	scanf("%d%d%d%d",&H,&W,&A,&B);
	For(s1,0,H) For(s2,0,W){
		int v1=s1*A+(H-s1)*(W-A);
		int v2=s2*B+(W-s2)*(H-B);
		if (v1==v2){
			//printf("%d %d\n",s1,s2);
			For(i,1,s1) rx[i]=A;
			For(i,s1+1,H) rx[i]=W-A;
			For(i,1,s2) ry[i]=B;
			For(i,s2+1,W) ry[i]=H-B;
			For(i,1,H){
				For(j,1,W){
					if (rx[i]&&ry[j]){
						--rx[i]; --ry[j];
						putchar('1');
					}
					else
						putchar('0');
				}
				puts("");
			}
			return 0;
		}
	} 
	puts("-1");
}
/*
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
}*/
/*
11000
01100
00110
00011
10001 
*/

Measured memory_bytes: 1280
"""自分で考えたやつ

N = int(input())
S = []
for i in range(N):
    s = str(input())
    s = ''.join(sorted(s))
    S.append(s)

count = 0
for i in range(N):
    Si = S[i]
    for k in range(N):
        if i==k:
            None
        else:
            Sk = S[k]
            if Sk == Si:
                count += 1

print(count / 2)
"""

N = int(input())
dic = {}
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if s in dic:
        ans += dic[s]
        dic[s] += 1
    else:
        dic[s] = 1
print(ans)


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

int h, w, dp[405][405];
int dr[4] = {-1, 0, 1, 0};
int dc[4] = {0, 1, 0, -1};
char grid[405][405];
vector<int> nodes;

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

    cin >> h >> w;

    for (int i = 0; i < h*w; i++) {
    	for (int j = 0; j < h*w; j++) {
    		dp[i][j] = 1e9;		
    	}
    }

    for (int i = 0; i < h; i++) {
    	for (int j = 0; j < w; j++) {
    		cin >> grid[i][j];
    		if (grid[i][j] == '.') {
    			nodes.push_back(i*w+j);
    			dp[i*w+j][i*w+j] = 0;
    		}
    	}
    }

    for (int i = 0; i < h; i++) {
    	for (int j = 0; j < w; j++) {
    		if (grid[i][j] == '.') {
    			for (int k = 0; k < 4; k++) {
    				int r = i+dr[k], c = j+dc[k];
    				if (r >= 0 && r < h && c >= 0 && c < w && grid[r][c] == '.') {
    					dp[i*w+j][r*w+c] = 1;
    				}
    			}
    		}
    	}
    }

    for (int k = 0; k < nodes.size(); k++) {
    	for (int i = 0; i < nodes.size(); i++) {
    		for (int j = 0; j < nodes.size(); j++) {
    			dp[nodes[i]][nodes[j]] = min(dp[nodes[i]][nodes[j]], dp[nodes[i]][nodes[k]] + dp[nodes[k]][nodes[j]]);
    		}
    	}
    }

    int ans = 0;
    for (int i = 0; i < nodes.size(); i++) {
    	for (int j = 0; j < nodes.size(); j++) {
    		ans = max(ans, dp[nodes[i]][nodes[j]]);
    	}
    }

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

Measured memory_bytes: 896
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[j][0]-xy[i][0]
		q = xy[j][1]-xy[i][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Measured memory_bytes: 3188
#include <stdio.h>

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

  scanf("%d %d %d" , &a,&b, &c);
 
 if(a > b) {
    d = a;
      a = b;
      b = d;
  } if(b > c) {
    d = c;
    c = b;
    b = d;

  } if(a > b) {
    d = a;
    a = b;
    b = d;
  }
  printf("%d %d %d\n",a ,b ,c);



  return 0;
}

Measured memory_bytes: 596
n = int(input())
inf = float('inf')
graphs = []

for i in range(n):
    weights = list(map(int, input().split()))
    weights = [inf if weight == -1 else weight for weight in weights]
    graphs.append(weights)
# print(graphs)
# M =graphs
color = ['WHITE' for _ in range(n)]
d = [inf for _ in range(n)]
p = [i for i in range(n)]


def prim():
    d[0] = 0
    p[0] = -1
    while True:
        min_cost = inf
        for i in range(n):
            if color[i] != 'BLACK' and d[i] < min_cost:
                min_cost = d[i]
                u = i
        if min_cost == inf:
            break
        color[u] = 'BLACK'

        for v in range(n):
            if color[v] != 'BLACK' and graphs[u][v] != inf:
                if graphs[u][v] < d[v]:
                    d[v] = graphs[u][v]
                    p[v] = u
                    color[v] = 'GRAY'


prim()
# print(d)
# print(p)
print(sum(d))



Measured memory_bytes: 5776
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, A, B, C, X, Y[200];

int main(void) {
  while(cin >> N >> A >> B >> C >> X, N) {
    REP(i, 0, N) cin >> Y[i];

    int ans = 0, k = 0;
    while(ans <= 10000) {
      if(X == Y[k]) {
        k++;
        if(k == N) break;
      }
      X = (((A % C) * X) % C + B) % C;
      ans++;
    }
    cout << (ans <= 10000 ? ans : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

vector<ll> value;
vector<ll> weight;
ll dp[101][100001];

ll solve(int n, int v){
  if(dp[n][v] > -1){
    return dp[n][v];
  }
  if(n == 0){
    if(v == 0){
      return dp[n][v] = 0;
    }
    else if(v - value[n] == 0){ 
      return dp[n][v] = weight[n];
    }
    else{
      return dp[n][v] = INT_MAX;
    }
  }
  if(v == 0){
    return dp[n][v] = 0;
  }
  else{
    if(v - value[n] >= 0){
      return dp[n][v] = min(weight[n] + solve(n-1, v - value[n]), solve(n-1, v));
    }
    else{
      return dp[n][v] = solve(n-1, v);
    }
  }
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, w;
  int total = 0;
	cin >> n >> w;
	value.resize(n);
	weight.resize(n);

	for(int i = 0; i < n; i++){
		int w, v;
		cin >> w >> v;
		weight[i] = w;
		value[i] = v;
    total += v;
	}
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 100001; j++) dp[i][j] = -1;
  }
  for(int i = total; i >= 0; --i){
    solve(n-1, i);
  }
  for(int i = total; i>=0; i--){
    if(dp[n-1][i] > -1 && dp[n-1][i] <= w){
        cout << i << endl;
        return 0;
      }
  }
	return 0;
}


Measured memory_bytes: 79232
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 24360
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int x;
		cin >> x;
		int t = 0;
		int a = 100;
		while(a<x)
		{
			t++;
			double y = a;
			y = y*1.01;
			a = (int)y;
		}

		cout << t;
	}
	return 0;
}

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

int main(){
    int n, arr[100005], sum=1, flex=0, i=0;
    cin >> n;
    for(i=1; i<=n; i++){
        cin >> arr[i];
    }
    i=2;
    while(i<=n){
        if(arr[i]<arr[i-1] && flex==1){
            sum++;
            flex=0; 
        }
        else if(arr[i]>arr[i-1] && flex==-1){
            sum++;
            flex=0;
        }
        else{
            if(arr[i]>arr[i-1]){
                flex=1;
            }
            else if(arr[i]<arr[i-1]){
                flex=-1;
            }
        }
        i++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) {
        cout << 1 << "\n";
    } else if (h % 2 == 1 && w % 2 == 1){
        cout << h * w / 2 + 1 << "\n";
    } else {
        cout << h * w / 2 << "\n";
    }
}

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

int main(){
  vector<long long> data(87);
  data.at(0) = 2;
  data.at(1) = 1;
  for (int i = 2; i < 87; i++){
    data.at(i) = data.at(i - 1) + data.at(i - 2);
  }
  
  long long n;
  cin >> n;
  cout << data.at(n) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<class T>
vector<T> get_divisor(T n) {
    vector<T> res;
    for (long long i = 1; (i * i) <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if ((i * i) != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    set<ll> ans;
    {
        vector<ll> tmp = get_divisor(n);
        rep(i, sz(tmp)) {
            if (tmp[i] == 1) continue;
            ll cv = n;
            while(cv % tmp[i] == 0) cv /= tmp[i];
            cv %= tmp[i];
            if (cv == 1) ans.insert(tmp[i]);
        }
    }
    {
        vector<ll> tmp = get_divisor(n - 1);
        rep(i, sz(tmp)) ans.insert(tmp[i]);
    }
    ans.erase(1);
    cout << sz(ans) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

vector<int>devisor(int n) {
	vector<int>value;
	FOR(i, 1, pow(n, 0.5) + 1) {
		if (n % i == 0) {
			value.push_back(i);
			if (i * i != n) {
				value.push_back(n / i);
			}
		}
	}
	return value;
}
int ans(int gcd, vector<int>&devisor,vector<int>&a) {
	bool flag = true;
	int i = 0;
	while (flag) {
		int count = 0;
		rep(j, a.size()) {
			if (a[j] % devisor[i] != 0) {
				count++;
			}
			if (count >= 2) {
				break;
			}
		}
		if (count <= 1) {
			gcd = max(gcd, devisor[i]);
			flag = false;
		}
		else {
			i++;
		}
	}
	return gcd;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));

	int b = a[0];
	int c = a[1];
	vector<int>devisor_b,devisor_c;
	devisor_b = devisor(b);
	devisor_c = devisor(c);
	sort(all(devisor_b));
	reverse(all(devisor_b));
	sort(all(devisor_c));
	reverse(all(devisor_c));
	int gcd = 1;
	int answer = max(ans(gcd, devisor_c, a), 
		ans(gcd, devisor_b, a));
	cout << answer << endl;

}


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

int H, W;
string S[30][30];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    bool f = false;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == "snuke") {
                cout << (char)('A' + j) << i+1 << endl;
                f = true;
                break;
            }
        }
        if (f) break;
    }


    return 0;
}


Measured memory_bytes: 256
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int m,n;
  while(cin>>m>>n&&(m||n)){
    int a[10],b[10],c[10],d[10];
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    list<pair<int,pair<int,int> > > p;
    for(i=0;i<n;i++){
      int t;
      cin>>t;
      p.push_back(make_pair(i,make_pair(i*10,t)));
    }
    while(n){
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1&&d[i]==0){
	    if(n!=1)
	      cout<<b[i]+1<<" ";
	    else
	      cout<<b[i]+1<<endl;
	    b[i]=-1;
	    n--;
	  }
	}else{
	  if(c[i]==0){
	    if(n!=1)
	      cout<<a[i]+1<<" ";
	    else
	      cout<<a[i]+1<<endl;
	    a[i]=-1;
	    n--;
	    if(d[i]==0){
	      if(n!=1)
		cout<<b[i]+1<<" ";
	      else
		cout<<b[i]+1<<endl;
	      b[i]=-1;
	      n--;
	    }
	  }
	}
      }
      if(n==0)
	break;
      h=1;
      while(p.empty()==0&&p.front().second.first==0&&h){
	h=0;
	for(i=0;i<m&&b[i]!=-1;i++);
	if(i!=m){
	  b[i]=p.front().first;
	  d[i]=p.front().second.second;
	  p.pop_front();
	  h=1;
	}else{
	  int mn=-1,mx=-1;
	  for(i=0;i<m;i++){
	    if(a[i]==-1){
	      if(p.front().second.second<=d[i]){
		if(mn==-1||d[mn]>d[i])
		  mn=i;
	      }else{
		if(mx==-1||d[mx]<d[i])
		  mx=i;
	      }
	    }
	  }
	  if(0){
	  }else if(mn!=-1){
	    a[mn]=p.front().first;
	    c[mn]=p.front().second.second;
	    p.pop_front();
	    h=1;
	  }else if(mx!=-1){
	    a[mx]=p.front().first;
	    c[mx]=p.front().second.second;
	    p.pop_front();
	    h=1;
	  }
	}
      }
      unsigned mn=-1;
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1)
	    mn=min(mn,(unsigned)d[i]);
	}else{
	  mn=min(mn,(unsigned)c[i]);
	}
      }
      if(p.empty()==0&&p.front().second.first)
	mn=min(mn,(unsigned)p.front().second.first);
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1)
	    d[i]=max(0,d[i]-(int)mn);
	}else{
	  c[i]=max(0,c[i]-(int)mn);
	  d[i]=max(0,d[i]-(int)mn);
	}
      }
      list<pair<int,pair<int,int> > >::iterator it;
      for(it=p.begin();it!=p.end();it++)
	(*it).second.first=max(0,(*it).second.first-(int)mn);
    }
  }
  return 0;
}

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

int main() {
  int n,i;
  string str1,str2,str3;
  cin >> n;
  cin >> str1 >> str2;
  str3 = "aa";
  //cout << n << endl;
  //cout << str1 << str2 << endl;
  //cout << str3 << endl;

  str3.at(0) = str1.at(0);
  str3.at(1) = str2.at(0);
  
  for(i =1;n > i; i++){
    str3 = str3 + str1.at(i) + str2.at(i);
  }
  
  cout << str3 << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String origin = sc.next();
        String[] data = origin.split("");

        int count = 0;
        for (int i = 0; i < (origin.length())/2; i++) {
            if (!(data[i].equals(data[origin.length() - i - 1]))) {
                count++;
            }
        }

        System.out.println(count);
	}
}


Measured memory_bytes: 23124
void main() {
	auto N = rs;
	auto arr = [2,4,5,7,9];
	auto arr2 = [0,1,6,8];
	if(arr.canFind(N.back - '0')) {
		writeln("hon");
	} else if(arr2.canFind(N.back - '0')) {
		writeln("pon");
	} else writeln("bon");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2700
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll A,B;
  cin >> A >>B;
  if(0>=A&& 0<=B){
    cout << "Zero" << endl;
  }
  else{
    if(A>0){
      cout << "Positive" << endl;
    }
    else{
      if((B-A)%2==0){
        cout << "Negative" << endl;
      }
      else{
        cout << "Positive" << endl;
      }
    }
  }
}

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

int main() {
   ll a = 0,n = 0;
   cin >> n;
   rep1(i,n){
      if(i%3 != 0 && i%5 != 0){
         a = a + i;
      }
   }
   cout << a << endl;
   return 0;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
if n == 2:
  print(max(a))
else:
  a0 = a[0]
  a1 = a[1]
  r = 0
  while True:
    r = a1 % a0
    if r == 0:
      b0 = a0
      break
    elif r > a0:
      a1, a0 = r, a0
    else:
      a1, a0 = a0, r
  a1 = a[1]
  a2 = a[2]
  r = 0
  while True:
    r = a2 % a1
    if r == 0:
      b1 = a1
      break
    elif r > a1:
      a2, a1 = r, a1
    else:
      a2, a1 = a1, r
  a0 = a[0]
  a2 = a[2]
  r = 0
  while True:
    r = a2 % a0
    if r == 0:
      b2 = a0
      break
    elif r > a0:
      a2, a0 = r, a0
    else:
      a2, a0 = a0, r
  max_a = max(b0,b1,b2)
  kouho = []
  for j in range(max_a,1,-1):
    if max_a % j == 0:
      c = list(map(lambda x: x % j,a))
      c_ng = [i for i in c if i > 0]
    #print("j=",j,"c=",c,"c_ng=",c_ng)
      if len(c_ng) <= 1:
        ans = j
        break
  print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> a (n);
  map<int,int64_t> kaz;
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    kaz[a.at(i)]++;
  }
  int64_t al = 0;
  for(auto x:kaz){
    al+=x.second*(x.second-1);
  }
  //cout << al << endl;
  for(int i = 0;i < n;i++){
    cout << (al - kaz[a.at(i)]*(kaz[a.at(i)]-1) + (kaz[a.at(i)]-1)*(kaz[a.at(i)]-2))/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 11964
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k;
    cin >> k;
    ll ans = 0;
    ans = 1000 * (k / 500) + 5 * ((k % 500) / 5);
    cout << ans;
    return 0;
}

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


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


  int a,b,m;
  cin >> a>> b >> m;
  vector<int> ca(a),cb(b);
  rep(i,a) cin >> ca[i];
  rep(i,b) cin >> cb[i];
  ll ans = *min_element(ca.begin(),ca.end()) + *min_element(cb.begin(),cb.end());
  rep(i,m){
    ll x,y,c;
    cin >> x >> y >> c;
    --x;--y;
    ans = min(ca[x] + cb[y] - c,ans);
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
  ll n;
  double d;
  cin>>n;
  cin>>d;
  ll count=0;
  for(ll i=0;i<n;i++)
  {
     ll a,b;
     cin>>a>>b;
     ll aa=pow(a,2);
     ll bb=pow(b,2);
     ll c=aa+bb;
     double dd=sqrt(c);
     if(dd<=d)
     ++count;


  }
  cout<<count;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int N;
pair<ll, ll> XH[200000];
ll adjust[200001];

int id(ll x)
{
	int ng = 0, ok = N;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (XH[mid].first > x) ok = mid;
		else ng = mid;
	}

	return ok;
}

int main()
{
	ll D, A, ans = 0, add = 0;

	cin >> N >> D >> A;
	rep(i, N) cin >> XH[i].first >> XH[i].second;
	
	rep(i, N) XH[i].second = (XH[i].second + A - 1) / A;

	sort(XH, XH + N);

	rep(i, N) {
		add += adjust[i];
		XH[i].second = max((ll)0, XH[i].second - add);

		ans += XH[i].second;
		add += XH[i].second;

		int p = id(XH[i].first + 2 * D);

		adjust[p] -= XH[i].second;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
N = int(input())

a = []
for i in range(N):
  a.append(input())
  if i > 0:
    curword = a[i]
    lastword = a[i-1]
    if lastword[len(lastword)-1] != curword[0]:
      print('No')
      exit()
    if curword in a[:len(a)-1]:
      print('No')
      exit()


print('Yes')


Measured memory_bytes: 38384