akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=20;
const int M=1e6+11;
const int mod1=998244353;
const int mod2=1e9+7;

int main(){
  ll n;
  cin>>n;
  cout<<n*(n-1)/2;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())

a = list(map(int, input().split(" ")))

yen = 0
x = 0
for i in a:
    yen += abs(i - x)
    x = i
yen += abs(x)

for i in range(n):
    if(i == 0):
        if((0 <= a[i] and a[i] <= a[i+1]) or (0 >= a[i] and a[i] >= a[i+1])):
            print(yen)
        elif(a[i] * a[i+1] < 0):
            print(yen - abs(a[i] * 2))
        elif(a[i] >= a[i+1] or a[i] <= a[i+1]):
            print(yen - abs(a[i+1] -a[i]) * 2)
        else:
            print(yen - abs(a[i] * 2))
    elif(i+1 < n):
        if((a[i-1] <= a[i] and a[i] <= a[i+1]) or (a[i-1] >= a[i] and a[i] >= a[i+1])):
            print(yen)
        elif((a[i-1] >= a[i] and a[i-1] >= a[i+1]) or (a[i-1] <= a[i] and a[i-1] <= a[i+1])):
            print(yen - abs((a[i+1] - a[i]) * 2))
        else:
            print(yen - abs((a[i] - a[i-1]) * 2))
    else:
        if((a[i-1] <= a[i] and a[i] <= 0) or (a[i-1] >= a[i] and a[i] >= 0)):
            print(yen)
        elif(a[i-1] * a[i] < 0):
            print(yen - abs(a[i] * 2))
        else:
            print(yen - abs((a[i-1] - a[i]) * 2))
        break


Measured memory_bytes: 29072
#include <stdio.h>

