akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int A, P; cin >>A >> P;
  cout << (A * 3 + P) / 2 << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string S; cin >> S;
  int cnt = 0;
  for(int i = 0; i < S.length()-1; ++i) {
    if(S[i] != S[i+1]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

Vi divisor(ll x){
  Vi ans = {};
  for(ll i = 1; i * i <= x; i++){
    if(i * i == x && x % i == 0) ans.pb(i);
    else if(x % i == 0){
      ans.pb(i); ans.pb(x / i);
    }
  }
  SORT(ans);
  return ans;
}
int main(){
  ll n; cin >> n;
  Vi d = divisor(n);
  ll ans = 0;
  for(auto &i : d){
//    cout << e << ' ' << n / e << endl;
    ll m = n / i - 1;
    if(m > i) ans += m;
  }
  // ll ans = 0;
  // for(ll i = 0; i * i <= n; i++){
  //   ll lb = ((n - i) * i + (n - 1)) / n;
  //   ll ub = ((n - i) * (i + 1) - 1) / n;
  //   for(ll x = lb; x <= ub; x++){
  //     if(x > 0 && (n - i) % x == 0) ans += (n - i) / x;
  //   };
  // }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}

void Main(){
  ll n;
  cin>>n;
  vl d(n);
  cin>>d;
  map<ll,ll> mp;
  ll pmax = 0;
  if(d[0]!=0){cout<<0<<endl; return;}
  rep(i,n){
    if(d[i]==0 and i!=0){cout<<0<<endl; return;}
    mp[d[i]]++;
    chmax(pmax,d[i]);
  }
  ll ans=1;
  srep(i,1,pmax+1){
    ll k = mp[i-1];
    if(mp[i]==0){cout<<0<<endl; return;}
    rep(j,mp[i]){
      ans*=k;
      if(ans>998244353){ans%=998244353;}
    }
  }
  cout<<ans<<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cmath>
#define N 105
using namespace std;

int n, s, ans, a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]), s += a[i];
	s = round(1.0 * s / n);
	for (i = 0; i < n; i++) ans += (s - a[i]) * (s - a[i]);
    cout << ans << endl;
    return 0;
}

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

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

int main(){
    int N, X;
    cin >> N >> X;
    
    int n1, n2;
    cin >> n1;
    n1 = abs(n1-X);
    for (int i = 0; i < N-1; i++ ) {
        cin >> n2;
        n1 = gcd(abs(n2-X),n1);
    }
    cout << n1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#define INF 1<<29
using namespace std;
int V;
int cost[1000][1000],mincost[1000];
bool used[1000];
bool connect[1000];

int prime()
{
  int res = 0;
  for(int i=0;i<V;++i)
    {
      mincost[i] = INF;
      used[i]=false;
    }

  mincost[0]=0;
  
 
  while(true)
    {
 int v = -1;
      for(int i=0;i<V;i++)
	{
	  if(connect[i] && !used[i] && (v == -1 ||  mincost[i] < mincost[v]))v = i;
	}
      
      if(v == -1)break;
      used[v] = true;
      res += mincost[v];
      
      for(int i=0;i<V;i++)
	{
	  mincost[i] = min(mincost[i],cost[v][i]);
	}

    }
  
  return res;
}




int main()
{
  int m,a,b;

  while(true)
    {
      cin >> V >> m;
      if(V == 0 && m == 0)break;
      for(int i=0;i<V;i++)for(int j=0;j<V;j++)cost[i][j] = INF;
      memset(connect,false,sizeof(connect));
      for(int i=0;i<m;i++)
	{
	  cin >> a >> b;
	  cin >> cost[a][b];
	  cost[b][a] = cost[a][b];
	  connect[a] = true;
	  connect[b] = true;
	}
      cout << prime() << endl;
    }
}

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

int main(){
  string s;
  cin >> s;
  int n;
  n = s.size();
  int i = 0;
  int k = n-1;
  bool start = true;
  bool goal = true;
  while(start){
    if(s[i]=='A'){
      start = false;
    }
    else{
      i += 1;
    }
  }

  while(goal){
    if(s[k]=='Z'){
      goal = false;
    }
    else{
      k += -1;
    }
  }
  cout << (k-i+1) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int bb = 0;
  for(int i = 0;i < a.size();i++){
    for(int j = 1;j < a.size()-i+1;j++){
      string b;
       b = a.substr(i,j);
      int d = 1;
      for(char s:b){
        if(s != 'A' && s != 'C' && s != 'G' && s != 'T')
          d = 0;}
      int f;
      f = b.size();
      if(d == 1){bb = max(bb,f);}
    }
  }
  cout << bb << endl;
      
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
void solve(){
    long long n, nn, sn = 0;
    cin >> n;
    nn = n;
    while (nn != 0){
        sn += nn % 10;
        nn /= 10;
    }
    if(n % sn == 0){
        cout << "Yes" << endl;
    }
    else 
    cout << "No" << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

vector<int> edge[55];
int a[55];
int b[55];
bool visited[55];

void dfs(int v, int na, int nb, int p = -1) {
	if (visited[v]) return;
	visited[v] = true;
	for (auto x : edge[v]) {
		if (na == v && nb == x) continue;
		if (na == x && nb == v) continue;
		if (x == p) continue;
		dfs(x, na, nb, v);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++)
			visited[j] = false;
		dfs(0, a[i], b[i]);
		for (int j = 0; j < n; j++) {
			if (!visited[j]) {
				flag = false;
				break;
			}
		}
		ans += !flag;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3536
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

main = do
  a <- readLn :: IO Int
  b <- readLn :: IO Int
  h <- readLn :: IO Int
  print $ (a+b) * h `div` 2


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    int x, y;
    cin >> x >> y;

    vector<int> vx,vy;
    int tcount = 0;
    int fcount = 0;
    REP(i,s.size()+1) {
        if (i == s.size() || s[i] == 'T') {
            if (tcount % 2 == 0) vx.push_back(fcount);
            else vy.push_back(fcount);
            tcount++;
            fcount = 0;
        } else {
            fcount++;
        }
    }

    int tx = vx[0];
    sort(vx.rbegin(),vx.rend()-1);
    sort(RALL(vy));

    FOR(i,1,vx.size()) {
        if (x >= tx) tx += vx[i];
        else tx -= vx[i];
    }
    int ty = 0;
    REP(i,vy.size()) {
        if (y >= ty) ty += vy[i];
        else ty -= vy[i];
    }
    
    //cerr << tx << " " << ty << endl;

    ATYN(x == tx && y == ty)

    return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;cin>>n;
    vector<int> a(n);
    REP(i,n){
        int b;cin>>b;
        a[i] = b;
    }

    int x = 1, cnt = 0;;
    bool f = false;
    map<int,int> map;
    map[1]++;
    while(true) {
        cnt++;
        int next = a[x-1];

        if(next == 2) {
            f = true;
            break;
        }

        map[next]++;
        if(map[next] > 1) break;
        x = next;
    }

    if(f) cout << cnt << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    ll n,k;
    cin >> n >> k;
    ll a[n+1],index=-1;
    for(ll i=1; i<=n; i++) cin>>a[i];
    ll i=1;
    set<ll> st;
    vector<ll> vec={1};

    st.insert(1);
    for(ll m=0;m<k;m++) {
        i=a[i];
        if(st.find(i)==st.end()) {
            st.insert(i);
            vec.pb(i);
        } else {
            for(ll j=0;j<(ll)vec.size();j++) {
                if(vec[j]==i) {
                    index=j;
                    break;
                }
            }
            break;
        }
    }
    if(index==-1) {
        cout<<i;
        return;
    }
    ll offset=index, looplen = vec.size() - index;

    cout<<vec[index + (k-offset)%looplen];
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int h,w;
    cin >> h >> w;
    char blc;
    int cl[h][w];

    REP(i,h){
        int loc=-1;
        REP(j,w){
            cin >> blc;
            if(blc=='c')loc=j;
            if(loc==-1){
                cl[i][j]=-1;
            }else{
                cl[i][j]=j-loc;
            }
        }
    }

    REP(i,h){
        REP(j,w){
            cout << cl[i][j];
            if(j!=w-1)cout << " ";
        }
        cout << endl;
    }

}



Measured memory_bytes: 3108
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, t = sc.nextInt()
    val ts = Array.fill(n)(sc.nextLong())

    val ans = t.toLong * n

    var tmp = 0L

    for (i <- ts.indices) {
      if (i != 0) {
        if (ts(i) - t < ts(i - 1)) {
          tmp += ts(i - 1) - (ts(i) - t)
        }
      }
    }

    println(ans - tmp)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 70708
H,W = list(map(int,input().split()))

M = []
for i in range(H):
    M.append(list(input()))

from collections import deque

out = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for sx in range(0,W):
    for sy in range(0,H):
        if M[sy][sx]=="#":
            continue
        d = [[10**4] * W for i in range(H)]
        que = deque([])
        que.append((sy, sx))
        d[sy][sx] = 0
        while que:
            p = que.popleft()
            for i in range(4):
                ny = p[0] + dy[i]
                nx = p[1] + dx[i]
                if (0<=nx<W)and(0<=ny<H)and(M[ny][nx]!="#")and(d[ny][nx]==10**4):
                    que.append((ny, nx))
                    d[ny][nx] = d[p[0]][p[1]] + 1
                    out = max(d[ny][nx],out)
print(out)

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

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

  string s;
  cin>>s;
  VVI dp(s.size()+1,VI(13,0));
  dp[0][0]=1;
  REPS(i,s.size()){
    int c;
    if(s[i-1]!='?')c=s[i-1]-'0';
    else c=-1;
    REP(j,10){
      if(c!=-1&&c!=j)continue;
      REP(ki,13){
        int x=(ki*10+j)%13;
        dp[i][x]+=dp[i-1][ki];
        dp[i][x]%=mod;
      }
    }
  }
    
  cout<<dp[s.size()][5]<<endl;

  return 0;
}


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

int main() {
  double m,n;
  double all;
  cin>>n>>m;
  all=0;
  string ans="Yes";
  vector<int> v(n);
  for (int i=0;i<n;i++){
    cin>>v[i];
    all+=v[i];
  }
  cerr<<all;
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int cnt=0;cnt<m;cnt++){
    cerr<<v[cnt]<<all/(4*m);  
    if (v[cnt]<all/(4*m)){
      ans="No";
      break;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var n = cin.ReadInt;
            var pt = 0;
            var ph = 0;
            for(int i = 0; i < n; i++) {
                var st = cin.Read;
                var sh = cin.Read;
                switch(sh.CompareTo(st)) {
                    case 1:ph += 3;break;
                    case -1: pt += 3;break;
                    default:ph += 1;pt += 1;break;
                }
            }
            Console.WriteLine(string.Join(" ", pt, ph));
        }
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 17176
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int N;
  int x = 1;
  cin >> N;
  while (pow(x, 2) <= N) {
    x++;
  }
  cout.unsetf(ios::fixed);
  cout << int(pow(x - 1, 2)) << endl;

  return 0;
}


Measured memory_bytes: 256
def get_values():
    return [int(a) for a in input().split()]

# PROBLEM C
N, = get_values()
Xs = get_values()

Ys = sorted(Xs)
mdx = len(Ys) // 2
x2b = {x:Ys[mdx if idx < mdx else mdx - 1] for idx, x in enumerate(Ys)}
for x in Xs:
    print(x2b[x])

Measured memory_bytes: 34820
def main():
    a = int(input())
    b = int(input())

    ans_list = [1, 2, 3]
    for i in range(3):
        if ans_list[i] == a or ans_list[i] == b:
            ans_list[i] = -1
    ans = 0
    for i in range(3):
        if ans_list[i] > 0:
            ans = ans_list[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
}

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

int main(){
    int n,fcnt=0;
    cin>>n;

    while(n--){
        int a;
        cin>>a;

        int cnt=0;
        bool flag=true;
        if(a==1) flag=false;
        if(a>3){
            for(int i=2; i<=sqrt(a); i++){
                if(a%i==0) cnt++;

                if(cnt>0){
                    flag=false;
                    break;
                }
            }
        }
        if(flag) fcnt++;
    }

    cout<<fcnt<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

int main() {
  // Input
  std::string s;
  std::string t;
  std::cin >> s;
  std::cin >> t;
  const int lenS = s.length();
  const int lenT = t.length();

  // Initialization
  auto dp = vectors<int>(1 + lenS + 1, 1 + lenT + 1, -IINF);
  auto prev = vectors<int>(1 + lenS + 1, 1 + lenT + 1, -IINF);
  // 1 UPPER, 2: LEFT, 3: UPPER-LEFT

  // Initial condition
  dp[0][0] = 0;
  prev[0][0] = 0;

  // DP main
  for (int i = 0; i < lenS + 1; ++i) {
    for (int j = 0; j < lenT + 1; ++j) {
      if (chmax(dp[i + 1][j], dp[i][j]))
        prev[i + 1][j] = 1;
      if (chmax(dp[i][j + 1], dp[i][j]))
        prev[i][j + 1] = 2;
      if (s[i] == t[j] and chmax(dp[i + 1][j + 1], dp[i][j] + 1))
        prev[i + 1][j + 1] = 3;
    }
  }

  // Output
  std::string res;
  int i = lenS;
  int j = lenT;
  for (;;) {
    if (prev[i][j] == 0)
      break;
    else if (prev[i][j] == 1)
      --i;
    else if (prev[i][j] == 2)
      --j;
    else {
      assert(prev[i][j] == 3);
      assert(s[i - 1] == t[j - 1]);
      res.push_back(s[i - 1]);
      --i;
      --j;
    }
  }
  std::reverse(res.begin(), res.end());
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int n,ans;
string s;
it chk(int l,int r){
	return s[l]=='A'&&s[l+1]=='B'&&s[r]=='C';
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),cin>>s;
	for(ri i=0;i<n-2;++i)
		ans+=chk(i,i+2);
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[10]:


N,Y = map(int, input().split())


# In[12]:


if Y > N*10000 or Y < N*1000:
    print("-1 -1 -1")
else:
    for i in range(N+1):
        for j in range(N+1-i):
            k = N-i-j
            m = 10000*i+5000*j+1000*k
            if m == Y:
                print("%s %s %s"%(i,j,k))
                break
        else:
            continue
        break
    else:
        print("-1 -1 -1")


# In[ ]:






Measured memory_bytes: 8976
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

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


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
  string s;
  cin>>s;
  ll x=0;
  for (char c:s){
      x+=(c-'0');
  } 
  x%=9;
  if(x==0)cout<<"Yes"<<endl;
  else cout<< "No"<<endl;
}

Measured memory_bytes: 3728
#include "iostream"
#include "vector"
#include "set"

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); ; i --) {
        if (a % i) continue;
        if (b % i) continue;
        k--;
        if (k == 0) return !printf("%d\n", i);
    }
}

Measured memory_bytes: 256
number = raw_input().split(" ")
a, b, c = int(number[0]), int(number[1]), int(number[2])
while True:
    if a > b:
        tmp = a
        a = b
        b = tmp
    elif b > c:
        tmp = b
        b = c
        c = tmp
    else:
        print str(a) + " " + str(b) + " " + str(c)
        break

Measured memory_bytes: 4212
n,p = map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

tmp = factorization(p)
ans = 1
for i in range(len(tmp)):
    while tmp[i][1]>=n:
        tmp[i][1]-=n
        ans*=tmp[i][0]
print(ans)

Measured memory_bytes: 9328
void main() {
    string o = readln.chomp;
    string e = readln.chomp;
    string password;
    foreach (i; 0 .. e.length) {
        password ~= o[i];
        password ~= e[i];
    }
    if (o.length != e.length) password ~= o[$-1];
    password.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: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
 int a,b[110],c,d;
    
  cin >> a;
  
  for(int i=0;i<a;i++)
    cin >> b[i];
  c=100000000;
  for(int i=-100;i<=100;i++){
    d =0;
    for(int j=0;j<a;j++){
    d +=(b[j]-i)*(b[j]-i);
    }
    
    c =min(c,d);
  }
  
  cout << c << endl;
}


Measured memory_bytes: 256
using System;

class ABC073B
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		string[] vals;
		for(int i=0; i < N; i++)
		{
			vals = Console.ReadLine().Split(' ');
			ans += int.Parse(vals[1]) - int.Parse(vals[0]) + 1;
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std ;
 
int main()
{
  int N,M;
  cin >>N>>M;
  int S = 0;
  int tmp;
  for(int i= 0;i<M;i++){
    cin >>tmp;
    S +=tmp;
  }
  cout<<max(N-S,-1)<<endl;
  
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int[] a = new int[100];
		int count=0,maxcount=0;
		while(cin.hasNext()){
			a[count++]=cin.nextInt();
		}
		int[] b = new int[count];
		for(int i = 0; i < count;i++){
			b[i]=a[i];
		}
		Arrays.sort(b);
		int[][] hyou = new int[100][2];
		int cnthyou=0;
		for(int i = 0; i < b.length;){
			int dx = 1;
			count=1;
			while(true){
				if(i + dx == b.length){
					break;
				}
				if(b[i] == b[i+dx]){
					dx++;
					count++;
				}
				else{
					break;
				}
			}
			hyou[cnthyou][0]=b[i];
			hyou[cnthyou][1]=count;
			maxcount = Math.max(maxcount, count);
			i += dx;
			cnthyou++;
		}
		for(int i = 0; i < cnthyou; i++){
			if(hyou[i][1]==maxcount){
				System.out.println(hyou[i][0]);
			}
		}
	}

}

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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll k;
    string s;
    cin >>k >> s;
    if(s.length()>k){
        ll i;
        for(i=0;i<k;i++)
        cout << s[i] ;
        cout << "..." << endl;
    }
    else
    cout << s << endl;
}

