akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private void solve() {
		
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		Operation[] operations = new Operation[N+M];
		for(int i=0;i<N;i++) {
			int A = in.nextInt();
			operations[i] = new Operation(1,A);
		}
		for(int j=N;j<N+M;j++) {
			int B = in.nextInt();
			int C = in.nextInt();
			operations[j] = new Operation(B,C);
		}
		Arrays.sort(operations);
		long ans = 0;
		int card_num = N;
		int k = 0;
		while(card_num>0) {
			if(operations[k].B > card_num) operations[k].B = card_num;
			ans += 1.0 * operations[k].C * operations[k].B;
			card_num -= operations[k].B;
			k++;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	public class Operation implements Comparable<Operation>{
		public int B;
		public int C;
		
		public Operation(int B, int C) {
			this.B = B;
			this.C = C;
		}
		
		@Override
		public int compareTo(Operation other) {
			return -Integer.compare(C, other.C);
		}
	}
}

Measured memory_bytes: 102528
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	vll a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	cout << (a[0] == a[1] && a[1] == a[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N;
    cin >> N;
    vll v(5);
    for(auto &a:v) cin >> a;
    ASC(v);
    cout << (ll)ceil(N / (double)v[0]) + 4 << endl;
}

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


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

int main(){
    int N;
    cin >> N;
    if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9) cout << "hon" <<endl;
    else if(N%10==3) cout << "bon" << endl;
    else cout << "pon" << endl;
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S, T; cin >> S >> T;
  cout << T + S << endl;

  return 0;
}



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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int n, k, cnt = 0;
  ll ans = 1LL ;
  scanf("%d %d", &n, &k) ;

  while(ans<k && cnt<n){
    ans<<=1 ;
    cnt++ ;
  }
  while(cnt<n){
    ans+=k ;
    cnt++ ;
  }

  cout << ans<<endl ;

	
  return 0 ;
}

Measured memory_bytes: 256
import math
a,b,x = map(int, input().split())
if (x <= (a*a*b)/2):
    p = (2*x)/(a*b)
    print(90-math.degrees(math.atan(p/b)))
elif (x == a*a*b):
    print(0)
    
else:
    p = 2*(a*a*b - x)/(a*a)
    print(90-math.degrees(math.atan(a/p)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


template <typename T> class Dijkstra{
    vector<pair < T, int >>* edges;
    int* par;
    T* Distance;
    int size;

public:
    Dijkstra(int n){
        size = n;
        edges = new vector<pair<T , int> >[n];
        Distance = new T[n];
        par = new int[n];
    };

    T Get_Distance(int x){
        if(x < 0 or x>= size) return T(-1);
        else return Distance[x];
    };

    void add_edge(T dist, int s,int t);

    void Disp_Graph();

    void Get_Shortest(int s);



};


template<typename T> void Dijkstra<T>::add_edge(T dist, int s,int t){
    edges[s].push_back( mp(dist, t));
}

template<typename T> void Dijkstra<T>::Disp_Graph(){
    REP(i,size){
        REP(j,edges[i].size()){
            cout << edges[i][j].se << " " << edges[i][j].fi <<endl;
        }
        cout << endl;
    }
}


template<typename T> void Dijkstra<T>::Get_Shortest(int s){
    REP(i,size) Distance[i] = T(INF);
    reversed_priority_queue< pair<T, int > > Q;
    bool used[size];
    REP(i,size) used[i] = false;
    REP(i,size) par[i] = -1;
    int Q_size = 1;
    Distance[s] = 0;
    Q.push( mp(T(0),s ) );
    while(Q_size){
        pair < T, int > x = Q.top();
        Q.pop();
        Q_size --;
        if( used[x.se]) continue;
        used[x.se] = true;
        REP(i,edges[x.se].size()){
            pair < T, int > y = edges[x.se][i];
            if(  Distance[y.se] > Distance[x.se] + y.fi){
                Distance[y.se] = Distance[x.se] + y.fi;
                Q.push( mp ( Distance[y.se],y.se) );
                Q_size ++;
                par[y.se] = x.se;
            }
        }

    }

}











signed main(){
    int n,m,s;
    cin >> n;
    Dijkstra<int> D(n);
    int t1,d1;
    REP(i,n){
        int u,k;
        scanf("%lld%lld",&u,&k);
        REP(j,k){
            scanf("%lld%lld",&t1,&d1);
            D.add_edge(d1,u,t1);
        
        }
    }


    D.Get_Shortest(0);
    int tmp = 0;
    REP(i,n){
        printf("%lld %lld\n",i,D.Get_Distance(i));
    }
}



Measured memory_bytes: 12028
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n+500, 0);
	for( int i = 0; i < n; ++i ){
		cin >> h[i];
	}
	vector<int> cost(n+500, INF);
	cost[0] = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = 1; j <= k; ++j ){
			cost[i+j] = min(cost[i+j], cost[i]+abs(h[i+j]-h[i]));
		}
	}
	cout << cost[n-1] << endl;
	return 0;
}

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

