akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, m, a, b, c, res = 0;
    priority_queue<int> q;
    priority_queue<pair<int, int>> qq;
    cin>>n>>m;
    rep(i, n) {
        cin>>a;
        q.push(-a);
    }
    rep(i, m) {
        cin>>b>>c;
        qq.push({c, b});
    }
    while(!q.empty() && !qq.empty()) {
        auto p = qq.top(); qq.pop();
        res += max(-q.top(), p.first);
        q.pop();
        p.second--;
        if(p.second > 0) qq.push(p);
    }
    while(!q.empty()) res -= q.top(), q.pop();
    cout<<res<<endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

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

	ll n,t;
	cin>>n>>t;
	map<ll,ll> m;
	ll small=1000000000;
	for(int i=0;i<n;i++)
	{
		int r;
		cin>>r;
		if(r<small)
		{
			small=r;
		}
		else
		{
			m[r-small]++;
		}
	}
	cout<<m.rbegin()->second<<'\n';
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
string s;
cin>>s;
int l,r;
l=0;r=s.size()-1;
int br=0;
while(l<r)
{
    if(s[l]!=s[r] && s[l]!='x' && s[r]!='x')
    {
        cout<<-1<<endl;
        return 0;
    }
    if(s[l]==s[r])
    {
        l++;
        r--;
        continue;
    }
    if(s[l]=='x')
    {
        l++;
        br++;
        continue;
    }
    if(s[r]=='x')
    {
        r--;
        br++;
        continue;
    }
}

cout<<br<<endl;
return 0;
}


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

#define PIAR pair<int, int>
int field[52][52];
int dx[] = {-1,  0, 1, 0, -1,  1, 1, -1};
int dy[] = {0 , -1, 0, 1, -1, -1, 1,  1};

void dfs(int x, int y){
	field[x][y] = 0;
	for(int i = 0; i < 8; i++){
		int nextX = x + dx[i];
		int nextY = y + dy[i];
		if(field[nextX][nextY] == 1) dfs(nextX, nextY);
	}
}

int main(){
    int w, h;
    while(cin >> w >> h, w != 0 && h != 0){
    	for(int i = 0; i < 52; i++){
    		for(int j = 0; j < 52; j++){
    			field[i][j] = 0;
    		}
    	}

        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                cin >> field[i][j];
            }
        }

        int island = 0;
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                //島を探す
                if(field[i][j] == 1){
                	dfs(i, j);
                    island++;
                }

            }
        }

        cout << island << endl;
    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        string s=to_string(i);
        if(s.size()%2==1) ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int n; cin >> n;
  int tmp = 0;
  int ans = 0;
  REP(i,n){
    cin >> tmp;
    if(tmp %2 != 0){
      ans ++;
    }
  }
  if(ans %2 != 0){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


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

int main() {
	string S,T;
	cin >> S >> T;
  cout << T + S << endl;
}

Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 51;
vector<int> adj[N];
int visit[N];
int low[N],tin[N];
int timer = 0;
int ans = 0;
void dfs(int src,int p=-1)
{
    tin[src] = low[src] = timer++;
    visit[src] = 1;
    for(auto it:adj[src])
    {
        if(it == p)
            continue;
        if(visit[it])
            low[src] = min(low[src],tin[it]);
        else
        {
            dfs(it,src);
            low[src] = min(low[src],low[it]);
            if(low[it]>tin[src])
                ans++;
        }
    }
}
signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,-1);
    cout<<ans;
}

Measured memory_bytes: 256
# A - Rainy Season

S = str(input())

if S == 'RRR':
    print(3)
elif S == 'SRR' or S == 'RRS':
    print(2)
elif S == 'SSR' or S == 'SRS' or S == 'RSS' or S == 'RSR':
    print(1)
else:
    print(0)

Measured memory_bytes: 8980
#include<iostream>
#include<algorithm>
#include<complex>
#include<vector>
#include<cmath>
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define NEXT(i,n)  ((i+1)%(n))
#define mp         make_pair
#define pb         push_back
using namespace std;

typedef complex<double> P;

const double pi = acos(-1);

