akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

size_t di[]={size_t(-1), 0, 1, 0};
size_t dj[]={0, size_t(-1), 0, 1};
char t[]={'^', '<', 'v', '>'};
char dir[]={'U', 'L', 'D', 'R'};

void simulate(std::vector<std::string> &s, 
    size_t &si, size_t &sj, size_t &me, char ch) {

  size_t H=s.size(), W=s[0].length();

  if (ch == 'S') {
    // shoot
    size_t i=si+di[me], j=sj+dj[me];
    while (i < H && j < W) {
      if (s[i][j] == '*') {
        s[i][j] = '.';
        return;
      } else if (s[i][j] == '#') {
        return;
      }
      i += di[me];
      j += dj[me];
    }
    return;
  }

  // move
  size_t k;
  for (k=0; k<4; ++k) 
    if (dir[k] == ch) break;

  size_t ni=si+di[k], nj=sj+dj[k];
  me = k;
  if (!(ni < H && nj < W) || s[ni][nj] != '.') {
    // cannot move
    s[si][sj] = t[me];
    return;
  }
  s[si][sj] = '.';
  s[ni][nj] = t[me];
  si = ni;
  sj = nj;
}

int solve_testcase() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  std::vector<std::string> S(H);
  size_t si=-1, sj=-1;
  size_t me=-1;
  for (size_t i=0; i<H; ++i) {
    char buf[32];
    scanf("%s", buf);
    S[i] = buf;

    for (size_t j=0; j<W; ++j) {
      for (size_t k=0; k<4; ++k) {
        if (S[i][j] == t[k]) {
          si = i;
          sj = j;
          me = k;
        }
      }
    }
  }

  size_t N;
  char buf[128];
  scanf("%zu %s", &N, buf);
  std::string T=buf;
  for (size_t i=0; i<N; ++i) {
    simulate(S, si, sj, me, T[i]);
  }

  for (size_t i=0; i<H; ++i)
    printf("%s\n", S[i].c_str());

  return 0;
}

int main() {
  int T;
  scanf("%d", &T);
  for (int i=0; i<T; ++i) {
    if (i > 0) printf("\n");
    solve_testcase();
  }
}



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

