akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll N;
ll A[3100];
ll dp[3100][3100][2];

ll dfs(ll l, ll r, ll p){
    if(dp[l][r][p] != -1) return dp[l][r][p];
    if(l > r) return 0;
    if(l==r) return p==0 ? A[l] : -A[l];
    
    if(p == 0){
        ll res = max(dfs(l+1, r, 1-p)+A[l], dfs(l, r-1, 1-p)+A[r]);
        return dp[l][r][p] = res;
    }
    else{
        ll res = min(dfs(l+1, r, 1-p)-A[l], dfs(l, r-1, 1-p)-A[r]);
        return dp[l][r][p] = res;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, 3100) REP(j, 3100) REP(k, 2) dp[i][j][k] = -1;
    
    cout << dfs(0, N-1, 0) << endstr;
    return 0;
}


Measured memory_bytes: 150528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>


int main(){
char s[101];

int X;
scanf("%d",&X);
if(X>=30)printf("Yes\n");
else printf("No\n");

return 0;
// scanf("%d %d",&b,&c);
// scanf("%s",s);
// printf("%d %s\n",a+b+c,s);

}


Measured memory_bytes: 1656
#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.at(i);
  
  vector<int> p2(N);
  p2 = p;
  sort(p2.begin(), p2.end());
  
  bool flag = false;

  vector<int> p3(N);
  
  for(int i=0; i<N-1; i++){
  
    for(int j=i; j<N; j++){
      
      for(int k=0; k<N; k++){
        
        if(k==i)
          p3.at(k) = p.at(j);
        else if(k==j)
          p3.at(k) = p.at(i);
        else
          p3.at(k) = p.at(k);
      
      }
      
      if(p3 == p2)
        flag = true;
    
    }
  
  }
  
  if(flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007LL
#define REP(i, n) for(int i=0;i<(n);++i)
typedef long long ll;

#define INF 2000000000
int V, E, r;
typedef pair<int, int> P;
struct edge {int to, cost;};
vector<edge> graph[100000];
int d[100000];

void dijkstra(int s){
	fill(d, d+V, INF); d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	while(!que.empty()){
		P a = que.top(); que.pop();
		if(d[a.second] < a.first) continue;
		REP(i, graph[a.second].size()){
			edge e = graph[a.second][i];
			if(d[e.to] > d[a.second]+e.cost){
				d[e.to] = d[a.second]+e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

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

	cin >> V >> E >> r;
	REP(i, E){
		int s, t, d; cin >> s >> t >> d;
		graph[s].push_back({t, d});
	}
	dijkstra(r);
	REP(i, V){
		if(d[i] == INF) cout << "INF" << endl;
		else cout << d[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 12976
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    s = input().rstrip()
    s = s[::-1]
    # 右から0, 1, 2...とした時のセーフな位置
    safe = []
    for i in range(n+1):
        if s[i] == '0':
            safe.append(i)
    res = []

    pos = 0
    while pos < n:
        pre = pos
        pos += m
        if pos >= n:
            res.append(str(n-pre))
            break
        idx = bisect_left(safe, pos)
        if safe[idx] > pos:
            pos = safe[idx-1]
        if pre == pos:
            print(-1)
            exit()
        res.append(str(pos-pre))
    print(*res[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 16256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k > 0){
        int kk = min(k, a);
        k -= kk;
        ans += kk;
    }
    if(k > 0){
        int kk = min(k, b);
        k -= kk;
    }
    if(k > 0){
        int kk = min(k, c);
        k -= kk;
        ans -= kk;
    }
    assert(k == 0);

    cout << ans << endl;
}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

// longest length that the preffix ending in i is equal to suffix start in 0
vector<int> pi_function(const string &s)
{
	int n = s.length();
	vector<int> pi(n);

	for (int i = 1, k = 0; i < n; ++i)
	{
		while (k && s[i] != s[k])
			k = pi[k - 1];
		k += s[i] == s[k];
		pi[i] = k;
	}

	return pi;
}

// matchs of pattern in text
vector<int> kmp(const string &text, const string &patt)
{
	int n = text.length(), m = patt.length();
	vector<int> ans, pi = pi_function(patt);

	for (int i = 0, k = 0; i < n; ++i)
	{
		while (k && text[i] != patt[k])
			k = pi[k - 1];
		k += text[i] == patt[k];
		if (k == m)
		{
			ans.push_back(i - k + 1);
			k = pi[k - 1];
		}
	}

	return ans;
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;

	vector<int> mp(n);

	for (int j = 0; j < 30; ++j)
	{
		string s = "", p = "";
		for (int i = 0; i < n+n-1; ++i)
			s += (char)(a[i%n]%2);
		for (int i = 0; i < n; ++i)
			p += (char)(b[i%n]%2);

		auto v = kmp(s, p);
		for (auto i : v)
			++mp[i];

		for (auto &i : s)
			i = 1-i;
		v = kmp(s, p);
		for (auto i : v)
			++mp[i];
	}

	for (int i = 0; i < n; ++i)
		if (mp[i] == 30)
		{
			cout << i << " " << (a[i]^b[0]) << "\n";
		}

	return 0;
}



Measured memory_bytes: 6964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    int n, x;
    cin >> n >> x;
    
    if (x == 1 || x == 2 * n - 1) {
        out("No");
        return 0;
    }
    
    out("Yes");
    
    if (n == x || n == 2) {
        rep(i, 2 * n - 1) out(i + 1);
        return 0;
    }
    
    // とりあえず小さいケース
    if (n == 3) {
        if (x == 2) {
            out("5 1 2 3 4");
        } else if (x == 4) {
            out("1 5 4 3 2"); // x == 2と対照的
        }
        return 0;
    }
    
    if (n == 4) {
        if (x == 6) {
            out("2 5 1 6 7 3 4");
        } else if (x == 2) {
            out("6 3 7 2 1 5 4"); // x == 6と対照的
        } else if (x == 5) {
            out("4 1 5 3 7 6 2");
        } else if (x == 3) {
            out("4 7 3 5 1 2 6");
        }
    }
    
    // 端以外できそうやけど...
    // わからん!!
    
    // 解説ac pdf
    /*
          x  x
          x  x
     x+2 x-1 x x+1
     ただし、x+2が存在しないといけない
     他の考える(逆に小さい方)
     
         x  x
     x-1 x x+1 x-2
     x-2が存在しないといけない
     */
    
    if (x != 2) {
        vector<int> v;
        int cnt = 0;
        rep3(i, 1, 2 * n + 1) {
            if (i != x - 1 && i != x && i != x + 1 && i != x - 2) {
                v.eb(i);
                cnt++;
                if (cnt == n - 2) {
                    v.eb(x - 1);
                    v.eb(x);
                    v.eb(x + 1);
                    v.eb(x - 2);
                }
            }
        }
        outa(v, 2 * n - 1);
    } else {
        vector<int> v;
        int cnt = 0;
        rep3(i, 1, 2 * n + 1) {
            if (i != x + 2 && i != x - 1 && i != x && i != x + 1) {
                v.eb(i);
                cnt++;
                if (cnt == n - 2) {
                    v.eb(x + 2);
                    v.eb(x - 1);
                    v.eb(x);
                    v.eb(x + 1);
                }
            }
        }
        outa(v, 2 * n - 1);
    }
    
}


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

int check(int n,int m){
	int x=m-n;
	int i=1;
	while(i<x) i*=2;
	while(i!=0){
		if(n%i==0&&m%i==0) return x/i;
		int a=n/i+(n%i!=0);
		int b=m/i;
		if(a<b) return b-a+(n%i==0?0:check(n,a*i))+(m%i==0?0:check(b*i,m));
		i/=2;
	}
}

int main(){
	int N; scanf("%d",&N); int s,d;
	for(int i=0;i<N;i++){
		scanf("%d%d",&s,&d);
		if(s<0&&d>0) printf("%d\n",check(0,-s)+check(0,d));
		else if(s<0&&d<=0) printf("%d\n",check(-d,-s));
		else printf("%d\n",check(s,d));
	}
}

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

int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    vector<long long> s(n);
    for(int i=0; i<q; i++){
        long long a;
        cin >> a;
        s[a-1]++;
    }
    
    for(int i=0; i<n; i++){
        auto ans = ((k+s[i])>q) ? "Yes": "No";
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int h = cin.nextInt();
        int n = cin.nextInt();

        int[] a = cin.ArrayInt(n);

        int sum = 0;

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

        WriteLine(h <= sum? "Yes":"No");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 18784
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1e5+10;

int n; bool ok=true;
vector<int> G[MAX_N];
int sub[MAX_N],dp[MAX_N];
vector<int> sz;

void dfs1(int v,int p){
    sub[v]=1;
    int big=0;
    for (int u:G[v]){
        if (u==p) continue;
        dfs1(u,v); sub[v]+=sub[u];
        if (sub[u]>=2) ++big;
    }
    if (n-sub[v]>=2) ++big;
    if (big>=3) ok=false;
}

void dfs2(int v,int p,int &s){
    if (p<0) dp[v]=0;
    if (dp[s]<dp[v]) s=v;
    for (int u:G[v]){
        if (u==p) continue;
        dp[u]=dp[v]+1;
        dfs2(u,v,s);
    }
}

void dfs3(int v,int p){
    int cnt=1; bool check=false;
    for (int u:G[v]){
        if (u==p) continue;
        if (sub[u]>=2) check=true;
    }
    for (int u:G[v]){
        if (u==p) continue;
        if (sub[u]>=2||!check) dfs3(u,v),check=true;
        else ++cnt;
    }
    sz.emplace_back(cnt);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=0;i<n-1;++i){
        int u,v; cin >> u >> v; --u,--v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    dfs1(0,-1);
    if (!ok){cout << -1 << '\n'; return 0;}
    vector<int> v(2,0);
    dfs2(v[0],-1,v[0]);
    v[1]=v[0];
    dfs2(v[1],-1,v[1]);
    vector<int> ans;
    for (int i=0;i<2;++i){
        sz.clear();
        dfs1(v[i],-1); dfs3(v[i],-1);
        reverse(sz.begin(),sz.end());
        vector<int> res;
        int now=1;
        for (int x:sz){
            for (int j=0;j<x-1;++j) res.emplace_back(now+1+j);
            res.emplace_back(now);
            now+=x;
        }
        if (!i) ans=res;
        if (i&&res<ans) ans=res;
    }
    for (int i=0;i<n;++i) cout << ans[i] << (i+1==n?'\n':' ');
}

Measured memory_bytes: 15984
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int v[] = new int[N];
		for(int i=0;i<N;i++) {
			v[i]=sc.nextInt();
		}
		Arrays.sort(v);
      double ans = v[0];
		for(int i=1;i<N;i++) {
			ans = (ans+v[i])/2;
		}
		System.out.println(ans);
	}
}

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


int main() {
    string S;
    cin >>S;
    vector<int> data(S.size());
        for(int j=0; j<S.size();j++){
            int count =0;
            int s=j;
        while (S.at(s) == 'A' || S.at(s) == 'T' || S.at(s) == 'C' || S.at(s) == 'G'){
            count++;
            s++;
            if(s == S.size()) break;
        }
        data.at(j)= count;
        }
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    cout << data.at(0)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
int a[114514],b[114514];
signed main(){
	ic(n)
	int ans=0;
	rep(0,i,n)cin>>a[i];
	rep(0,i,n)b[a[i]]++;
	rep(1,i,114514){
		if(b[i-1]+b[i]+b[i+1]>ans){
			ans=b[i-1]+b[i]+b[i+1];
		}
	}
	c(ans)
}			

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

int main(){
    vector<int> p(5), q(5);
    for(int i = 0; i < 5; i++){
        int a; cin >> a;
        p[i] = a / 10;
        if(a % 10 == 0){
            p[i] = a / 10 * 10;
            q[i] = 10;
        }else{
            p[i] = (a / 10 + 1) * 10; 
            q[i] = a % 10;
        }
    }
    sort(q.begin(), q.end());
    int ans = 0;
    for(int i = 0; i < 5; i++){
        ans += p[i];
    }
    ans -= 10;
    ans += q[0];
    cout << ans << endl;
}

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

int main()
{
	string S;
	cin>>S;
		int i,j,k,n;
	if("SAT"==S) cout<<7-6;
	else if("SUN"==S)cout<<7-0;
	else if("MON"==S)cout<<7-1;
	else if("TUE"==S)cout<<7-2;
	else if("WED"==S)cout<<7-3;
	else if("THU"==S)cout<<7-4;
	else if("FRI"==S)cout<<7-5;
	
	
     
	return 0;
}

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


using namespace std;

int main(){
    int x;
    cin >> x;
    int ans = 0;
    int gohyaku = x/500;
    ans += gohyaku*1000;
    int goen = (x%500)/5;
    ans += goen*5;
    cout << ans << endl;
    return 0;    
}

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

struct DSU
{
	int n;
	vector<int> par, sze;

	void init(int N)
	{
		n = N;
		par.resize(n);
		sze.resize(n);
		for (int i = 0; i != n; ++i)
			par[i] = i, sze[i] = 1;
	}

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

	void join(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sze[x] < sze[y]) swap(x, y);

		--n;
		par[y] = x;
		sze[x] += sze[y];
	}
};

int main()
{
	DSU unionfind;
	int n, m;
	scanf("%d %d", &n, &m);
	unionfind.init(n);
	for (int i = 0; i != m; ++i)
	{
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		unionfind.join(x - 1, y - 1);
	}
	cout << unionfind.n << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

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

    p = n * a;

    if(p < b){
        printf("%d\n", p);
    }else if(b < p){
        printf("%d\n", b);
    }else if(p == b){
        printf("%d\n", p);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll a, b, x;
	cin >> x >> a >> b;
	if (a - b >= 0) {
		cout << "delicious" << endl;
	}
	else if (b - a <= x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  vi target(3);
  cin >> n;
  rep(i, 3) cin >> target[i];
  vi l(n);
  rep(i, n) cin >> l[i];
  int limit = 1;
  int ans = INT_MAX;
  rep(i, n) limit *= 4;
  rep(x, limit) {
    vi cnt(4, 0);
    vi total(4, 0);
    rep(i, n) {
      int code = (x >> (2 * i)) & 3;
      total[code] += l[i];
      cnt[code] += 1;
    }
    int score = 0;
    bool valid = true;
    rep(j, 3) {
      if (total[j] == 0) valid = false;
    }
    if (!valid) continue;
    rep(j, 3) {
      score += (cnt[j] - 1) * 10;
      score += abs(target[j] - total[j]);
    }
    ans = min(ans, score);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int  x,y,W,H,r;
    cin >> W >> H >> x >> y >> r;
    // cout << x - r  << x + r << y - r << y + r <<endl;
    if (x - r < 0 or x + r > W or y - r < 0 or y + r > H){
        cout << "No"<< endl;
    }else{
        cout << "Yes" << endl;
    }


}


Measured memory_bytes: 3124
N, X, Y = list(map(int, input().split()))

L = [0] * N

for i in range(1, N):
  for j in range(i + 1, N + 1):
    k = j - i
    k = min(k, abs(X - i) + 1 + abs(Y - j))
    L[k] += 1

for i in range(1, N):
  print(L[i])

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

typedef unsigned long long ull;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	
	for (ll i = -119; i <= 119; ++i) {
		for (ll j = -119; j <= 119; ++j) {
			ll a = pow(i, 5);
			ll b = pow(j, 5);
			
			if (a - b == n) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3964
/*
g++ -std=c++14 B.cpp && ./a.out <<< "redcoder"
*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// Source: https://codeforces.com/blog/entry/62393
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);
    }
};

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    string S;
    cin >> S;
    int ans = 0;
    int i = 0; int j = sz(S) - 1;
    while (i < j) {
        if (S[i] != S[j]) ans++;
        i++;
        j--;
    }
    cout << ans << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

vector<ll> div(ll N) {

  vector<ll> a;
  ll tmp = N;

  for (ll i = 2; i * i <= N; i++) {
    ll j = 1;
    while(tmp % i == 0) {
      tmp /= i;
      a.pb(pow(i, j));
      j++;
    }
  }

  if (tmp != 1) {
    a.pb(tmp);
  }

  return a;
}

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

    ll N; cin >> N;
    vector<ll> d = div(N);
    sort(all(d));

    if (d.size() == 1) {
      cout << 1 << endl;
      return 0;
    }

    ll cnt = 0;
    rep(i, d.size()) {
      if (N % d[i] == 0) {
        N /= d[i];
        cnt++;
      }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4032
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	ll ans = n*2;
	rep(i,0,s1.sz){
		string ss;
		rep(j,i,s1.sz){
			ss += s1[j];
		}
		int flag = 1;
		rep(j,0,ss.sz){
			if(ss[j]!=s2[j])flag = 0;
		}
		if(flag == 1){
			ans = min(ans,(ll)n*2-(ll)ss.sz);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);i++)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<string> w(n);
  map<string, bool> a;
  REP(i, n) {
    cin >> w[i];
    if(a[w[i]] == true) {
      cout << "No" << endl;
      return 0;
    } else {
      a[w[i]] = true;
    }
  }

  FOR(i, 1, n) {
    if(w[i-1][w[i-1].size()-1] != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  
}


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

int main(){
  int K, S;
  cin >> K >> S;
  
  
  int count = 0;
  for (int i = 0; i <= K; i++){
    for (int j = 0; j <= K; j++){
      if (S-i-j <= K && S-i-j >= 0){
        count++;
      }
      
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a+b < c) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,i,n;
    int arr[1000];
    cin>>n;
    c = 0;
    b = 1;
    for(i = 0;i < n;i++){
        cin>>arr[i];
        c = c+arr[i];
        if(arr[i]%10!=0){
            b = 0;
        }
    }
    if(b == 1){
        cout<<0;
        return 0;
    }
    sort(arr,arr+n);
    for(i = 0;i < n;i++){
        if(c %10==0){
            if(arr[i]%10==0){
                continue;
            }
            c = c-arr[i];
        }
        else{
            break;
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
from numpy import *;i=int32;q=searchsorted;n,*ab=map(int,open(0).read().split());A,B,c=i(ab[:n]),i(ab[n:]),0;
for k in range(1,30):
  a,b=sort(hstack((A%(1<<k),A%(1<<k)-2**k))),B%(1<<k);c+=(sum(q(a,2**k-b)-q(a,2**(k-1)-b)))%2<<k-1
print(c)


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

int main() {
	int h,w,m;
	cin >> h >> w >> m;
	vector<int> hi(m),wi(m);
	vector<int> hn(h,0), wn(w,0);
	rep(i,m) {
		cin >> hi[i] >> wi[i];
		hi[i]--;
		wi[i]--;
		hn[hi[i]]++;
		wn[wi[i]]++;
	}
	int hnmax=0;
	int wnmax=0;
	rep(i,m) {
		hnmax = max(hnmax,hn[hi[i]]);
		wnmax = max(wnmax,wn[wi[i]]);
	}
	set<int> hindex,windex;
	set<int> bomb;
	rep(i,m) {
		if (hnmax == hn[hi[i]]){
			hindex.insert(hi[i]);
		}
		if (wnmax == wn[wi[i]]){
			windex.insert(wi[i]);
		}
		int id = hi[i]+h*wi[i];
		bomb.insert(id);
	}
	int now=0;
	for (set<int>::iterator hit=hindex.begin();hit !=hindex.end();hit++)
		for (set<int>::iterator wit=windex.begin();wit !=windex.end();wit++) {
		int hi,wi;
		hi = *hit;
		wi = *wit;
		now = hn[hi]+wn[wi];
		int id = hi+h*wi;
		set<int>::iterator bid;
		bid=bomb.find(id);
		if (bid == bomb.end()) {
			cout << now << endl;
			return 0;
		}
	}
	now--;
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 50200
while True:
    H, W = [int(i) for i in input().split()]
    if W == H == 0:
        break
    line = ""
    for i in range(H):
        for j in range(W):
            if i % 2 == 0:
                if j % 2 == 1:
                    line = line + "."
                else :
                    line = line + "#"

            else :
                if j % 2 == 1:
                    line = line + "#"
                else :
                    line = line + "."
        print(line)
        line = ""
    print()

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
int ds(int n) {
    int t = 0;
    while (n) t += n % 10, n /= 10;
    return t;
}
int main() {
    int n, b = 1;
    scanf("%d", &n);
    for (int i = 2; i < n; i++)
        if (ds(b) + ds(n-b) > ds(i) + ds(n-i))
            b = i;
    printf("%d\n", ds(b) + ds(n-b));
}

Measured memory_bytes: 256
using Yorukatsu039.Questions;
using Yorukatsu039.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu039.Questions
{
    /// <summary>
    /// ABC128 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ap = inputStream.ReadIntArray();
            var a = ap[0];
            var p = ap[1];
            p += a * 3;
            yield return p / 2;
        }
    }
}


namespace Yorukatsu039
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu039.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu039.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi A(N);
  vvi X(N),Y(N);
  REP(i,N) {
    cin>>A[i];
    REP(j,A[i]) {
      int x,y; cin>>x>>y;
      x--;
      X[i].push_back(x);
      Y[i].push_back(y);
    }
  }

  int M = 0b01<<N;
  int ans = 0;
  REP(i,M) {
    int pt = i; // 誰が正直者になるかを仮定するパターン
    int mask = 0b01;

    vi good(N, 0);
    REP(j,N) {
      if (pt&mask) good[j] = 1;
      mask <<= 1;
    }

    bool ok = true; // 評価に矛盾がないか

    REP(j,N) { // j の人の意見を聞く
      if (good[j]) { // j の人が正直者と仮定されていれば
        for(int k=0; k<X[j].size(); k++) { // j の人の k 番目の評価
          int tg = X[j][k]; // 評価対象者
          int ev = Y[j][k]; // 評価
          if (good[tg] != ev) { // 評価が仮定と矛盾する
            ok = false;
            break;
          }
        }
      }
    }
      
    // 矛盾がなければ、今回の仮定の結果を計算
    if (ok) {
      int cnt = 0;
      REP(i,N) {
        if (good[i]==1) cnt++;
      }

      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		boolean flag = true;
		String word = sc.next();
		char last = word.charAt(word.length()-1);
		while(sc.hasNext()) {
			word = sc.next();
			char first = word.charAt(0);
			if(last == first) {
				last = word.charAt(word.length()-1);
			} else {
				flag = false;
				break;
			}
		}
		if(flag) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main()
{
    int n; cin >> n;
    vint sieve(1000005, 0);
    vint a(n);
    rep(i, n) cin >> a[i];

    rep(i, n){
        if(a[i]%2==0) sieve[2]++;
        while(a[i]!=1 && a[i]%2==0) a[i] /= 2;

        int j = 3;
        for(j=3; j*j<=a[i]; j+=2){
            if(a[i]%j==0) sieve[j]++;
            while(a[i]!=1 && a[i]%j==0) a[i] /= j;
        }

        if(a[i] >= j) sieve[a[i]]++;
    }

    bool set_flg = false;

    // rep(i, 10) pr(sieve[i]);
    rep(i, 1000006){
        if(sieve[i]==n) {
            cout << "not coprime" << endl;
            return 0;
        }
        if(sieve[i]>1) set_flg = true;
    }

    if(set_flg) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;
    return 0;}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N+1];
    int[] B = new int[N+1];
    int[] C = new int[N+1];
    int total =0;
    for (int i =1; i<N+1; i++) {
      A[i] = sc.nextInt();
    }
    for (int i =1; i<N+1; i++) {
      B[i] = sc.nextInt();
      total += B[i];
    }
    for (int i =1; i<N; i++) {
      C[i] = sc.nextInt();
    }
    for (int i =1; i<N; i++) {
      if (A[i+1] == A[i] + 1) {
        total += C[A[i]];
      }
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int h, w, c; cin >> h >> w >> c;

	int a = max(h, w);

	cout << (c + a - 1) / a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000001
#define LINF 1000000000000000001

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n;

int main(){
	cin >> n;
	int a = n, b = 0,c = 100000000;
	while(c >= 1){
		b += a / c;
		a %= c;
		c /= 10;
	}
	if(n % b == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    p = list(map(int, input().split()))

    ans = 0

    for i in range(n-1):
        if p[i] == i + 1:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
            ans += 1

    if p[n-1] == n:
        ans += 1

    print(ans)


Measured memory_bytes: 14008
from collections import deque
def main():
    h, w = map(int, input().split())
    S = list(map(lambda x: int(x) - 1, input().split()))
    G = list(map(lambda x: int(x) - 1, input().split()))
    A = [list(input()) for _ in range(h)]
    INF = 100000000
    score = [[INF] * w for _ in range(h)]
    score[S[0]][S[1]] = 0
    visited = [[False] * w for _ in range(h)]
    stack = deque([S])
    dxy = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    while stack:
        y, x = stack.popleft()
        if visited[y][x]:
            continue
        else:
            visited[y][x] = True
        count = 0
        for dx, dy in dxy:
            X = x + dx
            Y = y + dy
            if Y < 0 or Y >= h or X < 0 or X >= w:
                continue
            elif A[Y][X] == '.':
                stack.appendleft([Y, X])
                score[Y][X] = min(score[Y][X], score[y][x])
        if count == 0 and A[y][x] == '.':
            for i in range(-2, 3):
                for j in range(-2, 3):
                    X = x + j
                    Y = y + i
                    if Y < 0 or Y >= h or X < 0 or X >= w:
                        continue
                    if A[Y][X] == '.' and score[Y][X] > score[y][x] + 1:
                        stack.append([Y, X])
                        score[Y][X] = min(score[Y][X], score[y][x] + 1)
    print(score[G[0]][G[1]]) if score[G[0]][G[1]] != INF else print(-1)


if __name__ == '__main__':
    main()


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

main() {
  string O, E; cin >> O >> E;
  rep(i, E.length()) {
    cout << O[i] << E[i];
  }
  if (O.length() > E.length()) cout << O.back();
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define mid ((l + r) >> 1)
#define lson (x << 1)
#define rson ((x << 1) | 1)
using namespace std;
typedef long long LL;

LL ans = 0;
LL val[1600005] = {0},tag[1600005] = {0};

void pushup(LL x){
	val[x] = val[lson] + val[rson];
}

void pushdown(LL x,LL l,LL r){
	if(!tag[x]) return;
	tag[lson] += tag[x]; val[lson] += (mid - l + 1) * tag[x];
	tag[rson] += tag[x]; val[rson] += (r - mid) * tag[x];
	tag[x] = 0;
}

void modify(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L <= l && r <= R){
		tag[x] += v; val[x] += v * (r - l + 1);
		return;
	}
	pushdown(x,l,r);
	if(L <= mid) modify(lson,l,mid,L,R,v);
	if(R > mid) modify(rson,mid + 1,r,L,R,v);
	pushup(x);
}

LL query(LL x,LL l,LL r,LL L,LL R){
	if(L <= l && r <= R) return val[x];
	LL ret = 0;
	pushdown(x,l,r);
	if(L <= mid) ret += query(lson,l,mid,L,R);
	if(R > mid) ret += query(rson,mid + 1,r,L,R);
	pushup(x); return ret;
}

struct node{
	LL xx,h;
}s[400005];
bool cmp(node x,node y){
	return x.xx < y.xx;
}

int main(){
	ios::sync_with_stdio(false);
	LL n,d,a;
	cin >> n >> d >> a; d <<= 1;
	for(LL i = 1;i <= n;i ++) cin >> s[i].xx >> s[i].h;
	sort(s + 1,s + 1 + n,cmp);
	
	for(LL i = 1;i <= n;i ++) modify(1,1,n,i,i,s[i].h);
	
	for(LL i = 1;i <= n;i ++){
		LL ad = query(1,1,n,i,i);
		if(ad <= 0) continue;
		ad = (ad - 1) / a + 1;
		ans += ad;
		LL L,R,MID,tmp; L = i; R = n; tmp = i;
		while(L <= R){
			MID = (L + R) >> 1;
			if(s[MID].xx - s[i].xx <= d){
				tmp = MID;
				L = MID + 1;
			}
			else R = MID - 1;
		}
		modify(1,1,n,i,tmp,-ad * a);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  long long n,k;cin>>n>>k;
  static 
  int dl[65][200000];
  for (size_t i = 1; i <= n; i++)
  {
    cin >> dl[0][i];
  }
  
  for (size_t i = 1; i < 64; i++)
  {
    for (size_t j = 1; j <= n; j++)
    {
      dl[i][j] = dl[i-1][dl[i-1][j]];
    }
    
  }
  
  int ans = 1;
  for (size_t i = 0; i < 64; i++)
  {
    if (k & (1LL<<i))
    {
      ans = dl[i][ans];
    }

  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 53608
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = r.readLine();
        String[] sp = is.split(" ");
        if(sp.length > 3)
        	return;
        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int c = Integer.parseInt(sp[2]);
        if(a<b){
        	if(b<c){
        		System.out.println("Yes");
        	}else
            	System.out.println("No");
        }else
        	System.out.println("No");
      }
}

Measured memory_bytes: 24108
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto abk = readln.split.to!(long[]);
  auto A = abk[0];
  auto B = abk[1];
  auto K = abk[2];

  void solve() {
    auto a = K >= A ? 0 : A - K;
    K -= A - a;
    auto b = K >= B ? 0 : B - K;
    writefln("%s %s", a, b);
  }

  solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstring>
using namespace std;

char s[6001];
int a[3000], b[3000];
int mat[6000];

char dp[6001][6001];

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

    for (int i = 0, ai = 0, bi = 0; i < 2 * n; i++)
        if (s[i] == 'a')
            a[ai++] = i;
        else
            b[bi++] = i;
    for (int i = 0; i < n; i++)
        mat[a[i]] = b[i], mat[b[i]] = a[i];
    n *= 2;

    // dp[n] = ""
    for (int i = n - 1; i >= 0; i--) {
        if (mat[i] < i) {
            strcpy(dp[i], dp[i + 1]);
        } else {
            if (s[i] == 'a') {
                dp[i][0] = 'a';
                dp[i][1] = 'b';
                strcpy(dp[i] + 2, dp[mat[i] + 1]);
            } else {
                int si = 0, ed = mat[i];
                for (int j = i; j <= ed; j++)
                    if (i <= mat[j]) {
                        dp[i][si++] = s[j];
                        ed = max(ed, mat[j]);
                    }
                strcpy(dp[i] + si, dp[ed + 1]);
            }
            if (strcmp(dp[i], dp[i + 1]) < 0)
                strcpy(dp[i], dp[i + 1]);
        }
    }

    puts(dp[0]);
}


Measured memory_bytes: 35200
//  Created by liszt on 2019/07/15.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    int n,ans,a[100010],l[100010],r[100010];
    
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    
    l[0]=a[0];
    r[n-1]=a[n-1];
    
    for(int i=0;i<n-1;i++){
        l[i+1]=gcd(l[i],a[i+1]);
        int j=n-2-i;
        r[j]=gcd(r[j+1],a[j]);
    }
    for(int i=0;i<n;i++){
        if(i==0){
            ans=r[1];
        }else if(i==n-1){
            ans=max(ans,l[n-2]);
        }else{
            ans=max(ans,gcd(l[i-1],r[i+1]));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
S = input()
oddnumlist = []
evennumlist = []
sepnum = 0

for index in S:
    if sepnum % 2 == 0:
        evennumlist.append(index)
    else:
        oddnumlist.append(index)
    sepnum += 1

if evennumlist.count("1") + oddnumlist.count("0") <= evennumlist.count("0") + oddnumlist.count("1"):
    print(evennumlist.count("1") + oddnumlist.count("0"))
else:
    print(evennumlist.count("0") + oddnumlist.count("1"))


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[3005];
	long long int ans = 0LL;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans += a[i];
	}
	cout << ans-n << endl;
	return 0;
}

Measured memory_bytes: 256