akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

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

int main(){
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	vector<vector<int>> dist(H, vector<int>(W, INF));
	for(int i=0;i<H;i++) {
		cin >> S[i];
	}
	dist[0][0] = 0;
	queue<pair<pair<int,int>, pair<int,int>>> q;
	q.push({{-1,-1},{0,0}});
	while(!q.empty()) {
		auto tmp = q.front(); q.pop();
		int beforey = tmp.first.first;
		int beforex = tmp.first.second;
		int nowy = tmp.second.first;
		int nowx = tmp.second.second;
		bool flag = false;
		if(beforey == -1 and beforex == -1) {
			flag = true;
			if(S[nowy][nowx] == '#') dist[nowy][nowx] = 1;
		} else {
			if(S[beforey][beforex] == '.') {
				if(S[nowy][nowx] == '#') {
					if(dist[nowy][nowx] > dist[beforey][beforex] + 1) {
						dist[nowy][nowx] = dist[beforey][beforex] + 1;
						flag = true;
					}
				} else {
					if(dist[nowy][nowx] > dist[beforey][beforex]) {
						dist[nowy][nowx] = dist[beforey][beforex];
						flag = true;
					}
				}
			} else {
				if(dist[nowy][nowx] > dist[beforey][beforex]) {
					dist[nowy][nowx] = dist[beforey][beforex];
					flag = true;
				}
			}
		}
		if(flag) {
			for(int i=0;i<2;i++) {
				int nexty = nowy + dy[i];
				int nextx = nowx + dx[i];
				if(0 <= nexty and nexty < H and 0 <= nextx and nextx < W) {
					q.push({{nowy, nowx},{nexty, nextx}});
				}
			}
		}
	}
	cout << dist[H-1][W-1] << endl;
}

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

