akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

const int MOD = (int)1e9 + 7;
const int kN = 5000 + 5;
std::vector<int> edges[kN];
int n;
bool vis[kN];
int parent[kN];
int sz[kN];
int que[kN];
int balance[kN];

int bfs(int source,int fa = -1) {
    int qf = 0,qe = 0;
    que[qe++] = source;
    parent[source] = fa;
    while (qf != qe) {
        int u = que[qf++];
        sz[u] = 1;
        balance[u] = 0;
        for (int v : edges[u]) {
            if (!vis[v] && parent[u] != v) {
                parent[v] = u;
                que[qe++] = v;
            }
        }
    }
    for (int i = qe - 1; i >= 0; -- i) {
        int u = que[i];
        if (i) {
            sz[parent[u]] += sz[u];
            balance[parent[u]] = std::max(balance[parent[u]],sz[u]);
        }
        balance[u] = std::max(balance[u],qe - sz[u]);
    }
    return qe;
}

int F[kN], Finv[kN], Inv[kN];

int binom(int a, int b)
{
    if (b < 0 || b > a) return 0;
    return F[a] * 1LL * Finv[b] % MOD * Finv[a - b] % MOD;
}

inline void add(int &a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
}

int calc(int root)
{
    bfs(root);
    std::vector<int> vec;
    for (int x : edges[root]) {
        vec.emplace_back(sz[x]);
    }

    static int g[2][kN];
    int cur = 0, nex = 1;
    int s = 0;
    g[0][0] = 1;
    for (int x : vec) {
        memset(g[nex], 0, sizeof(g[nex]));
        for (int i = 0; i <= s; ++ i) {
            for (int j = 0; j <= x; ++ j) {
                add(g[nex][i + j], g[cur][i] * 1LL * binom(x, j) % MOD * binom(x, j) % MOD * F[j] % MOD);
            }
        }
        s += x;
        std::swap(cur, nex);
    }
    int ret = 0;
    for (int i = 0; i <= s; ++ i) {
        add(ret, g[cur][i] * 1LL * F[n - i] % MOD * (i % 2 == 0 ? 1 : -1));
    }
    return ret;
}

int main()
{
    Inv[1] = 1;
    for (int i = 2; i < kN; ++ i)
        Inv[i] = (MOD - MOD / i) * 1LL * Inv[MOD % i] % MOD;
    F[0] = 1;
    Finv[0] = 1;
    for (int i = 1; i < kN; ++ i) {
        F[i] = F[i - 1] * 1LL * i % MOD;
        Finv[i] = Finv[i - 1] * 1LL * Inv[i] % MOD;
    }
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b); a --; b --;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }
    int root = n;
    {
        std::vector<std::pair<int, int>> vec;
        for (int i = 0; i < n; ++ i) {
            bfs(i);
            vec.emplace_back(balance[i], i);
        }
        std::sort(vec.begin(), vec.end());
        if (vec.size() > 1 && vec[0].first == vec[1].first) {
            printf("%d\n", F[n / 2] * 1LL * F[n / 2] % MOD);
        } else {
            root = vec[0].second;
            printf("%d\n", calc(root));
        }
    }
}


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

using namespace std;

#define int long long

int32_t main()
{
    int x, y;
    cin>>x>>y;

    int ans = 0;
    if(x==1 && y==1)
    {
        ans = 400000;
    }

    if(x==1)
        ans+=300000;
    if(x==2)
        ans+=200000;
    if(x==3)
        ans+=100000;

    if(y==1)
        ans+=300000;
    if(y==2)
        ans+=200000;
    if(y==3)
        ans+=100000;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

void main() {
	string s, t, u;
	uint a, b;

	auto st = readln.chomp.split(" ");
	s = st[0];
	t = st[1];
	auto ab = readln.chomp.split(" ");
	a = to!uint(ab[0]);
	b = to!uint(ab[1]);
	u = readln.chomp;

	if (u == s) {
		--a;
	} else if (u == t) {
		--b;
	}

	writeln(a, " ", b);
}


Measured memory_bytes: 256
//package AtCoder.Panasonic2020;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        List<Integer> q = new ArrayList<>(Arrays.asList(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
        ));
        int k = in.NI();
        out.println(q.get(k-1));
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 22996
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll calc(ll b,ll n){
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {
	
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll lc = n * m / gcd(n, m);
	if (s[0] != t[0]) {
		cout << -1 << endl;
		return;
	}

	ll si[100010];
	ll lenn = lc / n;
	map<ll, char> mp;

	for (ll i = 1,c = 1; i < n; i++,c++)
	{
		ll p = lenn * c;
		mp[p] = s[i];
	}

	ll lenm = lc / m;
	for (size_t i = 1, c = 1; i < m; i++, c++)
	{
		ll p = lenm * c;
		
		if (mp.count(p) && mp[p] != t[i]) {
			cout << -1 << endl;
			return;

		}
	}
	cout << lc << endl;
}


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



Measured memory_bytes: 11904
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++) 
typedef long long ll;
using namespace std;

