akhauriyash/Code-Regression huggingface dataset:
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-12-1 22:26:27
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int F[110][10];
ll P[110][11];
int cnt[110];
ll ans = -10000000000000;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    for (auto j = 0; j < 10; j++)
    {
      cin >> F[i][j];
    }
  }
  for (auto i = 0; i < N; i++)
  {
    for (auto j = 0; j < 11; j++)
    {
      cin >> P[i][j];
    }
  }
  for (auto i = 1; i < (1 << 10); i++)
  {
    fill(cnt, cnt + N, 0);
    for (auto j = 0; j < 10; j++)
    {
      if ((i >> j) & 1)
      {
        for (auto k = 0; k < N; k++)
        {
          if (F[k][j])
          {
            cnt[k]++;
          }
        }
      }
    }
    ll tans = 0;
    for (auto k = 0; k < N; k++)
    {
      tans += P[k][cnt[k]];
    }
    ans = max(tans, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
c = 0
d = 0
for i in A:
    if i % 4 == 0:
        c += 1
    elif i % 2 == 0:
        d += 1
if d > 0:
    if c >= n-c-d : print("Yes")
    else: print("No")
else:
    if c >= n//2: print("Yes")
    else: print("No")

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

int main() {
	int n,l;;
	cin >> n >> l;
	int sm = n * l + n * (n - 1) / 2;
	int sm1 = 0;
	if(l<0&&l+n-1<0)
	{
		sm1=l+n-1;
	}
	else if(l>0)
	{
		sm1 =l;
	}
	cout << sm - sm1<< endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ld> p(n);
	REP(i, n) cin >> p[i];
	vector<vector<ld>> dp(n, vector<ld>(6001, 0));
	dp[0][3001] = p[0];
	dp[0][2999] = 1 - p[0];
	FOR(i, 1, n) REP(j, 6001) {
		if(j) dp[i][j] += dp[i - 1][j - 1] * p[i];
		if(j != 6000) dp[i][j] += dp[i - 1][j + 1] * (1 - p[i]);
	}
	ld ans = 0;
	FOR(i,3001, 6001) ans += dp[n - 1][i];
	cout << fixed << setprecision(39) << ans << endl;
	return 0;
}

/* --------------------------------------- */


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

int main(void)
{
	int n;
	int money = 100000;
	cin >> n;

	while(n > 0){
		n--;
		money = money + money*0.05;
		if(money % 1000 > 0)
			money = money-money%1000+1000;
	}
	cout << money << endl;


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n,p;
while(cin>>p>>n){
if((p==4||p==6||p==9||p==1)&&(n==4||n==6||n==9||n==11)) cout<<"Yes"<<endl;
else if((p==1||p==3||p==5||p==7||p==8||p==10||p==12)&&(n==1||n==3||n==7||n==8||n==5||n==10||n==12))cout<<"Yes"<<endl;
else cout<<"No"<<endl;
} return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

typedef struct node{
  int p;
  int l;
  int r;
  int d;
  int h;
}Node;

Node T[30];


void setDepth(int u,int d){
  if(u == NIL){
    return;
  }

  T[u].d = d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}

int setHeight(int u){
  int h1 = 0;
  int h2 = 0;

  if(T[u].l != NIL){
    h1 = setHeight(T[u].l)+1;
  }
  if(T[u].r != NIL){
    h2 = setHeight(T[u].r)+1;
  }
  return T[u].h = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL)return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL)return T[T[u].p].r;
  return NIL;
}

int main(){
  int n,i,j,v,l,r,root,deg;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i=0;i<n;i++){
    if(T[i].p == NIL ){
      root = i;
    }
  }
  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++){
    deg = 0;
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,getSibling(i));
    if(T[i].l != NIL)deg++;
    if(T[i].r != NIL)deg++;
    printf("degree = %d, depth = %d, height = %d, ",deg,T[i].d,T[i].h);
    if(T[i].p == NIL)printf("root\n");
    else if(T[i].l == NIL && T[i].r == NIL)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <algorithm>
using namespace std;

#define INF 1e9

int a[111][111], b[111][111];