pair<double,double> check(double dx,double dy,double rx,double ry,double r,
			  bool &flag){
  double a=(dx*dx+dy*dy),b=-2*rx*dx-2*ry*dy,c=rx*rx+ry*ry-r*r;
  double D=b*b-4*a*c;
  if (D < 0)return mp(-1,-1);
  flag=true;
  return mp((-b-sqrt(D))/(2*a),(-b+sqrt(D))/(2*a));
}

inline P getnorm(P a){
  return a/abs(a);
}

bool isp(P a,P b,P c){
  return abs(a-c)+abs(b-c) < abs(a-b)+1e-10;
}


void getdata(vector<P> &p,vector<P> &e,vector<double> &a,bool flag){
  rep(i,p.size()){
    double r = abs(p[i]);
    double ori=arg(p[i]);
    rep(j,e.size()){
      bool cansolve=false;
      P norm=getnorm(e[NEXT(j,e.size())]-e[j]);
      pair<double,double> tmp=check(norm.real(),norm.imag(),-e[j].real(),-e[j].imag(),r,cansolve);
      if (!cansolve)continue;
      rep(k,2){
	P point=e[j]+tmp.first*norm;
	if (isp(e[j],e[NEXT(j,e.size())],point)){
	  double t = arg(point);
	  if (flag){
	    if (t <ori)t+=2*pi;
	    a.pb(t-ori);
	  }else {
	    if (ori < t)t-=2*pi;
	    a.pb(ori-t);
	  }
	}
	swap(tmp.first,tmp.second);
      }
    }
  }
}

double solve(vector<P> &p,vector<P> &e){//cx,cy=0,0
  vector<double> a;
  a.pb(2*pi);
  getdata(p,e,a,true);
  getdata(e,p,a,false);
  sort(a.begin(),a.end());
  return a[0]*180/pi;
}


main(){
  int n,m;
  while(cin>>n>>m && n){
    vector<P> e(n),p(m);
    rep(i,e.size()){
      double x,y;cin>>x>>y;e[i]=P(x,y);
    }
    rep(i,p.size()){
      double x,y;cin>>x>>y;p[i]=P(x,y);
    }
    double cx,cy;
    cin>>cx>>cy;
    P minus=P(cx,cy);
    rep(i,e.size())e[i]-=minus;
    rep(i,p.size())p[i]-=minus;
    printf("%.7lf\n",solve(p,e));
  }

}

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

int N, M;
int sum[10010], dis[10010];