int N;
int istr;
long long beg, fin, ans, conb;
long long T;
vector<int> t;
int main()
{
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> istr;
		t.push_back(istr);
	}
	beg = t[0];
	for (int i = 0; i < N; i++) {
		if (fin < t[i]) {
			ans += fin-beg;
			beg = t[i];
			fin = beg + T;
		}
		else {
			fin = t[i] + T;
		}
	}
	ans += fin - beg;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
int iro[100000],ban[100000],shiro=MOD,kuro=MOD;
vector<pair<int,int>> hen[100000];
        void dfs(int a){
                if(iro[a]==1)shiro=min(ban[a],shiro);
                else kuro=min(ban[a],kuro);
                for(int i=0;i<hen[a].size();i++){
                        if(iro[hen[a][i].first]==0){
                                iro[hen[a][i].first]=-1*iro[a];
                                ban[hen[a][i].first]=hen[a][i].second-ban[a];
                                dfs(hen[a][i].first);
                        }
                }
        }
     signed main(){
             int n,m;
             cin>>n>>m;
             int u[m],v[m],s[m];
             for(int i=0;i<m;i++){
                     cin>>u[i]>>v[i]>>s[i];
                     u[i]--;v[i]--;
                     hen[u[i]].push_back(make_pair(v[i],s[i]));
                     hen[v[i]].push_back(make_pair(u[i],s[i]));
             }
        iro[0]=1;
        dfs(0);
        int k=-1;
        for(int i=0;i<m;i++){
                 if(iro[u[i]]!=iro[v[i]]){
                        if(ban[u[i]]+ban[v[i]]!=s[i]){ 
                                cout<<0;
                                return 0;
                        }
                        continue;
                        }
             
                       
                       if((s[i]-ban[u[i]]-ban[v[i]])%2!=0||(iro[u[i]]*(s[i]-ban[u[i]]-ban[v[i]])/2<=0)||(k!=-1&&k!=iro[u[i]]*(s[i]-ban[u[i]]-ban[v[i]])/2)){
                               cout<<0;
                               return 0;
                       }
                       k=iro[u[i]]*(s[i]-ban[u[i]]-ban[v[i]])/2;

              
        }
        if(k==-1){
                cout<<max(0ll,kuro-1+shiro);
        }else{
                if(1-shiro>k||kuro<=k)cout<<0;
                else cout<<1;
        }
    return 0;
}

        


Measured memory_bytes: 16384
#include <cstdio>

using namespace std;

int numere[12];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &numere[i]);
    int cp = n;
    int rez = 1;
    while(cp){
        rez *= 3;
        cp--;
    }
    int diff = 1;
    for(int i = 1; i <= n; i++){
        if(numere[i] % 2 == 0)
            diff *= 2;
    }
    rez -= diff;
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, k; cin >> n >> k;
	map<ll, ll> a;
	REP(i, n) {
		ll x; cin >> x;
		a[x]++;
	}

	vector<ll> b;
	for (auto&& x : a) b.push_back(x.second);
	sort(ALL(b));

	ll ans = 0;
	REP(i, (ll)b.size() - k) {
		ans += b[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;
#define mapp map<int,int>
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)
 
bool comps(const pair<int,int> &a, const pair<int,int> &b) {return (a.second<b.second);} 

int fac[100001];
int power(int x, unsigned int y)
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}