Measured memory_bytes: 3644
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	x := string(slice[0])
	y := string(slice[1])
	X, _ := strconv.Atoi(x)
	Y, _ := strconv.Atoi(y)

	if 0 <= X && X <= 8 && 0 <= Y && Y <= 8 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}

}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)

using namespace std;

typedef long long ll;
const ll mod=1e9+7;

using pear = pair<int,int>;



int main(){
    int n; cin >>n;
    vector <pear> a(n);
    rep(i,n){
        cin >>a[i].first;
        a[i].second = i;
    }
    sort(a.begin(),a.end());
    rep(i,n) cout << a[i].second+1 << " ";
    cout <<endl;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P);
P dequeue(void);

int main()
{
  int elaps = 0, cnt=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++)
  {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
 
  while(tail != head)
    {      
      u=dequeue();
      
      if(u.t-q > 0)
	{
	  cnt+=q;
	  u.t = u.t-q;
	  enqueue(u);
	}
      else
	{
	  cnt+=u.t;
	  printf("%s %d\n",u.name,cnt);
	}
    }

  
  return 0;
}


void enqueue(P x)
{
  Q[tail] = x;
  if(tail+1 == LEN)tail = 0;
  else tail++;
}

P dequeue(void)
{
  P x;
  x = Q[head];
  if(head+1 == LEN)head = 0;
  else head++;
  return x;
}



