akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)

int main() {
	string s; cin >> s;
	int ans=0;
	rep(i,4) {
		if(s[i]=='-') ans--;
		else ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(10 ** 9)
    R.append(10 ** 9)
    i = 0
    j = 0
    global count
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += (len(L) - i -1)

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(count)


Measured memory_bytes: 27480
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int i,N,tmp; cin >> N;
  vector <int>X(N,0); rep(i,N){cin >> X[i];}
  int a=0, b=0;

  std::sort(X.begin(), X.end(),std::greater<int>());
  rep(i,N){
      if(i%2==0){a+=X[i];}else{b+=X[i];}
  }

  cout << a - b << endl;

  return 0;
}


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

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

    int n;
    int flag = 0; // 1に立ったらDENIED
    while(cin >> n){
        for(int i=0; i<n; i++){
            if(n%2 == 0){
                if(n%3 == 0 || n%5 == 0){
                    //何もしない
                }else{
                    flag = 1;
                }
            }
        }
    }

    for(int i=0; i<n; i++){
        if(n%2 == 0){
            if(n%3 == 0 || n%5 == 0){
                //何もしない
            }else{
                flag = 1;
            }
        }
    }
    if(flag == 0){
        cout << "APPROVED" << '\n';
    }else{
        cout << "DENIED" << '\n';
    }

}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int bubbleSort(vector<int> &A, int N);

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    int count = bubbleSort(A, N);
    rep(i, A.size())
    {
        cout << A.at(i);
        if (i != A.size() - 1)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
    cout << count << endl;
}

int bubbleSort(vector<int> &A, int N) //N個の要素を含む、0オリジンの配列 A
{
    int count = 0;
    int flag = 1; //逆の隣接要素が存在する
    while (flag)
    {
        flag = 0;
        for (int j = N - 1; j > 0; j--)
        {
            if (A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                flag = 1;
                count++;
            }
        }
    }
    return count;
}


