akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
   
      int N = sc.nextInt();
      int L = sc.nextInt();

      String[] S = new String[N];

      for (int i = 0;i<N;i++){
        S[i] = sc.next(); 
      }
      sc.close();
      
      Arrays.sort(S);
      
      StringBuilder sb = new StringBuilder();
      for (int i = 0;i<N;i++){
          sb.append(S[i]);  
      }
      System.out.println(sb.toString());
	}
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(void){
    while(1){
        int H, W;
        cin >>H >>W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i == 0 || i==H-1){
                    cout<<"#";
                }
                else if(j==0 || j==W-1){
                    cout<<"#";
                }
                else{
                    cout<<".";
                }
            }
            cout<<endl;
        }cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3008
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	int a, b, c, d, ma;
	cin >> a >> b >> c >> d;
	ma = max({a, b, c});
	int bb = a + b + c - ma;
	for (int i = 0; i < d; i++)
	{
		ma *= 2;
	}
	cout << ma + bb<<"\n";
}


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

int main(void) {
	unsigned long  A,B,K;

//入力
    scanf("%lu %lu %lu",&A,&B,&K);

    if(A<=K) {K-=A;A=0;}
    else     {A-=K;K=0;}

    if(B<=K)  B=0;
    else      B-=K;

    printf("\n%lu %lu\n",A,B);

return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL w, h, x, y;
	cin >> w >> h >> x >> y;
	printf("%.15f ", 1.0 * w * h / 2);
	if (x * 2 == w && y * 2 == h) puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

// 二乗判定
template <typename T> bool is_square(T n){T rt = sqrt(n); return rt*rt == n;}

// 約数列挙
vector<LLI> divisor_list(LLI n){
  vector<LLI> temp, res;
  for(LLI i=1LL; i*i<n; ++i) if(n%i == 0) temp.push_back(i);
  for(auto i : temp) res.push_back(i);
  if(is_square(n)) res.push_back((LLI)sqrt(n));
  for(auto itr=temp.rbegin(); itr!=temp.rend(); ++itr) res.push_back(n/(*itr));
  return res;
}

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

  LLI n,k;
  while(cin >> n >> k){
    vector<LLI> a(n); cin >> a;
    sort(ALL(a));

    LLI s = accumulate(ALL(a), 0LL);

    auto divs = divisor_list(s);

    LLI ans = 0;

    for(auto d : divs){
      vector<LLI> b(n);
      REP(i,n) b[i] = a[i] % d;
      sort(ALL(b));

      LLI s = 0;
      LLI t = d * n - accumulate(ALL(b), 0LL);

      bool yes = false;

      if(s <= k and t <= k and (s-t)%d == 0){
        yes = true;
      }
      
      REP(i,n){
        s += b[i];
        t -= (d-b[i]);
        
        if(s <= k and t <= k and (s-t)%d == 0){
          yes = true;
        }
      }

      if(yes){
        chmax(ans, d);
      }
    }

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


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

INF = 10**18
if 0 in lst1:
    print(0)
    exit()
ans = 1
for i in range(n):
    ans *= lst1[i]
    if ans > INF:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 85700
import math
a,b,h,m = map(int,input().split())

h_angle = 30 * h
m_angle = 12 * m
diff = 2 * math.pi * (m / 60 - (h + m / 60) / 12)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(diff))
print(ans)

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>T;

	if(T>=n && T<=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



}


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

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<k;i++)
    ans+=a[i];
