akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}



int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    
    string s;
    cin>>s;
    int res=0;
    for(int i=0;i<s.size();i++)
        res+=(s[i]-'0');
    if(res%9==0)
        cout<<"Yes";
    else
        cout<<"No";
    
  

}


Measured memory_bytes: 3372
#pragma GCC optimize("Ofast", "unroll-loops")

// #define TEST

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	vector<int> A(N - 1);
	for (int i = 0; i < N - 1; ++i)
		cin >> A[i];
	vector<int> res(N, 0);
	for (auto ai : A)
		++res[ai - 1];
	for (auto i : res)
		cout << i << endl;
	return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll int mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,m,n;
    ll c,cnt=0;
    cin>>m>>c;
    if(c/2>=m)
    {
        cnt+=m;
        c-=2*m;
        cnt+=c/4;
    }
    else
    {
        cnt+=c/2;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int is_same( char x[], char y[] ){


  int a,b,i;
  
  a = strlen(x);
  b = strlen(y);

  if ( a != b ) return 0;

  for ( i = 0 ; i < a ; i++ ){
    if ( x[i] != y[i] ) return 0;
  }

  return 1;

}

int main(){

  char w[12],t[1000];
  char e[12] = "END_OF_TEXT";
  
  int a,b,i,count;
  count = 0;

  scanf("%s",w);

  a = strlen(w);

  for ( i = 0 ; i < a ; i++ ){
    if ( w[i] >= 'A' && w[i] <= 'Z' ) w[i] = w[i] - 'A' + 'a';
  }

  while(1){

    scanf("%s",t);

    b = strlen(t);

    if ( is_same( t, e ) == 1 ) break;

    for ( i = 0 ; i < b ; i++ ){
      if ( t[i] >= 'A' && t[i] <= 'Z' ) t[i] = t[i] - 'A' + 'a';
    }
    
    if ( is_same( w, t ) == 1 ) count++;
    
  }

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

  return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> revec(N);
  
  for (int i = 0; i < N; i++) {
    string a;
    int b;
    int c = i+1;
    cin >> a >> b;
    b = 100-b;
    revec.at(i) = make_tuple(a,b,c);
  }
  
  sort(revec.begin(), revec.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(revec.at(i)) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

ll dp[1234500];
ll h[123400];
ll k;

ll junp(ll now){
    if(dp[now] != -1){
        return dp[now];
    }
    ll mn = MOD;
    for(ll i = 1; i < k+1;i++){
        if(now-i > 0){
            mn = min(mn,abs(h[now]-h[now-i])+junp(now-i));
        }else{
            break;
        }
    }
    dp[now] = mn;
    return mn;
}


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

    ll n;
    cin >> n >> k;
    h[0] = MOD;
    
    for(ll i = 1; i < n+1;i++){
        cin >> h[i];
    }
    
    for(ll i = 1; i < n+1;i++){
        dp[i] = -1;
    }
    dp[0] = 0;
    dp[1] = 0;
    for(ll i = 2; i < n+1;i++){
        junp(i);
    }

    cout << dp[n]<< endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B = in();
    cout << max(A+B,max(A-B,A*B)) << "\n";
}

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

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var b = true;
			var count = 0;
			while (b)
			{
				b = false;
				for (var i = A.Length - 1; 1 <= i; i--)
				{
					if (A[i] < A[i - 1])
					{
						var tmp = A[i];
						A[i] = A[i - 1];
						A[i - 1] = tmp;
						b = true;
						count++;
					}
				}
			}

			System.Console.WriteLine(string.Join(" ", A));
			System.Console.WriteLine(count);
		}
	}
}



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

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

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

    vector<int> a(n);
    rep (i, n)
        cin >> a[i];

    int ans = a[0];
    for (int i = 1; i < n; i++)
        ans = gcd(ans, a[i]);

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

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}Node;
typedef Node *NodePointer;

NodePointer createNode(void);
void inorder(NodePointer);
void preorder(NodePointer);
void insert(int);
NodePointer root = NULL;