class UnionFind {
public:
    vector<int> parent;  //親ノード
    vector<int> Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(int n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
};
 
int main() {
    int n, m;
    cin >> n >> m;
 
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind Uni(n);
 
    vector<ll> ans(m);
    ans[m-1] = (ll)n*(n-1)/2;
    for(int i = m-1; i >= 1; i--) {
 
        if(Uni.same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ans[i-1] = ans[i] - (ll)Uni.size(a[i]) * Uni.size(b[i]);
            Uni.unite(a[i], b[i]);
        }
    }
 
    rep(i, m) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3712
import math
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

A.sort()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
Ne = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, Ne + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



maxi = 0
for i in range(K-1,N):
    maxi += A[i]*cmb(i, K-1, mod)

mini = 0
A.sort(reverse=True)
for j in range(K-1,N):
    mini += A[j]*cmb(j, K-1, mod)

print((maxi-mini)%mod)


Measured memory_bytes: 20168
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let k:usize = read();
    if k > b - a {
        for i in a..=b {
            println!("{}", i);
        }
    } else {
        for i in a..a+k {
            println!("{}", i);
        }
        for i in max(b-k+1, a+k)..=b {
            println!("{}", i);
        }
    }
}


Measured memory_bytes: 2144
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  ll n,m,ans=0;cin>>n;
  vector<string> a(n);
  rep(i,0,n){
    cin>>a[i];
  }
  cin>>m;
  vector<string> b(m);
  rep(i,0,m){
    cin>>b[i];
  }
  rep(i,0,n){
    ll tmp=0;
    rep(j,0,n){
      if(a[j]==a[i])tmp++;
    }
    rep(j,0,m){
      if(b[j]==a[i])tmp--;
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}




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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int digi_sum(int val)
{
  int ret = 0;
  while (val > 0) {
    ret += val % 10;
    val /= 10;
  }
  return ret;
}

int main()
{
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int s = digi_sum(i);
    if (A <= s and s <=B) { ans += i; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
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():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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

def solve():
    n = I()
    a = IR(n)
    dp = [float("inf")]*n
    m = max(a)
    for i in a:
        j = m-i
        ind = bisect.bisect_right(dp,j)
        dp[ind] = j
    print(len(dp)-dp.count(float("inf")))
    return

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


Measured memory_bytes: 48476
#include <iostream>

int main(){
  int A,B;
  int Add,Substract,Multiply;
  
  std::cin >> A >> B;

  Add = A + B;
  Substract = A - B;
  Multiply = A * B;

  if(Add >= Substract && Add >= Multiply){
    std::cout << Add << std::endl;
  }else if(Substract >= Add && Substract >= Multiply){
    std::cout << Substract << std::endl;
  }else if(Multiply >= Add && Multiply >= Substract){
    std::cout << Multiply << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    ll mod = 1000000007;

    int n, m;
    cin >> n >> m;
    
    
    vector<bool> flag(n+1, true);//flag[0]は未使用
    REP(i,0,m) {
        int a;
        cin >> a;// 1 <= a <= n-1
        flag[a] = false;
    }

    vector<ll> dp(n+1, 0);
    dp[0] = 1;
    dp[1] = 1;
    if (flag[1] == false) dp[1] = 0;

    REP(i,2,n+1) {
        if (flag[i]) {
            dp[i] += (dp[i-1] + dp[i-2]) % mod;
        }
        else {
            dp[i] = 0;
        }
    }

    cout << dp[n] << endl;
}

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

using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double t = 60.0*h+m;
    double h_x, h_y, m_x, m_y;
    h_x = a * cos(2.0*M_PI/(60*12) * t);
    h_y = a * sin(2.0*M_PI/(60*12) * t);
    m_x = b * cos(2.0*M_PI/60 * t);
    m_y = b * sin(2.0*M_PI/60 * t);
    double ans = sqrt((h_x-m_x)*(h_x-m_x)+(h_y-m_y)*(h_y-m_y));
    printf("%.10lf\n",ans);
}


Measured memory_bytes: 4184
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)
    val C = IntArray(N + 1)
    var total = 0L
    A.forEach { a ->
        total += C[a]
        C[a]++
    }
    A.forEach { a ->
        println(total - (C[a] - 1)) // - nC2 + (n-1)C2 = -(n-1)
    }
}

Measured memory_bytes: 99976
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  string s;cin>>s;

  
  REP(i,n){
    ans*=2LL;
    ans+=(ll)(s[i]-48);
    ans%=MOD;
  }
  ans++;
  ans*=2LL*n;
  ans%=MOD;
  vi pt(n/3+1,0);


  for(ll i=1;i<=n/3;i++){
    if (n%(i*2)==i){

      ll flg=0;
      for(int j=i;j<n;j++){
        
        if ((j/i)%2==0){
          if (s[j]<s[j%i]){
            flg=1;
            break;
          }
          if (s[j]>s[j%i]){
            flg=0;
            break;
          }
        }else{
          if (s[j]<(49-s[j%i]+48)){
            flg=1;
            break;
          }
          if (s[j]>(49-s[j%i]+48)){
            flg=0;
            break;
          }
        }
      //ある場合はflg0 ない場合はflg1
      }

        ll sm=0LL;
        REP(j,i){
          sm*=2LL;
          sm+=(ll)(s[j]-48);
          sm%=MOD;
        }
        sm++;
        sm=(sm-flg+MOD)%MOD;

        
        REP(jj,i){
          if (jj==0){
            continue;
          }
          //if ((jj*jj)>=i)break;
          if (i%jj==0){
            if ((i/jj)%2==1){
              sm=(sm-pt[jj]+MOD)%MOD;
            }
          }
        }
        

        pt[i]=sm;
        ans-=(sm*(2LL*n));
        ans+=sm*(2LL*i);
        ans%=MOD;
        ans=(ans+MOD)%MOD;
        //cout<<i<<endl;
    }
  }




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

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    n%=10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)cout<<"hon\n";
    else if(n==3)cout<<"bon\n";
    else cout<<"pon\n";
    return 0;   
}


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