int main()
{
    while(cin >> N >> M, N)
    {
        for(int i = 0; i < N; i++)sum[i] = dis[i] = 0;
        for(int i = 0; i < M; i++)
        {
            int s,k;
            cin >> s >> k;
            for(int j = 0; j < k; j++)
            {
                int c;
                cin >> c;
                c--;
                sum[c] += s;
                if(k == 1)dis[c] += s;
            }
        }

        int MAX = 0;
        int MAX_index = 0;
        for(int i = 0; i < N; i++)
        {
            if(MAX < sum[i])
            {
                MAX = sum[i];
                MAX_index = i;
            }
        }
        sum[MAX_index] = -1;

        int second_MAX = 0;
        for(int i = 0; i < N; i++)
        {
            second_MAX = max(second_MAX, sum[i]);
        }

        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            ans = max(ans, ((i == MAX_index) ? second_MAX : MAX) - dis[i]);
        }

        cout << ans + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3180
import itertools
S=list(input())
l=['-','+']
L=list(itertools.product(l,repeat=len(S)-1))
ans=0
for i in range(2**(len(S)-1)):
    a = S[0]
    for j in range(len(S)-1):
        a+=L[i][j]+S[j+1]
    if eval(a)==7:
        print(a+'=7')
        break

Measured memory_bytes: 3060
s = input()
t = input()

#辞書順
s = sorted(s)
t = sorted(t)

#逆順処理
t = t[::-1]

#文字数記憶
sf = len(s)
tf = len(t)

#判定
flag = 0

i = 0

while sf>0 and tf>0:
    if s[i] < t[i]:
        print('Yes')
        flag += 1
        break
    elif s[i] > t[i]:
        print('No')
        flag += 1
        break
    elif s[i] == t[i]:
        sf -= 1
        tf -= 1
        i += 1

if flag == 0:
    if len(s) < len(t):
        print('Yes')
    else:
        print('No')
        


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

#define F(i,a,b) for(int i=(a);i<=(b);++i)

char s[22];
LL p[22];
int n;
LL ans;

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%s",s);
	n = strlen(s);
	ans = 0;
	p[0] = p[1] = 1;
	F(i,2,21) p[i] = p[i-1]*2;
	F(l,0,n-1)
		F(i,0,n-l-1)
		{
			int j = i + l;
			LL cur = 0;
			for(int k=i;k<=j;++k) cur = cur*10 + s[k] - '0';
			ans += cur * p[i]*p[n-j-1];
		//	printf("%lld %lld %lld\n",cur,p[i],p[n-j-1]);
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    // input
    int m, f, r;
    int scores[50];
    int idx_scores = 0;
    do {
        cin >> m >> f >> r;

        // value check
        if( m > 50 || f > 50 || r > 100 ) {
            cout << "data err!";
        }

        // A B C D E F
        // 0 1 2 3 4 5
        if( m == -1 || f == -1 ) {
            scores[idx_scores] = 5;
        } else if( m + f >= 80 ) {
            scores[idx_scores] = 0;
        } else if( m + f >= 65 && m + f < 80 ) {
            scores[idx_scores] = 1;
        } else if( m + f >= 50 && m + f < 65 ) {
            scores[idx_scores] = 2;
        } else if( m + f >= 30 && m + f < 50  ) {
            if(r >= 50) {
                scores[idx_scores] = 2;
            } else {
                scores[idx_scores] = 3;
            }
        } else if( m + f < 30 ) {
            scores[idx_scores] = 5;
        }

        idx_scores += 1;
    } while( !(m == -1 && f == -1 && r == -1) );

    // output
    // output 1line/person
    for( int i=0; i<idx_scores-1; i++ ) {
        switch( scores[i] ) {
            case 0:
                cout << "A" << endl;
                break;
            case 1:
                cout << "B" << endl;
                break;
            case 2:
                cout << "C" << endl;
                break;
            case 3:
                cout << "D" << endl;
                break;
            case 4:
                cout << "E" << endl;
                break;
            case 5:
                cout << "F" << endl;
                break;
            //default:
                // nothing
        }
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(x) for(int i=0;i<x;i++)
#define reprev(x) for(int i=x-1;i>=0;i--)
#define repdef(x,n) for(int i=x;i<n;i++)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define TEST(t) while(t--)
#define mod 1000000007
#define MAX 1000005
int fast_exp(ll base,ll exp){
    if(exp==1){
        return base%mod;
    }
    if(exp&1){
        int ans=fast_exp(base,exp-1);
        return (base%mod*ans%mod)%mod;
    }else{
        int ans=fast_exp(base,exp/2);
        return (ans%mod*ans%mod)%mod;
    }
}
int fast_exp_itr(ll base,ll exp,ll p){
    ll ans=1;
    base=base%p;
    while(exp>0){
        if(exp&1){
            ans=((ans%p)*(base%p))%p;
        }
        exp>>=1;
        base=((base%p)*(base%p))%p;
    }
    return ans;
}
ll euclid_gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return euclid_gcd(b,a%b);
}
vector<ll>primes;
bool arr[MAX];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(arr,true,sizeof(arr));
    arr[0]=arr[1]=false;
    primes.clear();
    for(ll i=2;i<MAX;i++){
    	if(arr[i]){
    		primes.push_back(i);
    		for(ll j=i*i;j<MAX;j+=i){
    			arr[j]=false;
    		}
    	}
    }
    ll a,b;
    cin>>a>>b;
  ll g=__gcd(a,b);
    //ll g=euclid_gcd(max(a,b),min(a,b));
    ll count=1;
    for(auto i:primes){
    	if(g%i==0){
    		count++;
    	}
    	while(g%i==0){
    		g/=i;
    	}
    }
    if(g!=1){
    	count++;
    }
    cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 2424
#include <stdio.h>

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

	int ans[4] = {0};
	char c[4];
	while (n--) {
		scanf("%s", c);
		switch (c[0]) {
		case 'A':
			ans[0]++;
			break;
		case 'W':
			ans[1]++;
			break;
		case 'T':
			ans[2]++;
			break;
		case 'R':
			ans[3]++;
			break;
		}
	}

	printf("AC x %d\n", ans[0]);
	printf("WA x %d\n", ans[1]);
	printf("TLE x %d\n", ans[2]);
	printf("RE x %d\n", ans[3]);
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  long long n, m;
  cin >> n >> m;

  vector<pair<long long, long long>> vab(n);
  for (auto &p : vab) {
    cin >> p.first >> p.second;
  }

  sort(vab.begin(), vab.end());
  long long ans = 0, cur = 0;
  while (m > 0) {
    long long cnt = min(m, vab[cur].second);
    ans += vab[cur].first * cnt;
    m -= cnt;
    cur++;
  }

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


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

bool make_line(int first, int last);
void output_ans(void);

int ans[100002];	// S = 1, W = -1
int N;
string s;

int main(void) {
	cin >> N;
	cin >> s;

	if (make_line(+1, +1)) {output_ans(); return 0;}
	if (make_line(+1, -1)) {output_ans(); return 0;}
	if (make_line(-1, +1)) {output_ans(); return 0;}
	if (make_line(-1, -1)) {output_ans(); return 0;}

	cout << -1 << endl;
	return 0;
}

bool make_line(int first, int last) {
	for (int i = 0; i <= N+1; i++) ans[i] = 0;

	ans[1] = ans[N+1] = first;
	ans[0] = ans[N] = last;

	for (int i = 1; i <= N; i++) {
		char rep = s[i-1];
		if ((ans[i] == 1 && rep == 'o') || (ans[i] == -1 && rep == 'x')) {
			if (ans[i+1] == 0) ans[i+1] = ans[i-1];
			if (ans[i+1] != ans[i-1]) return false;

		} else {
			if (ans[i+1] == 0) ans[i+1] = -ans[i-1];
			if (ans[i+1] == ans[i-1]) return false;
		}
	}
	return true;
}

void output_ans(void) {
	for (int i = 1; i <= N; i++) {
		if (ans[i] == 1) cout << 'S';
		else cout << 'W';
	}
	cout << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=998244353;
int x[2005],y[2005],tw[2100],n,num,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	tw[0]=1;
	for(int i=1;i<=2000;i++)
		tw[i]=(tw[i-1]<<1)%mod;
	ans=tw[n]-n-1;
	//cout<<tw[n]<<endl;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			num=0;
			for(int k=j+1;k<=n;k++)
				if((x[j]-x[i])*(y[k]-y[j])==(x[k]-x[j])*(y[j]-y[i]))
					num++;
			ans=(ans-tw[num]+mod)%mod;
		//	cout<<i<<" "<<j<<" "<<ans<<endl;
		}
	//ans-=(n+1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
//MACROS
#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F
#define MAX 1001
#define MOD 1000000007
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_multiset<int> usmi;

int main() {
    string s; cin >> s;
    if (s[sz(s) - 1] == 's') s += "es";
    else s += 's';
    cout << s << endl;
}

Measured memory_bytes: 3132
/*	author:  Kite_kuma
	created: 2020.09.09 11:36:34 */

#include <iostream>
using namespace std;

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
struct iofast {
	iofast() {
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
	}
} iofast_;
int res;
int a[200000], b[200000];
int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++) res ^= (a[i] + b[j]);
	cout << res << "\n";
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,k){
    int m;
    cin >> m;
    rep(j,m){
      int a;
      cin >> a;
      d[a-1] = 1;
    }
  }
  int ans = 0;
  rep(i,n) if(d[i] == 0) ans++;
  cout << ans << endl;



}


Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
//using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 10*9+7

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int x,y,z;
  cin >> x >> y >>z;
  swap(x,y);
  swap(x,z);
  cout<< x <<" "<< y <<" "<<z<<endl;

}


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