int main()
{
  int N, M;

  cin >> N >> M;

  vector<int> H(N);

  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }

  vector<int> T(N, 0);

  for (int i = 0; i < M; i++)
  {
    int A, B;
    cin >> A >> B;
    if (H.at(A - 1) > H.at(B - 1))
    {
      T.at(B - 1) = -1;
    }
    else if (H.at(A - 1) < H.at(B - 1))
    {
      T.at(A - 1) = -1;
    }
    else
    {
      T.at(B - 1) = -1;
      T.at(A - 1) = -1;
    }
  }

  int count = 0;

  for (int i = 0; i < N; i++)
  {
    if (T.at(i) == 0)
    {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 4048
s = int(input())

def fx(s):
    if s % 2 == 1:
        return 3*s + 1
    else:
        return s//2

a = [s]
b0 = a[0]

ans = 1
while fx(b0) not in a:
    a.append(fx(b0))
    b0 = a[-1]
    ans += 1

print(ans+1)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
	ll a; double b;
    cin>>a>>b;
    ll k=b*100+1e-8 ;
   //cout<<k<<endl;
    ll m=(a*k)/100;
    cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin>>n;
	int ans=inf;
	for(int i=1;i*i<=n;i++){
		if(n%i>0) continue;
		int t=max((to_string(i).size()),(to_string(n/i)).size());
		ans=min(ans,t);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  int n = s.length();
  int i;
  char tmp = s[0];
  for(i=1;i<n;i++){
    if(s[i]!=tmp){
      cnt++;
      tmp = s[i];
    }
  }
  cout << cnt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
signed main(void){
    int n;cin>>n;
    int sum=0;
    int V[n];
    rep(i,n){
        cin>>V[i];
        sum+=V[i];
    }
    int f=0;
    rep(i,n){
        f+=V[i];
        if(f>=(sum+1)/2){
            cout<<min(f*2-sum,sum-(f-V[i])*2)<<endl;
            break;
        }
    }
    
    
}
        

Measured memory_bytes: 1792
#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() {
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<P> p(n);
  rep(i, n){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  d = d*2;
  ll tot = 0;
  queue<pair<ll, ll>> q;
  ll ans = 0;
  rep(i, n){
    ll x = p[i].first;
    ll h = p[i].second;
    while(q.size() && q.front().first < x){
      tot -= q.front().second;
      q.pop();
    }
    h -= tot;
    if(h>0){
      ll num = (h+a-1) / a;
      ans += num;
      ll damage = num * a;
      tot += damage;
      q.emplace(x+d, damage);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6412
from collections import Counter
n = int(input())
a_li = list(map(int,input().split()))
a_counter = Counter(a_li)
a_most = a_counter.most_common()
ans = 0
for s in a_most:
    dum = s[1] - s[0]
    if dum < 0:
        ans += s[1]
    elif dum > 0:
        ans += dum
print(ans)

Measured memory_bytes: 21228
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);
 
  int T=0;
  int X=0;
  int Y=0;
 
  int can=1;
 
  for(int i=0;i<n;i++){
    int t,x,y;
    scanf("%d%d%d",&t,&x,&y);
 
    int d=abs(x-X)+abs(y-Y);
    if(d>t-T){
      can=0;
    }
 
    if(d%2!=(t-T)%2){
      can=0;
    }
    X=x;
    Y=y;
    T=t;
  }
 
  if(can){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

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

using namespace std;
using ll = long long;

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

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

    int ans = 0;

    ans += (x/500)*1000;
    x %= 500;
    ans += (x/5)*5;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),target=1,broken=0;
    for(ll i=0;i<n;++i){
        if(in()==target){
            ++target;
        }
        else{
            ++broken;
        }
    }
    cout<<(broken==n?-1:broken)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	string *curr = &a;
	char currnum = 'A';
	while ((*curr).size() > 0)
	{
		char temp = (*curr)[0];
		(*curr).erase(0, 1);
		if (temp == 'a')
		{
			curr = &a;
			currnum = 'A';
		}
		else if (temp == 'b')
		{
			curr = &b;
			currnum = 'B';
		}
		else if (temp == 'c')
		{
			curr = &c;
			currnum = 'C';
		}

	}
	cout << currnum;

}

Measured memory_bytes: 384
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
last_ys = [-1] * W
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "#":
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      for t in range(last_ys[x]+1,y):
        Y[t][x] = y-1-last_ys[x]
      last_x = x
      last_ys[x] = y
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  for t in range(last_ys[x]+1,H):
    Y[t][x] = H-1-last_ys[x]
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans-1)


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

#define N (1<<18)
template<class T>
struct RMQ{
	pair<T,int>dat[2*N];
	T inf;
	function<pair<T,int>(pair<T,int>,pair<T,int>)>merge;
	RMQ(T Inf,function<pair<T,int>(pair<T,int>,pair<T,int>)>Merge){
		inf=Inf;merge=Merge;
		rep(i,2*N-1){
			dat[i].first=inf;
			if(i>=N-1)dat[i].second=i-N+1;
		}
	}
	void update(int k,T x){
		k+=N-1;
		dat[k].first=x;
		while(k){
			k=(k-1)/2;
			dat[k]=merge(dat[k*2+1],dat[k*2+2]);
		}
	}
	pair<T,int>query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l||r<=a)return make_pair(inf,-1);
		if(a<=l&&r<=b)return dat[k];
		auto lb=query(a,b,k*2+1,l,(l+r)/2);
		auto rb=query(a,b,k*2+2,(l+r)/2,r);
		return merge(lb,rb);
	}
	T getValue(int a,int b){
		return query(a,b).first;
	}
	int getIndex(int a,int b){
		return query(a,b).second;
	}
};
template<class T>
pair<T,int>RangeMax(pair<T,int>a,pair<T,int>b){
	return a.first>=b.first?a:b;
}
template<class T>
pair<T,int>RangeMin(pair<T,int>a,pair<T,int>b){
	return a.first<=b.first?a:b;
}

RMQ<int>seg(INT_MIN,RangeMax<int>);

int n;
int p[200000];
int l1[200000],l2[200000],r1[200000],r2[200000];

void calc(int*l1,int*l2){
	rep(i,n)seg.update(i,INT_MIN);
	rep(i,n){
		seg.update(p[i],i);
		auto p1=seg.query(p[i]+1,n);
		if(p1.first==INT_MIN){
			l1[i]=l2[i]=-1;continue;
		}
		else{
			l1[i]=p1.first;
			int X=p1.first;
			seg.update(p1.second,INT_MIN);
			auto p2=seg.query(p[i]+1,n);
			if(p2.first==INT_MIN)l2[i]=-1;
			else l2[i]=p2.first;
			seg.update(p1.second,X);
		}
	}
}
int main(){
	cin>>n;
	rep(i,n){
		scanf("%d",&p[i]);p[i]--;
	}
	calc(l1,l2);
	rep(i,n/2)swap(p[i],p[n-i-1]);
	calc(r1,r2);
	rep(i,n/2){
		swap(p[i],p[n-i-1]);
		swap(r1[i],r1[n-i-1]);
		swap(r2[i],r2[n-i-1]);
	}
	rep(i,n){
		r1[i]=n-1-r1[i];
		r2[i]=n-1-r2[i];
	}
	ll ans=0;
	rep(i,n){
		p[i]++;
		//Left
		ll C=0;
		ll L=l1[i]-l2[i];
		ll R=r1[i]-i;
		C+=L*R;
		L=r2[i]-r1[i];
		R=i-l1[i];
		C+=L*R;
		ans+=C*p[i];
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

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


int main()
{
    long long int n, a[100010];
    long long int m = 0;

    cin >> n;

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

    vector<int> l(n+1, 0), r(n+1, 0);

    for (int i = 0; i < n; i++) {
        l[i+1] = gcd(l[i], a[i]);
    }

    for (int i = n-1; i >= 0; i--) {
        r[i] = gcd(r[i+1], a[i]);
    }

    for (int i = 0; i < n; i++) {
        if (m < gcd(l[i], r[i+1])) {
            m = gcd(l[i], r[i+1]);
        }
    }

    cout << max(m, gcd(m, r[0])) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

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

    int cnt = 0;
    int kuti = 1;

    while(kuti < b){
        kuti--;
        kuti += a;
        cnt++;
    }

    println(cnt);
}


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

int main(void){
  int a,b,c;
  double x;
  int rectangles = 0; //????????¢
  int lozenges = 0; //????????¢
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(a == b){
      lozenges++;
    }else{
      x = sqrt(a*a + b*b);
      if(fabs(x - c) < DBL_EPSILON){
        rectangles++;
      }
    }
  }
  printf("%d\n%d\n",rectangles,lozenges);
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string a;
	while (cin >> a)
	{
		if (a[a.size() - 1] == 's') a = a + "es";
		else a = a + 's';
		cout << a << endl;
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;

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

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

void show_me(int *a, size_t size)
{
    for (size_t i = 0; i < size; ++i)
    {
        cout << (i == 0 ? "" : " ") << a[i];
    }
    cout << endl;
}

void modify(int *a)
{
    a[0] = 1000;
}

void insertion_sort(int *a, size_t size)
{
    int v;
    for (int i = 1; i < size; ++i)
    {
        v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = v;
        show_me(a, size);
    }
}

int main()
{
    int a[100] = {};
    size_t n;
    cin >> n;
    for (size_t i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    show_me(a, n);
    insertion_sort(a, n);
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5+1;
const ll mod = 1e9+7;

ll sum = 0;

void solve(int pos,vector<int>&store,vector<array<int,4>>&arr,int m){
    if(pos==store.size()){
        ll ans = 0;
        for(auto x: arr){
            int a = x[0],b = x[1], c = x[2], d = x[3];
            if(store[b]-store[a]==c) ans+=d;
        }
        sum = max(ans,sum);
        return;
    }

    for(int i=store[pos-1];i<=m;i++){
        store[pos]=i;
        solve(pos+1,store,arr,m);
    }

}



int main(){

    FASTIO;
    PRECISION;

    int n,m,q;
    cin>>n>>m>>q;
    vector<array<int,4>>arr(q);

    for(auto &x: arr){
        for(auto &y: x){
            cin>>y;
        }
    }

    vector<int>store(n+1,1);

    solve(1,store,arr,m);

    cout<<sum<<"\n";

}


Measured memory_bytes: 3636
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
 int n,m;
 cin >> n >> m;
 int a,b;
 vector<pair<int,int>> key;
 //鍵の入力
  for(int i=0;i<m;i++){
   int s=0;
   cin >> a >> b;
   for(int j=0;j<b;j++){
     int c;
     cin >> c;
     c--;//cはデクリメントする必要がある
     s |= 1<<c;//i+1番目の鍵で開けられる集合
   }
   key.emplace_back(s,a);//鍵を配列に追加
 }
 //DPをしていく
 vector<int> dp(1<<n,INF);//集合を開けるのに必要な最小のコストを記録する
  dp[0]=0;//最初は0
  for(int i=0;i<1<<n;i++){
    for(int j=0;j<m;j++){
      int t = i | key[j].first;//j番目の鍵との和集合が開けられる宝箱の集合
      int cost=dp[i]+key.at(j).second;
      dp[t]=min(dp[t],cost);//costが小さければ更新
    }
  }
  if(dp.back()==INF){
    cout << "-1" << endl;
  }
  else{
    cout << dp.back() << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    auto t = s.substr(0, n / 2);
    std::cout << (t + t == s ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << '\n'
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,b;
    cin >> n;
    vector<ll> ans(n,0);
    vector<P> a(n);
    rep(i,n){
        cin >> b;
        a[i] = P(b,-i);
    }
    ll k = a[0].first;
    RSORT(a);
    ll c,d,now = a[0].first,stock = 0;
    priority_queue<ll,vector<ll>,greater<ll>> q;
    rep(i,n){
        tie(c,d) = a[i];
        d *= -1;
        if (c != now){
            ans[q.top()] += stock*(now-c);
            now = c;
        }
        q.push(d);
        stock++;
    }
    ans[0] += now*n;
    rep(i,n) PRINT(ans[i]);
}    


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
int Inv[1000010];
const int fish=998244353;
int f[1000010],mu[1000010],Prime[1000010],IsPrime[1000010],hs[1000010],cnt,Con[1000010],N,a[1000010];
void Init(){
	Inv[1]=1;
	for (int i=2;i<=1000000;i++)
		Inv[i]=1ll*Inv[fish%i]*(fish-(fish/i))%fish;
	mu[1]=1;
	for (int i=2;i<=1000000;i++){
		if (!IsPrime[i]) Prime[++cnt]=i,mu[i]=-1;
		for (int j=1;i*Prime[j]<=1000000&&j<=cnt;j++){
			IsPrime[i*Prime[j]]=true;
			if (i%Prime[j]==0){
				mu[i*Prime[j]]=0;
				break;
			}
			mu[i*Prime[j]]=-mu[i];
		}
	}
}
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
		scanf("%d",&a[i]),Con[a[i]]++;
	Init();
	for (int i=1;i<=1000000;i++)
		for (int j=i;j<=1000000;j+=i)
			(hs[i]+=1ll*Con[j]*j%fish)%=fish,f[i]=(f[i]+1ll*Con[j]*j%fish*j%fish)%fish;
	for (int i=1;i<=1000000;i++)
		f[i]=1ll*((1ll*hs[i]*hs[i]%fish-f[i])%fish+fish)%fish*Inv[2]%fish;
	long long ans=0;
	for (int k=1;k<=1000000;k++)
		for (int T=k;T<=1000000;T+=k)
			(ans+=(1ll*Inv[k]*mu[T/k]%fish*f[T]%fish))%=fish;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 28160
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


i64 n, k, a[101010];
int cnt[101];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; (1LL << j) <= a[i]; j++){
			if((a[i] >> j) & 1) cnt[j]++;
		}
	}
	
	i64 ans = 0;
	for(i64 i = 60; i >= 0; i--){
		if((1LL << i) > k) continue;
		if(cnt[i] < n/2+n%2){
			if(ans+(1LL << i) <= k){
				ans += (1LL << i);
			}
		}
	}
	i64 ma = 0;
	for(int i = 0; i < n; i++){
		ma += ans^a[i];
	}
	cout << ma << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import math

a,b,deg = map(float,input().split(" "))

sindeg = math.sin(math.radians(deg))
S = (a*b*sindeg)/2


cosdeg = math.cos(math.radians(deg))
z = a*a + b*b - 2*a*b*cosdeg
L = a + b + math.sqrt(z)

h = b*sindeg

print("{:.5f}".format(S))
print("{:.5f}".format(L))
print("{:.5f}".format(h))




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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  long long int cntr=0;
  long long int cntb=0;
  long long int cntg=0;
  rep(i,n){
    if(s[i]=='R') cntr++;
    if(s[i]=='B') cntb++;
    if(s[i]=='G') cntg++;
  }
  long long int ans=cntr*cntb*cntg;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=2*j-i;
      if(k>=n) break;
      if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]) ans--;
    }
  }
  cout<<ans<<endl;
}
        
        
        


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[2000006];
int main()
{
    ll k,n;
    cin >> k >> n;
    for(ll i=1;i<=n;i++)
        cin>> a[i];

    ll mx=0,ans=0;
    ans+=(a[1]+k-a[n]);
    mx = max(mx,(a[1]+k-a[n]));

    for(ll i=2;i<=n;i++)
    {
        ans+= a[i]-a[i-1];
        mx = max(mx,a[i]-a[i-1]);
    }

    cout << ans-mx << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

#define int long long

void solve(){
	
	int n;
	cin>>n;
	int a[n];

	bool flag= true;

	for(int i  = 0 ;i < n; ++i){

		int x;
		cin>>x;

		if(x&1)
			continue;

		if(x%5==0)
			continue;
		if(x%3==0)
			continue;
		flag = false;
	}

	if(flag)
		cout<<"APPROVED\n";
	else cout<<"DENIED\n";
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e7 + 5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, m, i, j, k, ans;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n >> m >> k)
	vll a(n + 1), b(m + 1);
	FOR(i, 1, n + 1)
		in(a[i])
	FOR(i, 1, m + 1)
		in(b[i])
	FOR(i, 2, n + 1)
		a[i] += a[i - 1];
	FOR(i, 2, m + 1)
		b[i] += b[i - 1];
	ans = 0, j = m;
	FOR(i, 0, n + 1)
	{
		if (a[i] > k)
			break;
		while (b[j] > k - a[i])
			--j;
		ans = max(ans, i + j);
	}
	out(ans)
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 6344
#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<ll,ll>;

int main() {
    int N;
    int count=0;
    cin>>N;
    rep(i,N)
    {
      int a;
      cin>>a;
      if(((i+1)%2)!=0)
      {
        if((a%2)!=0)count++;
      }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    static int MAX_COUNT = 0;
    static int[][] grid;
    static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        grid = new int[2][n];
        for(int row = 0; row < 2; row++) {
            for(int col = 0; col < n; col++) {
                grid[row][col] = sc.nextInt();
            }
        }
        count(0, 0, 0);
        System.out.println(MAX_COUNT);
    }

    public static void count(int currentCount, int row, int col) {
        if(row >= 2 || col >= n) return;
        if(row == 1 && col == n-1) {
            MAX_COUNT = Math.max(currentCount + grid[row][col], MAX_COUNT);
            return;
        }
        count(currentCount + grid[row][col], row+1, col);
        count(currentCount + grid[row][col], row, col+1);
        return;
    }
}

Measured memory_bytes: 21844
#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>;

ll x = 1e9 + 7; 
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}

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