int main(void)
{
	int n, m, i, j, k, ans = 0;

	scanf("%d %d" ,&n, &m);

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i != j)
				a[i][j] = INF;

	while (m--)
	{
		int x, y, z;

		scanf("%d %d %d" ,&x, &y, &z);

		a[x][y] = a[y][x] = b[x][y] = b[y][x] = z;
	}

	for (k = 1; k <= n; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);

	for (i = 1; i < n; i++)
		for (j = i + 1; j <= n; j++)
			if (a[i][j] < b[i][j])
				++ans;

	printf("%d" ,ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{
  public static void main(String[] args){
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int x = Integer.parseInt(br.readLine());
      int h = x/3600;
      int m = (x%3600)/60;
      int s = ((x%3600)%60);
      System.out.println(h + ":" + m + ":" + s);
    } catch(IOException e){
      System.err.println(e.toString());
    }
  }
}


Measured memory_bytes: 24232
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,D;
    cin >> N >> D;
    double X[N][D];
    rep(i,N) rep(j,D) cin >> X[i][j];
    int ans=0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        double dis=0;
        rep(k,D) dis+=pow(X[i][k]-X[j][k],2);
        dis=sqrt(dis);
        if(dis==(int)dis) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll nax = 100000 + 10;

vi graph[nax];

int dfs(int v, int par)
{
    if(graph[v].size() == 1 && par != -1)
    {
        return 0;
    }
    int xori = 0;
    for(auto x: graph[v])
    {
        if(x == par) continue;
        xori ^= (dfs(x, v) + 1);
    }
    return xori;
}
void clr()
{
    for(int i = 1; i <= 1e5; i++)
        graph[i].clear();
}
int main()
{
    ios::sync_with_stdio(0);
    int t = 1;
    while(t--)
    {
        int n;
        cin >> n;
        clr();
        for(int i = 1; i <= n - 1; i++)
        {
            int u, v;
            cin >> u >> v;
            graph[u].pb(v);
            graph[v].pb(u);
        }
        int ans = dfs(1, -1);
        if(ans == 0)
            cout << "Bob" << endl;
        else
            cout << "Alice" << endl;
    }
    return 0;
}


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

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(m);
    rep(i, m) {
        cin >> ab[i].first >> ab[i].second;
        ab[i].first--; ab[i].second--;
    }
    ll ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (j == i) continue;
            uf.merge(ab[j].first, ab[j].second);
        }
        set<ll> s;
        rep(j, n) s.insert(uf.root(j));
        if (sz(s) > 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 2000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,s;

int main(void){
	scanf("%lld%lld",&n,&s);
	if(n==s){
		printf("%lld\n",n+1LL);
		return 0;
	}
	for(ll b=2;b*b<=n;b++){
		ll cnt=0,nn=n;
		while(nn>0){
			cnt+=nn%b;
			nn/=b;
		}
		if(cnt==s){
			printf("%lld\n",b);
			return 0;
		}
	}
	ll res=n+1LL;
	for(ll p=1;p*p<n;p++){
		ll b=(n-s)/p+1LL;
		if(b<2 || b<n/b)continue;
		if(n/b+n%b==s)res=min(res,b);
	}
	printf("%lld\n",res==n+1LL?-1:res);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

bool isSymmetry(vector<string> T, int N){
    FOR(i, 0, N){
        FOR(j, 0, N){
            if(T[i][j]!=T[j][i]){
                return false;
            }
        }
    }
    return true;
}

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

    // input
    ll N;
    cin >> N;

    vector<string> S(N);
    FOR(i, 0, N){
        cin >> S.at(i);
    }

    ll count = 0;
    vector<string> T(N);
    // y方向にずらしたときにシンメトリーかチェック
    FOR(offset, 0, N){
        FOR(i, 0, N){
            int index = i + offset;
            if(index >= N){
                index -= N;
            }
            T[i] = S[index];
        }
        if(isSymmetry(T, N)){
            count++;
        }
    }

    p(count * N);
    
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

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

ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}


int main(){

  ll n,k;cin>>n>>k;
  ll a[n];

  ll p=1e6;
  ll ma=0;
  rep(i,0,n){
    cin>>a[i];
    p=min(p,a[i]);
    ma=max(ma,a[i]);
  }

  rep(i,0,n){
    p=gcd(p,a[i]);
  }
  for(int num=p;num<=ma;num+=p){
    if(num==k){
      out("POSSIBLE");
      return 0;
    }
  }

  out("IMPOSSIBLE");





  return 0;
}


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

int M,N;

int main(){
	cin>>N>>M;
	if(N&1){
		for(int i=1;i<=M;i++){
			cout<<i<<' '<<N-i<<endl;
		}
	}
	else{
		for(int i=1;i<=M;i++){
			if(N+1-i-i>N/2){
				cout<<i<<' '<<N+1-i<<endl;
			}
			else{
				cout<<i<<' '<<N-i<<endl;
			}
		}
	}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll d,s,t;
  cin>>d>>t>>s;
  if(d<=t*s){
    COUT("Yes");
  }
  else COUT("No");
}

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

#define ok cout<<"ok"<<endl
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;
int main()
{
	int n,m;
	cin>> n >> m;
	cout <<(m * 1900 + (n - m) * 100) * pow(2,m)<< endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;
using ull = unsigned long long;

ull calcSunuke(ull n) {
  ull sunuke = 0;
  while (n != 0) {
    sunuke += n % 10;
    n /= 10;
  }
  return sunuke;
}

bool check(ull n, ull base) {
  return n * calcSunuke(n + base) <= calcSunuke(n) * (n + base);
}

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

  ull K;
  cin >> K;

  ull c = 0;
  ull n = 0;
  ull base = 1;

  while (1) {
    if (K <= c) break;
    
    if (!check(n + base, base)) base *= 10;

    n += base;
    cout << n << endl;
    ++c;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)


template <typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n=0): n(n), d(n+1){}
    //add x to d[i+1]
    void add(int i, T x=1){
        for(++i; i<=n; i+=i&-i){
            d[i]+=x;
        }
    }
    T sum(int i){
        T x=0;
        for(++i; i; i-=i&-i){
            x+=d[i];
        }
        return x;
    }
    // Reconsider how useful this is.
    //
    //T sum(int r, int l){
    //    return sum(l-1)-sum(r-1);
    //}
};

