akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int A[3000], B[3000];
int dp[3001];
int main() {
  int N, T, S;
  while(cin>>N>>T>>S) {
    REP(i, N) {
      cin >> A[i] >> B[i];
    }
    //REP(i,T+1)printf("%3d", i);cout << endl;
    REP(i, N) {
      for (int j=T-B[i]; j>=0; --j) {
        if (S<=j||j+B[i]<=S)
          dp[j+B[i]] = max(dp[j+B[i]], dp[j]+A[i]);
      }
      REP(j, T) dp[j+1] = max(dp[j+1], dp[j]);
      //REP(j,T+1)printf("%3d", dp[j]);cout << endl;
    }
    cout << dp[T] << endl;
  }
}

Measured memory_bytes: 860
a = readline()
x=length(a)
s=[0,0]
for i in [i for i = 1:x]
  if(a[i] == ' ')
  	s[1] = i
    break
  end
end
for i in [i for i = s[1]+1:x]
  if(a[i] == ' ')
  	s[2] = i
  end
end
println(a[s[2]+1:x]," ",a[1:s[1]-1]," ",a[s[1]+1:s[2]-1])

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

int main(){
    int n;
    cin >> n;
    double v[n];
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v,v+n);
    for(int i=0;i<n-1;i++){
        v[i+1] = (v[i]+v[i+1])/2;
    }
    cout << v[n-1] << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500001
#define NIL -1
typedef struct node{
  int left;
  int right;
  int key;
  int p;
  int leftid;
  int rightid;

}Node;
Node node[MAX];
int root=NIL;
void inorder(int);
void preorder(int);
void addTree(int n,int num){
  int tmp;
  //rootが空の場合
  if(node[n].key==root){
    root=n;
    node[root].key=num;
    
  }
  else{
  tmp=root;

  while(1){
    if(node[tmp].key>num){
      if(node[tmp].left!=NIL){
	tmp=node[tmp].leftid;
      }
      else{
	node[tmp].left=num;
	node[tmp].leftid=n+1;
	node[n+1].key=num;
	
	break;
      }
    }
    else{
      if(node[tmp].right!=NIL){
	tmp=node[tmp].rightid;
	
      }
      else{
	node[tmp].right=num;
	node[n+1].key=num;
	node[tmp].rightid=n+1;
	break;
      }
    }
  }
  
  node[n].p=tmp;
  
  }
}
int main(){
  int num,i,n,l=0,tmp;
  char name[100];
  scanf("%d",&n);
 for(i=0;i<MAX;i++){//初期化
    node[i].p=NIL;
    node[i].left=NIL;
    node[i].right=NIL;
    node[i].key=NIL;
    
  }


 for(i=0;i<n;i++){
    scanf("%s",name);
    if(name[0]=='i'){
      scanf("%d",&num);
      addTree(l,num);
      l++;
      }
      
   else if(name[0]=='p'){
    inorder(root);
   printf("\n");
   preorder(root);
   printf("\n");
      
    }
  }
 
 
 
  return 0;
}
void inorder(int t){
  if(node[t].left!=NIL){
    inorder(node[t].leftid);
  }
    printf(" %d",node[t].key);
  if(node[t].right!=NIL){
    inorder(node[t].rightid);
  }
}
void preorder(int t){
 
      printf(" %d",node[t].key);
  if(node[t].left!=NIL){
    preorder(node[t].leftid);
  }
  if(node[t].right!=NIL){
    preorder(node[t].rightid);
  }
}




Measured memory_bytes: 13480
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

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

	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);

		sum += a.at(i);
	}

	int v = sum / n;
	if (abs(sum) % n != 0)
	{
		if (abs(sum) % n > n / 2)
		{
			if (v > 0)
			{
				v++;
			}
			else if (v < 0)
			{
				v--;
			}
		}
	}

	int64_t out = 0;
	for (int i = 0; i < n; i++)
	{
		out += (a.at(i) - v) * (a.at(i) - v);
	}

	cout << out << endl;
}

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

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

#define fi first
#define se second
#define pb push_back
#define mp nake_pair

typedef long long ll;

ll d[110][110];