int powerp(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

int binomialCoeff(int n, int k)
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}
void precomp()
{ 
    fac[0] = 1; 
    for (int i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%mod;
}
int modInverse(int n, int p) {return powerp(n, p-2, p);}
int nCrModPFermat(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r   
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
signed main()
{
    
    IOS
    int n,m;
    cin>>n>>m;
    vin(h,n);
    vi flag(n,1);
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        if(h[a-1]<=h[b-1]) flag[a-1]=0;
        if(h[b-1]<=h[a-1]) flag[b-1]=0;
    }
    int count=0;
    rep(i,0,n) count+=flag[i];
    cout<<count;
    return 0;
}

Measured memory_bytes: 4780
/*author : Yashvardhan
Friday, June 19, 2020
4:07 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

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

#ifdef __APPLE__
#define debug(...) __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...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


map<pair<int,string>,int> dp;
int n;

bool isValid(string s){
	for(int i = 0; i <= 3; i++){
		string tmp = s;
		if(i >= 1){
			swap(tmp[i], tmp[i - 1]);
		}
		if(tmp.substr(0, 3) == "AGC" || tmp.substr(1, 3) == "AGC"){
			return false;
		} 
	}
	return true;
}

int add(int a, int b){
	return (a + b) % mod;
}

int solve(int i, string s){
	pair<int, string> curr = {i, s};
	if(dp.count(curr)) return dp[curr];
	if(i == n) return 1;

	string tmp = "ACGT";
	int ans = 0;
	for(auto it : tmp){
		string nxt = s + it;
		if(isValid(nxt)){
			ans = add(ans, solve(i + 1, nxt.substr(1,3)));
		}
	}
	return dp[curr] = ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	cin >> n;
	
	cout << solve(0, "TTT") << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 4172
import numpy as np

N = int(input())
S = input()
Ps = np.fromstring(S, dtype=int, sep=" ")

min_val = Ps[0]
count = 1
for i in range(1, N):
    if min_val >= Ps[i]:
        count += 1
        min_val = Ps[i]

print(count)

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> d(K);
    vector<vector<int>> A(K,vector<int>(N));
    for(int i=0;i<K;i++) {
        cin >> d[i];
        for(int j=0;j<d[i];j++) {
            cin >> A[i][j];
        }
    }

    vector<bool> sweet(N,false);
    for(int i=0;i<K;i++) {
        for(int j=0;j<d[i];j++) {
            sweet[A[i][j]-1] = true;
        }
    }

    int p = 0;
    for(int i=0;i<N;i++) {
        if(sweet[i]) continue;
        else p++;
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 100000;

int coins[N_MAX];
int dp[21][N_MAX];

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, 0, m){
    cin >> coins[i];
  }
  
  // init
  rep(row, 0, m+1) dp[row][0] = 0;
  rep(col, 1, n+1) dp[0][col] = 50001;

  // fill
  rep(row, 1, m+1){
    rep(col, 1, n+1){
      if(col - coins[row-1] >= 0) dp[row][col] = min(dp[row-1][col - coins[row-1]]+1, min(dp[row-1][col], dp[row][col-coins[row-1]]+1));
      else dp[row][col] = dp[row-1][col];
      /*
      while(col - k * coins[row-1] >= 0){
	use_k_min = min(use_k_min, dp[row-1][col - k * coins[row-1]] + k);
	k++;
	}*/
    }
  }
  cout << dp[m][n] << endl;
  
  /*
  rep(row, 0, m+1){
    rep(col, 0, n+1){
      cout << dp[row][col] << " ";
    }
    cout << endl;
  }
  */
  return 0;
}



Measured memory_bytes: 7284
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	a := l % 2019
	b := r % 2019

	if a >= b || r-l > 2019 {
		fmt.Println(0)
		return
	}
	if a < b {
		min := 10000
		for i := a; i <= b-1; i++ {
			for j := i + 1; j <= b; j++ {
				t := (i * j) % 2019
				if t < min {
					min = t
				}
			}
		}
		fmt.Println(min)
		return
	}
}


Measured memory_bytes: 512
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, q = rint;
	auto seg = new SegTree!long(0, n, (x, y) => y, 0);
	seg.setValue(0, n, (1L<<31) - 1);
	log("seg:", seg);
	foreach(_; 0 .. q){
		int c = rint;
		if(c == 0){
			int l = rint, r = rint + 1;
			long x = rlong;
			seg.setValue(l, r, x);
			log("l:", l, "r:", r, "x:", x);
			log("seg:", seg);
		}
		else{
			int i = rint;
			log("i:", i);
			seg.getValue(i).writeln;
		}
	}
}

class SegTree(T){
	T delegate(T, T) apply;
	T initial;
	int a, b; // a <= x < b を担当する
	bool hasValue;
	SegTree left, right; // 左の子(a <= x < c)、右の子(c <= x < b)
	T value;
	this(int a, int b, T delegate(T, T) apply, T initial = T.init){
		this.a = a, this.b = b;
		this.apply = apply;
		this.initial = initial;
		this.value = initial;
		if(b - a == 1){
			this.hasValue = 1;
		}
		else{
			int c = (a + b) / 2;
			this.left = new SegTree(a, c, apply, initial);
			this.right = new SegTree(c, b, apply, initial);
		}
	}
	
