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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|


int main() {
    const double pi = acos(-1);
    double A,B,H,M;
    int As,Bs,Hs,Ms;
    cin >> A >> B >> H >> M;
    As = A; Bs = B; Hs = H; Ms = M;
    double turn = H * 60 + M;
    int tmp =  ( Hs * 60 + Ms ) % 60;
    double Aturn = ((double)turn / 360.0) * pi;
    double Bturn = ((double)tmp / 60.0) * 2 * pi;
    double diff = abs(Bturn - Aturn);

    double X = A * A + B * B - 2 * A * B * cos(diff); 
    cout << setprecision(24) << sqrt(X) << endl;
    //cout << Aturn << "\n";
    //cout << Bturn << "\n";
}

Measured memory_bytes: 4260
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 200;
int g[N][N];

int main() {
  int n, m, len;
  scanf("%d%d%d", &n, &m, &len);
  vector<int> p(len);
  for (int i = 0; i < len; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      g[i][j] = INF;
    }
    g[i][i] = 0;
  }
  while (m--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    --x; --y;
    g[x][y] = g[y][x] = z;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (g[i][j] > g[i][k] + g[k][j]) {
          g[i][j] = g[i][k] + g[k][j];
        }
      }
    }
  }
  int64 ret = 1LL << 60;
  do {
    int64 cur = 0;
    for (int i = 1; i < len; ++i) {
      int x = p[i - 1], y = p[i];
      cur += g[x][y];
    }
    ret = min(ret, cur);
  } while (next_permutation(p.begin(), p.end()));
  printf("%lld\n", ret);
  return 0;
}


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

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

    string S;
    cin >> S;

    int counter = 0;
    if(0 <= (int)S.find("a") && S.find("a") <= 2){
        counter++;
    }
    if(0 <= (int)S.find("b") && S.find("b") <= 2){
        counter++;
    }
    if(0 <= (int)S.find("c") && S.find("c") <= 2){
        counter++;
    }

    if(counter == 3){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, UVW):
    g = defaultdict(dict)
    for u, v, w in UVW:
        g[u][v] = w
        g[v][u] = w

    for i in range(1, N+1):
        if len(g[i]) == 1:
            s = i
            break

    C = [-1] * (N+1)
    C[s] = 0
    q = deque()
    q.append(s)
    while q:
        u = q.popleft()
        for v, w in g[u].items():
            if C[v] == -1:
                q.append(v)
                if w % 2 == 0:
                    C[v] = C[u]
                else:
                    C[v] = C[u] ^ 1

    for c in C[1:]:
        print(c)
    return


def main():
    N = read_int()
    UVW = [read_int_n() for _ in range(N-1)]
    slv(N, UVW)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71388
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var abc = Console.ReadLine().Split(' ').Select(num => Int32.Parse(num)).ToArray();
        var A = abc[0];
        var B = abc[1];
        var C = abc[2];
        var max = abc.Max();
        var tarinai = new List<int>();
        if (A != max) tarinai.Add(A);
        if (B != max) tarinai.Add(B);
        if (C != max) tarinai.Add(C);
        var ans = 0;
        for (int i=0;i<tarinai.Count();)
        {
            var sa = max - tarinai[i];
            if (1 < sa)
            {
                ans += sa / 2;
                tarinai[i] += (sa / 2) * 2;
                if (tarinai[i] == max) tarinai.RemoveAt(i);
                else i++;
            }
            else i++;
        }
        //二つ違う
        if (tarinai.Count()==2) ans++;
        //一つだけ違う
        else if (tarinai.Count()==1) ans += 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;