vector<int> S(100000, -1);

int main(){
	long n, q;
	cin >> n >> q;
	for (long i = 0; i < n; i++) S[i] = i;
	for (long i = 0; i < q; i++){
		long c, x, y;
		cin >> c >> x >> y;
		if (c == 0){
			long sx = S[x];
			long sy = S[y];
			for (long j = 0; j < n; j++){
				if (S[j] == sx) S[j] = sy;
			}
		}
		else {
			if (S[x] == S[y]) cout << "1" << endl;
			else cout << "0" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>


void main()
{
	int ans, N, M, A[10000],i,wa=0;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++)
	{
		scanf("%d", &A[i]);
		wa = wa + A[i];
	}
	if (wa <= N)
	{
		ans = N - wa;
	}
	else
	{
		ans = -1;
	}
	printf("%d", ans);
}


Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	if(n/10==9||n%10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	string S;
	cin>>S;
	int N=S.size();
	vector<char> V;
	REP(i,N){
		if(S[i]=='S'){
			V.push_back(S[i]);
		}
		else if(S[i]=='T'&&(V.empty()||V.back()=='T')){
			V.push_back(S[i]);
		}
		else{
			V.pop_back();
		}
	}
	cout<<V.size()<<endl;
	return 0;
}


Measured memory_bytes: 772
#include <iostream>

using namespace std;

int main () {
    int N, K;
    cin >> N >> K;
    int h;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if (K <= h) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }
    
    bool isVowel(char x) {
        const string s = "aiueo";
        for (int i = 0; i < 5; i++) if (s[i] == x) return true;
        return false;
    }

    int N;
    vector<string> S;
    bool input() {
        cin >> N;
        if (N == 0) return false;
        S.clear(); S.resize(N); cin >> S;
        return true;
    }

    string encode(const string& s) {
        string t;
        t.push_back(s[0]);
        for (int i = 0; i + 1 < s.size(); i++) {
            if (isVowel(s[i])) {
                t.push_back(s[i + 1]);
            }
        }
        return t;
    }

    void solve() {
        vector<string> T(N);
        int K = 0;
        for (int i = 0; i < N; i++) {
            T[i] = encode(S[i]);
            K = max(K, int(T[i].size()));
        }
        int ans = -1;
        for (int k = 1; k <= K; k++) {
            vector<string> ss;
            for (int i = 0; i < N; i++) {
                ss.push_back(T[i].substr(0, min(k, int(T[i].size()))));
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    if (ss[i] == ss[j]) {
                        goto next;
                    }
                }
            }
            ans = k;
            break;
            next:;
        }
        cout << ans << endl;
    }
}

