akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
// void rec(int val,map<int,int>&mp,int chk)
// {
//     if(val<=chk) return 0;
//     if(mp.count(val)) return mp[val];
//     if(val>chk)
//     {
//         int l=rec((val+1)/2,mp,chk);
//         int r=rec((val)/2,mp,chk);
//         return mp[val]=l+r+1;
//     }

// }
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll lo=1;
    ll hi=a[0];
    //cout<<hi<<endl;
    auto chk=[&](ll val){
        ll v=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]<=val) break;
            else
            {
                ll z=a[i];
                
                v+=z/val;

                
            }
            

        }
        return v;

    };
    ll ans;
    //cout<<chk(4)<<endl;
    if(k==0) 
    {
        cout<<hi<<endl;
        return 0;
    }
    while(lo<=hi)
    {
        ll m=lo+(hi-lo)/2;
        ll cal=chk(m);
        if(cal>k) lo=m+1;
        else 
        {
            ans=m;
            hi=m-1;

        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4836
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  ll X; cin >> X;
  for(ll i = 1;; i++){
    if(i * (i+1) / 2 >= X){
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int n;
vector<int> a,ans,dp,used;
vector<vector<int>> g;

void dfs(int cur){
	used[cur] = 1;
	int pos = lower_bound(all(dp), a[cur]) - dp.begin();
	int ret;
	if(pos==dp.size()){
		ret = -1;
		dp.push_back(a[cur]);
	}else{
		ret = dp[pos];
		dp[pos] = a[cur];
	}

	ans[cur] = dp.size();

	for(auto x:g[cur]){
		if(used[x]==0) dfs(x);
	}

	if(ret==-1){
		dp.pop_back();
	}else{
		dp[pos] = ret;
	}
}


int main()
{
	cin>>n;
	a.resize(n);
	ans.resize(n,1);
	used.resize(n,0);
	rep(i,n) cin>>a[i];
	g.resize(n);
	rep(i,n-1){
		int u, v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	dfs(0);

	rep(i,n)cout<<ans[i]<<endl;


	return 0;
}

Measured memory_bytes: 25024
using System;


public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var count = 0;
        for (int i = a; i < b + 1; i++)
            if (c % i == 0) count++;
        Console.WriteLine(count);
    }
}



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

const int MAX_W = 100;
int h,w;
char orchard[MAX_W][MAX_W];
bool counted[MAX_W][MAX_W];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

void dfs(int i, int j, char tree) {
  // cout << "depth i=" << i << " j=" << j << endl;
  // 今いるところが果樹園の外か、treeでないならreturn
  if (i < 0 || i >= h || j < 0 || j >= w || counted[i][j] || tree != orchard[i][j])
    return;
  // 今いる場所のcountedをtrueにする
  counted[i][j] = true;

  // 4方向に進む
  for (int k = 0; k < 4; k++) {
    dfs(i + dy[k], j + dx[k], tree);
  }
}

int main() {
  // ifstream ifs( "test.txt" );

  while (true) {
    // 入力
    cin >> h >> w;
    if (!(h | w))
      break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> orchard[i][j];
        counted[i][j] = false;
      }
    }
    // 計算
    int res = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (!counted[i][j]) {
          char tree = orchard[i][j];
          dfs(i, j, tree);
          res++;
        }
      }
    }

    // 出力
    cout << res << endl;
  }
}