int main(){

  int i, n, x;
  char str[10];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", str);
    if(str[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

NodePointer createNode(void){

  NodePointer tree = malloc(sizeof(Node));
  tree->left = NULL;
  tree->right = NULL;
  tree->parent = NULL;
  tree->key = 0;

  return tree;
}

void insert(int key){

  NodePointer z = createNode();
  NodePointer x = root;
  NodePointer y = NULL;
  z->key = key;
  while(x != NULL){
    y = x;

    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(NodePointer T){

  if(T != NULL){
    inorder(T->left);
    printf(" %d",T->key);
    inorder(T->right);
  }
}

void preorder(NodePointer T){

  if(T != NULL){
  printf(" %d", T->key);
    preorder(T->left);
    preorder(T->right);
  }
}

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

vector<int> heap;

void propagate(int i)
{
  if (i == 1) return;
  int parent = i/2;
  if (heap[parent] < heap[i]) {
    swap(heap[i], heap[parent]);
    propagate(parent);
  }
}

void insert(int v)
{
  heap.push_back(v);
  propagate(heap.size()-1);
}

void down_propagate(int n, int i)
{
  int li = 2*i, ri = 2*i+1;

  int largest = i;
  if (li <= n && heap[li] > heap[i])
    largest = li;
  if (ri <= n && heap[ri] > heap[largest])
    largest = ri;

  if (largest != i) {
    swap(heap[i], heap[largest]);
    down_propagate(n, largest);
  }
}

int extract()
{
  int n = heap.size();
  int e = heap[1];

  heap[1] = heap[n-1];
  heap.resize(n-1);
  down_propagate(n-1, 1);

  return e;
}

int main()
{
  heap.push_back(-1);
  for (;;) {
    char op[20]; scanf("%s", op);
    if (op[0] == 'i') {
      int v; scanf("%d", &v);
      insert(v);
    } else if (op[1] == 'x') {
      printf("%d\n", extract());
    } else {
      break;
    }
  }

  return EXIT_SUCCESS;
}




Measured memory_bytes: 7024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dot[7] ={
  5000000,
  2500000,
  1250000,
   625000,
   312500,
   156250,
    78125
};
int get(string s, int k){
  //k - 0..31
  int l = k % 4;
  int m = 7 - k / 4;
  if(isdigit(s[m])){
    int n = s[m] - '0';
    return n >> l & 1;
  }else{
    int n = s[m] - 'a' + 10;
    return n >> l & 1;
  }
}
string tos(int N){
  stringstream ss;
  ss<<N;
  return ss.str();
}


int main(){
  int N;
  while(cin>>N){
    REP(i, N){
      string s;
      cin>>s;
      int low = 0;
      int high = 0;
      REP(i, 7) low += dot[i] * get(s, 6 - i);
      REP(i, 24) high += (1<<i) * get(s, 7 + i);
      string t;
      if(get(s, 31)) t += "-";
      t += tos(high);
      t += ".";
      string l = tos(low);
      while(l.size() < 7) l = "0" + l;
      t += l;
      int end = t.size() - 1;
      while(t[end] == '0' && t[end - 1] != '.') end--;
      cout<<t.substr(0, end + 1)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
struct node
{
	int val;     // value of this node
	double pri;  // priority selected randomly
	int size;    // size of tree
	int mini;     // min,max,sum etc.
	node *lch,*rch;
	node(int v,double p):val(v),pri(p),size(1),mini(v)
	{
		lch = NULL;
		rch = NULL;
	}
};
typedef pair<node*,node*> Np;
int size(node *v){return !v?0:v->size;}
int mini(node *v){return !v?INF:v->mini;}
node* update(node *v)
{
	v->size = size(v->lch)+size(v->rch)+1;
	v->mini = min(min(mini(v->lch),mini(v->rch)),v->val);
	return v;
}
node* merge(node *l,node *r)
{
	if(!l||!r)return !l?r:l;
	if(l->pri > r->pri)
	{
		l->rch = merge(l->rch,r);
		return update(l);
	}
	else
	{
		r->lch = merge(l,r->lch);
		return update(r);
	}
}
Np split(node *v,int k) //[0,k),[k,n)
{
	if(!v)return Np(NULL,NULL);
	if(k<=size(v->lch))
	{
		Np s = split(v->lch,k);
		v->lch = s.sec;
		return mp(s.fi,update(v));
	}
	else
	{
		Np s = split(v->rch,k-size(v->lch)-1);
		v->rch = s.fi;
		return mp(update(v),s.sec);
	}
}
node* insert(node* v,int k,int val,double pri)
{
	if(!v)return new node(val,pri);
	Np s = split(v,k);
	node* x = new node(val,pri);
	return merge(merge(s.fi,x),s.sec);
}
//jissou kaizen no yochi ari.(kesareta node wo delete) 
Np erase(node* v,int k) // remain,erased
{
	Np sr = split(v,k+1);
	Np sl = split(sr.fi,k);
	return mp(merge(sl.fi,sr.sec),sl.sec);
}
node *root;
int n,q;
int main()
{
	srand((unsigned int)time(NULL));
	scanf("%d %d",&n,&q);
	root = NULL;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		root = insert(root,i,x,(double)rand());
	}
	for(int i=0;i<q;i++)
	{
		int type,l,r,pos,val;
		scanf("%d %d %d",&type,&l,&r);
		pos = l;
		val = r;
		if(type==0)
		{
			Np s1 = split(root,l);
			Np s2 = split(s1.sec,r-l+1);
			Np s3 = split(s2.fi,r-l);
			root = merge(merge(s1.fi,merge(s3.sec,s3.fi)),s2.sec);
		}
		else if(type==1)
		{
			Np s1 = split(root,l);
			Np s2 = split(s1.sec,r-l+1);
			printf("%d\n",mini(s2.fi));
			root = merge(s1.fi,merge(s2.fi,s2.sec));
		}
		else
		{
			Np s1 = split(root,pos);
			Np s2 = split(s1.sec,1);
			node* newnode = new node(val,(double)rand());
			root = merge(merge(s1.fi,newnode),s2.sec);
		}
	}
	return 0;
}

Measured memory_bytes: 13700
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,x;cin>>n>>x;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    long long res = 1ll<<60;
    for(long long i=1;i<=n;++i){
        long long tmpres = 0;
        multiset<long long> se;
        for(int k=0;k<i;++k)se.insert(a[k]);
        for(long long k=0;k<n;++k){
            auto itr=se.begin();
            tmpres += *itr;
            se.erase(a[k]);
            se.insert(a[(k+i)%n]);
        }
        res = min(res,tmpres + (i-1)*x);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;


public class Main {
    static void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = "2018" + s.substring(4, s.length());
        System.out.println(s);
    }

    public static void main(String[] args) {
        solve();
    }
}


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

using namespace std;

using ll = long long;

int main()
{
    queue<ll> que;
    for (ll i = 1; i < 10; i++) que.push(i);

    ll K; cin >> K;

    for (ll i = 0; i < K - 1; i++) {
        ll tmp = que.front();
        if (tmp % 10 != 0) que.push(10 * tmp + tmp % 10 - 1);
        que.push(10 * tmp + tmp % 10);
        if (tmp % 10 != 9) que.push(10 * tmp + tmp % 10 + 1);
        que.pop();
    }

    cout << que.front() << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
 
#define MAX 6400
 
int main()
{
	int i, j, H, W, A[82][82], B[82][82], D[82][82];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) scanf("%d", &(A[i][j]));
	}
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			scanf("%d", &(B[i][j]));
			D[i][j] = abs(A[i][j] - B[i][j]);
		}
	}
	
	int k, dp[2][82][MAX + 1] = {};
	for (j = 2, dp[1][1][D[1][1]] = 1; j <= W; j++) {
		for (k = 0; k <= MAX; k++) {
			if (dp[1][j-1][k] == 1) {
				dp[1][j][abs(k - D[1][j])] = 1;
				if (k + D[1][j] <= MAX) dp[1][j][k + D[1][j]] = 1;
			}
		}
	}
	for (i = 2; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			for (k = 0; k <= MAX; k++) dp[i%2][j][k] = 0;
		}
		for (k = 0; k <= MAX; k++) {
			if (dp[1-i%2][1][k] == 1) {
				dp[i%2][1][abs(k - D[i][1])] = 1;
				if (k + D[i][1] <= MAX) dp[i%2][1][k + D[i][1]] = 1;
			}
		}
		for (j = 2; j <= W; j++) {
			for (k = 0; k <= MAX; k++) {
				if (dp[i%2][j-1][k] == 1) {
					dp[i%2][j][abs(k - D[i][j])] = 1;
					if (k + D[i][j] <= MAX) dp[i%2][j][k + D[i][j]] = 1;
				}
				if (dp[1-i%2][j][k] == 1) {
					dp[i%2][j][abs(k - D[i][j])] = 1;
					if (k + D[i][j] <= MAX) dp[i%2][j][k + D[i][j]] = 1;
				}
			}
		}
	}
	
	for (k = 0; k <= MAX; k++) if (dp[H%2][W][k] == 1) break;
	printf("%d\n", k);
	fflush(stdout);
	return 0;
}


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

#define N 1000

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

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (a  == (i * j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int h, w, K;
    cin >> h >> w >> K;
    K--;  // Kを0-indexにする

    vector<vector<ll>> dp(h+1, vector<ll>(w));  // dp[i+1][j] : i行目を通過した直後にj列目にいる場合の数のmodでの剰余(i,jは0-index)

    dp[0][0] = 1LL;
    rep(i, h) {
        rep(j, w) {
            for(int b = 0; b < (1 << (w-1)); b++) {  // bのjビット目が1ならj列目とj+1列目の間に横棒を引き、0なら引かない
                
                // 横棒がつながっていないか調べる
				int flag = 1;
				rep(L, w-1) {
					if ( (b & (1 << L)) && (b & (1 << (L+1))) ) {  // bのLビット目もL+1ビット目も1のとき
						flag = 0;  // 横棒はつながっている
					}
				}

                //横棒がつながっていないとき
                if(flag) {
                    // bのj-1ビット目が1だったら、j列目からj-1列目に移動する(左方向に横棒を通過する場合)
                    if( j >= 1 && (b & (1 << (j-1))) ) {
                        dp[i+1][j-1] += dp[i][j];
                        dp[i+1][j-1] %= mod;
                    }
                    // bのjビット目が1だったら、j列目からj+1列目に移動する(右方向に横棒を通過する場合)
                    else if( j <= w-2 && (b & (1 << j)) ) {
                        dp[i+1][j+1] += dp[i][j];
                        dp[i+1][j+1] %= mod;
                    }
                    // 横棒を通過せず下に降りる場合
                    else {
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j] %= mod;
                    }
                }

            }
        }
    }

    cout << dp[h][K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int ww[110],v[110];
ll dp[100009];
int main() {
    ios::sync_with_stdio(false);
    int n,w;cin>>n>>w;
    for(int i=1;i<=n;i++)cin>>ww[i]>>v[i];
    for(int i=1;i<=w;i++)dp[i]=-1e9;
    dp[0]=0;
    for(int i=1;i<=n;i++)
        for(int j=w;j>=ww[i];j--)
            dp[j]=max(dp[j],dp[j-ww[i]]+1ll*v[i]);
    cout<<*max_element(dp+1,dp+w+1)<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a; cin >> a;
    cout << a + a*a + a*a*a;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool chk(int n, vector<bool> &use){
  if(n == 0){
    return !use.at(0);
  }
  while(n != 0){
    if(use.at(n%10) == true) return false;
    n /= 10;
  }
  return true;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<bool> use(10, false);
  rep(i, k){
    int in;
    cin >> in;
    use.at(in) = true;
  }
  while(1){
    if(chk(n, use) == true){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}

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

int main(){
    for(;;){
        int i,j,o;
        cin >> i >> j;
        if((i == 0) && (j == 0)){
            break;
        }
        if(i > j){
            o = i;
            i = j;
            j = o;
        }
        cout << i << " " << j << endl;
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#define N 150
using namespace std;

string a, mn, ans[N];

string f(string p, string q) {
	if (p == "") return q;
	if (p.size() != q.size()) return p.size() < q.size() ? p : q;
	return p < q ? p : q;
}

int main()
{
	int i, j;
	for (i = 'a'; i <= 'z'; i++) ans[i] = i;
	cin >> a;
	for (i = a.size() - 1; i >= 0; i--) {
		mn = "";
		for (j = 'a'; j <= 'z'; j++) mn = f(mn, ans[j]);
		ans[a[i]] = a[i] + mn;
	}
	mn = "";
	for (i = 'a'; i <= 'z'; i++) mn = f(mn, ans[i]);
    cout << mn << endl;
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n);
   rep(i,0,n)scanf("%d",&a[i]);
   int res=inf;
   rep(i,0,101){
      int sub=0;
      rep(j,0,n)sub+=(a[j]-i)*(a[j]-i);
      chmin(res,sub);
   }
   printf("%d\n",res);
   return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)	((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
  
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    cout.setf(ios::fixed); cout.precision(9);    
    solve();               	
    return 0;
} 

const int MOD = 998244353, MAXN = 100 + 10, INF = 1e9 + 10;
 
void solve() {
    string s;
    cin >> s;

    string t($(s), 'x');
    cout << t << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

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;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    FOR(b, 1, N+1){
      ll n = (N+1)/b; //nセット
      ans += n * max(b-K, 0LL);

      ll rest = (N+1)%b;//あまり
      ans += max(rest-K, 0LL);
    }

    if(K==0) ans-=N;
    p(ans);
    return 0;
}

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

const int N = 200000;

typedef long long ll;

int n;
int a[N + 5], b[N + 5];

ll ans = -1;
ll cost() {
    ll res = 0;
    for(int i = 1; i < n; ++i) {
        res += std::abs(b[i] - b[i-1]);
    }
    return res;
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", a + i);
    std::sort(a, a + n);

    if(n & 1) {
        int j = n-1;
        for(int i = 2; i < n - 1; i += 2, -- j) { b[i] = a[j]; }
        b[0] = a[j--];
        b[n-1] = a[j--];
        for(int i = 1; i < n; i += 2, -- j) { b[i] = a[j]; }
        ans = max(ans, cost());

        j = n - 1;
        for(int i = 1; i < n; i += 2, -- j) { b[i] = a[j]; }
        b[0] = a[j--];
        b[n-1] = a[j--];
        for(int i = 2; i < n - 1; i += 2, -- j) { b[i] = a[j]; }

        ans = max(ans, cost());
    } else {
        int j = n-1;
        for(int i = 1; i < n; i += 2, -- j) { b[i] = a[j]; }
        for(int i = 0; i < n; i += 2, -- j) { b[i] = a[j]; }

        ans = max(ans, cost());
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

/*
「定理 : 一番長い辺が他の N-1 辺の長さの合計よりも真に短い場合に限り、条件を満たす N 角形が描ける。」

からといって、

一番長い辺が他の N-1 辺の長さの合計よりも真に短ければ必ず条件を満たすN角形が描けるとは言えないにゃーん。

(もとの定理の裏)

とはいえ、図形を考えてみれば多分描けるやろ(雑)
*/

int main(void) {
	int N;
	int L[16];
	int i;
	int asumisu = 0, mizuhasu = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &L[i]) != 1) return 1;
		asumisu += L[i];
		if (mizuhasu < L[i]) mizuhasu = L[i];
	}
	puts(asumisu - mizuhasu > mizuhasu ? "Yes" : "No");
	return 0;
}


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

using namespace std;

int main()
{
    while (1)
    {
        int w, h, dp[101][101][2][2], mod=100000;
        memset(dp, 0, sizeof(dp));
        cin>>w>>h;
        if (!w) break;
        for (int i=1; i<=w; i++) dp[1][i][1][0]=1;
        for (int i=1; i<=h; i++) dp[i][1][1][1]=1;
        for (int i=2; i<=h; i++)
        {
            for (int j=2; j<=w; j++)
            {
                dp[i][j][0][0]=dp[i][j-1][1][1];
                dp[i][j][0][1]=dp[i-1][j][1][0];
                dp[i][j][1][0]=(dp[i][j-1][1][0]+dp[i][j-1][0][0])%mod;
                dp[i][j][1][1]=(dp[i-1][j][1][1]+dp[i-1][j][0][1])%mod;
            }
        }
        cout<<(dp[h][w][0][0]+dp[h][w][0][1]+dp[h][w][1][0]+dp[h][w][1][1])%mod<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <string>
 
using namespace std;
int main() {
  int x,y,z;
  int k,s;
  int count {0};
  
  cin >> k;
  cin >> s;
  for(x=0; x<=k; x++) {
    for(y=0; y<=k; y++) {
      z=s-(x+y);
      if (z >= 0 && z <= k && x+y+z == s) {
        count += 1;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
def floyd(n,L):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                L[i][j]=min(L[i][j],L[i][k]+L[k][j])

while True:
    n,m,s,g1,g2=map(int,raw_input().split())
    if n==0:break
    s-=1
    g1-=1
    g2-=1
    INF=1e10
    L=[[INF]*n for i in range(n)]
    for i in range(n):
        L[i][i]=0
    for i in range(m):
        b1,b2,c=map(int,raw_input().split())
        b1-=1
        b2-=1
        L[b1][b2]=c
    floyd(n,L)
    ans=INF
    for i in range(n):
        ans=min(ans,L[s][i]+L[i][g1]+L[i][g2])
    print ans

Measured memory_bytes: 4684
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

ll toLong(string &str){
    ll res = 0;
    for(auto itr=str.begin(); itr!=str.end(); itr++){
        res *= 10;
        res += *itr - '0';
    }

    return res;
}

int main(void){

    string s;
    cin >> s;

    ll p = 1;
    ll ans = 0;
    REP(i,s.size()-1){
        ostringstream ss;
        ss << setw(s.size()-1) << setfill('0') << p;
        string plus(ss.str());

        do{
            int offset = 0;
            string s2(s);
            REP(j, plus.size()){
                if(plus[j] == '1'){
                    s2.insert(s2.begin()+j+1+offset, '+');
                    offset++;
                }
            }

            vector<string> v = split(s2, '+');
            for(string st : v) ans += (ll)toLong(st);

        }while(next_permutation(plus.begin(), plus.end()));

        p *= 10; p++;
    }

    cout << ans+(ll)toLong(s) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		for(int k = 0 ; k < n ; k++) {
			if(k != n - 1) {
				System.out.print(a[k] + " ");
			} else {
				System.out.print(a[k]);
			}

			if(k == n - 1) System.out.println();
		}
		insertionSort(a, n);
	}

	static int[] insertionSort(int[] a, int n) {
		for(int i = 1 ; i < n ; i++) {
			int v = a[i];
			int j = i - 1;
			while(j >= 0 && a[j] > v) {
				a[j + 1] = a[j];
				j--;
			}
			a[j + 1] = v;
			for(int k = 0 ; k < n ; k++) {
				if(k != n - 1) {
					System.out.print(a[k] + " ");
				} else {
					System.out.print(a[k]);
				}

				if(k == n - 1) System.out.println();
			}
		}
		return a;
	}

}

Measured memory_bytes: 34064
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=1e5;
int n,k,ans,tot;
vector<int>vr[maxn+8];
int pre[maxn+8],now[maxn+8],son[maxn+8],dep[maxn+8],fa[maxn+8];
bool vis[maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void add(int u,int v)
{
    pre[++tot]=now[u];
    now[u]=tot;
    son[tot]=v;
}

void dfs(int x)
{
    vr[dep[x]].push_back(x);
    for (int p=now[x];p;p=pre[p])
	{
	    int child=son[p];
	    fa[child]=x;dep[child]=dep[x]+1;
	    dfs(child);
	}
}

void solve(int x)
{
    for (int i=1;i<=k;i++)
	{
	    if (vis[x]) return;
	    vis[x]=1;
	    x=fa[x];
	}
    ans+=(x!=1);
}

int main()
{
    n=read(),k=read();
    int x=read();if (x!=1) ans=1;
    for (int i=2;i<=n;i++)
	{
	    int f=read();
	    add(f,i);
	}
    dfs(1);
    vis[1]=1;
    for (int i=n;i;i--)
	for (vector<int>::iterator it=vr[i].begin();it!=vr[i].end();it++)
	    solve(*it);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 10880
module IntMap = Map.Make(struct type t = int let compare = compare end)
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string |> List.map int_of_string

let m = List.fold_left (fun map i -> IntMap.add i (1 + try IntMap.find i map with Not_found -> 0) map) IntMap.empty a

let rec loop map a b = function
  | 0 -> true
  | n -> 
      let remove a s =
        match IntMap.find a s with
          | exception Not_found -> s
          | 1 -> IntMap.remove a s
          | n -> IntMap.add a (n - 1) s
      in
      IntMap.mem b map && loop (remove b map) b (a lxor b) (n - 1)

let () = print_endline @@ 
  if loop m (fst (IntMap.min_binding m)) (fst (IntMap.max_binding m)) n 
  then "Yes" else "No"

Measured memory_bytes: 16384
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = na()

s = [0] * (n + 1)
dic = {}
dic[0] = 1
for i in range(n):
    s[i+1] = s[i] + a[i]
    count = dic.get(s[i+1], 0) + 1
    dic[s[i+1]] = count
ans = 0
for m in dic.values():
    ans += m* (m-1)//2
print(ans)


Measured memory_bytes: 40748
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll x(n);
  rep(i, n){
    cin >> x[i];
  }
  vll a(n), b(n);
  rep(i, n){
    a[i] = b[n-1-i] = 50000*(i+1);
  }
  rep(i, n){
    a[x[i]-1] -= n-1-i;
  }
  print(a);
  print(b);
}


Measured memory_bytes: 1152
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  std::map<int, int> m;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    m[a]++;
  }
  if (m.size() <= k)
  {
    puts("0");
    return 0;
  }
  std::vector<std::pair<int, int>> v;
  for (auto& p : m)
  {
    v.emplace_back(p);
  }
  std::sort(v.begin(), v.end(), [](auto a, auto b){ return a.second < b.second; });
  int ans = 0;
  for (int i = 0; i < m.size() - k; ++i)
  {
    ans += v[i].second;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 11768
from sys import stdin


def main() -> None:
    s = next_str()
    print(s[0], len(s) - 2, s[-1], sep="")


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const int MAX_V = 55000;
const int INF = 1e9;
typedef pair<int, int> P;

struct Edge {
    int to;
    int cost;
};
vector<Edge> G[MAX_V];

vector<int> dijkstra(int s) {
    vector<int> d(MAX_V, INF);
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        if (d[p.second] <= p.first) continue;
        d[p.second] = p.first;
        for (Edge &e : G[p.second]) {
            if (d[e.to] > p.first + e.cost) { q.push(P(p.first + e.cost, e.to)); }
        }
    }
    return d;
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    vector<int> rtoi(N, -1);
    for (int i = 0; i < R; ++i) {
        cin >> r[i];
        r[i]--;
        rtoi[r[i]] = i;
    }

    auto get_id = [&](int i, int bt) { return i * (1 << 8) + bt; };

    for (int i = 0; i < M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        for (int bt = 0; bt < (1 << R); ++bt) {
            if (rtoi[A] != -1) {
                G[get_id(B, bt)].push_back((Edge){get_id(A, bt | (1 << rtoi[A])), C});
            } else {
                G[get_id(B, bt)].push_back((Edge){get_id(A, bt), C});
            }
            if (rtoi[B] != -1) {
                G[get_id(A, bt)].push_back((Edge){get_id(B, bt | (1 << rtoi[B])), C});
            } else {
                G[get_id(A, bt)].push_back((Edge){get_id(B, bt), C});
            }
        }
    }
    int s = MAX_V - 2;
    int t = MAX_V - 1;
    for (int i = 0; i < R; ++i) {
        G[s].push_back((Edge){get_id(r[i], 1 << rtoi[r[i]]), 0});
        G[get_id(r[i], (1 << R) - 1)].push_back((Edge){t, 0});
    }

    auto d = dijkstra(s);
    cout << d[t] << endl;

    return 0;
}

Measured memory_bytes: 174536
#include <bits/stdc++.h>
 
#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
 
#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()
 
using namespace std;
 
inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	
	int n = nxt();
	double ans = 0;
	if (n == 1) {
		ans = 1;
		printf("%.13f\n", ans);
		return 0;
	}

	if (n % 2 == 0) {
		ans = (double)(n / 2) / n;
		printf("%.13f\n", ans);
		return 0;
	} else {
		int cnt = 0;
		for (int i = 1; i <= n; ++i) {
			if (i % 2 != 0) {
				cnt++;
			}
		}

		ans = (double)cnt / n;
		printf("%.13f\n", ans);
		return 0;
	}
 
	return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 08, 2020 2:24 PM
 *    Problem Name  : A - Serval vs Monster
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc153/tasks/abc153_a
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;

    if(a%b == 0) cout << a/b << endl;
    else cout << (a/b)+1 << endl;


    return 0 ;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            --x;
            graph[u].emplace_back(x);
        }
    }
    queue<int> q;
    vector<int> dist(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int nv : graph[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            q.push(nv);
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << i << " " << dist[i - 1] << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  string s;
  while(true){
    getline(cin,s);
    //cout << s << endl;
    if(s==".") break;
    int len=s.length();
    std::vector<char> v;
    for(int i=0;i<len;i++){
      if(s[i]=='(' || s[i]==')' || s[i]=='[' || s[i]==']'){
        v.push_back(s[i]);
      }
    }
    bool update=true;
    while(update){
      update=false;
      int le=v.size();
      for(int i=0;i<le-1;i++){
        if((v[i]=='(' && v[i+1]==')') || (v[i]=='[' && v[i+1]==']')){
          v.erase(v.begin()+i,v.begin()+i+2);
          update=true;
          i=le;
        }
      }
      //for(int i=0;i<v.size();i++) cout << v[i];
      //cout << endl;
    }
    if(v.empty()) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
#define SIZE 2000000
#define INF 30
int n,hi[SIZE+1];

void maxHeapify(int i);
void increasekey (int i,int p);
void insert (int p);
int extract ();
int main(){
  int key;
  char hi[10];

  while(1){
    scanf("%s",hi);
    if(hi[0]=='e' && hi[1]=='n') break;
    if(hi[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }

  return 0;
}

void maxHeapify(int i){
  int l,r,max,tem;
  l=2*i;
  r=2*i+1;
  
  if(l<=n && hi[l]>hi[i]){
    max=l;
  }
  else max=i;
  if(r<=n && hi[r]>hi[max]){
    max=r;
  }
  if(max != i){
    tem =hi[i]; 
    hi[i]=hi[max];
    hi[max]=tem;
    maxHeapify(max);
  }
}

void increasekey (int i,int p){
  int tem;
  hi[i]=p;
  while(i>1 && hi[i/2]<hi[i]){
    tem =hi[i]; 
    hi[i]=hi[i/2];
    hi[i/2]=tem;

    i=i/2;
  }
}

void insert (int p){
  n++;
  hi[n]=-INF;

  increasekey(n,p);
}

int extract (){
  int a;
  if(n<1)
    return -INF;

  a=hi[1];
  hi[1]=hi[n--];
  
  maxHeapify(1);

  return a;
}
  



Measured memory_bytes: 5648
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,m=inp
d=[]
lis = na(n+1)
m.times{
  dd = inp
  lis[dd[0]] += 1
  lis[dd[1]] += 1
}
lis.delete_at(0)
lis.each do |d|
  if(!(d.even?))
    puts "NO"
    exit
  end
end
puts "YES"
=begin
=end

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c,d;
    cin >> a  >> b >> c >> d;
    ll x=0,y=0;
    if (a%d!=0){
        x++;
    }
    if (c%b!=0){
        y++;
    }
    if ((a/d)+x<(c/b)+y){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640