cout<<ans<<endl;
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0) : d(n, -1) {}
  int find(int x) { return d[x] < 0 ? x : d[x] = find(d[x]); }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


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

  Vi pre(m, -1);
  UnionFind uf(n);

  rep(i, n) {
    int k; cin >> k;
    rep(j, k) {
      int l; cin >> l;
      --l;
      if (pre[l] != -1) uf.unite(pre[l], i);
      pre[l] = i;
    }
  }

  cout << (uf.size(0) == n ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 3952
import sys 
S=input()
N=len(S)
n=(N-1)//2
for i in range(n):
    if S[i]!=S[-i-1]:
        print('No')
        sys.exit()
for i in range((n-1)//2):
    if S[i]!=S[n-i-1] or S[i+n+2-1]!=S[N-i-1]:
        print('No')
        sys.exit()
for i in range(1):
    if S[i]!=S[n-i-1] or S[i+n+2-1]!=S[N-i-1]:
        print('No')
        sys.exit()     
print('Yes')

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

using namespace std;
using ll=long long;

#define ip(i,w) for(int i=1;i<=w;i++)
#define ip2(j,h) for(int j=1;j<=h;j++)



int main()
{
    while(true)
    {
        int h,w;
        cin >> w >> h;
        if(w==0&&h==0)
        {
            break;
        }
        ip(i,w)
        {
        ip2(j,h)
        {
            if((j+i)%2==0)
            {
                cout << "#" ;
            }
            else
            {
                cout << ".";
            }
        } 
        cout << endl;
        }
        cout << endl;
    }
    return(0);
    
}



Measured memory_bytes: 3092
program prob5
    implicit none
    integer(16)::i,j,k,X,M, mid1, mid2
    integer(16), allocatable::a(:), b(:)
    read(*,*) M
    allocate(a(M), b(M))
    read(*,*) a

    b = a

    call heapsort(M,a)

    mid1 = a(M/2)
    mid2 = a(M/2 + 1)

    do i = 1, M
        if(b(i) <= mid1) then
            write(*,*) mid2
        else
            write(*,*) mid1
        end if
    end do

    deallocate(a, b)
    stop
    contains
    subroutine heapsort(n,array)
        implicit none
        integer(16),intent(in) :: n
        integer(16),intent(inout) :: array(1:n)
       
        integer ::i,k,j,l
        double precision :: t
       
        if(n.le.0)then
           write(6,*)"Error, at heapsort"; stop
        endif
        if(n.eq.1)return
      
        l=n/2+1
        k=n
        do while(k.ne.1)
           if(l.gt.1)then
              l=l-1
              t=array(L)
           else
              t=array(k)
              array(k)=array(1)
              k=k-1
              if(k.eq.1) then
                 array(1)=t
                 exit
              endif
           endif
           i=l
           j=l+l
           do while(j.le.k)
              if(j.lt.k)then
                 if(array(j).lt.array(j+1))j=j+1
              endif
              if (t.lt.array(j))then
                 array(i)=array(j)
                 i=j
                 j=j+j
              else
                 j=k+1
              endif
           enddo
           array(i)=t
        enddo
      
        return
    end subroutine heapsort
end program prob5

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

using namespace std;
int c[3005],pt;
int p,a[3005],b[3005],inv[3005];

int getc(int d)
{
    if(d==0||d==p-1) return 1;
    if(c[d]!=-1) return c[d];
    return c[d] = 1LL*pt*inv[d]*inv[p-d-1]%p;
}

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

    memset(c,-1,sizeof(c));
    for(int i=0;i<p;++i) scanf("%d",a+i);
    pt = 1;
    for(int i=2;i<=p-1;++i){
        pt*=i;pt%=p;
    }
    int tmp = 1;
    for(int i=1;i<=p-1;++i){
        inv[i]=1;tmp*=i;tmp%=p;
        for(int j=0;j<p-2;++j)
            {inv[i]*=tmp;inv[i]%=p;}
    }

    for(int i=0;i<p;++i){
        if(a[i]==0) continue;
        ++b[0];b[0]%=p;
        int base = 1;
        for(int j=0;j<p;++j){
            b[p-1-j]-=getc(j)*base%p;
            b[p-1-j]%=p;
            base*=-i;base%=p;
        }
    }

    for(int i=0;i<p;++i){
        if(b[i]<0) b[i]+=p;
        printf("%d ",b[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n;
  scanf("%d\n",&n);
  int v[n],c[n];
  for(int i = 0; i < n; ++i) scanf("%d",&v[i]);
  for(int i = 0; i < n; ++i) scanf("%d",&c[i]);
  int pre[n];
  for(int i = 0; i < n; ++i) pre[i] = v[i] - c[i];
  int answer = 0;
  for(int i = 0; i < n; ++i){
    if(pre[i] > 0) answer += pre[i];
  }
  printf("%d\n",answer);
  return 0;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  int a,b,l=0,r=1e5;
  //N $BKg$N(B ID $B%+!<%I$H(B M $B8D$N%2!<%H$,$"$j$^$9!#(B
  //i $BHVL\$N%2!<%H$O(BLi,Li+1,...,Ri$BHVL\$N(B 
  //ID $B%+!<%I$N$&$A$I$l$+(B 1 $BKg$r;}$C$F$$$l$PDL2a$G$-$^$9!#(B
  //1 $BKg$@$1$GA4$F$N%2!<%H$rDL2a$G$-$k(B 
  //ID $B%+!<%I$O2?Kg$"$k$G$7$g$&$+!#(B
  rep(i,m){
    cin>>a>>b;
    l=max(a,l);
    r=min(b,r);
    //cout<<l<<" "<<r<<endl;
  }
  cout<<max(r-l+1,0)<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int fx = 0;
    int temp = N;
    while (temp != 0) {
        fx += temp % 10;
        temp /= 10;
    }
    if (N % fx==0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
	int a,b,c,d,l,ans;
	cin >> l;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	if(a/c > b/d && a%c==0)
	{
		//cout<<"ok1";
		ans=a/c;
	}
	else if(a/c > b/d && a%c!=0)
	{
		//cout<<"ok2";
		ans=(a/c)+1;
	}
	else if(a/c < b/d && a%c==0)
	{
		//cout<<"ok3";
		ans=b/d;
	}
	else
		ans=(b/d)+1;

	cout << l-ans <<endl;


	return 0;
}

Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 15 20:38:11 2019

@author: Yamazaki Kenichi
"""

S = input()

counta = 1
ans = "Yes"
for c in S:
    if counta & 1:
        if c == "L":
            ans = 'No'
    else:
        if c == 'R':
            ans = 'No'
    counta += 1

print(ans)
        


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ans = 0;
  int i,j;
  cin >> n;
  for(i=1;i<=n;i+=2){
    int tmp = 0;
    for(j=1;j<=i;j++){
      if(i%j==0)tmp++;
    }
    if(tmp==8)ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;
}


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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    vector<ll> sum(n);
    sum.at(0) = v.at(0);
    for(int i=1; i<n; i++){
        sum.at(i) = sum.at(i-1) + v.at(i);
    }

    int ans = 1;
    for(int i=n-2; i>=0; i--){
        if(sum.at(i)*2 >= v.at(i+1)){
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  map<string, vector<pair<int, int>>> M;
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;

    M[S].push_back({P, i + 1});
  }

  for (auto& m : M) {
    string S = m.first;
    vector<pair<int, int>>& R = m.second;
    sort(R.rbegin(), R.rend());
    for (const auto r : R) {
      cout << r.second << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int D[31][31];
int grid[500][500];
int main()
{
	memset(D, 0, sizeof(D));
	memset(grid, 0, sizeof(grid));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, C; cin >> N >> C;
	for (int x = 1; x <= C; ++x){
		for (int y = 1; y <= C; ++y){
			cin >> D[x][y];
		} // end for
	} // end for

	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			cin >> grid[i][j];
		} // end for
	} // end for

	map<int,int> cnt0; cnt0.clear();	// cnt[color] := number
	map<int,int> cnt1; cnt1.clear();
	map<int,int> cnt2; cnt2.clear();
	for (int i = 0; i < N * N; ++i){
		int r = i / N;
		int c = i % N;
		if ((r + c) % 3 == 0){
			++cnt0[grid[r][c]];
		}else
		if ((r + c) % 3 == 1){
			++cnt1[grid[r][c]];
		}else{ // if ((r + c) % 3 == 2)
			++cnt2[grid[r][c]];
		} // end if
	} // end for

	int res = INF;
	for (int c0 = 1; c0 <= C; ++c0){
		for (int c1 = 1; c1 <= C; ++c1){
			if (c0 == c1) continue;
			for (int c2 = 1; c2 <= C; ++c2){
				if (c0 == c2 || c1 == c2) continue;

				int totalD0 = 0;
				map<int,int>::iterator it0 = cnt0.begin();
				for (; it0 != cnt0.end(); ++it0){
					int candc0 = (*it0).first;
					int num0   = (*it0).second;
					if (candc0 == c0) continue;
					totalD0 += D[candc0][c0] * num0;
				} // end for

				int totalD1 = 0;
				map<int,int>::iterator it1 = cnt1.begin();
				for (; it1 != cnt1.end(); ++it1){
					int candc1 = (*it1).first;
					int num1   = (*it1).second;
					if (candc1 == c1) continue;
					totalD1 += D[candc1][c1] * num1;
				} // end for

				int totalD2 = 0;
				map<int,int>::iterator it2 = cnt2.begin();
				for (; it2 != cnt2.end(); ++it2){
					int candc2 = (*it2).first;
					int num2   = (*it2).second;
					if (candc2 == c2) continue;
					totalD2 += D[candc2][c2] * num2;
				} // end for
				int total = totalD0 + totalD1 + totalD2;
				res = min(res, total);
			} // end for
		} // end for
	} // end for

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

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

int main(){
    int K, N;
    cin >> K >> N;
    int A[2*N];
    rep(i,N) cin >> A[i];
    rep(i,N) A[N+i] = K + A[i];

    int ans = K;

    rep(i,N) {
        ans = min(ans, A[N+i-1]-A[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;
const int MN = 1e5 + 5;

int n;
int arr[MN] , cap[MN];
vector<pii>adj[MN];

int dfs(int s,int pr)
{
	int tmp=0;
	if(Size(adj[s]) == 1){
		cap[pr] = arr[s];
		return cap[pr];
	}
	for(auto x:adj[s]){
		int v = x.first , e = x.second;
		if(e == pr) continue;
		tmp += dfs(v , e);		
	}
	if(~pr) cap[pr] = 2*arr[s] - tmp;
	return ((~pr)?cap[pr]:tmp);
}

int32_t main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n;
	for(int i=0;i<n;++i) cin >> arr[i];
	for(int i=0;i<n-1;++i){
		int a,b;cin>>a>>b;
		--a,--b;
		adj[a].pb({b,i});
		adj[b].pb({a,i});
	}
	if(n == 2) return cout << ((arr[0] == arr[1])?"YES\n":"NO\n") , 0;
	for(int i=0;i<n;++i) if(Size(adj[i]) > 1){
		int t = dfs(i , -1);
		if(t != 2*arr[i]) return cout << "NO\n" , 0;
		break;
	}
	for(int i=0;i<n-1;++i) if(cap[i] < 0) return cout << "NO\n" , 0;

	for(int v=0;v<n;++v) if(Size(adj[v]) > 1){
		int mx = -1;
		for(auto x:adj[v]) mx = max(mx , cap[x.second]);
		if(mx > arr[v]) return cout << "NO\n" , 0;		
	}		
	cout << "YES\n";
	return 0;
}


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

int main(){
  
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int a[n];
  int b[m];
  for(int i=0;i<n;i++){ cin >> a[i];}
  for(int i=0;i<m;i++){ cin >> b[i];}
  
  sort(a,a+n);
  sort(b,b+m);
  if(x<b[0] && a[n-1]<b[0] && a[n-1]<y){cout << "No War" << endl;}
  else{cout << "War" << endl;}

  return 0;
}

Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

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

    // code here
    int n = input<int>();

    vector<pair<int, int>> ans;
    
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (i + j != (n % 2 == 0 ? n + 1 : n))
                ans.emplace_back(i, j);
                    

    cout << SZ(ans) << "\n";
    for (auto elem: ans)
        cout << elem.first << " " << elem.second << "\n";
    
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  int X,i,p;
  p=1;
  scanf("%d",&X);
  
  for(i=1;i<=20;i++){
    if(105*i-105<X&&X<100*i){
      p=0;
    }
  }
  
  printf("%d",p);
  
  return 0;
}

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

int main(){
	int n, a, b;
	int sum = 0;
	cin >> n >> a >> b;
	for(int i=1; i<=n; i++){
		int tmp = i;
		int dSum = 0;
		while(tmp){
			dSum += tmp%10;
			tmp /= 10;
		}
		if(dSum >=a && dSum <= b)
			sum += i;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int cost[n];

    for(int i=0;i<n;i++)cin>>cost[i];

    int dp[n];

    dp[0] = 0;
    dp[1] = abs(cost[1]-cost[0]);

    for(int i=2;i<n;i++)
    {
        dp[i] = min( dp[i-1]+abs( cost[i]-cost[i-1] ), dp[i-2] + abs( cost[i]-cost[i-2]) );
    }
    cout<<dp[n-1];

}


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

int main(){
  
  int n;
  cin >> n;
  int b[110];
  for(int i=1; i<n; i++) cin >> b[i];
  
  int sum=b[1];
  for(int i=1; i<n-1; i++){
  	sum+=min(b[i],b[i+1]);
  }
  sum+=b[n-1];
  cout << sum<< endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.Function
import Control.Monad

judge :: Int -> Int -> Int -> String
judge m f r
    | m == -1 || f == -1           = "F"
    | t >= 80                      = "A"
    | t < 80 && t >= 65            = "B"
    | t < 65 && t >= 50 || r >= 50 = "C"
    | t < 50 && t >= 30            = "D"
    | otherwise                    = "F"
    where
        t = m + f

main :: IO ()
main = fix $ \loop -> do
    [m,f,r] <- map read . words <$> getLine
    unless ([m,f,r] == [-1,-1,-1]) $ do
        putStrLn $ judge m f r
        loop


Measured memory_bytes: 3996
#include <stdio.h>

int main(void){
	int a,b,c,d;
	int i,j,temp;

	while(scanf("%d %d",&a,&b)!=EOF){
		c = a;
		d = b;
		for(i = 1,j = 1;1;){
			if(a*j>b*i){
				i++;
			}else if(a*j<b*i){
				j++;
			}else if(a*j == b*i){
				break;
			}
			
		}


		for(;1;){
			if(c % d != 0){
				temp = c%d;
				c = d;
				d = temp;
			}else{
				break;
			}
		}
		printf("%d %d\n",d,a*j);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
pair<string, pair<int,int> > p[105];
bool my_comp(pair<string,pair<int,int> > p1, pair<string, pair<int,int> > p2)
{
    if(p1.F!=p2.F)
        return p1.F<p2.F;
    return p1.S.F>p2.S.F;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s; int x;
        cin>>s>>x;
        p[i]=mp(s,mp(x,i+1));
    }
    sort(p,p+n,my_comp);
    for(int i=0;i<n;i++)
        cout<<p[i].S.S<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int N,K;
    cin >> N >> K;
    vi p(N);
    in(N,p);
    
    vd pp(N);
    rep(i,N) pp[i] = (double)(p[i]+1)/2;
    
    double ans = 0.0, an = 0.0;
    rep(i,K) ans += pp[i];
    int s = 0;
    an = ans;
    reps(i,K,N) {an += pp[i]-pp[s];s++;chmax(ans,an);}
    outset(10);
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 5548
n = int(input())
cheak_box = [[0]*9 for _ in range(9)]

for i in range(1, n+1):
    s = str(i)
    s1 = int(s[0]) - 1
    s2 = int(s[-1]) - 1
    if s2 == -1:
        continue 
    cheak_box[s1][s2] += 1

ans = 0
for p in range(9):
    for q in range(9):
        ans += cheak_box[p][q] * cheak_box[q][p]
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 200000+10;
const int mo = 1000000000+7;

int n,m;
LL a[maxn],b[maxn],p[maxn];
map<pair<LL,LL>,int> mp;

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

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
    for (int i=1;i<=n;i++)
    {
        if (a[i]==0&&b[i]==0) continue;
        m++;
        LL x=abs(a[i]);
        LL y=abs(b[i]);
        LL g=gcd(x,y);
        a[i]/=g;
        b[i]/=g;
        if (a[i]<0) a[i]=-a[i],b[i]=-b[i];
        if (a[i]==0&&b[i]<0) b[i]=-b[i];
        pair<LL,LL> pir=make_pair(a[i],b[i]);
        mp[pir]++;
    }
    int w=n-m;
    p[0]=1;
    for (int i=1;i<=n;i++) p[i]=p[i-1]*2ll%mo;
    LL ans=1;
    for (int i=1;i<=n;i++)
    {
        if (a[i]==0&&b[i]==0) continue;
        LL x=-b[i];
        LL y=a[i];
        if (x<0) x=-x,y=-y;
        if (x==0&&y<0) y=-y;
        pair<LL,LL> pir=make_pair(a[i],b[i]);
        int k1=mp[pir]; mp[pir]=0;
        pir=make_pair(x,y);
        int k2=mp[pir]; mp[pir]=0;
        //printf("...%d %d %lld\n",k1,k2,p[k1]+p[k2]-1);
        ans=ans*(p[k1]+p[k2]-1)%mo;
    }
    ans=(ans-1+w+mo)%mo;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 33500
#include <stdio.h>


#define DEF_ELEM_MAX 10001

int S[DEF_ELEM_MAX];
int N;
int ans = 0;

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
void linearSearch(int key)
{
	int i = 0;

	S[N] = key;
	while (S[i] != key) {
		i++;
	}
	if ( i < N ) {
		ans++;
	}
	return;
}
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	int i;
	int Q;
	int key;

//
	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &S[i]);
	}

	scanf("%d", &Q);
	for ( i = 0 ; i < Q ; i++ ) {
		scanf("%d", &key);
		linearSearch(key);
	}

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

	return 0;
}

Measured memory_bytes: 636
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    n, k = na()
    xs = na()

    m = float('inf')
    for i in range(n-k+1):
        if xs[i] * xs[i+k-1] < 0:
            l = abs(xs[i]) + abs(xs[i+k-1]) + min(abs(xs[i]), abs(xs[i+k-1]))
        else:
            l = max(abs(xs[i]), abs(xs[i+k-1]))

        m = min(m, l)

    print(m)
    
main()


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

using namespace std;
int main(){
    string s; cin >> s;
    int i,n = s.size();
    if(s[n - 1]!='s') s.push_back('s');
    else{
        s.push_back('e'); s.push_back('s');
    }
    cout << s << endl;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
N,M,S,T = map(int,input().split())
S,T = S-1,T-1
UVAB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for u,v,a,b in UVAB:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))

import heapq
INF = float('inf')
costy = [INF] * N
costy[S] = 0
hq = [(0,S)]
while hq:
    c,v = heapq.heappop(hq)
    for to,a,_ in es[v]:
        if costy[to] <= c+a: continue
        costy[to] = c+a
        heapq.heappush(hq, (c+a,to))

costs = [INF] * N
costs[T] = 0
hq = [(0,T)]
while hq:
    c,v = heapq.heappop(hq)
    for to,_,b in es[v]:
        if costs[to] <= c+b: continue
        costs[to] = c+b
        heapq.heappush(hq, (c+b,to))

ans = [0]
for y,s in reversed(list(zip(costy,costs))):
    ans.append(max(ans[-1], 10**15 - y - s))

print(*ans[1:][::-1], sep='\n')

Measured memory_bytes: 81744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int num, size;
    cin >> num;
    cin >> size;
    unordered_map<int, int> map;
    for (int i = 0; i < size; i++)
    {
        int a;
        cin >> a;
        map[a] = 1;
    }
    int l = num, r = num;
    while (1)
    {
        if (!map[l])
        {
            cout << l << endl;
            return 0;
        }
        if (!map[r])
        {
            cout << r << endl;
            return 0;
        }
        l--;
        r++;
    }

    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <cstring>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
const int maxn = 5e4+10;
double esp = 1e-8;
int flag, le;
double r,PI = acos(-1);

int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        if(n>999) printf("ABD\n");
        else printf("ABC\n");
    }
    return 0;
}
/***************

****************/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

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

	int k;
	k = abs((b + a));
	if(k % 2 == 0) {
		k = k / 2;
		cout << k;
		return 0;
	}
	else {
		cout << "IMPOSSIBLE";
		return 0;
	}
	return 0;
}

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;



void solve() {
	ld n;
	cin >> n;
	n *= 2;
	n *= M_PI;
	cout << setprecision(10) << fixed;
	cout << n;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}


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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')cout << "vowel";
    else cout << "consonant";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int[] s = sc.nextLine().chars().map(c -> c - '0').toArray();

        boolean ok = s[0] == 1 && s[s.length-1] == 0;
        for (int i = 0; i < s.length-1; i++) {
            if (s[i] != s[s.length-2-i]) ok = false;
        }

        if (!ok) {
            System.out.println(-1);
        }
        else {
            ArrayList<Edge> edges = new ArrayList<>();
            Stack<Integer> children = new Stack<>();
            for (int v = 1; v <= s.length; v++) {
                if (s[v-1] == 1 || v == s.length) {
                    while (!children.empty()) {
                        edges.add(new Edge(v, children.pop()));
                    }
                }
                children.push(v);
            }

            for (Edge e : edges) {
                System.out.printf("%d %d\n", e.u, e.v);
            }
        }

        sc.close();
    }
}

class Edge {
    public int u, v;
    Edge(int u, int v) {
        this.u = u;
        this.v = v;
    }
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct node{
    int id;
    lint cost;

    bool operator<(const node &right) const {
        return cost > right.cost;
    }
};

int main(){
    int n, m, k, s;
    lint p, q;
    cin >> n >> m >> k >> s >> p >> q;
    vector< vector<int> > g(n);
    vector<bool> zombie(n);
    rep(i, k){
        int c;
        cin >> c;
        --c;
        zombie[c] = true;
    }
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dis(n, IINF);
    rep(i, n){
        if(zombie[i] && dis[i] == IINF){
            queue< P > bfs;
            bfs.push({i, 0});
            while(!bfs.empty()){
                P now = bfs.front();
                bfs.pop();
                if(zombie[now.first]){
                    now.second = 0;
                }
                if(now.second > s || dis[now.first] <= now.second){
                    continue;
                }
                dis[now.first] = now.second;
                for(auto x : g[now.first]){
                    if(dis[x] > now.second + 1){
                        bfs.push({x, now.second + 1});
                    }
                }
            }
        }
    }
    vector<bool> danger(n);
    rep(i, n){
        danger[i] = dis[i] <= s;
    }
    vector<lint> cost(n, LLINF);
    priority_queue<node> dij;
    dij.push({0, 0});
    while(!dij.empty()){
        node now = dij.top();
        dij.pop();
        if(cost[now.id] <= now.cost){
            continue;
        }
        cost[now.id] = now.cost;
        for(auto x : g[now.id]){
            if(!zombie[x]){
                if(danger[x] && cost[x] > now.cost + q && x != n - 1){
                    dij.push({x, now.cost + q});
                }else if(!danger[x] && cost[x] > now.cost + p && x != n - 1){
                    dij.push({x, now.cost + p});
                }else if(cost[x] > now.cost && x == n - 1){
                    dij.push({x, now.cost});
                }
            }
        }
    }
    cout << cost.back() << endl;
    return 0;
}


Measured memory_bytes: 10612
A = []
for i in range(3):
  a = list(map(int,input().split()))
  A.append(a)

B = []
N = int(input())
for i in range(N):
  b = int(input())
  B.append(b)
  
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
  print('Yes')
elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
  print('Yes')
else:
  for i in range(3):
    if A[i][0] in B and A[i][1] in B and A[i][2] in B:
      print('Yes')
      exit()
    if A[0][i] in B and A[1][i] in B and A[2][i] in B:
      print('Yes')
      exit()
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    int a[n], cnt(0);
    for (auto& i : a)
        cin >> i;
    if (n < 3)
        return cout << 0, 0;
    //sort(a, a + n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (i == j)
                continue;
            for (int k = j + 1; k < n; k++) {
                if (j == k or i == k)
                    continue;
                if (a[i] == a[j] or a[j] == a[k] or a[k] == a[i])
                    continue;
                if (a[i] + a[j] > a[k] and a[i] + a[k] > a[j] and a[j] + a[k] > a[i])
                    cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i=0; i<M; i++){
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    if(M<=N) cout << 0 << endl;
    else{
        int remain=M-N;
        vector<int> dis(M-1);
        for(int i=0; i<M-1; i++){
            dis[i]=X[i+1]-X[i];
        }
        sort(dis.begin(), dis.end());
        int ans=0;
        for(int i=0; i<remain; i++){
            ans+=dis[i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
s = int(input())
a = [s]
count = 1

for i in range(100000):
  if a[i] % 2 == 0:
    b = a[i]/2
  else:
    b = 3*a[i]  + 1  
  a.append(b)
  count += 1
  if a.count(b) >1:
    break

print(count)

Measured memory_bytes: 9188
while true
  h, w = gets.split(" ").map(&:to_i)
  if h == 0 && w == 0
    break
  end
  puts "#" * w
  (h-2).times do
    puts "#" + "." * (w-2) + "#"
  end
  puts "#" * w
  print "\n"
end

Measured memory_bytes: 8888
import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
import java.math.BigInteger.*;
import java.util.Arrays; 

public class   Main
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  int[] nums1[];
  boolean con = true;
  
  ArrayList < Integer >  ar = new ArrayList < Integer >();
  ArrayList < Integer >  fi = new ArrayList < Integer >();
  Map<Integer,Integer > map = new HashMap<Integer, Integer>();
  public static void main (String[] args)
  {
    new Main  ();
  }
  
  public int GCD(int a, int b) {
    if (b==0) return a;
    return GCD(b,a%b);
  }
  
  public int LIS(int arr[])
  {
    int n = arr.length;
    int sun[] = new int [n];
    int cur = 0;
    for(int x = 0;x<n;x++)
    {
      int temp = Arrays.binarySearch(sun,0,cur,arr[x]);
      if(temp < 0)
        temp = -temp -1;
      sun[temp] = arr[x];
      if(temp == cur)
        cur++;
    }
    return cur;
    
  }
  
  
  
  
  public Main  ()
  {
    try
    {
      
      in = new BufferedReader (new InputStreamReader (System.in));
     int a = nextInt();
     int c = nextInt();
     String b = nextLine();
     int happy = 0;
     for(int x = 0;x<a;x++)
     {
       if(b.charAt(x) == 'L')
       {
         if(x != 0 && b.charAt(x-1) == 'L')
           happy++;
       }
       else
       {
         if(x != a - 1 && b.charAt(x+1) == 'R')
           happy++;
       }
     }
     System.out.println(Math.min(a-1,happy + 2 * c));
                        
    }
    catch(IOException e)
    {
      
    }
  }
  
  
  
  
  
  
  
  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }
    
    
    return as.nextToken ();
  }
  
  
  
  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }
  
  
  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }
  
  
  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }
  
  
  String nextLine () throws IOException
  {
    return in.readLine ().trim ();
  }
}

Measured memory_bytes: 25044
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

#from math import gcd
from fractions import gcd

def main():
	n=int(input())
	A=list(map(int,input().split()))
	B=set(A)
	A=list(A)
	A.sort(reverse=True)
	a=1
	ans=0
	for i in A:
		g=gcd(a, i)
		ans *=i//g
		a=a*i//gcd(a, i)
		ans+=a//i
	
	
	
	
	print(ans%mod)
	
	
	
	
	
	


if __name__ == "__main__":
	main()


Measured memory_bytes: 6456
#include <stdio.h>

int main()
{
   long int a,b,c,sum,k;
   scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
   sum=0;
  if(a>b && a>c)
  {
      while(k--)
      {
          a*=2;
          sum=a+b+c;
      }
  }else{
      if(b>a && b>c)
      {
          while(k--)
      {
          b*=2;
          sum=b+a+c;
      }
      }else{
          
              while(k--)
      {
          c*=2;
          sum=c+a+b;
      }
      }
      
  }
  printf("%ld",sum);

    return 0;
}


Measured memory_bytes: 128