#define PI 3.14159265358979323846

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  int lens = s.size();
  string t2 = t.substr(0,lens);
  if( t2 == s ) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  long long a, b, q;
  cin >> a >> b >> q;

  vector<long long> s(a), t(b);
  for (int i = 0; i < a; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> t[i];
  }

  while (q--) {
    long long x; cin >> x;
    long long ans = 2e10+10;

    int sr = lower_bound(s.begin(), s.end(), x) - s.begin();
    int sl = sr-1;

    int tr = lower_bound(t.begin(), t.end(), x) - t.begin();
    int tl = tr-1;

    // 右に神社, 右に寺
    if (sr < a && tr < b) {
      long long rd1 = abs(s[sr] - x);
      long long rd2 = abs(t[tr] - x);
      ans = min(ans, max(rd1, rd2));
    }
    // 左に神社, 左に寺
    if (sl >= 0 && tl >= 0) {
      long long ld1 = abs(s[sl] - x);
      long long ld2 = abs(t[tl] - x);
      ans = min(ans, max(ld1, ld2));
    }
    // 右に神社, 左に寺
    if (sr < a && tl >= 0) {
      long long rd = abs(s[sr] - x);
      long long ld = abs(t[tl] - x);
      ans = min(ans, rd+ld+min(rd, ld));
    }
    // 左に神社, 右に寺
    if (sl >= 0 && tr < b) {
      long long rd = abs(t[tr] - x);
      long long ld = abs(s[sl] - x);
      ans = min(ans, rd+ld+min(rd, ld));
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, T;
    cin >> N >> T;
    vector<pii> v(N);
    int a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        v[i] = pii(a, b);
    }
    sort(v.begin(), v.end());

    vector<vector<int> > dp(N + 1, vector<int>(T+1));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < T; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            int k = j + v[i].first;
            if (k <= T - 1)
                dp[i+1][k] = max(dp[i][k], dp[i][j] + v[i].second);
        }
        dp[i+1][T] = max(dp[i][T], dp[i][T - 1] + v[i].second);
    }
    cout << dp[N][T] << '\n';
}

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

r = [[0]*n for _ in range(8)]
for i in range(n):
    x, y, z = map(int, input().split())
    r[0][i] = x+y+z
    r[1][i] = x+y-z
    r[2][i] = x-y+z
    r[3][i] = x-y-z
    r[4][i] = -x+y+z
    r[5][i] = -x+y-z
    r[6][i] = -x-y+z
    r[7][i] = -x-y-z

print(max(sum(sorted(r[i])[-m:]) for i in range(8)) if m != 0 else 0)


Measured memory_bytes: 3444
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = x; i < n; i++)
#define rrep(i, x, n) for(ll i = x; i >= n; i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cout<<"> "<<#this<<" : "<<this<<"\n"
typedef long long int ll;
typedef long double ld;
typedef pair< ll, ll > pii;
typedef vector< ll > vi;
typedef vector< vi > vvi;
const ll MOD = 1e9+7;
ld PI=3.1415926535897932384626;
ld EPS = 1e-9;
#define endl '\n'

int main() {
	boost;
	ll n;
	cin >> n;
	vi v(n);
	ll sum = 0;
	rep(i, 0, n) {
		cin >> v[i];
		if(i & 1) sum -= v[i];
		else sum += v[i];
	}
	rep(i, 0, n) {
		cout << sum << " ";
		sum = 2 * (v[i] - sum / 2);
	}
}
























Measured memory_bytes: 2176
import sys
import math
read = sys.stdin.buffer.read #全てまとめて文字列として格納
readline = sys.stdin.buffer.readline # 一行読む
readlines = sys.stdin.buffer.readlines # 全行リストに格納
H = int(read())
if H == 1:
  print(1)
  exit()

EXP = math.floor(math.log(H,2))
print(str(int(2**(EXP+1)-1)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	for(int i=start;i<to;i++)
		for(int j=i+1;j<=to;j++) res[i][j]=index;
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
}
int main(){
	cin>>n;
	dfs(1,n,1);

	for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";cout<<endl;
}



Measured memory_bytes: 1408
using System;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt=0;
            string str = Console.ReadLine();
            for (int i = 0; i < str.Length / 2; i++)
            {
                if (str[i] != str[str.Length - 1 - i])
                {
                    cnt++;
                }
            }
            Console.WriteLine( cnt);  
        }
    }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps=1e-9;

int field[19][15];
struct aa {
	int x;
	int y;
	bitset<20>bs;
	int turn;
};
bool operator<(const aa&l, const aa&r) {
	return l.x == r.x ? l.y == r.y ? l.bs.to_ulong() < r.bs.to_ulong() : l.y < r.y : l.x < r.x;
}bool operator==(const aa&l, const aa&r) {
	return l.x == r.x && l.y == r.y && l.bs.to_ulong();
}