// How to use
// Initiate BIT, to write "BIT <int> d(n);"

int main(){
    int n,q; cin>>n>>q;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> col(n+1,-1);
    vector<vector<int>> che(n);
    rep(i,n){
        if(col[a[i]]!=-1){
            che[col[a[i]]].push_back(i);
        }
        col[a[i]]=i;
    }

    vector<vector<P>> inp(n);
    rep(i,q){
        int a,b; cin>>a>>b;
        a--; b--;
        inp[a].emplace_back(b,i);
    }
    vector<int> ans(q);
    BIT<int> d(n);
    for(int i=n-1; i>=0; --i){
        for(auto &v: che[i]){
            d.add(v,1);
        }
        for(auto & v: inp[i]){
            ans[v.second]=v.first-i+1-d.sum(v.first);
        }
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 59920
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

struct Edge {
  int from, to, weight;
  Edge(int from, int to, int weight) : from(from), to(to), weight(weight) {}
};

struct Node {
  std::vector<Edge> ongoingEdges;
  void addEdge(Edge edge) {
    ongoingEdges.push_back(edge);
  }
};

class Graph {
private:
  std::vector<Node> nodes;
  int size;
public:
  Graph(int size): size(size) {
    nodes.resize(size);
  }
  void addEdge(Edge edge) {
    nodes[edge.from].addEdge(edge);
  }

  std::vector<int> calculateDist(int source) {
    std::vector<int> dist(size, (1 << 30));
    std::priority_queue< std::pair<int, int>, std::vector< std::pair<int, int> >, std::greater< std::pair<int, int> > > pq;

    pq.push(std::make_pair(0, source));
    dist[source] = 0;

    while(!pq.empty()) {
      int from = pq.top().second;
      pq.pop();

      for(Edge edge: nodes[from].ongoingEdges) {
        if(dist[edge.to] > dist[from] + edge.weight) {
          dist[edge.to] = dist[from] + edge.weight;
          pq.push({dist[edge.to], edge.to});
        }
      }

    }

    return dist;
  }
};

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

  for(int i = 0; i < n; i++) {
    int u, k;
    std::cin >> u >> k;

    for(int i = 0; i < k; i++) {
      int v, c;
      std::cin >> v >> c;
      graph.addEdge(Edge(u, v, c));
    }

  }

  std::vector<int> dist = graph.calculateDist(0);

  for(int i = 0; i < n; i++) {
    std::cout << i << ' ' << dist[i] << std::endl;
  }

}

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

int main() {
  int n, k;
  string s;
  cin>>n>>s>>k;
  char c = s[k-1];
  for (int i=0; i<n; i++) {
    if (s[i] == c) {
      cout<<c;
    } else {
      cout<<"*";
    }
  }
  cout<<endl;

}

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

int main() {
	while (1) {
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) break;

		int i, j, k;
		int l = 0;
		for (i = 1; i <= n - 2; i++) {
			for (j = 2; j <= n - 1; j++) {
				if (i >= j) continue;
				for (k = 3; k <= n; k++) {
					if (j >= k) continue;
					if (i + j + k == x) {
						l++;
					}
				}
			}
		}
		cout << l << endl;
	}


	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC147C()
{
	int N;
	cin >> N;
	vector<map<int, int> > ans(N);
	for (int i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
		for (int j = 0; j < A; ++j)
		{
			int x, y;
			cin >> x >> y;
			ans[i][x - 1] = y;
		}
	}

	int num = 0;
	for (int i = 0; i < (1 << N); ++i)
	{
		bool contradiction = false;
		for (int j = 0; j < N; ++j)
		{
			bool isOk = (i >> j) & 1;
			for (auto& x : ans[j])
			{
				int k = x.first;
				bool b = (i >> k) & 1;
				bool ansOk = (b && x.second) || (!b && !x.second);
				if (isOk && !ansOk)
				{
					contradiction = true;
					break;
				}
			}
			if (contradiction)
				break;
		}
		if (!contradiction)
		{
			int x = 0;
			for (int j = 0; j < N; ++j)
			{
				x += (i >> j) & 1;
			}
			num = max(num, x);
		}
	}
	cout << num << endl;
}

int main()
{
	ABC147C();
	return 0;
}

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

int main(){
    std::string str;
    std::cin >> str;

    if((str.at(0) == str.at(1) && str.at(1) == str.at(2)) || str.at(1) == str.at(2) && str.at(2) == str.at(3)){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, k, a[200010], mu;
vector<int> ta;

signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	rep(i, n) {
		if (i == 0 || a[i - 1] != a[i]) {
			ta.push_back(upper_bound(a, a + n, a[i]) - lower_bound(a, a + n, a[i]));
		}
	}
	if (ta.size() <= k) {
		cout << 0 << endl;
		return 0;
	}
	sort(ta.begin(), ta.end());
	rep(i, ta.size() - k) mu += ta[i];
	cout << mu << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 3956
from collections import defaultdict
import math
N, X, Y = list(map(int, input().split()))
res = defaultdict(int)
x = []
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i >= j:
            continue
        if i == X and Y == j:
            key = 1
        else:
            key = int(min(j - i, math.fabs(X - i) + math.fabs(Y - j) + 1))
        res[key] += 1


for i in range(1, N):
    print(res[i])


Measured memory_bytes: 48220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max((a*c),max((a*d),(max((b*d),(b*c)))));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)3e3+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cout << #x << " = " << x << endl;
#define pb push_back
#define MP make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vii vector<pi>
#define all(x) x.begin(), x.end()

int n,m,t,k;
double p[MAXN];
double dp[MAXN][MAXN];

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

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i];

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << 1-p[i] << endl;
	// }

	dp[0][0] = 1.0f-p[0];
	dp[0][1] = p[0];

	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j <= i+1; ++j)
		{
			if(j)
				dp[i][j] = dp[i-1][j] * (1.0f-p[i])  + dp[i-1][j-1] * (p[i]);
			else
				dp[i][j] = dp[i-1][j] * (1.0f-p[i]);
		}
	}

	double ans = 0;
	for (int i = n/2+1; i <= n; ++i)
	{
		// cout << i _ dp[n-1][i] << endl;
		ans += dp[n-1][i];
	}

	cout << std::setprecision(12) << ans;
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << i << " : ";
	// 	for (int j = 0; j <= i+1; ++j)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	return 0;
}


