akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin, a[i];
    }
    vector<vector<int>> G(n);
    REP(i, 0, n - 1) {
        int u, v;
        cin, u, v;
        u--;
        v--;
        G[v].push_back(u);
        G[u].push_back(v);
    }

    const ll inf = 1LL << 60;
    vector<ll> lis(n, inf);
    vector<ll> ans(n, 0);
    function<void(int, int)> dfs = [&](int pos, int prev) {
        auto it = lower_bound(lis.begin(), lis.end(), a[pos]);
        ll res = *it;
        *it = a[pos];
        ans[pos] = lower_bound(lis.begin(), lis.end(), inf) - lis.begin();
        for (int v : G[pos]) {
            if (v == prev) continue;
            dfs(v, pos);
        }
        *it = res;
    };
    dfs(0, -1);
    REP(i, 0, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

using LL = long long;
using VL = vector<LL>;
using STR = string;

#define REP(i, n) for (LL i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (LL i = LL(n) - 1; i >= 0; --i)

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

#define SZ(var) (LL)(var.size())

#define IN_LL(var) LL var; cin >> var;
#define IN_VL(var, n) VL var(n); REP(i, n) { cin >> var[i]; };
#define IN_STR(var) STR var; cin >> var;

#define OUT(var) cout << (var) << '\n';

void myMain();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	myMain();
	return 0;
}

void myMain() {
	IN_LL(K);
	IN_STR(S);

	if (SZ(S) <= K) {
		OUT(S);
	}
	else {
		S = S.substr(0, K);
		S += "...";
		OUT(S);
	}
}

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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 100;

int n;

pair<ll, int> a[maxn];

ll p[maxn];

int main(){
    #ifdef ONPC
    ifstream cin("a.in");
    ofstream cout("a.out");
    #endif
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i].first, a[i].second = i;
    sort(a, a + n);
    reverse(a, a + n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
        p[a[i].second] = sum - a[i].first * i, sum += a[i].first;
    ll mx = 0;
    for (int i = 0; i < n; i++){
        p[i] = sum - p[i];
        if (mx >= p[i])
            cout << 0;
        else
            cout << p[i] - mx, mx = p[i];
        cout << '\n';
    }
}


Measured memory_bytes: 3456
import java.util.Scanner;

class Main{
 public static void main(String[] args){

 Scanner sc = new Scanner(System.in);

    int w = sc.nextInt();
    int h = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();

if (x+r <= w && x-r >= 0 && y+r <= h && y-r >= 0){
System.out.println("Yes");
}else{
System.out.println("No");
}

}
} 


Measured memory_bytes: 26216
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
    int minn = INF ;
    int maxx = 0;
    int n,x;
    cin>>n;
    while(n--)
    {
        cin>>x;
        minn=min(minn,x);
        maxx=max(maxx,x);
    }
    cout<<maxx-minn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
 int w,a,b;
 cin>>w>>a>>b;
 if(a<b && a+w<b)cout<<b-(a+w)<<endl;
 else if(a>b && b+w<a) cout<<a-(b+w)<<endl;
 else cout<<0<<endl;
}

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

long long int cnt = 0;
vector<int> a;
vector<int> g;

void insertionSort(int n, int x){
  for(int i = x; i < n; i++){
    int v = a[i];
    int j = i - x;

    while(j >= 0 && a[j] > v){
      a[j+x] = a[j];
      j -= x;
      cnt++;
    }
    
      a[j+x] = v;    
  }
}

void shellSort(int n){
  
  for(int i = 1; i <= n; i = 3*i + 1){
    g.push_back(i);
  }

  for(int i = g.size() - 1; i >= 0; i--){
    insertionSort(n, g[i]);
  }
}

int main()
{
  int n;
  
  scanf("%d", &n);
  a.resize(n);

  for(int i = 0; i < n; i++) scanf("%d", &a[i]);

  shellSort(n);

  cout << g.size() << endl;

  for(int i = g.size() - 1; i >= 0; i--){
    printf("%d", g[i]);
    if(i) printf(" ");
    
  }

  printf("\n");

  printf("%lld\n", cnt);

  for(int i = 0; i < n; i++) printf("%d\n", a[i]);

  return 0;

}



