akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    string s=in<string>();
    REP(i,3){
        if(s[i]=='9'){
            s[i]='1';
        }else{
            s[i]='9';
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll N, A, B; cin >> N >> A >> B;
  if (A>B) swap(A,B);

  if ((B-A)%2==0) cout << (B-A)/2 << endl;
  else {
    if (A-1<=N-B) cout << A+(B-A-1)/2 << endl;
    else cout << N-B+1+(B-A-1)/2 << endl;
  }
  

  

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

satisfy = 0

for i in range(n):
  satisfy += b[a[i] - 1]
  if i == n-1:
    break
  if a[i+1] == a[i] + 1:
    satisfy += c[a[i] - 1]

print(satisfy)


Measured memory_bytes: 9004
#include <stdio.h>
int main()
{
	int i,a,b,c,z=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		
		if(c%i==0)
		{
			z++;
		}
	}
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2000
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::map<std::string, std::multimap<int, int, std::greater<int> > > map;
  std::string S;
  int P;
  int counter = 1;
  for (int i=0; i<N; i++){
    std::cin >> S;
    scanf("%d",&P);
    map[S].insert(std::make_pair(P,counter));
    counter++;
  }
  auto itr = map.begin();
  while(itr!=map.end()){
    //std::cout << "====-" << std::endl;
    //std::sort(itr->second.begin(), itr->second.end(), std::greater<int>() );
    for (auto const& entry: itr->second){
      std::cout << entry.second << std::endl;
    }
    itr++;
  }
  
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int N;
    cin >> N;
    int mx=0, count[N];
    fill(count, count+N, 0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        count[a]++;
        mx = max(mx, a);
    }

    bool ans = true;
    if (mx % 2 == 0) {
        if (count[mx/2] != 1) ans = false;
        for (int i = 0; i < mx; i++) {
            if (i < mx/2 && count[i] > 0) ans = false;
            if (i > mx/2 && count[i] < 2) ans = false;
        }
    } else {
        if (count[(mx+1)/2] != 2) ans = false;
        for (int i = 0; i < mx; i++) {
            if (i < (mx+1)/2 && count[i] > 0) ans = false;
            if (i > (mx+1)/2 && count[i] < 2) ans = false;
        }
    }

    if (ans) {
        cout << "Possible";
    } else {
        cout << "Impossible";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "math.h"
using namespace std;
int Debt = 100000;

void RoundUp(int& Integer, int Power)
{
	int Place = pow(10, Power);
	if(Integer % Place != 0){
		Integer = Place * (Integer / Place + 1);
	}
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		Debt *= 1.05;
		RoundUp(Debt, 3);
	}
	cout << Debt << endl;
	return 0;
}

Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    string p;
    cin >> p;
   
    for (int i = 0; i < p.size(); i++)cout << "x";
    cout << endl;

    return 0;

}

Measured memory_bytes: 256
s=int(input())
a=[s]
for i in range(1,1000001):
  if a[i-1]%2==0:
    if a[i-1]/2 in a:
      print(i+1)
      break
    else:
      a.append(a[i-1]/2)
  else:
    if (3*a[i-1]+1) in a:
      print(i+1)
      break
    else:
      a.append(3*a[i-1]+1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=10007;

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>>s(H+2,vector<char>(W+2));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>s[i][j];
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){ 
      if(s[i][j]=='#'){
        bool ok=true;
        if(s[i-1][j]=='#'){ok=false;}
        if(s[i+1][j]=='#'){ok=false;}
        if(s[i][j-1]=='#'){ok=false;}
        if(s[i][j+1]=='#'){ok=false;}
        if(ok){cout<<"No"<<endl;return 0;}
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;  
}

Measured memory_bytes: 3560
X, Y, A, B, C = map(int, input().split())

p = sorted(map(int, input().split()), reverse=True)[:X]
q = sorted(map(int, input().split()), reverse=True)[:Y]
r = list(map(int, input().split()))

apples = p + q + r
apples.sort(reverse=True)

print(sum(apples[: X + Y]))


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

using namespace std;

int main(){
    
    int res=0;
    
    string s;
    
    cin>>s;
    
    for(int i=0;i<s.size();i++)
        if(s[i]=='1') res++;
    
    
    cout<<res;
    
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  int tk = c/b + (c%b > 0);
  int ao = a/d + (a%d > 0);

  cerr << tk << " " << ao << endl;
  cout << (tk <= ao ? "Yes": "No") << endl;

  return 0;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  if(A>12){
    cout<<B<<endl;
  }
  else if(A>5){
    cout<<B/2<<endl;
  }
  else{
    cout<<0<<endl;
  }
  
    
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

int n, k;
int a[N], b[N];

void dfs(int nd, vector<int>&v) {
	v.pb(nd);
	if (v.front() != a[nd])
		dfs(a[nd], v);
}

void solve() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		cin >> b[i];

	int ma = -inf;
	for (int i = 1; i <= n; i++) {
		vector<int> v;
		dfs(i, v);
		int m = v.size();
		int cy = k / m;
		int rem = k % m;
		int ans = -inf, val1 = -inf, val2 = -inf;
		int tot = 0;
		for (int j = 1; j < m; j++) {
			tot += b[v[j]];
			val2 = max(val2, tot);
			if (j <= rem)
				val1 = max(val1, tot);
		}
		tot += b[v[0]];
		val2 = max(val2, tot);
		if (!cy)
			ans = val1;
		else
			ans = max({(cy * tot) + val1, ((cy - 1) * tot) + val2, val2});
		ma = max(ans, ma);
	}

	cout << ma << endl;

}

// you should probably see down .. believe me it would help
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 3972
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B; R(A,B);
    if(B%A==0)W(A+B);
    else W(B-A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    set<int> as;
    for(int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        as.insert(a);
    }
    if(as.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

map<pii,int> m1;
int solve(){
    cin>>n;
    rep(i,1,n){
        string s=to_string(i);
        m1[{s[0]-'0',s[sz(s)-1]-'0'}]++;
    }
    rep(i,1,9){
        rep(j,1,9){
            ans+=m1[{i,j}]*m1[{j,i}];
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


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


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int s,t;
    s = max(a,c);
    t = min(b,d);
    if(t-s < 0)cout << 0 << endl;
    else cout << t-s << endl;
}

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

int main() {
  int n;
  cin >> n;
  int d[n];
  rep(i,n) cin >> d[i];

  sort(d,d+n);

  int m = n/2;

  if(d[m-1]==d[m]){
      cout << 0 << endl;
  }

  else {
      cout << d[m]-d[m-1] << endl;
  }
}

Measured memory_bytes: 640
n = int(input())
A = [0]+list(map(int,input().split()))

d = {}

ans = 0
for i in range(1,n+1):
    if i+A[i] not in d:
        d[i+A[i]] = 1
    else:
        d[i+A[i]] += 1
    if i-A[i] in d:
        ans += d[i-A[i]]
        
print(ans)

Measured memory_bytes: 120588
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

long n, k;

long rec(long level, long step) {
  if (level == 0) return step > 0;
  
  const long total = (2ll << level) - 3;
  const long patty = (1ll << level) - 1;
  
  long sum = 0;
  if (step <= 1) return sum;
  --step;
  if (step <= total) return sum + rec(level - 1, step);
  step -= total;
  sum += patty;
  if (step <= 1) return sum + step;
  --step;
  ++sum;
  if (step <= total) return sum + rec(level - 1, step);
  sum += patty;
  step -= total;
  return sum;
}

int main() {
  cin >> n >> k;
  cout << rec(n, k) << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int x,p;
    cin>>x;
    for (int i=1;i<=9;++i)
       {
       	 p=i*111;
       	 if (x<=p)
       	   break;
	   }
	printf ("%d\n",p);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n,a,b; cin >> n >> a >> b;
  vector<ll> cnt(3,0);
  REP(i,n){
    ll p; cin >> p;
    if(p<=a) cnt[0]++;
    else if(p<=b) cnt[1]++;
    else cnt[2]++;
  }
  ll ans = 1e18;
  REP(i,3) ans = min(ans, cnt[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e10;
ll w[105], v[105];
ll dp[105][100005];
int main(){
	int n, W;
	cin >> n >> W;
	int w[105], v[105];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= sum; j++) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= sum; j++) {
			if (j >= v[i]) {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= sum; i++) {
		if (dp[n][i] <= W) {
			ans = i;
		}
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n,a,b;
cin >> n>>a>>b;
ans=min(b,a*n);

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


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

using namespace std;

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S[i] == T[i]) count++;
    
  }


  cout << count << endl;
 return 0;
}





Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int N;
int A[200001];
int E[400001], ne[400001], he[200001], it[200001];
int V[200001], v;
int S[200001], s;

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	S[s++] = 1;
	while (s) {
		int p = S[s - 1];
		if (p > 0) {
			S[s - 1] = -p;
			if (V[v - 1] < A[p]) {
				it[p] = v;
				swap(V[v++], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			else {
				it[p] = lower_bound(V, V + v, A[p]) - V;
				swap(V[it[p]], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			he[p] = -v;
		}
		else {
			s--;
			p = -p;
			V[it[p]] = A[p];
			v -= !A[p];
		}
	}

	rep1(i, N) putint(-he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 8668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll a,b;
  ll ans;
  cin>>a>>b;
  if(a>9 || b>9 )
    cout<<-1;
  else
    {
        ans=a*b;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	/** 入力数字の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			Set<Integer> set = new HashSet<>();
			IntStream.range(0, N).forEach(i -> set.add(scanner.nextInt()));
			System.out.println(set.size());
		}
	}
}


Measured memory_bytes: 36036
#include<iostream>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
int main() {
	long long int a, b;
	cin >> a >> b;
	cout << a*b/gcd(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
D,N = map(int,(input().split()))
l = [[] for _ in range(3)]
for i in range(1,1010001):
    c = 0
    j = i
    while j%100 == 0:
        c += 1
        j //= 100
    if c < 3:
        l[c].append(i)

print(l[D][N-1])

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

#define int long long
typedef vector<vector<int> > mat;
 
mat mul(mat A, mat B, int M){

    if(A[0].size() != B.size())return mat();
    int n = A.size(), m = B[0].size();
    mat C(n,vector<int> (m));
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            for(int k = 0; k < A[0].size(); k++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
            }
        }
    }
    return C;
}
 
mat pow(mat A, int n, int M){
    mat res(A.size(),vector<int> (A[0].size()));
    for(int i = 0; i < A.size(); i++) res[i][i] = 1;
    while(n > 0){
        if(n & 1) res = mul(res, A, M);
        A = mul(A, A, M);
        n >>= 1;
    }
    return res;
}

signed main(){

    int n; cin >> n;
    int k; cin >> k;
    int MOD = 1000000007;
    mat A(n, vector<int> (n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> A[i][j];
        }
    }

    mat dp(1, vector<int> (n, 1));

    A = pow(A, k, MOD);
    dp = mul(dp, A, MOD);
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += dp[0][i];
        ans %= MOD;
    }

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

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX=1e6;
int d[MAX];
int main()
{  int a,b,c,i;
  scanf("%d%d",&a,&b);
  for(i=0;i<b;i++)
  {
  	scanf("%d",&d[i]);
  	a-=d[i];
  	if(a<0)
  	break;
  }
  if(a<=0)
  printf("Yes\n");
  else
  printf("No\n");
  
    
 
	
}






















Measured memory_bytes: 512
#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)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#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 pll = pair<ll, ll>;
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 x;
  cin>>x;
  x-=400;
  COUT(8-(x/200));
}

Measured memory_bytes: 3628
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
using namespace std;


int main(){
    char c;
    queue<string> res;
    bool f = true;
    deque<int> deq;
    while(cin >> c){
        if(c == '.'){
            if(!deq.empty())f = false;
            deq.clear();
            res.push(f ? "yes" : "no");
            f = true;
        }
        
        if(c == '(')deq.push_back(1);
        if(c == '[')deq.push_back(2);
        if(f && c == ')'){
            if(deq.empty())f = false;
            if(f){
                int now = deq.back();
                deq.pop_back();
                if(now == 2)f = false;
            }
        }
        if(f && c == ']'){
            if(deq.empty())f = false;
            if(f){
                int now = deq.back();
                deq.pop_back();
                if(now == 1)f = false;
            }
        }
    }
    while(!res.empty()){
        string r = res.front();
        res.pop();
        if(res.empty())break;
        cout << r << endl;
    }
}


Measured memory_bytes: 3324
# coding: utf-8
class Case03

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  def read
    @n = gets.chomp.to_i
    @b = gets.chomp.split.map(&:to_i)
  end

  def solve
    @result = @b[0]
    2.upto(@n-1) do |i|
      @result += [@b[i-2], @b[i-1]].min
    end
    @result += @b[-1]
  end
  
  def output
    puts @result
  end

end

Case03.new.execute if $0 == __FILE__



Measured memory_bytes: 1788
word = input()
alphabet = [chr(i) for i in range(97,97+26)]

none_alpha = ["None"]

for i in range(26):
    if alphabet[i] in none_alpha:
        continue;
    a = word.find(alphabet[i])
    if a == -1:
        if "None" in none_alpha:
            none_alpha.remove("None")
        none_alpha.append(alphabet[i])

print(none_alpha[0])

Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

typedef complex<double> P;

void koch(int n, P p1, P p2)
{
    if (n == 0)
        return;

    P s = p1 + (p2 - p1) / 3.0;
    P t = p1 + (p2 - p1) / 3.0 * 2.0;
    P u = s + (t - s) * polar(1.0, M_PI * 1 / 3);
    koch(n - 1, p1, s);
    printf("%.8f %.8f\n", s.real(), s.imag());
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.real(), u.imag());
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.real(), t.imag());
    koch(n - 1, t, p2);
}

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

    printf("%.8f %.8f\n", 0., 0.);
    koch(n, P(0, 0), P(100, 0));
    printf("%.8f %.8f\n", 100., 0.);

    return 0;
}

Measured memory_bytes: 1072
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    int dx = tx - sx, dy = ty - sy;
    cout << "D" << string(dx+1, 'R') << string(dy+1, 'U') << string(dx+1, 'L') << string(dy, 'D');
    cout << "L" << string(dy+1, 'U') << string(dx+1, 'R') << string(dy+1, 'D') << string(dx, 'L') << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

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

    // kが少ない
    if(k<a+1){
        cout << 1+k << endl;
        return 0;
    }
    
    ll sum=0;
    if((b-1)>=(a+1)){
        sum+=b;
        k-=(a+1);

        if(k%2==0){
            sum+=b*(k/2)-a*(k/2);
            cout << sum << endl;
        }
        else{
            k--;
            sum+=b*(k/2)-a*(k/2);
            cout << sum+1 << endl;
        }
    }
    else{
        // +1し続ける
        cout << 1+k << endl;
        return 0;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll MOD=1e9+7;
vector<vector<ll>> adj(100005);
ll mem[100005][30];
string s;

ll solve(ll cur,ll rem){
    if(cur==s.size()){
        if(rem==5){
            return 1;
        }
        return 0;
    }
    if(mem[cur][rem]!=-1){
        return mem[cur][rem];
    }
    ll ret=0;
    for(int i=0;i<adj[cur].size();i++){
       ret+=solve(cur+1,(rem+adj[cur][i])%13);
       ret%=MOD;
    }
    return mem[cur][rem]=ret%MOD;
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("maxflow.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>s;
    ll cur=1;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='?'){
            for(int j=0;j<=9;j++){
                ll c=j*cur;
                adj[i].push_back(c%13);
            }
        }
        else{
            stringstream ss;
            ll k;
            ss<<s[i];
            ss>>k;
            k*=cur;
            adj[i].push_back(k%13);
        }
        cur*=10;
        cur%=13;
    }
    cout<<solve(0,0)<<endl;
    return 0;
}

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

int main() {
    int N;
    cin>>N;
    int a;
    int b;
    if(N%2==0)
    {
      a=N/2;
      cout<<a*a<<endl;
    }
    else
    {
      a=(N-1)/2;
      b=a+1;
      cout<<a*b<<endl;
    }
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	map<string,priority_queue<int,vector<int>,greater<int> > > latte;
	string S;
	int P;
	while(cin>>S>>P){
		latte[S].push(P);
	}
	map<string,priority_queue<int,vector<int>,greater<int> > >::iterator itr = latte.begin();
	while(itr!=latte.end()){
		cout<<itr->first<<endl;
		printf("%d",itr->second.top()); itr->second.pop();
		while(!itr->second.empty()){
			printf(" %d",itr->second.top()); itr->second.pop();
		}puts("");
		itr++;
	}
}

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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
ans = num2alpha(n)
print(ans.lower())

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

bitset<100005> diff[31];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, c, s, t, a; cin >> n >> c;

    for(int i = 0; i < n; ++i){
        cin >> s >> t >> a;
        --a;
        diff[a][max(1, s - 1)] = diff[a][max(1, s - 1)] ^ 1;
        diff[a][t] = diff[a][t] ^ 1;
    }

    int best = 0;

    for(int j = 1; j < 100001; ++j){
        int cur = 0;
        for(int i = 0; i < c; ++i){
            diff[i][j] = diff[i][j] ^ diff[i][j - 1];
            if(diff[i][j])
                ++cur;
        }
        best = max(best, cur);
    }

    cout << best << "\n";

    return 0;

}


Measured memory_bytes: 640
//Small, Large, or Equal
import java.util.Scanner;

class Main {
    public void cubic() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String out = "a > b";
        if (a == b ) {
            out = "a == b";
        }else if(a < b) {
            out = "a < b";
        }


                                        
        System.out.println(out);
    }
    
    public static void main(String[] args){
    new Main().cubic();
    }
}

Measured memory_bytes: 17324
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<string.h>
#define fornt(k,n) for(int i=k; i<n; ++i)
#define fornt2(p,n) for(int j=p; j<n; ++j)
#define pb push_back
#define ll long long
#define sc(n) scanf("%d",&n)
#define sc2(x,y) scanf("%d %d",&x,&y)
#define scl(n) scanf("%lld",&n)
#define scl2(x,y) scanf("%lld %lld",&x,&y)
#define pr(n) printf("%d\n",n)
#define prl(n) printf("%lld\n",n)
#define pry printf("YES\n")
#define prn printf("NO\n")
using namespace std;

int main ()
{
   ll n;
   scl(n);
   string s;
   while(n)
   {
       s += (char)('a'+((n-1)%26));
       if(n%26!=0)
         n /= 26;
       else
       {
           n /= 26;
           n--;
       }
   }
   reverse(s.begin(),s.end());
   cout<<s<<endl;
}

Measured memory_bytes: 3192
import numpy as np

A,B,H,M = list(map(int,input().split()))

alpha = 2 * np.pi * (H/12 + M/(60*12))
beta = 2 * np.pi * M/60

print(((A * np.cos(alpha) - B * np.cos(beta))**2 + (A * np.sin(alpha) - B * np.sin(beta))**2)**0.5)

Measured memory_bytes: 27204
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

class DisjointSet{
    public:
    vector<ll> rank,p,sz;
    DisjointSet(){}
    DisjointSet(ll size){ //作られうる木の頂点数の最大値を入れる。
        rank.resize(size,0);
        p.resize(size,0);
        sz.resize(size,0);
        rep(i,size) makeSet(i);
    }
    void makeSet(ll x){ //xだけが属する木を作る。
        p[x]=x;
        rank[x]=0;
        sz[x]=1;
    }
    bool same(ll x,ll y){ //xとyが同じ木に属するかどうか
        return findSet(x)==findSet(y);
    }
    void unite(ll x, ll y){
        link(findSet(x),findSet(y));
    }
    void link(ll x, ll y){ //rankが大きい方の根に小さい方の根をつける。
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++; //xとyの木のrankが同じであれば、統合するとrankが1増える。
            }
        }
        ll totalSize=sz[x]+sz[y];
        sz[x]=totalSize;
        sz[y]=totalSize;
    }
    ll findSet(ll x){ //xが属する木の根の番号を返す
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};


int main()
{
    ll n,m,k;
    cin >> n >> m >> k;
    
    vector<ll> ans(n);
    DisjointSet ds=DisjointSet(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        ans[a]--;
        ans[b]--;
        if(!ds.same(a,b)) ds.unite(a,b);
    }
    rep(i,n){
        //cout << ans[i] << endl;
    }
    rep(i,k){
        ll c,d;
        cin >> c >> d;
        c--;
        d--;
        if(ds.same(c,d)){
            ans[c]--;
            ans[d]--;
        }
    }
    rep(i,n){
        //cout << ds.sz[ds.p[i]] << endl;
    }
    rep(i,n){
        ans[i]+=ds.sz[ds.findSet(i)]-1;
        if(i) cout << " ";
        cout << ans[i];
    }
    
    return 0;
} 

Measured memory_bytes: 3968
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i] == '9') cout << 1;
        else cout << 9;
    }   
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] = (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])



Measured memory_bytes: 52572
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;

struct edge{int to;ll dist;};
using Graph=vector<vector<edge>>;
Graph G(0);
ll INF=pow(10,17);
vec x;
int b;

void dfs(int s){
    for(auto next_s:G[s]){
        if(x[next_s.to]!=INF){
            if(x[next_s.to]!=x[s]+next_s.dist){
                b=0;
                return;
            }
            else continue;
        }

        x[next_s.to]=x[s]+next_s.dist;
        dfs(next_s.to);
    }
    return;
}

int main(){
    int n,M;cin>>n>>M;
    const int N=n;
    G.resize(N+10);
    x.resize(N+10,INF);
    int L,R;
    ll D;
    for(int i=0;i<M;i++){
        cin>>L>>R>>D;
        L--;R--;
        G[L].push_back((edge){R,D});
        G[R].push_back((edge){L,-D});
    }
    
    for(int i=0;i<N;i++){
        if(x[i]==INF){
            b=1;
            x[i]=0;
            dfs(i);
            if(b==0){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

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

    int cnt[101]={0};
    for(int i=0;i<N;i++){
        cnt[v.at(i)]++;
    }

    int ans=0;
    for(int i=0;i<101;i++){
        if(cnt[i]>0) ans++;
    }
    
    cout << ans << endl;

}

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

using namespace std;

typedef long long ll;


const int INF = 1e9;
const ll MOD = 1e9 + 7;  

int main(){
    int N;
    string s;
    cin >> N >> s;
    string check = string();
    for(int i = 0 ; i < N; i++) check += '0';
    int i = 0;
    for(int k = 0; k < N; k++){
        if(check[i] == '1') {
            i++;
            continue;
        }
        if(s[i] == '('){
            bool flag = true;
            for(int j = i+1; j < s.length(); j++){
                if(s[j] == ')' && check[j] == '0'){
                    check[j] = '1';
                    check[i] = '1';
                    flag = false;
                    break;
                }
            }
            if(flag){
                check[i] = '1';
                check += '1';
                s += ')';
            }
        }
        else if(s[i] == ')'){
            bool flag = true;
            for(int j = i-1; j >= 0; j--){
                if(s[j] == '(' && check[j] == '0'){
                    check[j] = '1';
                    check[i] = '1';
                    flag = false;
                    break;
                }
            }
            if(flag){
                check[i] = '1';
                check = '1' + check;
                s = '(' + s;
                i++;
            }
        }
        i++;
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	N := 2019
	s := reverse(scanText())
	m := map[int]int{}
	total := 0
	d := 1
	m[0] = 1
	for _, c := range s {
		n, _ := strconv.Atoi(string(c))
		total += n * d
		total %= 2019
		d = (d * 10) % N
		m[total]++
	}
	sum := 0
	for _, v := range m {
		sum += v * (v - 1) / 2
	}
	fmt.Println(sum)
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void) {
    long long num,data[4001],i,j,employee[4001],price,amount,flag,sp;
    while (1) {
        scanf("%lld\n",&num);
        if (num==0) break;
        for (i=1;i<=4000;i++) data[i]=0;
        flag=0;
        sp=0;
        for (i=0;i<num;i++) {
            scanf("%lld %lld %lld\n",&employee[sp],&price,&amount);
            data[employee[sp]]+=price*amount;
            if (data[employee[sp]]>=1000000) flag=1;
            for (j=0; j<sp; j++) {
                if (employee[sp]==employee[j]) {
                	sp--;
                	break;
                }
            }
            sp++;
        }
        if (flag==0) {
            printf("NA\n");
        } else {
            for (i=0; i<sp; i++) {
                if (data[employee[i]]>=1000000) printf("%lld\n",employee[i]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 660
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 0L;
            var switches = new int[nm[1]][];
            for (var i = 0; i < switches.Length; i++)
            {
                switches[i] = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x) - 1).ToArray();
            }
            var p = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

            for (var bit = 0; bit < (1 << nm[0]); bit++)
            {
                var isValid = true;
                for (var j = 0; j < switches.Length; j++)
                {
                    var tmp = 0;
                    var lights = switches[j];
                    for (var k = 1; k < lights.Length; k++)
                    {
                        if (((bit >> lights[k]) & 1) == 1) tmp++;
                    }
                    if (tmp % 2 != p[j]) isValid = false;
                }
                if (isValid) count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
import java.io.*;
import java.util.*;
 
public class Main {
	static final Reader in = new Reader();
	
	public static void main(String[] args) {
		int n=in.nextInt(), m=in.nextInt();
		char[] s = in.next().toCharArray();
		for(int i=0; i<n; ++i)
			s[i]-='A';
		List<Integer>[] adj = new List[n];
		for(int i=0; i<n; ++i)
			adj[i]=new ArrayList<Integer>();
		int[][] d = new int[n][2];
		for(int i=0; i<m; ++i) {
			int u=in.nextInt()-1, v=in.nextInt()-1;
			adj[u].add(v);
			adj[v].add(u);
			++d[u][s[v]];
			++d[v][s[u]];
		}
		boolean[] g = new boolean[n];
		int[] qu = new int[n];
		int qt=0;
		for(int i=0; i<n; ++i) {
			if(d[i][0]<=0||d[i][1]<=0) {
				g[i]=true;
				qu[qt++]=i;
			}
		}
		for(int qh=0; qh<n; ++qh) {
			if(qh>=qt) {
				System.out.println("Yes");
				return;
			}
			int u=qu[qh];
			for(int v : adj[u]) {
				if(g[v])
					continue;
				--d[v][s[u]];
				if(d[v][s[u]]<=0) {
					g[v]=true;
					qu[qt++]=v;
				}
			}
		}
		System.out.println("No");
	}
	
	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 82244