akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,a[500005],p[500005],ans[500005],cnt,vis[500005];
struct ii
{
	int mi,id;
}s[2000005];
ii mrg(ii x,ii y)
{
	return x.mi<y.mi?x:y;
}
void update(int x,int l,int r,int y,ii c)
{
	if(l==r){
		s[x]=c;
		return;
	}
	int mid=(l+r)/2;
	if(y<=mid){
		update(x+x,l,mid,y,c);
	}
	else{
		update(x+x+1,mid+1,r,y,c);
	}
	s[x]=mrg(s[x+x],s[x+x+1]);
}
ii query(int x,int l,int r,int ql,int qr)
{
	if(ql>qr){
		return (ii){0x3f3f3f3f,-1};
	}
	if(ql<=l&&r<=qr){
		return s[x];
	}
	int mid=(l+r)/2;
	if(qr<=mid){
		return query(x+x,l,mid,ql,qr);
	}
	if(ql>mid){
		return query(x+x+1,mid+1,r,ql,qr);
	}
	return mrg(query(x+x,l,mid,ql,qr),query(x+x+1,mid+1,r,ql,qr));
}
vector<int> bi[500005];int deg[500005];
void add(int x,int y){bi[x].push_back(y);deg[y]++;/*cerr<<x<<' '<<y<<endl;*/}
int main()
{
	scanf("%d%d",&n,&m);
	fz1(i,n){
		scanf("%d",&a[i]);
		p[a[i]]=i;
	}
	fz1(i,n){
		update(1,1,n,i,(ii){0x3f3f3f3f,-1});
	}
	fd1(i,n){
		ii t=query(1,1,n,max(1,p[i]-m+1),p[i]-1);
		if(t.id!=-1){
			add(p[t.id],p[i]);
		}t=query(1,1,n,p[i]+1,min(n,p[i]+m-1));
		if(t.id!=-1){
			add(p[t.id],p[i]);
		}
		update(1,1,n,p[i],(ii){i,i});
	}
	priority_queue<int> pq;
	fz1(i,n){
		if(!deg[i]){
			deg[i]=-1;
			pq.push(i);
		}
	}
	cnt=n+1;
	while(!pq.empty()){
		int x=pq.top();pq.pop();
		deg[x]=-1;ans[x]=--cnt;
		ff(bi[x],it){
			if(!--deg[*it]){
				pq.push(*it);
			}
		}
	}
	fz1(i,n){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

#define ll long long
#include<vector>

using namespace std;

int main(){
	int n,c=0;
	cin>>n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
	for(int i=1; i<n-1; i++){
		if((v[i-1]<v[i])&&(v[i]<v[i+1])) c++;
		else if((v[i-1]>v[i])&&(v[i]>v[i+1])) c++;
	}
	cout<<c<<endl;




}



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

typedef long long ll;
typedef long double ld;

map <string, int> br;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n;
    for(int i=1; i<=n; i++){
        string s;
        cin >> s;
        br[s]++;
    }
    cin >> m;
    for(int i=1; i<=m; i++){
        string s;
        cin >> s;
        br[s]--;
    }
    int mx = 0;
    for(auto c : br){
        mx = max(mx, c.second);
    }
    cout << mx << "\n";
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
count = []
ans = ""

n.times do |i|
    s = gets.chomp.split("")
    h = Hash.new(0)
    s.each do |alphabet|
        h[alphabet] += 1
    end
    count << h.sort.to_h
end

("a".."z").each do |alphabet|
    min_count = 114514
    flag = true
    count.each do |h|
        if h.has_key?(alphabet)
            min_count = min_count > h[alphabet] ? h[alphabet] : min_count
        else
            flag = false
            break
        end
    end
    if flag
        ans += alphabet * min_count
    end
end

puts ans

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


int main()
{
  int N;
  long K;
  cin >> N >> K;
  vector<long> a(N);
  vector<int> count(40);
  for (int i = 0; i < N; i++)
  {
    cin >> a[i];
    for (int j = 39; j >= 0; j--)
    {
      if (a[i] & (1L << j))
      {
        count[j]++;
      }
    }
  }
  long used = 0;
  for (int j = 39; j >= 0; j--)
  {
    if ((used + (1L << j)) <= K)
    {
      if (count[j] < N - count[j])
      {
        used += (1L << j);
      }
    }
  }
  long result = 0;
  for (int i = 0; i < N; i++)
  {
    result += used ^ a[i];
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007


using namespace std;


int main() {
	HS;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int diffX = x2 - x1, diffY = y2 - y1;
	int x3, y3, x4, y4;
	x3 = x2 - diffY;
	y3 = y2 + diffX;
	x4 = x1 - diffY;
	y4 = y1 + diffX;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef double db;
typedef pair<int,int> pii;
const int mod = 1e9 +7;
const int win[7] = {0, 1, 0, 1, 1, 1, 1};
void q(void)
{
	cout << 1 << endl;
}

void solve()
{
	string s;
	cin >> s;
	if(s=="ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
}
int main()
{
		solve();
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    char num[1001];
    int sum;
    while(1){
        scanf("%s",num);
        if(num[0] == '0') break;
        sum = 0;
        for(int i = 0; num[i] != '\0'; i++){
            sum += num[i] - '0';
        }
        printf("%d\n",sum);
    }
    return 0;
    
}


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

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

Measured memory_bytes: 3604
from math import gcd
mod = 1000000007
n = int(input())
zero = 0
bad = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zero += 1
        continue
    g = gcd(x, y)
    x //= g
    y //= g
    if y < 0: x, y = -x, -y
    if y==0 and x<0: x, y = -x, -y
    is_rotate90 = (x <= 0)
    if is_rotate90: x, y = y, -x
    if not (x, y) in bad: bad[x, y] = [0, 0]
    bad[x, y][is_rotate90] += 1

ans = 1
for x, y in bad:
    c1, c2 = bad[x, y]
    c3 = (pow(2, c1, mod) - 1) + (pow(2, c2, mod) - 1) + 1
    ans *= c3
    ans %= mod

ans += zero - 1
ans = (ans + mod) % mod
print(ans)


Measured memory_bytes: 60388
import sys
sys.setrecursionlimit(200000)

K = int(input())

lis = [0]

def pl(now,keta):
    now[keta] += 1

    if keta == len(now)-1:
        if now[keta] == 10:
            now.append(1)
            now[keta] = 0
            return
        else:
            return

    else:
        if now[keta] == 10 or now[keta] > now[keta+1] + 1:
            pl(now,keta+1)
            now[keta] = max(0,now[keta+1] - 1)
            return
        else:
            return

for loop in range(K):

    pl(lis,0)

lis.reverse()
print ("".join(map(str,lis)))



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 


#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 1000000007ll
///////////////////////////
///////////////////////////
///

int main() {

   ll n;
   L(n);

   ll res = BM(10ll, n, md);
   res -= BM(9ll, n, md);
   res -= BM(9ll, n, md);
   res += BM(8ll, n, md);
   cout<<((res % md + md) % md)<<Endl;
//    for(int i = 2; i<=n;i++){
//       ll ans = BM(2ll, (ll)i, md) - 2;
//       ans = (ans % md + md) % ans;
//       ans *= BM(8ll, (ll)(n-i), md);
//       res = (res + ans) % md;
//    }



    return 0;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int M=100005,P=(int)1e9+7;
typedef long long LL;
void Add(int &x,int y){
	x+=y;
	if(x<0)x+=P;
	if(x>=P)x-=P;
}
int n,a[M],las[M];
int fac[M],rfac[M];
int fast(int x,int p){
	int re=1;
	while(p){
		if(p&1)re=(LL)re*x%P;
		x=(LL)x*x%P,p>>=1;
	}return re;
}
int C(int a,int b){
	if(b>a)return 0;
	return (LL)fac[a]*rfac[b]%P*rfac[a-b]%P;
}
int main(){
	scanf("%d",&n);n++;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	fac[0]=1,rfac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=(LL)fac[i-1]*i%P,rfac[i]=fast(fac[i],P-2);
	int l=-1,r=-1;
	for(int i=1;i<=n;i++){
		if(las[a[i]]==0)las[a[i]]=i;
		else {
			l=las[a[i]];
			r=i;
			break;
		}
	}
	int mid=r-l-1;
	for(int i=1;i<=n;i++){
		if(i==1){
			printf("%d\n",n-1);
		}else if(i==n)printf("%d\n",1);
		else if(i==2){
			int ans=0;
			Add(ans,C(n-2,2));
			Add(ans,1);
			Add(ans,n-2);
			Add(ans,mid);
			printf("%d\n",ans);
		}else {
			int ans=C(n-2,i);//no imp
			Add(ans,C(n-2,i-2));//two imp has mid
			Add(ans,2LL*C(n-2,i-1)%P),Add(ans,-C(n-2-mid,i-1));//one imp has mid
			printf("%d\n",ans);
		}
	}
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;

int main()
{		
	
    IOS
    ll n;
    cin>>n;
    map<string ,ll> m;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }

    ll ans=0;
    for(auto i:m)
    {
        ans+=((i.ss)*(i.ss-1))/2;
    }


    cout<<ans<<endl;



}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int t;
	cin >> t;
	int sum = 0;
    for(int i = 1; i <= t; i++){
        if (i % 3 != 0 && i%5 != 0){
            sum += i;
        }
    }
    cout << sum;
}




Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <map>
using namespace std;

const int MAXN = 100100;

int N;
vector<int> a;
vector<int> g[MAXN];

bool check(int x, int p) {
	bool leaf = true;
	bool win = false;
	for (int i = 0; i < g[x].size(); ++i) {
		int to = g[x][i];
		if (to != p) {
			leaf = false;
			if (a[to] < a[x]) {
				if (!check(to, x)) {
					win = true;
				}
			}
		}
	}

	if (!leaf) {
		return win;
	} else {
		return false;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i + 1 < N; ++i) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	vector<int> res;
	for (int i = 0; i < N; ++i) {
		if (check(i, -1)) {
			res.push_back(i);
		}
	}
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i] + 1 << " ";
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int N=1e5;
typedef long long ll;

int n,cnt;
struct edge
{
    int head,to,w;
    bool operator <(const edge & x) const
    {
        return w<x.w;
    }
}ed[N<<2];
struct point
{
    int x,y,num;
}p[N];
bool cmp1(point x,point y)
{
    return x.x<y.x;
}
bool cmp2(point x,point y)
{
    return x.y<y.y;
}
int fa[N];

int _find(int x)
{
    if(fa[x]!=x){
        return fa[x]=_find(fa[x]);
    }
    return  fa[x];
}

ll kruskal()
{
    sort(ed+1,ed+1+cnt);
    ll ans=0;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=cnt;i++){
         int xx=_find(ed[i].head);
         int yy=_find(ed[i].to);
        if(xx!=yy) {
            fa[xx]=yy;
            ans+=ed[i].w;
        }
    }
    return ans;
}
int main() {

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i].x>>p[i].y;
        p[i].num=i;
    }
    sort(p+1,p+1+n,cmp1);
    for(int i=1;i<n;i++){
         ed[++cnt].w=p[i+1].x-p[i].x;
         ed[cnt].head=p[i+1].num;
         ed[cnt].to=p[i].num;
    }
    sort(p+1,p+1+n,cmp2);
    for(int i=1;i<n;i++){
         ed[++cnt].w=p[i+1].y-p[i].y;
         ed[cnt].head=p[i+1].num;
         ed[cnt].to=p[i].num;
    }
    cout<<kruskal()<<endl;

    return 0;
}




Measured memory_bytes: 7556
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265358979323
typedef long long ll;
const int INF = 1e9+5;
ll MOD(ll ans, ll m)
{
    return (ans % m + m) % m;
}
int main()
{
    fast_IO;
    int n;
    cin>>n;
    vector<int> ans(3);
    for(int i=0;i<n;i++)
    {
        vector<int> dp(3,0);
        vector<int>c(3);
        for(int i=0;i<3;i++)
        {
            cin>>c[i];
        }
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(i != j)
                {
                    dp[j] = max(dp[j] , ans[i] + c[j]);
                }
            }
        }
        ans = dp;
    }
    cout<<max({ans[0],ans[1],ans[2]})<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
    cout << "infinity" << endl;
    return 0;
  }
  ll x1 = a1 * t1 - b1 * t1;
  ll x2 = (a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2);
  // cerr << x1 << "," << x2 << endl;
  if ((x1 > 0 && x2 > 0) || (x1 < 0 && x2 < 0)) {
    cout << 0 << endl;
    return 0;
  }
  x1 = abs(x1);
  x2 = abs(x2);
  if (x1 < x2) {
    cout << 1 << endl;
  } else if (x1 == x2) {
    cout << 2 << endl;
  } else {
    if (x1 % x2 > 0) {
      ll cnt = x1 / x2;
      cout << 1 + 2 * cnt << endl;
      return 0;
    } else {
      ll cnt = x1 / x2;
      cout << 2 * cnt << endl;
      return 0;
    }
  }
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x, a, b;

int main() {
	cin >> x >> a >> b;
	if (abs(x-a) < abs(x-b)) cout << "A" << ln;
	else cout << "B" << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long a,b;
	char c;
	scanf("%lld %c %lld",&a,&c,&b);
	if(c=='+')
	printf("%lld\n",a+b);
	if(c=='-')
	printf("%lld\n",a-b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <deque>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<string, string> ps;


map<ps, ll>dict;
ll ans;

int main()
{
    char c;
    string s, t;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c;
        s += c;
    }
    for (int i = 0; i < n; i++) {
        cin >> c;
        t += c;
    }

    for (int i = 0; i < (1 << n); i++) {
        int tmp = i;
        
        string red, blue;

        for (int j = n - 1; j >= 0; j--) {
            if (tmp & 1) {
                red.insert(red.begin(), t[j]);
            }
            else {
                blue += t[j];
            }

            tmp = tmp >> 1;
        }

        dict[ps(red, blue)]++;
    }

    for (int i = 0; i < (1 << n); i++) {
        int tmp = i;
        
        string red, blue;

        for (int j = n - 1; j >= 0; j--) {
            if (tmp & 1) {
                red.insert(red.begin(), s[j]);
                //red += s[j];
            }
            else {
                blue += s[j];
                //blue.insert(blue.begin(), s[j]);
            }
            
            tmp = tmp >> 1;
        }

        if (dict.count(ps(blue, red))) {
            ans += dict[ps(blue, red)];
        }
    }

    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

ll mypow(ll x, ll y){
  ll ans = 1;
  rep(i, 0, y) ans = ans * x;
  return ans;
}

int main(){
  ll k;
  cin >> k;
  vector<vvll> luna(100, vvll(10));
  ll count = 0;
  ll keta = 0;
  luna[keta][0] = {0};
  ll ans;
  while(true){
    rep(i, 1, 10){
      if(keta == 0){
        ll now = i;
        luna[keta][i].push_back(now);
        count++;
        ans = now;
        if(count == k) goto OUT;
      }
      else{
        if(i == 1){
          if(keta == 1){
            luna[keta][i].push_back(10);
            count++;
            ans = 10;
            if(count == k) goto OUT;
          }
          rep(j, 0, keta - 1){
            rep(x, 0, 2){
              vrep(y, luna[j][x]){
                ll now = mypow(10, keta) + y;
                luna[keta][i].push_back(now);
                count++;
                ans = now;
                if(count == k) goto OUT;
              } 
            }
          }
        }
        rep(j, -1, 2){
          if(i + j < 10 && i + j > 0){
            vrep(y, luna[keta - 1][i + j]){
              ll now = mypow(10, keta) * i + y;
              luna[keta][i].push_back(now);
              count++;
              ans = now;
              if(count == k) goto OUT;
            }
          }
        }
      }
    }
    keta++;
  }

  OUT:
  cout << ans << endl;
}

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

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

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

    for(int i=0;i<n-1;i++){
        a[i]=h[i]-h[i+1];
    }

    int k=-1,tmp,max=0;

    for(int i=0;i<n-1;i++){
        if(a[i]<0){
            tmp=i-k-1;
            if(max<tmp)max=tmp;
            k=i;
        }
    }

    if(a[n-2]>=0){
        tmp=n-2-k;
        if(max<tmp)max=tmp;
    }

    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();

		if(c>=a&&c<=b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;




int cap[maxn];
int siz[maxn];
int par[maxn];


int parent(int x) {
    if (x==par[x]) return x;
    return par[x]=parent(par[x]);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    int n, h, w;
    cin>>n>>h>>w;

    for (int i=0; i<h+w; i++) {
	cap[i] = 1;
	siz[i] = 1;
	par[i] = i;
    }


    // Every row and column starts off with capacity=1
    // As long as the cc of rows and cols collectively have enough capacity to handle the number of nodes
    // we picked, there always exists an assignment of rows/cols -> nodes.
    
    
    vector<pair<ll,pair<int,int>>> cards;
    for (int i=0; i<n; i++) {
	int r,c,a;
	cin>>r>>c>>a;
	--r; --c;
	cards.push_back({a,{r,c}});
    }

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


    ll res = 0;

    while (!cards.empty()) {
	auto card = cards.back();
	ll val = card.first;
	int r = card.second.first;
	int c = card.second.second + h;
	cards.pop_back();

	r = parent(r);
	c = parent(c);

	if (r==c) {
	    if (cap[r] >= 1) {
		res += val;
		cap[r]--;
	    }
	} else {
	    if (cap[r]+cap[c] >= 1) {
		res += val;
		if (siz[r] < siz[c]) {
		    swap(r, c);
		}
		siz[r] += siz[c];
		par[c] = r;
		cap[r] += cap[c];
		cap[r]--;
	    }
	}
    }

    cout<<res<<endl; 
    return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 200000, MAXLOGA = 20;

int dp[2][MAXLOGA + 1];

int main() {
	int N;
	cin >> N;
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		int A;
		cin >> A;
		int l = 0;
		for(int j = A, k = 0; k <= MAXLOGA; j >>= 1, k++) {
			if(j & 1) {
				l = max(l, dp[0][k]);
				dp[1][k] = dp[0][k];
				dp[0][k] = i + 1;
			} else {
				l = max(l, dp[1][k]);
			}
		}
		ans += i - l + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

// common
#define X real()
#define Y imag()

using Vector2 = complex<double>;
using Line = pair<Vector2, Vector2>;
using Segment = pair<Vector2, Vector2>;
const double EPS = 1e-10;
const double PI = 3.14159265359;

bool isSame(double a, double b){
    if(abs(a - b) < EPS){
        return true;
    }
    else{
        return false;
    }
}

// struct

struct Circle{
    Vector2 c;
    double r;
    Circle(Vector2 c, double r){
        this->c = c;
        this->r = r;
    }
};

// Vector2
double dot(Vector2 a, Vector2 b){
    return (a.X * b.X + a.Y * b.Y);
}

double cross(Vector2 a, Vector2 b){
    return (a.X * b.Y - a.Y * b.X);
}

Vector2 project(Line l, Vector2 p){
    Vector2 base = l.second - l.first;
    double r = dot(p - l.first, base) / norm(base);
    return l.first + base * r;
}

Vector2 reflect(Line l, Vector2 p){
    return p + (project(l, p) - p) * 2.0;
}

int main(){

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Line l(Vector2(x1, y1), Vector2(x2, y2));
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        Vector2 p(x, y);
        Vector2 ans = reflect(l, p);
        cout << fixed << setprecision(9) << ans.X << " " << ans.Y << endl;
    }

    return 0;
}


Measured memory_bytes: 3324
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<int Modulo = MOD>
struct Mint {

	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v % Modulo) { if (val < 0) val += Modulo; }

	constexpr Mint& operator += (const Mint &r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint &r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint &r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint &r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			lint t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}

	constexpr Mint operator + (const Mint &r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint &r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint &r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint &r) const noexcept { return Mint(*this) /= r; }

	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }

	constexpr bool operator == (const Mint &r) const noexcept { return val == r.val; }
	constexpr bool operator != (const Mint &r) const noexcept { return val != r.val; }

	friend ostream &operator << (ostream &os, const Mint<Modulo> &x) noexcept { return os << x.val; }
	friend istream &operator >> (istream &is, Mint<Modulo> &x) noexcept {
		lint tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo> &a, lint n) noexcept {
		Mint now(1), tmp = a;
		while (n > 0) {
			if (n & 1) now *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return now;
	}
};

using mint = Mint<2019>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	int ans = 0;
	vector<int> rem(2019);
	rem[0] = 1;
	mint now = 0, ten = 1;
	for (int i = S.size() - 1; i >= 0; i--, ten *= 10) {
		now += ten * (S[i] - '0');
		ans += rem[now.val]++;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3724
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
void fail() { cout << -1 << endl; exit(0); }

typedef pair<int, int> pii; typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9+7;
constexpr int MAX = 50050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1; constexpr int INF = 1e9 + 1;
//const int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

int cnt[100010];
void solve() {
	int N; cin >> N;
	REP(i, N) {
		int a; cin >> a;
		cnt[a]++;
	}
	ll ans = 0;
	REP(i, 100010) {
		ans += cnt[i] * i;
	}
	int Q; cin >> Q;
	REP(i, Q) {
		int b, c; cin >> b >> c;
		ans -= cnt[b] * b;
		ans += cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		print(ans);
	}

	//print(ans);
}





signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//mt.seed((int)(time(0)));
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}



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

using namespace std;

int main(){
  unsigned tmp;
  vector<unsigned> height;
  for ( unsigned i = 0; i < 10; i++ )
    {
      cin >> tmp;
      height.push_back( tmp );
    }
  sort( height.begin(), height.end(), greater<unsigned>() );
  for ( unsigned i = 0; i < 3; i++ )
    {
      cout << height[ i ] << endl;
    }
  return 0;
}

Measured memory_bytes: 1208
// abc073_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,l,r;
  ll ans=0;
  cin>>n;
  rep(i,n){
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    int H, A;
    cin >> H >> A;
    if (H % A == 0) {
        cout << H / A << endl;
    } else {
        cout << H / A + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
i1 = input()
i2 = int(i1.split(" ")[0])
i3 = int(i1.split(" ")[1])
i4 = 0
i5 = 0
i6 = 0
li = []
for i in range(i2):
  i4 = input().split(" ")
  i5 = (float(i4[1]) ** 2 + float(i4[0]) ** 2) ** 0.5
  if i3 >= abs(i5):
    i6 += 1
print(i6)

Measured memory_bytes: 9664
#include<stdio.h>
int main()
{
    int n,t,k=0,temp;
    scanf("%d %d",&n,&t);
    int ac[n],at[n],az[n],min=1001;
    for(int i=0; i<n; i++)
    {
        scanf("%d %d",&ac[i],&at[i]);
    }
    for(int j=0; j<n; j++)
    {
        if(at[j]> t)
        {
            ac[j]=1002;

        }
        if(ac[j]<min)
        {
            min=ac[j];
        }

    }

//    int min =1000;
//    for(int l=0; l<k; l++)
//    {
//        if(az[k]<min)
//        {
//            min=az[k];
//        }
//
//    }
    if(min!=1001)
    {
    printf("%d",min);
    }
    else
    {
        printf("TLE");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, X, Y;


signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> A(N);

    FOR(i, N){
        FOR(j, i){
            int a = min({i-j,abs(Y-i)+1+abs(X-j),abs(X-i)+1+abs(Y-j)});
            A[a]++;
        }
    }
    FOR(i, 1, N){
        cout << A[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<climits>
#include<algorithm>

#define MAX 200010

using namespace std;

int price[MAX];

int main()
{
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &price[i]);
    }
    int result = INT_MIN;
    int minNum = price[0];
    for (i = 1; i < n; i++) {
        result = max(result, price[i] - minNum);
        minNum = min(minNum, price[i]);
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 3508
N, K = map(int, input().split())
S = input()
Nums = []
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
# 累積和を作る
# 0 1 2 3 4 5 6
#  0 1 2 3 4 5
sum = [0] * (len(Nums) + 1)
for i in range(len(Nums)):
    sum[i + 1] = sum[i] + Nums[i]
ans = 0
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    # 次のleft, rightを計算する [left, right)
    left = i
    right = min(i + Add, len(Nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 46956
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>

using namespace std;

int main() {
    bool x;
    cin >> x;
    cout << !x << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main(){
int a,b;
  int big;
  cin>>a>>b;
  for(int i=0;i<2;i++){
  if(a>=b){
	big+=a;
    a--;
  }else{
	big+=b;
    b--;
  }
}
  cout<<big<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a <= c && c <= b) {

			System.out.print("Yes");
			System.out.print(" ");

		} else

		{
			System.out.print("No");
			System.out.print(" ");
		}

	}

}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int arr[100005]={0},ans[100005],i,d;
  
  for(i=1;i<=n;i++)
    cin >> arr[i];
  
  ans[1]=0;
  
  for(i=2;i<=n;i++)
  {  ans[i]=ans[i-1]+abs(arr[i-1]-arr[i]);
     if(i>2)
    ans[i]=min(ans[i],ans[i-2]+abs(arr[i-2]-arr[i]));
  }
   cout<<ans[n];
}

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

template<class T>
std::vector<T> read_vector(const uint64_t n) {
    auto v = std::vector<T>();
    v.reserve(n);

    for(uint64_t i = 0; i < n; ++i) {
        T t;
        std::cin >> t;
        v.push_back(t);
    }

    return v;
}

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

    auto hs = read_vector<uint64_t>(n);

    auto succeed = true;

    for(int i = n - 2; i >= 0; --i) {
        if(hs[i] >= hs[i + 1] + 2) {
            succeed = false;
            break;
        } else if(hs[i] == hs[i + 1] + 1) {
            --hs[i];
        }
    }

    if(succeed) {
        std::cout << "Yes";
    } else {
        std::cout << "No";
    }
    std::cout << std::endl;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  int g[101][101], h[101][101];
  fill(g[0], g[101], inf);
  fill(h[0], h[101], inf);
  rep(i, 101) g[i][i] = h[i][i] = 0;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a][b] = g[b][a] = h[a][b] = h[b][a] = c;
  }
  rep(i, n) rep(j, n) rep(k, n) {
    g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
  }
  int ans = 0;
  rep(i, n) reps(j, i+1, n) {
    if(h[i][j] == inf) continue;
    if(g[i][j] != h[i][j]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

A=rr(5)
x = 10
for a in A:
    x = min(x,a%10 if a%10 !=0 else 10)

s = 0
for a in A:
    s += (a//10)*10
    s += 10 if a%10 != 0 else 0

print(s-10+x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  int c[20][20];
  int d[20][20];
  rep(i,a){
  cin>>b[i];
    rep(j,b[i])
      cin>>c[i][j]>>d[i][j];
  }
  int ans=0;
  rep(i,(1<<a)){
  bitset<20> bit(i);
    bool e=1;
   rep(j,a){
     if(bit.test(j)){
     rep(k,b[j]){
       int v=c[j][k]-1;
  if(d[j][k]!=bit.test(v))
    e=0;
   }
      }
     }
   if(e){
     int t=bit.count();
    chmax(ans,t);
    }
  }
  cout<<ans<<endl;
  }

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

typedef long long LL;

const int N = 200050;

vector<int> G[N];
priority_queue<int, vector<int>, greater<int> >  S[N];
int a[N], g[N], d[N], n, u, v;

void dfs(int x, int p) {
    int k = lower_bound(g+1, g+n+1, a[x]) - g;
    d[x] = max(d[p], k);
    g[k] = a[x];
    S[k].push(a[x]);
    /*
    printf("push %d:", x);
    for (int i = 0; i < 10; ++i) printf("%d ", g[i]);
    printf("\n");
    */

    for (int i = 0; i < G[x].size(); ++i) {
        int y = G[x][i];
        if (y == p) continue;
        dfs(y, x);
    }

    S[k].pop();
    if (S[k].empty()) g[k] = 2e9;
    else g[k] = S[k].top();
    /*
    printf("pop  %d:", x);
    for (int i = 0; i < 10; ++i) printf("%d ", g[i]);
    printf("\n");
    */
}

int work() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i < n; ++i) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i = 0; i <= n; ++i) g[i] = 2e9;
    dfs(1, 1);

    for (int i = 1; i <= n; ++i) printf("%d\n", d[i]);
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 38728
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int h[] = new int[N];
    for(int i = 0; i < N; i++){
      h[i] = sc.nextInt();
    }
    int tmp = 0;
    int count = 0;
    do{
      tmp = count;
      int min = 100;
      int index = 0;
      int lastValue = 0;
      for(int i = 0; i < N; i++){
        if(h[i] == 0){
          if(lastValue == 0){
            index = i + 1;
            continue;
          }
          for(int j = index; j < i; j++){
            h[j] -= min;
          }
          count += min;
          min = 100;
          index = i + 1;
          lastValue = 0;
        }else if(i == N-1){
          min = (min < h[i]) ? min : h[i];
          for(int j = index; j <= i; j++){
            h[j] -= min;
          }
          count += min;
          min = 100;
          index = i + 1;
        }
        min = (min < h[i]) ? min : h[i];
        lastValue = h[i];
      }
    }while(tmp != count);
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
using namespace std;

int main() {

  int h, w;
  string s[100];
  cin >> h >> w;
  for(int i=0; i<h; i++){
    cin >> s[i];
  }
  for(int i=0; i<h; i++){
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
  return 0;
}

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

int N, Y;
int res10000 = -1, res5000 = -1, res1000 = -1;

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

	for (int x = 0; x <=N; x++) {
		for (int y = 0; x + y <=N; y++) {
			int z = N - x - y;
			int sum = 10000 * x + 5000 * y + 1000 * z;
			if (sum == Y) {
				res10000 = x;
				res5000 = y;
				res1000 = z;
			}
		}
	}
	cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256