using namespace std;

int main() {
    int n;
    cin>>n;
    map<string,int> m1;
    int max1=0;
    for(int i=0;i<n;i++){
        string s1;
        cin>>s1;
        m1[s1]++;
        max1=max(m1[s1],max1);
    }
    //vector<string> v1;
    for(auto x:m1){
        if(x.second==max1){
    //        v1.push_back(x.first);
            cout<<x.first<<"\n";      
        }
    }
    
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    ll n;cin>>n;
   ll ans=power(10,n)-2*power(9,n)+power(8,n);
    if(ans<0) ans=(mod-(-ans)%mod)%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K,A,B;
    cin >>K>>A>>B;

    int res = 0,n=0;
    for (int i = 0; i < 1100; i++)
    {
        if(A<=n&&n<=B){
            res = 1;
            break;
        }
        n+=K;
    }

    if(res == 1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    string s;
    cin >> s;
    int ds = 0;
    repe(i, s) ds += i - '0';
    if(ds == 1) ds = 10;
    cout << ds << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,M;
	cin>>N>>M;
	vector<int>cnt(N+1);
	for(int i=0;i<2*M;i++){
		int a;
		cin>>a;
		cnt.at(a)++;
	}
	for(int i=1;i<=N;i++)cout<<cnt.at(i)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long N,M,Q;
struct x{
    int a,b,c,d;
};


template< typename T >
vector< T > convert_base(T x, T b) {
  vector< T > ret;
  T t = 1, k = abs(b);
  while(x) {
    ret.emplace_back((x * t) % k);
    if(ret.back() < 0) ret.back() += k;
    x -= ret.back() * t;
    x /= k;
    t *= b / k;
  }
  if(ret.empty()) ret.emplace_back(0);
  reverse(begin(ret), end(ret));
  return ret;
}


vector<int> add(vector<int>&a,int N,int M,int k){

    a[k]++;
    if((k<N-1&&a[k]>a[k+1])||a[k]==M){
        if(k==N-1){a=vector<int>(0);return a;}
        for(int i=0;i<=k;i++)a[i]=0;
        add(a,N,M,k+1);
    }
    return a;

}

int main(){
    cin>>N>>M>>Q;
    vector<x>v(Q);
    for(int i=0;i<Q;i++){
        cin>>v[i].a>>v[i].b>>v[i].c>>v[i].d;
    }
    long long ans=0LL;

    vector<int>end(N,M),a(N,0);
    for(int i=0;;i++){
        long long tmp=0LL;
        
        // for(auto x:a)cout<<x<<" ";
        // cout<<endl;
        
        for(int q=0;q<Q;q++){
            if(a[v[q].b-1]-a[v[q].a-1]==v[q].c)tmp+=v[q].d;
        }
        ans=max(ans,tmp);
        add(a,N,M,0);
        if(a.size()==0)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
n=int(input())
c=1
f=1
a=list(map(int,input().split()))
for i in range(0,n):
  if a[i]==0:
    f=1
    c=0
    break
  if f==0: continue
  if c*a[i]>1e18:
    c*=a[i]
    f=0
    continue
  c*=a[i]
if f==0: print(-1)
else: print(c)

Measured memory_bytes: 21636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll inf  = 1e6+5;
vector<int> freq (5);
int main() {
  int a,b; cin >> a >> b;
  vector<string> words (a);
  for (int i = 0; i < a; i++){
      cin >> words[i];
  }
  sort(words.begin(), words.end());
  for (string i : words){
      cout << i;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

ll dp[1001][1001];

int main() {
	ll ans = 0;
	makei(N);
	makei(M);
	vector<vll> v(3);
	rep(N) {
		ll a, b, c;
		cin >> a >> b >> c;
		v[0].push_back(a);
		v[1].push_back(b);
		v[2].push_back(c);
	}
	For(k, (1 << 3)) {
		For(i, 1001) {
			For(j, 1001) {
				dp[i][j] = -1e18;
			}
		}
		dp[0][0] = 0;
		int cnt = 0;
		For(i, N) {
			For(j, M + 1) {
				ll w = 0;
				For(l, 3) {
					if (k & (1 << l))w += v[l][i];
					else w -= v[l][i];
				}
				if (j == 0)dp[i + 1][j] = dp[i][j];
				else dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + w);
			}
		}
		maxi(ans, dp[N][M]);
	}
	say(ans);
}

Measured memory_bytes: 8064
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000 + 5;
const int M = 200000 + 5;

int n, m;
int vis[N], flag;
vector<pair<int, int>> adj[N];
int ans[M];
int minv[N];

void dfs(int u, int mark = 1, int forbid = -1)
{
    if (u == forbid) return;
    if (vis[u]) return;
    vis[u] = mark;
    for (auto e : adj[u]) {
        int v = e.first;
        dfs(v, mark, forbid);
    }
}

void solve()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u, --v;
        adj[u].push_back(make_pair(v, i));
    }

    for (int i = 0; i < n; i++) {
        memset(vis, 0, sizeof vis);
        dfs(i);
        for (int u = 0; u < n; u++) {
            if (! vis[u]) continue;
            for (auto e : adj[u]) {
                if (e.first != i) continue;
                ans[e.second] ++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        memset(vis, 0, sizeof vis);
        for (auto e : adj[i]) {
            dfs(e.first, e.second + 1, i);
        }
        for (int j = 0; j < n; j++) {
            minv[j] = vis[j];
        }
        memset(vis, 0, sizeof vis);
        for (auto e = adj[i].rbegin(); e != adj[i].rend(); e++) {
            dfs(e->first, e->second + 1, i);
        }
        for (auto e : adj[i]) {
            int v = e.first;
            if (e.second + 1 != minv[v] || e.second + 1 != vis[v]) {
                ans[e.second] += 2;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        puts(ans[i] == 3 || ans[i] == 0 ? "same" : "diff");
        //cout << ans[i] % 2 << ' ' << ans[i] / 2 << endl;
    }

}

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



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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


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

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VL a(n);
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    
    ll ans = 0;
    
    bool found;
    do {
        found = false;
    
        FOR(i,0,n-1) if (a[i] >= n) {
            found = true;
            
            ll here = a[i] / n;
                        
            ans += here;
            a[i] %= n;
        
            FOR(j,0,n-1) if (j != i) {
                a[j] += here;
            }
        }
    } while (found);
    
    cout << ans;

    return 0;
}

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


Measured memory_bytes: 256
using System;

namespace AtCoder.ABC093
{
    class b
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = int.Parse(spl[0]);
            var B = int.Parse(spl[1]);
            var K = int.Parse(spl[2]);
            if (B - A + 1 <= K * 2)
            {
                for(var i = A; i <= B; ++i)
                {
                    Console.WriteLine(i);
                }
            }
            else
            {
                for (var i = A; i < A + K; ++i)
                {
                    Console.WriteLine(i);
                }
                for (var i = B - K + 1; i <= B; ++i)
                {
                    Console.WriteLine(i);
                }
            }
        }
    }
}


Measured memory_bytes: 13140
const val COLORS = "RYGB"

fun main(args: Array<String>) {
  val (h, w, d) = readLine()!!.split(" ").map { it.toInt() }
  val board = Array(h, { CharArray(w) })
  for (y in 0 until h) {
    for (x in 0 until w) {
      val s = x + y
      val t = x - y + 2 * d * 1000
      val cs = if ((s % (2 * d)) < d) 0 else 1
      val ct = if ((t % (2 * d)) < d) 0 else 1
      board[y][x] = COLORS[2 * ct + cs]
    }
  }

  for (y in 0 until h) {
    println(String(board[y]))
  }
}


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

int main() {
    int N,t,l;
    cin >> N;
    vector<int> p;

    p.push_back(1);
    t = 1;
    while((t*=6) <= N)
        p.push_back(t);
    t = 1;
    while((t*=9) <= N)
        p.push_back(t);
    l = p.size();

    vector<vector<int>> dp(l+1, vector<int>(N+1,INF));
    rep(i,l+1)
        dp.at(i).at(0) = 0;

    rep(i,l)
        rep(j,N+1)
            if(p.at(i) > j)
                dp.at(i+1).at(j) = dp.at(i).at(j);
            else
                dp.at(i+1).at(j) = min(dp.at(i).at(j), dp.at(i+1).at(j-p.at(i))+1);
    cout << dp.at(l).at(N) << endl;
}

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

using namespace std;

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

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

    int ans=0;
    for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
        if(p[i-1]>p[i] && p[i]>p[i+1]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll a,ll b) {
    while(b!=0) {
        ll t=a%b;
        a=b;
        b=t;
    }
    return(a);
}
int main()
{
	ll a,b,GCD;
	cin>>a>>b;
	GCD=__gcd(a,b);
	vector<ll> num;
	for(int i=1;i<=sqrt(GCD);i++){
		if(GCD%i==0)
			if(GCD/i==i)num.push_back(i);
			else num.push_back(GCD/i),num.push_back(i);
	}
	sort(num.begin(),num.end(),greater<ll>());
	ll i=0,pd=0;
    while(i<num.size()){
        ll j=i+1;
        while(j<num.size()){
            if (gcd(num[i],num[j])!=1){
                num.erase(num.begin()+i);
                pd=1;
            }
            j++;
        }
        i++;
        if(pd==1)
        {
        	pd=0;i--;
		}
    }
	cout<<num.size();
	return 0;
}


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

typedef struct str_node node_t;
typedef struct str_node {
    int64_t id;
    bool visited;
    node_t* next;
}node_t;
int main(void) {
    int64_t N,K;
    int64_t A;
    int64_t cnt = 0;
    int64_t start = -1;
    int64_t rem;
    int64_t mod = 0;
    node_t* p;

    cin >> N >> K;

    vector<node_t> node(N);
    for(int i=0;i<N;i++) {
        node[i].id = i;
        cin >> A;
        node[i].next = &node[A-1];
        node[i].visited = false;
    }

    p = &node[0];
    for(int i=0;i<K;i++) {
        p->visited = true;
        p = p->next;
        cnt++;
        if(p->visited == true) {
            start = p->id;// ループの開始
            break;
        }
    }

    if(start >= 0) {    
        // ループがある場合
        p->visited = false;
        while(p->next->visited){
            p = p->next;
            mod++;
        }
        rem = (K - (cnt-mod-1)) % (mod + 1);
        p = &node[start];
        for(int i=0;i<rem;i++) {
            p = p->next;
        }
    }

    cout << p->id + 1 << "\n";

    return 0;
}


Measured memory_bytes: 7920
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF INT_MAX
using namespace std;
const int N=111;
const int M=N*3;
int n,W;
int a[110],b[110];
int dp[N][N][M];
int main(){
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)
			for(int h=0;h<=3*j;h++){
				dp[i+1][j][h]=max(dp[i][j][h],dp[i+1][j][h]);
				dp[i+1][j+1][h+a[i]-a[0]]=max(dp[i+1][j+1][h+a[i]-a[0]],dp[i][j][h]+b[i]);
			}
	int ans=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=3*i;j++){
			LL c=(LL)a[0]*i+j;
			if(c<=W)ans=max(ans,dp[n][i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12928
import java.util.*;

public class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int bndresult = 0;
    int cnt = 0;
    
    ArrayList<Integer> bndList = new ArrayList<Integer>();
    
    for(int i = 0; i<=n; i++){
      	if(i != 0){
        int l = sc.nextInt();
      	bndresult = bndresult + l;
        }
      	bndList.add(bndresult);
    }
    
    for (int i=0; i<bndList.size(); ++i){
      int z = bndList.get(i);
      if(z <= x){
        cnt++;
      }
    }
    System.out.println(cnt);  
  }
 }


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

int main() {
  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC" << endl;
  }
  else if(1200<=R && R<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
from collections import deque
def bfs(yy,xx):
  global ans
  d=[[float('inf')]*w for i in range(h)]
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  q=deque([])
  q.append((yy,xx))
  d[yy][xx]=0
  while q:
    y,x=q.popleft()
    for i in range(4):
      ny,nx=y+dy[i],x+dx[i]
      if 0<=ny<h and 0<=nx<w and s[ny][nx]=='.' and d[ny][nx]==float('inf'):
        d[ny][nx]=d[y][x]+1
        q.append((ny,nx))
        if ans<d[ny][nx]:
          ans=d[ny][nx]
  return ans
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
a=0
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      a=max(a,bfs(i,j))
print(a)

Measured memory_bytes: 46428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		String S        = scanner.next();
		//上2桁を取得し数値に変換
		int front = Integer.parseInt(S.substring(0,2));
		//下2桁を取得し数値に変換
		int back  = Integer.parseInt(S.substring(2,4));
		
		//AMBIGUOUSの場合
		if((front != 0 && front <= 12) && (back != 0 && back <= 12)){
			
			System.out.println("AMBIGUOUS");
			
		//YYMMの場合
		}else if(back != 0 && back <= 12){
			
			System.out.println("YYMM");
			
		//MMYYの場合
		}else if(front != 0 && front <= 12){
			
			System.out.println("MMYY");
		//NAの場合
		}else{
			
			System.out.println("NA");
		}
	}
}


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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m;
ll s;

int main()
{
    cin >> s;
    printf("%.10lf", (1.0*s/3)*(1.0*s/3)*(1.0*s/3));

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]

print('Yes' if len(Counter(st())) > 1 else 'No')

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

using namespace std;
typedef pair<int, int> P;

bool comp(const P& p1, const P& p2) {
    if (p1.first > p2.first) return true;
    if (p1.first == p2.first && p1.second < p2.second) return true;
    else return false;
}

int main(void) {
    int n, m, c;
    while (cin >> n >> m, n) {
        P cnt[110];
        for (int i = 0; i < m; i++) {
            cnt[i].first = 0;
            cnt[i].second = i;
        }

        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                cin >> c;
                cnt[j].first += (c == 1);
            }
        
        sort(cnt, cnt + m, comp);

        for (int i = 0; i < m; i++) {
            if (i) cout << " ";
            cout << cnt[i].second + 1;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAXN = 1001024;

// 結果を格納する変数
int prime[MAXN]; // n 以下の素数のうち i 番目の素数
bool is_prime[MAXN]; // 整数 i が素数であるかどうか

int sieve(int n) {
    int res = 0;
    fill(is_prime, is_prime + MAXN, true);
    is_prime[0] = is_prime[1] = false; // 0 と 1 は素数ではない。
    for(int i = 2; i <= n; ++i) {
        if(!is_prime[i]) continue;
        prime[res++] = i;
        for(int j = 2 * i; j <= n; j += i) is_prime[j] = false; // 素数 i の倍数は素数ではない (ふるい(篩)にかける)
    }
    return res;
}


signed main(){

    sieve(200000);
    while(1){
        int n; cin >> n;
        if(!n) break;
        int ans = 5;
        int i = 1;
        while(1){
            if(prime[i] > n) break;
            if(is_prime[prime[i] - 2]){
                ans = prime[i];
            }
            i++;
        }
        cout << ans - 2 << " " << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4192
#include <stdio.h>
#include<string.h>
int main()
{
  
   char a[10],b[10],c[10];
  scanf("%s %s %s",a,b,c);
   if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
   {
       printf("YES");
   }else{
       printf("NO");
   }
    return 0;
}


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

int main() {
	int n, t, a, h, mn = 100001000, num;
	cin >> n >> t >> a;

	for (int i = 1; i <= n; i++) {
		cin >> h;
		if (mn > abs(1000 * a - (1000 * t - h * 6))) {
			mn = abs(1000 * a - (1000 * t - h * 6));
			num = i;
		}
	}
	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[20];
int main()
{
	long long n;
	cin>>n;
	int ans=1;
/*while(n)
	{
		
		h*=26;
		if(n>h)
		{
			ans++;
		}
		else
		break;
	}*/ 
	while(n)
	{
		n-=1;
		a[ans]='a'+n%26;
		n/=26;
		ans++;
	}
	for(int i=ans-1;i>=1;i--)
	{
		cout<<a[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main() {

 char S[4];
 int i=0;
 int a=0;

 int ret= scanf("%s",S);
 if( ret == EOF ) {
    printf( "scanfでエラー\n" );
    return -1;
  }

 for ( i=1;i<=3;i++){
  if(S[i]==S[i-1]){
    a=1;
  }
 }
 if(a==1){
  printf("Bad");
 }
 else if(a==0){
  printf("Good");
 }
 return (0);
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1005;
const int   M   = 3e5 + 5;

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

    int n;  cin >> n;
    int a;  cin >> a;
    int b;  cin >> b;

    if (a + b - 1 > n || 1ll * a * b < n)   {
        cout << -1;
        return  0;
    }
    for(int i = 1 ; a > 0 ;)    {
        int c = min(b,n - i + 2 - a);

        for(int j = i + c - 1 ; j >= i ; --j)
            cout << j << " ";
        
        i += c;
        a -= 1;
    }
}

Measured memory_bytes: 2176
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N = ri()
a = rli()

s = [a[0]]
for i in range(1, N):
    s.append(s[i-1] + a[i])

ans = 1145148101919
for i in range(N-1):
    ans = min(ans, abs(2*s[i]-s[-1]))

print(ans)

Measured memory_bytes: 23792
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<map>
#include<set>
using namespace std;

int  main()
{   
    int n;
    cin >> n;
    set<string> str;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        str.insert(s);
    }
    cout << str.size() << endl;
}

Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;  
    while(t--)
    {
        int a,b,x;
        cin>>x>>a>>b;
        int d = b-a;
        if(d<=0)
        {
            cout<<"delicious";

        }
        else if( d <= x)
            cout<<"safe";
        else
            cout<<"dangerous";

    }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main(void) {
	char s[2000], ans[2000];
	int w, l, sum = 0, a = 0, i;
	scanf("%s", s);
	scanf("%d", &w);
	l = strlen(s);
	while (1) {
		if (sum >= l) {
			break;
		}
		ans[a] = s[sum];
		sum += w;
		a++;
	}
	for (i = 0; i < a; i++) {
		printf("%c", ans[i]);
	}

}

Measured memory_bytes: 128
// edpc_g
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


struct Graph {

    int n;

    vector<vector<int>> edges;
    vector<vector<int>> rev;
    vector<int> memo;

    Graph(int n): n(n), edges(n), rev(n){}


    void add_edge(int u, int v){
        edges[u].emplace_back(v);
        rev[v].emplace_back(u);
    }

    vector<int> topological_sort(){
        queue<int> q;

        REP(i, n){
            if (rev[i].empty()) q.push(i);
        }

        vector<int> ret;
        while (!q.empty()){
            int u = q.front(); q.pop();
            ret.emplace_back(u);

            for (auto v: edges[u]){
                rev[v].erase(remove(ALL(rev[v]), u), rev[v].end());
                if (rev[v].empty()){
                    q.push(v);
                }
            }
        }
        return ret;
    }

    int dfs(int u){

        if (memo[u] != -1) return memo[u];

        int tmp = 0;
        for (auto v: edges[u]){
            tmp = max(tmp, dfs(v) + 1);
        }

        return memo[u] = tmp;

    }

    int dfs(){

        memo.assign(n, -1);

        int ret = 0;
        REP(i, n){
            ret = max(ret, dfs(i));
        }

        return ret;
    }

};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    Graph g(N);
    REP(i, M){
        int x, y;
        cin >> x >> y; x--; y--;
        g.add_edge(x, y);
    }

    int ans = g.dfs();

    print(ans);



    return 0;
}


Measured memory_bytes: 12928
#include <stdio.h>

int main()
{
    signed long h,n;
    signed short temp;
    scanf("%ld%ld",&h,&n);
     while(n>0)
    {
        scanf("%hd",&temp);
        h = h - temp;
        n--;
    }
   
    if(h>0)
    {
        printf("No");
    }else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 300010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    init();

    ll ans = 0;
    exrep(i, 0, n-k) {
        ll x = (a[(n-1)-i] + 2*mod - a[i])%mod;
        ll y = Comb((n-1)-i, k-1);
        ans += x*y;
        ans %= mod;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 8064
N, x = map(int, input().split())
input_list = [int(i) for i in input().split()]

result = 0

for i in range(N-1):
    count = 0
    if input_list[i] + input_list[i+1] > x:
        count = (input_list[i] + input_list[i+1] - x)
        result += count
        if input_list[i+1] < count:
            input_list[i+1] = 0
            input_list[i] -= (count - input_list[i+1])
        else:
            input_list[i+1] -= count

print(result)

Measured memory_bytes: 14540
import sys
input = sys.stdin.readline
N, D = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(N)]

D_2 =pow(D, 2)
count = 0
for i in range(N):
    a = pow(points[i][0], 2) + pow(points[i][1], 2)
    if D_2 >= a:
        count +=1

print(count)


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

int main() 
{
	int cnt=0;
	char s[1000];
	cin>>s;
	int n=strlen(s);
	if(n%2==0)
	{
		for(int i=0,j=n-1;i<n/2,j>n/2-1;i++,j--)
		{
			if(s[i]==s[j])
				continue;
			else
			{
				s[j]=s[i];
				cnt++;
			}
		}
	}
	else
	{
		for(int i=0,j=n-1;i<n/2,j>n/2;i++,j--)
		{
			if(s[i]==s[j])
				continue;
			else
			{
				s[j]=s[i];
				cnt++;
			}
		}
	}
	cout<<cnt;

	return 0;
}

Measured memory_bytes: 256