akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int,int>

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


int dp[100010];
int INF=INT_MAX;

int main(){
  int n;
  cin>>n;
  for(int i = 0; i <= n; i++){
    dp[i]=INF;
  }
  dp[0]=0;
  //dp
  for(int i=1; i <=n; i++){
    if(i>=1) chmin(dp[i],dp[i-1]+1);
    if(i>=6) chmin(dp[i],dp[i-6]+1);
    if(i>=9) chmin(dp[i],dp[i-9]+1);
    if(i>=36) chmin(dp[i],dp[i-36]+1);
    if(i>=81) chmin(dp[i],dp[i-81]+1);
    if(i>=216) chmin(dp[i],dp[i-216]+1);
    if(i>=729) chmin(dp[i],dp[i-729]+1);
    if(i>=1296) chmin(dp[i],dp[i-1296]+1);
    if(i>=6561) chmin(dp[i],dp[i-6561]+1);
    if(i>=7776) chmin(dp[i],dp[i-7776]+1);
    if(i>=46656) chmin(dp[i],dp[i-46656]+1);
    if(i>=59049) chmin(dp[i],dp[i-59049]+1);
  }
  cout<<dp[n]<<endl;
}



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int D;
    cin >> D;

    string day[4] = {"Christmas", "Christmas Eve", "Christmas Eve Eve", "Christmas Eve Eve Eve"};

    cout << day[25 - D] << endl;
    return 0;
}

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

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll G[base10_5+10];
vll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
ll getMod(ll value,ll mod){
    if(value == 0) return 0;
    if(mod==0) return -1;
    value %= mod;
    if(value<0) value += mod;
    return value;
}
#include <queue>
//https://cpprefjp.github.io/reference/queue/priority_queue/pop.html
//std::priority_queue<ll> que;
//que.push(val);
//ll getv = que.top();
//que.pop();
//typedef pair<ll,ll> P;  
//priority_queue<P,vector<P>, greater<P> > que;
//que.push(P(0,base_index));
ll visited[base10_6]={};
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> K;

    rep(ni,N-1){
        ll mi,mj;
        cin >> mi >> mj;
        G[mi].push_back(mj);
        G[mj].push_back(mi);
    }
    ll max2=0;
    for( ll ni = 1 ; ni <=N ; ni++ ){
        max2 = llmax( max2, G[ni].size() );
    }    
    
    ll ans = 1;
    ans *= K;
    ans = getMod(ans,MOD);
    visited[1]=1;

    priority_queue<ll> nexti;
    ll ki = K-1;
    rep(mi,G[1].size()){
        ll ni = G[1][mi];
        if(visited[ni]==0){
            ans *= ki;
            ki--;
            ans = getMod(ans,MOD);
            nexti.push(ni);
            visited[ni]=1;
        }
    }
    //cout << ans << endl;
    while(nexti.size()>0){
        ll index = nexti.top();
        nexti.pop();
        ki = K-2;
        rep(mi,G[index].size()){
            ll ni = G[index][mi];
            if(visited[ni]==0){
                //cout << ni  << " " << ki << endl;
                ans *= ki;
                ki--;
                ans = getMod(ans,MOD);
                nexti.push(ni);
                visited[ni]=1;
            }
        }
        //cout << index << endl;
    }

    cout << ans << endl;

}

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