using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ll n,i;
	int k,min,max,mid;
	cin>>n>>k;
	vector<int>L(n);
	for(i=0;i<n;i++){
	    cin>>L[i];
	}
	sort(L.begin(),L.end());
	min=-1;
	max=n;
	while(max-min>1){
	    mid=(max+min)/2;
	    if(L[mid]<k){
	        min=mid;
	    }
	    else{
	        max=mid;
	    }
	}
	cout<<n-max<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        int temp = 0;

        for(int i = 1;i <= b-a ;i++){//i=0,1,2,,,,n-1 で動作
            temp += i;
        }

        System.out.println(temp - b);
    }
}

Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var exps [1003]int

	for i := 0; i <= n; i++ {
		t := i
		div := 2
		for div*div <= i {
			if t%div == 0 {
				t /= div
				exps[div]++
			} else {
				div++
			}
		}
		if t != 1 {
			exps[t]++
		}
	}

	var ans int64 = 1
	const mod = int64(1e9) + 7

	for i := 2; i <= n; i++ {
		ans *= int64(exps[i] + 1)
		ans %= mod
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
n=int(input())
s=input()

j=s[1:].count("E")
t=[j]
for i in range(n-1):
	t.append(t[i]+s[i].count("W")-s[i+1].count("E"))
	if j>t[i+1]:
		j=t[i+1]
print(j)


Measured memory_bytes: 15544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5000+100;

ll a[maxn],t[maxn],n,ans;

inline int low_bit(int x){
	return x&(-x);
}
void updata(int i,ll k){
	for(;i<maxn;i+=low_bit(i))t[i]+=k;
}
int query(int i){
	ll ans=0;
	for(;i>0;i-=low_bit(i))ans+=t[i];
	return ans;
}

int main(){
	memset(t,0,sizeof(t));
	scanf("%lld",&n);

	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		updata(a[i],1);
	}
	ans=0;
	sort(a,a+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			int r=a[i]+a[j]-1,l=a[i]-a[j];
			if(l<0)l=-l;
			int tmp=query(r)-query(l);
			if(l<a[i]&&a[i]<=r)tmp--;
			if(l<a[j]&&a[j]<=r)tmp--;
			if(tmp>0)ans+=tmp;
		}
			
	printf("%lld\n",ans/3);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
int main()
{
    int a,b;
    cin>>a>>b;
    if((a*b)&1)
        cout<<"Yes"<<el;
    else
        cout<<"No"<<el;


    return 0;
}


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

int main() {
  
  int n,m,a=0,b;
  cin>>n>>m;
  b=n;
  vector<int> vec(2*m);
  for(int i=0; i<2*m; i++){
    cin>>vec[i];
  }
  for(int i=0; i<m; i++){
    if(vec[2*i]>a)
      a=vec[2*i];
  }
  for(int i=0; i<m; i++){
    if(vec[2*i+1]<b)
      b=vec[2*i+1];
  }
  cout<<max(b-a+1,0)<<endl;
  
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}


/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

int n;
vi es[101010];
int a[101010], b[101010];

map<P, int> ans;

int dfs(int v, int c, int p = -1){
  if(p != -1){
    int x = v, y = p;
    if(x > y) swap(x, y);
    ans[P(x, y)] = c;
  }
  int nextc = c;
  bool flag = false;
  for(int to : es[v]) if(to != p) {
    if(flag) nextc++;
    else if(nextc <= 1) { flag = true; nextc = c+1; }
    else nextc--;
    dfs(to, nextc, v);
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n-1){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    es[a[i]].emplace_back(b[i]);
    es[b[i]].emplace_back(a[i]);
    if(a[i] > b[i]) swap(a[i], b[i]);
  }

  dfs(0, 0);

  int ma = 0;
  for(auto i : ans){
    chmax(ma, i.second);
//    cout << i.first.first << " " << i.first.second << " " << i.second << endl;
  }
  cout << ma << endl;
  rep(i, 0, n-1) cout << ans[P(a[i], b[i])] << endl;

  return 0;
}



Measured memory_bytes: 16384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        System.out.println(Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)));
    }
}

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

ll fc(int lv){
	ll ans = 1;
	rep(i, lv){
		ans = ans * 2 + 3;
	}
	return ans;
}

ll al(ll lv){
	ll ans = 1;
	rep(i, lv){
		ans = ans * 2 + 1;
	}
	return ans;
}

ll b_s(ll x, ll l, ll r, int lv){
	if(lv == 0){
			return 1;
	}
	ll mid = (l+r)/2;
	if(x == r-1) return al(lv-1) * 2 + 1;
	else if(x == l) return 0;
	else if(mid < x) return b_s(x, mid + 1, r-1, lv-1) + al(lv-1) + 1;
	else if(mid == x) return al(lv-1) + 1;
	else return b_s(x, l+1, mid, lv-1);
}