int main() {
  int n,l;
  cin >> n >> l;
  vector<string> S(n);
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  sort(S.begin(),S.end());
  for(int i=1;i<n;i++){
  S[0].append(S[i]);
  }
  cout << S[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll n,ans;
 	cin>>n;
 	ans=power(10,n,M);
 	ans%=M;
 	ll z=power(9,n,M);
 	z%=M;
 	z*=2;
 	z%=M;
 	z-=power(8,n,M);
 	z+=M;
 	z%=M;
 	ans-=z;
 	ans+=M;
 	ans%=M;
 	cout<<ans;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TES/TS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    int s=a+b+c;

    set<tuple<int,int,int>>mem;
    rep(i,1000){
        if(mem.find(make_tuple(a,b,c))!=mem.end()){
            cout<<-1<<endl;
            break;
        }
        mem.insert(make_tuple(a,b,c));
        if(a%2||b%2||c%2){
            cout<<i<<endl;
            break;
        }
        a=(s-a)/2;
        b=(s-b)/2;
        c=(s-c)/2;
    }

}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int n, m;
	cin >> n >> m;
	const int nmax = 50;
	char a[nmax][nmax], b[nmax][nmax];

	rep(y, n) {
		rep(x, n) {
			cin >> a[y][x];
		}
	}

	rep(y, m) {
		rep(x, m) {
			cin >> b[y][x];
		}
	}

	bool exist = false;

	rep(ly, n) {
		rep(lx, n) {
			if (ly + m - 1 >= n || lx + m - 1 >= n) continue;

			bool match = true;
			rep(y, m) {
				rep(x, m) {
					if (a[ly + y][lx + x] != b[y][x]) match = false;
				}
			}
			if (match) exist = true;
		}
	}

	if (exist)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;

}

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