	// [a, b) に値を設定する ※[a, b) はこのノードの担当区間とかぶっていなくてもよい
	void setValue(int a, int b, T value){
		if(b <= this.a || this.b <= a) return;
		if(a <= this.a && this.b <= b){
			this.hasValue = true;
			this.value = apply(this.value, value);
		}
		else{
			if(this.hasValue){
				left.setValue(left.a, left.b, this.value);
				right.setValue(right.a, right.b, this.value);
				this.hasValue = false;
			}
			left.setValue(a, b, value);
			right.setValue(a, b, value);
		}
	}
	
	// iにおける値 ※iは必ずこのノードの担当区間内である前提
	T getValue(int i){
		assert(a <= i && i < b);
		if(this.hasValue) return this.value;
		else if(i < left.b) return left.getValue(i);
		else return right.getValue(i);
	}
	
	// 配列に変換したもの（デバッグ用）
	T[] array(){
		T[] res;
		foreach(i; a .. b) res ~= this.value;
		return res;
	}
	
	// 文字列に変換したもの（デバッグ用）
	override string toString(){
		if(this.hasValue) return this.array.to!string;
		else return left.toString ~ right.toString;
	}
}



Measured memory_bytes: 43240
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll       long long
#define ull       unsigned long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX                 100000
#define maxn 200002
#define pb push_back
#define mk make_pair


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n,k;
		cin >> n >> k;
		int a[MAX];
		for (int i=0; i<n ; i++)
		{
			cin >> a[i];
		}
		sort (a,a+n);
		ll sum = 0;
		for (int i=0 ; i<k ; i++)
		sum+=a[i];
		cout << sum << endl;
		return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef struct _node {
  int key;
  struct _node *next;
  struct _node *prev;
} NODE, *PNODE;

PNODE root;

void init(void) {
  root = malloc(sizeof(NODE));
  root->next = root;
  root->prev = root;
}

void insert(key) {
  PNODE t = malloc(sizeof(NODE));
  t->key = key;
  t->next = root->next;
  t->prev = root;
  root->next->prev = t;
  root->next = t;
}

void deleteNode(PNODE node) {
  if (node == root) {
    return;
  }
  node->next->prev = node->prev;
  node->prev->next = node->next;
  free(node);
}

void delete(key) {
  PNODE cur = root->next;
  while (cur != root) {
    if (cur->key == key) {
      deleteNode(cur);
      return;
    }
    cur = cur->next;
  }
}

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

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

void printNodes(void) {
  PNODE cur = root->next;
  while (1) {
    printf("%d", cur->key);
    cur = cur->next;
    if (cur != root) {
      putchar(' ');
    } else {
      break;
    }
  }
  putchar('\n');
}

void release(void) {
  PNODE tmp, cur = root->next;
  while (cur != root) {
    tmp = cur;
    cur = cur->next;
    deleteNode(tmp);
  }
  free(root);
} 

int main(void) {
  char cmd[100];
  int n, i, f;
  int key;

  init(); 

  scanf("%d", &n);

  f = 0;
  while (scanf("%s", cmd) > 0) {
    if (cmd[0] == 'i') {
      f = 1;
    } else if (cmd[0] == 'd') {
      switch (cmd[6]) {
      case '\0':
	f = 2;
	break;
      case 'F':
	deleteFirst();
	break;
      case 'L':
	deleteLast();
	break;
      }
    } else {
      key = atoi(cmd);
      if (f == 1) {
	insert(key);
      } else if (f == 2) {
	delete(key);
      }
    }
  }

  printNodes();

  release();

  return 0;
}

Measured memory_bytes: 31852
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


n = int(input())
divs = make_divisors(n)
ans = 10**12
for div in divs:
    x = n // div
    ans = min(x - 1 + div - 1, ans)