Measured memory_bytes: 11888
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#define Max 100005*2
#define INF 1000000000000000000
#define getMax(a,b) a<b?b:a
#define getMin(a,b) a<b?a:b
using namespace std;



int main(){

	string s;
	int n;
	scanf("%d",&n);
	cin >> s;

	char ch;
	for(int i=0;i<s.size();i++){
		//cout << i << " " << s[i] << endl;
		ch = (((s[i]-'A')+n)%26)+'A';
		printf("%c",ch);
	}
	cout << endl;

	return 0;
}

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

int main() {
  int n,ans=0;
  cin >> n;
  string s[n+1];
  for(int i=0; i<n; i++) {
    cin >> s[i];
    s[i]+='x';
  }
  for(int i=0; i<=n; i++) s[n]+='x';
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      if(s[i-1][j-1]=='o'&&s[i][j-1]=='x'&&s[i-1][j]=='x'&&s[i][j]=='x') ans++;
    }
  }
  cout << ans/3 << endl;
  return 0;
}


Measured memory_bytes: 3208
import sys
n,m = map(int,input().split())

s = []
c = []
if m == 0:
	if n == 1:
		print("0")
		sys.exit()
for i in range(m):
	S,C = map(int,input().split())
	s.append(S)
	c.append(C)

for i in range(m-1):
	for j in range(i+1,m):
		if s[i] == s[j]:
			if c[i] != c[j]:
				print("-1")
				sys.exit()