int main() {
  int a,b;
  cin >> a >> b;
  if ( b==1){
    cout << 0 << endl;
  return 0 ;
  }
  int sum=a ;
    int ans = 1 ;
  for ( ; ; ans++){
    if (sum < b){
      sum+= a-1 ;
    }else break;
   }
  cout << ans << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	int cnt[3] = {};
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		int e = 0;
		while (a % 2 == 0) {
			a /= 2;
			e++;
		}
		e = min(e, 2);
		cnt[e]++;
	}

	cout << ((cnt[2] + (cnt[1] == 0) >= cnt[0]) ? "Yes" : "No") << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    long long x, k, d;
    cin >> x >> k >> d;

    long long minCnt = 0;
    long long minP = min(abs(x%d + d), abs(x%d - d));
    if (abs(x%d) <= minP) minCnt = abs(x/d);
    else minCnt = abs(x/d) + 1; 

    if (minCnt >= k) {
        long long move = d * k;
        if (x >= 0) x -= move;
        else x += move;
    } else {
        long long move = d * minCnt;
        if (x >= 0) x -= move;
        else x += move;

        if ((k-minCnt) % 2 != 0) {
            if (x >= 0) x -= d;
            else x += d;
        }
    }

    cout << abs(x) << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#define maxn 100010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int f[maxn];
void dfs(int x,int las)
{
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        dfs(to[i],x);
    }
    priority_queue<int>q;
    for(int i=head[x];i;i=nxt[i]){
        if(to[i]==las)  continue;
        q.push(f[to[i]]);
    }
    if(q.size()==0)  return;
    int now=0;
    while(q.size())
    {
        int tmp=q.top();
        q.pop();
        now++;
        f[x]=max(f[x],tmp+now);
    }
}
int main()
{
    n=read();
    for(int i=2;i<=n;i++)
    {
        int x=read();
        add(i,x);
        add(x,i);
    }
    dfs(1,0);
    printf("%d\n",f[1]);
    return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String a = input.next();
		String b = input.next();
		String c = input.next();

		int ai = Integer.parseInt(a);
		int bi = Integer.parseInt(b);
		int ci = Integer.parseInt(c);

		if(ai < bi && bi < ci){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}
	}
}

Measured memory_bytes: 26296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		for (int i = 1; i <= 3; i++) {
			if(i!=a && i!=b) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 23636
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[II()-1])

main()

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

public class Main {
  public static void main(String[] arg) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    for(int i=n; i>0; i=i-1) {
      if(Math.sqrt(i)==(int)Math.sqrt(i)) {
        System.out.println(i);
        break;
      }
    }
  }
}
   

Measured memory_bytes: 32544
s = input()

s = list(s)
sowth = s.count('S') if 'S' in s else 0
east  = s.count('E') if 'E' in s else 0
north = s.count('N') if 'N' in s else 0
west  = s.count('W') if 'W' in s else 0