int main(){

  int N; cin >> N;
  
  vector<int> len(N);
  
  for(int i = 0; i < N; i++){
    cin >> len[i];
  }
   
  int sum = 0 ; //全ての辺の和
  int max =*max_element(len.begin(),len.end()); //最長辺
  
  for(int i = 0; i < N; i++){
    sum += len[i];
  }
  
  if(max < sum - max){
    cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  
  return 0;
}
  

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

int max(int a,int b){
    if(a>=b){
        return a;
    }
    else{
        return b;
    }
}

long long int maxll(long long int c,long long int d){
    if(c>=d){
        return c;
    }
    else{
        return d;
    }
}

int min(int a,int b){
    if(a>=b){
        return b;
    }
    else{
        return a;
    }
}

long long int minll(long long int c,long long int d){
    if(c>=d){
        return d;
    }
    else{
        return c;
    }
}

int main(void){ 
    int N,i;
    long long int fmax=-1000000000000;
    long long int A[1000000];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
    }
    long long int mina=A[0];
    for(i=1;i<N;i++){
        fmax=maxll(fmax,A[i]-mina);
        mina=minll(mina,A[i]);
    }
    printf("%lld\n",fmax);
    return 0;
}



Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
    cin>>s;
    for (int i=0;i<s.size();i++){
        if (s[i]=='7'){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void dfs(vector<int>vtr[],int s,int dp[],int vis[])
{
    vis[s]=1;
    int i;
    for(i=0;i<vtr[s].size();i++)
    {
    	int x=vtr[s][i];
    	if(vis[x]==0)
    	{
    		dfs(vtr,x,dp,vis);
    	}
    	dp[s]=max(dp[s],1+dp[x]);
    }
}
using namespace std;
int main() 
{
    int n,m;
    cin>>n>>m;
    int vis[n+5]={0};
    vector<int>vtr[n+1];
    int x,y;
    int i;
    for(i=0;i<m;i++)
    {
    	cin>>x>>y;
    	vtr[x].push_back(y);
    }
    int ans=0,dp[n+3]={0};
   for(i=1;i<=n;i++)
   {
   	if(vis[i]==0)
   	{
          dfs(vtr,i,dp,vis);
   	}
   }
   	for(i=1;i<=n;i++)
   		ans=max(ans,dp[i]);
   
   cout<<ans;
}

Measured memory_bytes: 13272
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, B = map(int, input().split())

    print(A + B) if A + B < 24 else print((A + B) % 24)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10396
#include <stdio.h>
#include <string.h>
int main(){
    char mirror[256];
    fgets(mirror,sizeof(mirror),stdin);
    int i=0,j,count=0;
    j=strlen(mirror)-1;
    for(i;i<(j/2);i++){
        if(mirror[i]!=mirror[j-1-i]){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int A,B; cin >> A >> B;
    if (A+B >= 10) cout << "error"; else cout  << A+B;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    print(solve(n, m))

def solve(n, m):
    a = m
    b = m + n - 1

    if a >= 0 and b >= 0:
        return sum(range(a + 1, b + 1))
    elif a < 0 and b < 0:
        return sum(range(a, b))
    else:
        return sum(range(a, b + 1))

main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>

int x[50];

// N-1枚選んだときに整数がMになる
int64_t dp[50][2501];

int main() {
	int n, a;
	std::cin >> n >> a;

	for (int i = 0; i < n; ++i)
		std::cin >> x[i];

	for (int i = 0; i < n; ++i) {
		for (int j = i; j >= 1; --j) {
			for (int k = 1; k <= 2500; ++k) {
				if (dp[j - 1][k] != 0)
					dp[j][k + x[i]] += dp[j - 1][k];
			}
		}
		++dp[0][x[i]];
	}

	int64_t ans = 0;
	for (int i = 0; i < n; ++i)
		ans += dp[i][a * (i + 1)];

	std::cout << ans << std::endl;
}

Measured memory_bytes: 640
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=998244353;
vector<vec> G;


main(){
    string s;cin>>s;
    ll k=lin();
    if(s[0]==s[s.size()-1]){
      int nw=0;
      while(nw<s.size()&&s[nw]==s[0])nw++;
      if(nw==s.size()){
        cout<<(k*(ll)nw)/2<<endl;
        return 0;
      }
      ll ans=0;
      rep2(i,nw,s.size()-1){
        int now=i;
        int cnt=0;
        while(now<s.size()&&s[now]==s[i]){now++;cnt++;}
        if(now==s.size())cnt+=nw;
        ans+=(cnt)/2;
        if(now==s.size())
        ans=(ans*k+(nw)/2+(cnt-nw)/2-cnt/2);
        i=now-1;
      }
      cout<<ans;
    }
    else{
      ll ans=0;
      rep(i,s.size()){
        int now=i;
        int cnt=0;
        while(now<s.size()&&s[now]==s[i]){now++;cnt++;}
        ans+=(cnt)/2;
        if(now==s.size())
        ans=ans*k;
        i=now-1;
      }
      cout<<ans<<endl;
    }
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

int N;
int ans = 0;
vector<int> v;

int main(){
	cin>>N;
	for(int i=1; i<N; i++){
		int x; scanf("%d", &x);
		v.pb(x);
		if(v.size()==1){
			ans += x;
		}else{
			ans += min(x, v[v.size()-2]);
		}
		if(i==N-1){
			ans += x;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define ll long long
#define rep(i,l,r,d) for(ll i=(l);i<(r);i+=(d))
#define max(p,q) ((p)>(q)?(p):(q))
int main(void){
    ll X, ANS=1;
    scanf("%lld", &X);
    ll root = sqrt(X) + 1;
    rep(i, 2, root, 1){
        ll a=i*i;
        while (a<=X) {
            ANS = max(ANS, a);
            a *= i;
        }
    }
    printf("%lld\n", ANS);
    return 0;
}


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

typedef long long ll;

int n;




int main(){
	cin >> n;
	vector<int> v(n+1);
	vector<int> res;
	vector<int> sum(n+1);
	for(int i=1;i<=n;++i){
		cin >> v[i];
		sum[i] = 0;
	}



	bool f = true;
	for(int i=n;i>0;i--){
		//cout << i << " " <<sum[i] << " " << v[i] << endl;
		if(sum[i]%2 == v[i]){
		//	cout << " --  "<<  i <<endl;
		}else{
			res.push_back(i);
			for(int j=1;j*j<=i;++j){
				if(i%j == 0){
					sum[j] += 1;
					if(j != i/j)sum[i/j] += 1;
				}
			}
			sum[i]++;
		}
	}/*
	cout << "--" <<endl;
		for(int i=1;i<=sum.size();++i){
			cout << sum[i] <<endl;
		}
	cout << "--" <<endl;*/

	if(f){
		cout << res.size() <<endl;
		for(int i=0;i<res.size();++i){
			cout << res[i] <<endl;
		}
	}
	else{
		cout << -1 <<endl;
	}




	return 0;
}



Measured memory_bytes: 3064
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    n, k = get_int_multi()
    a_list = get_int_list()

    p_list=[]
    m_list=[]
    for num in a_list:
        if num > 0:
            p_list.append(num)
        else :
            m_list.append(num)


    p_list.sort()
    m_list.sort(reverse=True)


    if k % 2 == 1:
        if (len(p_list) > 0):
            ans = p_list.pop()
            k -= 1
        else:
            m_list.sort()
            ans = m_list.pop()
            k -= 1
    else:
        ans = 1

    nokori = k
    while nokori > 0:
        if len(p_list) == 1 and len(m_list) == 1:
            ans = ans * p_list.pop() * m_list[0]
            del m_list[0]
            nokori -= 2
        else:
            if len(p_list) >= 2:
                pval = p_list[-1] * p_list[-2]
            else:
                pval = 0

            if len(m_list) >= 2:
                mval = m_list[-1] * m_list[-2]
            else:
                mval = 0

            if pval > mval:
                p_list.pop()
                p_list.pop()
                ans = ans * pval % 1000000007
            else:
                m_list.pop()
                m_list.pop()
                ans = ans * mval % 1000000007
            nokori -= 2

    print(ans % 1000000007)

if __name__ == '__main__':
    main()




Measured memory_bytes: 31996
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


signed main(){
	int R, G;
	cin >> R >> G;

	cout << 2*G-R << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin>>N>>T>>A;
  vector<tuple<double,int>> tem;
  for(int i=0;i<N;i++){
    int H;
    cin>>H;
    double temperature=T-H*0.006;
    double TEM = A-temperature;
    if(TEM<0){
      TEM=-TEM;
    }
    tem.push_back(tie(TEM,i));
  }
  sort(tem.begin(),tem.end());
  cout<<get<1>(tem.at(0))+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 1e2 + 5;

int n, W;
int w[N], v[N];
int dp[N][3*N];
int ndp[N][3*N];

int main() {
    cin >> n >> W;
    REP(i, n) {
        cin >> w[i] >> v[i];
    }

    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        memset(ndp, -1, sizeof ndp);
        for (int k = 0; k <= n; k++) {
            for (int d = 0; d <= 3*k; d++) {
                if (dp[k][d] == -1) continue;

                ndp[k][d] = max(ndp[k][d], dp[k][d]);

                LL totw = (LL)k * w[0] + d;
                LL newd = totw + w[i] - (LL)(k+1) * w[0];
                if (totw + w[i] > W) continue;
                if (k+1 > n) continue;
                ndp[k+1][newd] = max(ndp[k+1][newd], dp[k][d] + v[i]);
            }
        }
        for (int k = 0; k <= n; k++) {
            for (int d = 0; d <= 3*k; d++) {
                dp[k][d] = ndp[k][d];
                if (i == n-1) {
                    ans = max(ans, dp[k][d]);
                }
            }
        }
    }

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






























Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

#define phb push_back
#define mkp make_pair
#define frs first
#define scn second
#define sz(x) int((x).size())
using namespace std;

const int kInf = 1000000000;
typedef pair< int, int > Pr;
typedef pair< int, Pr > Prr;

int N, M;
Prr E[50010];
vector< int > NE;

int nset[510];

void read();
void solve();
int kruskal(int);

int find_set(int x) {
  if (~nset[x])
    return nset[x] = find_set(nset[x]);
  return x;
}

void union_set(int x, int y) {
  nset[find_set(y)] = find_set(x);
}

bool cmpf(const Prr &, const Prr &);

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

void read() {
  int u, v, c;

  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> u >> v >> c;
    E[i] = mkp(c, mkp(u, v));
  }
}

void solve() {
  int res, mcst, csum;

  stable_sort(&E[0], &E[M], cmpf);
  mcst = kruskal(-1);

  res = csum = 0;
  for (int i = 0; i < N - 1; ++i)
    if (kruskal(NE[i]) > mcst)
      ++res, csum += E[NE[i]].frs;

  cout << res << " " << csum << "\n";
}

int kruskal(int fid) {
  fill(&nset[0], &nset[510], -1);

  int i, j, ret = 0;

  if (fid == -1) {
    for (i = j = 0; i < M && j < N - 1; ++i) {
      int u = E[i].scn.frs, v = E[i].scn.scn;

      if (find_set(u) != find_set(v))
        ret += E[i].frs, union_set(u, v), ++j, NE.phb(i);
    }
  }
  else {
    for (i = j = 0; i < M && j < N - 1; ++i) {
      if (i == fid) continue;

      int u = E[i].scn.frs, v = E[i].scn.scn;

      if (find_set(u) != find_set(v))
        ret += E[i].frs, union_set(u, v), ++j;
    }
  }

  return j == N - 1 ? ret : kInf;
}

bool cmpf(const Prr &ra, const Prr &rb) {
  return ra.frs < rb.frs;
}

Measured memory_bytes: 2064
# -*- coding: utf-8 -*-
import math
str_a, str_b = input().split()
a = int(str_a)
b1 = int(str_b[0])
b01 = int(str_b[2])
b001 = int(str_b[3])

product_1 = a * b1
product_01 =  a * b01
product_001 = a * b001


tmp_result = product_1 * 100 + product_01 * 10 + product_001
str_result = str(tmp_result)
if len(str_result) < 3:
    result = 0
else:
    result = str_result[0:-2]

print(result)


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

int main() {
  int D; cin >> D;
  string res;
  if (D == 25) res = "Christmas";
  else if (D == 24) res = "Christmas Eve";
  else if (D == 23) res = "Christmas Eve Eve";
  else res = "Christmas Eve Eve Eve";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;

int pot (ll q, ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q*= qw;
	return q;
}

ll n,k;
vector <long double> rj;
long double p[200200],maks = -99999999;

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

cin >> n >> k;

for (int i = 0; i<n; i++)
	cin >> p[i];
	
rj.push_back(0);

for (int i = 0; i<k; i++)
	rj[0] += (p[i]+1)/2;

int br = 1;

for (int i = k; i<n; i++){
	rj.push_back(rj[br-1]-(p[i-k]+1)/2);
	rj[br] += (p[i]+1)/2;
	br++;
}

for (int i = 0; i<rj.size(); i++)
	maks = max (maks, rj[i]);

cout << fixed << maks;

return 0;
}



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

int H, W;

void solve(vector<string> &board, vector<vector<int>> &min_vv, int x, int y, int &ans, int count, bool streak){
  // 無効な移動を省く
  if(x < 0 || x > W-1 || y < 0 || y > H-1) return;
  if(board.at(y).at(x) == '#')
  {
    if(streak);
    else
    {
      count++;
      streak = true;
    }
  }
  else streak = false;
  if(count >= min_vv.at(y).at(x)) return;
  min_vv.at(y).at(x) = count;
  // 再帰パターン
  solve(board, min_vv, x+1, y, ans, count, streak);
  solve(board, min_vv, x, y+1, ans, count, streak);
}

int main(){
  cin >> H >> W;
  vector<string> board(H);
  vector<vector<int>> min_vv(H, vector<int>(W, 10000));
  for (int i = 0; i < H; i++)
  {
    cin >> board.at(i);
  }
  int ans = 10000;
  solve(board, min_vv, 0, 0, ans, 0, false);
  cout << min_vv.at(H-1).at(W-1) << endl;
  return 0;
}

Measured memory_bytes: 256
bs = { 
  'A' => [[1,1],[1,1]],
  'B' => [[1],[1],[1],[1]],
  'C' => [[1,1,1,1]],
  'D' => [[0,1],[1,1],[1,0]],
  'E' => [[1,1,0],[0,1,1]],
  'F' => [[1,0],[1,1],[0,1]],
  'G' => [[0,1,1],[1,1,0]]
}

while true
  c = Array.new
  while true
    s = gets
    break if s.nil?
    s = s.chomp.split('').map(&:to_i)
    break if s.size == 0
    next if s.inject(:+) == 0
    c.push(s)
  end

  break if c.size == 0

  (c[0].size - 1).downto(0).each { |x| 
    s = 0 
    c.each { |r| s += r[x] }
    c.each { |r| r.delete_at(x) } if s == 0
  }

  bs.each { |k, b|
    if b.size == c.size && b[0].size == c[0].size
      r = (0..b.size - 1).map { |y| b[y] == c[y] }.uniq
      puts k if r.size == 1 && r[0]
    end 
  }
end

Measured memory_bytes: 2652
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;


int main() {
	string S;
	cin >> S;
	if (S[0] == '7' || S[1] == '7' || S[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
N,A,B,C,D = list(map(int, input().split()))
S = input()

flg = '##' in S[A-1:C] or '##' in S[B-1:D]
if C > D and not flg:
  f,e = max(A-1,B-2),min(D+1,N)

  flg = not '...' in S[f:e]
print("No" if flg else "Yes")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	ll arr[3*n];
	rep(i,0,3*n)
	cin>>arr[i];
	ll ans=0;
	ll i=3*n-2;
	ll cnt=0;
	sort(arr,arr+3*n);
	 while(cnt<n)
	 {
	 	ans+=arr[i];
	 //	cout<<ans<<" "<<i<<endl;
	 	i-=2;
	 	cnt++;
	 }
	cout<<ans;
}






Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N, M;
    cin >> N >> M;
    vector<int> A(N, 0);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[a]++;
        A[b]++;
    }

    REP(i, N) {
        cout << A[i] << endl;
    }
    return 0;
}

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

double f(double x){
  double s;
  s = - x * x + 6 * x + 8;
  return s;
}

int main() {
  int a, b ,c;
  cin >> a >> b ;
  
  c = a * b;
  
  cout << c << endl;
  
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();

		int ans = 0;
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N; j++) {
				int tmp = N - R * i - G * j;
				if (tmp >= 0 && tmp % B == 0) ans++;
			}
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 23764
from collections import deque
N=int(input())
A=[int(i) for i in input().split()]
def f(K):
    L=deque()
    L.append([0,A[0]])
    for i in range(N-1):
        #print(L)
        if A[i]<A[i+1]:
            L.append([0,A[i+1]-A[i]])
            continue
        t=A[i]-A[i+1]
        while t-L[-1][1]>=0:
            t-=L[-1][1]
            L.pop()
            #print(L)
        L[-1][1]-=t
        #if L[-1][1]==0:
            #L.pop()
        if L[-1][0]!=K-1:
            if L[-1][1]==1:
                L[-1][0]+=1
            else:
                L[-1][1]-=1
                L.append([L[-1][0]+1,1])
        else:
            s=0
            while len(L)!=0 and L[-1][0]==K-1:
                s+=L[-1][1]
                L.pop()
            if len(L)==0:
                return False
            elif L[-1][1]==1:
                L[-1][0]+=1
                L.append([0,s])
            elif L[-1][1]!=1:
                L[-1][1]-=1
                L.append([L[-1][0]+1,1])
                L.append([0,s])
    #print(L)
    return True



mi=0
ma=2*10**5+1
while ma-mi>1:
    mid=(ma+mi)//2
    if f(mid):
        ma=mid
    else:
        mi=mid
print(ma)


Measured memory_bytes: 204200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    Yn(s + t[t.size()-1] == t);

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

struct QueueItem {
  ulli x, d;
  QueueItem(ulli x, ulli d) : x(x), d(d) {}
};

int main()
{
  ulli K;
  std::cin >> K;
  
  std::vector<bool> v(K + 1, false);
  
  std::deque<QueueItem> q;
  q.emplace_back(1, 1);
  
  ulli ans = MAX_ULLI;
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop_front();
    v[item.x] = true;
    
    if (item.x == 0) {
      ans = std::min(ans, item.d);
      break;
    }
    
    if ((item.d <= ans) && !v[(item.x * 10) % K]) {
      q.emplace_front((item.x * 10) % K, item.d);
    }
    
    if ((item.d <= ans) && !v[(item.x + 1) % K]) {
      q.emplace_back((item.x + 1) % K, item.d + 1);
    }
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n;
	cin >> n;
	vector<ll>v(n), s;
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	s = v;
	for (int i = n - 2; i >= 0; --i) {
		s[i] += s[i + 1];
		s[i] %= mod;
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		ans += v[i] * s[i + 1];
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 5956
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int d[N + 1];
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        d[i] = readInt();
    }
    sort(d + 1, d + n + 1);
    cout << d[n / 2 + 1] - d[n / 2];
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int Get(string S) {
	int sum = 0;
	for (int i = 0; i < S.size() - 1; ++i) {
		if (S[i] == 'A' && S[i + 1] == 'B') {
			sum++;
		}
	}
	return sum;
}
int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	int T;
	cin >> K >> T;
	priority_queue<int> A;

	rep(i, 0, T) {
		int a;
		cin >> a;
		A.push(a);
	}
	int x = A.top();
	A.pop();
	while (!A.empty()) {
		int y = A.top();
		A.pop();
		if (x > y) {
			x -= y;
			continue;
		}
		y -= x;
		x = y;

	}
	if (x > 0) {
		cout << x - 1;

	}
	else
		cout << 0;
	return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll A,B,M;
    ll a[100010],b[100010],c[100010];
    ll d[100010];
    ll x[100010],y[100010];
    cin>>A>>B>>M;
    ll minb=LLINF;
    rep(i,A) cin>>a[i];
    rep(i,B){
        cin>>b[i];
        chmin(minb,b[i]);
    }
    rep(i,B) d[i]=b[i];
    vector<pll> mp[100010];
    rep(i,M){
        cin>>x[i]>>y[i]>>c[i];
        x[i]--,y[i]--;
        mp[x[i]].pb(pll(y[i],c[i]));
    }
    ll ans=LLINF;
    rep(i,A){
        ll cost=a[i]+minb;
        rep(j,(ll)mp[i].size()){
            chmin(cost,a[i]+b[mp[i][j].fi]-mp[i][j].sc);
        }
        chmin(ans,cost);
    }
    cout<<ans<<endl;




}

 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

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

const int MAXV = 100010;
using UnWightedGraph = vector<vector<int> >;
template <typename G>
struct StronglyConnectedComponents {
    const G &g;
    UnWightedGraph gg, rg;
    vector<int> comp, order, used;
    StronglyConnectedComponents(G &g)
        : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
        for (int i = 0; i < g.size(); i++) {
            for (auto e : g[i]) {
                gg[i].push_back((int)e);
                rg[(int)e].push_back(i);
            }
        }
    }
    int operator[](int k) { return comp[k]; }

    void dfs(int idx) {
        if (used[idx]) return;
        used[idx] = true;
        for (int to : gg[idx]) dfs(to);
        order.push_back(idx);
    }

    void rdfs(int idx, int cnt) {
        if (comp[idx] != -1) return;
        comp[idx] = cnt;
        for (int to : rg[idx]) rdfs(to, cnt);
    }

    void build(UnWightedGraph &t) {
        for (int i = 0; i < gg.size(); i++) dfs(i);
        reverse(order.begin(), order.end());
        int ptr = 0;
        for (int i : order) {
            if (comp[i] == -1) rdfs(i, ptr), ptr++;
        }
        t.resize(ptr);
        for (int i = 0; i < g.size(); i++) {
            for (auto &to : g[i]) {
                int x = comp[i], y = comp[to];
                if (x == y) continue;
                t[x].push_back(y);
            }
        }
    }
};

int main() {
    int v, e, q;
    cin >> v >> e;
    UnWightedGraph g(v), buff;
    for (int i = 0; i < e; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
    }
    StronglyConnectedComponents<UnWightedGraph> scc(g);
    scc.build(buff);
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        cout << (scc[a] == scc[b] ? 1 : 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 5124
n = gets.to_i
as = gets.split(" ").map(&:to_i)

sum = 0
prev = 0
n.times do |i|
  sum += (prev - as[i]).abs
  prev = as[i]
end
sum += as[-1].abs

prev = 0
n.times do |i|
  if i+1 == as.size
    puts sum - (prev - as[i]).abs - as[i].abs + prev.abs
  elsif prev < as[i+1] && as[i+1] < as[i]
    puts sum - (as[i+1] - as[i]).abs * 2
  elsif prev > as[i+1] && as[i+1] > as[i]
    puts sum - (as[i+1] - as[i]).abs * 2
  elsif prev < as[i] && as[i] > as[i + 1]
    puts sum - (prev - as[i]).abs * 2
  elsif prev > as[i] && as[i] < as[i + 1]
    puts sum - (prev - as[i]).abs * 2
  else
    puts sum
  end

  prev = as[i]
end

Measured memory_bytes: 11540
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
https://atcoder.jp/contests/abc075/tasks/abc075_c?lang=ja

*/
struct UnionFind {
vector<int> d;
UnionFind(int n=0): d(n,-1) {}
int find(int x) {
  if (d[x] < 0) return x;
  return d[x] = find(d[x]);
}
bool unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return false;
  if (d[x] > d[y]) swap(x,y);
  d[x] += d[y];
  d[y] = x;
  return true;
}
bool same(int x, int y) { return find(x) == find(y);}
int size(int x) { return -d[find(x)];}
};


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);

  UnionFind uf(n);

  REP(i,m){
    int ax, bx;
    cin >> ax >> bx;
    --ax; --bx;
    a[i] = ax;
    b[i] = bx;
  }

  vector<ll> noconnect(m+1);
  REP(i,m+1) noconnect[i] = 0;
  noconnect[m] = (ll)n*(n-1)/2;
  //uf.unite(a[m-1],b[m-1]);

  for(int i = m-1; i >= 0; --i){
    if(uf.same(a[i],b[i])){
      noconnect[i] = noconnect[i+1];
      //uf.unite(a[i],b[i]);
    }
    else{
      noconnect[i] = noconnect[i+1] - (uf.size(a[i]) * uf.size(b[i]));
    }
    uf.unite(a[i],b[i]);
  }


  REP2(i,1,m+1) cout << noconnect[i] << endl;

  return 0;
}


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

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    
    int num = 0;
    num = ((r * 100) + (g * 10) + (b * 1));

    if (num % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

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

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if (a+b+c)%2 == 0 && max(a, b, c) == (a+b+c)/2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}


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

    cout << min(c, b / a);

    return 0;
}



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

int main(){
  string s;
  cin >> s;
  
  long cnt_z = 0, cnt_a = 200000;
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      cnt_a = i;
      break;
    }
  }
  for(long i = 0; i < s.size(); i++){
    if(s[i] == 'Z'){
      cnt_z = max(i, cnt_z);
    }
  }
  
  cout << cnt_z - cnt_a + 1 << endl;
}
      
  

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] x = new int[5];
        Arrays.setAll(x, i -> sc.nextInt());
        sc.close();
        
        for (int i = 0; i < 5; i++) {
            if (x[i] == 0) {
                System.out.println(i+1);    
                break;
            }
        }
    }
}



Measured memory_bytes: 35704
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,K,X;
    int ans=0;
    cin>>K>>X;

    FOR(i,X-K+1,X+K-1){
        Out(i);
    }

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 3e5+23;

vector<pair<int, int>> v;
int H[N], W[N];

void solve() {
  int h, w, m; scanf("%d%d%d", &h, &w, &m);
  int a = 0, b = 0;
  for (int i = 0; i < m; ++i) {
    int x, y; scanf("%d%d", &x, &y);
    v.emplace_back(--x, --y);
    ++H[x];
    a = max(a, H[x]);
    ++W[y];
    b = max(b, W[y]);
  }
  int cnt = 0;
  for (const auto &e: v) {
    cnt += (H[e.first]+W[e.second]) == (a+b);
  }
  int cntH = 0, cntW = 0;
  for (int i = 0; i < h; ++i)
    cntH += (H[i] == a);
  for (int i = 0; i < w; ++i)
    cntW += (W[i] == b);
  if (1LL*cntH*cntW > cnt)
    printf("%d", a+b);
  else
    printf("%d", a+b-1);
}

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


Measured memory_bytes: 9816
x1,y1,x2,y2=gets.chomp.split(' ').map(&:to_i)
x,y=x2-x1,y2-y1
x,y=-y,x
x3,y3=x2+x,y2+y
x,y=-y,x
x4,y4=x3+x,y3+y
puts [x3,y3,x4,y4].join(' ')

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            double bunbo = 0.0;

            for(int i =0; i<n; i++)
            {

                bunbo += 1.0 / double.Parse(s[i]);
            }

            Console.WriteLine(1.0 / bunbo);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
LL ans=0;
int a[N],mi[N];
void solve (int l,int r)
{
	if (l==r) return ans+=a[l],void ();
	int mid=(l+r)>>1;
	mi[mid+1]=a[mid+1];
	for (int i=mid+2; i<=r; i++)
		mi[i]=min (mi[i-1],a[i]);
	mi[mid]=a[mid];
	for (int i=mid-1; i>=l; i--)
		mi[i]=min (mi[i+1],a[i]);
	for (int i=mid+1,j=mid+1; i<=r; i++)
	{
		while (j> l&&mi[i]< mi[j-1]) --j;
		ans+=(LL)mi[i]*(mid-j+1);
	}
	for (int i=mid,j=mid; i>=l; i--)
	{
		while (j< r&&mi[i]< mi[j+1]) ++j;
		ans+=(LL)mi[i]*(j-mid);
	}
	solve (l,mid),solve (mid+1,r);
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	for (int i=1; i<=n; i++)
		sc(a[i]);
	solve (1,n);
	pr(ans);

    return 0;
}

Measured memory_bytes: 4992