akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, std::vector<long long> D){
  vector<ll> v;
  vector<ll> x;
  for(ll i=0; i<10; i++) {
    auto res = find(D.begin(), D.end(), i);
    if(res == D.end())
      v.push_back(i);
  }
  for(ll i=0; i<v.size(); i++) {
    x.push_back(v[i]);
  }
  for(ll i=0; i<v.size(); i++) {
    for(ll j=0; j<v.size(); j++) {
      x.push_back(v[j]*10+v[i]);
    }
  }
  for(ll i=0; i<v.size(); i++) {
    for(ll j=0; j<v.size(); j++) {
      for(ll k=0; k<v.size(); k++) {
	x.push_back(v[k]*100+v[j]*10+v[i]);
      }
    }
  }
  for(ll i=0; i<v.size(); i++) {
    for(ll j=0; j<v.size(); j++) {
      for(ll k=0; k<v.size(); k++) {
	for(ll l=0; l<v.size(); l++) {
	  x.push_back(v[l]*1000+v[k]*100+v[j]*10+v[i]);
	}
      }
    }
  }
  for(ll i=0; i<v.size(); i++) {
    for(ll j=0; j<v.size(); j++) {
      for(ll k=0; k<v.size(); k++) {
	for(ll l=0; l<v.size(); l++) {
	  for(ll m=0; m<v.size(); m++) {
	    x.push_back(v[m]*10000+v[l]*1000+v[k]*100+v[j]*10+v[i]);
	  }
	}
      }
    }
  }
  sort(x.begin(), x.end());
  ll n = N;
  while(n!=0) {
    ll y = n % 10;
    n = n / 10;

    if(find(D.begin(), D.end(), y) != D.end()) {
      auto it = lower_bound(x.begin(), x.end(), N);
      std::cout << *it << std::endl;
      return;
    }
  }
  std::cout << N << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <vector>

#include <math.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

ll calc_dist_two(const int D, vector<ll> a, vector<ll> b) {
    ll res = 0;
    for (int i = 0; i < D; i++) {
        res += (a[i] - b[i]) * (a[i] - b[i]);
    }
    return res;
}

int main(void) {
    int N, D;
    cin >> N >> D;

    vector<vector<ll> > points(N, vector<ll>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> points[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ll dist = calc_dist_two(D, points[i], points[j]);
            // cout << dist << endl;
            ll sq = (ll) sqrt(dist);
            if (sq * sq == dist) {
                count++;
            }
        }
    }

    cout << count << endl;
    
    return 0;
}


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

using namespace std;


void solve() {
    int N; cin >> N;

    vector<long long> edge(N);

    for (int i = 0; i < N-1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        if (u > v) swap(u, v);
        edge[u] += N - v;
    }

    vector<long long> node_sum(N+1);
    vector<long long> edge_sum(N+1);

    long long ans = 0;

    for (int i = N-1; i >= 0; i--) {
        node_sum[i] = node_sum[i+1] + N - i;
        edge_sum[i] += edge_sum[i+1] + edge[i];

        //cout << node_sum[i] << " " << edge_sum[i] << endl;

        ans += node_sum[i] - edge_sum[i];
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	if (N <= 999) cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}

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

namespace Atcoder
{

    class Program
    {
        static void Main(string[] args)
        {
            {
                var split = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int ans = 0;
                for (int i = 0; i < split[0]; i++)
                {
                    var read = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    if (read[0] >= split[1] && read[1] >= split[2]) ans++;
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

    char table[25][25];
    ll vis[25][25], dep[25][25];
    ll n, m;
    ll X[4] = {0, 0, -1, 1};
    ll Y[4] = {1, -1, 0, 0};

    bool check(ll x, ll y){
        if(x < 0 || x >= n || y < 0 || y >= m || vis[x][y] == 1 || table[x][y] == '#') return false;
        return true;
    }

    ll bfs(ll i, ll j, ll ii, ll jj){
        queue<pii> q;
        q.push({i, j});
        memset(vis, 0, sizeof(vis));
        memset(dep, 0, sizeof(dep));
        ll mx1 = 0;
        while(!q.empty()){
            ll x = q.front().ft, y = q.front().sd; q.pop();
            if(vis[x][y]) continue;
            vis[x][y] = 1;
            if(x == ii && y == jj){
                return dep[ii][jj];
            }
            for(ll l = 0; l < 4; l++){
                ll xx = x + X[l], yy = y + Y[l];
                if(check(xx, yy)){
                    dep[xx][yy] = dep[x][y] + 1;
                    q.push({xx, yy});
                }
            }
        }
        return mx1;
    }

void solve(){

    cin >> n >> m;

    memset(vis, 0, sizeof(vis));

    for(ll i =0; i < n; i++){
        for(ll j = 0; j < m; j++){
            char x; cin >> x; table[i][j] = x;
        }
    }

    ll ans = 0;
    for(ll i =0; i < n; i++){
        for(ll j = 0; j < m; j++){
            for(ll ii = 0; ii < n; ii++){
                for(ll jj = 0; jj < m; jj++){
                    if(table[i][j] != '#' && table[ii][jj] != '#'){
                        ans = max(ans, bfs(i, j, ii, jj));
                        //cout << i << " " << j << " " << ii << " " << jj << " "
                        //<< bfs(i, j, ii, jj) << "\n";
                    }
                }
            }
        }
    }cout << ans ;

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
n, w = map(int, input().split())
W, V = [], []
for i in range(n):
    wi, vi = map(int, input().split())
    W.append(wi)
    V.append(vi)
    
# Dp[i][sum_w] := i-1 番目までの品物から重さがsum_wを超えないように選んだときの、価値の総和の最大値
Dp = [[0] * (w + 1) for _ in range(n+1)]

for i in range(n):
    for sum_w in range(w+1):
        # i番目の商品を選ぶ場合
        if sum_w - W[i] >= 0:
            Dp[i+1][sum_w] = max(Dp[i+1][sum_w], Dp[i][sum_w - W[i]] + V[i])
        # i番目の商品を選ばない場合
        Dp[i+1][sum_w] = max(Dp[i+1][sum_w], Dp[i][sum_w])
print(Dp[-1][-1])

Measured memory_bytes: 120684
S = input()[::-1]

DREAM = 'dream'[::-1]
DREAMER = 'dreamer'[::-1]
ERASE = 'erase'[::-1]
ERASER = 'eraser'[::-1]

keywords = (DREAM, DREAMER, ERASE, ERASER)

while len(S) > 0:
    for keyword in keywords:
        if S.startswith(keyword):
            S = S[len(keyword):]
            break
    else:
        break

if len(S) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
enum class Usage_type :bool{
	Swing, Throw
};
class Knife_damage {
	int _damage;
	Usage_type _type;
public:
	Knife_damage() :_damage{ 0 }, _type{ Usage_type::Swing } {}
	Knife_damage(int n, Usage_type ut) :_damage{ n }, _type{ ut } {}
	int damage() const { return _damage; }
	Usage_type type() const { return _type; }
};
int main() {
	int n, h;
	std::cin >> n >> h;
	std::vector<Knife_damage> knifes(2 * n);
	{
		int arg;
		for (auto i = 0; i < n; ++i) {
			std::cin >> arg;
			knifes[i * 2] = Knife_damage(arg, Usage_type::Swing);
			std::cin >> arg;
			knifes[i * 2 + 1] = Knife_damage(arg, Usage_type::Throw);
		}
	}
	std::sort(knifes.begin(), knifes.end(), [](Knife_damage a, Knife_damage b) {return (a.damage() > b.damage()); });
	int i = 0;
	for (; h > 0 && knifes[i].type() == Usage_type::Throw; ++i) {
		h -= knifes[i].damage();
	}
	if (h > 0) std::cout << i + (h + knifes[i].damage() - 1) / knifes[i].damage();
	else std::cout << i << std::endl;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  char s[11];
  scanf("%s",s);
  int len = strlen(s);

  /*小文字判定*/
  for(int i = 0; i < len; ++i){
    if(s[i] != 'A' && s[i] != 'C'){
      if(s[i] - 'a' < 0){
        printf("WA");
        return 0;
      }
    }
  }

  /*C文字判定*/
  int C_judge = 0;
  for(int i = 2; i < len-1; ++i){
    if(C_judge == 1 && s[i] =='C'){
      printf("WA");
      return 0;
    }
    if(s[i] == 'C') C_judge = 1;
  }

  if(s[0] == 'A' && C_judge == 1){
    printf("AC");
  }else{
    printf("WA");
  }

  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , k ;
	cin >> n >> k ;
	if(k > ((n - 1)*(n - 2))/2){
		cout << -1 ;
		return 0 ;
	}
	int arr[n + 1] = {0}, i = 1;
	while(k != 0){
		arr[i] = min(k + i , n - 1) ;
		k -= min(k , n - i - 1) ;
		i++ ;
	}	
	vector < pair < int , int >> p ;
	for(int i = 1 ; i <= n ; i++){
		for(int j = i + 1 ; j <= n ; j++){
			if(j > arr[i]) p.pb(mp(i , j)) ;
		}
	}
	cout << p.size() << '\n' ;
	for(int i = 0 ; i < p.size() ; i++) cout << p[i].first << " " << p[i].second << '\n' ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  sr--; sc--;
  string s, t;
  cin >> s >> t;

  ll idx_l = 0, idx_r = w-1;
  for (ll i = n-1; i >= 0; i--) {
    if (t[i] == 'R') idx_l = max(idx_l-1, 0LL);
    if (t[i] == 'L') idx_r = min(idx_r+1, w-1);
    if (s[i] == 'R') idx_r--;
    if (s[i] == 'L') idx_l++;
//    cerr << idx_l << " " << idx_r << endl;
    if (idx_l > idx_r || idx_l < 0 || idx_r >= w) {
      puts("NO");
      return 0;
    }
  }
  if (sc < idx_l || idx_r < sc) {
    puts("NO");
    return 0;
  }

  ll idx_u = 0, idx_d = h-1;
  for (ll i = n-1; i >= 0; i--) {
    if (t[i] == 'D') idx_u = max(idx_u-1, 0LL);
    if (t[i] == 'U') idx_d = min(idx_d+1, h-1);
    if (s[i] == 'D') idx_d--;
    if (s[i] == 'U') idx_u++;
//    cerr << idx_u << " " << idx_d << endl;
    if (idx_u > idx_d || idx_u < 0 || idx_d >= h) {
      puts("NO");
      return 0;
    }
  }
  if (sr < idx_u || idx_d < sr) {
    puts("NO");
    return 0;
  }

  puts("YES");
  return 0;
}


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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
typedef pair<int,int> pii;
#define F first
#define S second
typedef vector<int> vint;
const int INF=INT_MAX/2;
int main(){
	int D,n;
	cin>>D>>n;
	vint temp(D);
	rep(i,D) cin>>temp[i];
	vector<pair<pii,int>> v(n);
	rep(i,n) cin>>v[i].F.F>>v[i].F.S>>v[i].S;
	vector<vector<int>> dp(D,vector<int>(n,0));
	rep(i,D){
		if(!i){
			rep(j,n){
				if(v[j].F.F<=temp[i]&&temp[i]<=v[j].F.S){
					dp[i][j]=0;
				}
				else{
					dp[i][j]=-INF;
				}
			}
			continue;
		}
		rep(j,n){
			if(v[j].F.F<=temp[i]&&temp[i]<=v[j].F.S){
				rep(k,n){
					dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(v[k].S-v[j].S));
				}
			}
		}
	}
	int ans=0;
	rep(i,n){
		ans=max(ans,dp[D-1][i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1344
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 5 + 10)





def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    aaa = max(data)


    if data.count(aaa) >= 2:
        for i in range(num):
            print(aaa)
    else:
        bbb = 0
        for j in range(num):
            if data[j] == aaa:
                continue
            bbb = max(data[j], bbb)

        for i in range(num):
            if data[i] == aaa:
                print(bbb)
            else:
                print(aaa)





if __name__ == '__main__':
    main()

Measured memory_bytes: 68824
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = LS()
    print(s[0][0]+s[1][0]+s[2][0])
    return

#B
def B():
    a, b, x = LI()
    print(b // x - (a - 1) // x)
    
    return

#C
def C():
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38512
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    long long a,b,x,y,z,n=0;
    cin>>a;
    cin>>b;
    cin>>x;
    if(a==0)
    {
        y=(a)/x;
        z=(b)/x;
        n=z-y;
        n++;
    }
    else{
        y=(a-1)/x;
    z=(b)/x;
    n=z-y;}
    cout<<n;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

const ll inf=1e11;

ll left_most(ll x, vector<ll>& s, int A) {
  int ok=0;
  int ng=A-1;
  while(ng-ok>1) {
    int m=(ok+ng)/2;
    if(s[m]<=x)
      ok=m;
    else
      ng=m;
  }
  return s[ok];
}

ll right_most(ll x, vector<ll>& s, int A) {
  int ok=A-1;
  int ng=0;
  while(ok-ng>1) {
    int m=(ok+ng)/2;
    if(s[m]>=x)
      ok=m;
    else
      ng=m;
  }
  return s[ok];
}

ll min_d(ll x, ll a, ll b) {
  ll ta=a;
  ll tb=b;
  a=min(ta,tb);
  b=max(ta,tb);
  if(x<=a) {
    return b-x;
  }
  if(a<=x&&x<=b) {
    return min(x-a+b-a,b-x+b-a);
  }
  if(b<=x) {
    return x-a;
  }
}

ll solve(ll x, vector<ll>& s, vector<ll>& t, int A, int B) {
  vector<ll> s_cands;
  s_cands.push_back(left_most(x,s,A));
  s_cands.push_back(right_most(x,s,A));
  vector<ll> t_cands;
  t_cands.push_back(left_most(x,t,B));
  t_cands.push_back(right_most(x,t,B));
  vector<ll> cs;
  for(auto& s_c : s_cands) {
    for(auto& t_c : t_cands) {
      cs.push_back(min_d(x,s_c,t_c));
    }
  }
  //
  sort(cs.begin(),cs.end());
  return cs[0];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> s(A+1);
  s[0]=-inf;
  vector<ll> t(B+1);
  rep(i,A)cin>>s[i+1];
  s.push_back(inf);
  t[0]=-inf;
  rep(i,B)cin>>t[i+1];
  t.push_back(inf);
  vector<ll> ans;
  rep(i,Q) {
    ll x;
    cin>>x;
    ans.push_back(solve(x,s,t,A+2,B+2));
  }
  rep(i,Q){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 4704
def answer(x):
  print(x)
  exit()

N=int(input())
A=list(map(int,input().split()))
if len(set(A))>=3:
  answer('No')
if len(set(A))==1:
  if N//2>=A[0] or A[0]==N-1:
    answer('Yes')
  else:
    answer('No')
A.sort()
if A[0]+1<A[-1]:
  answer('No')
X=1
for i in range(N-1):
  if A[i]==A[i+1]:
    X+=1
  else:
    break
if X==N-1:
  answer('No')
if X+1<=A[-1]<=X+(N-X)//2:
  answer('Yes')
else:
  answer('No')


Measured memory_bytes: 97636
#!/usr/bin/env python3
import sys
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
from collections import defaultdict          # subclass of dict. defaultdict(facroty)
from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
from heapq import heapify, heappush, heappop # heapify(L) changes list in-place in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(nlgk)=O(n).
from itertools import accumulate             # accumulate(iter[, f])
from functools import reduce                 # reduce(f, iter[, init])
from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
from fractions import gcd                    # for Python3.4.3


def main():
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    def count_divide_two(num, memo=0):
        if num % 2 == 1:
            return memo
        else:
            return count_divide_two(num//2, memo+1)
    
    _ = ii()
    a = lmi()
    ans = 0
    for elm in a:
        ans += count_divide_two(elm)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 6468
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;
 
// ??¶??\???????????°????????????
#define MAX_N 10000 + 16
int parent[MAX_N];
int height[MAX_N];
 
void init(const int& n)
{
	for (int i = 0; i < n; ++i)
	{
		parent[i] = i;
		height[i] = 0;
	}
}
 
int find(const int& x)
{
	if (parent[x] == x)
	{
		return x;
	}
	else
	{
		return parent[x] = find(parent[x]);
	}
}
 
void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}
 
	if (height[x] < height[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (height[x] == height[y])
		{
			++height[x];
		}
	}
}
 
bool same(const int& x, const int& y)
{
	return find(x) == find(y);
}
// End Of ??¶??\???
 
#define MAX_E MAX_N * MAX_N / 2 + 1
struct edge
{
	int u, v;
	double cost;
	edge(int u = 0, int v = 0, double cost = 0) : u(u), v(v), cost(cost) {}
	bool operator < (const edge & e2) const
	{
		return cost > e2.cost;
	}
};
 
edge es[MAX_E];
int V, E;
double kruskal()
{
	sort(es, es + E);    // ?????§??????????°???°??§??????
	init(V);
	double res = 0;
	for (int i = 0; i < E; ++i)
	{
		edge e = es[i];
		if (!same(e.u, e.v))
		{
			unite(e.u, e.v);
		}
		else
		{
			res += e.cost;
		}
	}
 
	return res;
}
 
pair<int, int> pile[MAX_N];
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	cin >> V >> E;
	
	for (int i = 0; i < V; ++i)
	{
		cin >> pile[i].first >> pile[i].second;
	}
 
	for (int i = 0; i < E; ++i)
	{
		cin >> es[i].u >> es[i].v;
		--es[i].u; --es[i].v;
		int dx = pile[es[i].u].first - pile[es[i].v].first;
		int dy = pile[es[i].u].second - pile[es[i].v].second;
		es[i].cost = sqrt(dx * dx + dy * dy);
	}
 
	cout.setf(ios::showpoint);
	cout.precision(3);
	cout.setf(ios::fixed);
	cout << kruskal() << endl;
	return 0;
}

Measured memory_bytes: 6068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,res=1,minus=1,minus2=1;
	cin>>n;
	ll mod = 1e9+7;
	for(int i=0;i<n;i++)
	{	
		res=(res*10)%mod;
		minus=(minus*9)%mod;
		minus2=(minus2*8)%mod;
	}
	res = (res - 2*minus + minus2)%mod;
	if(res<0)
		res += mod;
	cout<<res<<"\n";


	
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var (
	dp    [3001][3001][4]int
	goods [3000][3000]int
)

func main() {
	defer flush()

	R := readInt()
	C := readInt()
	K := readInt()
	for i := 0; i < K; i++ {
		r := readInt() - 1
		c := readInt() - 1
		v := readInt()
		goods[r][c] = v
	}

	for i := 0; i < R; i++ {
		for j := 0; j < C; j++ {
			for k := 2; k >= 0; k-- {
				dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k]+goods[i][j])
			}
			for k := 0; k < 4; k++ {
				dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
			}
		}
	}

	result := -1
	for k := 0; k < 4; k++ {
		result = max(result, dp[R-1][C-1][k])
	}

	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 357612
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long a = input.nextInt();
		long b = input.nextInt();
		long c = input.nextInt();
		long d = input.nextInt();
		System.out.println(Math.min(a, b)*c + Math.max(a-b,0) * d);
	
	
	}
				
}

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

int main(){
  double A, B;
  int iAVE;
  double AVE;
  cin >> A >> B;

  AVE=(A+B)/2;
//  cout << AVE << endl;
  iAVE = ceil(AVE);
  cout << iAVE << endl;

}

Measured memory_bytes: 256
S = input()[::-1]
N = len(S)
ans = 0
i = 0
cb = 0
ans = 0
while i < N:
    if S[i:i + 2] == 'CB':
        i += 2
        cb += 1
    elif S[i] == 'A':
        i += 1
        ans += cb
    else:
        i += 1
        cb = 0
print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))




int main(){
	ll m,d;
	cin >> m >> d;
	ll ans = 0;
	FOR(i,1,m+1){
		FOR(j,1,d+1){

			ll d1 = j%10;
			ll d2 = j/10;
			if(d1<2||d2<2)continue;
			if(d1*d2==i)ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
  u, v, w = map(int, input().split())
  T[u - 1].append([v - 1, w])
  T[v - 1].append([u - 1, w])
D = [-1] * N
D[0] = 0
Q = [0]
while Q:
  q = Q.pop()
  for adj, w in T[q]:
    if D[adj] < 0:
      D[adj] = D[q] + w
      Q.append(adj)
for d in D:
  print(d % 2)

Measured memory_bytes: 48976
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
int main()
{
	int A, B, H, M;
	scanf("%d%d%d%d", &A, &B, &H, &M);
	double t1 = (double)H / 12 + (double)M / (12 * 60), t2 = (double)M / 60;
	double delta = fabs(t1 - t2);
	double ans = (double)B * B + (double)A * A - 2.0 * B * A * cos(delta * 2 * acos(-1));
	printf("%.20lf\n", sqrt(ans));
	return 0;
}

Measured memory_bytes: 4292
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    cout << x * x;
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
int p[1000005];
int main() {
  int x;
  cin >> x;
  for (int i = 2; i <= 1000000; i++) {
    if (!p[i]) {
      if (i >= x) {
        cout << i << endl;
        return 0;
      }
      for (int j = i + i; j <= 1000000; j += i)
        p[j] = 1;
    }
  }
}

Measured memory_bytes: 4096
//TYPE
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;
#define cls(x) memset(x,0,sizeof(x))


const int INF = 0x3f3f3f3f;
const int SZ = 100;

int main() {
  ll n;
  vector<ll> a(5);
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  ll small = min({a[0], a[1], a[2],a[3],a[4]});
  cout << n / small + 4 + (n % small == 0 ? 0 : 1) << endl;
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> A(n);
    int zemax = 0;
    int idx = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (abs(zemax) < abs(A[i])) zemax = A[i], idx = i;
    }

    cout << 2 * n - 1 << endl;

    for (int i = 0; i < n; i++) {
        cout << idx + 1 << " " << i + 1 << endl;
    }

    if (zemax < 0) {
        for (int i = n; i > 1; --i) {
            cout << i << " " << i - 1 << endl;
        }
    } else {
        for (int i = 1; i < n; i++) {
            cout << i << " " << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n=0,x=0,count=0,i,j,k;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0&&x==0) break;
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if((i+j+k)==x){
						count++;
					}
				}
			}
		}
		printf("%d\n",count);
		count=0;	//syokika ga hituyo
	}
	return 0;
}

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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define ld long double
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define len(a) a.length()
#define all(v) (v).begin(), (v).end()
#define tr(c) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define maxv(a) *max_element(all(a))
#define minv(a) *min_element(all(a))
#define pb push_back
#define ins insert
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a)         \
    fo(sz(a)) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pll> vpl;
typedef set<ll> sl;
typedef set<char> sc;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;
const ll N = 1e9 + 7;

void solve()
{
    ll k, a, b;
    cin >> k >> a >> b;

    for(ll i = a; i < b + 1; i++)
    {
        if(i % k == 0)
        {
            cout << "OK"; 
            return; 
        }
    }
    cout << "NG" << endl; 
}

int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
    //cin >> t;
    t=1;
    while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


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

string S,T;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>S>>T;
	int ans = T.size();
	for(int i = 0;i <= S.size() - T.size();i++){
		int diff = 0;
		for(int j = 0;j < T.size();j++){
			if(T[j] != S[i + j]){
				diff++;
			}
		}
		ans = min(ans,diff);
	}
	cout<<ans<<endl;
}


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

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

  string s;
  cin >> s;
  ll ans = 0;
  for (int tmp = 0; tmp < (1 << s.size()-1); tmp++)
  {
    bitset<10> bs(tmp);
    ll tmp_num = 0;
    for (int i = 0; i < s.size(); i++)
    {
      int num = s.at(i) - '0';
      if(i == s.size()-1)
      {
        ans += tmp_num*10 + num;
        break;
      }
      if(bs.test(i))
      {
        ans += tmp_num*10 + num;
        tmp_num = 0;
      }
      else
      {
        tmp_num = tmp_num * 10 + num;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

typedef std::vector<std::map<index_t, std::int64_t>> edge_t;

template<class Value, class Compare>auto custom_bellman_ford(std::vector<std::map<index_t, Value>>const& edge, Compare compare)
->boost::optional<Value>
{
	auto N = edge.size();
	std::vector<boost::optional<Value>> result(N);
	result[0] = 0;
	for (auto c : boost::irange<index_t>(1, N))
	{
		for (auto i : boost::irange<index_t>(0, N))
		{
			for (auto&& e : edge[i])
			{
				auto j = e.first;
				auto v = e.second;
				if (result[i] && (!result[j] || compare(*result[i] + v, *result[j])))
				{
					result[j] = *result[i] + v;
				}
			}
		}
	}
	auto ret = result[N - 1];
	for (auto c : boost::irange<index_t>(1, N))
	{
		for (auto i : boost::irange<index_t>(0, N))
		{
			for (auto&& e : edge[i])
			{
				auto j = e.first;
				auto v = e.second;
				if (result[i] && (!result[j] || compare(*result[i] + v, *result[j])))
				{
					result[j] = *result[i] + v;
				}
			}
		}
	}
	return ret == result[N - 1] ? ret : boost::none;
}

void Main()
{
	int N, M;
	std::int64_t P;
	std::cin >> N >> M >> P;
	edge_t edge(N);
	for (auto i : boost::irange(0, M))
	{
		index_t a, b;
		std::int64_t v;
		std::cin >> a >> b >> v;
		--a; --b;
		if (edge[a].count(b))
		{
			edge[a][b] = std::max(edge[a][b], v - P);
		}
		else
		{
			edge[a][b] = v - P;
		}
	}
	auto result = custom_bellman_ford(edge, std::greater<>());
	if (result)
	{
		std::cout << std::max(std::int64_t(), *result) << std::endl;
	}
	else
	{
		std::cout << -1 << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 896
n = int(input())
bx = 0
by = 0
bt = 0
def p(t,x,y):
  if abs(x)+abs(y) > t:
    return True
  elif (t-abs(x)-abs(y))%2 == 1:
    return True
  else:
    return False
for _ in range(n):
  at,ax,ay = map(int,input().split())
  if p(at-bt,bx-ax,by-ay):
    print("No")
    exit()
  bx = ax
  by = ay
  bt = at
print("Yes")  

Measured memory_bytes: 46440
N, Q = map(int, input().split())
S = input()

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    l, r = map(int, input().split())
    result = hit[r - 1] - hit[l - 1]
    print(result)



Measured memory_bytes: 50776
#include <bits/stdc++.h>
using namespace std;
string n, t; int x, ok=1;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> x; cin >> n;
if (x%2) ok=0;
for (int i=0; i<x/2; i++) if (n[i]!=n[i+x/2]) ok=0;
if (ok) cout << "Yes";
else cout << "No";
return 0;
}

Measured memory_bytes: 256
import sys

n, m = map(int, input().split())
N = [None]*n
for _ in range(m):
    s, c = map(int, input().split())
    if s-1 == c == 0 and n != 1:
        print(-1)
        sys.exit(0)
    if N[s-1] == None or N[s-1] == c:
        N[s-1] = c
    else:
        print(-1)
        sys.exit(0)
if N[0] == None and n > 1:
    N[0] = 1
for i in range(n):
    if N[i] == None:
        N[i] = 0
    print(N[i], end="")
print()

Measured memory_bytes: 38460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<string> t{"SUN","MON","TUE","WED","THU","FRI","SAT"};
	vector<int> num{7,6,5,4,3,2,1};
	rep(i,7){
		if(t.at(i) == s) cout << num.at(i) << endl;
	}
}


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

const int MOD = 1000000007;
const int MAXN = 5005;

void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }
void sub(int &a, int b) { a -= b; if(a < 0) a += MOD; }
void mul(int *A, int An, int *B, int Bn, int *C) {
	memset(C, 0, (An+Bn-1) * sizeof(int));
	for(int i = 0, a, j, *v; i < An; i++) {
		a = A[i]; v = C+i;
		for(j = 0; j < Bn; j++, v++)
			*v = (ll(a) * B[j] + *v) % MOD;
	}
}

int dp[MAXN][2][MAXN];
int F[MAXN], C[4][MAXN];

vector<int> G[MAXN];
int cnt[MAXN];

int N, Ans;

void dfs(int idx) {
	cnt[idx] = 1;
	dp[idx][0][1] = 1;
	for(int v : G[idx]) if(!cnt[v]) {
		dfs(v);

		for(int a : {0, 1}) for(int b : {0, 1})
			mul(dp[idx][a], cnt[idx]+1, dp[v][b], cnt[v]+1, C[a<<1|b]);
		for(int a : {0, 1}) for(int b : {0, 1})
			for(int i = cnt[idx]+1, t; i--;) {
				t = dp[idx][a][i];
				for(int j = 0; j <= cnt[v]; j += 2)
					add(C[a<<1|b^1][i], ll(t) * F[j] % MOD * dp[v][b][j] % MOD);
			}
		cnt[idx] += cnt[v];
		for(int i = cnt[idx]+1; i--;) {
			add(C[0][i], C[3][i]);
			add(C[1][i], C[2][i]);
		}
		for(int t : {0, 1})
			memcpy(dp[idx][t], C[t], (cnt[idx]+1) * sizeof(int));
		for(int t : {0, 1, 2, 3})
			memset(C[t], 0, (cnt[idx]+1) * sizeof(int));
	}
}

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

	cin >> N;
	for(int i = 1, a, b; i < N; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}

	F[0] = 1;
	for(int i = 2; i <= N; i += 2)
		F[i] = ll(F[i-2]) * (i-1) % MOD;

	dfs(1);

	for(int i = 1; i <= N; i++) {
		add(Ans, ll(dp[1][0][i]) * F[i] % MOD);
		sub(Ans, ll(dp[1][1][i]) * F[i] % MOD);
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 195584
divide = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(4):
    divide[i] = divide[i][::-1]
s = input()[::-1]
can = True
i = 0
while i < len(s):
    can2 = False
    for j in range(4):
        d = divide[j]
        if s[i:i+len(d)] == d:
            can2 = True
            i += len(d)
    if not can2:
        can = False
        break

if can:
    print("YES")
else:
    print("NO")

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

int main(void){
	while(true){
		int n;
		int sum;
		int count = 0;
		cin >> n;
		if(n == 0)return 0;
		int a[n + 1];
		for(int i = 1; i <= n; i ++){
			a[i] = i;
		}

		for(int i = 1; i <= n/2; i++){
			sum = i;
			for(int j = i + 1; sum < n; j++){
				sum += j;
			}
			if(sum == n) count++;
		}
		cout << count << endl;



	}
	return 0;
}


Measured memory_bytes: 3000
#include<stdio.h>

int main(){
  int a, b, x;
  scanf("%d%d%d", &x, &a, &b);
  
  if(b<=a){
    printf("delicious\n");
  }else if(a<b && (b-a)<=x){
    printf("safe\n");
  }else if(x<=(b-a)){
    printf("dangerous\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int sort(const void *a, const void *b){
    if( *(long long int*)a - *(long long int*)b < 0 )
        return -1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return 1;
    return 0;
}

int main(void){
    int n;
    scanf("%d",&n);
    long long t[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&t[i]);
    }
    qsort(t,n,sizeof(long long),sort);
    
    long long ans=t[0];
    for (int i=1; i<n; i++){
        long long m,n,r;
        if (t[i]>ans){
            m=t[i];
            n=ans;
        } else {
            m=ans;
            n=t[i];
        }
        r=m%n;
        while (r!=0){
            m=n;
            n=r;
            r=m%n;
        }
        ans=t[i]/n*ans;
    }
    printf ("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main(void) {
	string a, b;
	cin >> a >> b;
	a += a;
	if (a.find(b) != string::npos) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define INF (1 << 29)

#define MAX_N 20000
#define MAX_M 16

using namespace std;

int N, M, C[MAX_M], X, dp[MAX_N + 1][256];

int main()
{
	while (true)
	{
		for (int i = 0; i < MAX_N + 1; i++)
		{
			for (int j = 0; j < 256; j++)
			{
				dp[i][j] = INF;
			}
		}

		dp[0][128] = 0;

		cin >> N >> M;

		if (N == 0 && M == 0) { break; }

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

		for (int i = 0; i < N; i++)
		{
			cin >> X;

			for (int j = 0; j < 256; j++)
			{
				for (int k = 0; k < M; k++)
				{
					int ptr = j + C[k];

					if (ptr < 0) { ptr = 0; }
					if (ptr > 255) { ptr = 255; }

					int sabun = (X - ptr) * (X - ptr);

					dp[i + 1][ptr] = min(dp[i + 1][ptr], dp[i][j] + sabun);
				}
			}
		}

		cout << *min_element(dp[N], dp[N] + 256) << endl;
	}

	return 0;
}

Measured memory_bytes: 23076
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = candies

candies :: IO ()
candies = do
  n :: Int <- readLn
  a1 :: V.Vector Int <- getLineSpcVec
  a2 :: V.Vector Int <- getLineSpcVec
  let sums = V.fromList [ V.sum $ V.take i a1 V.++ V.drop (i - 1) a2
                        | i <- [1..n]
                        ]
  print $ V.maximum sums

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    long long X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    long long moves = X / D;
    if (moves >= K) {
        X -= K * D;
    } else {
        X -= moves * D;
        long long rem = K - moves;
        if (rem & 1)
            X -= D;
    }

    cout << abs(X);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int n; cin >> n;
	for (int i = n; i < 1000; ++i) {
		if (i % 10 == i / 10 % 10 && i / 10 % 10 == i / 100 % 10) {
			cout << i << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }

    if (n == 1){
        cout << 0 << endl;
        return 0;
    }
    
    ll b = 0;

    for (ll i = 0; i < n-1; i++){
        for (ll j = i+1; j < n; j++){
            if (a[i] > a[j]){
                b++;
            }
        }
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll z = 0;

    for (ll i = 0; i < n-1; i++){
        for (ll j = i+1; j < n; j++){
            if (a[i] > a[j]){
                z++;
            }
        }
    }

    //cout << b << endl;
    //cout << z << endl;

    ll p = (k-1)*k/2;
    p %= MOD;
    p *= z;
    p %= MOD;
    ll q = b*k;
    q %= MOD;
    ll ans = (p+q)%MOD;

    //cout << ((k-1)*k*z/2 + b*k)%MOD << endl;

    cout << ans << endl;

}

Measured memory_bytes: 3672
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: u64 = 1_000_000_000 + 7;
fn main() {
    input! {
        n: usize, k: u64,
        a: [u64; n],
    }
    let mut tento = 0u64;
    let mut tento_s = 0u64;
    for i in 0..n {
        for j in 0..n {
            if a[i] > a[j] {
                tento += 1;
                if j > i {
                    tento_s += 1;
                }
            }
        }
    }

    let sum_ = ((1 + k - 1) * (k - 1) / 2) % MOD;

    tento *= sum_;
    tento %= MOD;

    tento_s *= k;
    tento_s %= MOD;

    let mut ans = tento + tento_s;
    ans %= MOD;
    println!("{}", ans);
}


Measured memory_bytes: 4352