akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int n, a[100], b[100], c[100], d[100];
vector<int> es[200];
bool used[200];
int match[200];

bool dfs(int v) {
	used[v] = true;
	REP(i, es[v].size()) {
		int t = es[v][i];
		int m = match[t];
		if (m < 0 || (!used[m] && dfs(m))) {
			match[v] = t;
			match[t] = v;
			return true;
		}
	}
	return false;
}

int flow() {
	int f = 0;
	memset(match, -1, sizeof(match));
	REP(i, n*2) if (match[i] < 0) {
		memset(used, 0, sizeof(used));
		if (dfs(i)) ++f;
	}
	return f;
}
 
int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> a[i] >> b[i];
	REP(i, n) cin >> c[i] >> d[i];
	REP(i, n) REP(j, n) if (a[i] < c[j] && b[i] < d[j]) {
		es[i].push_back(n+j);
		es[n+j].push_back(i);
	}
	cout << flow() << endl;
	return 0;
}
 

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    S = [list(map(int, readline().strip())) for j in range(H)]

    white = 0
    for line in S:
        white += sum(line)

    if white <= K:
        print(0)
        exit()

    # 横線の決め方を全探索
    ans = 10**5
    for pattern in range(2**(H-1)):
        # 初期化
        impossible = False
        x = 0
        ly = bin(pattern).count("1")
        y = [S[0]]
        line = 0
        for i in range(1,H):
            if (pattern >> i-1) & 1:
                line += 1
                y.append(S[i])
            else:
                y[line] = [y[line][j] + S[i][j] for j in range(W)]

        # 各列の値を加算していく
        count = [0]*(ly + 1) 
        for j in range(W):
            for i in range(line+1):
                if y[i][j] > K :
                    impossible = True
                    break

                count[i] += y[i][j]
                if count[i] > K:
                    x += 1
                    for i in range(line+1):
                        count[i] = y[i][j] 
                    break
            if x + ly > ans or impossible:
                impossible = True
                break
        if impossible:
            x = 10**6

        ans = min(ans, x + ly)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44380
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
 
typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;
 
int main(){
    fast_cin();
    int k,n;cin>>k>>n;
    vec v(n);
    rep(i, 0, n)
    cin>>v[i];
    int ans = v[0]+k-v[n-1];
    rep(i, 0, n-1)
    ans = max(ans, v[i+1]-v[i]);

    cout<<k-ans<<endl;
}

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

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

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

    int inp[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &inp[i]);

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (inp[i - 1] < inp[i] && inp[i] < inp[i + 1])
            ans++;
        else if (inp[i - 1] > inp[i] && inp[i] > inp[i + 1])
            ans++;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] b=new int[n-1];
		for(int i=0; i<n-1; i++){
			b[i]=sc.nextInt();
		}
		int[] a=new int[n];
		a[n-1]=Integer.MAX_VALUE;
		for(int i=n-2; i>=0; i--){
			a[i]=b[i];
			if(a[i+1]>b[i]){
				a[i+1]=b[i];
			}
		}
		int sum=0;
		for(int i=0; i<n; i++){
			sum+=a[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string.h>
#include <queue>
#include <set>
using namespace std;

#define N 64

char Rin[N][N],Len[N][N];
char memo[N][N][N][N];
int W,H,xr,xl,yl,yr;
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};

int main()
{	// LenRin
	//puts("test0");
	while(cin>>W>>H,W||H){
		cin.ignore();
		//puts("test1");
		memset(Rin,'#',sizeof(Rin));
		memset(Len,'#',sizeof(Len));
		memset(memo,0,sizeof(memo));
		for(int i=0;i<H;i++)scanf("%s %s",Len[i],Rin[i]);
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(Len[i][j]=='L')
					xl=j,yl=i;
				if(Rin[i][j]=='R')
					xr=j,yr=i;
			}
		}
		memo[yl][xl][yr][xr] = 1;
		//printf("start:(%d,%d),(%d,%d)\n",yl,xl,yr,xr);
		queue<pair<int,int> > rin,len;
		rin.push(make_pair(xr,yr));
		len.push(make_pair(xl,yl));
		int flag = 0;
		while(!rin.empty() && !flag){
			xr = rin.front().first;
			yr = rin.front().second;
			xl = len.front().first;
			yl = len.front().second;
			
			rin.pop(); len.pop();
			
			for(int k=0;k<4;k++){
				int txR = xr + dx[k];
				int tyR = yr + dy[k];
				int txL = xl + dx[k]*-1;
				int tyL = yl + dy[k];
				if( txR<0 || tyR<0 || txR>=W || tyR>=H || Rin[tyR][txR]=='#')
					txR = xr, tyR = yr;
				if( txL<0 || tyL<0 || txL>=W || tyL>=H || Len[tyL][txL]=='#')
					txL = xl, tyL = yl;
				if( memo[tyL][txL][tyR][txR]==1)continue;
				if( Rin[tyR][txR]=='%' && Len[tyL][txL]=='%'){
					flag=1;
					break;
				}
				if( Rin[tyR][txR]=='%' || Len[tyL][txL]=='%')
					continue;
				
				memo[tyL][txL][tyR][txR] = 1;
				
				rin.push(make_pair(txR,tyR));
				len.push(make_pair(txL,tyL));
				//printf("(%d,%d) (%d,%d)\n",tyL,txL,tyR,txR);
			}
		}
		puts(flag?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 17000
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		var a = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
		int x = a[0];
		int y = a[1];
		
		if(y%2==1){
			Console.WriteLine("No");
		}else if(y<2*x){
			Console.WriteLine("No");
		}else if(y>4*x){
			Console.WriteLine("No");
		}else{
			Console.WriteLine("Yes");
		}
		
	}
}

