akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll>R(n+1,0),G(n+1,0),B(n+1,0);
    for(int i=1;i<=n;i++){
        if(s.at(i-1)=='R'){
            R.at(i)=1;
        }
        if(s.at(i-1)=='G'){
            G.at(i)=1;
        }
        if(s.at(i-1)=='B'){
            B.at(i)=1;
        }
        R.at(i)+=R.at(i-1);
        G.at(i)+=G.at(i-1);
        B.at(i)+=B.at(i-1);
    }
    ll ans = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
           ll d = j-i;
            char z = s.at(i),zz=s.at(j);
            string t ="";
            t+=z;
            t+=zz;
            sort(t.begin(),t.end());
            if(t=="BG"){
                ans+=R.at(n)-R.at(j);
                            if(d+j>=n)continue;
                if(s.at(d+j)=='R')ans--;
            }
            if(t=="BR"){
                ans+=G.at(n)-G.at(j);
                            if(d+j>=n)continue;
                if(s.at(d+j)=='G')ans--;
            }
            else if(t=="GR") {
                ans+=B.at(n)-B.at(j);
                            if(d+j>=n)continue;
                if(s.at(d+j)=='B')ans--;
            }
    }
    }
    cout << ans << endl;
}
    



Measured memory_bytes: 3704
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n,m,a,b,ant=1000000000,key,ch[100000];
vector<ll>v[100000],ans;
map<ll,ll>mp;
void f(ll n){
    for(ll x:v[n]){
        //cout<<x<<" "<<ch[x]<<endl;
        if(ch[x]==0){
            ch[x]=1;
            ans.push_back(x+1);
            f(x);
            return ;
        }
    }
    return ;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    for(auto xx:mp){
        if(ant>xx.S){
            ant=xx.S;
            key=xx.F;
        }
    }
    //cout<<key<<"W"<<endl;
    //cout<<"KE"<<key<<endl;
    ch[key-1]=1;
    ans.push_back(key);
    f(key-1);
    ll tmp=ans.size();
    //cout<<endl;
    f(key-1);
    ll N=ans.size();
    cout<<N<<endl;
    for(int i=0;i<N-tmp;i++){
        cout<<ans[N-i-1]<<" ";
    }
    for(int i=0;i<tmp;i++){
        cout<<ans[i]<<" ";;
    }
    cout<<endl;
}


Measured memory_bytes: 17400
n = int(input())
p = []

for _ in range(n):
    x,y = map(int, input().split())
    p.append([x,y])

import math
import itertools

if n == 2:
    print(math.sqrt((p[0][0]-p[1][0])**2 + (p[0][1]-p[1][1])**2)/2)
    exit()

def rad(v):
    p1 = v[0]
    p2 = v[1]
    p3 = v[2]
    x1 = p1[0]
    y1 = p1[1]
    x2 = p2[0]
    y2 = p2[1]
    x3 = p3[0]
    y3 = p3[1]
    
    px = (y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2)
    if (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3)) == 0:
        return None
    px = px / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
    
    py = (x1-x3)*(x1**2-x2**2+y1**2-y2**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2)
    if (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3)) == 0:
        return None
    py = py / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))

    return [px,py,(x1-px)**2+(y1-py)**2]

ans = 10**13

for v in itertools.combinations(p,2):
    p1 = v[0]
    p2 = v[1]
    px = (p1[0]+p2[0])/2
    py = (p1[1]+p2[1])/2
    rr = (p1[0]-p2[0])**2+(p1[1]-p2[1])**2
    rr = rr /4
    chk = True
    for i in range(n):
        if (p[i][0]-px)**2+(p[i][1]-py)**2 > rr + 10**(-6):
            chk = False
    if chk:
        ans = min(ans,rr**0.5)

for v in itertools.combinations(p,3):
    d = rad(v)
    if d == None:
        continue
    chk = True
    for i in range(n):
        if (p[i][0]-d[0])**2+(p[i][1]-d[1])**2 > d[2] + 10**(-6):
            chk = False
    if chk:
        ans = min(ans,d[2]**0.5)

print(ans)