int main() {
    while (input()) solve();
    return 0;
}

Measured memory_bytes: 3252
import java.util.*;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		
		String [] ymd = S.split("/");
		
		int m = Integer.parseInt(ymd[1]);
		
		if(m<=4) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}

		sc.close();
	}

}

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

int n;
long long a[505][505];
int primes[1011];
int tot = 0;

long long lcm(long long a,long long b) {
	return a / __gcd(a, b) * b;
}
void build() {
	int ptr = 2;
	while (tot < 1007) {
		bool prime = 1;
		for (int i = 2; i * i <= ptr; ++i) {
			if (ptr % i == 0) {
				prime = 0;
				break;
			}
		}
		if (prime) primes[tot++] = ptr;
		ptr++;
	}
	for (int i = 0; i < 500; ++i) {
		for (int j = 0; j < 500; ++j) {
			if (!(i + j & 1)) {
				a[i][j] = primes[(i + j) / 2] * primes[(i - j) / 2 + 752];
			}
		}
	}
	for (int i = 0; i < 500; ++i) {
		for (int j = 0; j < 500; ++j) {
			if (i + j & 1) {
				a[i][j] = 1;
				if (i > 0) a[i][j] = lcm(a[i][j], a[i - 1][j]);
				if (j > 0) a[i][j] = lcm(a[i][j], a[i][j - 1]);
				if (i < 499) a[i][j] = lcm(a[i][j], a[i + 1][j]);
				if (j < 499) a[i][j] = lcm(a[i][j], a[i][j + 1]);
				a[i][j]++;
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	build();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll x;
    cin >> x;
    ll ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
mod=10**9+7
n=int(input())
d={}
z=0
from math import gcd 
for i in range(n):
    x,y=map(int,input().split())
    if x==y==0:z+=1
    else:
        f=gcd(x,y)
        x//=f;y//=f
        if x<0:x*=-1;y*=-1
        if x==0 and y<0:y=-y
        if (x,y)not in d:d[(x,y)]=1
        else:d[(x,y)]+=1
ans=1
for (a,s) in d:
    if d[(a,s)]==0:continue
    ng=0
    if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0
    if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0
    ans*=(pow(2,d[(a,s)],mod)-1 + pow(2,ng,mod)-1 +1)%mod
    ans%=mod
    d[(a,s)]=0
print((ans+z-1)%mod)

Measured memory_bytes: 49444
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<int> cs(N);
  for (int i = 1; i < N; ++i)
    {int A; cin >> A;
    cs[--A]++;}
  for (auto c : cs) cout << c << endl;}

Measured memory_bytes: 3980
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string s="aeiou";
char c;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>c;
	size_t f=s.find(c);
	if(f!=string::npos)
	cout<<"vowel";
	else
	cout<<"consonant";
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<vi> fortune(n,vi(3));
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++) cin >> fortune[i][j];
    vector<vi> dp(n,vi(3,0));
    for(int i=0;i<3;i++) dp[0][i]=fortune[0][i];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=max(dp[i-1][(j+1)%3]+fortune[i][j],dp[i-1][(j+2)%3]+fortune[i][j]);
        }
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}

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

