akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int in[200050];
int main() {
	int N, M, i;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= 2 * N; i++) scanf("%d", &in[i]);

	sort(in + 1, in + 2 * N + 1);

	int st = 0, en = M - 2, mi, rv = M - 1;
	while (st <= en) {
		mi = (st + en) / 2;

		int st2 = 1, en2 = N, mi2, rv2 = 0;
		while (st2 <= en2) {
			mi2 = (st2 + en2) / 2;
			
			int v = 0;
			for (i = 1; i <= mi2; i++) v = max(v, in[i] + in[2 * mi2 + 1 - i]);
			
			if (v <= mi) {
				rv2 = mi2;
				st2 = mi2 + 1;
			}
			else en2 = mi2 - 1;
		}

		int mn = 0, mx = N;
		for (i = 1; i <= N; i++) {
			int t = 2 * N - i + 1;
			int S = lower_bound(in + 1, in + 2 * N + 1, M - in[t]) - in;
			int E = lower_bound(in + 1, in + 2 * N + 1, M + mi + 1 - in[t]) - in;
			E = min(E, t);

			mn = max(mn, (4 * N + 1 - E - t) / 2 + 1);
			mx = min(mx, (4 * N + 1 - S - t) / 2);
			if (mn <= i && i <= mx && i >= N - rv2) break;
		}
		if (rv2 == N || i <= N) {
			rv = mi;
			en = mi - 1;
		}
		else st = mi + 1;
	}
	return !printf("%d\n", rv);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    int arr[n];
    rep(i,0,n)
        scanf("%d",&arr[i]);

    ll s=arr[0];
    rep(i,1,n){
        s^= arr[i];
    }
    rep(i,0,n){
        printf("%lld ",s^arr[i]);
    }
}


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

int main(void)
{
    int n = 0;
    char ch[4];
    for (int i = 0; i < 4; i++) {
        cin >> ch[i];
        if (ch[i] == '+') {
            n++;
        }   
        else {
            n--;
        }   
    }   
    cout << n << endl;
    return 0;
}
 

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

Measured memory_bytes: 256
lower = [chr(i) for i in range(97, 97+26)]
lower_dict = {l:"a" for l in lower}
upper = [chr(i) for i in range(65, 65+26)]
upper_dict = {u:"A" for u in upper}
all_dict= {**lower_dict, **upper_dict}

print(all_dict[input()])


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define xrep(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
string dumpd(vector<double> vs) { string out = "[";for (int i = 0; i < vs.size(); ++i) {if (i == vs.size() - 1) {out += to_string(vs[i]);} else {out += to_string(vs[i]) + ", ";}}out += "]";return out;}
string dumpi(vector<int> vs) {string out = "[";for (int i = 0; i < vs.size(); ++i) {if (i == vs.size() - 1) {out += to_string(vs[i]);} else {out += to_string(vs[i]) + ", ";}}out += "]";return out;}
typedef long long ll;

int N, K;
int d;
set<int> A;
int main() {
  cin >> N >> K;
  int a;
  rep(i, K) {
    cin >> d; 
    rep(j, d) {
      cin >> a;
      A.insert(a);
    }
  }

  cout << N - A.size() << endl;

  

  
  return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;

class J
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(int.Parse).ToLookup(x => x);
		var d = Enumerable.Range(0, 4).Select(i => a[i].Count()).ToArray();
		int s3 = d[3], s2 = s3 + d[2], s1 = s2 + d[1];

		var dp = new double[s3 + 1, s2 + 1, s1 + 1];
		for (int i = 0; i <= s3; i++)
			for (int j = 0; i + j <= s2; j++)
				for (int k = 0, r; (r = i + j + k) <= s1; k++)
					dp[i, j, k] = r == 0 ? 0 : (s1 +
						i * (i > 0 ? dp[i - 1, j + 1, k] : 0) +
						j * (j > 0 ? dp[i, j - 1, k + 1] : 0) +
						k * (k > 0 ? dp[i, j, k - 1] : 0)) / r;
		Console.WriteLine(dp[d[3], d[2], d[1]]);
	}
}


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

