akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans[2], a[1000000];
bool f;
struct Edge { LL to, cost; };
string str;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	if (a[n - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	ans[0] = 2, ans[1] = 3;
	Mfor(i, n-1) {
		ans[0] = (ans[0] / a[i] + (ans[0] % a[i] != 0 ? 1 : 0))*a[i];
		ans[1] = (ans[1]) / a[i] * a[i];
		ans[1] += a[i] - 1;
		//cout << ans[0] << " " << ans[1] << endl;
	}
	LL A[2] = { ans[0],ans[1] };
	rep(i, n) {
		A[1] -= A[1] % a[i];
		A[0] -= A[0] % a[i];
	}
	if (A[1]!=2||A[0]!=2) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans[0] << " " << ans[1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 無限大を表す値

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N+1, vector<long long>(W+1, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j-w[i] >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }

    long long result = 0;
    for (int j = 0; j <= W; ++j) result = max(result, dp[N][j]);
    cout << result << endl;
}

Measured memory_bytes: 83008
a = []
a.append(int(input()))
i = 1
while True:
  x = a[-1]
  if x % 2 == 0:
    y = x // 2
    a.append(y)
  else:
    y = 3 * x + 1
    a.append(y)
  if a.count(y) >= 2:
    break
print(len(a))

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

void initStrArray(char** p, int n, int len){
    for(int i=0; i<n; i++){
        *(p + i) = (char*)malloc(sizeof(char) * (len + 1));
    }
}

int main(){
    int n;
    scanf("%d", &n);
    char* w[n];
    initStrArray(w, n, 101);
    int t[n];
    rep(i, 0, n){
        scanf("%s %d", w[i], &t[i]);
    }
    int ans = 0;
    char x[101];
    scanf("%s", x);
    int f=0;
    rep(i, 0, n){
        if(f){
            ans += t[i];
        }
        if(strcmp(w[i], x) == 0){
            f = 1;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=='?':
        break
    
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(a//b)


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

using namespace std;


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define vi                                        vector<int> 
#define vpii                                      vector< pii >

#define all(v)                                    v.begin(),v.end()
#define sz(re)                                    (int)re.size()
#define mset(a,f)                                 memset(a,f,sizeof(a))
#define M                                         1000000007
#define Think_Twice_Code_Once                     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)


bool J27 = 1;
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(!J27)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7;
const long long INF = LLONG_MAX;
const int inf = INT_MAX;

int n, Q;
int arr[N+2];

int get(int h)
{
      if( h == 1 ) return 1;
      return 2*get(h/2) + 1;
}
void solve()
{
      int h;
      cin >> h;

      cout << get(h) << endl;
}


int32_t main()
{

      J27 = 1;
      Think_Twice_Code_Once;
    // INP(); 
      int t = 1;
      //cin >> t;
      while(t--) solve();


}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair                                                                

#define ff first                                                                  
#define ss second   

#define matr vector<vector<int> > 

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


using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 
string s;  
int cnt[maxn]; 

void solve() {        
    cin >> n >> s; 
    for (auto v : s) {
        cnt[v - 'a']++; 
    }
    int ans = 1; 
    for (int i = 0; i < 30; ++i) {
        ans *= (cnt[i] + 1); 
        ans %= mod; 
    }
    --ans; 
    ans += mod; 
    ans %= mod; 
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1;  
    for (int i = 0; i < t; ++i)              
        solve();
    return 0;
}  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){int n,a,b,c,x,y,z,p,q,r; cin>>n>>a>>b>>c; p=a,q=b,r=c,n--; while(n--){cin>>x>>y>>z; a=x+max(q,r),b=y+max(r,p),c=z+max(p,q),p=a,q=b,r=c;}; cout<<max({a,b,c});}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int n;
vector<int> V, W;
vector<vector<int> > dp(550, vector<int>(100010, 0));
void init_dp() {
  int limit = min(n, (1<<9)-1);
  rep(i, limit) {
    int v = i+1;
    rep(j, 100005) {
      dp[v][j] = dp[v/2][j];
      if(W[i] <= j) chmax(dp[v][j], dp[v/2][j-W[i]]+V[i]);
    }
  }
}
void solve(int v, int L) {
  int limit = (1<<9)-1;
  if(v <= limit) {
    int ans = 0;
    repc(i, L) chmax(ans, dp[v][i]);
    cout << ans << "\n";
    return;
  }
  vector<int> vs;
  int v_ = v;
  while(v_ > limit) {
    vs.push_back(v_);
    v_ /= 2;
  }
  int sz = vs.size(), ans = 0;
  rep(i, 1<<sz) {
    int w = 0, v = 0;
    rep(j, sz) if((i>>j)&1) {
      w += W[vs[j]-1];
      v += V[vs[j]-1];
    }
    if(w <= L) chmax(ans, dp[v_][L-w] + v);
  }
  cout << ans << "\n";
}
void answer() {
  cin >> n;
  V.assign(n, 0);
  W.assign(n, 0);
  rep(i, n) cin >> V[i] >> W[i];
  init_dp();
  int Q; cin >> Q;
  rep(i, Q) {
    int v, L; cin >> v >> L;
    solve(v, L);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 220768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll sum=0;
    ll ans=0;
    ll hu=0;
    priority_queue<ll> que;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n){
      sum+=a[i]-b[i];
      if(a[i]>b[i]) que.push(a[i]-b[i]);
      else if(b[i]>a[i]){
        //cout<<a<<' '<<b<<endl;
        hu+=b[i]-a[i];
        ans++;
      }
    }
    if(sum<0){
      cout<<-1<<endl;
    }else{
      //cout<<hu<<endl;
      while(hu>0){
        ans++;
        ll now=que.top();
        que.pop();
        hu-=now;
      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 2428
#include <iostream>

using namespace std;

int cards[50];

void shuffle(int p, int c) {
    int a[p + c - 1];
    for (int i = 0; i < p + c - 1; ++i) {
        if (i < c) {
            a[i] = cards[p - 1 + i];
        } else {
            a[i] = cards[i - c];
        }
    }

    for (int i = 0; i < p + c - 1; ++i) {
        cards[i] = a[i];
    }
}

int main() {
    while (true) {
        int N, R;
        cin >> N >> R;
        if (N == 0 && R == 0) return 0;

        for (int i = 0; i < N; ++i) {
            cards[i] = N - i;
        }

        for (int i = 0; i < R; ++i) {
            int p, c;
            cin >> p >> c;
            shuffle(p, c);
        }

        cout << cards[0] << endl;
    }
}


Measured memory_bytes: 2960
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int a[1000];
int main()
{
	int i,j,k,n,m;
	scanf("%d",&n);
	if(n==0)
	{
		printf("0");
		return 0;
	}
	i=0;
	while(n!=0)
	{
		if(n<0)
		{
			a[i]=-n%2;
			n=n/(-2)+a[i];
		}
		else
		{
			a[i]=n%2;
			n=n/(-2);
		}
		i++;
	}
	for(i--;i>=0;i--)
	{
		printf("%d",a[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

long long int A,N,res=1,P[200200],now=1,sum[200200]={};
string S;
long double B;




int main(){
    cout << fixed << setprecision(18);
    cin>>A>>B;
    B*=100;
    B+=0.000001;
    cout<<A*(long long int)(B)/100;

}




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

int main(){
    int H,W,count = 0;
    char c[52][52];
    cin >> H >> W;

    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++)  cin >> c[i][j];
    }

    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++)
            if(c[i][j] == '#' && c[i - 1][j] != '#' && c[i + 1][j] != '#' && c[i][j + 1] != '#' && c[i][j -1] != '#') count++;
    }
    if(count == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int a, b,c;
    cin >> a >> b >> c;
    if(a == b) {
        if(b == c) {
            cout << 1 << endl;
        } else {
            cout << 2 << endl;
        }
    } else if(b == c) {
        cout << 2 << endl;
    } else if(a == c){
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
N = input()
dlist = []
n2 = int(round(math.sqrt(N)))
for i in range(2,n2+1):
	if(N % i == 0):
		if(N/i - 1 > i):
			dlist.append(N/i -1)
if(N!=2):
	dlist.append(N-1)
print(sum(dlist))

Measured memory_bytes: 34436
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
int a;
char s[10];
int main(){
	scanf("%d%s", &a, s);
	if (a >= 3200) printf("%s\n", s);
	else printf("red\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
LL a[N];
int main() {
    LL n,x;
    scanf("%lld%lld",&n,&x);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    LL res=0;
    for(int i=1;i<=n-1;i++){
        if(a[i]+a[i+1]>x){
            LL sub=a[i]+a[i+1]-x;
            a[i+1]-=sub;
            res+=sub;
        }
    }
    if(a[n]>x)
        res+=a[n]-x;

    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<cmath>
#define pub push_back
using namespace std;
int main(void){
    int r[100]={0};
    int n,m,q,w;
    cin>>n>>m;
    while(m--){
        cin>>q>>w;
        r[q]++;r[w]++;
    }
    for(int i=1;i<=n;i++){
        cout<<r[i]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin>>X[i]>>Y[i];
  }
  int ans=N;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j)continue;
      ll p=X[i]-X[j];
      ll q=Y[i]-Y[j];
      int cnt=0;
      for(int ii=0;ii<N;ii++){
        for(int jj=0;jj<N;jj++){
          if(ii==jj)continue;
          if(X[ii]-X[jj]==p && Y[ii]-Y[jj]==q){
            cnt++;
          }
        }
      }
      ans=min(ans,N-cnt);
    }
  }
  if(N==1)ans=1;
  cout<<ans<<endl;
}


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a == b && b != c) {cout << "Yes" << endl;}
  else if (b == c && c != a) {cout << "Yes" << endl;}
  else if (c == a && a != b) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef long long ll;
struct Point{ int x,y,id; };
struct edge{ int from,to,cost; };
bool compe(edge &e1,edge &e2){ return e1.cost<e2.cost; }
bool compx(Point &p1,Point &p2){ return p1.x<p2.x; }
bool compy(Point &p1,Point &p2){ return p1.y<p2.y; }

struct UnionFind{
	vector<int> par;
	vector<int> sizes;
	UnionFind(int n):par(n),sizes(n,1){ rep(i,n)par[i]=i; }

	//find root of x
	int find(int x){
		if(x!=par[x]) par[x] = find(par[x]);
		return par[x];
	}

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(sizes[x] < sizes[y]) swap(x, y);
		par[y] = x;
		sizes[x] += sizes[y];
	}

	bool same(int x,int y){ return find(x) == find(y); }
	int size(int x){ return sizes[find(x)]; }
};



int main(void){
	int N;
	cin>>N;
	vector<Point> p(N);
	rep(i,N){
		cin>>p[i].x>>p[i].y;
		p[i].id=i;
	}

	vector<edge> ve;
	
	sort(all(p),compx);
	rep(i,N-1){
		ve.push_back({p[i].id, p[i+1].id, p[i+1].x-p[i].x});
	}
	
	sort(all(p),compy);
	rep(i,N-1){
		ve.push_back({p[i].id, p[i+1].id, p[i+1].y-p[i].y});
	}
	

	UnionFind uf(N);
	sort(all(ve),compe);
	ll res=0;
	rep(i,(int)ve.size()){
		if(!uf.same(ve[i].from,ve[i].to)){
			uf.unite(ve[i].from,ve[i].to);
			res+=ve[i].cost;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5876
#include <stdio.h>
const int MAX_V = 1000000;
int main() {
    int prime[MAX_V+1];
    int i, k, v,a=0,n;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;
            }
            
        } 
        
    }
    while(1){
      scanf("%d",&n);
      if(n==0)break;
      for(i=0;i<=n-2;i++){
          int isprime = prime[i];
          int isprimex = prime[i+2];
          if(isprime && isprimex){
             if(a<i)a=i;
          }
        }
        printf("%d %d\n",a,a+2);
    }
    return 0; 
    
}

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

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b % 2) {
            res *= a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int N = 5e6 + 5;
int n, k, p;

bool ispalin(string &s) {
    int b = true;
    int i=0, j=s.length()-1;
    for(; i<j; i++, j--) {
        if(s[i] != s[j]) return false;
    }
    return true;
}
signed main() {
    int n;
    cin >> n;
    map<ll, ll > m;
    ll x;
    ll a[n + 5];
    for(int i=1; i<=n; i++) {
        cin >> x;
        a[i] = x;
        m[x]++;
    }
    ll ans = 0;
    for(auto it : m) {
        ans += it.sd*(it.sd-1)/2;
    }
    for(int i=1; i<=n; i++) {
        ll aa = ans;
        ll ct = m[a[i]];
        aa -= ct*(ct-1)/2;
        ct--;
        aa += ct*(ct-1)/2;
        cout << aa << '\n';
    }
    return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

struct pascal_comb {
    vector<vector<long long>> dat;
    pascal_comb(int s) : dat(s+1,vector<long long>(s+1)) {
        rep(i,s+1) {
            dat[i][0] = 1;
            dat[i][i] = 1;
        }
        for (int k = 1; k < s+1; k++) {
            for (int j = 1; j < k; j++) {
                dat[k][j] = dat[k-1][j-1] + dat[k-1][j];
            }
        }
    }
    long long operator() (int a, int b) {
        if (b < 0 || a < b) return 0;
        return dat[a][b];
    }
};

int main() {
    int n, p; cin >> n >> p;
    int ct_0 = 0, ct_1 = 0;
    rep(i,n) {
        int x; cin >> x;
        if (x % 2 == 0) ct_0++;
        else ct_1++;
    }
    pascal_comb com(50);
    ll ans = 0;
    if (p == 0) {
        for (int a = 0; a <= ct_1; a += 2) {
            ans += com(ct_1,a) * pow(2,ct_0);
        }
    } else {
        for (int a = 1; a <= ct_1; a += 2) {
            ans += com(ct_1,a) * pow(2,ct_0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4072
n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
s = 1/(4*m)*sum(i for i in a)
for i in range(n):
    if a[i] < s:
        print("No")
        break
    if i == m-1:
        print("Yes")
        break


Measured memory_bytes: 3060
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(a,x,b),y,g(c,z,d))==10:return f"(({a} {x} {b}) {y} ({c} {z} {d}))"
   if g(g(a,x,g(b,y,c)),z,d)==10:return f"(({a} {x} ({b} {y} {c})) {z} {d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5660
#include <stdio.h>

int n, k, su[10];

int byNum(int n) {
    for(int i=0; i<k; i++) {
        if(n==su[i]) return 0;
    }
    return 1;
}
int isOK(int n) {
    while(n) {
        if(byNum(n%10))
            n/=10;
        else
            return 0;
    }
    return 1;
}

int main(void) {
    int st;
    scanf("%d %d", &n, &k);
    for(int i=0; i<k; i++) scanf("%d", su+i);
    st=n;
    while(1) {
        if(isOK(st)) {
            printf("%d", st);
            break;
        }
        st++;
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main (String[]args){
		Scanner teclado = new Scanner (System.in);
		int A, B, C, D, E;
		A=teclado.nextInt();
		B=teclado.nextInt();
		C=teclado.nextInt();
		D=teclado.nextInt();
		E=teclado.nextInt();
		int k = teclado.nextInt();
		if(B-A <= k  && C-A <= k && D-A <= k && E-A <= k && C-B <= k && D-B <= k && E-B <= k && D-C <= k  && E-C <= k  && E-D <= k    ) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
 
	 
	 }
	 
	
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <set>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(ary) do { for(auto i:ary){ cout << i << " "; } cout << endl; } while (0)
int main()
{
    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R);
    REP(i, R) {
        int k; cin >> k;
        r[i] = k-1;
    }
    vector<vector<int>> shortest(N);
    REP(i, N) shortest[i].resize(N, 100000 * 200 + 1);
    REP(i, N) shortest[i][i] = 0;
    REP(i, M) {
        int a, b, c; cin >> a >> b >> c;
        shortest[a-1][b-1] = shortest[b-1][a-1] = c;
    }
    REP(k, N) REP(x, N) REP(y, N) {
        shortest[x][y] = min(shortest[x][y], shortest[x][k] + shortest[k][y]);
    }
    sort(r.begin(), r.end());
    Int minimum = numeric_limits<Int>::max();
    do {
        Int c = 0;
        REP(i, R-1) c += shortest[r[i]][r[i+1]];
        minimum = min(minimum, c);
    } while (next_permutation(r.begin(), r.end()));
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}

int main(){
    char buf1[10],buf2[10];

    my_gets(buf1,10,stdin);
    my_gets(buf2,10,stdin);
    printf(
        "%d\n",
        (buf1[0]==buf2[0]) + (buf1[1]==buf2[1]) + (buf1[2]==buf2[2])
    );
    return 0;
} 

Measured memory_bytes: 128
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	int a[100000], b[100000], c[100000];
	scanf("%d", &n);
	for(i=0; i<n; i++){ scanf("%d", a+i); }
	for(i=0; i<n; i++){ scanf("%d", b+i); }
	for(i=0; i<n; i++){ scanf("%d", c+i); }
	qsort(a, n, sizeof(int), comp);
	qsort(b, n, sizeof(int), comp);
	qsort(c, n, sizeof(int), comp);

	long ans=0;
	for(i=0; i<n; i++){
		int k=b[i];
		long now;
		int l, r, m;
		l=0, r=n-1;
		while(l<=r){
			m=(l+r)/2;
			if(a[m]>=k) r=m-1; else l=m+1;
		}
		now=l;
		l=0, r=n-1;
		while(l<=r){
			m=(l+r)/2;
			if(c[m]>k) r=m-1; else l=m+1;
		}
		now*=n-l;
		ans+=now;
	}
	printf("%ld\n", ans);
}


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

using namespace std;

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

#define MAX_N 50
#define MAX_D 31

int n;
bool schedule[MAX_N][MAX_D];
set<int> check[MAX_N];

int main() {
	while(cin>>n, n) {
	    rep(i, MAX_N) memset(schedule[i], false, MAX_D);
	    rep(i, MAX_N) check[i] = { i };
	    rep(i, n) {
	        int f; cin >> f;
	        rep(_, f) { int d; cin>>d; schedule[i][d] = true; }
	    }
	    int ans = -1;
	    REP(d, 1, MAX_D) {
	        set<int> tmp;
	        rep(i, n) if(schedule[i][d]) for(int k: check[i]) tmp.insert(k);
	        rep(i, n) if(schedule[i][d]) for(int k: tmp) check[i].insert(k);
	        if(tmp.size()==n) ans = d;
	        if(ans!=-1) break;
	    }
        cout << ans << endl;
	}
}



Measured memory_bytes: 3116
/*
  no pain, no gain
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define pii pair<int, int>
#define all(s) s.begin(), s.end()
#define prev myrza4321
#define y1 myrza1234
#define OK puts("OK")
using namespace std;

const int N = (int)1e5 + 5;
const int INF = 0x3f3f3f3f;

main() {
  int n, x;
  cin >> n >> x;
  int pnt = 0, ans = 1;
  while (n--) {
    int add;
    scanf("%d", &add);
    pnt += add;
    if (pnt <= x) {
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

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

	for (string s; cin >> s&&s != "#";) {
		int n = s.size();
		string a, b;
		vector<string> v;
		for (int mask = 0; mask < (1 << n); mask++) {
			a = s;
			bool flag = false;
			rep(i, 0, n) {
				if (mask >> i & 1) {
					if (a[i] == 'z') {
						flag = true;
						break;
					}
					a[i] += 1;
				}
			}
			if (flag)
				continue;
			b = a;
			static bool f[128];
			memset(f, 0, sizeof(f));
			rep(i, 0, n) {
				if (b[i] == 'a')continue;
				if (f[b[i]])continue;
				f[b[i]] = true;
				b[i] -= 1;
			}
			if (b == s) {
				v.emplace_back(a);
			}
		}
		cout << v.size() << endl;
		sort(all(v));
		if (v.size() > 10) {
			rep(i, 0, 5)
				cout << v[i] << endl;
			rep(i, v.size() - 5, v.size())
				cout << v[i] << endl;
		}
		else {
			rep(i, 0, v.size()) {
				cout << v[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define maxn 3005
using namespace std;

char str[maxn];

int dp[maxn][maxn],prefix[maxn][maxn];

void add_self(int& a,int b)
{
    a+=b;
    if(a>=mod) {
        a-=mod;
    }
}

int main()
{
    int n;
    cin>>n;
    cin>>str;
    dp[1][1] = 1;

    for(int len=2;len<=n;len++)
    {
        for(int k=1;k<=len-1;k++) {
            prefix[len-1][k] = (prefix[len-1][k-1]+dp[len-1][k])%mod;
        }
        for(int i=1;i<=len;i++)
        {
            int l,r;
            if(str[len-2]=='<') {
                l = 1;
                r = i-1;
            }
            else {
                l = i;
                r = len-1;
            }
            if(l<=r) {
                add_self(dp[len][i],(prefix[len-1][r]-prefix[len-1][l-1]+mod)%mod);
            }
            /*for(int j=1;j<=len-1;j++)
            {
                int real_j = j;
                if(j>=i) {
                    ++real_j;
                }
                assert(real_j!=i);
                if( (real_j<i) != (str[len-2]=='<')) continue;
                add_self(dp[len][i],dp[len-1][j]);
            }*/
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
       add_self(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 69504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s; cin >> s;
  cout << s[0] << s.size() - 2 << s.back() << '\n';
  
  return 0;
}



Measured memory_bytes: 256
import math
N = int(input())
a_ls = [int(i) for i in input().split()]


def gcd(ls):
    ls = [i for i in ls if i > 0]
    while True:
        _min = min(ls)
        ls = [i % _min for i in ls if i % _min != 0]
        if len(ls) == 0:
            return _min
        ls.append(_min)

l_ls = [0]
r_ls = [0]
for i in range(N):
    l_ls.append(gcd([l_ls[i], a_ls[i]]))
    r_ls.append(gcd([r_ls[i], a_ls[-i-1]]))
r_ls = r_ls[::-1]
sum_ls = [gcd([l_ls[i], r_ls[i+1]]) for i in range(N)]
print(max(sum_ls))

Measured memory_bytes: 14436
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int sum;
  foreach (_; 0..n) {
    auto l = readln.chomp.split.map!(to!int);
    sum += l[1] - l[0] + 1;
  }
  writeln(sum);
}


Measured memory_bytes: 380
def b(line):
	cnt = 0
	for i in range(len(line)):
		if cnt < 1 and line[i] == 'R':
			cnt += 1
			continue
		if cnt >= 1 and line[i] == line[i-1] and line[i] == 'R':
			cnt += 1
			continue
	return cnt

print(b(input()))

Measured memory_bytes: 9052
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]

    X, Y = [], []
    for x, y in XY:
        X.append(x + y)
        Y.append(x - y)
    res = max(max(X) - min(X), max(Y) - min(Y))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 61284
#include<bits/stdc++.h>
using namespace std;
long long f[3001][3001];
int a[3001];
int main()
{
	int i,j,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(n%2==0)
			f[i][i]=-a[i];
		else
			f[i][i]=a[i];	
	}
	for(j=1;j<n;j++)
	{
		for(i=1;i+j<=n;i++)
		{
			if(j%2==n%2)
			{
				f[i][i+j]=min(f[i+1][i+j]-a[i],f[i][i+j-1]-a[i+j]);
			}
			else if(j%2!=n%2)
			{
				f[i][i+j]=max(a[i]+f[i+1][j+i],f[i][i+j-1]+a[i+j]);
			}
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}

Measured memory_bytes: 70016
using System;

namespace ABC099B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var sum = 0;
            var dis = N[1] - N[0];

            for(var x=0; x<=dis; x++)
            {
                sum += x;
            }
            Console.WriteLine(sum - N[1]);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;

const int maxn = 1e5+5;
int h[maxn][3], dp[maxn][3];

int main(){
	int n; scanf("%d", &n);
	for(int i = 0; i<n; i++)
		for(int j = 0; j<3; j++) scanf("%d", &h[i][j]);
	for(int j = 0; j<3; j++) dp[0][j] = h[0][j];
	for(int i = 1; i<n; i++){
		for(int j = 0; j<3; j++){
			dp[i][j] = h[i][j];
			int add = 0;
			for(int d = 0; d<3; d++) if (d != j) add = max(add, dp[i-1][d]);
			dp[i][j]+= add;
		}
	}
	int ans = 0; for(int i = 0; i<3; i++) ans = max(ans, dp[n-1][i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560
//***Faithless is he that says farewell when the road darkens***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
   ll k,x;
   cin>>k>>x;

   for(ll i=x-k+1;i<=(x+k-1);i++)
   cout<<i<<" ";
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }
    let vn: Vec<char> = s.chars().collect();
    let mut sum = 0;
    for i in 0..vn.len() {
        sum += vn[i as usize] as i32 - 48;
    }
    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
	int x,y = 1;
	while (x != 0 || y != 0){
		cin >> x >> y;
		if (x != 0 || y != 0){

			if(x < y){
			cout << x << " " << y << endl;
			}else{
			cout << y << " " << x << endl;
			}
		}
	}
return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>

int main(){
  int i, j, n, matrix[11][11];
  while(scanf("%d", &n)){
    if(!n) break;
    memset(matrix, 0, sizeof(matrix));
    for(i = 0;i < n;i++){
      for(j = 0;j < n;j++){
	scanf("%d", &matrix[i][j]);
	matrix[i][n] += matrix[i][j];
	matrix[n][j] += matrix[i][j];
	matrix[n][n] += matrix[i][j];
      }
    }

    for(i = 0;i <= n;i++){
      for(j = 0;j <= n;j++){
	printf("%5d", matrix[i][j]);
      }
      puts("");
    }
  }
  return 0;
}

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

using namespace std;
const unsigned long long MAXN=1e12+5;

long long n;
vector<int> ans,aans;
int mx;

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=59;i>=0;i--){
		if(n>=(1LL<<i)){
			n-=(1LL<<i);
			ans.push_back(i);
		}
	}
	//for(int i=0;i<ans.size();i++) cout<<ans[i]<<endl;
	int crt=1;
	for(;crt<=ans[0];crt++){
		if(crt!=1) aans.insert(aans.begin()+crt-1,crt);
		else aans.push_back(crt);
		aans.push_back(crt);
	}
		aans.push_back(crt);
		aans.push_back(crt++);
	for(int i=1;i<ans.size();i++){
		for(vector<int>::iterator it=aans.begin();it!=aans.end();it++){
			if(*it==ans[i]+1){
				aans.insert(it,crt);
				break;
			}
		}
		aans.push_back(crt++);
	}
	cout<<aans.size()<<endl;
	for(int i=0;i<aans.size();i++) cout<<aans[i]<<' ';
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

char s[500002];
int n;

int d[29][500001];

int incre(int_fast8_t c, int_fast32_t i){ c-='a';
	for(; i<=n; i+=i&-i) d[c][i]++;
}
int decre(int_fast8_t c, int_fast32_t i){ c-='a';
	for(; i<=n; i+=i&-i) d[c][i]--;
}
int sum(int_fast8_t c, int_fast32_t l, int_fast32_t r){ c-='a';
	int s=0;
	for(; r>0; r-=r&-r) s+=d[c][r];
	for(l--; l>0; l-=l&-l) s-=d[c][l];
	return s;
}

int main(void){
	int q, i, j;
	scanf("%d%s%d", &n, s+1, &q);
	for(i=1; i<=n; i++) incre(s[i], i);
	for(i=0; i<q; i++){
		int q0;
		scanf("%d", &q0);
		if(q0==1){
			int i; char c;
			scanf("%d %c", &i, &c);
			decre(s[i], i);
			incre(c, i);
			s[i]=c;
		}else{
			int l, r;
			scanf("%d%d", &l, &r);
			int ans=0;
			for(char c='a'; c<='z'; c++){
				if(sum(c, l, r)>0) ans++;
			}
			printf("%d\n", ans);
		}
	}
}


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

using ll = long long;
const int MAX = 1e5 + 10;
using edge = struct {int to; ll cost;};
vector<edge> tree[MAX];
ll depth[MAX];

void dfs(int v, int p, ll d) {
  depth[v] = d;
  for (int i = 0; i < tree[v].size(); i++) {
    edge e = tree[v][i];
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
  // for (auto &e : tree[v]) {
  //   if (e.to == p) continue;
  //   dfs(e.to, v, d + e.cost);
  // }
}

int main() {
  int N;
  cin >> N;
  int a, b;
  ll c;
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b >> c;
    a--; b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }

  int Q, K;
  cin >> Q >> K;
  K--;
  dfs(K, -1, 0);
  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << depth[x] + depth[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 15872
#include <iostream>

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

using namespace std;

int main(){
	int n,a;
	cin >> n >> a;
	
	if ((n%500)<=a) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;	
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):
    ret = 0
    for i in range(N):
        no = False
        for j in range(0, i):
            if H[i] < H[j]:
                no = True
                break
        if not no:
            ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll h,w;
	cin >> h >> w;
	if(h==1||w==1){
		cout << "1" << endl;
	}else{
		cout << ((h*w+1)/2) << endl;
	}
	return 0;
}


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

typedef long long ll;

bool is_prime(ll num){
    if(num <= 1)    return false;
    
    for(ll i = 2; i * i <= num; ++i){
        if(num % i == 0){
            return false;
        }
    }
    
    return true;
}

bool used[1000005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll a, b;
    cin >> a >> b;
    if(a == 1 || b == 1){
        cout << 1 << endl;
        return 0;
    }
    if(a > b)   swap(a, b);
    
    int cnt = 1;    // 1の分
    
    map<int, int> prime;
    for(ll i = 2; i * i <= a; ++i){
        if(a % i == 0){
            ++prime[i];
            while(a % i == 0){
                a /= i;
            }
        }
    }
    if(a > 0)   ++prime[a];
    
    for(ll i = 2; i * i <= b; ++i){
        if(b % i == 0){
            ++prime[i];
            while(b % i == 0){
                b /= i;
            }
        }
    }
    if(b > 0)   ++prime[b];
    
    for(auto it = prime.begin(); it != prime.end(); ++it){
        if(it->first == 1)  continue;
        if(it->second == 2){
            ++cnt;
        }
    }
    
    cout << cnt << endl;
}

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

int main(){
	
	int i,n,s;
	int a[52];
	char m;

	for (i = 0; i < 52; i++){
		a[i] = 0;
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		//scanf("%c %d",&m, &s);  //入力の問題でwrong answerになってた..
		scanf(" %c", &m);
		scanf("%d",&s);
		if (m == 'S'){
			a[s - 1] = 1;
		}else if(m=='H'){
			a[s + 12] = 1;
		}else if (m=='C'){
			a[s + 25] = 1;
		}else if(m=='D'){
			a[s + 38] = 1;
		}
	}

	for (i = 0; i < 52; i++){
		if (a[i] == 0){
			if (i < 13){
				printf("S %d\n",i+1);
			}else if (i < 26){
				printf("H %d\n",i-12);
			}else if (i < 39){
				printf("C %d\n",i-25);
			}else if(i <52){
				printf("D %d\n",i -38);
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, l, sum = 0, mi = INF, t = 0;
	
	cin>>n>>l;
	
	for(int i = 1; i <= n; i++){
		sum += l+i-1;
		if(mi > abs(l+i-1)){
			t = l+i-1;
			mi =  abs(l+i-1);
		}
	}
	
	// for(int i = 0; i <= n; i++){
		
	// }
	
	cout<<sum-t<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256