print(ans)


Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	long long n,m,d;
	scanf("%lld %lld %lld", &n, &m, &d);

	double sum = d+2*(n-2*d)+d;
	if(d==0) sum/= 2;

	//sum *= pow(n,m-1);
	sum *= (m-1);
	//printf("%f\n", sum);
	double ans = sum / pow(n,2);

	printf("%.9f\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

int32_t main()
{	
	IOS
	int n;
	cin >> n;
	long double side = (n / 3.0);
	long double ans = side * side * side;
	cout << fixed << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int K, ans = 0;

	cin >> K;

	cout << (K / 2) * (K / 2) + (K / 2) * (K % 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;

int main() {

	int n, a;
	vector<int> v;
	int cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		v.push_back(a);
	}

	for (int i = 0; i < n; i++) {
		if (i != 0) {
			if (v.at(i - 1) == v.at(i)) {
				cnt++;
				v.at(i) += 10;
			}
		}
	}

	cout << cnt << endl;
}



Measured memory_bytes: 256
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [(int(input())) for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            A_1[i] = 1
        elif A_2[i] == b[j]:
            A_2[i] = 1
        elif A_3[i] == b[j]:
            A_3[i] = 1


if A_1[0] == A_1[1] == A_1[2]:
    print("Yes")
elif A_2[0] == A_2[1] == A_2[2]:
    print("Yes")
elif A_3[0] == A_3[1] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[0] == A_3[0]:
    print("Yes")
elif A_1[1] == A_2[1] == A_3[1]:
    print("Yes")
elif A_1[2] == A_2[2] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[1] == A_3[2]:
    print("Yes")
elif A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
bool IsPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  int prime[1000000]={};
  for(int i=2;i<=1000000;i++){
      if(IsPrime(i)) prime[i]=prime[i-1]+1;
      else prime[i]=prime[i-1];
  }
   
  while(cin >> n) cout << prime[n]<< endl;

   
   return 0;
}



Measured memory_bytes: 6976
#include<iostream>
#include<string>
#define AC ios_base::sync_with_stdio(0),cin.tie(0)
#define ll long long 
using namespace std;

int n;
string s;
int cnt=1;

void backtrack(int m){
	if(m==n){
		cout<<s<<"\n";
		return;
	}
	for(int i=0;i<=cnt;i++){
		char c='a'+i;
		s+=c;
		int temp=cnt;
		cnt=max(cnt,s[m]-'a'+1);
		backtrack(m+1);
		cnt=temp;
		s=s.substr(0,s.length()-1);
	}
}

int main(){
	AC;
	cin>>n;
	s="a";
	backtrack(1);
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int x[4]={0,0,-1,1};
int y[4]={1,-1,0,0};
ll r,c;
string s[405];
ll vis[405][405];
bool chk(ll s1,ll s2)
{
	return s1>=0 && s1<r && s2>=0 && s2<c;
}
ll ans,white,black;
void dfs(ll s1,ll s2, char prev){
	s[s1][s2]='o';
	char next;
	if(prev=='#')
	{
		black++;
		next='.';
	}
	else{
		white++;
		next='#';
	}
	for(ll i=0;i<4;i++)
	{
			ll pntx=s1+x[i];
			ll pnty=s2+y[i];
			if(chk(pntx,pnty) && s[pntx][pnty]==next){
				dfs(pntx,pnty,next);
			}
		}
}
int main()
{
	ll i,j;
	cin>>r>>c;
	for(i=0;i<r;i++)
	{
		cin>>s[i];
	}
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			if(s[i][j]=='#')
			{
				white=0;
				black=0;
				dfs(i,j,'#');
				ans+=white*black;
				//memset(vis,0,sizeof vis);
			}
		}
	}
	cout<<ans;
 	return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll k = 0, two = 0;
    rep(i, n) {
        ll d = b[i] - a[i];
        k += d;
        if (d > 0) two += (d + 1) / 2;
    }

    if (two <= k)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  string output = "";
  string s;
  cin >> s;
  for ( char c : s){
    if (!output.empty() && c == 'B'){
      output.pop_back();
    }
    else if( c != 'B'){
      output += c;
    }
  }
  std::cout << output << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ll N,K,D;
    cin >> N >> K >> D;
    
    N = abs(N);
    ll a = N/D;
    
    ll ans = infi;
    
    if(a <= K){
        ans = N%D;
        K -= a;
        
        if(K % 2 == 1) ans = abs(ans-D);
        
    }else{
        ans = N-K*D;
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
	cin>>A>>B;
	if(A==B)
	cout<<"Draw";
	else if ((A>B&&B!=1)||(A==1))
		cout<<"Alice";
	else if ((A<B&&A!=1)||(B==1))
		cout<<"Bob";
}

	

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        Scanner sc = new Scanner(is);

        long n = sc.nextLong();
        long cap[] = new long[5];

        for (int i = 0; i < 5; i++) {
            cap[i] = sc.nextLong();
        }

        int botttleneckIndex = 0;
        long bottoleneck = Long.MAX_VALUE;

        for (int i =0; i < cap.length; i++) {
            if (cap[i] < bottoleneck) {
                botttleneckIndex = i;
                bottoleneck = cap[i];
            }
        }

        long count = (n + bottoleneck - 1)/ bottoleneck + 4;

        os.println(count);
    }

}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;