num = 10**(n)
num_g = list(str(10**(n-1)))

for i in range(len(s)):
	num_g[s[i]-1] = str(c[i])

ans = ""
for i in range(len(num_g)):
	ans += num_g[i]

if ans[0] == "0" and n > 1:
	print("-1")
	sys.exit()

if int(ans) >= num or int(ans)<0:
	print("-1")
else:
	print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>

using namespace std;

int main()
{
    int i,j;

    for(i=1;i<10;i++)
    for(j=1;j<10;j++)
    {
        cout<<i<<"x"<<j<<"="<<i*j<<endl;
    }


    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c-min(a-b,c);

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	S := nextString()
	// Sunny, Cloudy, Rainy
	switch S {
	case "Sunny":
		fmt.Println("Cloudy")
	case "Cloudy":
		fmt.Println("Rainy")
	case "Rainy":
		fmt.Println("Sunny")
	default:
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<pair<int,int> > g[110000];
int UF[110000];
vector<pair<int,int> >G[210000];
int num[210000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;
	//if(UF[a]>UF[b])swap(a,b);
	UF[a]+=UF[b];
	UF[b]=a;
}
pair<int,pair<int,int> > edge[110000];
long long ans[110000];
int sz[210000];
int n;
int calc(int a){
	if(a<n){
		sz[a]++;
	}
	for(int i=0;i<G[a].size();i++){
		sz[a]+=calc(G[a][i].first);
	}
	return sz[a];
}
void dfs(int a,long long b){
	if(G[a].size()==2){
		dfs(G[a][0].first,b+(long long)sz[G[a][1].first]*G[a][0].second);
		dfs(G[a][1].first,b+(long long)sz[G[a][0].first]*G[a][1].second);
	}else{
		ans[a]=b;
	}
}
int main(){
	int a;scanf("%d",&a);n=a;
	for(int i=0;i<a;i++){
		num[i]=i;
	}

	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<a-1;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);p--;q--;
		edge[i]=make_pair(r,make_pair(p,q));
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	std::sort(edge,edge+a-1);
	reverse(edge,edge+a-1);
	for(int i=0;i<a-1;i++){
		int L=edge[i].second.first;
		int R=edge[i].second.second;
		if(UF[FIND(L)]>UF[FIND(R)])swap(L,R);
		
		G[a+i].push_back(make_pair(num[FIND(L)],edge[i].first));
		G[a+i].push_back(make_pair(num[FIND(R)],edge[i].first));
		UNION(L,R);
		num[FIND(L)]=a+i;
	}
	calc(a+a-2);
	dfs(a+a-2,0LL);
	for(int i=0;i<a;i++)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 24704
#include<bits/stdc++.h>
# define max 1000000
int a[max];
int a1[max];
int main()
{
    long m,n,i,j,k,l,c;
    for(i=2; i<max; i++) a[i]=1;
    k=2;
    for(i=2; i*i<=max; i++)
    {
        for(j=k+k; j<max; j=j+k) a[j]=0;
        k++;
        for(; !a[k]; k++);
    }
    a1[1]=0;
    c=1;
    for(i=2; i<max; i++)
    {
        if(a[i])
        {
            a1[i]=c;
            c++;
        }
        else a1[i]=c;
    }
    while(scanf("%ld",&n)==1)
    {
        if(n==1)
        {
            printf("0\n");
            continue;
        }
        if(a[n]) printf("%d\n",a1[n]);
        else printf("%d\n",a1[n]-1);
    }
    return 0;
}

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int K, X;
  cin >> K >>X;
  if(K * 500 >= X) {
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}  

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

using namespace std;

int f(int a, int b, char op) {

    if (op == '+') {
        return a + b;
    }
    return a - b;
}

int main() {

    int a, b;
    char op;
    cin >> a >> op >> b;

    int result = f(a, b, op);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
class Array
    def accum
        ac = Array.new(size + 1)
        ac[0] = 0
        (1..size).each do |i|
            ac[i] = ac[i-1] + self[i-1]
        end
        ac
    end

    def bsearch_last_index(l = 0, r = size - 1, &pred)
        return nil if l > r
        c = (l + r) / 2 
        if pred[self[c]]
            bsearch_last_index(c+1, r, &pred) || c
        else
            bsearch_last_index(l, c-1, &pred)
        end
    end
end

m, n = gets.split.map(&:to_i)
books = (1..m).map { gets.split.map(&:to_i) }
shelfs = (1..n).map { gets.split.map(&:to_i) }
accum = books.transpose.map(&:accum).transpose

cache = {}
tsp = Array.new(2 ** n, 0)
tsp[0] = 0
(1..2**n-1).each do |x|
    (0..n-1).each do |i|
        next if x[i] == 0
        c, b = shelfs[i]
        y = x - (1 << i)
        k = tsp[y]
        l = accum.bsearch_last_index(0, m){|aw, at| aw - accum[k][0] <= c && at - accum[k][1] <= b}
        tsp[x] = l if l > tsp[x]
    end
end
p tsp[-1]


Measured memory_bytes: 46200
#include<bits/stdc++.h>
using namespace std;
queue<long long> q;
int main()
{
	int n,ld,sum=0;
	long long tmp;
	scanf("%d",&n);
	if(n<=9)
	{
		printf("%d\n",n);
		return 0;
	}
	for(int i=1;i<=9;i++)
		q.push(i);
	while(true)
	{
		tmp=q.front();
		sum++;
		if(sum>=n)
			break;
		q.pop();
		ld=tmp%10;
		if(ld-1>=0)
			q.push(tmp*10+tmp%10-1);
		q.push(tmp*10+tmp%10);
		if(ld+1<=9)
			q.push(tmp*10+tmp%10+1);
	}
	printf("%lld\n",tmp);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<ccomplex>
#include<vector>
#include<map>
#include<string>
#include<set>
using namespace std;
#define fl(i,n)             for(int i=0;i<n;i++)
#define fit(it,x)           for(auto it=x.begin();it!=x.end();it++)
#define fll(j,n)            for(int j=n-1;j>=0;j--)
#define pb                  push_back
#define mp                  make_pair
#define f                   first
#define s                   second
#define all(x)              x.begin(),x.end()
typedef vector<int>         vi;
typedef vector<double>      vd;
typedef vector<char>        vc;
typedef vector<string>      vs;
typedef map<int, int>       mii;
typedef map<string, int>    msi;
typedef pair<int, int>      pii;
typedef set<int>            si;
typedef long long ll;
const int mod = 1000000007;
int sum = 0, max = 0, min = 0;
void solve() {
    string s, t; cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) sum++;
    }
    cout << sum;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin >> test_case;
    for (int i = 1; i <= test_case; i++) {
        solve();
        cout << endl;
    }
}


Measured memory_bytes: 3796
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=10**10
ng=1
for i in range(40):
    chk=(ok+ng)//2
    cnt=0
    for j in range(n):
        cnt+=(a[j]+chk-1)//chk-1
    if cnt > k:
        ng = chk
    else:
        ok = chk
print(ok)


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

int main(){
  int n;
  cin >> n;
  vi c(n), w(n);
  rep(i,n)cin >> c[i] >> w[i];

  vi sum(n+1,0);
  rep(i,n)sum[i+1] = sum[i] + w[i];

  vector<vi> can(n,vi(n,0));
  rep(i,n)can[i][i] = 1;

  for(int len=1;len<n;len++){
    rep(l,n-len){
      int r = l+len;
      if(can[l+1][r] && sum[r+1]-sum[l+1]<=c[l])can[l][r] = 1;
      if(can[l][r-1] && sum[r]-sum[l]<=c[r])can[l][r] = 1;
    }
  }

  vector<int> dp(n+1,n);
  dp[0] = 0;

  rep(i,n){
    rep(k,i+1){
      if(can[k][i])dp[i+1] = min(dp[i+1], dp[k]+1);
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 4964
//AT2523 Digits in Multiplication
# include <iostream>
# include <cmath>
using namespace std;
int F(int);
int main() {
    long long n; cin>>n;
    for (int i=sqrt(n); i>=1; i--) 
        if (n%i==0) {
            cout<<F(n/i);
            return 0;
        }
    return 0;
}
int F(int a) {
    int k=0;
    while (a) {
        a/=10;
        k++;
    }
    return k;
}

Measured memory_bytes: 256
# B - TAKOYAKI FESTIVAL 2019
def main():
    import itertools

    n = int(input())
    d = list(map(int, input().split()))
    sum = 0

    for v in itertools.combinations(ｄ, 2):
        sum += v[0] * v[1]
    print(sum)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
s = gets.chomp.chars
N = s.size
(N - 1).times do |i|
  s.insert(i * 2 + 1, nil)
end
a = []
(2**(N-1)).times do |i|
  d = s.dup
  sprintf("%0#{N-1}s", i.to_s(2)).chars.each.with_index do |c, j|
    if c == "1"
      d[j * 2 + 1] = "+"
    end
  end
  a << d.join
end
p eval(a.join("+"))


Measured memory_bytes: 6012