Measured memory_bytes: 28236
from itertools import product

N,M=map(int,input().split())
scores=[list(map(int,input().split())) for _ in range(N)]

def f(score):
  return sum([score[i]*((-1)**(1-p[i])) for i in range(3)])

ans=0
for p in product(range(2),repeat=3):
  s = list(map(f,scores))
  s = sorted(s,reverse=True)
  SUM = sum(s[:M])
  if ans < SUM:ans=SUM
    
print(ans)

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

int main() {
  int n,ans=0;
  cin >> n;
  int p[n],m[n];
  rep(i,n) cin >> p[i];
  m[0] = p[0];
  for(int i=1;i<n;i++) m[i] = min(m[i-1],p[i]);
  rep(i,n) if(m[i] == p[i])  ans++;
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
    
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str = s.next();
		int l = str.length();
		char[] out = new char[l];
		for (int i=0 ; i<l ; i++)
			out[i] = str.charAt(i);
		for (int i=l-1 ; i >= 0 ; i--)
			System.out.print(out[i]);
System.out.println();
    }
}

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

int main(int argc, char *argv[]){
  int N,K;
  cin>>N>>K;
  if(K==1){
    cout<<0<<endl;
  }else{
    cout<<N-K;
  }
  
  return 0;
}



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

int main() {
    int q;
    set<int> st;
    cin >> q;
    for(int i=0;i<q;i++){
        int c, x;
        cin >> c >> x;
        if(c==0){
            st.insert(x);
            cout << st.size() << endl;
        }
        else if(c==1){
            cout << st.count(x) << endl;
        }
        else{
            st.erase(x);
        }
    }
    return 0;
}



Measured memory_bytes: 12468
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d;
  cin>>n;
  vector<int> D(n);
  for(int i=0;i<n;i++)
  {
    cin>>d;
    D[i]=d;
  }
  int count=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      count+=D[i]*D[j];
    }
  }
cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin >> a >> b;
	if(a == b) println("Yes");
	else println("No");
}


Measured memory_bytes: 256
import math

a, b, T = map(float, input().split())
t = math.radians(T)
h = b * math.sin(t)
s = h * a / 2
c = ((a - b * math.cos(t)) ** 2 + h ** 2) ** 0.5
l = a + b + c
print(s, l, h)


Measured memory_bytes: 5700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	Graph G(4);
	rep(i, 0, 3) {
		int a, b; cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bool ok = true;
	rep(i, 0, 4) {
		if (G[i].size() == 3)ok = false;
	}
	cout << (ok ? "YES" : "NO") << "\n";
	
	return 0;
}

Measured memory_bytes: 3596
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

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

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int x,x2;
int y,y2;

signed main(){
    io();

    in(x,y,x2,y2);
    int xdiff=x2-x;
    int ydiff=y2-y;

    //show(xdiff,ydiff);

    printf("%lld %lld %lld %lld\n",x2-ydiff,y2+xdiff,x-ydiff,y+xdiff);

    return 0;
}