int main()
{
  int n;
  while (cin >> n && n != 0) {
    ostringstream oss;
    oss << oct << n;
    string s = oss.str();
    for (string::iterator it(s.begin()); it != s.end(); ++it) {
      static const char tbl[] = "01235789";
      *it = tbl[*it-'0'];
    }
    cout << s << endl;
  }
  return 0;
}

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

#define int long long

int a[100000];

signed main() {
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    map<int, int> mp;
    for(int i=0; i<n; ++i) mp[a[i]]++;
    int ans = 0;
    for(auto p : mp) {
        int x = p.first;
        int n = p.second;
        if(n<x) ans += n;
        else ans += n-x;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define reverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};
 
int main() {
	string S;
  	cin>>S;
  	string sub="";
  	int Q;
  	cin>>Q;
  	int counter=0;
  	rep(i,Q){
    	int T;
      	cin>>T;
      	if(T==1) counter++;
      	else{
        	int F;
          	cin>>F;
          	char C;
          	cin>>C;
          	if((F+counter)%2==1)sub=sub+C;
          	else S=S+C;
        }
    }
  	reverse(sub);
  	S=sub+S;
  	if(counter%2==1)reverse(S);
  	cout<<S<<endl;
}

Measured memory_bytes: 1728
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
    long[] checkNum = new long[2];
    long answer = 0;
    long minDifference = long.MaxValue;
		long n = long.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);//ソート

    if(nums[n-1] % 2 == 0)
    {
      checkNum[0] = nums[n-1]/2;
      checkNum[1] = nums[n-1]/2;
    }else
    {
    checkNum[0] = nums[n-1]/2;
    checkNum[1] = nums[n-1]/2+1;//中央値
    }

    for(long num = 0; num < n-1; num++)
    {
      if(Math.Min(Math.Abs(checkNum[0]-nums[num]), Math.Abs(checkNum[1]-nums[num]))
        < minDifference)
      {
        minDifference = Math.Min(Math.Abs(checkNum[0]-nums[num]), Math.Abs(checkNum[1]-nums[num]));
        answer = nums[num];
      }
    }

		Console.WriteLine(nums[n-1] + " " + answer);
	}
}


Measured memory_bytes: 20320
import java.util.Scanner;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

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

    System.out.println(sum);

  }

}


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

template <typename T>
class FenwickTree {
	const int n;
	vector<T> data;
public:
	FenwickTree(int n_) : n(n_), data(n) {}
	T find(int p) const {
		T res = 0;
		while (p >= 0) {
			res += data[p];
			p = (p & (p + 1)) - 1;
		}
		return res;
	}
	void add(int p, T val) {
		while (p < n) {
			data[p] += val;
			p |= p + 1;
		}
	}
};

template <typename T>
class RARS {
	const int n;
	FenwickTree<T> bit0, bit1;
public:
	RARS(int n_) : n(n_), bit0(n), bit1(n) {}
	T find(int p) const {
		return bit1.find(p) * (p + 1) + bit0.find(p);
	}
	T find(int l, int r) const {
		return find(r) - find(l - 1);
	}
	void add(int l, int r, T val) {
		bit0.add(l, -val * l);
		bit1.add(l, val);
		bit0.add(r + 1, val * (r + 1));
		bit1.add(r + 1, -val);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS<ll> rars(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", rars.find(s, t));
		}
		else {
			cin >> x;
			rars.add(s, t, x);
		}
	}
	return 0;
}



Measured memory_bytes: 4328
import math

def perm(n, r):
    return math.factorial(n)//math.factorial(n-r)

def comb(n, r):
    if n <= 1:
        return 0
    return perm(n, r)//math.factorial(r)

N, M = map(int,input().split(" "))

ans = comb(N,2) + comb(M,2)


print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1<<endl;
    else if(b==0)cout<<2<<endl;
    else if(c==0)cout<<3<<endl;
    else if(d==0)cout<<4<<endl;
    else cout<<5<<endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define ll long long int
#define N 200005
#define endl '\n'
#define speed        ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

void  solve()
{
    int n;
    cin >>n;
    int a[n+1][3];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
            cin >>a[i][j];
    }
    int dp[n+1][3];
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    int ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);
    cout <<ans <<endl;
}