Measured memory_bytes: 6748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N,M;
  cin >> N >> M;
  int X[M];
  for(int i=0;i<M;i++){
    cin >> X[i];
  }
  sort(X,X+M);
  int sum[M-1];
  for(int i=0;i<M-1;i++){
      sum[i]=X[i+1]-X[i];
  }
  sort(sum,sum+M-1);
  int ans=0;
  if(N<M){
    ans = X[M-1]-X[0];
    for(int j=0;j<N-1;j++){
      ans -= sum[M-2-j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3892
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        for(char i='a'; i<='z'; i++){
            if(s.indexOf(i)>=0){
                continue; //文字列内にアルファベットが含まれているとき
            }else{
                System.out.println(i);
                return;
            }
        }
        System.out.println("None");
    }
}


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

int n, m;
int cnt[100055];
bool can[100055];

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

	for (int i = 0; i < n; i++) cnt[i] = 1;

	can[0] = true;

	int x, y;

	while (m--) {
		scanf("%d %d", &x, &y);
		x--, y--;

		can[y] |= can[x];

		cnt[y]++;
		cnt[x]--;

		if (cnt[x] == 0) can[x] = false;
	}

	int res = 0;

	for (int i = 0; i < n; i++) res += can[i];

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int dp[maxn],n,t;
pair<int,int> book[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>t;
	int ans=0;
	for(int i=0;i<n;i++) cin>>book[i].fi>>book[i].se;
	sort(book,book+n);
	for(int i=0;i<n;i++)
	{
		for(int j=t-1;j>=0;j--)
		{
			ans=max(ans,dp[j]+book[i].se);
			if(j+book[i].fi<t) 
				dp[j+book[i].fi]=max(dp[j+book[i].fi],dp[j]+book[i].se);
		}
	}
	cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>

const int N = 26, D = 365;

using namespace std;
int main() {
    int d;
    cin >> d;
    vector<int> c(N);
    vector<vector<int>> s(D, vector<int>(N));
    for (int i = 0; i < N; ++i)
        cin >> c[i];
    for (int i = 0; i < d; ++i)
        for (int j = 0; j < N; ++j)
            cin >> s[i][j];
    vector<int> ans;
    vector<int> last(N, 0);
    for (int i = 1; i <= d; ++i) {
        int maxt = 0, maxg = INT_MIN;
        for (int j = 0; j < N; ++j) {
            int gain = s[i - 1][j];
            for (int k = 0; k < N; ++k)
                if (k != j)
                    gain -= c[k] * (i - last[k]);
            if (i < d) {
                int tmp = last[j];
                last[j] = i;
                int maxt2 = 0, maxg2 = INT_MIN;
                for (int k = 0; k < N; ++k) {
                    int gain2 = s[i][k];
                    for (int k2 = 0; k2 < N; ++k2)
                        if (k2 != k)
                            gain2 -= c[k2] * (i + 1 - last[k]);
                    if (gain2 > maxg2) {
                        maxg2 = gain2;
                        maxt2 = k;
                    }
                }
                last[j] = tmp;
                gain += maxg2;
            }
            if (gain > maxg) {
                maxg = gain;
                maxt = j;
            }
        }
        last[maxt] = i;
        ans.emplace_back(maxt + 1);
    }
    for (int i : ans)
        cout << i << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
//E:Knapsack 2

using namespace::std;

const int MAXV = 1e5 + 1;
long long DP[2][MAXV];

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

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

	fill(DP[0],DP[0] + MAXV,W + 1);
	DP[0][0] = 0;
	bool flag = true;
	for(int i = 1;i <= N;i++){
		int w,v;
		cin >> w >> v;

		for(int j = 0;j < MAXV;j++)
			DP[flag][j] = DP[!flag][j];

		for(int j = 0;j + v < MAXV;j++)
			DP[flag][j + v] = min(DP[!flag][j + v],DP[!flag][j] + w);
		flag = !flag;
	}

//	for(int i = 1;i <= N;i++)
//		cerr << i << ' ' << DP[!flag][i] << '\n';

	int sol = 0;
	for(int i = 1;i < MAXV;i++)
		if(DP[!flag][i] <= W)
			sol = max(sol,i);

	cout << sol << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    long int n;
    long int ans=0;
    long int i=1;

    scanf("%ld",&n);
    //printf("%ld\n",n);

    // for (i=1;i<=n;i++){
    //     if (i%3!=0 && i%5!=0)
    //         ans=ans+i;
    // }

    while (i<=n){
        if (i%3!=0 && i%5!=0)
            ans=ans+i;
        i++;
    }

    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll power(int k, int n, int M){
  if(n == 0) return 1;
  if(n == 1) return (ll)k;
  
  ll res = power(k, n/2, M);
  
  res = res * res % M;
  return n%2 == 1 ? res * k % M : res;
}


ll dp[SIZE] = {};

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

  ll sum = 0;
  dp[0] = 1;
  
  for(int i=1;i<=n+1;i++){
    sum += dp[i-1];
    dp[i] = sum % mod;
    if(i >= m) sum = (sum - dp[i-m] + mod) % mod;
  }

  cout << (power(2, n, mod) - dp[n+1] + mod) % mod << endl;
  
  
  
  return 0;
}




Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	string s1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(int I=0;I<s.length();I++)
	{
		for(int i=0;i<s1.length();i++)
		{
			if(s[I]==s1[i])
			{
				int x=i+n;
				if(x>25)
					x=x-26;
				//cout<<x<<endl;
				cout<<s1[x];
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  vector<double>x(n);
  vector<double>y(n);
  rep(i,n) cin >> x[i];
  rep(i,n) cin >> y[i];
  double d1=0,d2=0,d3=0,dinf=0;
  rep(i,n) d1+=abs(x[i]-y[i]);
  rep(i,n) d2+=pow(x[i]-y[i],2);
  d2=sqrt(d2);
  rep(i,n) d3+=abs(pow(x[i]-y[i],3));
  d3=pow(d3,0.3333333333333333333);
  rep(i,n){
    if(dinf<abs(x[i]-y[i]))dinf=abs(x[i]-y[i]);
  }
  cout << fixed << setprecision(10) << d1 << endl;
  cout << fixed << setprecision(10) << d2 << endl;
  cout << fixed << setprecision(10) << d3 << endl;
  cout << fixed << setprecision(10) << dinf << endl;
}



Measured memory_bytes: 3448
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

int main()
{
	ll N = 0;
	ll M = 0;
	ll tmp = 0;
	string ret = "YES";
	map< ll, ll > D;

	cin >> N;
	Rep(i, N) {
		cin >> tmp;
		D[tmp]++;
	}

	cin >> M;
	vector<ll> T(M, 0);
	Rep(i, M) {
		cin >> T[i];
	}

	// check
	Rep(m, M) {
		ll ckeck_no = T[m];

		// search
		if (D[ckeck_no] > 0) {
			D[ckeck_no]--;
		}
		else {
			ret = "NO";
			break;
		}
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#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()
 
int main() {
  int N,K; cin >>N>>K;
  vector<long long int> H(N);
  rep(i,N){
    cin>>H.at(i);
  }
  long long int sum=0;
  sort(all(H));
  if(N-K<=0){
    cout<<"0"<<endl;
  }else{
    rep(i,N-K){
      sum=sum+H.at(i);
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1792
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[N-1] == N:
    ans += 1

print(ans)


Measured memory_bytes: 14008
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 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',
];
#[allow(unused)]
const ALPHA: [char; 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',
];
fn main() {
    input!(N: usize, X: usize, T: usize);
    let ans = T * ((N + X - 1) / X);
    println!("{}", ans);
}


Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

double heron(double a, double b, double c){
  double s = (a + b + c) / 2.0;
  return sqrt(s * (s-a) * (s-b) * (s-c));
}

int main(){
  double a,l,x;
  while(cin >> a >> l >> x) printf("%.6f\n",heron(a,l,l) + heron(l,(l+x)/2.0,(l+x)/2.0)*2.0);
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int q;
	scanf("%d", &q);
	int k;
	for(int i = 0; i < q; i++) {
		scanf("%d", &k);
		printf("%ld\n", lower_bound(a.begin(), a.end(), k) - a.begin());
	}
}



Measured memory_bytes: 3408
S = input()

from collections import deque

q = deque([]) 

c = 0
for s in S:
    if len(q) == 0:
        q.append(s)
    else:
        p = q.pop()
        if s == p:
            q.append(s)
            q.append(s)
        else:
            c = c + 2
            
print(c)


Measured memory_bytes: 4212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        Map<Integer, List<Integer>> nexts = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = stdin.readLine();
            for (int j = 0; j < n; j++) {
                if (s.charAt(j) == '1') {
                    nexts.computeIfAbsent(i, unused -> new ArrayList<>()).add(j);
                    nexts.computeIfAbsent(j, unused -> new ArrayList<>()).add(i);
                }
            }
        }

        // 0:未着色, -1:white, 1:black
        int[] color = new int[n];
        Deque<Integer> stack = new ArrayDeque<>();
        stack.addLast(0);
        color[0] = 1;
        while (!stack.isEmpty()) {
            int current = stack.pollLast();
            for (int next : nexts.get(current)) {
                if (color[current] == color[next]) {
                    stdout.println(-1);
                    return ;
                }
                if (color[next] == 0) {
                    color[next] = color[current] * -1;
                    stack.addLast(next);
                }
            }
        }

        int[][] wf = new int[n][n];
        int inf = 100000000 + 7;
        for (int[] row : wf) {
            Arrays.fill(row, inf);
        }
        for (int i = 0; i < n; i++) {
            for (int j : nexts.get(i)) {
                wf[i][j] = 1;
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    wf[i][j] = Math.min(wf[i][j], wf[i][k] + wf[k][j]);
                }
            }
        }

        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (wf[i][j] != inf) {
                    max = Math.max(max, wf[i][j]);
                }
            }
        }
        stdout.println(max + 1);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 28628
n, q = list(map(int, input().split()))
cnt = [0 for _ in range(n + 1)]
cnt[0] = -9999999999
mx = [0, cnt[0]]


def spam():
    max_v = max(cnt)
    idx = min([i for i, value in enumerate(cnt) if value == max_v])
    return idx, max_v

for _ in range(q):
    a, v = list(map(int, input().split()))
    cnt[a] += v
    if mx[0] == a and v > 0:
        mx[1] += v

    elif mx[0] == a:
        mx[0], mx[1] = spam()

    elif mx[1] < cnt[a]:
        mx[0], mx[1] = a, cnt[a]

    elif mx[1] == cnt[a] and mx[0] > a:
        mx[0], mx[1] = a, cnt[a]

    print("%d %d" % (mx[0], mx[1]))

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

int main() {
	string s;
	int K;

	cin >> s;
	cin >> K;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') continue;
		if ('z' - s[i] + 1 <= K) { K -= 'z' - s[i] + 1; s[i] = 'a'; }
	}
	s[s.size() - 1] = 'a' + (s[s.size() - 1] - 'a' + K) % 26;

	cout << s << endl;

	return 0;
}

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

typedef long long ll;
using namespace std;

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

	int n,k; cin >> n >> k;
	ll ans = 0;

    for (int a = 1;a <= k;a++){
		if((a*2)%k != 0) continue;
		ll m = ((n-a)/k)+1;
		ans += m*m;
		//cout << a << " " << m*m << endl;;
    }

	ans *= n/k;

	for (int a = 1;a <= n%k;a++){
		if((a*2)%k != 0) continue;
		ll m = ((n-a)/k)+1;
		ans += m*m;
		//cout << a << " " << m*m << endl;;
    }

	cout << ans << endl;

/*	for (int a = ;a <= n;a++){
		if((a*2)%k != 0) continue;
		for (int b = a;b <= n;b += k){
            for (int c = b;c <= n;c += k){
				if((a+c)%k == 0){
					cout << a << b << c << endl;
				    if(a == b && b == c) ans += 1;
					//else if(a == b || b == c || c == a) ans += 3;
					//else ans += 6;
					else if(a == b || c == a) ans += 2;
					//else ans += 6;
					else ans += 1;
				}
            }
		}
    }
   
	cout << ans << endl;
*/
	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        if(N % 2 == 0){
            String s1 = S.substring(0, N / 2);
            String s2 = S.substring(N / 2, S.length());
            boolean f = true;
            for(int i = 0; i < s1.length(); i++){
                if(s1.charAt(i) != s2.charAt(i)){
                    f = false;
                    break;
                }
            }
            if(f){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}


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

int main() {
  int n,q; cin >> n;
  vector<int> A(n); 
  for (int i =0; i<n; i++) cin >> A.at(i);
  cin >> q;
  vector<int> m(q);
  for (int i =0; i<q; i++) cin >> m.at(i);
  
  for (int i =0; i<q; i++) {
    bool check =false;
    for (int tmp =0; tmp < (1 << n); tmp++) {
      int ans =0;
      bitset<20> bit(tmp);
      for (int j =0; j<20; j++) {
        ans += bit[j] * A[j];
      }
      if (ans == m.at(i)) {
        cout << "yes" << endl;
        check = true;
        break;
      }
    }
    if (!check) cout << "no" << endl; 
  }
}
  
  


Measured memory_bytes: 3116
h,n=map(int, input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
max_a=max(a)
dp=[float("inf")]*(h+max_a+1)
dp[0]=0
for i in range(h):
    for j in range(n):
        dp[i+a[j]] = min(dp[i+a[j]], dp[i]+b[j])
print(min(dp[h:]))

Measured memory_bytes: 42348
#include <iostream>
#include <cmath>

using namespace std;

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

    bool flag[N];

    for (int k = 0; k < N; ++k) {
        flag[k] = false;
    }

    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int tmp;
            cin >> tmp;
            if(!flag[tmp - 1]){
                flag[tmp - 1] = true;
            }
        }
    }

    auto count = 0;

    for (int l = 0; l < N; ++l) {
        if(flag[l] == 0){
            ++count;
        }
    }
    cout << count;
}



Measured memory_bytes: 3580
t = int(input())

def gcd(a, b):
  if a<b:
    a, b = b, a
  if b==0:
    return a
  return gcd(b, a%b)

for i in range(t):
  a, b, c, d = list(map(int, input().split()))
  if a<b or b>d or a%b>c:
    print("No")
  elif b==d:
    print("Yes")
  elif b-gcd(b, d)<=c:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
N = int(input())
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)

    # divisors.sort()
    return divisors
if (make_divisors(N)[-1])**2 ==N:
  print(2*make_divisors(N)[-1]-2)
else:
  print(make_divisors(N)[-1]+make_divisors(N)[-2]-2)


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main() {
    int d, n;
    cin >> d >> n;
    if(n != 100) {
        if(d == 0) {
            cout << n << endl;
        } else if(d == 1) {
            cout << n * 100 << endl;
        } else {
            cout << n * 10000 << endl;
        }
    } else {
        if(d == 0) {
            cout << 101 << endl;
        } else if(d == 1) {
            cout << 100 * 101 << endl;
        } else {
            cout << 10000 * 101 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		long ans = 0;
		long[] pows = new long[11];
		for(int i=0;i<11;i++) {
			pows[i] = (long) Math.pow(10, i);
		}

		while(k>0) {
			ans++;
			int[] digits = new int[(int) Math.log10(ans)+1];
			long tempans = ans;
			for(int i=0;i<digits.length;i++) {
				digits[i] = (int) (tempans/pows[digits.length-i-1]);
				tempans = (long) (tempans - digits[i]*pows[digits.length-i-1]);
			}
			boolean check = true;
			for(int i =0;i<digits.length-1;i++) {
				if(Math.abs(digits[i]-digits[i+1])>1) {
					ans = ans+pows[digits.length-i-2]-1;
					check=false;
					break;
				}
			}
			if(check)k--;
		}
		System.out.println(ans);
	}





}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 38868
import sys
a, b = map(int, raw_input().split())
s = raw_input()
num = [str(i) for i in xrange(10)]
for i in xrange(a):
    if not s[i] in num:
        print "No"
        sys.exit()

if not s[i+1] == "-":
    print "No"
    sys.exit()

for i in xrange(b):
    if not s[i+a+1] in num:
        print "No"
        sys.exit()

print "Yes"


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

int main(){
	int h,w,a,b;	cin>>h>>w>>a>>b;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i<b&&j<a)cout<<'0';
			else if(i>=b&&j>=a)cout<<'0';
			else cout<<"1";
		}
		cout<<endl;
	}

	return 0;
}


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

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B)
        cout << C << endl;
    if(B == C)
        cout << A << endl;
    if(A == C)
        cout << B << endl;
    
    return 0;
}

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