int main(){
    int n, m, s, g1, g2;
    while(~scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2)){
        if(n == 0 && m == 0) break;
        rep(i, 110) rep(j, 110) d[i][j] = (i == j ) ? 0LL : 1e18;
        int b1, b2, c;
        s--;
        g1--;
        g2--;
        rep(i, m){
            scanf("%d%d%d", &b1, &b2, &c);
            b1--;
            b2--;
            d[b1][b2] = min((ll)c, d[b1][b2]);
        }
        rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        ll ans = d[s][g1]+d[s][g2];
        rep(i, n){
            ans = min(ans, d[s][i]+d[i][g1]+d[i][g2]);
        }
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 3244
/**
 *    author:  tourist
 *    created: 20.05.2018 15:05:13       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (a[0] != 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1] + 1) {
      cout << -1 << '\n';
      return 0;
    }
  }
  long long ans = 0;
  set<long long> s;
  long long delta = 0;
  for (int i = n - 1; i >= 0; i--) {
    delta += (-1);
    s.insert(a[i] - delta);
    if (!s.empty() && *s.begin() + delta == 0) {
      s.erase(s.begin());
    }
    ans += (int) s.size();
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
	int s, w;
	cin >> s >> w;
	
	if (s <= w)
	{
		cout << "unsafe" << endl;
	}
	else
	{
		cout << "safe" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var num = 0
    for(i in 0..a) {
        for(j in 0..b) {
            for(k in 0..c) {
                if(x == i * 500 + j * 100 + k * 50) {
                    num = num + 1
                }
            }
        }
    }
    println(num)
}

Measured memory_bytes: 31604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(b % a == 0 ? a + b : b - a);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(b,a*n) << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
X = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        X[i].append((x, y))

ans = 0
for i in range(2**n):
    t = [-1]*n
    flag = True
    cnt = 0
    for j in range(n):
        if (i >> j) & 1:
            cnt += 1
            t[j] = 1
        else:
            t[j] = 0
    for j in range(n):
        if (i >> j) & 1:
            for x, y in X[j]:
                if t[x] != y:
                    flag = False
    if flag:
        ans = max(ans, cnt)

print(ans)


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

#define ll  long long  int
using namespace std;


int  main()
{

  #ifndef ONLINE_JUDGE
freopen("fi.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#else
// online submission
 
#endif
int n;
cin>>n;
if(n>=30)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

}


Measured memory_bytes: 3656
#include <stdio.h>

int main() {
    char alphabet[26] = {0};
    for( int i=0; i<4; i++ ) {
        char c;
        scanf("%c",&c);
        alphabet[c-'A'] ++;
    }

    int max = 0;
    int min = 4;
    for( int i=0; i<26; i++ ) {
        if( alphabet[i] > max ) max = alphabet[i];
        if( alphabet[i] != 0 && alphabet[i] < min ) min = alphabet[i];
    }

    if( max == 2 && min == 2 ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
#include<numeric>
using namespace std;
//max=({});

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long x = a * b;
	if (a < b) {
		c = a;
		a = b;
		b = c;
	}
	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	cout << x / b << endl;
	return 0;
}


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

const int M = 81;
const int MV = 2 * M * M;
int n, m;
int a[M][M], b[M][M], d[M][M];
int dp[M][M][MV];

void upd(int *s, int *t, int d) {
    for (int k = 0; k < MV; k++)
        if (s[k]) {
            if (k + d < MV) t[k + d] = 1;
            t[abs(k - d)] = 1;
        }
}

int main() {
    while (scanf("%d %d", &n, &m) == 2) {
        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", &b[i][j]);
        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) d[i][j] = abs(a[i][j] - b[i][j]);
        dp[0][0][d[0][0]] = 1;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                if (i > 0) upd(dp[i - 1][j], dp[i][j], d[i][j]);    
                if (j > 0) upd(dp[i][j - 1], dp[i][j], d[i][j]);    
            }

        int res = MV;
        for (int k = 0; k < MV; k++) if (dp[n-1][m-1][k]) { res = k; break; }
        printf("%d\n", res);
    }
    return 0;       
}


Measured memory_bytes: 336640
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  x = c.get(i)
  while x:
    n -= x
    r = r * pow(p, x, M) % M
    i += 1; p = x; x = c.get(i)
print((r, 0)[n > 1])


Measured memory_bytes: 22636
//看题解了，重做 
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int NN = 700;
int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];

int main(){
	//freopen("atcoderabc106d.in", "r", stdin);
	
	scanf("%d%d%d", &n, &m, &q);
	for (int i=1; i<=m; i++) {
		scanf("%d%d", &x, &y);
		a[x][y]++;
	}
	
	for (int i=1; i<=n; i++)
		for (int j=i; j<=n; j++)
			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 
	
	for (int i=1; i<=n; i++)
		for (int j=i; j<=n; j++)
			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 
	
	
	while (q--){
		scanf("%d%d", &x, &y);
		printf("%d\n", c[x][y]);
		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);
	} 
	
	return 0;
} 

Measured memory_bytes: 5504
N = gets.to_i
as = gets.split.map(&:to_i)
b = as.min
d = as.count(b)
case
when d > 2
  puts "Impossible"; exit
when d == 2
  as = as.map{ |a| a + 1 }
  as << b
end

h = {}
as.each{ |a| h[a] = (h[a] || 0) + 1 }
es = h.keys.sort
m = 2*b
if es.max == m && es.size == m-b+1
  if es[1..-1].all?{ |k| k >= 2 }
    puts "Possible"; exit
  end
end
puts "Impossible"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define maxn 3010
#define mod 1000000007
using namespace std;
int dp[maxn][maxn],n,m,l[maxn],r[maxn],tp,s[maxn],C[maxn][maxn];
char ss[maxn];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",ss+1);
	for(int i=1;i<=n;++i)
		s[i]=s[i-1]+(ss[i]=='1');
	for(int i=1;i<=m;++i){
		scanf("%d%d",&l[i],&r[i]);
		if(l[i]==l[tp])r[tp]=max(r[tp],r[i]);
		else if(r[tp]<r[i])l[++tp]=l[i],r[tp]=r[i];
	}
	dp[1][s[r[1]]-s[l[1]-1]]=1;
	for(int i=0;i<=n;++i)
		for(int j=*C[i]=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for(int i=2;i<=tp;++i){
		int k=s[r[i]]-s[max(l[i]-1,r[i-1])],A=min(r[i-1]+1,l[i])-l[i-1],len=r[i-1]-l[i-1]+1,len2=r[i]-l[i]+1;
		for(int j=k;j<=len2&&j<=max(0,r[i-1]-l[i]+1)+k;++j)
			for(int a=0;a<=A&&a+j-k<=len;++a)
				dp[i][j]=(dp[i][j]+1ll*dp[i-1][a+j-k]*C[A][a])%mod;
	}
	int ans=0;
	for(int i=0;i<=r[tp]-l[tp]+1;++i)
		ans=(ans+1ll*dp[tp][i]*C[r[tp]-l[tp]+1][i])%mod;
	printf("%d",ans);
}

Measured memory_bytes: 50176
nk=input().split()

n=int(nk[0])
k=int(nk[1])

weight=[int(input()) for i in range(n)]

def ok(m):
    load=0
    track=1
    # sum all the weight and count the track number we need
    for i in range(n):
        load+=weight[i]
        if load==m:
            load=0
            if i!=n-1:
                track+=1
        elif load>m:
            if weight[i]>m:
                return False
            else:
                load=weight[i]
                track+=1
        else:
            continue

    if track<=k:
        return True
    else:
        return False

low=0
high=sum(weight)
while low+1<high:
# low<mid<high
#not ok(l) and ok(h)
    mid=(low+high)//2
    if ok(mid):
        high=mid
    else:
        low=mid



print(high)


Measured memory_bytes: 9556
#include<stdio.h>

int main(void){
    int n,i,a;
    scanf("%d",&n);
    for(i=1;i<50000;i++){
        a = i*1.08;
        if(a==n){
            a*=100;
            if(a%108==0){
                a/=108;
                printf("%d\n",a);
            }else{
                a/=108;
                a++;
                printf("%d\n",a);
            }
            return 0;
        }
    }
    printf(":(\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);*/
        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
        WriteLine(temp.Replace(","," "));
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main()
{
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  int turn = 0;
  while (true)
  {
    if (S[turn] == "")
    {
      cout << (char)(turn + 'A') << endl;
      return 0;
    }
    char c = S[turn].at(0);
    S[turn] = S[turn].substr(1, S[turn].length() - 1);
    turn = c - 'a';
  }
  return 0;
}

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

string add(string a, string b) {
	int al = a.size(), bl = b.size();
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	string res;
	int tmp = 0;
	for (int i = 0; i < al || i < bl || tmp; i++) {
		tmp += (i < al ? a[i] - '0' : 0) + (i < bl ? b[i] - '0' : 0);
		res.push_back('0' + tmp % 10);
		tmp /= 10;
	}
	reverse(res.begin(), res.end());
	return res;
}

int main()
{
	int N;
	string a, b;
	cin >> N;
	while (N--) {
		cin >> a >> b;
		string sum = add(a, b);
		cout << (sum.size() > 80 ? string("overflow") : sum) << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
result = 0
for i in s:
    if i % 10 != 0:
        result = 1
        break

if result == 0:
    print('0')
    exit()

total = sum(s)
if total % 10 == 0:
    for i in range(n):
        total -= s[i]
        if total % 10 == 0:
            total = sum(s)
        else:
            break
print(total)
        


Measured memory_bytes: 3064
#s=int(input())
# b=input()
# c=[]
# for i in range(b):
#     c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))
c=0
for i in range(2):
    c+=a[a.index(max(a))]
    a[a.index(max(a))]=a[a.index(max(a))]-1

print(c)



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

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

int main()
{
    long N, X, Y;
    cin >> N >> X >> Y;
    vector<long> ans(N);
    for (int i = 1; i < N;i++){
        ans.at(i) = N - i;
    }
    for (int i = 0; i < N;i++){
        for (int j = -i; j <= i;j++){
            long num = X + j;
            if(num <= 0){
                continue;
            }
            long mvlen = abs(i) + 1;
            long remainlen = mvlen - abs(j);
            if(remainlen == 1){
                long goal = Y;
                if(mvlen < (goal - num) && goal > num){
                    ans.at(goal - num) -= 1;
                    ans.at(mvlen)   += 1;
                }
            }
            else if(remainlen > 1){
                remainlen -= 1;
                long goal1 = Y - remainlen;
                long goal2 = Y + remainlen;
                if(mvlen < (goal1 - num) && goal1 > num && goal1 <= N){
                    ans.at(goal1 - num) -= 1;
                    ans.at(mvlen)   += 1;
                }
                if(mvlen < (goal2 - num) && goal2 > num && goal2 <= N){
                    ans.at(goal2 - num) -= 1;
                    ans.at(mvlen)   += 1;
                }
            }
        }
    }

    for (int i = 1; i < N;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
<?php
class main {
    var $arr = array();
    var $adv = array();
    var $step = array();
    var $cnt = 0;
    function run() {
        $line = trim(fgets(STDIN));
        $this->arr = explode(" ", $line);

        for ($i = 0;$i < $this->arr[1]; $i++) {
            $line = trim(fgets(STDIN));
            $tmp = explode(" ", $line);
            $this->adv[$tmp[0]][] = $tmp[1];
            $this->adv[$tmp[1]][] = $tmp[0];
        }

        foreach($this->adv[1] as $start) {
            $this->step[1] = 1;
            $this->next($start);
        }

        echo $this->cnt;
    }
    
    function next ($start) {
        $this->step[$start] = $start;
        if (count($this->step) == $this->arr[0]) {
            $this->cnt++;
            unset($this->step[$start]);
            return;
        }
        foreach($this->adv[$start] as $next) {
            if (!in_array($next, $this->step)) {
                $this->next($next);
                
            }
        }
        unset($this->step[$start]);
    }
}

$object = new main();
$object->run();

Measured memory_bytes: 3832
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 >= 13)
		{
			System.out.println(B);
		}else if( 6 <= A && A <= 12)
		{
			int C = B /2;
			System.out.println(C);
		}else
		{
			int D = 0;
			System.out.println(D);
		}
	}
}

Measured memory_bytes: 21844
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0002&lang=jp
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

void digit(int a, int b){
	int counter = 1;
	int c = a+b;
	while(c/10 > 0){
		counter++;
		c /= 10;
	}
	cout << counter << endl;
	return;
}


int main(){
	int a,b;
	while(cin >> a >> b){
		digit(a,b);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)

using namespace std;

int main(void){
    ll x;
    cin >> x;
    llv v (100000+1,0);
    v[0] = 1;
    rep(i,100001){
        if(v[i] == 1){
            for(int j = 100;j <= 105 && i+j <= 100000;j++){
                v[i+j] = 1;
            }
        }
    }

    if (v[x] == 1)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
}

Measured memory_bytes: 3648
from math import sqrt, factorial
from itertools import permutations

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

all_sum = 0

for i in permutations(range(N)):
    for j in range(len(i) - 1):
        all_sum += sqrt((xy[i[j]][0] - xy[i[j + 1]][0]) ** 2 +
                        (xy[i[j]][1] - xy[i[j + 1]][1]) ** 2)


print(all_sum / factorial(N))


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

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;

int main(){
	LL N;
	int ans = 0;
	scanf("%lld", &N);
	int q = sqrt(N);
	for (int i = 2; i <= q; i++) {
		int cnt = 0;
		while (N % i == 0) N /= i, cnt++;
		if (cnt > 0) {
			int tmp = 1;
			while (cnt >= tmp) {
				ans++;
				cnt -= tmp;
				if (cnt <= tmp) break;
				tmp++;
			}
		}
	}
	if (N > 1) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string>s(h);
    for(int i=0;i<h;i++){
        cin >> s.at(i);
    }        
	int dy[4] = {0,0,1,-1};
    int dx[4]={-1,1,0,0}; 
	int ans = 0;
 for(int sy=0;sy<h;sy++){
	 for(int sx=0;sx<w;sx++){
				 if(s[sy][sx]=='#')continue;
    vector<vector<int>> score(h, vector<int>(w, 10e8));
    queue<pair<int,int>> que;   
        score[sy][sx]=0;
    que.push(make_pair(sy,sx));
    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i=0;i<4;i++){
            if(y+dy[i]<0||y+dy[i]>=h||x+dx[i]<0||x+dx[i]>=w)continue;
            
            if(s.at(y+dy[i]).at(x+dx[i])=='#')continue;
            
            if(score[y+dy[i]][x+dx[i]] > score[y][x]+1){
                score[y+dy[i]][x+dx[i]]= score[y][x]+1;
               
                que.push(make_pair(y+dy[i],x+dx[i]));
            }
        }
    }
	int che =0;
	for(int ii=0;ii<h;ii++){
		for(int jj=0;jj<w;jj++){
			if(s[ii][jj]=='#')continue;
			che = max(che,score[ii][jj]);
		}
	}
	ans = max(ans,che);
	 }
 }
cout << ans << endl;
}



Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q,l,r, x, y, u, v, n, m;
    string a,b;
    cin>>a>>b;
    n=a.size();
    m=b.size();

    ll dp[n+1][m+1];

    Ff(i,0,m+1)
    dp[0][i]=0;

    Ff(i,0,n+1)
    dp[i][0]=0;

    Ff(i,1,n+1)
    {
        Ff(j,1,m+1)
        {
            if(a[i-1]==b[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    i=n;
    j=m;
    string s="";
    while(i>0 and j>0)
    {
        if(a[i-1]==b[j-1])
        {
            s+=a[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i][j]==dp[i][j-1])
            j--;
            else
            i--;
        }
    }

    reverse(all(s));
    cout<<s;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


Measured memory_bytes: 81016
/*input

*/
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
//gcc 1.cpp -lstdc++ -o main.o
#define ull                 unsigned long long
#define ll                         long long
#define M                         1000000007
#define pb                         emplace_back
#define p_q                 priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define all(a)      (a).begin(),(a).end()
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b))/gcd((a),(b))
#define ios                    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp                         make_pair
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define F first
#define S second
#define N 200005
using namespace std;


int main(void)
{
        ios
        ll n;
        cin>>n;
        vi v(n);
        rep(i,0,n)
                cin>>v[i];
        ll sum  = 0;
        mi mp1;

        rep(i,0,n){
                mp1[v[i]]++;
                sum = sum  + v[i];
        }

        ll q , t1;
        cin>>q;
        rep(i,0,q){
                ll a , b;
                cin>>a>>b;
                t1 = mp1[a];
                mp1[b] = mp1[b] + t1;
                mp1.erase(a);
                sum = sum + t1*(b - a);
                cout<<sum<<"\n";

        }
}

Measured memory_bytes: 7816
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

typedef long long ll;

ll f(ll r,ll a){
    return (r + a) - 1;
}

int main() {
    ll A,B,result=1,count=0;
    cin >> A >> B;

    while (result < B){
        result = f(result,A);
        count++;
    }

    cout << count << endl;
    


}

Measured memory_bytes: 256
#include <cstdio>

bool pd(int x) {
    if(x % 10 == x / 10 % 10 && x % 10 == x / 100) return 1;
    return 0;
}

int main() {
    int x;
    scanf("%d", &x);
    if(pd(x)) {
        printf("%d", x);
        return 0;
    }
    while(!pd(++x));
    printf("%d", x);
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, K = MI()
    P = LI()
    P.sort()
    print(sum(P[:K]))

if __name__ == '__main__':
    solve()


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

using namespace std;

using ll = long long;

class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
int dx[] = {1, 1, 1, 0, -1, -1, -1, 0};
int dy[] = {1, 0, -1, -1, -1, 0, 1, 1};

int main()
{
    int h,w;
    while(cin >> h >> w){
        if(h == 0)return 0;
        map<pair<int,int>, int> se;
        int cnt = 0;
        for(int x = 0;x < w;x++){
            for(int y = 0;y < h;y++){
                int c;cin >> c;
                if(c){
                    se[make_pair(x, y)] = cnt;
                    cnt++;
                }
            }
        }
        UnionFind Uni(cnt);
        for(auto a : se){
            int x = a.first.first;
            int y = a.first.second;
            for(int i = 0;i < 8;i++){
                if(se.find(make_pair(x + dx[i], y + dy[i])) != se.end()){
                    Uni.connect(a.second, se[make_pair(x + dx[i], y + dy[i])]);
                }
            }
        }
        set<int> s;
        for(int i = 0;i < cnt;i++){
            s.insert(Uni.root(i));
        }
        std::cout<<s.size()<<endl;
    }
}



Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int a, b, t;
    cin >> a >> b >> t;
    int ans = 0;
    while(t > 0){
        t -= a;
        if(t >= 0) ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            if (N == 1)
            {
                Println("Hello World");
            }
            else
            {
                Println(ReadInt() + ReadInt());
            }
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

int main(){
  int n;
  string s;
  cin >>n >>s;
  int ans = 0;
  for(int i= 0; i<n; i++){
    int cnt = 0;
    for(char c = 'a'; c<='z'; c++){
      bool left = false, right = false;
      rep(j,i){
        if(s[j]==c) left = true;
      }
      for(int j = i; j<n; j++){
        if(s[j]==c) right = true;
      }
      if(left&&right) cnt++;
    }
    if(ans<cnt) ans = cnt;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    string s, s1 = "";
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0')
            s1 += '0';
        if(s[i] == '1')
            s1 += '1';
        if(s[i] == 'B' && !s1.empty())
            s1.erase(s1.begin() + (s1.size() - 1));
    }
    cout << s1;
}

// ."ww"w"".ww"""...ww"".

int main(){
    //freopen("lepus.in","r",stdin);
    //freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
    solve();
    //cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int minsum = 0;
	for(int m = *min_element(a.begin(),a.end());m<=*max_element(a.begin(),a.end());m++){
		int sum = 0;
		for(int i=0;i<n;i++){
			sum += pow(a[i]-m,2);
		}
		if(m==*min_element(a.begin(),a.end())){
			minsum = sum;
		}else{
			if(minsum>sum){
				minsum = sum;
			}
		}
	}
	cout << minsum << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unchecked")
class Main{
 
    void solve(){
        Scanner sc = new Scanner(System.in);
 
        while(true){
            char t = sc.next().charAt(0);
            if(t=='#') break;
 
            ArrayList[] list = new ArrayList[4];
            for(int i=0; i<4; i++) list[i] = new ArrayList<String>();
            
            char now = 'a';
            for(int i=0; i<4; i++){
                for(int j=0; j<13; j++){
                    String s = sc.next();
                    if(i==0 && j==0) now = s.charAt(1);
                    list[i].add(s);
                }
            }
 
            int[] point = new int[2];
            int turn = 0;
 
            for(int i=0; i<13; i++){
                String s = (String)list[turn].get(0);
                list[turn].remove(0);
                now = s.charAt(1);
                char maxC = now;
                char max = s.charAt(0);
                int maxidx = turn;
 
                for(int j=0; j<4; j++){
                    if(j==turn) continue;

                    for(int k=0; k<list[j].size(); k++){
                        String ss = (String)list[j].get(k);
                        if(ss.charAt(1)==now){
                            list[j].remove(k);                            
                            if(maxC==now && max(ss.charAt(0), max)){
                                max = ss.charAt(0);
                                maxidx = j;
                            }
                            break;
                        }
                    }

                    if(list[turn].size()!=list[j].size()){
                        String ss = (String)list[j].get(0);
                        list[j].remove(0);
                        if(ss.charAt(1)!=t) continue;
                        if(maxC!=t || (maxC==t && max(ss.charAt(0), max))){
                            max = ss.charAt(0);
                            maxidx = j;
                            maxC = t;
                        }
                    }
                }
                point[maxidx%2]++;
                turn = maxidx;
            }
 
            int ew = point[1] - 6;
            int ns = point[0] - 6;
            if(ew>ns) System.out.println("EW "+ew);
            else System.out.println("NS "+ns);
        }
    }
 
    boolean max(char c1, char c2){
        char[] list = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
        int idx1 = 0, idx2 = 0;
        for(int i=0; i<list.length; i++){
            if(c1==list[i]) idx1 = i;
            if(c2==list[i]) idx2 = i;
        }
 
        if(idx1>idx2) return true;
        return false;
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 24820
// #include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
// #include <algorithm>
#define pb push_back
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
// #define cerr if(0)cerr
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL ,int> PLI;
typedef pair<LL ,LL > PLL;

const int N=100010;
int n;
LL W;
PLI T[N];
LL DP[N];

LL maxi(LL x, LL y){if(y>x)return y;return x;}
LL mini(LL x, LL y){if(y<x)return y;return x;}

int main()
{
  // boost;
  scanf("%d%lld",&n,&W);
  for(int i=1; i<=n; i++)
  {
    scanf("%lld%d",&T[i].f,&T[i].s);
  }

  for(int i=0; i<N; i++)
    DP[i]=W+10;

  DP[0]=0;

  for(int i=1; i<=n; i++)
  {
    for(int j=N-1; j>=T[i].s; j--)
    {
      DP[j]=mini(DP[j],DP[j-T[i].s]+T[i].f);
    }
  }

  for(int i=N-1; i>=0; i--)
  {
    if(DP[i]<=W)
    {
      return !printf("%d",i);
    }
  }


  return 0;
}


Measured memory_bytes: 896
#include<vector>
#include<iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
using pii = pair<int, int>;
constexpr int INF = 1e9;

struct edge
{
	int from, to, cost;
	bool operator>(const edge& other)const {
		return cost > other.cost;
	}
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cost)
{
	g[from].push_back(edge{ from,to,cost });
	g[to].push_back(edge{ to,from,cost });
}

edges prim(const graph& g)
{
	const int N = g.size();
	vector<bool> used(N);
	used[0] = true;
	priority_queue < edge, vector<edge>, greater<edge >>que;
	for (auto e : g[0])
	{
		que.push(e);
	}
	edges mst;
	while (!que.empty())
	{
		auto e = que.top();
		que.pop();
		if (used[e.to])
		{
			continue;
		}
		mst.push_back(e);
		
		used[e.to] = true;
		for (auto new_e : g[e.to])
		{
			que.push(new_e);
		}
	}
	return mst;
}

int main()
{
	int V, E;
	cin >> V >> E;
	graph g(V);
	for (int i = 0; i < E; i++)
	{
		int s, t, w;
		cin >> s >> t >> w;
		add_edge(g, s, t, w);
	}
	const auto mst = prim(g);
	int ans = 0;
	for (auto& e : mst)
	{
		ans += e.cost;
	}
	cout << ans << endl;
}





Measured memory_bytes: 10248
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s; cin>>s;
    int t; cin>>t;
    int i=0;
    while(true){
        if(s[i]=='1'){
            if(i==t-1){
                cout<<1<<endl;
                return 0;
            }
            i++;
        }else{
            cout<<s[i]<<endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=2000;
    ans=min(ans,a+c);
    ans=min(ans,a+d);
    ans=min(ans,b+c);
    ans=min(ans,b+d);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	string in[10000];
	int max=0;
	string ml_str;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			ml_str=in[i];
		}
	}
	in[i+1]="end";
	sort(in,in+i);
	tmp=1;
	max=0;
	//cout<<in[0]<<" ";
	for(int j=1;j<=i;j++){
	//cout<<in[j]<<" ";
		if(in[j]==in[j-1]){
			tmp++;
			//cout<<endl<<in[j]<<tmp<<endl;
		}else{
			if(max<tmp){
				max=tmp;
				
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<ans<<" "<<ml_str<<endl;
}

Measured memory_bytes: 1272
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    string s;
    ll K;
    cin >> s >> K;
    ll i, j;
    set<string> st;
    for(i=0; i<s.size(); i++) {
        for(j=1; j<=K; j++) {
            st.insert(s.substr(i, j));
        }
    }
    
    auto it=st.begin();
    for(i=0; i<K-1; i++) it++;
    pt(*it);
}




Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;


map<string, string> n;

int main() {
    n["Sunny"] = "Cloudy";
    n["Cloudy"] = "Rainy";
    n["Rainy"] = "Sunny";

    string s;
    cin >> s;
    cout << n[s] << endl;
}

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

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

    int ans = 0;
    int N, K, x;
    cin >> N >> K;

    for (size_t i = 0; i < N; i++)
    {
        cin >> x;
        ans += min(x, K - x) * 2;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3604
def balance(n, wli):

    ans = 10**9

    for i in range(n):
        ans = min(ans, abs(int(sum(wli[:i]))-int(sum(wli[i:]))))

    return ans
def main():
    n = int(input())
    wli = list(map(int, input().split()))
    print(balance(n, wli))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


S=input()

Alp="qwertyuiopasdfghjklzxcvbnm"

Q=sorted(set(S)^set(Alp))

if len(Q)>0:
	print(Q[0])
else:
	print("None")

Measured memory_bytes: 3188
using System;using static System.Console;class P{static void Main(){while(1>0){var a=Array.ConvertAll(ReadLine().Split(),int.Parse);if(a[0]+a[1]==0)break;for(int i=0,j;i++<a[0];WriteLine())for(j=0;j++<a[1];Write(i==1||i==a[0]||j==1||j==a[1]?"#":"."));WriteLine();}}}


Measured memory_bytes: 15956
N = int(input())
a = list(map(int, input().split()))
boxes = [0 for _ in range(N)]
ans = []
for i in range(N):
    j = N-i
    count = sum([boxes[k] for k in range(j-1,N,j)])
#    k = j*2
#    while k<N+1:
#        if k in ans:
#            count += 1
#        k += j
    if count%2 != a[j-1]:
        ans.append(j)
        boxes[j-1] = 1
print(len(ans))
ans = [str(x) for x in ans]
ans = ' '.join(ans)
print(ans)

Measured memory_bytes: 19388
import java.lang.reflect.Array;
import java.util.*;
public class Main {




    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());

        int[] array = new int[3];
        array[0]=a;
        array[1]=b;
        array[2]=c;

        Arrays.sort(array);

        String term1 = Integer.toString(array[2]) + Integer.toString(array[1]);
        System.out.println(Integer.parseInt(term1) + array[0]);

    }
}

Measured memory_bytes: 21460