int main()
{
    speed;
    ll t=1;
    //cin >>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>

#define SIZE 100
#define INF 10000000

typedef struct {
  int data;
  int pos;
} DAT;


using namespace std;

int main(){

  DAT ans;
  int i,j,k;
  int a,b,c;
  int n;
  int time[SIZE][SIZE];

  while(1){

    int sum[SIZE]={0};
    cin>>n;
    if(n==0)break;

  for(i=0;i<n+1;i++){
    for(j=0;j<n+1;j++){
      if(i==j){
	time[i][j]=0;
      } else {
	time[i][j]=INF;
      }
    }
  }

  int max=0;
    for(i=0;i<n;i++){
      cin>>a>>b>>c;
      time[a][b]=c;
      time[b][a]=c;
      if(max<a)max=a;
      if(max<b)max=b;
    }

    for(i=0;i<max+1;i++){
      for(j=0;j<max+1;j++){
	for(k=0;k<max+1;k++){
	  time[j][k]=min(time[j][k],time[j][i]+time[i][k]);
	}
      }
    }

    for(i=0;i<max+1;i++){
      for(j=0;j<max+1;j++){
	sum[i]+=time[i][j];
      }
    }

    ans.data=INF;
    ans.pos=-1;
    for(i=0;i<max+1;i++){
      if(sum[i]<ans.data){
	ans.data=sum[i];
	ans.pos=i;
      }
    }

    printf("%d %d\n",ans.pos,ans.data);

  }
  
  return 0;
}

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

int MOD=1000000007;

ll power(ll x, ll n) {
  if (n == 0) return 1;
  if (n%2 == 0) return power(x*x %MOD , n/2) %MOD;
  return power(x*x%MOD, n/2)*x%MOD;
}

ll comb(ll n, ll r) {
  ll ans = 1;
  for (int i = n; i >= n-r+1; i--) {
    ans = (ans*i) % MOD;
  }
  
  for (int i = 1; i <= r; i++) {
    ans = (ans * power(i, MOD-2)) %MOD;
  }

  return ans;
}

int main(void) {
  int n,a,b;
  cin >> n >> a >> b;

  ll ans = (power(2,n) - 1 - comb(n,a) - comb(n,b)) % MOD;

  if(ans < 0) ans += MOD;

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


Measured memory_bytes: 256
#include <stdio.h>

#define INFTY 1000000001
 
void merge(int a[], char mark[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int l[n1 + 1], r[n2 + 1];
  char lm[n1 + 1], rm[n2 + 1];
  int i, j, k;
  for (i = 0; i < n1; i++) {
    l[i] = a[left + i];
    lm[i] = mark[left + i];
  }
  for (i = 0; i < n2; i++) {
    r[i] = a[mid + i];
    rm[i] = mark[mid + i];
  }
  l[n1] = INFTY;
  r[n2] = INFTY;
  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    if (l[i] <= r[j]) {
      mark[k] = lm[i];
      a[k] = l[i++];
    }
    else {
      mark[k] = rm[j];
      a[k] = r[j++];
    }
  }
}
 
void merge_sort(int a[], char mark[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(a, mark, left, mid);
    merge_sort(a, mark, mid, right);
    merge(a, mark, left, mid, right);
  }
}

void sort_num(int *x, int *y) {
  int c;
  c = *x;
  *x = *y;
  *y = c;
}

void sort_mark(char *x, char *y) {
  char c;
  c = *x;
  *x = *y;
  *y = c;
}

int partition(int a[], char mark[], int p, int r) {
  int x = a[r];
  int i = p - 1;
  for (int j = p; j < r; j++)
    if (a[j] <= x) {
      i = i + 1;
      sort_num(&a[i], &a[j]);
      sort_mark(&mark[i], &mark[j]);
    }
  sort_num(&a[i + 1], &a[r]);
  sort_mark(&mark[i + 1], &mark[r]);
  return i + 1;
}

void quick_sort(int a[], char mark[], int p, int r) {
  int q;
  if (p < r) {
    q = partition(a, mark, p, r);
    quick_sort(a, mark, p, q - 1);
    quick_sort(a, mark, q + 1, r);
  }
}

int stable_check(int a[], int b[], char c[], char d[], int n) {
  for (int i = 0; i < n; i++)
    if (a[i] != b[i] || c[i] != d[i])
      return 0;
  return 1;
}

int main(void) {
  int n;
  int a[100000], acopy[100000];
  char mark[100001], markcopy[100000];
 
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf(" %c", &mark[i]);
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++) {
    acopy[i] = a[i];
    markcopy[i] = mark[i];
  }

  quick_sort(a, mark, 0, n - 1);
  merge_sort(acopy, markcopy, 0, n);

  if (stable_check(a, acopy, mark, markcopy, n))
    printf("Stable\n");
  else
    printf("Not stable\n");
  
  for (int i = 0; i < n; i++)
    printf("%c %d\n", mark[i], a[i]);
  
  return 0;
}



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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  vector<int> numbers(n);
  for(int i = 0; i < n; ++i) {
    cin >> numbers[i];
  }
  SORT(numbers);
  int max_in = numbers[n-1];
  numbers.erase(numbers.begin()+n-1);
  int half_num;
  if(max_in % 2) {
    half_num = max_in / 2 + 1;
  } else {
    half_num = max_in / 2;
  }
  auto target_itr = lower_bound(ALL(numbers), half_num);
  if(target_itr == numbers.end()) {
    cout << max_in << " " << numbers[n-2] << endl;
    return 0;
  }
  int target_index = target_itr - numbers.begin();
  if(max_in % 2) {
    if(numbers[target_index] == half_num || numbers[target_index] == half_num+1 || target_index == 0) {
      cout << max_in << " " << numbers[target_index] << endl;
      return 0;
    }
    if(half_num - numbers[target_index - 1] < numbers[target_index] - (half_num+1)) {
      cout << max_in << " " << numbers[target_index - 1] << endl;
      return 0;
    } else {
      cout << max_in << " " << numbers[target_index] << endl;
      return 0;
    }
    
  } else {
    if(numbers[target_index] == half_num || target_index == 0) {
      cout << max_in << " " << numbers[target_index] << endl;
      return 0;
    }

    if(half_num - numbers[target_index-1] < numbers[target_index] - half_num) {
      cout << max_in << " " << numbers[target_index-1] << endl;
      return 0;
    } else {
      cout << max_in << " " << numbers[target_index] << endl;
      return 0;
    }
  }
  return 0;
}
/***** MAIN *****/


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