int dx8[8] = { -1,-1,-1, 0, 1, 1, 1, 0 };
int dy8[8] = { -1, 0, 1, 1, 1, 0,-1,-1 };
pair<int, int> amove(const int way,const int fx, const int fy, bitset<20>&bs) {
	int nx = fx+dx8[way];
	int ny = fy + dy8[way];
	bool ok = false;
	while (1) {
		if (ny >= 18 && ok) {
			break;
		}
		if (nx < 0 || nx >= 15 || ny < 0)return make_pair(-1, -1);
		if (field[ny][nx] && bs[field[ny][nx] - 1]) {
			bs[field[ny][nx] - 1] = false;
		}
		else {
			break;
		}
		if (ny >= 18&&ok) {
			break;
		}
		ok = true;
		ny += dy8[way];
		nx += dx8[way];
	}
	if (!ok) {
		return make_pair(-100, -100);
	}
	else {
		return make_pair(nx, ny);
	}
}

int main() {
	int num = 1;
	int sx = 0, sy = 0;
	for (int i = 0; i < 19; ++i) {
		string st; cin >> st;
		for (int j = 0; j < 15; ++j) {
			if (st[j] == 'X') {
				field[i][j] = num;
				num++;
			}
			else if (st[j] == 'O') {
				field[i][j] = 0;
				sx = j;
				sy = i;
			}
			else {
				field[i][j] = 0;
			}
		}
	}
	queue<aa>que;
	que.push(aa{ sx,sy,bitset<20>((1 << (num-1)) - 1),0 });
	map<aa,int>mp;
	mp[que.front()]=0;
	int ans = -1;
	while (!que.empty()) {
		aa atop(que.front());
		que.pop();
		if (atop.y >= 18) {
			if (atop.y == 18) {
				if (atop.x < 0 || atop.x >= 15)continue;
			}
			ans = atop.turn;
			break;
		}
		for (int way = 0; way < 8; ++way) {
			bitset<20>bs(atop.bs);
			pair<int, int>p(amove(way, atop.x, atop.y, bs));
			if (p.first != -100) {
				if (mp.find(aa{ p.first,p.second,bs, 0 }) == mp.end()) {
					mp[aa{ p.first,p.second,bs,0 }] = atop.turn + 1;
					que.push(aa{ p.first,p.second,bs,atop.turn + 1 });
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) ;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

ll n,k;
ll p[N];
ll c[N];
int vis[5002];

main()
{
    ll a=29544642561,b=29507023469;
    //cout<<(a>=b)<<endl;
    cin>>n>>k;
    for(ll i=1;i<=n;i++)   cin>>p[i];
    for(ll i=1;i<=n;i++)   cin>>c[i];

    ll ans=-1e18;
    for(ll i=1;i<=n;i++)
    {
//        cout<<endl<<endl;
//        dbg(i);
        vector<ll>now;
        vector<ll>cs;
        vector<ll>go,cyc;

        ll cur=i;
        ll al=0;
        memset(vis,0,sizeof vis);

        while(now.size()<k)
        {


            cur=p[cur];

            if(vis[cur]==4)
                break;
            vis[cur]++;

            go.push_back(cur);
            now.push_back(c[cur]);
            al+=c[cur];
            cs.push_back(al);
            if(vis[cur]==4)
                cyc.push_back(c[cur]);

        }
//        if(i==5)
//        {
//            for(ll u:go)
//                cout<<u<<' ';
//            cout<<endl;
//            //return 0;
//        }

        if(now.size()==k)
        {
            for(ll u:cs)
            {
                ans=max(ans,u);
            }
        }
        else
        {
            for(ll u:cs)
            {
                ans=max(ans,u);
            }
            ll sz=cyc.size();
            //dbg(sz);
            ll al=cs[cs.size()-cyc.size()-1];
           // dbg(al);
            ans=max(ans,al);
            ll cycsum=0;
            for(ll u:cyc)
            {
                cycsum+=u;
            }
            dbg(cycsum);

            ll temp=(k-(cs.size()-cyc.size()))/sz;

            ll koyta=max(0LL,temp-1);
            ll tot=(cs.size()-cyc.size())+koyta*sz;

            ll baki=k-tot;

            dbg(koyta);
            dbg(baki);
            //cout<<baki<<endl;
            cycsum*=koyta;
            cycsum+=al;
            dbg(cycsum);
            for(int i=0;i<sz;i++)
                cyc.push_back(cyc[i]);


            for(ll i=0;i<baki;i++)
            {
                cycsum+=cyc[i];
               // cout<<i<<' '<<cycsum<<endl;
                ans=max(ans,cycsum);
            }
        }
        //cout<<i<<' '<<ans<<endl;
    }
    cout<<ans;

}


Measured memory_bytes: 4104
#include <stdio.h>
int main(void)
{
	int n, i, k=0, m;
	scanf("%d", &n);
	
	int a[n];
	for(i = 0; i < n; i++)scanf("%d", &a[i]);
	
	int f=1;
	
	while(f==1){
		f=0;
		for(i = n-1; i >= 1; i--){
			if(a[i] < a[i-1]){
				m = a[i];
				a[i] = a[i-1];
				a[i-1] = m;
				k++;
				f=1;
			}
		}
	}
	
	for(i =0; i < n; i++){
		if(i!=n-1)printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	printf("%d\n", k);
	
	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <cmath>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		int h, m;
		scanf("%d%*c%d", &h, &m);
		double theta_l = h * 30 + (double)m / 2;
		double theta_s = m * 6;
		double theta = fabs(theta_l - theta_s);
		if(theta > 180)
		{
			theta = 360 - theta;
		}
		if(0 <= theta && theta < 30)
		{
			cout << "alert" << endl;
		}
		else if(30 <= theta && theta < 90)
		{
			cout << "warning" << endl;
		}
		else
		{
			cout << "safe" << endl;
		}
	}
}

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

Measured memory_bytes: 0
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	cout<<(n-1)*(m-1)<<"\n";
	

	return 0;
}



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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (B <= A) {
    cout << "delicious" << endl;
  } else if ( X + A - B >= 0) {
    cout << "safe" << endl;
  	} else {
      cout << "dangerous" << endl;
  }
}


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

#include <cstring>

using namespace std;

#define MAXL 100000

int first[26];
int nxt[MAXL + 1][26];

int main(){
  string s,t;

  cin >> s >> t;

  memset(first, -1, sizeof first);
  int Ls = s.size();

  for(int i = 0;i < Ls;++i){
    int x = s[i] - 'a';

    if(first[x] == -1)
      first[x] = i;
  }

  memset(nxt, -1, sizeof nxt);

  for(int i = Ls - 1;i >= 0;--i){
    for(int j = 0;j < 26;++j){
      nxt[i][j] = nxt[i + 1][j];
    }

    if(i + 1 < Ls){
      int x = s[i + 1] - 'a';
      nxt[i][x] = i + 1;
    }
  }

  long long ans = 0;
  int turns = 0;
  int pos = -1;
  int Lt = t.size();

  for(int i = 0;i < Lt;){
    int x = t[i] - 'a';

    if(pos == -1){
      ++turns; ++i;
      pos = first[x];

      if(pos == -1){
        ans = -1;
        break;
      }
    }else{
      pos = nxt[pos][x];
      if(pos != -1) ++i;
    }

    //cout << t[i] << " " << pos << endl;
    ans = (long long)(turns - 1) * Ls + pos + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <vector>
//#include "../cxx-prettyprint/prettyprint.hpp"

int main() {
    int H, W;
    std::cin >> H >> W;

    std::vector<std::vector<char>> S;
    S.assign(H + 2, std::vector<char>(W + 2, '_'));
    for (int i = 1; i <= H; i ++) {
        for (int j = 1; j <= W; j ++) {
            std::cin >> S[i][j];
        }
    }

    for (int i = 1; i <= H; i ++) {
        for (int j = 1; j <= W; j ++) {
            if (S[i][j] == '.') {
                int count =
                        (S[i - 1][j - 1] == '#') + (S[i - 1][j] == '#') + (S[i - 1][j + 1] == '#') +
                        (S[i][j - 1] == '#') + (S[i][j + 1] == '#') +
                        (S[i + 1][j - 1] == '#') + (S[i + 1][j] == '#') + (S[i + 1][j + 1] == '#');
                std::cout << count;
            } else {
                std::cout << S[i][j];
            }
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 256
n=int(input())
nana=[7,5,3]
def check(x):
    s=str(x)
    d=1 if all(s.count(str(nana[i]))>=1 for i in range(3) ) else 0
    return (d and x<=n)

def dfs(x):
    res=0
    if x>n:
        return 0
    if check(x):
        res+=1
    for i in range(3):
        res+=dfs(10*x+nana[i])
    return res
 
print(dfs(0))

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

#define mod 1000000007
#define MAX_N 2000100
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long rect(int r, int c) {
    return combination(c+r+2, r+1) - 1;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    GetInv(); GetFactorial();
    long long r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    long long ans = rect(r1-1, c1-1) + rect(r2, c2) - rect(r1-1, c2) - rect(r2, c1-1);
    cout << (ans % mod + mod) % mod << "\n";
    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

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

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

int32_t main()
{
    FASTIO;

    int x;
    cin >> x;
    if(x >= 30) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    print(YES if S[2]==S[3] and S[4]==S[5] else NO)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};
using Graph = vector<vector<edge> >;

int N, M, S, T, U, V;
Graph graph;
vint dijkstra(int s) {
  vint mincost(N, inf);
  mincost[s] = 0;
  priority_queue<Pi, vector<Pi>, greater<Pi> > que;
  que.emplace(0, s);
  while(!que.empty()) {
    Pi p = que.top(); que.pop();
    int v = p.second;
    if(mincost[v] < p.first) continue;
    for(auto e : graph[v]) {
      if(mincost[v]+e.cost < mincost[e.to]) {
	mincost[e.to] = mincost[v]+e.cost;
	que.emplace(mincost[e.to], e.to);
      }
    }
  }
  return mincost;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M >> S >> T >> U >> V;
  --S, --T, --U, --V;
  graph.resize(N);
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, c);
  }
  auto distS = dijkstra(S);
  auto distT = dijkstra(T);
  auto distU = dijkstra(U);
  auto distV = dijkstra(V);
  vint id(N);
  iota(all(id), 0);
  sort(all(id), [&](int i, int j)->bool{
      return distS[i] < distS[j];
    });
  int ans = inf;
  vint dp(N, inf);
  for(int i : id) {
    chmin(dp[i], distU[i]);
    for(auto e : graph[i]) {
      if(distS[i]+e.cost+distT[e.to] == distS[T]) {
	chmin(dp[e.to], dp[i]);
      }
    }
  }
  rep(i, N) chmin(ans, dp[i]+distV[i]);
  vint dp2(N, inf);
  for(int i : id) {
    chmin(dp2[i], distV[i]);
    for(auto e : graph[i]) {
      if(distS[i]+e.cost+distT[e.to] == distS[T]) {
	chmin(dp2[e.to], dp2[i]);
      }
    }
  }
  rep(i, N) chmin(ans, dp2[i]+distU[i]);
  cout << ans << endl;

  return 0;
}



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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    cout << abs(A.at(0) - A.at(N - 1)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mk make_pair
pii q[200001];
int h,t;
int n;
set<int> s[200001];
map<pii,int> mp;
int fa[200001];
int findfa(int x){
	return x==fa[x]?fa[x]:fa[x]=findfa(fa[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=(n-1)*2;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		mp[mk(u,v)]++;mp[mk(v,u)]++;
		s[u].insert(v),s[v].insert(u);
		if(mp[mk(u,v)]==2)q[++t]=mk(u,v);
	}
	for(int i=1;i<=n;++i)fa[i]=i;
	set<int>::iterator id;
	while(h<t){
		int u=q[++h].first,v=q[h].second;
		u=findfa(u),v=findfa(v);
		s[u].erase(v),s[v].erase(u);
		if(s[u].size()<s[v].size())swap(u,v);
		for(id=s[v].begin();id!=s[v].end();++id){
			int to=(*id);
			mp[mk(v,to)]=mp[mk(to,v)]=0;
			s[to].erase(v);s[to].insert(u);
			mp[mk(u,to)]++,mp[mk(to,u)]++;
			if(mp[mk(u,to)]==2){
				q[++t]=mk(u,to);
			}
			s[u].insert(to);
		}
		fa[v]=u;
		s[v].clear();
	}
	int ans=0;
	for(int i=1;i<=n;++i)ans+=fa[i]==i;
	if(ans==1)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 61312
#include<iostream>
#include<cstdlib>

using namespace std;

int main() {
    int N = 0;
    int result;
    cin >> N;

    if (N % 2 == 0){
        result = abs(N);
    }else{
        result = 2 * abs(N);
    }

    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n;
	string str;
	string a_str,b_str;
	bool flag = true;	

	cin >> n;
	cin >> str;
	if (n%2 == 0) {
		if (str.substr(0,n/2) != str.substr(n/2,n)) {
			flag = false;
		}
	} else {
		flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b,f,x[101],h[101],y[101],cx,cy,H;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
        if(h[i]!=0)
            f=i;
    }
    for(int xx=0; xx<=100; ++xx)
        for(int yy=0; yy<=100; ++yy)
        {
            cx=xx,cy=yy;
            H=h[f]+abs(x[f]-cx)+abs(y[f]-cy);
            for(int i=1; i<=n; ++i)
            {
                if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
                    break;
                if(i==n)
                {
                    printf("%d %d %d",cx,cy,H);
                    return 0;
                }
            }
        }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin>>n>>k;
  ll c=n/k;
  ll d=c*c*c;
  if(k%2==0){
     if(k*c+k/2<=n)
       c++;
     d+=c*c*c; 
  }
  cout<<d;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static int computeMaxProfit(int n, int[] R) {
		int maxProfit = -2147483648;
		int minPrice = R[0];
		for (int i = 1; i < n; i++) {
			minPrice = Math.min(R[i - 1], minPrice);
			maxProfit = Math.max(maxProfit, R[i] - minPrice);
		}
		
		return maxProfit;
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] R = new int[n];
		
		for (int i = 0; i < n; i++) {
			R[i] = scan.nextInt();
		}
			
		System.out.println(computeMaxProfit(n, R));
	}

}



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

int main(){
	int num[2];
	cin>>num[0]>>num[1];
	while(num[0]!=0 || num[1]!=0){
		sort(num,num+2);
		cout<<num[0]<<" "<<num[1]<<endl;
		cin>>num[0]>>num[1];
	}
}


Measured memory_bytes: 3128
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
vector<int> lst[N + 5];

int dist[N + 5];

void dfs(int cur, int p, int m) {
	dist[cur] = m;
	for(int i = 0;i < lst[cur].size();i++) {
		int to = lst[cur][i];
		if(p == to) continue;
		dfs(to, cur, m + 1);
	}
}

int res = 0;

void dfs2(int cur, int p, int m) {
	res = max(res, dist[cur] - 1);
	for(int i = 0;i < lst[cur].size();i++) {
		int to = lst[cur][i];
		if(to == p) continue;
		if(m + 1 >= dist[to]) res = max(res, dist[to]);
		else res = max(res, dist[to] - 1);
		if(m + 1 < dist[to]) dfs2(to, cur, m + 1);
	}
}

void hora(int tc) {
	int n, u, v;
	cin>>n>>u>>v;
	for(int i = 1;i < n;i++) {
		int a, b;
		cin>>a>>b;
		lst[a].pb(b);
		lst[b].pb(a);
	}
	dfs(v, v, 0);
	dfs2(u, u, 0);
	cout<<res<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 11264
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a==b &&b==c){
            System.out.println(1);
        }else if(a==b &&b!=c){
            System.out.println(2);
        }else if(a==c &&c!=b){
            System.out.println(2);
        }else if(b==c &&c!=a){
            System.out.println(2);
        }else{
            System.out.println(3);
        }
    }
}

Measured memory_bytes: 21844
import math
n=int(input())#時間をoverするができないことはない。
minimum=len(str(n))
temp=minimum
for i in range(1,math.ceil(math.sqrt(n))+1):
    if n%i==0:
        a=i
        b=n//i
        temp=max(len(str(a)),len(str(b)))
        if minimum>=temp:
            minimum=temp
print(minimum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,a,b; cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else{
        ll x = a-1 + b-1 + 1;
        ll y = n-a + n-b + 1;
        cout<<min(x,y)/2<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int n, k, q; cin >> n >> k >> q;
    unordered_map<int, int> mpa;
    F0R(i, q) {
        int temp; cin >> temp;
        mpa[temp]++;        
    }

    FOR(i, 1, n + 1) cout << (k - q + mpa[i] <= 0 ? "No" : "Yes") << endl;
}

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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9
int Amin(int *p,int size){
   int _min = inf;
   for(int i = 0;i < size;i++)
      if(p[i] < _min)_min = p[i];
   return _min;
}
int main(){
   int n,x;scanf("%d %d",&n,&x);
   int m[100];for(int i = 0;i < n;i++)scanf("%d",&m[i]);
   for(int i = 0;i < n;i++){
      x-=m[i];
   }
   printf("%d",n+x/Amin(m,n));
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main() {
  int n, ret = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 0 && a[i] % 2 == 1) ret++;
  }

  cout << ret << endl;
}

Measured memory_bytes: 3500
import Data.List
main = do
  [n,k] <- map (read::String->Int) . words <$> getLine
  s <- map (map (read::String->Int)) . map words . lines <$> getContents
  print $ length $ foldl intersect [1..n] [[1..n]\\x | (i, x) <- zip [0..] s, odd i]

Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,N,x,t;
  cin>>N;
  vec v(N+1,-1);
  rep1(i,N+1){
    cin>>v[i];
  }
  vsort(v);
  cout<<v[N]<<" ";
  t=v[N]/2;
  auto p=lower_bound(all(v),t);
  x=p-v.begin();
  if(x==N)x--;
  if(v[N%2]==0){
    if(v[x]-t<=t-v[x-1]){
      cout<<v[x]<<endl;
    }else{
      cout<<v[x-1]<<endl;
    }
  }else{
    if(v[x]-t<=t-v[x-1]){
      cout<<v[x]<<endl;
    }else{
      cout<<v[x-1]<<endl;
    }
  }
  return 0;
}

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

int main() {
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int m=max(a,max(b,c));
  printf("%d",a*b*c/2/m);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int d, n;
    cin >> d >> n;
    int base_num = 100;
    rep(i, d-1) base_num *= base_num;
    if ( d == 0 ) {
        if ( n == 100 ) cout << 101 << endl;
        else                cout << n << endl;
    }
    else if ( d == 1 ) {
        if ( n == 100 ) cout << 10100 << endl;
        else            cout << n * base_num << endl;
    }
    else {
        if ( n == 100 ) cout << 1010000 << endl;
        else            cout << n * base_num << endl;
    }
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    if(d & 1){
        cout << b - a << endl;
    }else{
        cout << a - b << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
 
typedef pair<int, int> P;
vector<P> edge[500050];
int minDist[500050];
map<P, int> mp;
int tot;
int Dijsktra(int s, int e)
{
    fill(minDist + 1, minDist + tot + 1, INF);
    minDist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, 1});
    while(que.size())
    {
        P now = que.top();
        que.pop();
        if(minDist[now.second] != now.first)
            continue;
        for(vector<P>::size_type i = 0;i < edge[now.second].size();++i)
        {
            P next = edge[now.second][i];
            if(minDist[now.second] + next.second < minDist[next.first])
            {
                minDist[next.first] = minDist[now.second] + next.second;
                que.push({minDist[next.first], next.first});
            }
        }
    }
    if(minDist[e] != INF)
        return minDist[e];
    return -2;
}
void AddEdge(int u, int v, int w)
{
    edge[u].push_back({v, w});
    edge[v].push_back({u, w});
}
int GetId(int u, int c)
{
    if(mp.find({u, c}) != mp.end())
        return mp[{u, c}];
    return mp[{u, c}] = ++tot;
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    tot = n;
    for(int i = 1; i <= m; ++i)
    {
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        int a = GetId(u, c);
        int b = GetId(v, c);
        AddEdge(a, b, 0);
        AddEdge(u, a, 1);
        AddEdge(v, b, 1);
    }
    printf("%d\n", Dijsktra(1, n) / 2);
    return 0;
}

Measured memory_bytes: 59176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <cassert>
#pragma GCC optimize("O3,Ofast")
using namespace std;
using VI = vector<long>;
using SS = pair<string, string>;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<SS, long> left;
    map<SS, long> right;
    
    string t1, t2;
    for (int i = 0; i < (1 << n); i++) {
        t1 = "";
        t2 = "";
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                t1 += s[j];
            } else {
                t2 += s[j];
            }
        }
        left[SS(t1, t2)]++;
    }
    
    for (int i = 0; i < (1 << n); i++) {
        t1 = "";
        t2 = "";
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                t1 += s[2 * n - 1 - j];
            } else {
                t2 += s[2 * n - 1 - j];
            }
        }
        right[SS(t1, t2)]++;
    }
    
    long ans = 0;
    for (auto &l: left) {
        ans += l.second * right[l.first];
    }
    cout << ans << endl;
}