Measured memory_bytes: 1648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>
using namespace std;
const bool debug=false;
const bool INJUDGE=false;
#define FASTERCIN cin.tie(0);ios_base::sync_with_stdio(false)
typedef long long ll;
/*Time:
Status:
Type:
Author:*/
int a,b,c;
ll k; 
int main(){
	cin>>a>>b>>c>>k;
	if(k&1)cout<<b-a; else cout<<a-b;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch 0Or1Swap | diff 0Or1Swap.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 0Or1Swap.cpp && ./a.out

/*
 
 7/27/2019
 
 5:04-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  int cnt=0;
  REP(i,N) cnt+=A[i]!=(i+1);
  if(cnt<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

void insertionSort(char *A,int N);

int main(void)
{
    char A[4 * 1000 + 99] = {};
    int N;
    
    scanf("%d\n",&N);
    fgets(A, 4 * 1000 + 99, stdin);
    insertionSort(A, N);

	return 0;
}

void insertionSort(char *B,int N)
{
    int A[100];
    int i = 0;
    char *p;
    int v = 0;
    int j = 0;
    int k;
    
    p = B;
    
    p = strtok(p, " ");
    
    while(p != NULL){
        A[i] = atoi(p);
        p = strtok(NULL, " ");
        i++;
    }
    
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        
        for(k = 0; k < N; k++){
            printf("%d",A[k]);
            if(k != N-1){
                printf(" ");
            }
        }
        printf("\n");
        
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
    }
    
    for(k = 0; k < N; k++){
        printf("%d",A[k]);
        if(k != N-1){
            printf(" ");
        }
    }
    printf("\n");
    
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
long long a, b;
int main(){
	scanf("%lld%lld", &a, &b);
	long long ans = 0;
	
	if(b - a <= 10)
		for(long long i = a ; i <= b; ++i)
			ans ^= i;
	
	else{
		while(a % 4)
			ans ^= a++;
		while(b % 4 != 3)
			ans ^= b--;	
	}
	
	printf("%lld\n", ans);	
	return 0;
}
 

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int i,x[7];
    char o[101];
    
    for(i=1;i<7;i++) scanf("%d",&x[i]);
    
    scanf("%s",o);
        
    for(i=0;o[i]!='\0';i++){
        x[0]=x[1];
        
        switch(o[i]){
            
            case 'W':
                x[1]=x[3];
                x[3]=x[6];
                x[6]=x[4];
                x[4]=x[0];
                break;
            
            case 'E':
                x[1]=x[4];
                x[4]=x[6];
                x[6]=x[3];
                x[3]=x[0];
                break;
            
            case 'S':
                x[1]=x[5];
                x[5]=x[6];
                x[6]=x[2];
                x[2]=x[0];
                break;
            
            case 'N':
                x[1]=x[2];
                x[2]=x[6];
                x[6]=x[5];
                x[5]=x[0];
                break;
        }
    }
           
    printf("%d\n",x[1]);
    
    return 0;
}


Measured memory_bytes: 2052
// https://atcoder.jp/contests/abc109/tasks/abc109_d
#include <iostream>
#include <vector>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, t;
    cin >> h >> w;
    vector<vector<int>> v(h);
    REP(i, h) REP(j, w) {
        cin >> t;
        v[i].push_back(t);
    }
    bool coin = false;
    vector<pii> ans, tmp;
    REP(i, h) REP(j, w) {
        int k = (i % 2 == 0 ? j : (w - j - 1));
        if (coin) {
            tmp.push_back({i + 1, k + 1});
        }
        if (v[i][k] % 2 == 1) {
            if (coin) {
                coin = false;
                ans.insert(ans.end(), ALL(tmp));
                tmp.clear();
            } else {
                coin = true;
            }
        }
        if (coin) {
            tmp.push_back({i + 1, k + 1});
        }
    }
    // 最後に移動させるためにボールを持ったまま終わることを考慮
    cout << ans.size() / 2 << "\n";
    REP(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << (i % 2 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> V(M);
    rep(i,M) {
        cin >> V[i];
    }
    int j = 0;
    while(V[j] < X) {
        j++;
    }
    cout << min(j,M - j) << endl;
}



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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, k, h[100009];
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    int dp[100009];
    fill(dp, dp + n, 1e9);
    dp[0] = 0;

    rep(i, n) FOR(j, 1, k + 1) {
        if(i + j >= n) break;
        chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
/*______________________________________________________

エラトステネスの篩という素数を見つけるアルゴリズムを仕様

素数には1合成数には0が代入されている
________________________________________________________*/


#include<stdio.h>

int poyo[1000000];

int main(void){
	int i, j;
	int n, ans;

	poyo[0] = 0; poyo[1] = 0;
	for (i = 2; i <= 1000000; i++){
		poyo[i] = 1;
	}

	for (i = 2; i*i <= 1000000; i++){
		for (j = i * 2; j <= 1000000; j += i){
			poyo[j] = 0;
		}
	}

	while (scanf("%d", &n) != EOF){
		ans = 0;
		for (i = 0; i <= n; i++){
			if (poyo[i] == 1) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int maxN = 2e5 + 2;

ll a[maxN], b[maxN];

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	int sol = 0;
	for(int i = 0, j = m; i <= n; i++){
		if(a[i] > k) break;
		while(a[i] + b[j] > k) j--;
		sol = max(sol, i + j);
	}
	cout << sol << '\n';
}


Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char a, b;
    cin >> a >> b;
    cout << (a == b ? 'H' : 'D');
}


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

int main(void) {
    int n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) cout << 0 << endl;
    else {
        long long a, b = 1;
        for (int i = 1; i <= max(n, m); i++) {
            b = b * i % 1000000007;
            if (i == min(n, m)) a = b;
        }
        if (a == b) cout << a * b % 1000000007 * 2 % 1000000007 << endl;
        else cout << a * b % 1000000007 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

#define MAX_V 500000//調節！！！！！！！！！！！！！！！！！！！！！！！！
struct edge{ll to,cost;};
ll d[MAX_V];//頂点sからの最短距離
ll V;//頂点数！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
vector<edge>G[MAX_V];
void dijkstra(ll s){
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;//firstは最短距離、secondは頂点の番号
    fill(d,d+V+1,inf);//頂点番号は0~V-1でも1~Vでもお好きな方で
    d[s]=0;
    que.push(l_l(0,s));
    while(!que.empty()){
        //greater<l_l>なのでfirstが小さい順に取り出せる！
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        for(ll i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(l_l(d[e.to],e.to));
            }
        }
    }
}
////////////////////////////////////////
struct line{
    ll p,q,c;
};

int main(){
    ll n,m;cin>>n>>m;
    vector<line>v;
    vector<ll>t[n];
    rep(i,0,n-1)t[i].pb(0);
    rep(i,1,m){
        ll p,q,c;cin>>p>>q>>c;
        p--;q--;
        t[p].pb(c);
        t[q].pb(c);
        line l{p,q,c};
        v.pb(l);
    }
    rep(i,0,n-1)sort(t[i].begin(),t[i].end());
    ll num[n+1];num[0]=0;
    rep(i,0,n-1)num[i+1]=num[i]+t[i].size();
    V=num[n];
    rep(i,0,n-1){
        rep(j,num[i]+1,num[i+1]-1){
            edge e{j,1};
            G[num[i]].pb(e);
            e.to=num[i];
            e.cost=0;
            G[j].pb(e);
        }
    }
    for(auto x:v){
        ll pp=lower_bound(t[x.p].begin(),t[x.p].end(),x.c)-t[x.p].begin()+num[x.p];
        ll qq=lower_bound(t[x.q].begin(),t[x.q].end(),x.c)-t[x.q].begin()+num[x.q];
        edge e{qq,0};
        G[pp].pb(e);
        e.to=pp;
        G[qq].pb(e);
    }
    
    dijkstra(0);
    if(d[num[n-1]]==inf)d[num[n-1]]=-1;
    cout<<d[num[n-1]]<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 79660
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <cassert>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rrep(i, a, N) for (i=(N)-1;i>=(a);i--)
#define rep(i, a, N) for (i=(a);i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;

// 3 5 7 11 13 
// 3 5 7
// 3^3 5, 3^3 7

int main() {
	std::ios::sync_with_stdio(false);

	int N,i;
	int ans = 0;
	int a[] = { 105, 135, 165, 189, 195 };

	cin >> N;
	rep(i,0, 5) if (N>=a[i]) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool hoge(int yeah){
  for(int i=1;i<10;i++){
    if(yeah%i==0&&yeah/i<10)
      return true;
    else
      continue;
  }
  return false;
}
int main(){
  int n;
  cin>>n;
  if(hoge(n))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
fn main() {
    let (n, m, a) = read();
    let ans = solve(n, m, a);
    write(ans);
}

fn read() -> (i32, i32, Vec<i32>) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let mut iter = l1.trim().split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();

    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let iter = l1.split_whitespace();
    let mut a = Vec::<i32>::new();
    for x in iter {
        a.push(x.parse::<i32>().unwrap());
    }
 
    (n, m, a)
}

fn write(ans: bool) {
    println!("{}", if ans {"Yes"} else {"No"});
}

fn solve(n: i32, m: i32, mut a: Vec::<i32>) -> bool {
    let ts: i32 = a.iter().sum();
    a.sort_by(|x, y| y.cmp(x));
    let r = a.iter().filter(|&&x| x as f64 >= ts as f64 / (4 * m) as f64).take(m as usize).count();

    r as i32 == m
}

Measured memory_bytes: 2076
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    ll x,y;
    cin >> x >> y;
    int cnt = 0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll h,w;
bool ma[110][110];
vector<PLL> v;
ll dp[110][110][2];
ll cal(int x,int y,int key){//key 右0,上1
    if(dp[x][y][key]!=-1)return dp[x][y][key];
    ll ans = INF;
    int c = 1;
    if(ma[x][y])c=0;
    if(x<w)chmin(ans,cal(x+1,y,c));
    if(y<h){
        chmin(ans,cal(x,y+1,c));
    }
    if(x==w&&y==h)ans = 0;
    if(c==1 && key==0)ans++;
    //cout<<"x,y,ans: "<<x<<" "<<y<<" "<<ans<<endl;
    return dp[x][y][key]=ans;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>h>>w; char inp;
    rep(i,110)rep(j,110)ma[i][j]=false;
    rep(i,110)rep(j,110)rep(z,2)dp[i][j][z]=-1;
    rep(i,h)rep(j,w){
        cin>>inp;
        if(inp == '#')ma[j+1][i+1]=false;
        else{
            ma[j+1][i+1] = true;
            
        }    
    }
    ll ans = 0;
    if(!ma[w][h]){
        //ans++;
        //ma[w][h]=true;
    }
    ans += cal(1,1,0);
    print(ans);
    return 0;
}



Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    cin>>h;
    ll ans = 0;
    ll tmp = 1;
    while(h != 0){
        ans += tmp;
        tmp *= 2;
        h/=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(long long int i=a;i<b;i++)
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  ll a;
  ci(a);
  if(a>=64)
    co(64);
  else if(a>=32)
    co(32);
  else if(a>=16)
    co(16);
  else if(a>=8)
    co(8);
  else if(a>=4)
    co(4);
  else if(a>=2)
    co(2);
  else
    co(1);
  }

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] nametype;
			while ((nametype = Console.ReadLine().Split(' '))[1] != "X")
			{
				var w = SplitWord(nametype[0]);

				if (nametype[1] == "U")
				{
					var s = string.Join("", w.Select(ss => char.ToUpper(ss[0]) + ss.Substring(1)).ToArray());
					Console.WriteLine(s);
				}
				else if (nametype[1] == "L")
				{
					var s = string.Join("", w.Select(ss => char.ToUpper(ss[0]) + ss.Substring(1)).ToArray());
					s = char.ToLower(s[0]) + s.Substring(1);
					Console.WriteLine(s);
				}
				else if (nametype[1] == "D")
				{
					var s = string.Join("_", w.Select(ss => ss.ToLower()).ToArray());
					Console.WriteLine(s);
				}
			}
		}

		static string[] SplitWord(string s)
		{
			string[] r;

			if (s.Contains('_'))
			{
				r = s.Split('_');
			}
			else if (char.IsUpper(s[0]))
			{
				var list = new List<string>();
				int index = -1;
				for (int i = 0; i < s.Length; i++)
				{
					if (char.IsUpper(s[i]))
					{
						list.Add(s[i].ToString());
						index++;
					}
					else
					{
						list[index] += s[i];
					}
				}
				r = list.ToArray();
			}
			else
			{
				var list = new List<string>();
				list.Add("");
				int index = 0;
				for (int i = 0; i < s.Length; i++)
				{
					if (char.IsUpper(s[i]))
					{
						list.Add(s[i].ToString());
						index++;
					}
					else
					{
						list[index] += s[i];
					}
				}
				r = list.ToArray();
			}

			return r;
		}
	}
}