char S[900],D[10][10]={"","\0afkpuz","\0bglqv.","\0chmrw?","\0dinsx!","\0ejoty "};
int i,j,l,r,c;
int main()
{
	for(;gets(S);)
	{
		char R[300]={0};
		if(strlen(S)%2)
		{
			puts("NA");
			continue;
		}
		for(i=0,l=strlen(S),j=0;i<l;i+=2,j++)
		{
			c=S[i]-'0';r=S[i+1]-'0';
			if(D[r][c]==0){strcpy(R,"NA");break;}
			R[j]=D[r][c];
		}
		puts(R);
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
const int N=2019,mod=924844033;
int n,k,sum,p,ans,f[2][N][N][2],g[2][N],fac[N];
void add(int&x,int y){x=x+y>=mod?x+y-mod:x+y;}
int main()
{
	scanf("%d%d",&n,&k);
	f[0][0][0][1]=f[1][0][0][0]=1;
	for(int p=0;p<2;p++)
	for(int i=1;i<=n;i++)
	for(int j=0;j<=i;j++)
	{
		add(f[p][i][j][0],f[p][i-1][j][0]);
		add(f[p][i][j][0],f[p][i-1][j][1]);
		if(j)
		{
			add(f[p][i][j][0],f[p][i-1][j-1][0]);
			add(f[p][i][j][1],f[p][i-1][j-1][0]);
			add(f[p][i][j][1],f[p][i-1][j-1][1]);
		}
	}
	g[0][0]=1;
	for(int i=1;i<=2*k&&i<=n;i++)
	{
		int len=(n-i)/k/2+1,tp=i>k;
		p^=1;
		memset(g[p],0,sizeof g[p]);
		if(i+(len-1)*2*k+k>n)
		for(int p1=0;p1<=len;p1++)
		for(int p2=0;p2<=sum;p2++)
		add(g[p][p1+p2],1ll*g[p^1][p2]*f[tp][len][p1][0]%mod);
		else for(int p1=0;p1<=len;p1++)
		for(int p2=0;p2<=sum;p2++)
		add(g[p][p1+p2],1ll*g[p^1][p2]*(f[tp][len][p1][1]+f[tp][len][p1][0])%mod);
		sum+=len;
	}
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=0;i<=sum;i++)add(ans,1ll*(i&1?mod-1:1)*g[p][i]%mod*fac[n-i]%mod);
	printf("%d",ans);
}

Measured memory_bytes: 62336