int main(){
  int n, i, j, temp;
  cin >> n;
  int a[n];
  for(i = 0; i < n; i++) cin >> a[i];
  for(i = 0; i < n; i++){
    for(j = i + 1; j < n; j++){
      if(a[i] < a[j]){
	temp = a[i];
	a[i] = a[j];
	a[j] = temp;
      }
    }
  }
  cout << a[0] - a[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
ans = []
for i in range(N+1):
    for j in range(N+1-i):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            ans = [i,j,N-i-j]
if len(ans) == 0:
    print('-1 -1 -1')
else:
    print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        String [] str = new String [a];
        for(int i=0;i<a;i++){str[i] = sc.next();
                             in[i] = sc.nextInt();
                            }
		String s = sc.next();
        int b = 0;
		int c = 0;
        for(int i=0;i<a;i++){if(s.equals(str[i])){c=i;break;
                                                 }
                            }
        for(int i=c+1;i<a;i++){b+=in[i];
                              }
		System.out.println(b);
	}
}


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

int main(){
	int n, min, sub;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i != n; i++){
		cin >> a[i];
		if (i == 0) min = a[0];
		if (i == 1) sub = a[1] - a[0];
		if (i > 1 && sub < a[i] - min) sub = a[i] - min;
		if (i > 0 && a[i] < min) min = a[i];
	}
	cout << sub << endl;
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
	int n;
	int t;
	cin>>t;
	if(!t) break;
	cin>>n;
	int a=0;
	for(int i=0;i<n;++i){
	    int b,c;
	    cin>>b>>c;
	    a+=c-b;
	}
	if(a<t) cout<<t-a<<endl;
	else cout<<"OK"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3012
ans = [int(input())]
import sys
for e in sys.stdin:
    inp = list(map(int, e.split(",")))
    l = len(inp)
    if l > len(ans):
        tmp = [-float("inf")] + ans + [-float("inf")]
    else:
        tmp = ans
    ans = []
    for i in range(l):
        ans += [max([tmp[i] + inp[i], tmp[i + 1] + inp[i]])]
print(*ans)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
    Int N,M;
    cin >> N >> M;
    using tp = tuple<Int,Int>;
    vector<vector<tp>>edge(N);
    for(Int v = 0; v + 1 < N; ++v){
        edge[v + 1].emplace_back(v,0LL);
    }
    for(int i = 0; i < M; ++i){
        Int u,v,c;
        cin >> u >> v >> c; --u; --v;
        edge[u].emplace_back(v,c);
        //edge[v].emplace_back(u,c);
    }
    constexpr Int inf = (1LL << 60);
    vector<Int>d(N,inf);

    priority_queue<tp,vector<tp>,greater<>>que;
    que.emplace(0,0);
    d[0] = 0;
    while(not que.empty()) {
        auto p = que.top(); que.pop();
        Int crt,v;
        tie(crt,v) = p;
        if(crt > d[v]) continue;
        for(auto tup : edge[v]){
            
            Int nv,cost;
            tie(nv,cost) = tup;
            if(cost + crt >= d[nv]) continue;
            d[nv] = cost + crt;
            que.emplace(d[nv],nv);
        }
    }
    cout << (d.back() == inf ? -1 : d.back()) << endl;
}


Measured memory_bytes: 10104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int k; cin >> k;
    string s; cin >> s;
    int n = s.size();
    if(n <= k){
        cout << s << endl;
    }
    else{
        string t = s.substr(0,k);
        cout << t << "..." << endl;
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>

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

// grid-repainting-2.cpp --- Grid Repainting 2
// author: Seong Yong-ju <sei40kr@gmail.com>

using namespace std;

int h, w;
bool data[52][52];

bool check() {
  FOR(i, 1, 51) {
    FOR(j, 1, 51) {
      if (data[i][j] && !data[i - 1][j] && !data[i + 1][j] && !data[i][j - 1] &&
          !data[i][j + 1]) {
        return false;
      }
    }
  }

  return true;
}

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

  fill((bool *)&data[0], (bool *)&data[51], false);

  cin >> h >> w;
  REP(i, h) {
    string s;
    cin >> s;

    REP(j, w) { data[i + 1][j + 1] = s[j] == '#'; }
  }

  cout << (check() ? "Yes" : "No") << endl;
}


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