if (west != 0 and east != 0 and sowth == 0 and north == 0) or\
    (sowth != 0 and north != 0 and west == 0 and east == 0) or\
    (sowth != 0 and north != 0 and west != 0 and east != 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8860
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> edges(n);

    int f, t;
    while (std::cin >> f >> t)
    {
        edges[f-1].emplace_back(t-1);
        edges[t-1].emplace_back(f-1);
    }

    std::vector<int> result(n, -1);
    std::queue<int> q = {};
    q.push(0);
    result[0] = 1;

    while (!q.empty())
    {
        int index = q.front();
        q.pop();
        
        const auto& ts = edges[index];
        for (const int t : ts)
        {
            if (result[t] != -1)
                continue;

            result[t] = index;
            q.push(t);
        }
    }

    if (std::all_of(std::cbegin(result), std::cend(result), [](const int r) { return r != -1; }))
    {
        std::cout << "Yes" << std::endl;
        for (std::size_t index = 1; index < result.size(); ++index)
        {
            std::cout << result[index] + 1 << std::endl;
        }
    }
    else
    {
        std::cout << "No" << std::endl;
    }
}


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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);


void solve() {
    ll x;
    cin >> x;
    ll num = x/500LL;
    ll rem = x - num*500LL;
    ll times = rem/5;
    ll ans = num * 1000LL + times * 5LL;
    cout << ans << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  string s; cin >> s;

  rep(i, s.size()) cout << "x";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

class ABC_124_C
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();

        int[] S = new int[input.Length];

        for (int i = 0; i < S.Length; i++)
        {
            S[i] = int.Parse(input[i].ToString());
        }

        int blackEven = 0;
        int blackOdd = 0;
        int whiteEven = 0;
        int whiteOdd = 0;

        for (int i = 0; i < S.Length; i++)
        {
            if (i % 2 == 0)
            {
                if (S[i] == 0) blackEven++;
                else whiteEven++;
            }
            else
            {
                if (S[i] == 0) blackOdd++;
                else whiteOdd++;
            }
        }

        int count = Math.Min(blackEven + whiteOdd, blackOdd + whiteEven);

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13664
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{   
    int n;
    scn(n);

    ll sum = 0;

    vi a(n);

    rep(i, 0, n) 
    scn(a[i]);

    rep(i, 1, n) {
        if(a[i] < a[i - 1]) {
            sum += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }

    lprin(sum);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4072
dic = {}
while(True):
    try:
        key, page = input().split()
        page = int(page)
    except:
        break
    try:
        dic[key].append(page)
    except:
        dic[key] = [page]
a = list(dic.keys())
a.sort()
for b in a:
    print(b)
    print(" ".join(str(e) for e in sorted(dic[b])))



Measured memory_bytes: 5608
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    bool[] boxes = new bool[n];
    boxes[0] = true;
    long[] balls = new long[n];
    balls[] = 1;
    foreach (i; 0 .. m)
    {
        tmp = readln.split.to!(long[]);
        long x = tmp[0] - 1, y = tmp[1] - 1;
        --balls[x], ++balls[y];
        if (boxes[x]) boxes[y] = true;
        if (balls[x] < 1) boxes[x] = false;
    }

    boxes.count(true).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4092
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;
using std::fill;

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

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const long long MOD = 1e9 + 7;
ll n, K;
ll a[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> K;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i] > a[j])
            {
                if (i < j)
                {
                    ans = (ans + K * (K + 1) / 2) % MOD;
                }
                else
                {
                    ans = (ans + K * (K - 1) / 2) % MOD;
                }
            }
        }
    }
    cout << ans;
}


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

def XOR_SUM(X):
    ans = 0
    if X % 4 == 0:
        ans = X
    elif X % 4 == 1:
        ans = 1
    elif X % 4 == 2:
        ans = X+1
    elif X % 4 == 3:
        ans = 0
    return ans
    
print(XOR_SUM(a-1)^XOR_SUM(b))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  cout << (10000 - n) % 1000 << endl;


  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