int main(){
	int n;
	ll x;
	cin >> n >> x;
	ll count = fc(n);
	ll ans = b_s(x-1, 0, count, n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int dp[MAXN];

int main() { 

  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1] + 1;
    for (int j = 6; j <= i; j *= 6) {
      dp[i] = min(dp[i], 1 + dp[i - j]);
    }
    for (int j = 9; j <= i; j *= 9) {
      dp[i] = min(dp[i], 1 + dp[i - j]);
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stdint.h>
#include<cmath>
#include<map>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29) 
#define MAX_N 101
#define MAX_M 101
#define MAX_Damage 1000005
using namespace std;

int N,M;
int HP[MAX_N];
vector<int> MP[2],Damage[2];
bool Target[MAX_M];//false -> Single, true -> All
uint64_t dp[2][MAX_Damage];



int main()
{
  while(cin >> N,N)
    {
      rep(i,N)cin >> HP[i];
      cin >> M;
      string Name,target;
      int mp,damage;
      rep(i,2)MP[i].clear(),Damage[i].clear();
      rep(i,M)
	{
	  cin >> Name >> mp >> target >> damage;
	  if(damage == 0)continue;
	  if(target[0] == 'S')
	    {
	      Target[i] = 0;
	      MP[0].push_back(mp),Damage[0].push_back(damage);
	    }
	  else
	    {
	      Target[i] = 1;
	      MP[1].push_back(mp),Damage[1].push_back(damage);
	    }
	}

      rep(i,2)rep(j,MAX_Damage)dp[i][j] = inf;
      dp[0][0] = dp[1][0] = 0;

      rep(i,2)
	{
	  rep(j,MP[i].size())
	    {
	      rep(k,MAX_Damage)
		{
		  if(dp[i][k] == inf || k+Damage[i][j] >= MAX_Damage)continue;
		  dp[i][k+Damage[i][j]] = min(dp[i][k+Damage[i][j]],
					      dp[i][k] + MP[i][j]);
		}
	    }
	}

      rep(i,2)
	{
	  for(int j=MAX_Damage-2;j>=0;j--)
	    {
	      dp[i][j] = min(dp[i][j],dp[i][j+1]);
	    }
	}
      /*
      rep(i,11)
	{
	  cout << "dp["<<0<<"]["<<i<<"] = " <<dp[0][i] << endl;
	}
      */
      uint64_t ans = inf;
      rep(i,MAX_Damage)//All
	{
	  if(dp[1][i] == inf)continue;
	  uint64_t cnt = dp[1][i];
	  bool ok = true;
	  rep(j,N)//Single
	    {
	      if(HP[j]-i <= 0)continue;
	      if(dp[0][HP[j]-i] == inf)
		{
		  ok = false;
		  break;
		}
	      cnt += dp[0][HP[j]-i];
	    }
	  if(!ok)continue;
	  //cout << "cnt = " << cnt << " ans = "<< ans << endl;
	  ans = min(ans,cnt);
	}
      //cout << "1 : " << ans << endl;
      int mex = -inf;
      uint64_t cnt = 0;
      rep(i,N)//Single
	{
	  mex = max(mex,HP[i]);
	  cnt += dp[0][HP[i]];
	}
      ans = min(ans,cnt);
      //cout << "2 : " << ans << endl;
      ans = min(ans,dp[1][mex]);//All
      //cout << "3 : " << ans << endl;
      cout << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 16852
#define DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#else
#define bug(args...) 0
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    // cin >> T;
    auto inputAll = [&]()->void {
        
    };
    auto kase = [&]()->void {
        // cout << "Case " << cn << ": ";
        int a,b,c,K;
        cin>>a>>b>>c>>K;
        int cnt=0;
        while(b<=a)++cnt,b*=2;
        while(c<=b)++cnt,c*=2;
        cout<<(cnt<=K ? "Yes" : "No")<<'\n';
    };
    auto resetAll = [&]()->void {
        
    };
    while (cn++!=T) inputAll(), kase(), resetAll();
}


Measured memory_bytes: 3644
//実験３：アドバイスに基づいて再帰で組む
//グローバル変数の定義
var N = 0;
var W = 0;
var obj = [];
var dp = [];
//再帰処理
function RecursiveDp(i,j){

  //メモによる再処理防止
  if (dp[i][j] != 0) {        
    return dp[i][j];
  }

  var res = 0;
  if (i === N) { 
    //商品がもうないので0を代入する        
    res = 0;
  } else if (j < obj[i][0]) { 
    //容量不足なので入れない処理だけをする
    res = RecursiveDp(i+1, j);
  } else { 
    //入れると最大になるとは限らないので入れる時と入れない時の大きい方を取る
    res = Math.max(RecursiveDp(i+1, j), RecursiveDp(i+1,j-obj[i][0])+obj[i][1]);
  }
  dp[i][j] = res;
  return res;
}
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  N = Number.parseInt(inputStr[0]);
  W = Number.parseInt(inputStr[1]);
  //要素の溜め込み
  for(var i=0 ; i<N ; i++){
    inputStr = input[i+1].split(" ");
    obj.push(inputStr.map( inputStr => parseInt(inputStr)))
  }
  //DP用メモの作成
  for(var i=0 ; i<=N ; i++){
    dp.push(Array(W+1).fill(0));
  }
  //再帰しつつ結果を出力
  console.log(RecursiveDp(0,W));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 190412
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
//inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int const maxn = 100005;

int par[2 * maxn];

inline int get(const int v) {
    return par[v] == v? v : par[v] = get(par[v]);
}

inline void uni(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y)
        par[x] = y;
}

set<int> xs[2 * maxn];
set<int> ys[2 * maxn];

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    iota(begin(par), end(par), 0);


    int n;
    cin >> n;

    vector<pair<int,int>> a(n);
    for (auto& pa : a)
        cin >> pa.first >> pa.second;

    for (const auto& pa : a) {
        uni(pa.first, pa.second + maxn);
    }

    for (const auto& pa : a) {
        int idx = get(pa.first);

        xs[idx].insert(pa.first);
        ys[idx].insert(pa.second);
    }

    int64_t ans = 0;
    for (int i = 0; i < maxn * 2; ++i)
        ans += xs[i].size() * 1LL * ys[i].size();

    cout << ans - n << endl;

}


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

using namespace std;


void solve() {
    vector<int> cnt(26, 0);
    for (int i = 0; i < 4; i++) {
        char c; cin >> c;
        cnt[c-'A']++;
    }
    int x = 0;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] == 2) x++;
    }
    cout << ((x==2)?"Yes":"No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
mod = 10**9+7
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))