int main(){
  ll h,w;
  cin>>h>>w;
  ll ans;
  if(h==1||w==1) ans=1;
  else if(h%2==0)
    ans=h*w/2;
  else
    ans=(h-1)*w/2+(w+1)/2;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
import math
n, m = map(int, input().split())
x = abs(n - m)
ans = 0
if x == 0:
    ans = 2 * math.factorial(n) * math.factorial(m) % (10 ** 9 + 7)
elif x == 1:
    ans = math.factorial(n) * math.factorial(m) % (10 ** 9 + 7)
print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int L = S.length();
    REP(i,L){
        char c = S[i];
        if(c == 'o'){
            ans += 1;
        }
    }

    ans += 15 - L;

    if(ans >= 8){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


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


long long int kazu(long long int x){
    if(x==1){
        return 1;
    }
    else{
        return( 2*kazu(x/2) + 1 );
    }
}

int main() {
    long long int H;
    cin >> H;
    cout << kazu(H) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxi=200010;
long long  a[maxi],n,x,sum,k,i;
int main()
{
    while (cin>>n>>x)
    {
          for (i=0;i<n;i++)
             cin>>a[i];
          sum=0;
         if (a[0]>x)
         {
             sum+=a[0]-x;
             a[0]=x;
         }
         for (i=1;i<n;i++)
         {
             k = a[i]+a[i-1]-x;
             if (k>0)
             {
                 sum+=k;
                 a[i]-=k;
             }
         }
         cout<<sum<<endl;
     }
     return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args) {
	try(Scanner sc = new Scanner(System.in)) {
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		double pi = 3.14;
		
		int m = w * h;
		double n = z * z * pi;
		
		
	if(x < w && y < h && 0 < x && 0 < y && 0 < z && z <= x && z <= y)
		if(n < m)
			System.out.println("Yes");
		else
			System.out.println("No");
	else
		System.out.println("No");
			
	}
}
}



Measured memory_bytes: 26272
loop do
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0
  (1..h).each do |y|
    line =
    if y == 1 || y == h
      '#' * w
    else
      '#' + ('.' * (w - 2)) + '#'
    end
    puts line
  end
  puts
end

Measured memory_bytes: 8936
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, q = LI()
L = LIR(q)
ans = 0
def f(arr):
    global ans
    if len(arr) == n:
        ret = 0
        for a, b, c, d in L:
            if arr[b - 1] - arr[a - 1] == c:
                ret += d
        ans = max(ans, ret)
    else:
        if arr:
            for k in range(arr[-1], m + 1):
                f(arr + [k])
        else:
            for k in range(1, m + 1):
                f(arr + [k])

f([])
print(ans)

Measured memory_bytes: 82468
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    re(i, n) cin >> a[i];

    long long max = 1;
    long long step_sum = 0;
    re(i, n) {
        if (max >= a[i])
            step_sum += max - a[i];
        else
            max = a[i];
    }

    cout << step_sum << endl;

    return 0;
}

Measured memory_bytes: 4760
n,l=map(int,input().split())
aji=[l+_ for _ in range(n)]
#print(aji)
#print("y") if 0 in aji else print("NO")
if 0 in aji:
    print(sum(aji))
else:
    kei=sum(aji)
    if max(aji)<0:
        print(kei-max(aji))
    else:
        print(kei-min(aji))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}

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