Measured memory_bytes: 45548
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
map<ll,ll>::iterator itr ;
ll ans ;
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  cin>>a>>b ;
  cout<<a*b ;
  return 0; }

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

using namespace std;

signed main()
{
    //mdsaqib;
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int m=t.size();
    int ans=1005;
    for(int i=0; i<n-m+1; i++)
    {
        int temp=0;
        for(int j=0; j<m; j++)
        {
            if(s[i+j]!=t[j])temp++;
        }
        ans=min(ans,temp);
    }
    cout << ans;
}



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

int main() {
	int N;
	ll K;
	cin >> N >> K;
	map<int, ll> mp;
	for (int i = 0; i < N; ++i) {
		int a;
		ll b;
		cin >> a >> b;
		mp[a] += b;
	}

	ll sum = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		if (sum + it->second >= K) {
			cout << it->first << endl;
			break;
		} else {
			sum += (it->second);
		}
	}

	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
const int MAX = 1000000;
const ll mod  = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
/*
ll red(ll a, ll b)
{
    if (a == 1 || b == 1) {
        return 1;
    }

    ll ret = red(a - 2, b - 1);
    ret += red(a - 1, b - 2);

    return ret;
}
*/
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1]            = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i]  = fac[i - 1] * i % mod;
        inv[i]  = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(ll n, ll k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void)
{
    COMinit();
    ll x, y;
    cin >> x >> y;
    if (2 * y - x < 0 || 2 * x - y < 0) {
        cout << 0 << endl;
        return 0;
    }
    if ((2 * y - x) % 3 || (2 * x - y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    ll a   = (2 * y - x) / 3;
    ll b   = (2 * x - y) / 3;
    ll sum = 1;
    /* rep(i, a)
     {
         sum *= ((a + b - i));
         //  sum %= mod;
     }
     rep(i, a) { sum /= (i + 1); }
     */
    cout << COM(a + b, a) << endl;
    return 0;
}



Measured memory_bytes: 23680
def cost(n,clist):
  for k in range(0,10):
    for i in range(0,10):
      for j in range(0,10):
        clist[i][j] = min(clist[i][j],clist[i][k]+clist[k][j])
  
  return clist[n][1]

def joisino(a,clist):
  note = [-1,0,-1,-1,-1,-1,-1,-1,-1,-1]
  answer = 0
  for raw in a:
    for number in raw:
      if number != -1:
        if note[number] == -1:
          note[number] = cost(number,clist)
        answer += note[number]
      
  return answer

def i_o():
  h, w = map(int,input().split(" "))
  i = 0 
  clist = []
  while i < 10:
    raw = list(map(int,input().split(" ")))
    clist.append(raw)
    i += 1
  a = []
  i = 1
  while i <= h:
    raw = list(map(int,input().split(" ")))
    a.append(raw)
    i += 1
  return h,w,clist,a

if __name__ == '__main__':
  h,w,clist,a = i_o()
  ans =joisino(a,clist)
  
  print(ans, flush=True)

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

int main() {
    string S; cin >> S;
    int ret = 0;

    for (int i = 0; i < S.size(); i += 2){
        if(S[i] == 'L'){
            ret = 1;
        }
    }
    for (int i = 1; i < S.size(); i += 2){
        if(S[i] == 'R'){
            ret = 1;
        }
    }

    if(ret == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint N, A;
llint x[55];

const llint bias = 2502;
llint dp[55][5005];

int main(void)
{
	cin >> N >> A;
	for(llint i = 1; i <= N; i++){
		cin >> x[i];
		x[i] -= A;
	}
	
	dp[0][bias] = 1;
	for(llint i = 1; i <= N; i++){
		for(llint j = 0; j < 5005; j++){
			dp[i][j] = dp[i-1][j];
			if(j - x[i] >= 0 && j - x[i] < 5005) dp[i][j] += dp[i-1][j-x[i]];
		}
	}
	
	cout << dp[N][bias] - 1 << endl;
	return 0;
}

Measured memory_bytes: 2176
require 'pp'
require 'set'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)
b_n = gets.chomp!.split(" ").map(&:to_i)

count = 0
n.times do |i|
    if b_n[i] >= a_n[i]
        tmp = a_n[i]
        count += tmp
        a_n[i] = 0
        b_n[i] -= tmp
    else
        tmp = b_n[i]
        count += b_n[i]
        b_n[i] = 0
        a_n[i] -= tmp
    end

    if b_n[i] > 0
        if b_n[i] >= a_n[i+1] 
            tmp = a_n[i+1]
            count += tmp
            a_n[i+1] = 0
            b_n[i] -= tmp
        else
            tmp = b_n[i]
            count += b_n[i]
            b_n[i] = 0
            a_n[i+1] -= tmp
        end
    end

    #pp a_n
    #pp b_n
end

#pp a_n
#pp b_n
puts count


Measured memory_bytes: 15916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 
int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,i,x;

sfl(n);

x=(n+1)/2;
cout<<(x*1.0)/n;
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

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

int main() {
  string T;cin>>T;
  rep(i,T.size()){
    if(T[i]=='?') T[i]='D';
  }
  cout << T << endl;
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL n;
    LL ans=0;
    cin >> n;

    for(LL i=1; i<=n; i++){
        LL tmp=n/i;
        ans=ans+(tmp*(tmp+1)*i)/2;
    }

    cout << ans << endl;

    return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

using pint = pair<int, int>;

int N;
vector<vector<pint>> v;

bool judge(int bit){
    rep(i, N){
        if(!(bit & (1 << i)))
            continue;
        else{
            for(pint xy: v[i]){
                int x = xy.first;
                int y = xy.second;
                if(y == 1 && !(bit & (1 << x)))
                    return false;
                if(y == 0 && (bit & (1 << x)))
                    return false;
            }
        }
    }
    return true;
}
 
int main(void){
    cin >> N;
    v.resize(N);
    rep(i, N){
        int A;
        cin >> A;
        v[i].resize(A);
        rep(j, A){
            cin >> v[i][j].first >> v[i][j].second;
            v[i][j].first--;
        }
    }

    int res = 0;
    for(int bit = 0; bit < (1 << N); bit++){
        if(judge(bit)){
            int count = 0;
            rep(i, N)
                if(bit & (1 << i))
                    count++;
            res = max(res, count);
        }
    }

    cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool Y = false;
  cin >> N;
  for(int i = 0;i < N;i++){
    string S;
    cin >> S;
    if(S == "Y"){
      Y = true;
      break;
    }
    else{}  
  }
  if(Y)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n,x;
  cin >> n >> x;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
 
  ll result = 0;
  ll buf = 10000;
  
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  
  for(i=0;i<n;i++){
    chmin(buf,a[i]);
    x -= a[i];
  }
  cout << n+x/buf << endl;
  

  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_a

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll Mo, Do, Mt, Dt;
  cin >> Mo >> Do >> Mt >> Dt;

  if (Mo == Mt)
    drop(0);
  else
    drop(1);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
a = list(str(input()))
b = list(str(input()))
c = list(str(input()))

from collections import deque
a = deque(a)
b = deque(b)
c = deque(c)

t = a.popleft()
while True:
  if t == 'a':
    if len(a) == 0:
      print('A')
      exit()
    else:
      t = a.popleft()
  elif t == 'b':
    if len(b) == 0:
      print('B')
      exit()
    else:
      t = b.popleft()
  else:
    if len(c) == 0:
      print('C')
      exit()
    else:
      t = c.popleft()

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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; }

vector<lli> d[100100];

void func(lli now){
	printf("%06d",now);
}

int main(){

	lli n,m;
	cin>>n>>m;
	vector<lli> p(m),y(m);
	REP(i,0,m){
		cin>>p[i]>>y[i];
		d[p[i]].push_back(y[i]);
	}

	REP(i,0,100100){
		if(d[i].size()==0)continue;
		SORT(d[i]);
	}

	REP(i,0,m){
		vector<lli> &v = d[p[i]];
		lli cnt = (lli)(lower_bound(v.begin(),v.end(),y[i]) - v.begin());
		func(p[i]);
		func(cnt+1);
		cout<<endl;
	}


    return 0;
}


Measured memory_bytes: 10300
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int mod;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
using Vm = vector<mint>;


VV G;
vector<Vm> dp;
mint dfs(int u, int p=-1) {
  mint res = 1;
  int d = G[u].size();
  dp[u] = Vm(d);
  rep(i, d) {
    int v = G[u][i];
    if (v == p) continue;
    dp[u][i] = dfs(v, u);
    res *= dp[u][i];
  }
  res += 1;
  return res;
}


Vm ans;
void dfs2(int u, mint x, int p=-1) {
  int d = dp[u].size();
  rep(i, d) if (G[u][i] == p) dp[u][i] = x;

  Vm l = dp[u], r = dp[u];
  rep(i, d-1) l[i+1] *= l[i];

  for (int i = d-2; i >= 0; --i) r[i] *= r[i+1];
  rep(i, d) {
    int v = G[u][i];
    if (v == p) continue;
    mint y = 1;
    if (i > 0) y *= l[i-1];
    if (i < d-1) y *= r[i+1];
    dfs2(v, y+1, u);

  }
  ans[u] = l[d-1];
}


int main() {
  int N; cin >> N >> mod;
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

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

  dp = vector<Vm>(N);
  ans = Vm(N);

  dfs(0);
  dfs2(0, 1);

  rep(i, N) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

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

    int n = s.size();

    lint dp[13] = {};
    dp[0] = 1;

    int mul = 1;

    for (int i = n-1; i >= 0; i--) {
        char c = s[i];

        lint next_dp[13] = {};

        if (c == '?') {
            rep(k, 10) {
                rep(j, 13) {
                    next_dp[(k * mul + j) % 13] += dp[j];
                    next_dp[(k * mul + j) % 13] %= MOD;
                }
            }
        }
        else {
            int k = c - '0';
            rep(j, 13) {
                next_dp[(k * mul + j) % 13] += dp[j];
                next_dp[(k * mul + j) % 13] %= MOD;
            }
        }

        rep(i, 13) dp[i] = next_dp[i];

        mul *= 10;
        mul %= 13;
    }

    cout << dp[5] << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		pw.println(A+B+C-Math.max(A, Math.max(B, C)));
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

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

const int N = 1e5 + 10;

int par[N], sz[N];
int cnt;

int find_parent(int x) {
  par[x] = (par[x] == x ? x : find_parent(par[x]));
  return par[x];
}

void merge(int x, int y) {
  x = find_parent(x);
  y = find_parent(y);
  if (x == y) {
    return;
  }
  if (rand() & 1) {
    par[x] = y;
    sz[y] += sz[x];
  } else {
    par[y] = x;
    sz[x] += sz[y];
  }
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  srand(time(NULL));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < N; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  vector<int> from(m), to(m);
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i];
    from[i]--; to[i]--;
  }
  vector<long long> ans;
  ans.push_back(1LL * n * (n - 1) / 2);
  for (int i = m - 2; i >= 0; i--) {
    int u = from[i + 1], v = to[i + 1];
    if (find_parent(u) == find_parent(v)) {
      ans.push_back(ans.back());
    } else {
      long long A = sz[find_parent(u)];
      long long B = sz[find_parent(v)];
      ans.push_back(ans.back() - A * (n - A) - B * (n - B) + A * B + (A + B) * (n - A - B));
      merge(u, v);
    }
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < m; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
typedef pair<int, int> P;
int H, W;
char maze[30][30];
int d[30][30];
int sx, sy, gx, gy;

int bfs() {
  rep(i, H) rep(j, W) d[i][j] = inf;
  queue<P> q;
  q.push(P(sx, sy));
  d[sy][sx] = 0;

  while(!q.empty()) {
    P p = q.front(); q.pop();
    if(p.first == gx && p.second == gy) break;
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] != '#' && d[ny][nx] == inf) {
        q.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }
  return d[gy][gx];
}

int main() {
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> maze[i][j];

  int res = 0;
  rep(i, H) {
    rep(j, W) {
      rep(k, H) {
        rep(l, W) {
          sy = i, sx = j;
          gy = k, gx = l;
          if(maze[sy][sx] == '#' || maze[gy][gx] == '#') continue;
          res = max(res, bfs());
        }
      }
    }
  }
  cout << res << endl;

  return 0;
}


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

def main():
    *S, = map(str, open(0).read().split())
    S = S[0]
    S_re = S[::-1]
    N = len(S)
    S_s1 = S[:(N-1)//2]
    S_s2 = S[(N+2)//2:]

    if (S == S_re
        and S_s1 == S_s1[::-1]
        and S_s2 == S_s2[::-1]):
        print('Yes')
    else:
        print('No')


main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int>a(3);
cin >> a[0]>>a[1]>>a[2];
sort(a.begin(),a.end());
cout << (a[0]==5 and a[1]==5 and a[2]==7?"YES":"NO")<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
#define fi first
#define se second
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  char ch=gc();
  while(!isdigit(ch)) ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return ans;
}
const int N=50001;
bitset<N>trans[N],tmp;
pii a[N<<1];
int n,m,op,tar[N],ct[N];
bool dir[N<<1],ok[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),m=read(),op=read();
  for(ri i=1;i<=m;++i) a[i].fi=read(),a[i].se=read();
  if(op==1) {
    for(ri i=1;i<=n;++i) trans[i][i]=1;
    for(ri i=m;i;--i) {
      tmp=trans[a[i].fi]|trans[a[i].se];
      trans[a[i].fi]=trans[a[i].se]=tmp;
    }
    tmp=trans[1];
    for(ri i=2;i<=n;++i) tmp&=trans[i];
    bool ff=0;
    for(ri i=1;i<=n;++i) if(tmp[i]) { ok[i]=1,ff=1;break; }
    if(!ff) puts("-1");
    else {
      for(ri x,y,i=m;i;--i) {
        x=a[i].fi,y=a[i].se;
        if(ok[x]&&!ok[y]) dir[i]=1;
        else dir[i]=0;
        if(ok[x]||ok[y]) ok[x]=ok[y]=1;
      }
      for(ri i=1;i<=m;++i) cout<<(dir[i]?'^':'v');
    }
  }
  else {
    if(n<3) puts("-1");
    else {
      for(ri i=1;i<=n;++i) tar[i]=i,ct[i]=1;
      for(ri x,y,i=m;i;--i) {
        x=a[i].fi,y=a[i].se;
        if(tar[x]==tar[y]) dir[i]=0;
        else if(ct[tar[x]]>1) {
          dir[i]=0;
          --ct[tar[x]];
          ++ct[tar[x]=tar[y]];
        }
        else {
          dir[i]=1;
          --ct[tar[y]];
          ++ct[tar[y]=tar[x]];
        }
      }
      for(ri i=1;i<=m;++i) cout<<(dir[i]?'^':'v');
    }
  }
  return 0;
}

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

typedef long long ll;

int main()
{
    int i,j,k;
    int n,x;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0){
            return 0;
        }
        ll ans = 0;
        for(i = 1;i <= n-2;++i){
            for(j = i+1;j <= n-1;++j){
                for(k = j+1;k <= n;++k){
                    int sum = i+j+k;
                    if(sum == x){
                        ++ans;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
 
public class Program
{
	public static Int64 sum(Dictionary<String, Int64> nums)
	{
		Int64 sum = 0;
		foreach (KeyValuePair<String, Int64> item in nums)
		{
			sum += item.Value * Convert.ToInt64(item.Key);
		}
 
		return sum;
	}
 
	public static void Main(String[] args)
	{
		var numbers = new Dictionary<String, Int64>();
		Int64 numberOfElements = Convert.ToInt64(Console.ReadLine());
		Int64 prevSum = 0;
		foreach (String x in Console.ReadLine().Split(' '))
		{
			if (numbers.ContainsKey(x))
			{
				numbers[x] += 1;
			}
			else
			{
				numbers.Add(x, 1);
			}
			prevSum += Convert.ToInt64(x);
		}
 		Int64 numOfOperations = Convert.ToInt64(Console.ReadLine());
		for (Int64 i = 0; i < numOfOperations; ++i)
		{
			String[] x = Console.ReadLine().Split(' ');
			if (numbers.ContainsKey(x[0]))
			{
              	prevSum += ((Convert.ToInt64(x[1]) - Convert.ToInt64(x[0])) * numbers[x[0]]);
				Console.WriteLine(prevSum);
				if (numbers.ContainsKey(x[1]))
					numbers[x[1]] += numbers[x[0]];
				else
					numbers[x[1]] = numbers[x[0]];
				numbers[x[0]] = 0;
			}
			else
				Console.WriteLine(prevSum);
		}
	}
}


Measured memory_bytes: 57028
#include<stdio.h>
 int main(){

  int a,b,d,r;
  double f;

  scanf("%d %d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  printf("%d %d %f\n",d,r,f);

return 0;
}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n,m;
  cin >> n >>m;
  cout << (n+m+1)/2 <<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
	int key;
	struct node *prev;
	struct node *next;
} Node;

Node *nil;
void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key) {
	Node *cur = nil->next;
	while(cur != nil && cur->key != key)
		cur = cur->next;
	return cur;
}

void deleteNode(Node *t)
{
	if(t == nil)
		return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if(cur == nil) {
			break;
		}else {
			if(isf++ > 0)
				printf(" ");
			printf("%d", cur->key);
			cur = cur->next;
		}
	}
	printf("\n");
}

int main()
{	
	int i, n;
	int key;
	char com[15];
	scanf("%d", &n);

	init();

	for(i = 0; i < n; i++) {
		scanf("%s %d", com, &key);
		if (com[0] == 'i') {
			insert(key);
		}
		else if(com[0] == 'd') {
			if(com[6] == 'F')
				deleteFirst();
			else if(com[6] == 'L')
				deleteLast();
			else
				deleteKey(key);
		}
	}

	printList();

    return 0;
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
int gcd(int,int);
int main(){
  int n,x;
  int mp[100000];
  int ans;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>mp[i];
  }
  for(int i=0;i<n;i++){
    if(i==0) ans=abs(x-mp[i]);
    else ans=gcd(ans,abs(x-mp[i]));
  }
  for(int i=0;i<n-1;i++){
     ans=gcd(ans,abs(mp[i+1]-mp[i]));
  }
  cout<<ans<<endl;
  return 0;
}
int gcd(int x,int y){
  int z;
  while(0 != y){
    z=y;
    y=x%y;
    x=z;
  }
  return x;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	static int[][] f = new int[21][21];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n==0)break;
			
			for(int i=0;i<=20;i++) {
				for(int j=0;j<=20;j++)
					f[i][j] = 0;
			}
			boolean ans = true;
			for(int i=0;i<n;i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				f[x][y] = 1;
			}
		
			int m = sc.nextInt();
			int x=10;
			int y=10;
			for(int i=0;i<m;i++) {
				char a = sc.next().charAt(0);
				int d = sc.nextInt();
				switch(a) {
				case 'N':
					for(int k=y;k<=y+d;k++) {	
						f[x][k] = 0;
					}
					y += d;
					break;
				case 'E':
					for(int k=x;k<=x+d;k++) {
						f[k][y] = 0;
					}
					x += d;
					break;
				case 'S':
					for(int k=y;k>=y-d;k--) {
						f[x][k] =0;
					}
					y -= d;
					break;
				case 'W':
					for(int k=x;k>=x-d;k--) {
						f[k][y] =0;
					}
					x -= d;
					break;
				}
			}
			
			for(int i=0;i<=20;i++) {
				for(int j=0;j<=20;j++)
					if(f[i][j] != 0) {
						ans = false;
						break;
					}
				if(!ans)break;
			}
		
			if(ans)System.out.println("Yes");
			else System.out.println("No");
			
		}
		
	}
}


Measured memory_bytes: 44632
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
	vite;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	double d,t,s;
	cin>>d>>t>>s;
	d=d/t;
	if(s>=d) cout<<"Yes";
	else cout<<"No";
	cout<< endl;
	// cout<< fixed << setprecision(6) << 1.0 * clock() / CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 3692
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k1;
	cin>>n>>k1;
	vector<int>arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;i+j<=min(n,k1);j++)
		{
			vector<int>tmp;
			for(int k=0;k<i;k++)
			{
				tmp.eb(arr[k]);
			}
			for(int k=0;k<j;k++)
			{
				tmp.eb(arr[n-k-1]);
			}
			sort(tmp.begin(),tmp.end());
			int rej=k1-(i+j);
			while(rej>0 && !tmp.empty() && tmp.front()<0)
			{
				tmp.erase(tmp.begin());
				rej--;
			}
			int sum=0;
			for(auto &x:tmp)
			    sum+=x;
			ans=max(ans,sum);
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(void){
    char a, b;
    cin >> a >> b;
    
    char ans;
    if(a=='H') {
        if(b=='H'){
            ans = 'H';
        }else{
            ans = 'D';
        }
    }else{
        if(b=='H'){
            ans = 'D';
        }else{
            ans = 'H';
        }
    }
 
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import heapq

n,m = map(int,input().split())
l = list(map(int,input().split()))
s = sum(l)
for i in range(n):
    l[i] *= (-1)

heapq.heapify(l)

discount = 0

for i in range(m):
    x = (-heapq.heappop(l))
    heapq.heappush(l,-(x//2))
    discount += (x-x//2)

print(s-discount)

Measured memory_bytes: 83352
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;


int main()
{
    int N, D;
    cin >> N >> D;
    int** matrix;
    matrix = new int*[N];
    for (int i = 0; i < N; i++)
    {
        matrix[i] = new int[D];
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> matrix[i][j];
        }
        
    }
    int* array;
    array = new int[D];
    int counter = 0;


    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            for (int k = 0; k < D; k++)
            {
                array[k] = matrix[i][k]-matrix[j][k];
            }
            int sum= 0;
            for (int k = 0; k < D; k++)
            {
                sum = sum+ array[k]*array[k];
                
            }
            int num = sqrt(sum);
            if(sum == num*num) counter++;
            
        }
        
    }
    cout << counter << endl;

    /*for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cout << matrix[i][j];
        }
        cout << endl;
    }*/
}

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

int main()
{
  double v0;
  while (scanf("%lf ", &v0) == 1) {
    cout << (int)((v0 * v0)/ (5.0 * 4.0 * 4.9)) + 2 << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define N 200000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (998244353);
ll a[maxn],b[maxn];
int main(){
    int n;scanf("%d",&n);
    ll sum = 0;
    for(int i = 1;i <= n;i++){
        scanf("%lld",&a[i]);sum ^= a[i];
    }
    for(int i = 1;i <= n;i++){
        ll b = (sum ^ a[i]);printf("%lld%c",b,(i == n ? '\n' : ' '));
    }
    return 0;
}

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

int main()
{

  string s;
  cin >> s;
  for(int i=0;i<4;i++)
    cout<< s[i];
 	cout << " ";
  for(int i=4;i<s.size();i++)
	cout << s[i];
  cout << endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int ten[100001],tt[100001];
priority_queue<P> qu;
int main(void)
{
	int n,r,l;

	P ppp;
	int t1,n1,i,j,nn;
	int d,t,x,max,maxi;

	scanf("%d %d %d",&n,&r,&l);
	for(i=1;i<=n;i++)	{
		ten[i]=0;
		tt[i]=0;
		qu.push(P(0,100000-i));
	}
	n1=1;
	t1=0;
	
	for(i=0;i<r;i++)	{
		scanf("%d %d %d",&d,&t,&x);
		tt[n1]+=t-t1;
		ten[d]+=x;
		qu.push(P(ten[d],100000-d));
		t1=t;
		while(1)	{
			ppp=qu.top();
			nn=100000-ppp.second;
			if(ten[nn]==ppp.first)	{
				n1=nn;
				break;
			}
			qu.pop();
		}
//		printf("n1=%d t1=%d\n",n1,t1);
	}
	tt[n1]+=l-t1;
	max=-1;
	for(i=1;i<=n;i++)	{
		if(tt[i]>max)	{
			max=tt[i];
			maxi=i;
		}
	}
	printf("%d\n",maxi);
	return 0;
}


Measured memory_bytes: 11600
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
  //happy coding

  string s;
  string t;
  cin>>s>>t;
	vector<int>m[27];
  for(int i=0;s[i];i++){
  	m[s[i]-'a'].pb(i);
  }

  for(int i=0;t[i];i++){
  	if(m[t[i]-'a'].size()==0){
  		cout<<-1<<endl;
  		return 0;
  	}
  }
  int n = s.size();
  int idx = -2;
  int sum = 0;
  for(int i=0;t[i];i++){
  	auto x = lower_bound(all(m[t[i]-'a']),idx+1);
  	if(x != m[t[i]-'a'].end()){
  		idx = *x;
  	}else{
  		sum ++;
  		idx = m[t[i]-'a'][0];
  	}
  }

  cout<<sum*s.length()+idx+1<<endl;

  
  return 0;
}
int main(){
  int test = 1;
  //scanf("%d", &test);
  while (test--)solve();return 0;
} 


Measured memory_bytes: 1216
n,m = map(int, input().split())
a = list(map(int, input().split()))
xy=[list(map(int,input().split())) for i in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())

uf = UnionFind(n)
for x,y in xy:
    uf.union(x,y)

g=uf.group_count()

if g==1:
    print(0)
    exit()

if n<(g-1)*2:
    print("Impossible")
    exit()

ans=0
all_costs=[]

from collections import defaultdict
costs=defaultdict(list)
for i in range(n):
    costs[uf.find(i)].append(a[i])

for k,v in costs.items():
    v.sort()
    ans+=v[0]
    all_costs.extend(v[1:])

all_costs.sort()
ans+=sum(all_costs[:(g-2)])

print(ans)


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

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

using namespace std;
using lint=long long;

int main(){
	lint n,m; cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1 && m==1){
		cout<<1<<endl;
	}
	else if(n==1){
		cout<<m-2<<endl;
	}
	else{
		cout<<(n-2)*(m-2)<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  int h[n]; for(int i = 0; i < n; i++) cin >> h[i];
  int i;
  for(i = 0; i < n - 1; i++){
    if(h[i] < h[i + 1]) h[i + 1]--;
    else if(h[i] > h[i + 1]) break;
  }
  if(i == n - 1) cout << "Yes\n";
  else cout << "No\n";
  return;
}

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


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main()
{
  long int n;
  long int k;

  scanf("%ld", &n);
  scanf("%ld", &k);

  long int a = n % k;
  long int b = k - a;

  if (a > b)
  {
    printf("%ld", b);
  }
  else
  {
    printf("%ld\n", a);
  }
}

Measured memory_bytes: 1728
m, k = map(int, input().split())
if m==1 and k==0:
    print(0,0,1,1)
    exit()
if m==k==1:
    print(-1)
    exit()

if 2**m<=k:
    print(-1)
    exit()
ans = [k]
for i in range(2**m):
    if i != k:
        ans.append(i)
ans.append(k)
for i in reversed(range(2**m)):
    if i != k:
        ans.append(i)
print(*ans)


Measured memory_bytes: 21648
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    M, *DC = map(int, read().split())

    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c

    ans = digits - 1 + (total - 1) // 9

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 112172
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 dp[101][100001];

struct product
{
    int v;
    int w;
};

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

    int N, W;
    cin >> N >> W;

    vector< product > pr(N + 1);
    pr[0].v = pr[0].w = 0;
    s64 vsum = 0;
    s64 wsum = 0;
    for (int i = 1; i <= N; ++i)
    {
        cin >> pr[i].w >> pr[i].v;
        vsum += pr[i].v;
        wsum += pr[i].w;
    }

    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= vsum; ++j)
        {
            dp[i][j] = wsum;
        }
    }

    dp[0][0] = 0;
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 0; j <= vsum; ++j)
        {
            if (j < pr[i].v)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = MIN(dp[i - 1][j], dp[i - 1][j - pr[i].v] + pr[i].w);
            }
        }
    }

    int j;
    for (j = vsum; j >= 0 && dp[N][j] > W; --j);
    cout << j << "\n";
    return 0;
}



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

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

int main()
{
	int n,k,s;
	vector<int> h;

	cin >> n >> k;
	rep(i, n)
	{
		cin >> s;
		h.push_back(s);
	}

	int ans = 0;
	rep(i, h.size())
	{
		if(h[i] >= k)
		{
			ans++;
		}
	}

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


Measured memory_bytes: 892