Measured memory_bytes: 6388
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);

		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int X = in.nextInt();
		int Y = in.nextInt();
		long ans = 0;
		
		int AB = Math.min(A + B, 2 * C);
		A = Math.min(A, AB);
		B = Math.min(B, AB);
		int XY = Math.min(X, Y);
		if(X >= 1 && Y >= 1) ans += XY * AB;
		
		if(X > Y){
			ans += (X - XY) * A;
		}else{
			ans += (Y - XY) * B;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.List
import Control.Monad

readLine :: Read a => IO [a]
readLine = map read . words <$> getLine

main :: IO ()
main = do
    n <- readLn 
    print $ sum [j*(j+1)`div`2*i|i<-[1..n], let j = n `div` i]

Measured memory_bytes: 4940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18
ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n+1, 0);
    rep(i, n) {
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }

    ll ans = 0;

    rep(i, n) {
       ll sum = (b[n] - b[i+1]) % mod;

       ans += a[i] * sum;
       ans%= mod; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6412
S = str(input())
Q = int(input())

hanten = 0
front = ""
end = ""

for i in range(Q):
  query = list(map(str, input().split()))
  if query[0] == "1":
    hanten += 1
    hanten = hanten % 2
  else:
    if query[1] == "1":
      if hanten == 0:
        front = front + query[2]
      else:
        end = end + query[2]
    else:
      if hanten == 0:
        end = end + query[2]
      else:
        front = front + query[2]

front = front[::-1]
ans = front + S + end
if hanten == 1:
  ans = ans[::-1]
print(ans)

Measured memory_bytes: 4432
#include<iostream>
#include<vector>
#include<string>
#include<set>

int main(){
    int h, w, k;
    std::cin >> h >> w >> k;
    std::vector<std::vector<char>> c(h, std::vector<char>(w));
    int init_black = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            std::cin >> c[i][j];
            if(c[i][j] == '#'){
                init_black++;
            }
        }
    }

    int target  = init_black - k; // 塗りつぶしたい個数

    // 塗る場所の設定
    int ans = 0;
    for(int h_bit = 0; h_bit < (1 << h); h_bit++){
        std::set<int> h_set;
        for(int i = 0; i < h; i++){
            if(h_bit & (1 << i)){
                h_set.insert(i);
            }
        }

        for(int w_bit = 0; w_bit < (1 << w); w_bit++){
            std::set<int> w_set;
            for(int i = 0; i < w; i++){
                if(w_bit & (1 << i)){
                    w_set.insert(i);
                }
            }


            // 計算する
            int cnt = 0;
            for(auto hh : h_set){
                for(int j = 0; j < w; j++){
                    if(c[hh][j] == '#') cnt++;
                }
            }
            for(auto ww : w_set){
                for(int i = 0; i < h; i++){
                    if(c[i][ww] == '#') cnt++;
                }
            }
            for(auto hh : h_set){
                for(auto ww : w_set){
                    if(c[hh][ww] == '#') cnt--;
                }
            }

            if(cnt == target) ans++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI b(n-1); REP(i,n-1) cin >> b[i];
    VI a(n,INF);
    REP(i,n-1){
        a[i]=min(a[i],b[i]);
        a[i+1]=min(a[i+1],b[i]);
    }
    out(SUM(a,0));

    return 0;
}

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

int N, M;
int a[60];
int b[60];
int counter[60];
int main(){
  cin >> N >> M;
  for(int i=0; i<M; ++i){
    cin >> a[i] >> b[i];
  }
  for(int i=0; i<N; ++i){
    counter[i] =0;
  }

  for(int j=1; j<N+1; ++j){
    for (int i=0; i<M; ++i){
      if ( j == a[i] || j == b[i]){
        ++counter[j-1];
      }
    }
  }
  
  for(int i=0; i<N; ++i){
    cout << counter[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((3**i-1)/2)for i in range(14,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc078.contest.atcoder.jp/tasks/arc078_b>
 問題文============================================================
 フェネックとすぬけくんがボードゲームで遊んでいます。
 
 このボードゲームには 1 番から N 番までの番号がついた N 個のマスと、
 マスどうしをつなぐ N−1 本の道が存在しています。
 ai 番のマスと bi 番のマスは i 番目の道を介して隣り合っています。
 どの 2 つのマスも隣接するマスをいくつか辿って必ず辿り着くことが可能です。
 すなわち、グラフ理論の言葉を用いると、マスと道から構成されるグラフは木です。
 
 はじめに 1 番のマスは黒く、N 番のマスは白く塗られています。
 その他のマスはまだ色が塗られていません。
 先手のフェネックと後手のすぬけくんは残りのマスに交互に色を塗ります。
 自分の手番において、2 人はそれぞれ以下のような行動を行います。
 
 フェネック：黒く 塗られたマスに隣接したマスであって、色が塗られていないマスを 1 つ選んで 黒く 塗る。
 すぬけくん：白く 塗られたマスに隣接したマスであって、色が塗られていないマスを 1 つ選んで 白く 塗る。
 
 手番のプレイヤーがマスに色を塗ることができなかったとき、敗者となります。
 フェネックとすぬけくんが最適に行動したとき勝者はどちらか判定してください。
 =================================================================
 
 解説=============================================================
 
 木構造になっており、閉路が存在しないので問題を簡単にできる
 
 まず、木構造から 1 から N までに唯一　一本の経路で到達できる
 そして、その経路において、より多く自分の色で塗れば、途中の分岐などを全て
 その色で塗ることができる。
 よって、その経路をできる限り抑えさえすれば最も多くの頂点を取得することができる
 
 これは、フェネック側から見た頂点iの深さを Fennec[i] , す抜け側を Snuke[i]とすれば
 
 Fennec[i] >= Snuke[i] であれば、その頂点は Fennecのものとなる
 
 よって、これで取得できる頂点の最大個数を互いに出すことだできる
 
 最後に、その個数（ cnt_f,cnt_s とする）が
 cnt_f > cnt_s であれば Fennecが勝利する
 
 
 ================================================================
 */
ll N;

void dfs(ll n,ll dep,vector<ll>& checked,vector<vector<ll>>&G){
    checked[n] = dep;
    for(ll next : G[n]){
        if(checked[next] != -1) continue;
        dfs(next,dep+1,checked,G);
    }
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    vector<vector<ll>> G(N);
    for(int i = 0; i < N-1;i++){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<ll> Fennec(N,-1),Snuke(N,-1);
    dfs(0,0,Fennec,G);
    dfs(N-1,0,Snuke,G);
    
    ll Fennec_have = 0, Snuke_have = 0;
    for(int i = 0; i < N;i++){
        if(Fennec[i] <= Snuke[i]) Fennec_have++;
        else Snuke_have++;
    }
    if(Fennec_have > Snuke_have){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}


Measured memory_bytes: 12032
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;
static const size_t MAX_N = 200050;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r])* inv[n - r];
}

int main(int argc, char *argv[]) {
	LL n, m, k;
	cin >> n >> m >> k;
	modll a = 0, b = 0;
	for (int i = 1; i < n; ++i) {
		modll p = i;
		p *= (n - i);
		a += p;
	}
	a *= m;
	a *= m;
	for (int i = 1; i < m; ++i) {
		modll p = i;
		p *= (m - i);
		b += p;
	}
	b *= n;
	b *= n;
	a += b;
	a *= combination(n * m - 2, k - 2);
	LL ans = a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
using namespace std;

typedef pair<int,int> pii;

int main(){
	int n;
	scanf("%d", &n);
	vector<vector<pii> > G(n);
	for(int i = 0; i < n; ++i){
		int u, k, v, c;
		scanf("%d%d", &u, &k);
		for(int j = 0; j < k; ++j){
			scanf("%d%d", &v, &c);
			G[u].push_back(pii(c, v));
		}
	}

	vector<int> d(n, 1 << 30);
	d[0] = 0;
	priority_queue<pii,vector<pii>,greater<pii> > pq;
	pq.push(pii(0, 0));
	while(!pq.empty()){
		int c = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if(d[u] != c){ continue; }
		for(int i = 0; i < G[u].size(); ++i){
			int b = c + G[u][i].first;
			int v = G[u][i].second;
			if(d[v] > b){
				d[v] = b;
				pq.push(pii(b, v));
			}
		}
	}
	
	for(int i = 0; i < n; ++i){
		printf("%d %d\n", i, d[i]);
	}
}

Measured memory_bytes: 5920
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;



int main()
{
    string s;
    cin>>s;
    int a=0,b=0,c=0,d=0;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7)
    {cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";}
    else
    if(a+b-c-d==7)
    {cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";}
    else
    if(a+b+c-d==7)
    {cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";}
    else
    if(a+b-c+d==7)
    {cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";}
    else
    if(a-b+c+d==7)
    {cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";}
    else
    if(a-b+c-d==7)
    {cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";}
    else
    if(a-b-c+d==7)
    {cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";}
    else
    if(a-b-c-d==7)
    {cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";}

    return 0;
} 

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 10000a+5000b+1000c=Yが成り立つa,b,cでa+b+c=Nとなる組み合わせが存在するか？

# O(N**2)で全探索すれば良い
# c=(Y-(10000a+5000b))//1000

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

for a in range(N + 1):
    for b in range(N + 1):
        c = (Y - 10000 * a - 5000 * b) // 1000
        if c < 0:
            continue
        if a + b + c == N:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 9172
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

A, B, C, X, Y = map(int, input().split())

ans = int(1e100)
ab_num = 0

while ab_num // 2 <= max(X, Y):
    money = ab_num * C
    money += max(0, (X - ab_num // 2)) * A
    money += max(0, (Y - ab_num // 2)) * B
    ans = min(ans, money)
    ab_num += 2

print(ans)    


Measured memory_bytes: 7984
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13) cout<<B<<endl;
    else if(A>=6) cout<<B/2<<endl;
    else cout<<0<<endl;
    return 0;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = true;
  int num = 0;

  int a, b; cin >> a >> b;
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#define ll long long
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n=s.size();
    if(s[n-1]=='s'){
        cout << s << "es";
    }
    else{
        cout << s << "s";
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner  sc = new Scanner(System.in);
        String ans ="Yes";
        int list[][] =new int[3][3];
        for (int i=0;i<3;i++) {
            for(int j=0;j<3;j++) {
                int num = sc.nextInt();
                list[i][j] =num;
            }
        }
        int tmpListA [] = new int[3];
        int tmpListB [] = new int[3];
        tmpListA[0]=0;
        for (int i=0;i<3;i++) {
                tmpListB[i] = list[0][i] -tmpListA[0];
                tmpListA[i] = list[i][0] - tmpListB[0];
        }
        for (int i=0;i<3;i++) {
            for(int j=0;j<3;j++) {
                if(list[i][j] == (tmpListA[i]+tmpListB[j])) {
                    continue;
                }else {
                    ans = "No";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> answer_man(N, 0);
    rep (i, Q) {
        int answer;
        cin >> answer;
        answer_man[answer - 1]++;
    }

    rep (i, N) {
        cout << (K - Q + answer_man[i] > 0 ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    list_n = list(int(input()) for i in range(n))
    list_m = list(int(input()) for i in range(m))
    list_n.sort
    list_m.sort
    sum_n = sum(list_n)
    sum_m = sum(list_m)
    if sum_n >= sum_m :
        sa = sum_n - sum_m
        result = -1
        for i in range(n) :
            if result == 1 :
                break
            for j in range(m):
                if list_n[i] == list_m[j] + sa / 2 :
                    print(list_n[i], list_m[j])
                    result = 1
                    break
        if result == -1 :
            print(-1)
            
            
    elif sum_n <= sum_m :
        sa = sum_m - sum_n
        result = -1
        for i in range(n) :
            if result == 1 :
                break
            for j in range(m):
                if list_m[j] == list_n[i] + sa / 2:
                    print(list_n[i], list_m[j])
                    result = 1
                    break
        if result == -1 :
            print(-1)
    


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        var h = ReadIntArray();

        int allh = h.Sum();
        int ans = 0;
        int mode = 0;

        while (allh > 0)
        {
            for (int i = 0; i < n; i++)
            {
                if (i == 0){ mode = 0; }

                if (h[i] > 0)
                {
                    if (mode == 0){ // start new watering
                        ans++;
                    }
                    mode = 1;
                    h[i]--;
                    allh--;
                }
                else
                {
                    mode = 0;
                }
            }
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 13396
from collections import deque

h, w = (int(x) for x in input().split())
ch, cw = (int(x) - 1 for x in input().split())
dh, dw = (int(x) - 1 for x in input().split())
S = [list(input()) for _ in range(h)]
grid = [[-1] * w for _ in range(h)]
grid[ch][cw] = 0
NX = [1, 0, -1, 0]
NY = [0, 1, 0, -1]
WarpX = [-2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
WarpY = [-2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2]

que = deque([(ch, cw)])
que2 = deque()
while que or que2:
    while que:
        y, x = que.popleft()
        for i in range(4):
            ny = y + NY[i]
            nx = x + NX[i]
            if 0 <= ny < h and 0 <= nx < w:
                if S[ny][nx] != "#" and grid[ny][nx] == -1:
                    grid[ny][nx] = grid[y][x]
                    que.append((ny, nx))
                elif S[ny][nx] == "#":
                    que2.append((y, x))
    while que2:
        y, x = que2.popleft()
        for i in range(20):
            ny = y + WarpY[i]
            nx = x + WarpX[i]
            if 0 <= ny < h and 0 <= nx < w:
                if S[ny][nx] != "#" and grid[ny][nx] == -1:
                    grid[ny][nx] = grid[y][x] + 1
                    que.append((ny, nx))

print(grid[dh][dw])


Measured memory_bytes: 131380
#include <iostream>

int main() {
    char n[4];
    for(int i = 1; i <= 3; i++) std::cin >> n[i];
    for(int j = 1; j <= 3; j++){
        if(n[j] == '1') n[j] = '9';
        else n[j] = '1';
    }
    std::cout << n[1] << n[2] << n[3] << std::endl;
}

Measured memory_bytes: 256