dp = [0] * (N + 1)
dp[:2] = 1, 1 if 1 not in a else 0

for i in range(2, N+1):
    # in listでは間に合わない
    if not i in a:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[-1])


Measured memory_bytes: 11884
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll a;ld b;cin>>a>>b;
    ll c=a*b;
    cout<<c<<"\n";
}

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

int main(){
  ios::sync_with_stdio(false);
  double x1, y1, x2, y2, dist;
  cin >> x1; cin >> y1; cin >> x2; cin >> y2;
  dist = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  printf("%1.5f\n" , dist);
  return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>
int main(void)
{
		int a,b,c,d,i;
		scanf("%d %d %d",&a,&b,&c);
		d=0;
		for(i=a;i<=b;i++){
			if(c%i==0){
				d++;
			}
		}
		printf("%d\n",d);
		return 0;
}


Measured memory_bytes: 2740
// {{{ include and macros
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#include <iostream>
// #include <stdio.h>
// #include <vector>
// #include <math.h>
// #include <algorithm>
// #include <string>
// #include <map>
// #include <set>
using namespace std;
// }}}

// {{{ put
void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
// }}}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(0>=b-a){
    put("delicious");
  }else if(x>=b-a){
    put("safe");
  }else{
    put("dangerous");
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  map<int, int> data;
  rep(i, n) {
    if (data.count(a.at(i))) {
      data.at(a.at(i))++;
    }
    else {
      data[a.at(i)] = 1;
    }
  }
  int datasize = data.size();
  vector<int> type(datasize);
  int counta = 0;
  for (pair<int, int> p : data) {
    int key = p.first;
    int value = p.second;
    type.at(counta) = value;
    counta++;
  }
  sort(type.begin(), type.end());
  int count = 0;
  int count_type = 0;
  while (k < datasize - count_type) {
    count += type.at(count_type);
    count_type++;
  }
  cout << count << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    VL a(n),b(n);
    LL asum = 0;
    LL bsum = 0;
    LL sub = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        asum += a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        bsum += b[i];
    }
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            sub += (b[i] - a[i]) / 2 + (b[i] - a[i]) % 2;
        }
    }
    if (sub > (bsum - asum)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
//情報オリンピック2011予選1「ランチ」
#include<stdio.h>
#include<limits.h>

int main(void)
{
	int p, min = INT_MAX, j, f1, sum = 0;
	//ピザの中で最小金額を求める
	for(f1 = 1; f1 <= 3; f1++){
		scanf("%d",&p);
		if(min > p)
			min = p;
	}
	
	sum += min;
	min = INT_MAX;
	//ジュースの中で最小金額を求める
	for(f1 = 1; f1 <= 2; f1++){
		scanf("%d",&j);
		if(min > j)
			min = j;
	}
	
	sum += min;
	sum -= 50;
	
	printf("%d\n",sum);
	
	return 0;
}
		

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int N, x;
    cin >> N >> x;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    sort(a, a + N);
    int ans = 0;

    // 少ない子から順に飴を配る
    // 最後の1人だけはまだ配らない
    for (int i = 0; i < N - 1; ++i) {
        if (x >= a[i]) {
            ++ans;
            x -= a[i];
        }
    }

    // 最後の1人にぴったり飴をあげられるか
    if (x == a[N - 1]) ++ans;

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


Measured memory_bytes: 256
N = int(input())

tree = [{'p': -1, 'c': list(), 'd': 0} for _ in range(N)]

for _ in range(N):
    l = list(map(int, input().split()))
    tree[l[0]]['c'] = l[2:]
    for i in l[2:]:
        tree[i]['p'] = l[0]


def calcDepth(tree, root, curDepth=0):
    tree[root]['d'] = curDepth
    [calcDepth(tree, c, curDepth + 1) for c in tree[root]['c']]


r = 0
for i, t in enumerate(tree):
    if t['p'] == -1:
        r = i
        break
calcDepth(tree, r)

for i in range(N):
    state = 'leaf'
    if tree[i]['p'] == -1:
        state = 'root'
    elif len(tree[i]['c']):
        state = 'internal node'
    print('node {i}: parent = {p}, depth = {d}, {state}, {ch}'.format(
        i=i, p=tree[i]['p'], d=tree[i]['d'], state=state, ch=tree[i]['c']
    ))

Measured memory_bytes: 56020
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    
    k=K%2
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    if k%2:t=(-1)*t
    print(t)
    #print(A,B,C)


#%%submit!
resolve()


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int a[100001], b[100001];
int main(){
	int i, n, k,ans;
	for (;~fscanf(stdin, "%d%d", &n, &k),n,k; P(d, ans)) {
		for(i=1;i<=k;i++)
			fscanf(stdin,"%d",a+i),b[i]=b[i-1]+a[i];
		for (ans = b[i]; i <= n; i++) {
			fscanf(stdin, "%d", a + i);
			b[i] = b[i - 1] + a[i] - a[i-k];
			if (ans < b[i]) ans = b[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] cnt = new int[N];
		Arrays.fill(cnt, 1);
		boolean[] red = new boolean[N];
		red[0] = true;
		
		for(int i=0; i<M; i++) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			red[y] |= red[x];
			cnt[x]--;
			cnt[y]++;
			if(cnt[x]==0)
				red[x] = false;
		}
		
		int ans = 0;
		for(int i=0; i<N; i++)
			if(red[i])
				ans++;
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 23476
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
B = LIST()

# 縦横独立に、全区間総和を取る
lsm = rsm = 0
for i in range(N):
    lsm += A[i] * (N-i-1)
    rsm += A[i] * i
    lsm %= MOD
    rsm %= MOD
h = rsm - lsm
lsm = rsm = 0
for i in range(M):
    lsm += B[i] * (M-i-1)
    rsm += B[i] * i
    lsm %= MOD
    rsm %= MOD
w = rsm - lsm

ans = h * w % MOD
print(ans)


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

int main(){
  string t;
  cin>>t;
  int n=t.size();
  rep(i,n){
    if(t[i]!='?') cout<<t[i];
    else cout<<'D';
  }
  cout<<endl;
}  

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

int V, E;
struct egde{int from, to; ll cost;};
egde es[5001]; ll d[5001];

void longest_path(int s){
  rep(i, V+1) d[i] = -INF;
  d[s] = 0;
  int j = 0;
  bool g = false;
  while(true){
    bool update = false;
    rep(i,E){
      egde e = es[i];
      if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
        if(j > 2*V && e.to == V) g = true;
      }
    }
    if(!update) break;
    if(j == 5*V){
        if(g) d[V] = INF;
        break;
    }
    j++;
  }
}

int main(){
    ll p;
    cin >> V >> E >> p;
    rep(i,E){
        int a, b; ll c;
        cin >> a >> b >> c;
        es[i] = {a, b, c-p};
    }
    longest_path(1);
    ll x = 0;
    if(d[V] == INF) cout << "-1" <<  endl;
    else cout << max(x,d[V]) << endl;
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<std::tuple<std::string, int64_t, int64_t>> d(n);

  for (int64_t i = 0; i < n; i++) {
    std::string s;
    int64_t j;
    std::cin >> s >> j;
    d[i] = std::make_tuple(s, -j, i + 1);
  }

  std::sort(d.begin(), d.end());

  for (const auto &i : d) {
    std::cout << std::get<2>(i) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    int N, L; cin >> N >> L;
    int ans = 0;
    int minx = 100000000;
    int suma = 0;
    FOR(i,1,N+1) suma += L+i-1;
    for(int i = 1; i <= N; i++) {
        int sum = 0;
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            sum += L + j - 1;
        }
        if(std::abs(sum-suma) < minx) {
            ans = sum;
            minx = std::abs(sum-suma);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    char s[6];
	char s1[]="Sunny";
	char s2[]="Cloudy";
	char s3[]="Rainy";
	int a,b,c;
	gets(s);
	a=strcmp(s,s1);
	if(a==0){
		printf("%s\n",s2);
		}
    b=strcmp(s, s2);
    if(b==0){
        printf("%s\n",s3);
    }
    c=strcmp(s, s3);
    if(c==0){
        printf("%s\n",s1);
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			String strLine = insBR.readLine();
			char[] chLine = strLine.toCharArray();
			boolean blBig = false;
			for(int i = 0; i < chLine.length; i++){
				blBig = Character.isUpperCase(chLine[i]);
				if(blBig == false){
					chLine[i] = Character.toUpperCase(chLine[i]);
				}else{
					chLine[i] = Character.toLowerCase(chLine[i]);
				}
				System.out.print(chLine[i]);
			}
			System.out.println();
		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  vector<int> vec(5);
  vec = { a, b, c, d, e };
  
  for( int i = 0; i < 5; i++ ){
    for( int j = i+1; j < 5; j++ ){
      if( vec.at(j) - vec.at(i) > k ){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll n,m;

bool check(ll x, VLL& a){
  ll cnt = 0;
  rep(i, n) {
    auto itr = lower_bound(all(a), x - a[i]);
    if (itr == a.end()) continue;
    cnt += n - (itr - a.begin());
  }
  return cnt >= m;
}

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

  cin >> n >> m;
  VLL a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  VLL sum = a;
  rep(i, n - 1) sum[i + 1] += sum[i];

  ll ok = 0;
  ll ng = 200001;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid, a)) {
      ok = mid;
    }else{
      ng = mid;
    }
  }

  ll ans = 0;
  ll cnt = 0;

  rep(i, n) {
    auto itr = lower_bound(all(a), ok - a[i]);
    if (itr == a.end()) continue;
    ll idx = itr - a.begin();
    cnt += n - idx;
    if (idx != 0)
      ans += a[i]*(n-idx) + sum[n - 1] - sum[idx - 1];
    else
      ans += a[i] * (n - idx) + sum[n - 1];
  }

  if (cnt > m) ans -= ok * (cnt - m);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] ar = new int[N][26];
        String[] Sa  = new String[N];
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            for (char c : S.toCharArray()) {
                ar[i][c-'a']++;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < N; j++) {
                min = Math.min(min, ar[j][i]);
            }
            for (int j = 0; j < min; j++) {
                sb.append((char) (i + 'a'));
            }
        }
        System.out.println(sb);
    }

}

Measured memory_bytes: 35716
#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;

let S = read string;;
let N = S.Length;;

let mutable i = 0;;

while i < N do
  let j = i in
  while i < N && S.[i] = 'R' do i <- i + 1 done;
  let k = i in
  while i < N && S.[i] = 'L' do i <- i + 1 done;
  for l in j..k-2 do
    printf "%d " 0
  done;
  let a = k - j in
  let b = i - k in
  printf "%d " ((a + 1) / 2 + b / 2);
  printf "%d " (a / 2 + (b + 1) / 2);
  for l in k+1..i-1 do
    printf "%d " 0
  done;
done;;

printfn "";;

reader.Close();;
writer.Close();;

Measured memory_bytes: 19284
#include <iostream>

using namespace std;

int main()
{
	int N, M, X, A[101] = {0},ans = 0;

	cin >> N >> M >> X;

	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		A[a] = 1;
	}

	for (int i = X; i >= 0; i--) {
		if (A[i])ans++;
	}

	int b = 0;
	for (int i = X; i <= N; i++) {
		if (A[i])b++;
	}

	if (ans > b)cout << b << endl;
	else cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s,ds;
int main(int argc, char const *argv[]){
    int len,l,i;
    while(getline(cin,s)){
        cin>>l;
        ds="";
        len=s.length();
        for(i=0;i<len;++i){
            if(i%l==0){
                ds+=s[i];
            }
        }
        cout<<ds<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 210, M_MAX = N_MAX*(N_MAX-1)/2, R_MAX = 8;
const int INF = 1e8;
int V,E,R;
int G[N_MAX][N_MAX];

void warshall_floyd(){
  rep(w,V)rep(v,V)repp(u,v+1,V) 
    G[v][u] = G[u][v] = min(G[v][u],G[v][w] + G[w][u]);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> R;
  vector<int> r(R);
  rep(i,R){
    cin >> r[i]; --r[i];
  }

  rep(v,V)rep(u,V) G[v][u] = (v==u) ? 0:INF;

  rep(i,E){
    int f,t,c; cin >> f >> t >> c; --f;--t;
    G[f][t] = G[t][f] = c; 
  }

  warshall_floyd();

  ll res = INF;
  sort(all(r));
  do{
    ll route = 0;
    rep(i,R-1) route += G[r[i]][r[i+1]];
    res = min(res,route);
  }while(next_permutation(all(r)));

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


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

signed main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      if(i*j<N)ans+=1;
      else break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define INF (2LL << 60)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<long long, int> iP;
typedef pair<long long, long long> llP;

int N, M, C;

struct edge {
  int to, cost;
};

bool used[100001];
long long sum[100001], Esum;
llP minDis[100001];
vector< vector<edge> > graph(100001);

void Dijkstra() {

  priority_queue<iP, vector<iP>, greater<iP> > que;
  que.push(iP(0, 1)); minDis[0] = llP(0, 0), minDis[1] = llP(0, 1);
  while(!que.empty()) {
    int now = que.top().sc;
    long long cost = que.top().fr; que.pop();
    for(int i = 0; i < graph[now].size(); i++) {
      edge &e = graph[now][i];
      if(e.cost + cost < minDis[e.to].fr) {
        que.push(iP(e.cost + cost, e.to));
        minDis[e.to] = llP(e.cost + cost, e.to);
      }
    }
  }
}

int main(){
  
  cin >> N >> M >> C;
  for(int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
    Esum += c;
  }
 
  fill_n(minDis, 100001, llP(INF, -1));
  Dijkstra();
  sort(minDis, minDis + N + 1);

  long long ans = INF, d = 0;
  for(int i = 1; i <= N; i++) {
    for(int j = 0; j < graph[minDis[i].sc].size(); j++) {
      if(used[graph[minDis[i].sc][j].to]) d += graph[minDis[i].sc][j].cost;
    }
    used[minDis[i].sc] = true;
    ans = min(ans, minDis[i].fr * C + Esum - d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12192
"use strict";
function main(input) {
  let n = input[0];

  let a = n.trim().split("");

  let judge = false; 
  for(let b of a){
    if(b === "7"){
      judge = true;
      break;
    }
  }

  console.log(judge?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 29612
#define rep(i,n) for (int i=0;i<(n);i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
	int n,cnt=0;
	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a[i];
	rep(i, n)
		if (i == a[a[i]-1]-1 )
			cnt++;
	cout << cnt/2;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000000;
using namespace std;
vector<pair<long long,long long>>juice;
int gcd(int a,int b){
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
long long stair[100009];
long long memo = 1;
long long DP(long long a) {
	stair[0] = memo;
	stair[1] = memo;
	if (a <= 1) {
		return memo;
	}
	else {
		return stair[a] = DP(a - 1) + DP(a - 2);
	}
}
int gram[1009];
int main() {
	int a = 0;
	cin >> a;
	int b = 0;
	for (int i = 0; i < a; i++) {
		cin >> gram[i];
		b += gram[i];
	}
	int  c = 0,counto=1000000;
	for (int i = 0; i < a - 1; i++) {
		for (int j = 0; j <= i; j++) {
			c += gram[j];
		}
		//cout << b << endl;
		counto = min(counto, abs(b - (c*2)));
		c = 0;
		//cout << counto<<endl;
	}
	cout << counto << endl;
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

const int mxN = 5e5 + 100;
const int MOD = 1e9 + 7;
int factorials[mxN];

int add(int x, int y) {
    x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}

int mult(int x, int y) {
    return (1LL * x * y) % MOD;
}

int binpow(int x, int y) {
	int z = 1;
	while(y > 0) {
		if(y % 2 == 1)
			z = mult(z, x);
		x = mult(x, x);
		y /= 2;
	}
	return z;
}

int inv(int x) {
	return binpow(x, MOD - 2);
}

int divide(int x, int y) {
	return mult(x, inv(y));
}

void precalcFactorials() {
    factorials[0] = 1;
    for (int i = 1; i < mxN; i++) {
        factorials[i] = mult(factorials[i - 1], i); 
    }
}


int choose(int n, int k) {
	return mult(factorials[n], inv(mult(factorials[k], factorials[n - k])));
}


void solve() {
	int n, m;
	cin >> n >> m;

	
	precalcFactorials();

	// C(m, n) - number of ways to choose n integers to appear in A
	// n! ways to arrange those integers 
	// C(m, n) * n!
	// we need to count (#0) - (#1) + (#2) - (#3)...
	// C(n, j) - choose j elements which are equal
	// we don't care abour remaining positions so C(m-j, n-j)
	// (n - j)! number of ways to arrange them
	int res = 0;
	int sign = 1;

	for (int i = 0; i <= n; i++) {
		int a_ways = mult(choose(m, n), factorials[n]);
		int b_ways = mult(choose(n, i), mult(choose(m - i, n - i), factorials[n - i]));
		res = add(res, sign * mult(a_ways, b_ways));
		sign *= -1;
	}

	cout << res << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 5604
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    unsigned long long power = 1;
    for (int i = 1; i <= N; i++) {
        power *= i;
        power %= 1000000007;
    }

    cout << power << endl;
    return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)	cout<<"bust";
	else
		cout<<"win";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int a[12];
	map<int, int> m;
	REP(i, 12){
		cin >> a[i];
		m[a[i]]++;
	}
	REP(i, 12){
		if(m[a[i]] % 4){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;

}

Measured memory_bytes: 3156
#include<stdio.h>

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

Measured memory_bytes: 1736
#include<set>
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include <utility>
#include<algorithm>

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    fast;



    long long a,b,c,d,e,f,target,i,j;
    long long sum=0;
    cin >> a >> target;

    map<long long,long long>mp;
    vector<long long>vec;
    while(a--)
    {
        cin >> b;
        vec.push_back(b);




    }
    vector<pair<long long,long long>>vec2;
    for(i=1;i<vec.size();i++)
    {
        vec2.push_back({vec[i]+vec[i-1],i});
    }
    sort(vec2.begin(),vec2.end());
    reverse(vec2.begin(),vec2.end());
    e=vec2[0].first;
    f=vec2[0].second;
    if(e>=target)
    {
        //cout << "f  ==  " << f << endl;
        cout << "Possible" << endl;
        for(i=1;i<f;i++)
            cout << i << endl;
        for(i=vec.size()-1;i>=f+1;i--)
        {
            cout << i << endl;
        }
        cout << f << endl;

    }
    else{
        cout << "Impossible" << endl;
    }









}

Measured memory_bytes: 6096
'''A - Airplane
https://atcoder.jp/contests/abc129/tasks/abc129_a

>>> main(1, 3, 4)
4
>>> main(3, 2, 3)
5

in5.txt
>>> main(99, 62, 92)
154'''

from itertools import permutations


def main(p, q, r):
    _max = 999

    for p in permutations([p, q, r], 2):
        if _max > sum(p):
            _max = sum(p)

    print(_max)


if __name__ == '__main__':
    p, q, r = map(int, input().split(' '))
    main(p, q, r)


Measured memory_bytes: 3060