ll gcd(ll a, ll b){
  if(b > a){
    ll c = a;
    a = b;
    b = c;
  }
  while(b != 0){
    ll c = b;
    b = a%b;
    a = c;
  }
  return a;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n; cin >> n;
  vector<ll> a(n);
  vector<ll> divisor(1000000+1, 0);
  vector<ll> primes;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i <= 1000000; i++){
    divisor[i] = i;
  }
  for(int i = 2; i <= 1000000; i++){
    if(divisor[i] == i){
      primes.push_back(i);
      int t = 2;
      while(i * t <= 1000000){
        if(divisor[i * t] > i) divisor[i * t] = i;
        t++;
      }
    }
  }
  vector<int> used(1000000+1, 0);
  for(int i = 0; i < n; i++) used[a[i]]++;
  for(auto p : primes){
    int cnt = 0;
    for(int i = p; i <= 1000000; i+=p){
        cnt += used[i];
    }
    if(cnt > 1){
      ll t = a[0];
      for(int i = 1; i < n; i++){
        t = gcd(t, a[i]);
      }
      if(t > 1){
        cout << "not coprime" << endl;
        return 0;
      }
      else{
        cout << "setwise coprime" << endl;
        return 0;
      }
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 23576
#include<iostream>
#include<string>
using namespace std;
int main(){
	int m;
	cin>>m;
	int a,n,y;
	bool q;
	double w;
	int e;
	for(int u=0;u<m;u++){
	cin>>a>>y>>n;
	int best=0;
	for(int i=0;i<n;i++){
		int m=a,ans=0;
		cin>>q>>w>>e;
		if(q==false){
			for(int j=0;j<y;j++){
				ans+=m*w;
				m-=e;
			}
			ans+=m;
		}
		if(q==true){
			for(int j=0;j<y;j++)
				m+=m*w-e;
			ans=m;
		}
		best=max(best,ans);
    }
	cout<<best<<endl;
	}
	return 0;
}

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

class unionfind {
  vector<int> par;
  
public:
  unionfind(int n) {
    for (int i = 0; i < n; i++) {
      par.push_back(i);
    }
  }
  
  int find(int n) {
    if (par.at(n) == n) return n;
    return par.at(n) = find(par.at(n));
  }
  
  void merge(int m, int n) {
    m = find(m);
    n = find(n);
    par.at(m) = n;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  unionfind tr(n);
  for (int i = 0; i < q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      tr.merge(u, v);
    } else {
      cout << (tr.find(u) == tr.find(v)) << endl;
    }
  }
}


Measured memory_bytes: 4236
#include <stdio.h>
int main(void){
    int dp[1000000] = {};
    int n,m;scanf("%d%d",&n,&m);
    int a[m];for(int i=0;i<m;i++)scanf("%d",&a[i]);
    int c=m-1;
    dp[n]=1;
    if(a[c]==n-1)c--;else dp[n-1]=1;
    for(int i=n-2;i>=0;i--){
        if(c>=0&&a[c]==i) c--;
        else dp[i]=(dp[i+1]+dp[i+2])%1000000007;
    }
    printf("%d",n==1?1:dp[0]);
}


Measured memory_bytes: 4480
#include<stdio.h>
 
int main(){
     
    int R[200000], n, i, maxv, minv;

    scanf("%d",&n);
 
    for (i = 0; i < n; i++)
        scanf("%d",&R[i]);

    maxv = -2000000000;
    minv = R[0];

    for (i = 1; i < n; i++) {
        if (maxv < R[i] - minv)
           maxv = R[i] - minv;
        if (minv > R[i])
           minv = R[i];
    }

    printf("%d\n", maxv);
    
    return 0;
}

Measured memory_bytes: 2564
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
path = [LIST() for _ in range(N - 1)]
Q, K = MAP()
question = [LIST() for _ in range(Q)]

graph = [[] for i in range(N)]

for i in range(N - 1):
	graph[path[i][0] - 1].append([path[i][1] - 1, path[i][2]])
	graph[path[i][1] - 1].append([path[i][0] - 1, path[i][2]])

depth = [0]*N

q = deque([K - 1])
connect = [0]*N
connect[K - 1] = 1
while q:
	n = q.popleft()
	for node, length in graph[n]:
		if connect[node] == 0:
			connect[node] = 1
			depth[node] = length + depth[n]
			q.append(node)

for i in range(Q):
	print(depth[question[i][0] - 1] + depth[question[i][1] - 1])

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

num = 3505

for i in range(1, num):
    if 4 / N > 1 / i:
        for j in range(1, num):
            if 4 / N > 1 / i + 1 / j:
                w = (N * i * j) / (4 * i * j - i * N - j * N)
                if w.is_integer():
                    print(i, j, int(w))
                    exit()

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

using namespace std;

int main(){
    int n;
    int count=0;
    int m=0;
    int height;
    cin >> n;

    while(cin >> height){
        if(m <= height){
            count++;
        }
        //cout << height;
        m = max(m,height);
    }

    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 1111;

void solve(){
    int n, s, k, i, j, a;
    cin >> n >> k >> s;
    if(s == modd1 - 7){
        a = 1;
    }
    else{
        a = s + 1;
    }
    for1(i, 1, k){
        cout << s <<' ';
    }
    for1(i, 1, n - k){
        cout << a << ' ';
    }
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 1280
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!
 
/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<char,char>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    ll n,i,ans=0;
    cin>>n;
    map<pii,ll> ma;
    for(i=1;i<=n;i++)
    {
        string s = to_string(i);
        char st = s[0] , et = s[s.size()-1];
        ma[{st,et}]++;
    }
    for(auto u: ma)
    {
        if(u.fi.fi==u.fi.se) ans += u.se * u.se;
        else
        {
            ans += u.se * ma[{u.fi.se,u.fi.fi}];
        }
    }
    cout<<ans;
    
}

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

using namespace std;
const int N=5e5+5,mod=1e9+7;
#define ll long long
int ans[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    int cnt=0,n;
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        ans[i]=cnt;
        cnt+=(s[i]=='W');
    }
    int mn=1e9;
    cnt=0;
    for(int i=s.size()-1;i>=0;i--)
    {
        ans[i]+=cnt;
        mn=min(mn,ans[i]);
        cnt+=(s[i]=='E');
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 1812
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s[m];
    rep(i, m){
        int k;
        cin >> k;
        rep(j, k){
            int s_;
            cin >> s_;
            s_--;
            s[i].push_back(s_);
        }
    }
    int p[m];
    rep(i, m) cin >> p[i];
    int ans = 0;
    for (int i = 0; i < (1 << n); i++){
        int swich[n];
        for (int j = 0; j < n; j++){
            swich[j] = ((i >> j) & 1);
        }
        int light = m;
        int num;
        for (int j = 0; j < m; j++){
            num = 0;
            for (int l = 0; l < s[j].size(); l++){
                if (swich[s[j][l]] == 1){
                    num++;
                }
            }
            if (num % 2 != p[j]){
                light--;
                break;
            }
        }
        if (light == m){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int D,N;
int ans;

void solove()
{
    if(N==100)
    {
        N++;
    }
    ans = pow(100,D)*N;
}

int main()
{
    cin >> D >> N;
    solove();
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
// #include <sstream>


using namespace std;

// left,rightの間にある文字列を切り出す
string substr2(const string s,const int left,const int right){
    return s.substr(left,right -left);
}

int main(){
    string str;
    cin >> str;
    // str = "125";

    
    // cout << str.length() << "\n";
    int n = str.length() - 1;
    
    long int sum = 0;
    

    
    for (int bit = 0; bit < (1 << n); bit++){

        
        long sum1 = 0;
        int left = 0;
        int right = 0;
        // cout << "bit" << bit <<"\n";
        for(right = 0; right < n ;right++){
            
            if((bit >> right) & 1){
                
                
                // string s =  str.substr(left,right + 1 - left);
                string s = substr2(str,left,right + 1);
                // cout << s;
                sum1 += stoll(s);
                // cout << "right" <<  right << "," << "left" << left << "," <<"s" << s << "\n";
                left = right + 1;
                
                // cout << right << ",";
                
                // cout << str[right] << "\n";
                // sum += str[right] - '0';
            }

        }
        // bit = 0のときは分割せずここに来る
        string s = substr2(str,left,right + 1);

        // string s =  str.substr(right - left + 1);
        // cout << s << "\n";
        sum1 += stoll(s);       
        
        
       sum += sum1;

        
    }
    
    cout  << sum <<"\n";
    
}


Measured memory_bytes: 256
H, W = map(int, input().split())
x = [list(map(str, list(input()))) for l in range(H)]

for i in range(len(x)):
    x[i].insert(0, ".")
    x[i].append(".")
x.insert(0, ["."]*(W+2))
x.append(["."]*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if x[i][j] == "#":
            if x[i][j-1] == x[i][j+1] == x[i-1][j] == x[i+1][j] == ".":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 9156