int main(){
    int n, t, l, b, x;
    while(cin >> n >> t >> l >> b, n+t+l+b){
        vector<int> mass(n+1, 0);
        while(l-- > 0){
            cin >> x;
            mass[x] = 1;
        }
        while(b-- > 0){
            cin >> x;
            mass[x] = 2;
        }
        vector<vector<double>> dp(2, vector<double>(n+1, 0));
        dp[0][0] = 1.0;
        for(int i = 0; i < t; i++){
            vector<vector<double>> ndp(2, vector<double>(n+1, 0));
            for(int j = 0; j < n; j++){
                for(int k = 1; k <= 6; k++){
                    int next = j+k;
                    if(next > n)    next = n - (next-n);
                    if(mass[next] == 1)         ndp[1][next] += dp[0][j]/6;
                    else if(mass[next] == 2)    ndp[0][0] += dp[0][j]/6;
                    else if(mass[next] == 0)    ndp[0][next] += dp[0][j]/6;
                }
            }
            for(int j = 0; j < n; j++)  ndp[0][j] += dp[1][j];
            ndp[0][n] += dp[0][n];
            dp = ndp;
        }
        cout << fixed << setprecision(12) << dp[0][n] << endl;
    }
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 modpow(int64 n, int64 r){
    if(r == 0){
        return 1;
    }
    if(r % 2 == 0){
        int64 x = modpow(n, r / 2);
        return x * x % MOD;
    }else{
        return modpow(n, r - 1) * n % MOD;
    }
}

int64 comb(int64 n, int64 r){
    int64 retval = 1;
    r = min(r, n - r);
    REP(i,r){
        retval *= n - i;
        retval %= MOD;
        retval *= modpow(i+1, MOD-2);
        retval %= MOD;
    }
    return retval;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x,y;
    cin >> x >> y;
    if((x + y) % 3 != 0 || x * 2 < y || y * 2 < x){
        cout << 0 << endl;
        return 0;
    }
    int32 d = abs(x - y);
    int32 n = (x + y) / 3;
    cout << comb(n, (n - d) / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, h, w int
	fmt.Scan(&n, &h, &w)
	count := 0
	for i := 0; i+h <= n; i++ {
		for j := 0; j+w <= n; j++ {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1768
from collections import deque

N = int(input())
inf = 10 ** 6
graph = [[] for i in range(N)]
distance = [inf for i in range(N)]

for i in range(N):
  a = list(map(int,input().split()))
  a = list(map(lambda x: x - 1,a))
  k,n = a[0],a[1]
  if n >= 0:
    graph[k] = a[2:]
    

def bfs(path,root,dist):
  dist[root] = 0
  queue = deque([root])
  while queue:
    cur = queue.popleft()
    for chi in path[cur]:
      if dist[chi] == inf:
        queue.append(chi)
      dist[chi] = min(dist[cur] + 1,dist[chi])

bfs(graph,0,distance)
distance = [-1 if i == inf else i for i in distance]

for i,j in enumerate(distance):
  print(i + 1,j)
  


Measured memory_bytes: 6040
#include<iostream>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int color[N];
int M[N][N];
int n,cnt;

void prim(){
	int d[N],p[N];
	for(int i=0;i<n;i++){
		color[i] = WHITE;
		d[i] = INFTY;
	}
	d[0]=0;p[0]=-1;
	int u;
	
	while(1){
		int mincost=INFTY;
		for(int i=0;i<n;i++){
			if(color[i] != BLACK && d[i] < mincost){
				mincost = d[i];
				u = i;
			}
		}
		if(mincost == INFTY)break;
		cnt += mincost;
		color[u] = BLACK;
		for(int i=0;i<n;i++){
			if(color[i] != BLACK && M[u][i] != INFTY){
				if(d[i] > M[u][i]){
					d[i] = M[u][i];
					p[i] = u;
					color[i] = GRAY;
				}
			}
		}
	}
}

int main(){
	cnt = 0;
	int d;
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> d;
			M[i][j] = (d!=-1?d:INFTY);
		}
	}
	prim();
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3116
n,m=map(int,input().split())
kusuri=[]
for i in range(n):
    a,b=map(int,input().split())
    kusuri.append([a,b])
kusuri.sort()
c=0
N=0
ans=0
while c!=m:
    if c+kusuri[N][1] <=m:
        c+=kusuri[N][1]
        ans+=kusuri[N][1]*kusuri[N][0]
    else :
        ans+=(m-c)*kusuri[N][0]
        c=m
    N+=1
print(ans)

Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;
int c[5][5],b[4][4];
int main(){
    for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
    cin>>c[i][j];
    for(int a1=0;a1<=100;a1++){
        b[1][1]=c[1][1]-a1;
        b[2][1]=c[1][2]-a1;
        b[3][1]=c[1][3]-a1;
        for(int a2=0;a2<=100;a2++){
            b[1][2]=c[2][1]-a2;
            b[2][2]=c[2][2]-a2;
            b[3][2]=c[2][3]-a2;
            if(b[1][1]!=b[1][2]||b[2][1]!=b[2][2]||b[3][1]!=b[3][2])
            	continue;
            for(int a3=0;a3<=100;a3++){
	            b[1][3]=c[3][1]-a3;
	            b[2][3]=c[3][2]-a3;
	            b[3][3]=c[3][3]-a3;
	            if(b[1][1]==b[1][3]&&b[2][1]==b[2][3]&&b[3][1]==b[3][3]){
    	        	cout<<"Yes";
        	    	return 0;
            	}
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    vector<int> abc(3);
    int ans;
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(),abc.end());
    ans = abc[2]*10+abc[0]+abc[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 x = sc.nextInt();
		int y = sc.nextInt();
		
		for (int i=0; i <= x; i++) {
		    int b = x - i;
		    if (2*i + 4*b == y) {
		        System.out.println("Yes");
				System.exit(0);
		    }
		}
		System.out.println("No");
    }
}

Measured memory_bytes: 35864
#include <iostream>
#include <math.h>
#include <string.h>

using namespace std;

const int MAX_N = 24;

class Circle {
public:
	short x, y, r, c; // 中心のxy座標、半径、色番号
};

/* 入力 */
int n; // 円盤の枚数
Circle cir[MAX_N]; // 円の情報

/*
S:すでに取り除いた円の集合(bitで表す、右から円番号0,1,2,...,MAX_N)
dp[S]:ここから取り除ける最大枚数
漸化式
dp[全部取り除いた] = n
dp[S] = max(dp[S U 取り除いた2つの円]+2)
*/
short dp[1 << MAX_N];

/* 2点間の距離 */
double dis(char x1, char y1, char x2, char y2) {
	return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

/* 円kが上に1枚でも重なっているかどうか、重なっていたらtrue */
bool ispiled(int k, int S) {
	for (int i = k - 1; i >= 0; i--) {
		if (dis(cir[i].x, cir[i].y, cir[k].x, cir[k].y) < cir[i].r + cir[k].r && !(S >> i & 1)) {
			return true;
		}
	}
	return false;
}
/*
bool ispiled(Circle c1, Circle c2) {
	if (dis(c1.x, c1.y, c2.x, c2.y) < c1.r + c2.r) {
		return true;
	}

	return false;
}
*/

/* S:すでに取り除いた円盤の集合 */
short remove(int S) {
	//cout << "S = " << S << " dp[" << S << "]: " << dp[S] << endl;
	if (dp[S] >= 0) {
		return dp[S];
	}
	
        /* 全部取り除いた */
	if (S == ((1 << n) - 1)) {
		return dp[S] = n;
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		if (S >> i & 1 || ispiled(i, S)) {
			continue;
		}
		for (int j = i + 1; j < n; j++) {
			/* どちらかがすでに取り除かれているか、2つの色が違うか、2枚のうち1枚以上が下にあれば取り除けないので次の組へ */
			if (S >> j & 1 || cir[i].c != cir[j].c || ispiled(j, S)) {
				continue;
			}

			if (true) {
				int tmp = S | 1 << i;
				tmp = tmp | 1 << j;
				res = max(res, remove(tmp) + 2);
				if (res == n + 2) {
					res = n;
					break;
				}
			}
		}
		if (res == n) {
			break;
		}
	}
	return dp[S] = res;
}

int main() {
	// 方針: bitDP
	//const int MAX_N = 24;
	while (true) {
		//cout << "n=" << endl;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> cir[i].x >> cir[i].y >> cir[i].r >> cir[i].c;
		}
		memset(dp, -1, sizeof(dp));
		//cout << "test" << endl;
		cout << remove(0) << endl;
	}

	return 0;
}

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

int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-a>k)
  {
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
#define PI 3.14159265359
const int U=2e5+5;
const ll MOD=998244353;
const int INF = 1001001001;


int main(){
    int A,B,H,M; cin>>A>>B>>H>>M;
    double ka = (H*5 - M) * 6 + M * 0.5;
    printf("%.11f",sqrt( A*A + B*B - 2 * A * B * cos(ka * PI / 180)));
    return 0;
}

Measured memory_bytes: 4192
from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
N,K=map(int,input().split())
mod=10**9+7
"""fac=[1,1]
for i in range(2,2*K+1):
    fac.append(fac[-1]*i%mod)
ifac=[pow(i,mod-2,mod) for i in fac]
#print(fac)
#print(ifac)"""
def H(a,b):
    return(comb(a+b-1,a))
def comb(a,b):
    return(fac[a]*ifac[a-b]*ifac[b]%mod)


dp=[1 for i in range(K+1)]
for i in range(1,len(dp))[::-1]:
    n=(len(dp)-1)//i
    z=pow(n,N,mod)
    for m in range(i,len(dp),i):
        z-=dp[m]

    dp[i]+=z
    dp[i]%=mod
print(sum([dp[i]*i%mod for i in range(len(dp))])%mod)


Measured memory_bytes: 16796
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    String[] strs = str.split(" ");
    int lowest = Integer.parseInt(strs[0]);
    int highest = Integer.parseInt(strs[1]);
    int n = Integer.parseInt(strs[2]);
    int count = 0;
    for (int i = lowest; i < highest+1; i++) {
      if(i % n == 0) count++;
    }
    System.out.println(count);
  }

}


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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a != c){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int MOD = 1e9 + 7;

int main(){
    int N;
    string S1, S2, arr;
    cin >> N >> S1 >> S2;
    rep(i, N) {
        if (S1[i] == S2[i]) arr += 'X';
        else {
            arr += 'Y';
            i++;
        }
    }
    ll ans;
    rep(i, arr.size()) {
        if (i == 0) {
            if (arr[0] == 'X') ans = 3;
            else ans = 6;
            continue;
        }
        if (arr[i-1] == 'X' && arr[i] == 'X') {
            ans *= 2;
            ans %= MOD;
        } else if (arr[i-1] == 'X' && arr[i] == 'Y') {
            ans *= 2;
            ans %= MOD;
        } else if (arr[i-1] == 'Y' && arr[i] == 'Y') {
            ans *= 3;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
ll n,m,p,ans=1;
signed main()
{
	string s;
	cin>>s;
	int l=s.size()-2;
	cout<<s[0]<<l<<s[l+1];
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;
my @x;
{
    my $in = <STDIN>;
    @x = split(" ", $in);
}
my $sum = sub
{
    my $s = 0;
    $s += $_ for @_;
    return $s;
};
my $med1 = int(1 / $n * $sum->(@x));
my $med2 = $med1 + 1;

my $ans1 = 0;
my $ans2 = 0;
for (my $i=0; $i<$n; $i++)
{
    $ans1 += ($x[$i] - $med1) ** 2;
    $ans2 += ($x[$i] - $med2) ** 2;
}
print "$ans1\n" if $ans1 < $ans2;
print "$ans2\n" unless $ans1 < $ans2;

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = "#" + S + "#"; // 端を石を置いておく    
    // C<Dの時は#が連続してなければ必ず可能
    if(C<D){
        for(int i=A;i<=C-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int i=B;i<=D-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else{
        for(int i=A;i<=C-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int i=B;i<=D-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
        // C>Dの時はどこかで追い越す必要がある
        // 追い越すためには　...すふ〇... の状況が必要
        // B-1のマスからD+1のマスのなかで3連続の空きがあればOK
        for(int i=B-1;i<=D-1;i++){
            if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

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

const int M=55555;
int C[M];
int main()
{
    int n;
    cin>>n;
    for(int i=2; i<M; ++i) if (!C[i]) {
        if (n>0 && i%5==1) {
            cout<<i<<' ';
            n--;
        }
        for(int j=i+i; j<M; j+=i) C[j]=1;
    }
    cout<<endl;
}


Measured memory_bytes: 512
package main

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

func calc(p int, n []int) int {
	sum := 0
	for _, j := range n {
		sum += (j - p) * (j - p)
	}
	return sum
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimSuffix(text, "\n")
	N, _ := strconv.Atoi(text)
	// fmt.Printf("%s, %d\n", text, N)
	values, _ := reader.ReadString('\n')
	// fmt.Printf("%s", values)
	var n []int
	for j, f := range strings.Fields(values) {
		if j == N {
			break
		}
		i, err := strconv.Atoi(f)
		if err == nil {
			n = append(n, i)
		}
	}
	// fmt.Printf("length %v\n", n)
	minpower := 1000000000
	// minpos := 0
	for i := 1; i <= 100; i++ {
		power := calc(i, n)
		// fmt.Printf("ss %v %v\n", i, power)
		if minpower > power {
			minpower = power
			// minpos = i
		}
	}
	// fmt.Printf("%v\n", minpos)
	fmt.Printf("%v\n", minpower)
}


Measured memory_bytes: 640
x, y = map(int, input().split())
assert(x != y)
if x <= y:
    if -x <= y:
        print(min(abs(x-y), abs(-x-y) + 1))
    else:
        print(min(abs(x-y), abs(x-(-y)) + 1))
else:
    if -x <= y:
        print(min(abs(-x-y), abs(-x-(-y)) + 1) + 1)
    else:
        print(min(abs(-y-x), abs(-y-(-x)) + 1) + 1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;



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

  			int h,w,sum=0;
  			cin >> h >>w;
  			int a[w];
  			for(int i=0;i<w;i++){
  				cin >> a[i];
  				sum+=a[i];
  			}
  			if(h-sum>=0){
  			cout << h-sum;
  		}
  		else cout << -1;
}

Measured memory_bytes: 3656
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

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

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi c(n);
    rep(i, n) {
        cin >> c[i];
    }

    sort(rall(c));
    mint ans = 0;
    rep(i, n) {
        if(!i) {
            ans = mint(2).pow(n-1)*c[0];
        }
        else ans += mint(2).pow(n-1-i)*(mint(2).pow(i)+mint(2).pow(i-1)*i)*c[i];
    }
    
    cout << ans * mint(2).pow(n) << endl;
}

Measured memory_bytes: 3888
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
p = LIST()
q = LIST()
l = list(permutations(range(1, n + 1), n))
l.sort()
a = 0
b = 0
for i in range(len(l)):
    flagp = True
    flagq = True
    for j in range(n):
        if l[i][j] != p[j]:
            flagp = False
        if l[i][j] != q[j]:
            flagq = False
    if flagp:
        a = i
    if flagq:
        b = i
print(abs(a - b))

Measured memory_bytes: 68076
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    string a,b;
    cin >> a >> b;
    string ans;
    if(a.size() > b.size()){
        ans = "GREATER";
    }else if(a.size() < b.size()){
        ans = "LESS";
    }else{
        if(a > b)
            ans = "GREATER";
        else if(a < b)
            ans = "LESS";
        else
            ans = "EQUAL";
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector <int> arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int diff = 0, v=0, c=0;
    for(int i=0;i<n;i++){
        int cn;
        cin >> cn;
        if(v+arr[i]-(c+cn) > diff){
            diff = max(diff, v+arr[i]-(c+cn));
            v+=arr[i];
            c+=cn;
        }
    }

    cout << diff << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int a = N/1000;
  int b = (N%1000)/100;
  int c = (N%100)/10;
  int d = N%10;
  
  if(a + b + c + d == 7) {cout << a<< "+" << b << "+" << c << "+" << d <<"=7" << endl;}
  else if(a + b + c - d == 7) {cout << a<< "+" << b << "+" << c << "-" << d <<"=7" << endl;}
  else if(a + b - c + d == 7) {cout << a<< "+" << b << "-" << c << "+" << d <<"=7" << endl;}
  else if(a + b - c - d == 7) {cout << a<< "+" << b << "-" << c << "-" << d <<"=7" << endl;}
  else if(a - b + c + d == 7) {cout << a<< "-" << b << "+" << c << "+" << d <<"=7" << endl;}
  else if(a - b + c - d == 7) {cout << a<< "-" << b << "+" << c << "-" << d <<"=7" << endl;}
  else if(a - b - c + d == 7) {cout << a<< "-" << b << "-" << c << "+" << d <<"=7" << endl;}
  else if(a - b - c - d == 7) {cout << a<< "-" << b << "-" << c << "-" << d <<"=7" << endl;}
  
}
  

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, K; cin >> N >> K;
    vi h(N); REP(i, N) cin >> h[i];

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

    int ans = INF;
    REP(i,N-K+1) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   int N, K;
   cin >> N >> K;
   vector<ll> h(N);
   rep(i, 0, N) cin >> h.at(i);
   vector<ll> f(N, INF);
   f.at(0) = 0;
   f.at(1) = abs(h.at(1) - h.at(0));
   rep(i, 2, N) {
     for (int j = 1; i - j >= 0 && j <= K; j++) {
       f.at(i) = min(f.at(i), f.at(i - j) + abs(h.at(i) - h.at(i - j)));
     }
   }
   cout << f.at(N - 1) << endl;
 }


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 8, MAX_M = 8 * 7 / 2;
bool G[MAX_N][MAX_N];
int N, M;

int dfs(int v, int N, bool visited[]) {
    bool all_visited = true;
    REP(i, N) if (!visited[i]) all_visited = false;
    if (all_visited) return 1;

    int ret = 0;
    REP(i, N) {
        if (!G[v][i]) continue;
        if (visited[i]) continue;
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b] = G[b][a] = true;
    }
    bool visited[MAX_N];
    fill(visited, visited + N, false);
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}

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

typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define all(a) begin(a), end(a)
#define watch(x) cerr << (#x) << " is " << (x) << '\n';

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

    int n;
    cin >> n;

    cout << n * n * n;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
struct point{
	int x,y,z;
	bool operator <(const point &rhs) const{
		return z<rhs.z;
	}
}b[maxn];
int a[maxn],fa[maxn],sum[maxn];
ll tot[maxn];
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main(){
	int n=read(),m=read();
	REP(i,1,n) fa[i]=i,tot[i]=read();
	REP(i,1,m) b[i].x=read(),b[i].y=read(),b[i].z=read();
	sort(b+1,b+m+1);
	REP(i,1,m){
		int x=b[i].x,y=b[i].y,z=b[i].z;
		x=find(x),y=find(y);
		if(x==y) sum[x]+=(z>tot[x]);
		else{
			fa[x]=y,tot[y]+=tot[x],sum[y]+=sum[x];
			if(z>tot[y]) sum[y]++;
			else sum[y]=0;
		}
	}
	int ans=0;
	REP(i,1,n) if(fa[i]==i) ans+=sum[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a + b >= 10){
            System.out.println("error");
            return;
        }
            System.out.println(a+b);
    }
}


Measured memory_bytes: 21076
#include <stdio.h>

int main(void)
{
	int cards[4][13] = { 0 };
	int n = 0, i, num = 0, j, k;

	char suit_inputvalue;
	char suit[5] = "SHCD";

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf(" %c %d", &suit_inputvalue, &num);

		if ((suit_inputvalue == suit[0]) || (suit_inputvalue == suit[1]))
		{
			if (suit_inputvalue == suit[0])
			{
				cards[0][num - 1] = 1;
			}
			else
			{
				cards[1][num - 1] = 1;
			}
		}
		else
		{
			if (suit_inputvalue == suit[2])
			{
				cards[2][num - 1] = 1;
			}
			else
			{
				cards[3][num - 1] = 1;
			}
		}
	}

	for (j = 0; j < 4; j++)
	{
		for (k = 0; k < 13; k++)
		{
			if (cards[j][k] == 0)
			{
				printf("%c %d\n", suit[j], k + 1);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2052
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
#warning "// FOR has been inclusive now!!!!"
string A, B;
int main()
{
	cin>>A>>B;
	cout<<(A[0]==B[0])+(A[1]==B[1])+(A[2]==B[2]);
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
        int a,i;
        char s[4];
        a=0;
        i=0;
        // 文字列の入力
        scanf("%s",s);
        while(i<4){
            if(s[i]=='+'){
                a++;
            }else{
                a--;
            }
        i++;
        }
        // 出力
        printf(" %d\n",a);
        return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll double
int main()
{
    int n;
    double k,a[200002];
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    double mx=-4;
    ll sum=0.0;
    for(int i=0; i<k; i++)
    {
        sum+=((a[i]*(a[i]+1))/2.0)/a[i];
    }
    //cout<<sum<<endl;
    mx=max(mx,sum);
    for(int i=k; i<n; i++)
    {
        int p=i-k;
        sum-=((a[p]*(a[p]+1))/2.0)/a[p];
        sum+=((a[i]*(a[i]+1))/2.0)/a[i];

        mx=max(mx,sum);
    }
    printf("%.10lf\n",mx);
    return 0;
    //cout<<mx<<endl;
}


Measured memory_bytes: 1792