Measured memory_bytes: 500
#include <stdio.h>

int main(void)
{
	int i, j;
	int H, W;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if ((H != 0) && (W != 0))
		{
			for (i = 0;i < H;i++)
			{
				for (j = 0;j < W;j++)
				{
					if ((i == 0) || (i == H - 1) || (j == 0) || (j == W - 1))
					{
						printf("#");
					}
					else
					{
						printf(".");
					}

				}
				printf("\n");
			}
			printf("\n");
		}
		else 
		{
			break;
		}


	}
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e9 + 7;
ll n, m, q, a, b, c, d, i, j, k, cnt = 1, ans;
ll ar[N];
vector < ll > vec, vec1, vec2, tmp;

int main()
{
    faster_io;
    cin >> n;
    for(i = 1; i <= n; i++)
        vec.pb(i);
    for(i = 1; i <= n; i++)
        cin >> a, vec1.pb(a);
    for(i = 1; i <= n; i++)
        cin >> a, vec2.pb(a);

    i = 1;
    do
    {
        if(vec == vec1)
            a = i;
        if(vec == vec2)
            b = i;
        i++;
    }
    while(next_permutation(vec.begin(), vec.end()));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

typedef long long ll;

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  if (N == 2)
  {
    if (K==0)
      printf("1\n1 2\n");
    else
      printf("-1\n");
    return 0;
  }
  if (N==3)
  {
    if (K==0)
      printf("3\n1 2\n2 3\n1 3\n");
    else if (K==1)
      printf("2\n1 2\n2 3\n");
    else
      printf("-1\n");
    return 0;
  }
  int maxK = (N-1)*(N-2)/2;
  if (K > maxK)
  {
    printf("-1\n");
    return 0;
  }
  int E = maxK-K;
  printf("%d\n", N-1+E);
  for (int i=2;i<=N;i++)
  {
    printf("1 %d\n", i);
  }
  int count = 0;
  for (int i=2;i<N;i++)
  {
    for (int j=i+1;j<=N;j++)
    {
      if (count==E) return 0;
      count++;
      printf("%d %d\n", i, j);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
const double EPS = 1e-8;

int main(){
	int x,y;
	cin >> x >> y;
	double m = (double)y/x;
	int count = 0;
	for(int i=0; i<=x; i++){
		if(abs(m*i -round(m*i)) < EPS){
			count++;
		}
	}
	cout << x+y+2-count << endl;
	return 0;
}



Measured memory_bytes: 3216
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner s = new Scanner(System.in);
        double a[] = new double[5];
        for(int i = 0; i < 5; i++){
            a[i] = s.nextInt();
        }
        double miti =  Math.abs(a[0] - a[2]) ;
        double haya = a[1] - a[3];
        if(miti <= haya * a[4]) System.out.println("YES");
        else  System.out.println("NO");
       // System.out.println(str.substring(0,3));
    }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll
using namespace std;

int main(int argc, char const *argv[])
{

    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<int, ll> mp;
    rep(i, n)
    {
        mp[s[i]]++;
    }
    ll ans = 1;
    rep(i, 'a', 'z' + 1)
    {
        ans *= mp[i] + 1;
        ans %= MOD;
    }
    ans--;
    ans %= MOD;

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


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

#define MAX 10	// ªºÌ

int main()
{
	int n;
	int flag;
	int i;

	while (cin >> n) {
		flag = 0;
		for (i = 0; i < MAX; i++) {
			if ( (n & 1<<i) == 0) continue;
			if (flag) cout << " ";
			else flag = 1;
			cout << (1<<i);
		}
		cout << endl;
	}

	return 0;
}

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

char right[15] = { 'q', 'w', 'e', 'r', 't', 'a', 's', 'd', 'f', 'g', 'z', 'x', 'c', 'v', 'b' };
char left[11] = { 'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm' };

char judge(char c){
	for (int i = 0; i < 15; ++i)if (right[i] == c)return 'r';
	return 'l';
}

int main(){
	std::string s;
	while (std::cin>>s){
		if (s == "#")break;
		char shift=judge(s[0]);
		int ans = 0;
		for (int i = 1; i < s.size(); ++i){
			if (shift != judge(s[i])){
				shift = judge(s[i]);
				ans++;
			}
			
		}
		std::cout << ans << std::endl;
		//printf("%c\n", );
	}
}

Measured memory_bytes: 1184
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    int index[N+1];
    REP(i,N){ 
        cin >> A[i];
        index[A[i]] = i;
    };
    set<int> S;
    S.insert(-1); S.insert(N);
    ll ans=0;
    for(int v=1;v<=N;v++){
        int i = index[v];
        auto it = S.lower_bound(i);
        ll r = *it;
        ll l = *--it;
        ans += v*(i-l)*(r-i);
        S.insert(i);
    }    

    cout << ans << endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ll take = min(a, k);
  ans += take;
  a -= take;
  k -= take;
  take = min(b, k);
  k -= take;
  take = min(c, k);
  ans -= take;
  k -= take;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3652
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
ulong MIDDLE = 100_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m, make;
    scan(n, m);
    if (n <= m / 2)
    {
        make += n, m -= 2 * n;
        make += m / 4;
    }
    else
    {
        make += m / 2;
    }
    make.writeln();

}


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

int main(){
  vector<int> n(3);
  for(int i=0;i<3;i++){
    cin >> n.at(i);
  }
  sort(n.begin(),n.end());
  int a=n.at(1)-n.at(0);
  int b=n.at(2)-n.at(1);
  
  cout << a+b << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int ans=0,max=0;
    for(int i=0;i<n;i++){
        int h;
        cin >>h;
        if(max <= h){
            ans++;
            max = h;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,w,l,d,a,p[20],r[20],s=0;
  char t[10][22];
  int i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      r[i]=i;
      scanf("%s %d %d %d",&t[i],&w,&l,&d);
      p[i]=3*w+d;
    }
    for(i=0;i<n;i++){
      for(j=1;i+j<n;j++){
	if(p[r[j-1]]<p[r[j]]){
	  a=r[j-1];
	  r[j-1]=r[j];
	  r[j]=a;
	}
      }
    }
    if(s!=0)printf("\n");
    s=1;
    for(i=0;i<n;i++){
      printf("%s,%d\n",t[r[i]],p[r[i]]);
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int n, x, a;
string s;

int main() {
	cin>>n>>s;
	rep(i, 0, n - 1) 
	    if(s[i] == 'R') x++;
	rep(i, 0, n - 1) 
		if(s[i] == 'R' && x <= i) a++;
	cout<<a<<endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int n, m, q;
    cin >> n >> m >> q;
    pair<int, int> x, y;
    map<int, int> f, c;
    map<pii, bool> par;
    map<int, vector<int>> mp1;
    map<int, vector<int>> mp2;
    x = {0, 0}, y = {0, 0};
    forn(i, q) {
        int h, w;
        cin >> h >> w;
        f[h]++;
        c[w]++;
        par[{h, w}]=1;
        //debug(h, w, f[h], c[w], x.F, y.S);
        if(f[h] >= x.S) {
            x = {h, f[h]};
            mp1[x.S].pb(x.F);
        }
        if(c[w] >= y.S) {
            y = {w, c[w]};
            mp2[y.S].pb(y.F);
        }
    }
    int ans = 0;
    for(auto p:mp1[x.S]){
        for(auto k:mp2[y.S]){
            ans=max(ans,f[p] + c[k] - par[{p, k}]);
            if(!par[{p,k}])goto done;
        }
    }
    done:;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 69788
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  priority_queue<pair<ll,pair<ll,ll>>> que;
  ll sum1 = 0;
  ll sum2 = 0;
  for(int i = 0;i < n;i++){
    ll a,b;
    cin >> a >> b;
    que.push(make_pair(a+b,make_pair(a,b)));
  }

  for(int i = 0;i < n;i++){
    pair<ll,pair<ll,ll>> p = que.top();
    que.pop();
    if(i % 2 == 0)sum1 += p.second.first;
    else sum2 += p.second.second;
  }

  cout << sum1 - sum2 << endl;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

double dp[310][310][310];
bool visit[310][310][310];
int N;

double rec(int one, int two, int thr){
  if(one<0 || two<0 || thr<0) return 0;
  if(one==0 && two==0 && thr==0) return dp[0][0][0] = 0;
  if(visit[one][two][thr]) return dp[one][two][thr];
  visit[one][two][thr] = true;

  
  dp[one][two][thr] = ((double)N + rec(one-1,two,thr)*one + rec(one+1,two-1,thr)*two + rec(one,two+1,thr-1)*thr) / (one+two+thr);
  
  return dp[one][two][thr];
}

int main(){
  cin >> N;
  vector<int> a(N); cin >> a;

  map<int,int> c;
  REP(i,N) ++c[a[i]];

  printf("%.012f\n", rec(c[1],c[2],c[3]));
  
  return 0;
}


Measured memory_bytes: 256256
num=list(map(int,input().split()))
com_1=0
com_2=0

if num[0]<=1:
    com_1=0
else:
    com_1=(num[0]*(num[0]-1))/2

if num[1]<=1:
    com_2=0
else:
    com_2=(num[1]*(num[1]-1))/2

print(int(com_1 + com_2))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    lint ans=0;
    rep(i,N) cin >> A[i];
    map<lint,lint> num;
    rep(i,N) num[A[i]]++,ans+=A[i];
    set<lint> exist;
    rep(i,N) exist.insert(A[i]);
    lint Q;
    cin >> Q;
    rep(i,Q){
        lint B,C;
        cin >> B >> C;
        lint cnt=num[B];
        ans-=B*cnt;
        ans+=C*cnt;
        num[B]=0;
        num[C]+=cnt;
        exist.erase(B);
        exist.insert(C);
        cout << ans << endl;
    }
}

Measured memory_bytes: 13116
from collections import Counter
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
if n % 2 == 0:
    for i in range(1, n, 2):
        if i not in count or count[i] != 2:
            print(0)
            exit()
    print(pow(2, n//2, MOD))
else:
    for i in range(2, n, 2):
        if i not in count or count[i] != 2:
            print(0)
            exit()
    if 0 not in count or count[0] != 1:
        print(0)
        exit()
    print(pow(2, (n-1)//2, MOD))



Measured memory_bytes: 14820
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		sc.close();

		long ans = 0;

		if (N >= 2) {
			ans += (N * (N - 1)) / 2;
		}

		if (M >= 2) {
			ans += (M * (M - 1)) / 2;
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23764
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n;
	cin>>n;
	cout<<(double)((n+1)/2)/n;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  string ans = "Yes";
  int n = s.size();
  rep(i,(n-1)/2){
    if(s[i] != s[n-1-i])
      ans = "No";
  }
  rep(i, (n-1)/2){
    if((s[i] != s[(n-1)/2-1-i]) ||
      (s[(n+3)/2-1+i] != s[n-1-i]))
      ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    map<int, int> count; 
    for(int i=0; i<N; i++){
        int num;
        cin >> num;
        count[num] += 1;
    }
    int answer=0;
    for(const auto & e : count){
        int diff;
        diff = e.second - e.first;
        if(diff >= 0){
            answer += diff;
        } else {
            answer += e.second;
        }
    }
    cout << answer << endl;
   return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N+1,0);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  int sum = 0;
  while(true){
    int r;
    for(int i=0;i<=N;i++){
      if(H[i]>0){
        r=i;
        break;
      }
      if(i==N){
        cout << sum << endl;
        return 0;
      }
    }
    for(int i=r;i<=N;i++){
      if(H[i]>0){
        H[i] --;
      }else{
        break;
      }
    }
    sum ++;
  }
}

Measured memory_bytes: 256
//d3n nos

#include <bits/stdc++.h>

using namespace std;

#define fn(i,n) for(int i = 0 ; i < n ; i++)

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

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


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

	priority_queue <long long, vector<long long>, greater<long long> > a; //min heap
	priority_queue <long long > c;//max heap 
	//long long a[n];
	long long ab[n];
	long long b[n];
	long long bc[n];
	//long long c[n];
	long long suma=0,sumc=0;
	long long k;

	fn(i,n)
	{
		//cin>>a[i];
		//suma+=a[i];

		cin>>k;
		a.push(k);
		suma+=k;
	}

	fn(i,n)
	{
		cin>>b[i];


	}
	fn(i,n)
	{
		// cin>>c[i];
		// sumc+=c[i];

		cin>>k;
		c.push(k);
		sumc+=k;
	}

	//qsort(a,n,sizeof(a[0]),comparator);
	//qsort(c,n,sizeof(c[0]),comparator2);

	// fn(i,n)
	// {
	// 	cout<<c[i]<<endl;
	// }

	// int j= 0;
	fn(i,n)
	{
		if(b[i]>a.top())
		{
			ab[i]=b[i]-a.top();
			a.pop();
			a.push(b[i]);
		}
		else
			ab[i]=0;
	}

	long long sumbc=0;
	fn(i,n)
	{
		if(b[n-1-i]<c.top())
		{
			bc[n-i-1]=c.top()-b[n-1-i];
			c.pop();
			c.push(b[n-1-i]);
		}
		else
			bc[n-1-i]=0;

		sumbc+=bc[n-1-i];

	}

	// cout<<sumbc<<endl;
	long long tprof = sumbc,maxprof=sumbc;
	//long long sumab = 0;
	fn(i,n)
	{
		tprof+=ab[i]-bc[i];
		if(tprof>maxprof)
			maxprof = tprof;

	}

	cout<< suma -sumc + maxprof ;


}

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

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

    int m;
    cin >> m;

    vector<ll> d(m), c(m);
    ll D = 0;
    ll S = 0;
    rep(i, m){
        cin >> d[i] >> c[i];
        D += c[i];
        S += d[i] * c[i];
    }

    cout << D-1 + (S-1)/9 << endl;

    return 0;
}

Measured memory_bytes: 6360
#include<iostream>
int main(void)
{
    using namespace std;
    int l,r,d,cnt=0;
    int i;

    cin >> l >> r >> d;
    for(i=l;i<=r;i++)
    {
        if(i % d == 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main(){
  
  vector<int> count_array;
  int count;
  int in_num;
  int a,b,c,d,i=0;
  while(cin>>in_num){
    count=0;
    if(in_num>36){
      count_array.push_back(0);
    }
    else{
      for(a=0;a<10;a++){
	for(b=0;b<10;b++){
	  for(c=0;c<10;c++){
	    for(d=0;d<10;d++){
	      if((a+b+c+d)==in_num){
		count++;
	      }
	    }
	  }
	}
      }
      count_array.push_back(count);
    }
    i++;
  }
  for(int j=0;j<i;j++){
    cout<<count_array[j]<<endl;
  } 
}

Measured memory_bytes: 1216
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

takeWhile2 :: (a -> a -> Bool) -> [a] -> [a]
takeWhile2 _ []  = []
takeWhile2 _ [x] = [x]
takeWhile2 p (i:j:xs) =
    if i `p` j then i : takeWhile2 p (j:xs) else [i]

solve :: [Int] -> Int
solve []  = 0
solve xs =
    let ml = maximum $ map length [x1,x2]
        r = drop ml xs
     in 1 + solve r
  where
    x1 = takeWhile2 (<=) xs
    x2 = takeWhile2 (>=) xs

main :: IO ()
main = do
    _ <- getLine
    a <- map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    print $ solve a


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int h, w, pref[905][905];

long long sum = 0;

char a[905][905], b[905][905];

bool check(int x, int y) {
    if(x >= 1 && x <= h && y >= 1 && y <= w && a[x][y] == '#') return 1;
    return 0;
}

void solve() {
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            pref[i][j] = 0;
            if(a[i][j] == '#')
                pref[i][j] = 1;
        }
    }
    for(int i = 1; i <= 3 * h; i++) {
        for(int j = 1; j <= 3 * w; j++) {
            if(i > h || j > w)
                pref[i][j] = 0;
            pref[i][j] += pref[i - 1][j - 1];
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(a[i][j] == '.') continue;
            for(int range = 1; range <= max(h, w); range++) {
                if(check(i + range, j + range))
                    sum = sum + pref[i + 2 * range - 1][j - 1] - pref[i + range - 1][max(j - range - 1, 0)];
            }
        }
    }
}

void rot() {
    for(int j = 1; j <= w; j++) {
        int cnt = 1;
        for(int i = h; i >= 1; i--) {
            b[j][cnt] = a[i][j];
            cnt++;
        }
    }
    swap(w, h);
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            a[i][j] = b[i][j];
    }
}

int main() {
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            scanf(" %c", &a[i][j]);
    }
    solve();
    rot(); solve();
    rot(); solve();
    rot(); solve();
    printf("%lld", sum);
}


Measured memory_bytes: 3968
loop do
  a,b=gets.split.map(&:to_i)
  break if a==0 && b==0
  count = 0
  (1..a-2).each do |i|
    (i+1..a-1).each do |j|
      (j+1..a).each do |k|
        count = count+1 if i+j+k==b
      end
    end
  end
  puts count
end


Measured memory_bytes: 6852
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main(void)
{
	int x, y;

	cin >> x >> y;
	int i;
	for (i = 0; i <= x; i++)
	{
		if (i * 2 + (x - i) * 4 == y)
		{
			break;
		}
	}
	if (i <= x)
		cout << "Yes";
	else
		cout << "No";

	//system("pause");

	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll a,b;
	cin>>a>>b;
	if(b==1||a==1) cout<<1<<endl;
	else if(a%2==0){
		cout<<a*b/2<<endl;
	}
	else {
		cout<<(a/2)*b+(b+1)/2<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    int y = b - a;
    if (y <= 0) {
        cout << "delicious" << endl;
    } else if (y < x + 1) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    } 
    return 0;
}




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

namespace ABC124
{
    class Program
    {
        static void Main(string[] args)
        {
            //Buttons(); // 8min
            //GreatOceanView(); // 15min
            ColoringColorfully();
        }

        static void ColoringColorfully()
        {
            bool[] xs = ReadBoolArray();

            int n = xs.Length;

            int ans = 0;

            for(int i = 0; i < n; i++)
            {
                if (xs[i] == (i % 2 == 0))
                {
                    ans++;
                }
            }

            ans = Math.Min(ans, n - ans);

            Console.WriteLine(ans);
        }

        static void GreatOceanView()
        {
            int n = ReadInt();
            int[] xs = ReadIntArray();

            int ans = 0;
            int max = 0;

            for(int i = 0; i < n; i++)
            {
                if (max <= xs[i])
                {
                    max = xs[i];
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }

        static void Buttons()
        {
            int[] xs = ReadIntArray();

            int ans = 0;

            for(int i = 0; i < 2; i++)
            {
                if (xs[0] > xs[1])
                {
                    ans += xs[0]--;
                }
                else
                {
                    ans += xs[1]--;
                }
            }

            Console.WriteLine(ans);
        }

        public static bool[] ReadBoolArray()
        {
            return Console.ReadLine().Select(c => c == '1').ToArray();
        }

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 11744
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a,h,w,d,q,y[90001],x[90001],s[90001];

int main() {
	cin >> h >> w >> d;
	REP(i,h) REP(j,w) {
    cin >> a;
    y[a]=i,x[a]=j;
  }
	cin >> q;
  int l[q],r[q];
	REP(i,q) cin >> l[i] >> r[i];

	for (int i=1; i<=h*w-d; i++) {
		s[i+d] = s[i] + abs(x[i+d]-x[i]) + abs(y[i+d]-y[i]);
  }

  REP(i,q) COUT(s[r[i]]-s[l[i]]);
  return 0;
}

Measured memory_bytes: 5416
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if(s[i] == t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	a = sort(a,rev=true)
	k = 0
	for i in 2:2:2n
		k += a[i]
	end
	println(k)
end
main()

Measured memory_bytes: 137256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    ans = "No"
    for i in range(9):
        i += 1
        for j in range(9):
            j += 1
            if N == i * j:
                ans = "Yes"
                break
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
const int MAXN = 110;
const int INF = 0x3f3f3f3f;

int n;

int main() {
	scanf( "%d", &n );
	int mx = -INF, mn = INF;
	for( int i = 0; i < n; ++i ) {
		int x; scanf( "%d", &x );
		mx = max(mx, x);
		mn = min(mn, x);
	}
	printf( "%d\n", mx-mn );
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real() * b.imag() - a.imag() * b.real(); }
ld dot(const P& a, const P& b) { return a.real() * b.real() + a.imag() * b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps) {
    auto c3 = [](const P& a, const P& b, const P& c) {
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P& a, const P& b) {
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P& a, const C& c) {
        return norm(a - c.pnt) <= c.rad * c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            c = c2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    c = c2(ps[j], ps[i]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

 int main(){
   srand(time(0));
    int n;
    cin >> n;
  vector<P> ps(n);
     for(int i = 0; i < n; ++i){
        ld x,y;
        cin >> x >> y;
        ps[i] = P(x,y);
    }

    printf("%.12lf\n", (double)smallest_enclosing_disc(ps).rad);
}


Measured memory_bytes: 256