int main()
{
	int i, N, A[200001], B[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(B[i]));
	
	int min = 1 << 30;
	long long sum = 0;
	for (i = 1; i <= N; i++) {
		sum += A[i];
		if (A[i] > B[i] && B[i] < min) min = B[i];
	}
	
	if (min == 1 << 30) printf("0\n");
	else printf("%lld\n", sum - min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int INF = 1e9 + 10;

int N;
int A[100010];
int dp[100010];

signed main()
{
	cin >> N;

	rep1(i, N) cin >> A[i], A[i] *= -1;

	rep(i, N + 5) dp[i] = INF;

	rep1(i, N) {
		int idx = upper_bound(dp, dp + N + 1, A[i]) - dp;
		dp[idx] = A[i];
	}

	int ans = lower_bound(dp, dp + N + 3, INF) - dp;

	cout << ans << endl;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, K;
    cin >> N >> K;

    vector<int64_t> h(N);
    for (auto &hi: h) {
        cin >> hi;
    }

    vector<int64_t> dp(N, LINF);
    dp[0] = 0;
    for (size_t i = 0; i < N; ++i) {
        for (size_t j = 1; j <= K; ++j) {
            chmin(dp[i + j], abs(h[i + j] - h[i]) + dp[i]);
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	int n;
	cin >> n;
	int v[4];
	for(int i = 0; i < 4; i++){
		v[i] = 0;
	}
	while(n--){
		string x;
		cin >> x;
		if(x == "AC") v[0]++;
		else if(x == "WA") v[1]++;
		else if(x == "TLE") v[2]++;
		else if(x == "RE") v[3]++;
		
	}
	
	printf("AC x %d\n",v[0]);
	printf("WA x %d\n",v[1]);
	printf("TLE x %d\n",v[2]);
	printf("RE x %d\n",v[3]);

	return 0;
}


Measured memory_bytes: 3724
def resolve():
    n,m=map(int,input().split())
    edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(m)]
    ans=0
    for x in edges:
        C=list(range(n))
        for y in edges:
            if y==x: continue
            C=[C[y[0]] if C[i]==C[y[1]] else C[i] for i in range(n)]
        if len(set(C))!=1: ans+=1
    print(ans)
resolve()

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

#define int long long
#define pb push_back
#define F first
#define S second
#define MAX 10000000
#define MOD 1000000007
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef pair<int, int> PII;

signed main(){
    off;
    int N;
    cin>>N;
    int arr[N];
    int sum = 0;
    for(int i=0; i<N; i++){
        cin>>arr[i];
        sum += arr[i];
    }
    int dp[N][N];
    for(int L=0; L<N;L++){
        for(int i=0, j=L; j<N; ++i, ++j){
            int x = ((i + 2) <= j) ? dp[i + 2][j] : 0; 
            int y = ((i + 1) <= (j - 1)) ? dp[i + 1][j - 1] : 0; 
            int z = (i <= (j - 2)) ? dp[i][j - 2] : 0; 
  
            dp[i][j] = max(arr[i] + min(x, y), arr[j] + min(y, z)); 
        }
    }
    cout<<2*dp[0][N-1] - sum<<endl;
    return 0;
}

Measured memory_bytes: 70528
#include <stdio.h>
 int main(){
  char p[101],s[101];  int i=0,j=0,k=0,l=0,m=0;  int ans=0;  for(i=0; i<101; i++){    scanf("%c",&s[i]);    if(s[i]=='\n')break;  }  for(j=0; j<101; j++){    scanf("%c",&p[j]);    if(p[j]=='\n')break;  }  for(k=0;k<i;k++){    if(s[k]==p[0]){      for(l=0; l<j; l++){        m=k+l;        if(m>=i)m-=i;        if(s[m]!=p[l])break;        if(l==j-1)ans=1;      }    }  }  if(ans)printf("Yes\n");  else printf("No\n");  return 0;}


Measured memory_bytes: 2108
#include <iostream>


using namespace std;

int main(){
 int n,i,j,temp;
 cin >> n;
 int a[n];
 for (i=0;i<n;++i) {
   cin >> a[i];
 }

 for (i=0;i<n;++i) {
   temp=a[i];
   for (j=i-1;j>-1;--j) {
     if (a[j]>temp) {
       a[j+1]=a[j];
     } else {
       break;
     }
   }
   a[j+1]=temp;
   for (j=0;j<n;++j) {
     cout << a[j];
     if (j<n-1) {
       cout << " ";
     } else {
       cout << endl;
     }
   }
 }
 return 0;
}



Measured memory_bytes: 3076
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    String ans = "Yes";
    if(s.length() == a + b + 1) {
    for(int i = 0; i < a + b + 1; i++) {
      char t = s.charAt(i);
      String str;
      if(i < a) {
        str = String.valueOf(t);
        try {
          int m = Integer.parseInt(str);
        } catch(NumberFormatException e) {
          ans = "No";
          break;
        }
      } else if(i == a) {
        if(t != '-') {
          ans = "No";
          break;
        }
      } else {
        str = String.valueOf(t);
        try {
          int m = Integer.parseInt(str);
        } catch(NumberFormatException e) {
          ans = "No";
          break;
        }
      }
    }
    }
    if(s.length() != (a + b + 1)) ans = "No";
    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
/*****Here we go again!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 3e5 + 10;

int main()
{
    fast;
    int n;
    cin >> n;
    vi a(n);
    get(a,n);

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    f(i,2,n)
        dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
    cout << dp[n-1];
}


Measured memory_bytes: 3980
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 1000005;
constexpr int INF = 1e9+5;
constexpr int INI = -1;


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b, k;
    cin >> k >> a >> b;
    bool ans = false;
    for(int i=a; i<=b; ++i){
        if(i%k == 0) ans = true;
    }
    if(ans) cout << "OK";
    else cout << "NG";
    return 0;
}


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

#define MAX 10000500
#define L   15

char Hash[MAX][L];

long long int h1(long long int key){
  return key%MAX;
}

long long int h2(long long int key){
  return 1+key%(MAX-1);
}

long long int h(int i, long long int key){
  return (h1(key)+i*h2(key))%MAX;
}

long long int create_key(char *str){
  long long int sum=0;
  
  for(int i=0, j=1; i<strlen(str); i++, j*=5){
    if(*(str+i)=='A') sum+=j;
    else if(*(str+i)=='C') sum+=j*2;
    else if(*(str+i)=='G') sum+=j*3;
    else sum+=j*4;
  }

  return sum;
}

void insert(long long int key, char *str){
  int i=0;
  long long int j;
  
  while(true){
    j=h(i, key);
    if(strlen(Hash[j])==0){
      strcpy(Hash[j], str);
      break;
    }
    else i++;
  }
}

bool find(long long int key, char *str){
  for(int i=0;;i++){
    int j=h(i, key);
    if(strcmp(Hash[j], str)==0) return true;
    else if(strlen(Hash[j])==0) return false;
  }
}

void init(void){
  int  n;
  long long int key;
  char com[L], str[L];
  
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%s %s", com, str);
    key=create_key(str);
  
    if(com[0]=='i'){
      insert(key, str);
    }
    else if(com[0]=='f'){
      if(find(key, str)) printf("yes\n");
      else printf("no\n");
    }
  }
}

int main(void){
  init();
  
  return 0;
}



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

#define MAX 500000
#define SENTINEL 2000000000

long L[MAX/2+2], R[MAX/2+2];

long merge(long x[], long n, long left, long mid, long right){
	long n1=mid-left;
	long n2=right-mid;
	
	long cnt=0;
	
	for(long i=0; i<n1; ++i) L[i]=x[left+i];
	for(long i=0; i<n2; ++i) R[i]=x[mid+i];
	L[n1]=R[n2]=SENTINEL; //?????????????????????

	long i=0, j=0;
	for(long k=left; k<right; ++k){
		if(L[i]<=R[j]) x[k]=L[i++];
		else{
			x[k]=R[j++];
			cnt+=n1-i;
		}
	}	
	
	return cnt;
}

long mergesort(long x[], long n, long left, long right){
	if(left+1 < right){
		long mid=(left+right)/2;
		
		long v1, v2, v3;
		
		v1=mergesort(x, n, left, mid);
		v2=mergesort(x, n, mid, right);
		v3=merge(x, n, left, mid, right);
		
		return v1+v2+v3;	
	}
	else return 0;
}

int main(){
	long a[MAX], n;
	
	scanf(" %ld", &n);
	for(long i=0; i<n; ++i) scanf(" %ld", &a[i]);
	
	long ans=mergesort(a, n, 0, n);
	
	printf("%ld\n", ans);
}

Measured memory_bytes: 6292
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int N, M, S, G1, G2;
int d[100][100];

int main(){
    while(std::cin >> N >> M >> S >> G1 >> G2, N){
        --S; --G1; --G2;
    
        REP(i, N){
            REP(j, N){
                if(i == j){d[i][j] = 0;}
                else{d[i][j] = INF;}
            }
        }

        REP(i, M){
            int from, to, cost;
            std::cin >> from >> to >> cost;
            --from; --to;
        
            d[from][to] = cost;
        }

        REP(k, N){
            REP(i, N){
                REP(j, N){
                    d[i][j] = std::min(d[i][j], d[i][k]+d[k][j]);
                }
            }
        }

        int res = INF;
        REP(i, N){
            res = std::min(res, d[S][i]+(d[i][G1]+d[i][G2]));
        }

        std::cout << res << std::endl;
    }
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 64000;

int n, k;
vector <int> un, my;
int cur, dp[2][Maxn];

int main()
{
    scanf("%d %d", &n, &k);
    int p = 1;
    while (p <= n) {
        un.push_back(p);
        p = n / (n / p) + 1;
    }
    un.push_back(p);
    my.resize(un.size());
    for (int i = 0; i + 1 < un.size(); i++) {
        int p = n / (un[i + 1] - 1);
        my[i] = upper_bound(un.begin(), un.end(), p) - un.begin();
    }
    dp[cur][int(un.size()) - 1] = 1;
    for (int i = 0; i < k; i++) {
        int ways = 0;
        for (int j = int(un.size()) - 1; j > 0; j--) {
            ways = (ways + dp[cur][j]) % mod; dp[cur][j] = 0;
            dp[!cur][my[j - 1]] = (dp[!cur][my[j - 1]] + ll(un[j] - un[j - 1]) * ways) % mod;
        }
        cur = !cur;
    }
    int res = 0;
    for (int j = 0; j < un.size(); j++)
        res = (res + dp[cur][j]) % mod;
    printf("%d\n", res);
    return 0;
}


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

using namespace std;

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

    int n , m;
    cin >> n >> m;

    vector<int> adj[n];
    for (int i = 0 ;i < m ;i++) {
        int k;
        cin >> k;
        while (k--) {
            int s;
            cin >> s;
            adj[s - 1].push_back(i);
        }
    }

    vector<int> p(m);
    for (int i = 0 ;i < m ;i++)
        cin >> p[i];

    int ans = 0;
    for (int i = 0 ;i < (1 << n) ;i++) {
        vector<int> cnt(m , 0);
        for (int j = 0 ;j < n ;j++) {
            if (i & (1 << j)) {
                for (int b : adj[j])
                    cnt[b]++;
            }
        }

        bool good = 1;
        for (int j = 0 ;j < m ;j++)
            good &= p[j] == cnt[j] % 2;

        ans += good;
    }

    cout << ans;
}

Measured memory_bytes: 3636
X,N = map(int,input().split(" "))
target = X
if N != 0:
    p_list = list(map(int,input().split(" ")))

    target_num_min = X
    target_num_plus = X
    if X in p_list:
        while True:
            target_num_min -= 1
            if target_num_min not in p_list:
                target = target_num_min
                break
            target_num_plus += 1
            if target_num_plus not in p_list:
                target = target_num_plus
                break
print(target)

Measured memory_bytes: 9140
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int N,T;
	int c[100],t[100];
	int mi = -1,min_c = 1200;

	scanf("%d %d",&N,&T);
	for (int i = 0; i < N; ++i)
	{
		scanf(" %d %d",&c[i],&t[i]);
		if(c[i] < min_c && t[i] <= T){
			min_c = c[i];
			mi = i;
		}
	}
	if(mi == -1)	printf("TLE\n");
	else printf("%d\n", min_c);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main()
{
  char buf[BUF_SIZE];
  int n=atoi(fgets(buf,BUF_SIZE,stdin));
  int array[ARRAY_SIZE];
  int change_count=0;

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

  int tmp=0;
  for(int i=i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(array[j]>array[j+1]){
        tmp=array[j+1];
        array[j+1]=array[j];
        array[j]=tmp;
        change_count++;
      }
    }
  }

  for(int i=0;i<n;i++){
    if(i!=n-1){
      printf("%d ",array[i]);
    }else{
            printf("%d\n",array[i]);
    }
    
  }
  printf("%d\n",change_count);
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int A,B,X;
  cin>>X>>A>>B;
  if(B <= A)
  {
    cout<<"delicious"<<endl;
  }
  else if(B <= A + X)
  {
    cout<<"safe"<<endl;
  }
  else
  {
    cout<<"dangerous"<<endl;
  }
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll N;

ll k;

ll p[100005];


ll dp[100005];
ll ans[100005];

ll rec(ll idx,ll D)
{
  ll mini=INT_MAX;
if (idx==D)
return 0;  


if (dp[idx]!=INT_MAX)
return dp[idx];



for(int j=1;j<=k;j++)
{
if(idx+j<=D){
mini=min(mini,abs(p[idx]-p[idx+j])+rec(idx+j,D));
}
}

dp[idx]=mini;
return dp[idx];
}


int main()
{


fastio();

cin>>N;

cin>>k;

for (int i=1;i<=N;i++)
cin>>p[i];  

fill(dp,dp+N,INT_MAX);
fill(ans, ans+N,INT_MAX);

ll g=rec(1, N);

cout<<g;
    
return 0;
}



Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n,k;
ll a[maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	sort(a,a+n);
	reverse(a,a+n);
	ll ans=0;
	for(int i=k;i<n;i++)
	{
		ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define bp __builtin_popcount
#define vi vector<int>
#define cr const reg&
#define int128 __int128
using namespace std;
const int mod = 998244353, N = 1e6 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int128 read() {
	int128 x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(int128 x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(int128 x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(int128 x) {put(x), putchar(' ');}
I void pr2(int128 x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

map<int128, int128> f;
LL A, B, C, D;

I int128 dfs(int128 n) {
	if(!n) return 0;
	if(n == 1) return D;
	if(f.count(n)) return f[n];
	int128 ans = D * n;
	reg o = n % 2;
	if(!o) ans = min(ans, dfs(n / 2) + A);
	else ans = min(ans, min(dfs((n - 1) / 2), dfs((n + 1) / 2)) + A + D);
	o = n % 3;
	if(o <= 1) ans = min(ans, dfs((n - o) / 3) + B + D * o);
	else ans = min(ans, dfs((n + 3 - o) / 3) + B + (3 - o) * D);
	o = n % 5;
	if(o <= 2) ans = min(ans, dfs((n - o) / 5) + C + D * o);
	else ans = min(ans, dfs((n - o + 5) / 5) + C + D * (5 - o));
	return f[n] = ans;
}

int main() {
	reg T = read();
	while(T--) {
		int128 n = read(); A = read(), B = read(), C = read(), D = read();
		f.clear(), pr2(dfs(n));
	}
	return 0;
}




Measured memory_bytes: 4652
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i, N) { cin >> w[i] >> v[i]; }
  int V_MAX = 100 * 1000;
  const ll INF = 10000000000;

  vector<vector<ll>> dp(N + 1, vector<ll>(V_MAX + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= V_MAX; j++) {
      if (v[i] <= j) {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  ll Ans;
  for (Ans = V_MAX; Ans >= 0; Ans--) {
    if (dp[N][Ans] <= W) break;
  }
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 80256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())

i = 0
s = 0
while s <= N:
    i += 1
    s += i
ans = set(range(1, i + 1))
ans.remove(s - N)
print(*ans, sep='\n')


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#define int long long
#define mod 1000000007
using namespace std;

int dp[54];
signed main() {
	int a; cin >> a;
	string b, c; cin >> b >> c;
	if (b[0] == c[0]) {
		dp[1] = 3;
	}
	else {
		dp[2] = 6;
	}
	for (int i = 1; i < a; i++) {
		if (!dp[i])continue;
		if (b[i - 1] == c[i - 1]) {
			if (b[i] == c[i]) {
				dp[i + 1] = dp[i] * 2 % mod;
			}
			else {
				dp[i + 2] = dp[i] * 2 % mod;
			}
		}
		else {
			if (b[i] == c[i]) {
				dp[i + 1] = dp[i];
			}
			else {
				dp[i + 2] = dp[i] * 3 % mod;
			}
		}
	}
	cout << dp[a] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;
int main() {
	int N;
	cin >> N;
	vector<int> s(N);
	int res = 0;
	for (int i = 0 ; i < N; i++) {
		cin >> s[i];
		res += s[i];
	}
	if (res % 10 == 0) {
		int mins = 10000;

		for (int i = 0; i < N; i++) {
			if (s[i] % 10 != 0) {
				mins = min(mins, s[i]);
			}
		}
		if (mins == 10000) {
			res = 0;
		}
		else {
			res -= mins;
		}
	}

	

	cout << res << endl;
	return 0;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        scanner.nextLine();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        scanner.nextLine();
        String u = scanner.next();
        if (s.equals(u)) {
            System.out.println(String.valueOf(a - 1) + ' ' + String.valueOf(b));
        } else if (t.equals(u)) {
            System.out.println(String.valueOf(a) + ' ' + String.valueOf(b - 1));
        }
    }
}


Measured memory_bytes: 22100
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template<typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    int a, b, k;
    cin >> a >> b >> k;
    int g = gcd(a, b);
    vector<int> divs;
    for (int i = 1; i * i <= g; i++)
    {
        if (g % i)
            continue;
        divs.push_back(i);
        if (i * i != g)
            divs.push_back(g / i);
    }
    sort(divs.rbegin(), divs.rend());
    cout << divs[k - 1] << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var k = int.Parse(Console.ReadLine());
        var set = new HashSet<string>();

        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 1; i + j <= s.Length && j <= k; j++)
            {
                set.Add(s.Substring(i, j));
            }
        }

        var array = set.ToArray();
        Array.Sort(array);
        Console.WriteLine(array[k - 1]);
    }
}


Measured memory_bytes: 14688
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <string>

using namespace std;
int main() {
		int n;
	cin >> n;
	vector <int>c(n);
	vector <int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];


int sum = 0;

for (int i = 0; i < n; i++)
{
	if (v[i] > c[i])
		sum = sum + v[i] - c[i];
}
cout << sum;
}

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

#define MAX_SIZE 110

void paint(int (*R)[MAX_SIZE], int hs, int he, int ws, int we) {
  for (int i = hs; i < he; ++i) {
    for (int j = ws; j < we; ++j) {
      R[i][j] = 1;
    }
  }
}

int main() {
  int R[MAX_SIZE][MAX_SIZE] = {0};
  int W, H, N;
  cin >> W >> H >> N;

  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    switch (a) {
    case 1:
      paint(R,0,H,0,x);
      break;
    case 2:
      paint(R,0,H,x,W);
      break;
    case 3:
      paint(R,0,y,0,W);
      break;
    case 4:
      paint(R,y,H,0,W);
      break;
    }
  }

  int ans = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (!R[i][j]) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  uint64_t N = 0;
  std::cin >> N;

  uint64_t remain = N;
  uint32_t count = 0, e = 0;
  while (remain % 2 == 0) {
    remain /= 2;
    e++;
  }
  for (size_t i = 1; e >= i; e -= i, i++, count++) {
  }

  for (size_t i = 3, e = 0; i * i <= remain; i += 2, e = 0) {
    while (remain % i == 0) {
      remain /= i;
      e++;
    }
    for (size_t i = 1; e >= i; e -= i, i++, count++) {
    }
  }

  if (remain != 1) count++;

  std::cout << count << std::endl;

  return 0;
}

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

#define SIGN_LENGTH 9
#define CIPHER_NUM 32
#define CODE_MAX 801
#define NUL 0x00
#define INITIALIZE 0
#define TEXT_MAX 100
#define FIVE 5

typedef struct cipher
{
	char charcter_change_sign[SIGN_LENGTH];
	char sign_change_charcter[SIGN_LENGTH];
	char charcter;
}CIPHER;

int main(void)
{
	short i = INITIALIZE;
	short j = INITIALIZE;
	short text_length = INITIALIZE;
	short barcode_length = 0;
	int count = INITIALIZE;
	
	char input_text[TEXT_MAX];
	char barcode[CODE_MAX];
	char code_fivecut[160][5];
	
	CIPHER code[CIPHER_NUM] = {
		{"100101","00000",'A'},
		{"10011010","00001",'B'},
		{"0101","00010",'C'},
		{"0001","00011",'D'},
		{"110","00100",'E'},
		{"01001","00101",'F'},
		{"10011011","00110",'G'},
		{"010000","00111",'H'},
		{"0111","01000",'I'},
		{"10011000","01001",'J'},
		{"0110","01010",'K'},
		{"00100","01011",'L'},
		{"10011001","01100",'M'},
		{"10011110","01101",'N'},
		{"00101","01110",'O'},
		{"111","01111",'P'},
		{"10011111","10000",'Q'},
		{"1000","10001",'R'},
		{"00110","10010",'S'},
		{"00111","10011",'T'},
		{"10011100","10100",'U'},
		{"10011101","10101",'V'},
		{"000010","10110",'W'},
		{"10010010","10111",'X'},
		{"10010011","11000",'Y'},
		{"10010000","11001",'Z'},
		{"101","11010",' '},
		{"010001","11011",'.'},
		{"000011","11100",','},
		{"10010001","11101",'-'},
		{"000000","11110",'\''},
		{"000001","11111",'?'}
	};
	for(i = 0; i < TEXT_MAX; i++)
	{
		input_text[i] = NUL;
	}
	
	while(gets(input_text) != NULL)
	{
		
		
		for(i = 0; i < CODE_MAX-1; i++)//配列の最後(800番目)には\0が入るためマイナス1してある
		{
			barcode[i] = NUL;
		}
		
		for(i = 0; i < 160;i++)
		{
			for(j = 0; j < 5; j++)
			{
				code_fivecut[i][j] = '0';
			}
		}
		
		for(i = 0; i < TEXT_MAX; i++)
		{
			text_length++;
			if(input_text[i] == NUL)
			{
				break;
			}
		}
		
		for(i = 0; i < text_length; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				if(input_text[i] == code[j].charcter)
				{
					strcat(barcode, code[j].charcter_change_sign);
				}
			}
		}
		
		for(i = 0; i < 801; i++)
		{
			barcode_length++;
			if( barcode[barcode_length] == '\0')
			{
				break;
			}
		}
		int c = 0;
		
		for(i = 0; i < barcode_length; i++)
		{
			for(j = 0; j < 5; j++)
			{
				if(c < barcode_length)
				{
					code_fivecut[i][j] =  barcode[c];
					c++;
				}
			}
		}
		
		for(i = 0;i < CODE_MAX ; i+= 5)
		{
			if(barcode_length <= i)
			{
				count = i / 5;
				break;
			}
		}
		
		int k = 0;
		int cc = 0;
		for(i = 0; i < count; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				for(k = 0; k < 5; k++)
				{
					if(code_fivecut[i][k] == code[j].sign_change_charcter[k])
					{
						cc++;
					}
				}
				if(cc == 5)
				{
					printf("%c",code[j].charcter);
				}
				cc = 0;
			}
		}
		printf("\n");
		count = 0;
		barcode_length = 0;
		text_length = 0;
	}
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
int main(void){
	int i,j,n,tako[51],sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&tako[i]);
	for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) sum+=(tako[i]*tako[j]);
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main()
{
    double X;
    cin>> X;
    double a=100 ;

    for(int i=1;;i++){
        
        a+=floor(a/100);
        if(a>=X){
            cout<<i<<endl;
            break;
        }
    }
  
    return 0;
}


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

int main()
{
      int n,k;
    cin>>n>>k;
    long s;
    cin>>s;
    int j=k;
    if(s>100000000){
        while(j--){
            cout<<s<<" ";
        }
        k=n-k;
        while(k--){
            cout<<"1"<<" ";
        }
        return 0;
    }
    while(j--){
        cout<<s<<" ";
    }
    k = n-k;
    while(k--){
        cout<<s+1<<" ";
    }


    return 0;
}


Measured memory_bytes: 1280
import sys
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from random import randint
d=int(input().rstrip())
c=[int(i)for i in input().split()]
s=[[int(i)for i in input().split()]for _ in range(d)]
last=[0]*26
for i in range(d):
    print(randint(1,26))

Measured memory_bytes: 9876
#include<stdio.h>

int main(void){
    int W,H,x,y,r,i,j;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    for ( i = ( x - r ) ; i <= ( x + r ) ; i++ ) {
        for ( j = ( y - r ) ; j <= ( y + r ) ; j++ ) {
            if ( i < 0 || i > W || j < 0 || j > H ) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>

using namespace std;

int main(){
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << (double)W*H/2 << " ";
    if(W%2 == 0 && H%2 == 0){
        if(W/2 == x && H/2 == y){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }else{
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
ll dp[305][305][305]={0};
bool used[305][305][305]={0};
string s;
ll get_dp(ll i,ll j,ll k){
  if(i==j) return dp[i][j][k]=1;
  else if(i+1==j){
    if(k==0) return dp[i][j][k]=(s[i]==s[j]?2:1);
    else return dp[i][j][k]=2;
  }
  else if(used[i][j][k]>0) return dp[i][j][k];
  used[i][j][k]=true;
  dp[i][j][k]=max(get_dp(i+1,j,k),get_dp(i,j-1,k));
  if(s[i]==s[j]) dp[i][j][k]=max(dp[i][j][k],get_dp(i+1,j-1,k)+2);
  else if(k>0) dp[i][j][k]=max(dp[i][j][k],get_dp(i+1,j-1,k-1)+2);
  return dp[i][j][k];
}
int main(){
  cin>>s;
  ll k;
  cin>>k;
  for(int i=0;i<305;i++){
    for(int j=0;j<305;j++){
      for(int l=0;l<305;l++) used[i][j][l]=false;
    }
  }
  cout<<get_dp(0,s.length()-1,k)<<endl;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m);
    rep(i, m) cin >> x.at(i) >> y.at(i);

    vector<int> ball_cnt(n, 1);
    vector<bool> red_potential(n, false);
    red_potential.at(0) = true;

    for (int i = 0; i < m; i++)
    {
        if (ball_cnt.at(x.at(i) - 1) != 0)
        {
            if (red_potential.at(x.at(i) - 1) == true)
            {
                ball_cnt.at(x.at(i) - 1) -= 1;
                ball_cnt.at(y.at(i) - 1) += 1;
                red_potential.at(y.at(i) - 1) = true;
            }
            else
            {
                ball_cnt.at(x.at(i) - 1) -= 1;
                ball_cnt.at(y.at(i) - 1) += 1;
            }
        }
        if (ball_cnt.at(x.at(i) - 1) == 0)
        {
            red_potential.at(x.at(i) - 1) = false;
        }
    }

    int answer = 0;
    for (int i = 0; i < n; i++)
    {
        if (red_potential.at(i) == true)
        {
            answer++;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  if(c=="a"){ cout << "vowel"; return 0; }
  if(c=="i"){ cout << "vowel"; return 0; }
  if(c=="u"){ cout << "vowel"; return 0; }
  if(c=="e"){ cout << "vowel"; return 0; }
  if(c=="o"){ cout << "vowel"; return 0; }
  cout << "consonant"; 
  
  
    
}
 

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n,k,ok[20],ans;
// ok[i] : digit i is ok
bool check(int a) {
	while (a!=0) {
		if (!ok[a%10])
			return false;
		a/=10;
	}
	return true;
}
int main() {
	scanf("%d %d",&n,&k);
	for (int i=0;i<=9;i++)
		ok[i]=true;
	for (int i=1;i<=k;i++) {
		int x;
		scanf("%d",&x);
		ok[x]=false;
	}
	ans=n;
	while (1) {
		if (check(ans))
			break;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion
lint n, m;
vector<vector<lint>> G(n + 15, vector<lint>(0));
void dfs(lint v, vector<bool>& seen, lint& res) {
	bool end = true;
	for (int i = 0; i < seen.size(); ++i) 
		if (!seen[i] && i != v) 
			end = false;
	if (end) {
		++res;
		return;
	}

	seen[v] = true;
	for (auto nv : G[v]) {
		if (seen[nv]) 
			continue;
		dfs(nv, seen, res);
	}
	seen[v] = false;
}
//うぅ…自力でわからなかった
//けんちょんさんの記事を参考にしました…ありがとうございます

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		lint a, b; cin >> a >> b; 
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<bool> seen(n, false);
	lint res = 0;
	dfs(0, seen, res);
	printf("%lld\n", res);

	return 0;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	/*string s;
	cin>>s;
	int a[n];
	for(int i=0;i<n;++i)
	cin>>a[i];*/
	if(n<m) {
		cout<<0;
	} else cout<<10;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if a >= b {
		fmt.Println("delicious")
		return
	}
	if b-a <= x {
		fmt.Println("safe")
		return
	}
	fmt.Println("dangerous")
}


Measured memory_bytes: 512
#include <stdio.h>

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

	int arr[101] = {0};

	while (n--) {
		int p;
		scanf("%d", &p);
		arr[p] = 1;
	}

	for (int i = 0; i <= 100; i++) {
		if (x-i <= 0)
			printf("%d\n", x-i);
		else if (!arr[x-i])
			printf("%d\n", x-i);
		else if (x+i > 100)
			printf("%d\n", x+i);
		else if (!arr[x+i])
			printf("%d\n", x+i);
		else
			continue;

		break;
	}
}


Measured memory_bytes: 1728
#include<stdio.h>

int main(void)
{
	int n, a, b;
	int p1;
	
	scanf("%d %d %d", &n ,&a, &b);
	
	p1 = n * a;
	
	if(p1 > b){
		printf("%d\n", b);
	}else{
		printf("%d\n", p1);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n,ans = 1;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] != s[i + 1]) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

double dist_p(int n, double *x, double *y, int p)
{
	double s = 0;
	for(int i = 0; i < n; ++i)
	{
		s += pow(fabs(x[i] - y[i]), p);
	}
	return pow(s, 1.0 / p);
}

double dist_inf(int n, double *x, double *y)
{
	double m = 0;
	for(int i = 0; i < n; ++i)
	{
		double d = fabs(x[i] - y[i]);
		m = (m > d) ? m : d;
	}
	return m;
}

int main()
{
	int n;
	double x[100];
	double y[100];

	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lf", &x[i]);
	}
	for(int i = 0; i < n; ++i)
	{
		scanf("%lf", &y[i]);
	}

	printf("%.6f\n", dist_p(n, x, y, 1));
	printf("%.6f\n", dist_p(n, x, y, 2));
	printf("%.6f\n", dist_p(n, x, y, 3));
	printf("%.6f\n", dist_inf(n, x, y));
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  rep(i,h){
    rep(j,w){
      cin>>a[i][j];
    }
  }
   rep(i,h){
    rep(j,w){
      cout<<a[i][j];
      }
     cout<<endl;
     rep(j,w){
      cout<<a[i][j];
      }
     cout<<endl;
  }
}


Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[] ar = str.split("");
        int n = 0;
        int m = 0;
        int num = 0;
        int length = str.length();

        String a = "A";
        String c = "C";




        if(ar[0].equals(a)){
            n = 0;
            for(int i = 2; i<str.length()-1; i++){
                if(ar[i].equals(c)){
                    n++;
                    num = i;
                }else{
                }
            }


            if(n == 1){
                for(int i = 0; i<str.length(); i++){
                    if(i == 0 || i == num){
                        continue;
                    }
                    if(Character.isLowerCase(str.charAt(i))){
                    }else{
                        m++;
                    }
                }

                if(m == 0){
                    System.out.println("AC");
                }else{
                    System.out.println("WA");
                }

            }else{
                System.out.println("WA");
            }
        }else{
            System.out.println("WA");
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef long long int lli;
const lli mod = 1e9+7;
using namespace std;

int main()
{
	fast;
	
	int n,m;cin>>n>>m;
	int a[n];
	lli s=0;
	for(int i=0; i<n; i++)
	{
	cin>>a[i];
	s+=a[i];
	}
	sort(a,a+n);
	lli y=ceil(((double)s/(double)(4*m)));
	int pos=n;
	for(int i=0; i<n; i++)
	{
		if(a[i]>=y)
		{
			pos=i;
			break;
		}
	}
	if(m> n-pos)
	{
		cout<<"No"<<"\n";
	}
	else{
		cout<<"Yes"<<"\n";
	}
		
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX=100;

int main(void){
    int n,x;
    int L[MAX];
    cin >> n >> x;
    for(int i=0; i<n; i++){
        cin >> L[i];
    }
    int bound=0;
    int dist=0;
    while(dist<=x && bound<=n+1){
        dist += L[bound];
        bound += 1;
    }
    cout << bound;
    return 0;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    printf("%lld",(N+1)/2);
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s, t;
	cin >> s >> t;
	cout << t << s << '\n';
	
	return 0;
}


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

int n, k, q, a;
vector<int> x;

int main(){
	cin >> n >> k >> q;
	x.resize(n);
	for (int i = 0; i < q; ++i){
		cin >> a;
		x[a-1]++;
	}
	for (int i = 0; i < n; ++i){
		printf("%s\n", (x[i] + k - q <= 0) ? "No" : "Yes");
	}
}

Measured memory_bytes: 1024