int main(){
    int N;
    cin >> N;
    
    if (N >= 2800){
        cout << "AGC" << endl;
    }

    else if (N < 1200){
        cout << "ABC" << endl;
    }

    else{
        cout << "ARC" << endl;
    }
    
    return 0;
}

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

int64_t change(int64_t *a,int64_t b){
    if(*a>b){
        return *a=(*a-b);
    }else return *a=(-1)*(*a-b);
}

int main(){
    int64_t n,k,ans1=0,ans2=0;
    cin>>n>>k;
    ans1=n%k;
    ans2=k-ans1;
    if(ans1<ans2){
        cout<<ans1;
    }else cout<<ans2;
    }


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int a[N], b[N];

bool check(int b1, int b2, int n);

int main() {
	fast_cin();
	int n; cin >> n;
	set<int> s;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if (s.size() > 3) {
		cout << "No\n";
		return 0;
	}
	sort(a + 1, a + 1 + n);
	for (int val = a[2]; val <= a[n]; ++val) {
		if (s.find(val) != s.end()) {
			if (check(a[1], val, n)) {
				cout << "Yes\n";
				return 0;
			}
			s.erase(val);
		}
	}
	cout << "No\n";
}

bool check(int b1, int b2, int n) {
	b[1] = b1; b[2] = b2;
	for (int i = 3; i <= n; ++i) {
		b[i] = (b[i - 1] ^ b[i - 2]);
	}
	if (b[n - 1] ^ b[n] ^ b[1]) {
		return false;
	}
	if (b[n] ^ b[1] ^ b[2]) {
		return false;
	}
	sort(b + 1, b + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (b[i] != a[i]) {
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 4224
#include <iostream>
#include <fstream>
using namespace std;
int n,m,s[10001],key,sum=0;
bool search(int a[],int n,int key)
{
	for(int i=0;i<n;i++)
		if(a[i]==key)
			return true;
	return false;	
}
int main()
{
	int i,t;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>s[i];
	cin>>m;
	for(i=0;i<m;i++)
	{
		cin>>t;
		if(search(s,n,t))
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>

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

const int ONE {1};
const int SIX {6};
const int NINE {9};
const int max_index {100010};
const int K {7}; // > log_6(100000)
const long long INF {1LL << 60};
int N;
long long dp[max_index];

int check(int index, int num) {
  for ( int k = 1; k < K; k++ ) {
    int res {index - static_cast<int>(std::pow(num, k))};
    if ( res >= 0 ) {
      chmin(dp[index], dp[res] + 1);
    } else {
      break;
    }
  }
  return 0;
}

int main()
{
  std::cin >> N;
  for ( int i = 0; i < max_index; i++ ) dp[i] = INF;
  dp[0] = 0;
  for ( int i = 1; i <= N; i++ ) {
    check(i, SIX);
    check(i, NINE);
    chmin(dp[i], dp[i - ONE] + 1);
  }

  // for (int i = 0; i <= N; i++) std::cerr << dp[i] << std::endl;
  std::cout << dp[N] << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec a(5);
  for(ll i=0;i<n;i++){
    string t;
    cin >> t;
    char b=t[0];
    if(b=='M')a[0]++;
    else if(b=='A')a[1]++;
    else if(b=='R')a[2]++;
    else if(b=='C')a[3]++;
    else if(b=='H')a[4]++;    
  }

  ll ans=0;
  for(ll i=0;i<5;i++){
    for(ll j=i+1;j<5;j++){
      for(ll k=j+1;k<5;k++){
        ans+=a[i]*a[j]*a[k];
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s.at(i);
    }
    vector<vector<int>> l(h, vector<int>(w, 0)), r(h, vector<int>(w, 0)), u(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));
    
    for (int i = 0; i < h; i++) {
        if (s.at(i).at(0) == '.') l.at(i).at(0) = 1;
        if (s.at(i).at(w - 1) == '.') r.at(i).at(w - 1) = 1;
        for (int j = 1; j < w; j++) {
            if (s.at(i).at(j) == '.') l.at(i).at(j) = l.at(i).at(j - 1) + 1;
            if (s.at(i).at(w - j - 1) == '.') r.at(i).at(w - j - 1) = r.at(i).at(w - j) + 1;
        }
    }
    
    for (int j = 0; j < w; j++) {
        if (s.at(0).at(j) == '.') u.at(0).at(j) = 1;
        if (s.at(h - 1).at(j) == '.') d.at(h - 1).at(j) = 1;
        for (int i = 1; i < h; i++) {
            if (s.at(i).at(j) == '.') u.at(i).at(j) = u.at(i - 1).at(j) + 1;
            if (s.at(h - i - 1).at(j) == '.') d.at(h - i - 1).at(j) = d.at(h - i).at(j) + 1;
        }
    }
    
    int ans = 0;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(ans, l.at(i).at(j) + r.at(i).at(j) + u.at(i).at(j) + d.at(i).at(j) - 3);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

const int N = 200000 + 10;
const int MOD = 1000000007;

int a[N];

bool cmp(int x, int y)
{
	if (x < 0) x = -x;
	if (y < 0) y = -y;
	return x > y;
}

int main()
{
	int res, n, k, x1, y1, x2, y2, i;
	cin>>n>>k;
	for (i=0; i<n; i++) cin>>a[i];
	sort(a, a + n, cmp);
	res = 1;
	for (i=0; i<k; i++) res = 1LL * res * a[i] % MOD;
	if (res >= 0) cout<<res<<endl;
	else
	{
		x1 = y1 = x2 = y2 = -1;
		for (i=k-1; i>=0; i--)
			if (a[i] > 0)
			{
				x1 = i;
				break;
			}
		for (i=k; i<n; i++)
			if (a[i] <= 0)
			{
				y1 = i;
				break;
			}
		for (i=k-1; i>=0; i--)
			if (a[i] < 0)
			{
				x2 = i;
				break;
			}
		for (i=k; i<n; i++)
			if (a[i] >= 0)
			{
				y2 = i;
				break;
			}
		if ((x1 < 0 || y1 < 0) && (x2 < 0 || y2 < 0)) 
		{
			res = 1;
			for (i=n-1; i>=n-k; i--) res = 1LL * res * a[i] % MOD;
			res = (res + MOD) % MOD;
		}
		else if ((x1 < 0 || y1 < 0) && !(x2 < 0 || y2 < 0))
		{
			res = 1;
			for (i=0; i<k; i++) if (i != x2) res = 1LL * res * a[i] % MOD;
			res = 1LL * res * a[y2] % MOD;
		}
		else if (!(x1 < 0 || y1 < 0) && (x2 < 0 || y2 < 0))
		{
			res = 1;
			for (i=0; i<k; i++) if (i != x1) res = 1LL * res * a[i] % MOD;
			res = 1LL * res * a[y1] % MOD;
		}
		else if (1LL * a[x1] * a[y2] < 1LL * a[x2] * a[y1])
		{
			res = 1;
			for (i=0; i<k; i++) if (i != x1) res = 1LL * res * a[i] % MOD;
			res = 1LL * res * a[y1] % MOD;
		}
		else
		{
			res = 1;
			for (i=0; i<k; i++) if (i != x2) res = 1LL * res * a[i] % MOD;
			res = 1LL * res * a[y2] % MOD;
		}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 4328