Measured memory_bytes: 68992
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll solve(ll a) {
    ll ans = (((a + 1) % 4) >> 1);
    if ((a & 1) == 0) ans |= a;
    return ans;
}

int main() {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", solve(a - 1) ^ solve(b));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B == C+D){
        cout <<"Balanced"<<endl;
    }
    if(A+B < C+D){
        cout<<"Right"<<endl;
    }
    if(A+B > C+D){
        cout <<"Left"<<endl;
    }
    return 0;
}


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

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  vector<int> v;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0') v.push_back(0);
    if(s[i] == '1') v.push_back(1);
    if(s[i] == 'B' && v.size() != 0) v.pop_back();
  }
  for(int i = 0; i < v.size(); i++){
    cout << v[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
	int tcase;
	ll A,B,C,D;
	scanf("%d",&tcase);
	while(tcase--){
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		if(B>A || B>D) puts("No");
		else if(C>=B) puts("Yes");
		else{
			ll last=A-(A-C)/B*B-B;
			if((A-C)%B==0) last+=B;
			if(last<0) puts("No");
			else if(D==B) puts("Yes");
			else{
				ll pos=last+(B-1-last)/__gcd(B,D-B)*__gcd(B,D-B);
				if(C<pos && pos<B) puts("No");
				else puts("Yes");
			}
		}
	}
	return 0;
}

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

typedef long long ll;
ll M = 1e9 + 7;
ll n;
map<ll, ll> d;

ll f(ll p) {
    if (p <= 1) return p + 1;
    if (d.count(p)) return d[p];
    if (p % 2) return d[p] = (f(p / 2) * 2 + f(p / 2 - 1)) % M;
    return d[p] = (f(p / 2) + f(p / 2 - 1) * 2) % M;
}

int main()
{
	cin >> n;
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, t;
	scanf("%d%d", &n, &t);
	int cur = 0;
	int x;
	scanf("%d", &x);
	ll cvr = t;
	ll res = t;
	for (int i = 1; i < n; ++i) {
		scanf("%d", &x);
		cvr = max(cvr, (ll)x);
		ll ncvr = x + t;
		res += ncvr - cvr;
		cvr = ncvr;
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		int W, H; cin >> W >> H;
		vector< vector<bool> > a(H, vector<bool>(W));
		while (N--) {
			int x, y; cin >> x >> y;
			a[y - 1][x - 1] = true;
		}
		int S, T; cin >> S >> T;
		int maxi = 0;
		for (int y = 0; y + T <= H; y++)
			for (int x = 0; x + S <= W; x++) {
				int cnt = 0;
				for (int _y = y; _y < y + T; _y++)
					for (int _x = x; _x < x + S; _x++)
						if (a[_y][_x]) cnt++;
				maxi = max(maxi, cnt);
			}
		cout << maxi << endl;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<int> A(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
	int cnt = 0, a = 0;
	while (a != 1)
	{
		a = A[a]-1;
		cnt++;
		if (cnt > n)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1e9+7
#define MOD 1e9+7
#define EPS 1e-10

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

P p[100];
bool f[100];

void print_Preorder(int id){
	cout << " " << id;
	if (p[id].first != -1)print_Preorder(p[id].first);
	if (p[id].second != -1)print_Preorder(p[id].second);
}

void print_Inorder(int id){
	if (p[id].first != -1)print_Inorder(p[id].first);
	cout << " " << id;
	if (p[id].second != -1)print_Inorder(p[id].second);
}

void print_Postorder(int id){
	if (p[id].first != -1)print_Postorder(p[id].first);
	if (p[id].second != -1)print_Postorder(p[id].second);
	cout << " " << id;
}

int main(){
	int n, s;
	cin >> n;
	for (int i = 0; i < n; i++){
		int id, l, r;
		cin >> id >> l >> r;
		if (i == 0)s = id;
		p[id] = P(l, r);
		if (l != -1)f[l] = 1;
		if (r != -1)f[r] = 1;
	}
	for (int i = 0; i < n; i++){
		if (!f[i])s = i;
	}
	cout << "Preorder" << endl;
	print_Preorder(s);
	cout << endl;
	cout << "Inorder" << endl;
	print_Inorder(s);
	cout << endl;
	cout << "Postorder" << endl;
	print_Postorder(s);
	cout << endl;
}

Measured memory_bytes: 3060
import java.io.*;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			
			String s = stdIn.nextLine();
			
			int l = s.length();
			for(int i = 0;i < l;i++){
				if(Character.isUpperCase(s.charAt(i))){
					char a = s.charAt(i);
					a = Character.toLowerCase(a);
					System.out.print(a);
				}
				else {
					char a = s.charAt(i);
					a = Character.toUpperCase(a);
					System.out.print(a);
				}
			}
			System.out.println();
		} catch(Exception e){
		}
	}
}
			

Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, B, M;
	cin >> A >> B >> M;
	
	vector<int> ai, bi;
	ai.push_back(0);// dummy
	bi.push_back(0);// dummy
	int minA = 100000, minB = 100000;
	for(int i = 0; i < A; i++){int t; cin >> t; if(t < minA) minA = t; ai.push_back(t);}
	for(int i = 0; i < B; i++){int t; cin >> t; if(t < minB) minB = t; bi.push_back(t);}
	int min_v = minA + minB;
	
	for(int i = 0; i < M; i++){
		int x, y, c;
		cin >> x >> y >> c;
		int v = ai[x] + bi[y] - c;
		if(v < min_v) min_v = v;
	}
  
  cout << min_v << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include <vector>
#include<math.h>
#include <map>
#include <functional>
#include <queue>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
using namespace std;
int n;
vector<int> g[100005];
int cnt[100005];
int val[100005];
int main(){
	cin >>n;
	for(int i=0;i<n-1;i++){
		int a,b; cin >>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		cnt[a]++;
		cnt[b]++;
	}
	vector<int> c(n);
	cinf(n,c);
	sort(c.begin(),c.end());
	queue<int> q;
	for(int i=0;i<n;i++){
		if(cnt[i]==1)q.push(i);
	}
	ll ans=0;
	int cur=0;
	while(q.size()){
		int v=q.front();
		q.pop();
		val[v]=c[cur];
		ans+=cnt[v]*c[cur];
		cur++;
		for(int i=0;i<g[v].size();i++){
			int nv=g[v][i];
			cnt[nv]--;
			if(cnt[nv]==1){
				q.push(nv);
			}
		}
	}
	cout << ans << endl;
	for(int i=0;i<n;i++){
		cout << val[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
      
        string a,b;cin>>a>>b;
        ll n=a.length();
        ll flg=0;
        for(ll i=0;i<n;i++){
            if(a[i]!=b[i])
            flg=1;
        }
        if(flg)
        cout<<"No"<<endl;
        else
        cout<<"Yes"<<endl;

}


Measured memory_bytes: 3660
#template
def inputlist(): return [int(k) for k in input().split()]
#template
A,B,C,D = inputlist()
ta = 0
ao = 0
if C % B == 0:
    ta = C//B
if C % B != 0:
    ta = (C//B)+1
if A % D == 0:
    ao = A//D
if A % D != 0:
    ao = (A//D)+1
if ta <= ao:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9136
s = str(input())
top = int(s[:2])
bottom = int(s[2:])

if 1 <= top <= 12 and 1 <= bottom <= 12:
    print('AMBIGUOUS')
elif top > 12 and bottom > 12:
    print('NA')
elif 1 <= top <= 12:
    print('MMYY')
elif 1 <= bottom <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;
ll pm(int n,int p){
    ll ret = 1;
    ll now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
ll C(int n, int k){
    ll ret = 1;
    for (int i = 1 ; i <= k ; i++) {
        ret *= n + 1 - i;
        ret %= mod;
        ret *= pm(i,mod-2);
        ret %= mod;
    }
    return ret;
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = ((pm(2,n) - C(n,a) - C(n,b) - 1) % mod + mod) % mod;
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int n, i;
  int sum = 0;
  
  scanf("%d", &n);
  
  int v[n];
  int c[n];
  
  for(i = 0; i < n; i++){
    scanf("%d", &v[i]);
  }
  for(i = 0; i < n; i++){
    scanf("%d", &c[i]);
  }
  
  for(i = 0; i < n; i++){
    if(v[i] - c[i] > 0){
      sum += v[i] - c[i];
    }
  }
  
  printf("%d\n", sum);
}
  

Measured memory_bytes: 128
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

vector<ll>inp[2000005];
ll vis[2000005];
ll color[2000005];

int main()
{
    int n,k;
    cin >> n >> k;
    map<int,int>mp;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>> d;
        while(d--)
        {
            int c;
            cin >> c;
            mp[c]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]==0)cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(){
  int n,m,i,ima,me;
  cin>>n>>m;
  if(n<=m){
    cout<<n;
    return 0;
  }
  char a[n+1];
  int s[n+1];
  for(i=0;i<n+1;i++){
    cin>>a[i];
    s[i]=0;
  }
  ima=n;
  for(i=0;;i++){
    for(me=m;me>=1;me--){
      if(a[ima-me]=='0'){
        ima-=me;
        s[i]=me;
        break;
      }
    }
    if(me==0){
      cout<<-1;
      return 0;
    }
    if(ima-m<=0){
      i++;
      s[i]=ima;
      break;
    }
  }
  for(;i>=0;i--){
    cout<<s[i]<<" ";
  }
}

Measured memory_bytes: 896
#include <stdio.h>

int leapyear(int y){
    if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)return 1;
        else return 0;
}

int main(void){
    int a,b,count,first=1;
    while(scanf("%d %d",&a,&b) != EOF && ( a != 0 || b != 0)){
        count=0;
        if(first == 0)printf("\n");
        for(int y = a;y <= b;y++){
            if(leapyear(y) == 1){
                printf("%d\n",y);
                count++;
            }
        }
        if(count == 0)printf("NA\n");
        first=0;
    }
    return 0;
}

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

namespace ABC160
{
    class D
    {
        static void Main(string[] args)
        {
            var nxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = nxy[0]; var x = nxy[1] - 1; var y = nxy[2] - 1;
            var dist1 = new long[n, n];
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    if (i != j)
                    {
                        dist1[i, j] = Math.Min(Math.Abs(j - i), Math.Abs(x - i) + 1 + Math.Abs(j - y));
                        dist1[i, j] = Math.Min(dist1[i, j], Math.Abs(y - i) + 1 + Math.Abs(j - x));
                    }
                }
            }

            /*
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    Console.Write(dist1[i, j]);
                }
                Console.WriteLine();
            }
            */

            var res = new long[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    res[dist1[i, j]]++;
                }
            }

            for (int i = 1; i < n; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}


Measured memory_bytes: 43356
#include<iostream>

int n, s;

int comb(int i, int sum, int c){
	if (i == 10){
		if (sum == s && c == n)return 1;
		else return 0;
	}

	return comb(i + 1, sum + i, c + 1) + comb(i + 1, sum, c);
}

int main(){
	while (std::cin >> n >> s, n || s){
		std::cout << comb(0, 0, 0) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
bool is_palindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return t == s;
}

int main() {
  string s;
  cin >> s;
  bool ans1 = is_palindrome(s);
  bool ans2 = is_palindrome(s.substr(0, s.length() / 2));
  bool ans;
  if(ans1 && ans2) ans =true;
  else ans = false;
  
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		String S = sc.next();
		int N = S.length();
		
		String firstHalf = S.substring(0, (N-1)/2);
		String secondHalf = S.substring((N+3)/2 - 1);
		
		// 結果の出力
		if (isPalindrome(S) && isPalindrome(firstHalf) && isPalindrome(secondHalf)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}		

		sc.close();
	}
	
	static boolean isPalindrome (String s) {
		int n = s.length();
		for (int i=0; i<n/2; i++) {
			if (s.charAt(i)!=s.charAt(n-i-1)) {return false;}
		}
		return true;
	}
}


Measured memory_bytes: 23764
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    long K = sc.nextLong();//next(文字列), nextDouble, nextLine(1行)とか
    int N = sc.nextInt();
    long[] S = new long[N];
    for (int i = 0; i < N;i++){
      S[i] = sc.nextLong();
    }
    long sum = 0;
    long max =0;
    for (int i = 0; i<N-1;i++){
      sum += S[i+1] - S[i];
      max = Math.max(max,(S[i+1]-S[i]));
    }
    sum += K-S[N-1]+S[0];
    max = Math.max(max,K-S[N-1]+S[0]);
    sum -= max;
    System.out.println(sum);      
  }    
}



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

int main()
{
	int N; cin >> N;
	//multiset<int> A;
	multiset<int, greater<int>> A;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		A.insert(a);
	}
	int a = 0, b = 0;
	//for (auto rit = A.rbegin(); rit != A.rend(); ++rit) {
	auto it = A.begin();
	for(;;){
		a += *it;
		it = A.erase(it);
		if (it == A.end()) break;
		b += *it;
		it = A.erase(it);
		if (it == A.end()) break;
	}
	cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){  
    int N;
    int a,b,c,d;
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>a>>b>>c>>d;
        int e=(a*c)+(b*d);
        e=min(e,4*(a*max(c,5)+b*max(2,d))/5);
        cout<<e<<endl;
        }
        return 0;
        }


Measured memory_bytes: 3104
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    int n;
    cin>>n;
    double a[100];
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=(double)1/a[i];
    }
    cout<<(double)1/sum<<endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

N = int(input())
a = list(map(int, input().split()))
flag = [0]*9
ans = 0
ans_max =0
for i in range(N):
    num = a[i]//400
    if num>=8:
        flag[8]+=1
    else:
        flag[num]=1
ans = sum(flag[:-1])
if ans == 0:
    ans =1
    ans_sum = flag[8]
else: 
    ans_sum= ans+flag[8]
    
print(ans, ans_sum)

Measured memory_bytes: 3064
use std::io::{Read, Write};

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    loop {
        let n: usize = it.next().unwrap().parse().unwrap();
        let m: usize = it.next().unwrap().parse().unwrap();
        if n == 0 {
            break;
        }
        let h: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
        let w: Vec<usize> = (0..m).map(|_| it.next().unwrap().parse().unwrap()).collect();
        let mut map = std::collections::BTreeMap::new();
        for i in 0..n {
            let mut sum = 0;
            for &h in &h[i..] {
                sum += h;
                *map.entry(sum).or_insert(0) += 1;
            }
        }
        let mut ans = 0;
        for i in 0..m {
            let mut sum = 0;
            for &h in &w[i..] {
                sum += h;
                match map.get(&sum) {
                    Some(&v) => ans += v,
                    _ => (),
                }
            }
        }
        writeln!(out, "{}", ans).ok();
    }
}