//関数
int ksum(int X){
    int ks=0;
    while(X>0){
        ks+=X%10;
        X-=X%10;
        X/=10;
    }
    return ks;
}
    
    
    
//main関数
int main() {
    
    
    
    //入力
    int N;
    cin>>N;
    
    
    
    
    
    
    
    
    
    
    //計算
    int result =1000000;
    for(int A=1;A<N;A++){
        result=min(ksum(A)+ksum(N-A),result);
        //cout <<A<<" "<<N-A<<" "<<ksum(A)+ksum(N-A)<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    //出力
    cout <<result<<endl;
}

Measured memory_bytes: 256
local ior = io.input()
local n, m = ior:read("*n", "*n")
local as, bs = {}, {}
for i = 1, m do
  as[i], bs[i] = ior:read("*n", "*n")
end

local parent = {}
local rootlist = {}
local score = {}
for i = 1, n do parent[i], score[i] = 0, 0 end

local function getroot(idx)
  while(parent[idx] ~= 0) do
    idx = parent[idx]
  end
  return idx
end

score[m] = 0
for i = m, 2, -1 do
  local sc = 0
  local a, b = as[i], bs[i]
  local ar, br = getroot(a), getroot(b)
  if(ar ~= a) then parent[a] = ar end
  if(br ~= b) then parent[b] = br end
  if(ar == br) then
    -- nothing
  elseif(ar == a and br == b) then
    parent[b] = a
    if(rootlist[b] == nil) then
      if(rootlist[a] == nil) then rootlist[a], sc = 2, 1
      else
        sc = rootlist[a]
        rootlist[a] = sc + 1
      end
    else
      if(rootlist[a] == nil) then
        sc = rootlist[b]
        rootlist[a] = sc + 1
      else
        local tmp1, tmp2 = rootlist[a], rootlist[b]
        sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
        rootlist[a] = tmp1 + tmp2
      end
      rootlist[b] = nil
    end
  elseif(ar == a) then
    parent[a] = br
    if(rootlist[a] == nil) then
      sc = rootlist[br]
      rootlist[br] = sc + 1
    else
      local tmp1, tmp2 = rootlist[br], rootlist[a]
      sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
      rootlist[br] = tmp1 + tmp2
      rootlist[a] = nil
    end
  elseif(br == b) then
    parent[b] = ar
    if(rootlist[b] == nil) then
      sc = rootlist[ar]
      rootlist[ar] = sc + 1
    else
      local tmp1, tmp2 = rootlist[ar], rootlist[b]
      sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
      rootlist[ar] = tmp1 + tmp2
      rootlist[b] = nil
    end
  elseif(ar ~= br) then
    parent[br] = ar
    local tmp1, tmp2 = rootlist[ar], rootlist[br]
    sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
    rootlist[ar] = tmp1 + tmp2
    rootlist[br] = nil
  end
  score[i - 1] = score[i] + sc
end
local mx = n * (n - 1) / 2
for i = 1, m do
  print(mx - score[i])
end


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

using namespace std;

long long lcm(long long a, long long b){
	return (a*b)/__gcd(a, b);
}

long long f(long long X, long long Y, long long Z){
	return X - (X/Y) - (X/Z) + X/lcm(Y, Z);
}

int main(){
	long long A, B, C, D;
	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
	
	printf("%lld", f(B, C, D) - f(A-1, C, D));
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}



int main(void){
    llint n,i,water=0,base=0,k=0;
    scanf("%lld",&n);
    llint h[n+1];
    for(i=1;i<n+1;i++){
        scanf("%lld",&h[i]);
    }
    h[0]=0;
    for(i=0;i<n;i++){
        if(h[i]<=h[i+1]) k=h[i+1]-base;
        if(h[i]>h[i+1]){
            base=h[i+1];
            water+=k;
            k=0;
        }
    }
    water+=k;

    printf("%lld\n",water);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

long long cnt = 0;

void insertion_sort(int A[], int N, int g) {
    for (int i = g; i < N; i++) {
        int j = i - g;
        int v = A[i];
        while (j >= 0 && v < A[j]) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int A[], int N) {
    vector<int> G;
    for (int i = 1;;) {
        if (i > N)
            break;
        G.push_back(i);
        i = 3 * i + 1;
    }
    cout << G.size() << endl;
    for ( int i = G.size() - 1; i >= 0; i--) {
        if (i == 0) {
            cout << G[i] << endl;
        } else {
            cout << G[i] << " ";
        }
        insertion_sort(A, N, G[i]);
    }
    cout << cnt << endl;
}

int main() {
    int n;
    int array[1000000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> array[i];

    shell_sort(array, n);
    for (int i = 0; i < n; i++)
        cout << array[i] << endl;

    return 0;
}


Measured memory_bytes: 7064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	//C
	int n;
	cin >> n;
	vector<int> a(n);
	int g ;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	g = a[0];
	for (int i = 0; i < n; i++) {
		g = __gcd(a[i], g);
	}
	cout << g << endl;
	return 0;	
}

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

int main() {
  int N;
  cin >> N;
  vector<int>data(3*N);
  for(int i=0;i<3*N;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int64_t count=0;
  for(int i=0;i<N;i++){
    count += data.at(2*i+1);
  }
  cout << count << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
	int a,b,i,j=1;
	scanf("%d%d",&a,&b);
	if(a>b){i=a;a=b;b=i;}
	while(a!=b){
		if(a>b){i=a;a=b;b=i;}
		j=b-a;b=j;}
	printf("%d\n",a);}


Measured memory_bytes: 2724
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

h, w = map(int, input().split())
ma = [ list(map(int,input().split(" "))) for i in range(10)]
sco = [ list(map(int,input().split(" "))) for i in range(h)]
a = csr_matrix(ma)
b = shortest_path(a)
ans = 0
for i in range(h):
  for j in range(w):
    num = sco[i][j]
    if num != -1:
      ans += b[num][1]
print(int(ans))

Measured memory_bytes: 14092
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
V = 10**5+5

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.size_x = [1 - i//V for i in range(N)]
        self.size_y = [i//V for i in range(N)]
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
            self.size_x[rb] += self.size_x[ra]
            self.size_y[rb] += self.size_y[ra]
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
            self.size_x[ra] += self.size_x[rb]
            self.size_y[ra] += self.size_y[rb]

uf = UnionFind(V*2)

for x,y in XY:
    uf.unite(x,y+V)
for i in range(V*2):
    uf.root(i)

ans = 0
used = set()
for i in range(V*2):
    r = uf.root(i)
    if r in used: continue
    used.add(r)
    ans += uf.size_x[r] * uf.size_y[r]
ans -= N
print(ans)

Measured memory_bytes: 47024
h,w = map(int,input().split())

f = []

for i in range(h):
    f.append(list(input()))
    
a = []
    
for i in range(len(f)):
    if f[i] == ["."]*len(f[i]):
        a.append(i)
        
for i in a:
    del f[i]
    for s in range(len(a)):
        a[s] -= 1
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
b = []
    
for i in range(len(f2)):
    if f2[i] == ["."]*len(f2[i]):
        b.append(i)
        
for i in b:
    del f2[i]
    for s in range(len(b)):
        b[s] -= 1
        
ff = []

for i in range(len(f2[0])):
    s = []
    
    for k in f2:
        s.append(k[i])
        
    ff.append(s)
        
for i in ff:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef unsigned long ul;
using namespace std;

int main() {
	int n,a,b,c,d;
	int count=0;
	int flag=0;
	int f=0;
	int i;
	string s;

	cin >> n >> a >> b >> c >> d;
	cin >> s;

	if(c>d && (s[d-2]=='#' || s[d] == '#')){
		f=1;
	}

	if(f==0){
        for(i=b-1; i<d; i++){
		if(s[i]=='#') count++;
		else count=0;

		if(count==2){
			cout << "No" << endl;
			flag = 1;
		    } 
	    }
		s[d-1] == '#';
		for(i=a-1; i<c; i++){
		    if(s[i]=='#') count++;
		    else count=0;

		    if(count==2){
			    cout << "No" << endl;
			    flag = 1;
                break;
			} 
		}
	}else{
		count=0;
        if(s[b-2]=='.' && s[b]=='.'){
            s[b-1] = '#';
        }else{
            for(i=b-1; i<d; i++){
                if(s[i]=='.') count++;
                else count=0;
                if(count==3){
                    s[i-1] = '#';
                    b = i;
                    i = 0;
                    break;
                }
            }

        }    
		if(i==d){
			flag = 1;
			cout << "No" << endl;
		}
		else{
			for(i=a-1; i<c; i++){
			if(s[i]=='#') count++;
			else count=0;

			if(count==2){
				cout << "No" << endl;
				flag = 1;
				} 
			}
			if(flag==0){
                s[c-1] = '#';
				for(i=b-1; i<d; i++){
				if(s[i]=='#') count++;
				else count=0;

				if(count==2){
					cout << "No" << endl;
					flag = 1;
					} 
				}
			}
		}	
	}
	
	if(flag == 0){
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 640
N = int(input())
L = []
for i in range(N):
    L.append([])
    A = int(input())
    for j in range(A):
        x,y = map(int, input().split())
        L[i].append([x-1,y])
ans = 0
for i in range(2**N):
    ok = True
    for j in range(N):
        if (i & (1 << j)) != 0:
            for x,y in L[j]:
                truth = (i & (1<<x)) == 0
                claim = y == 0
                if(truth != claim):
                    ok = False
    # set i is possible
    if ok:
        # count bits that are 1
        ans = max(ans, bin(i).count('1'))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
	int n,b=0;
	scanf("%i",&n);
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 && a[i]%5!=0)
			{
				b=1;
				break;
			}
		}
	}
	if(b==0)	printf("APPROVED");
	else printf("DENIED");
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long A, long long B){
  cout << min(B,N*A) << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define MAX 2001
#define NIL -1
#define B -2
#define W -1
#define G 0
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

int d[MAX];
int p[MAX];
int color[MAX];
int n;
int u;
int k;
int c;
int v;
int M[MAX][MAX];
queue <int> Q;

void DIJKSTRA() {
	for (int i = 0; i < n; i++) {
	    d[i] = 9000000;
		p[i] = NIL;
		color[i] = W;
	}
	d[0] = 0;
	color[0] = B;
	int s = 0;
	Q.pop();
	int count = 0;
	while (!Q.empty()) {
		count++;
		for (int i = 0; i < n; i++) {
			if (M[s][i] != -1 && color[i] != B) {
				
				if (d[i] > d[s] + M[s][i]) {
					
					d[i] = d[s] + M[s][i];
					p[i] = s;
					color[i] = G;
					
					
				}
			}
		}
		int a = 0;
		int mini = MAX;
		for (int j = 0; j < n; j++) {
			
			if (color[j] == G) {
		
				if(mini>d[j]){
					a = j;
				}
				mini = min(mini, d[j]);
			}

		}
		s = a;
		color[a] = B;
		Q.pop();
		
	}
	
}
int main(){

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = -1;
		}
	}

	for (int i = 0; i < n; i++) {
		cin >> u; cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
			Q.push(i);
		}
	}

	DIJKSTRA();
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3576
#include <stdio.h>

int main(void) {

  int S, h, m, s;
  scanf("%d", &S);

  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
using namespace std;


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

vector<double>v;
double k;
for(int i=0;i<N;i++){
cin>>k;
v.push_back(k);
}

sort(v.begin(),v.end());

for(int i=0;i<N-1;i++){
    v[i+1]=(v[i]+v[i+1])/2;
}
cout<<v[N-1]<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d,e;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  d=max(max(a,b),c);
  e=min(min(a,b),c);
  printf("%d",d-e);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int main(){
  double L; cin >> L;
  double l = L/3;
  cout << fixed << setprecision(7);
  cout << l*l*l << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      if(A>=13){
        Console.WriteLine(B);
      }else if(A>=6){
        Console.WriteLine(B/2);
      }else{
        Console.WriteLine(0);
      }
     
    }
    
  }

}


Measured memory_bytes: 27516
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define int long long

inline int read () {
    int ret = 0, t = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') t = -1, c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret * t;
}

int n, k;
int a[200200] = {};

bool check (int x) {
    int i, j;
    int ret = 0;
    for (i = 1; i <= n; i++) {
        int l = 1, r = n, ans = 0;
        if (a[i] > 0) {
            while (l <= r) {
                int mid = (l + r) >> 1;
                if (a[i] * a[mid] < x) ans = mid, l = mid + 1;
                else r = mid - 1;
            }
            if (a[i] * a[i] < x && ans >= i) ans--;
        }
        else {
            ans = n + 1;
            while (l <= r) {
                int mid = (l + r) >> 1;
                if (a[i] * a[mid] < x) ans = mid, r = mid - 1;
                else l = mid + 1;
            }
            if (a[i] * a[i] < x && ans <= i) ans++;
            ans = n - ans + 1;
        }
        //printf("%lld %lld\n", ans, i);
        ret += ans;
    }
    //printf("%lld %lld\n", x, ret / 2 + 1); puts("=======");
    if (ret / 2 + 1 <= k) return true; return false;
}

signed main () {
    n = read(), k = read();
    int i, j;
    for (i = 1; i <= n; i++) a[i] = read(); sort(a + 1, a + n + 1);
    int l = -1000000000000000000ll, r = 1000000000000000000ll, ans;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
// Aizu Vol-10 1029: Traffic Analysis
// 2017.8.19 bal4u@uu

#include <stdio.h>

#define MAX 10000
int a[MAX + 5], b[MAX + 5], n, m;
int max;

int main()
{
	int i, j, s, t;

	while (scanf("%d%d", &n, &m) && (n || m)) {
		for (i = 0; i < n; i++) scanf("%d", a + i);
		for (i = 0; i < m; i++) scanf("%d", b + i);
		max = i = j = 0, s = 0, t = -1;
		while (i < n || j < m) {
			if (i < n) {
				if (s == a[i]) i++;
				if (i < n) t = a[i];
			}
			if (j < m) {
				if (s == b[j]) j++;
				if (j < m && (t < 0 || b[j] < t)) t = b[j];
			}
			if (t >= 0) {
				if (i < n && t == a[i]) i++;
				if (j < m && t == b[j]) j++;
				if (t - s > max) max = t - s;
				s = t;
				t = -1;
			}
		}
		if (t >= 0 && t - s > max) max = t - s;
		printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 676
/** In the Name of ALLAH */


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

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

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



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const int mx = 1e5+123;
int per[mx];

int main()
{
	optimize();

	for ( int i = 1; i*i < mx; i++ ) {
		per[i*i] = i;
	}


	int n;
	cin >> n;
	for ( int i = 1; i <= n; i++ ) {

		int cnt = 0;

		for ( int x = 1; x*x <= i; x++ ) {
			for ( int y = 1; y*y <= i; y++ ) {
				int a = 1;
				int b = x + y;
				int c = i - (x*x) - (y*y) - (x*y);


				int d1 = (b*b) + (4 * a * c);

				if ( d1 < 0 ) continue;
				else if ( per[d1] == 0 ) continue;
				else if (per[d1] - b <= 0 ) continue;

				if ( (per[d1]- b) % (2*a) == 0 ) {
					cnt++;
				}
			}
		}

		cout << cnt << endl;
	}


	return 0;
}



Measured memory_bytes: 4020
s = int(input())
a = [s]
an = s
cnt = 0

for i in range(10**6):
	if an%2 == 0:
		an //=2
		a.append(an)
	else:
		an = 3*an+1
		a.append(an)

for j in range(len(a)):
	cnt += 1
	if a[j] == a[j+3]:
		cnt += 3
		break
print(cnt)

Measured memory_bytes: 10900
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	int H, W;
	string data;
	cin >> H >> W;

	for(int i = 0; i < W + 2; i++){
		cout << "#";
	}
	cout << endl;

	for(int i = 0; i < H; i++){
		cout << "#";
		cin >> data;
		cout << data;
		cout << "#" << endl;
	}

	for(int i = 0; i < W + 2; i++){
		cout << "#";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256