Measured memory_bytes: 3112
/* ex3_3 melo */
#include <stdio.h>
int main(void){
    int Num, BaseN;//整数の箱を二つ用意する
    int digit=0;//桁数をいれる箱を用意し、0を代入する
    scanf("%d %d",&Num,&BaseN);//Num,BaseNに代入
    while(Num!=0){//NumをBaseNで割った商が0になるまで繰り返す
        Num=Num/BaseN;//割った時の商をNumに代入する（今回はNumをK進数で表す必要がないためあまりを考える必要はない）
        digit=digit+1;//桁数を+1する
    }
    printf("%d\n",digit);//何桁か表示
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 matchNeeded[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m;
    cin >> n >> m;
    vector<int32> a(m);
    REP(i,m)cin >> a[i];
    sort(ALL(a));
    vector<int32> digits(n+1, -INF);
    digits[0] = 0;
    FOR(i,1,n+1){
        REP(j,m){
            if(i - matchNeeded[a[j]] < 0)continue;
            digits[i] = max(digits[i], digits[i - matchNeeded[a[j]]] + 1);
        }
    }
    while(n > 0){
        FORR(i,m-1,0){
            if(n - matchNeeded[a[i]] < 0)continue;
            if(digits[n] - digits[n - matchNeeded[a[i]]] == 1){
                cout << a[i];
                n -= matchNeeded[a[i]];
                break;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX
int main(){
    int n;cin>>n;
    bool a[MAX_B];
    rep(i,n)cin>>a[i];
    bool s[MAX_B];
    memset(s,0,sizeof(s));
    for(int i=n-1;i>=0;--i){
        int x=i+1;
        int sum=0;
        for(int j=2*x;j<=n;j+=x){
            sum+=s[j-1];
        }
        if(sum%2!=a[i])s[i]=1;
        else s[i]=0;
        }
        int count=0;
        rep(i,n)if(s[i])count++;
        cout<<count<<endl;
        rep(i,n)if(s[i])cout<<i+1<<" ";
        cout<<endl;
        
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<ll> l(n+1);
    for(int i=0;i<n+1;i++)cin>>a[i];
    l[0]=1;
    
    for(int i=1;i<=n;i++){
        if(l[i-1]-a[i-1]>LLONG_MAX/2){
            l[i]=LLONG_MAX;
            continue;
        }
        l[i]=(l[i-1]-a[i-1])*2;
    }
    ll now=a[n];
    ll ret=a[n];
    if(l[n]<a[n]){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=n-1;i>=0;i--){
        if(now/2+a[i]>l[i]){
            cout<<-1<<endl;
            return 0;
        }else if(now+a[i]<=l[i]){
            now+=a[i];
        }else{
            now=l[i];
        }
        ret+=now;
    }
    cout<<ret<<endl;
}


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

int main() {
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(&n[0], &n[3]);
	cout << n[2] * 10 + n[1] + n[0] << endl;
	return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	a = int(input())
	b = int(input())
	if(set([a,b])==set([1,2])):
		print(3)
	elif(set([a,b])==set([1,3])):
		print(2)
	else:
		print(1)

def factorization(n):
	if n<2:
		return []
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


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

int main()
{
    char s[3];
    for ( int i=0; i<3; i++){
        scanf("%c", &s[i]);
    }
    
    if ( s[0] != s[1] || s[1] != s[2] || s[2] != s[0] ){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

def make_is_prime(N):
    prime = [1 for i in range(N+1)]
    prime[0] = prime[1] = 0
    for i in range(2,N+1):
        if prime[i] == 0: continue
        j = i**2
        while (j <= N):
            prime[j] = 0
            j += i
    return prime

a = make_is_prime(10**5+5)

N = int(input())

for i in range(N,10**5+5):
    if a[i] == 1:
        print(i)
        sys.exit()


Measured memory_bytes: 83880
# D問題
from collections import deque
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    inf = 10**5
    ans = [0]*n
    q = deque()
    for i in range(n):
        dist = [inf]*n
        q.appendleft(i)
        dist[i] = 0
        while q:
            v = q.pop()
            d = dist[v]
            if v-1 >= 0 and dist[v-1] == inf:
                q.appendleft(v-1)
                dist[v-1] = d+1
            if v+1 <= n-1 and dist[v+1] == inf:
                q.appendleft(v+1)
                dist[v+1] = d+1
            if v == x and dist[y] == inf:
                q.appendleft(y)
                dist[y] = d + 1
            if v == y and  dist[x] == inf:
                q.appendleft(x)
                dist[x] = d + 1
        for di in dist:
            ans[di] += 1
    for a in ans[1:]:
        print(a//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 82396
import java.util.*

fun main(args: Array<String>) {

    var s = readLine()!!
    var deq = ArrayDeque<Char>()
    deq.addAll(s.toCharArray().asList())
    val q =  readLine()!!.toInt()

    var rev = false
    repeat(q) {
        val qu = readLine()!!
        if (qu == "1") rev = !rev
        else {
            val (t,f,c) =  qu.split(' ')
            if (f == "1") {
                if (rev) deq.addLast(c.toCharArray()[0])
                else deq.addFirst(c.toCharArray()[0])
            } else {
                if (rev) deq.addFirst(c.toCharArray()[0])
                else deq.addLast(c.toCharArray()[0])
            }
        }
    }


    while(deq.isNotEmpty()) {
        if (rev) {
            print(deq.pollLast())
        } else {
            print(deq.pollFirst())
        }

    }
    println()

}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 2e5 + 41;

int a[MAX];
int n;
ll ans;
map<ll, ll> d;

void solve() {
	ll s = 0;
	d[s] = 1;
	fi(1, n) {
		s += a[i];
		ans += d[s];
		d[s]++;
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d", &a[i]);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 13568
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if (a-b)%2 == 0:
        print((a+b)//2)
    else:
        print("IMPOSSIBLE")
    return

#B
def B():
    n = I()
    p = LI()
    k = [p[i] for i in range(n)]
    k.sort()
    s = 0
    for i in range(n):
        s += (p[i] != k[i])
    if s < 3:
        print("YES")
    else:
        print("NO")
    return

#C
def C():
    n = I()
    a = LI()
    b = LI()
    b.append(0)
    ans = 0
    sb = sum(b)
    i = n
    while i >= 0:
        if a[i] > b[i]:
            a[i] -= b[i]
            b[i] = 0
        else:
            b[i] -= a[i]
            a[i] = 0
        if a[i] > b[i-1]:
            a[i] -= b[i-1]
            b[i-1] = 0
        else:
            b[i-1] -= a[i]
            a[i] = 0
        i -= 1

    print(sb-sum(b))
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


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

int main(){
  string N;
  cin >> N;
  if (N[0] == '7')
    std::cout << "Yes\n";
  else if(N[1] == '7')
    std::cout << "Yes\n";
  else if(N[2] == '7')
    std::cout << "Yes\n";
  else
    std::cout << "No\n";
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;

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

	int N,D;
	cin >> N >> D;

	cout << (N + 2 * D) / (2 * D + 1) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    int n, x, num;
    while(1)
    {
        num = 0;
        scanf("%d %d", &n, &x);
        if((n == 0) && (x == 0)) break;
        for(int i=1; i<=n-2; i++)
            for(int j=i+1; j<=n-1; j++)
                for(int k=j+1; k<=n; k++)
                    if(i+j+k == x)
                        num++;
        printf("%d\n", num);
    }

    return 0;
}


Measured memory_bytes: 2692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt() * 2;

        if (a >= b) {
            System.out.println((a-b));
        } else {
            System.out.println(0);
        }
        sc.close();
    }    
}


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

int main(){
	int n;
	scanf("%d",&n);
	ll ans=0;
	
	for(int i=0;i<n;i++){
		ll a,b;
		scanf("%lld %lld",&a,&b);
		if(a>b) swap(a,b);
		ans+=(b-a+1);
	}
	
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

int n;
int d[55];

int cnt[55];

vector<int> newd;
vector<int> extra;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", d + i);
    for (int i = 1; i <= n; i++) {
        cnt[d[i]]++;
    }
    for (int i = 0; i <= 12; i++) {
        if (cnt[i] > 2) {
            printf("0"); return 0;
        } else if (cnt[i] == 2) {
            extra.push_back(i);
            extra.push_back(24 - i);
        } else if (cnt[i] == 1) {
            newd.push_back(i);
        }
    }
    int ans = 0;
    for (int msk = 0; msk < (1 << (newd.size())); msk++) {
        vector<int> seq;
        for (int j = 0; j < newd.size(); j++) {
            if (msk & (1 << j)) {
                seq.push_back(newd[j]);
            } else {
                seq.push_back(24 - newd[j]);
            }
        }
        seq.push_back(0);
        for (int j = 0; j < extra.size(); j++) {
            seq.push_back(extra[j]);
        }
        int mind = 100000;
        for (int i = 0; i < seq.size(); i++) {
            for (int j = 0; j < seq.size(); j++) {
                if (i == j) continue;
                if (seq[i] < seq[j]) continue;
                mind = min(mind, min(seq[i] - seq[j], 24 - seq[i] + seq[j]));
            }
        }
        ans = max(ans, mind);
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 3204
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	int K, T;cin >> K >> T;
	vector<int> a(T);
	for(int i = 0; i < T; i++)cin >> a[i];
	sort(a.begin(), a.end());
	int curr = a[T - 1], sum = 0;
	for(int i = 0; i < T - 1; i++)sum += a[i];
	int ans = curr - sum - 1;
	if(ans <= 0)ans = 0;
	cout << ans;
	return 0;
}


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

void solve(long long a, std::string s)
{
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long a;
    scanf("%lld", &a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

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

    fflush(stdin);
    string s;
    cin>>s;

    int k;
    cin>>k;

    for(i=0;i<n;i++)
        if(s[i]!=s[k-1])
            s[i]='*';

    cout<<s;

return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

if 2*N >= M:
  print(M // 2)
  exit()
  
## だいたい(M-2*N)/4 個追加でSを作ると良い
var1 = (M - 2*N) // 4 - 1
ans1 = min(N + var1, M - 2*var1)
var2 = (M - 2*N) // 4
ans2 = min(N + var2, M - 2*var2)
var3 = (M - 2*N) // 4 + 1
ans3 = min(N + var3, (M - 2*var3)//2)
ans = max(ans1, ans2, ans3)
print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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;
}
using namespace std;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}


void solve(){
    ll a,b;
    cin>>a>>b;
    if(a*b<=0)cout<<"Zero\n";
    else if(a>0)cout<<"Positive\n";
    else {
      ll cnt=b-a+1;
      if(a==b)cout<<"Positive\n";
      if(cnt%2)cout<<"Negative\n";
      else cout<<"Positive\n";
    }
    return;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        T = input().rstrip()

        ans = 0
        for i, s in enumerate(S):
            if s == T[i]:
                ans += 1
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38384
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
ans = sum(A)
d = defaultdict(lambda:0)
for i in range(N):
    d[A[i]] += 1

Q = int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]

for i in range(Q):
    b,c = BC[i]
    ans += d[b]*(c-b)
    d[c] += d[b]
    d[b] = 0
    print(ans)

Measured memory_bytes: 106012
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static class Component {
		int lux, luy, rdx, rdy;
		ArrayList<Component> child;
		String name;
		
		public Component(String name, int lux, int luy, int rdx, int rdy) {
			super();
			this.name = name;
			this.lux = lux;
			this.luy = luy;
			this.rdx = rdx;
			this.rdy = rdy;
			
			child = new ArrayList<Component>();
		}
		
		public boolean is_hit(int x, int y){
			if(this.lux <= x && x <= this.rdx && this.luy <= y && y <= this.rdy){
				return true;
			}else{
				return false;
			}
		}
		
		public Component getHitChild(int x, int y){
			for(Component comp : child){
				if(comp.is_hit(x, y)){
					return comp;
				}
			}
			
			return null;
		}
		
		public int getChildSize(){
			return child.size();
		}
		
		public String toString(){
			return "<" + lux + ", " + luy + "> " + name + " <" + rdx + ", " + rdy + "> => " + child;
		}
	}
	
	public static int parse(Component owner, char[] input, int first, int last){
		if(input[first] != '<'){
			return last;
		}
		StringBuilder sb = new StringBuilder();
		
		int pos = first + 1;
		while(input[pos] != '>'){
			sb.append(input[pos]);
			pos++;
		}
		
		pos++;
		int lux = 0, luy = 0, rdx = 0, rdy = 0;
		
		while(input[pos] != ','){
			lux *= 10;
			lux += input[pos] - '0';
			pos++;
		}
		pos++;
		
		while(input[pos] != ','){
			luy *= 10;
			luy += input[pos] - '0';
			pos++;
		}
		pos++;
		
		while(input[pos] != ','){
			rdx *= 10;
			rdx += input[pos] - '0';
			pos++;
		}
		pos++;
		
		while(input[pos] != '<'){
			rdy *= 10;
			rdy += input[pos] - '0';
			pos++;
		}
		
		Component comp = new Component(sb.toString(), lux, luy, rdx, rdy);
		//System.out.println(sb.toString());
		if(owner != null){
			owner.child.add(comp);
		}
		
		while(input[pos] == '<' && input[pos + 1] != '/'){
			pos = parse(comp, input, pos, last);
		}
		
		//System.out.println(sb.toString() + " : " + (pos) + " : " + (pos + sb.length() + 3));
		return pos + sb.length() + 3;
	}

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

		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			char[] input = sc.next().toCharArray();
			Component owner = new Component("OUT OF MAIN PANEL", 0, 0, 10000, 10000);
			
			parse(owner, input, 0, input.length - 1);
			
			//System.out.println(owner);
			
			for(int i = 0; i < n; i++){
				Component just_hit = owner;
				
				final int x = sc.nextInt();
				final int y = sc.nextInt();
				
				while(just_hit.is_hit(x, y) && just_hit.getHitChild(x, y) != null){
					just_hit = just_hit.getHitChild(x, y);
				}
				
				System.out.println(just_hit.name + " " + just_hit.getChildSize());
			}

		}

		sc.close();
	}
}

Measured memory_bytes: 19660
module practiceA
  sub Main(ByVal args() as String)
    dim K as Integer
    dim A as Integer
    dim B as Integer
    K = Console.ReadLine()
    dim arr as String()
    arr=Split(Console.ReadLine())
    A=arr(0)
    B=arr(1)
    Console.WriteLine(if(can(k,a,b),"OK","NG"))
  end sub
  
  function can(k,a,b) as boolean
      dim n as integer
      for n = 1 to 1001
          if n*k >= a and n*k <= b then
              can = true
              exit function
          end if
      next
      can = false
  end function
end module

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

bool isSecond(int a, int b, int c) {
    if (a < b && b < c) {
        return true;
    } else if (a > b && b > c) {
        return true;
    } else {
        return false;
    }
}

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

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

    int cnt = 0;
    for (int i = 1; i < n-1; i++) {
        if (isSecond(p[i-1], p[i], p[i+1])) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int a, b, c;
	cin >> a >> b >> c;
	int d;
	cin >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	sp;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
    cin >> n;
    string w[n];
    bool bb=0;
    REP(i,n){
        cin >> w[i];
        if(i>0){
            REP(j,i){
                if(w[j]==w[i]) bb=1;
            }
            if(w[i][0]!=w[i-1][w[i-1].size()-1]) bb=1;
        }
    }
    cout << (bb ? "No" : "Yes") << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    
    int num = sc.nextInt();
    int[] counts = new int[4];
    String[] ans = {"AC","WA","TLE","RE"};
    String[] str = new String[num];
    for(int i = 0; i < num; i++){
    	str[i] = sc.next();
      	for(int j = 0; j < 4; j++){
        	if(ans[j].equals(str[i])){
            	counts[j]++;
            }
        }
    }

    for(int i = 0; i < 4; i++)
    	System.out.println(ans[i] + " x " + counts[i]);
    
  }
}

Measured memory_bytes: 63748
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long ll;

vector<int> edges[3001];

ll a[3001];

int n;

vector<int> vis(3001,false);


bool dfs(int s,int v,int cou)
{
	if(edges[v].size() == 0)
	{
		return cou % 2 == 1;
	}
	

	if(cou % 2 == 0)
	{

		bool ans = false;

		for(int to : edges[v])
		{
			ans = ans || dfs(s,to,cou + 1);

		}

		return ans;
	}
	else
	{
		bool ans = true;
		for(int to : edges[v])
		{
			ans = ans && dfs(s,to,cou + 1);

		}

		return ans;
	}
	return false;
}

	


int main()
{
	cin >> n;

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

	for(int i = 0;i < n - 1;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;
		y--;

		if(a[x] == a[y]) continue;

		if(a[x] > a[y]) swap(x,y);

		edges[y].push_back(x);
	}

	for(int i = 0;i < n;i++)
	{
		if(dfs(i,i,0))
		{
			cout << i + 1 << " ";
		}
	}

	return 0;




}





Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = Integer.parseInt(scan.next());
        scan.close();

        if (x >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35576
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
bitset<2003*2003> bb;
int n,a[2003];
int main()
{
	cin>>n; int s=0;
	for(int i=1;i<=n;++i) cin>>a[i],s+=a[i];
	bb[0]=1;
	for(int i=1;i<=n;++i)
		bb|=bb<<a[i];
	s=(s+1)/2;
	for(int i=s;;++i)
		if(bb[i])
		{
			printf("%d\n",i);
			return 0;
		}
}


Measured memory_bytes: 1792
def main():
    N = int(input())
    P = list(map(int, input().split(' ')))
    flags = [1 if i + 1 == p else 0 for i, p in enumerate(P)]
    seq_nums = list()
    n = 0
    for f in flags:
        if f == 1:
            n += 1
        elif n > 0:
            seq_nums.append(n)
            n = 0
    if n > 0:
        seq_nums.append(n)
    print(sum([(s - 1) // 2 + 1 for s in seq_nums]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 14008
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)

Measured memory_bytes: 314524
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (n, m): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    let result = if n == 1 {
        if m == 1 {
            1
        } else {
            m - 2
        }
    } else if m == 1 {
        n - 2
    } else {
        (m - 2) * (n - 2)
    };
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "2 2\n",
            "0\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "1 7\n",
            "5\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "314 1592\n",
            "496080\n",
        );
    }
}

Measured memory_bytes: 4352
use std::cmp::max;
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
    n: usize,
    h: [usize; n],
    }
    let mut ans = 0;
    let mut l = 0;
    let mut b = h[0];
    for i in 1..n {
        if b >= h[i] {
            b = h[i];
            l += 1;
        } else {
            b = h[i];
            ans = max(ans, l);
            l = 0;
        }
    }
    ans = max(ans, l);
    println!("{}", ans);
}


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

double xp,yp,xc,yc;

int tri(double *p,double *q,double *s,double *t,double *f,double *g){
	if(((*t-*s)*(*f-*p)-(*g-*s)*(*q-*p))>0) return 1;
	else return 0;
}

int main(){
	int flag=0;
	double x1,y1,x2,y2,x3,y3,xc,yc;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=-1){
		xc=(x1+x2+x3)/3; yc=(y1+y2+y3)/3; flag=0;
		if(tri(&x1,&x2,&y1,&y2,&xp,&yp)==tri(&x1,&x2,&y1,&y2,&xc,&yc)) flag++;
		if(tri(&x2,&x3,&y2,&y3,&xp,&yp)==tri(&x2,&x3,&y2,&y3,&xc,&yc)) flag++;
		if(tri(&x3,&x1,&y3,&y1,&xp,&yp)==tri(&x3,&x1,&y3,&y1,&xc,&yc)) flag++;
		if(flag==3) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 612
from collections import defaultdict
import sys
input=sys.stdin.readline


def get_dist(s, d, N):
    dist = [-1]*(N+1)
    dist[s] = 0
    q = [s]
    while q:
        a = q.pop()
        for b in d[a]:
            if dist[b]!=-1:
                continue
            dist[b] = dist[a] + 1
            q.append(b)
    return dist


def solve():
    N, u, v = map(int, input().split())
    d = defaultdict(list)
    for _ in range(N-1):
        A, B = map(int, input().split())
        d[A].append(B)
        d[B].append(A)
    du, dv = get_dist(u, d, N), get_dist(v, d, N)
    ds = [(i, j) for i, j in zip(du, dv) if i<j]
    ds.sort(key=lambda x:-x[1])
    print(ds[0][1]-1)


if __name__ == "__main__":
    solve()


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


void solve(long long X, long long A, long long B){
    if(-A+B <=0) cout << "delicious" << endl;
    else if(-A+B <=X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] List = new int[n];
		
		for(int i=0;i<n;i++) 
			List[i] = sc.nextInt();
		
		int q = sc.nextInt();
		
		for(int i=0;i<q;i++) {
			int count = 0;
			int b = sc.nextInt();
			int e = sc.nextInt();
			int k = sc.nextInt();
			
			for(int j=b;j<e;j++) 
				if(List[j] == k) count++;
			
			System.out.println(count);
		}
		
	}
}


Measured memory_bytes: 36204
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    readLine()!
    let arr = readInts()
    var result = 0
    var prev = -1
    for x in arr {
        if prev == -1 {
            prev = x
            continue
        }
        if prev > x {
            result += prev - x
        } else {
            prev = x
        }
    }
    print("\(result)")
}

main()


Measured memory_bytes: 21264
#include<cstdio>
using namespace std;
long long a,b,ans;
void solve()
{
    if(a==1&&b==1)ans=1;
    else if(a==1||b==1)ans=a*b-2;
    else ans=a*b-2*(a+b)+4;
}
main()
{
    scanf("%lld%lld",&a,&b);
    solve();
    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;


int main(void){
    int N;
    cin >> N;
    ll h[N];
    ll dp[N];
    
    for(int i = 0 ; i < N ; i++){
        cin >> h[i];
    }
    for(int i = 0 ; i < N ; i++){
        dp[i] = INF;
    }
    
    dp[0] = 0;
    for(int i = 1 ; i < N ; i++){
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1){
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
int main(){
    long long a,b,m,x,y,c;
    cin>>a>>b>>m;
    long long aa[a],bb[b],ans[m];
    f(i,0,a){
        cin>>aa[i];
    }
    f(i,0,b){
        cin>>bb[i];
    }
    f(i,0,m){
        cin>>x>>y>>c;
        ans[i]=aa[x-1]+bb[y-1]-c;
    }
    sort(aa,aa+a);
    sort(bb,bb+b);
    sort(ans,ans+m);
    cout<<min(aa[0]+bb[0],ans[0])<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

struct UnionFind {
    vector<int> par,si; 

    UnionFind(int N) : par(N), si(N,1) { 
        rep(i,0,N) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x); 
        y = root(y); 
        if (x == y) return; 
        si[y]+=si[x];
        par[x] = y; 
    }

    bool same(int x, int y) { 
      return root(x)== root(y);
    }
    int size(int x){
       return si[root(x)];
    }

};




void solve(){
  ll n,m;
  cin >> n  >> m;
  UnionFind u(n);
  rep(i,0,m) {
   ll a,b;
    cin >> a >> b;
    a--;
    b--;
    u.unite(a,b);
  }
  ll ans=0;
  rep(i,0,n) {
    ll tot=u.size(i);
    chmax(ans,tot);
  }
  
 cout << ans << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 11064
n, m = list(map(int, input().split()))

wa_count = [0] * n
is_accepted = [False] * n
ans_ac = 0
ans_wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
        if not is_accepted[p]:
            is_accepted[p] = True
            ans_ac += 1
            ans_wa += wa_count[p]
    else:
        wa_count[p] += 1

print(ans_ac, ans_wa)


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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<string> b(n);
    for (int i=0; i<m; i++){
        cin >> b[i];
    }
    for (int i=0; i<=n-m; i++){
        for (int j=0; j<=n-m; j++){
            bool matched = true;
            for (int k=0; k<m; k++){
                for (int l=0; l<m; l++){
                    if (a[i+k][j+l] != b[k][l]) {
                        matched = false;
                        break;
                    }
                }
                if (!matched) {
                    break;
                }
            }
            if (matched) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
void pitsu(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b||b>d){
        cout<<"No"<<"\n";
        return ;
    }
    if(c>=b){
        cout<<"Yes"<<"\n";
        return;
    }
    ll g=GCD(b,d);
    ll MAX=(b-a%g+g-1)/g*g+a%g-g;
    if(MAX>c)cout<<"No"<<"\n";
    else cout<<"Yes"<<"\n";
}
int main(){
    int t;
    cin>>t;
    while(t--)pitsu();
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int b, c1, c2, q1, q2;
		int ans1, ans2;
		
		while (true) {
			q1 = sc.nextInt();
			if (q1 == 0) {
				break;
			}
			b = sc.nextInt();
			c1 = sc.nextInt();
			c2 = sc.nextInt();
			q2 = sc.nextInt();
			ans1 = -1;
			ans2 = -1;
			
			for (int i = q2; 0 < i; i--) {
				int cost1 = c1 * i;
				int money = b - cost1;
				if (0 <= money && q1 <= money / c2 + i) {
					ans1 = i;
					ans2 = money / c2;
					break;
				}
			}
			
			if (0 < ans1 && 0 <= ans2) {
				System.out.println(ans1 + " " + ans2);
			} else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 20340