fn main() {
    run();
}



Measured memory_bytes: 11176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int abc(int, int, int, int);

int main(void) {

	int a, b, c, d, ans = 0;

	cin >> a >> b >> c;

	while (1) {
		d = max(a, b);
		d = max(d, c);
		if (abc(a, b, c, d) == 2) {
			if (min(a, b) == a) {
				if (min(b, c) == b) {
					a++;
					b++;
				}
				else {
					a++;
					c++;
				}
			}
			else {
				if (min(a, c) == a) {
					a++;
					b++;
				}
				else {
					b++;
					c++;
				}
			}
		}
		else if (abc(a, b, c, d) == 1) {
			if (min(a, b) == a) {
				if (min(a, c) == a)
					a += 2;
				else
					c += 2;
			}
			else {
				if (min(b, c) == c)
					c += 2;
				else
					b += 2;
			}
		}
		else
			break;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

int abc(int a, int b, int c, int d) {
	int sum = 0;
	if (d > a)
		sum++;
	if (d > b)
		sum++;
	if (d > c)
		sum++;

	return sum;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
    uint32_t a, b, c, x;
    std::cin >> a >> b >> c >> x;

    uint32_t sum = 0;
    for (int a_num = 0; a_num < a+1; a_num++) {
        for (int b_num = 0; b_num < b+1; b_num++) {
            for (int c_num = 0; c_num < c+1; c_num++) {
                if (500*a_num + 100*b_num + 50*c_num == x) {
                    sum++;
                }
            }
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def solve(c, s):
    if s == c * len(s):
        return 0
    t = ""
    for i in range(len(s) - 1):
        if s[i] == c or s[i + 1] == c:
            t += c
        else:
            t += s[i]
    return solve(c, t) + 1


def main():
    s = input()
    ans = INF
    for c in set(s):
        ans = min(ans, solve(c, s))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572