Measured memory_bytes: 108288
s = list(input())
if (s[0] == "A") and (s[2:-1].count("C")==1):
    s[0] = "a"
    s[s[2:-1].index("C")+2] = "c"
    l = list()
    for i in range(len(s)):
        l.append(s[i].lower())
    #(s,l)
    if s == l:
        print("AC")
        exit()
print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	vector<int>B(N - 1);
	vector<int>A(N);
	for (int i = 0; i < N - 1; ++i)cin >> B[i];

	int ans = B[0];
	for (int i = 1; i < N-1;++i) {
		ans += min(B[i - 1], B[i]);
	}
	ans += B[N - 2];

	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 0
for i in range(N):
    del_T = abs(A - (T - H[i]*6/1000))
    if i == 0:
        ans = del_T
        ind = 0
    elif ans > del_T:
        ans = del_T
        ind = i
print(ind+1)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main(){
    ll n, K;
    cin >> n >> K;
    vector<vector<vector<ll>>> dp(55, vector<vector<ll>>(55, vector<ll>(3000)));
    dp[0][0][0] = 1;
    REP(i, n){
        REP(j, n){
            REP(k, n * n + 1){
                dp[i + 1][j][k + j * 2] += dp[i][j][k];
                dp[i + 1][j][k + j * 2] %= MOD;
                
                dp[i + 1][j + 1][k + (j + 1) * 2] += dp[i][j][k];
                dp[i + 1][j + 1][k + (j + 1) * 2] %= MOD;
                
                dp[i + 1][j][k + j * 2] += dp[i][j][k] * 2 * j;
                dp[i + 1][j][k + j * 2] %= MOD;
                
                if(j - 1 >= 0){
                    dp[i + 1][j - 1][k + (j - 1) * 2] += dp[i][j][k] * j * j;
                    dp[i + 1][j - 1][k + (j - 1) * 2] %= MOD;
                }
            }
        }
    }
    cout << dp[n][0][K] << endl;
}

Measured memory_bytes: 72704
#include <stdio.h>
#define min(x, y) x < y?x:y
int A, B, n, minn = 10000000;
void judge(int num, int &judge_add)
{
	int i, j, k, l, m;
	i = num / 10000;
	j = num % 10000 / 1000;
	k = num % 1000 / 100;
	l = num % 100 / 10;
	m = num % 10 ;
	judge_add += i + j + k + l + m;
}
int main()
{
	scanf("%d", &n);
	int judge_add;
	for(A = 1; A <= n - 1; A++)
	{
		B = n - A;
		judge_add = 0;
		judge(A, judge_add);
		judge(B, judge_add);
		minn = min(minn, judge_add);
	}
	printf("%d", minn);
	return 0;
}

Measured memory_bytes: 128