akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

class Task{
public:
    void solve(istream& in, ostream& out){
        string s, t = "abc";
        in>>s;
        do{
            if(s==t){
                out<<"Yes\n";
                return;
            }
        }while(next_permutation(ALL(t)));
        out<<"No\n";
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;

    REP(i, N) {
        int a;
        cin >> a;
        if ((a % 2) == 0) {
            if ((a % 3) != 0 && (a % 5) != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



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


Measured memory_bytes: 256
#高速化heapqダイクストラ
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()


def BFS(point,d):
    cost=[1e7]*(n+1)
    cost[point]=0
    Q=deque([(0,point)])
    
    while Q:
        c,p = Q.popleft()
        for np in d[p]:
            if cost[np]==1e7:
                cost[np]=c+1
                Q.append((c+1,np))
    return cost

n=int(input())
d={}
for i in range(n-1):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a].append(b)
    else:
        d[a]=[b]
    if b in d.keys():
        d[b].append(a)
    else:
        d[b]=[a]
        
x=BFS(1,d)[1:]
y=BFS(n,d)[1:]

#print(x,y)

F=0
S=0

for s,t in zip(x,y):
    if s<=t:
        F+=1
    else:
        S+=1

if F<=S:
    print("Snuke")
else:
    print("Fennec")


Measured memory_bytes: 35476
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 55

int N,M;
char A[SIZE][SIZE],B[SIZE][SIZE];


int main(){

	scanf("%d %d",&N,&M);

	for(int row = 0; row < N; row++){

		scanf("%s",A[row]);
	}
	for(int row = 0; row < M; row++){

		scanf("%s",B[row]);
	}

	bool FLG;
	for(int base_row = 0; base_row+M <= N; base_row++){
		for(int base_col = 0; base_col+M <= N; base_col++){

			FLG = true;
			for(int row = 0; row < M; row++){
				for(int col = 0; col < M; col++){
					if(A[base_row+row][base_col+col] != B[row][col]){
						FLG = false;
						break;
					}
				}
				if(!FLG)break;
			}


			if(FLG){
				printf("Yes\n");
				return 0;
			}
		}
	}



	printf("No\n");

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = 1;
    rep(i, 0, N){
        ll tempa, tempb;
        tempa = ans * 2;
        tempb = ans + K;
        ans = tempa < tempb ? tempa : tempb;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int a[1000010];
int b[1000010];

map<ll, ll> prime_factor(ll n) {
      map< ll, ll > ret;
      for(ll i = 2; i * i <= n; i++) {
          while(n % i == 0) {
              ret[i]++;
              n /= i;
          }
      }
      if(n != 1) ret[n] = 1;
      return ret;
}

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    int g = a[0];
    rep(i, n-1) g = __gcd(g, a[i+1]);
    if(g > 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    rep(i, n){
        map<ll,ll> mp = prime_factor(a[i]);
        for(auto e : mp) b[e.first]++;
    }

    rep(i, 1000010){
        if (b[i] > 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 11368
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
const double pi = acos(-1);
void solve() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double theta1 = 2 * pi * (h * 1.0 + m * 1.0 / 60) / 12;
	double theta2 = 2 * pi * (m * 1.0) / 60;
	double theta = abs(theta1 - theta2);
	double ans = sqrtl(a * a + b * b - 2 * a * b * cos(theta));
	trace(theta * 180 / pi);
	cout << setprecision(12) << ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 4124
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N + 1, 0);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
int main(){
	scanf("%d",&n);
	printf("%d\n",48-n);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadLong;
            var s = cin.ReadStrArray(N);
            string[] sorted = new string[N];
            for (long i = 0; i < N; i++)
            {
                sorted[i] = String.Concat(s[i].OrderBy(c => c));
            }

            long count = 0;

            var dict = new Dictionary<string, long>();
            foreach(string str in sorted)
            {
                if (dict.ContainsKey(str))
                {
                    count += dict[str];
                    dict[str] += 1;
                }
                else
                {
                    dict.Add(str, 1);
                }
            }

            Console.WriteLine(count);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 38788
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *aa, const void *bb)
{
    return -*(int*)aa + *(int*)bb;
}

int main(void) {
  int n, i, j, k, h, ans = 0, t;
  scanf("%d %d", &n, &h);
  int a[n], b[n], num = n;
  long long int sum[n];
  for(i = 0; i < n; ++i) scanf("%d %d", &a[i], &b[i]);
  qsort(a, n, sizeof(int), compare_int);
  qsort(b, n, sizeof(int), compare_int);
  sum[0] = (long long)b[0];
  if(sum[0] >= (long long)h) {
    printf("1\n");
    return 0;
  }
  for(i = 1; i < n; ++i) {
    sum[i] = (long long)b[i] + sum[i - 1];
  }
  for(i = 0; i < n; ++i) {
    if(a[0] > b[i]) {
      num = i;
      break;
    }
  }
  for(i = 0; i < num; ++i) {
    if(sum[i] >= (long long)h) {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  ans += num;
  h -= sum[num - 1];
  ans += (h + a[0] - 1) / a[0];
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <functional>
using namespace std;

struct MinCostFlow {
	static const int INF = 1e9;

	struct E {
		//to,??????,?????????,?????????index
		int to, cap, cost, rev;
		E(int t, int ca, int co, int r) {
			to = t;
			cap = ca;
			cost = co;
			rev = r;
		}
	};

	//?????§????????°
	int V;
	vector<vector<E>>G;
	MinCostFlow(int v) {
		V = v;
		G.resize(V);
	}

	//?????????
	inline void add_edge(int from, int to, int cap, int cost) {
		if (from == to)return;
		E e = E(to, cap, cost, G[to].size());
		E ee = E(from, 0, -cost, G[from].size());
		G[from].push_back(e);
		G[to].push_back(ee);
	}

	//?????????????????¢??¨??????
	//?????????,????°??????????
	vector<int>dist, mindist;
	//??????????????¨
	vector<int>pre_v, pre_i;

	//?§????????????????????????§???????°??????????
	void dijkstra(int s) {
		priority_queue< pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > que;
		dist.assign(V, INF);
		dist[s] = 0;
		que.push(pair<int,int>(0,s));
		while (!que.empty()) {
			pair<int,int> p = que.top(); que.pop();
			int v = p.second;
			if (dist[v] < p.first)continue;

			for (int i = 0; i < G[v].size(); i++) {
				E &e = G[v][i];
				if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + mindist[v] - mindist[e.to]) {
					dist[e.to] = dist[v] + e.cost + mindist[v] - mindist[e.to];
					pre_v[e.to] = v;
					pre_i[e.to] = i;
					que.push(pair<int,int>(dist[e.to], e.to));
				}
			}
		}
	}

	int min_cost_flow(int s, int t, int flow) {
		int cost = 0;
		mindist.resize(V);
		pre_v.resize(V);
		pre_i.resize(V);

		//????????????????????????????????§
		while (flow > 0) {
			dijkstra(s);
			if (dist[t] == INF)return -1;
			for (int v = 0; v < V; v++)mindist[v] += dist[v];

			int f = flow;
			for (int v = t; v != s; v = pre_v[v]) {
				f = min(f, G[pre_v[v]][pre_i[v]].cap);	
			}
			flow -= f;

			cost += f * mindist[t];

			for (int v = t; v != s; v = pre_v[v]) {
				E& e = G[pre_v[v]][pre_i[v]];
				E& ee = G[v][e.rev];
				e.cap -= f;
				ee.cap += f;
			}
		}

		return cost;
	}
};

int main() {
	int V, E, F; cin >> V >> E >> F;

	MinCostFlow mcf(V);

	for (int i = 0; i < E; i++) {
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		mcf.add_edge(u,v,c,d);
	}

	int ans = mcf.min_cost_flow(0,V-1,F);

	cout << ans << endl;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep( i, n ) for (int i = 0; i < ( long long )(n); i++)
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	
	for(int i = 0 ; i < max(a,b) ; i++){
		cout<<min( a , b );
	}
}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = []
for _ in range(N) :
    X.append(list(map(int, input().split())))

cnt = 0

for i in range(N) :
    for j in range(i+1, N) :
        sum = 0
        for k in range(D) :
            sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        sum = math.sqrt(sum)
        #print(sum)
        if sum.is_integer() :
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(M)]
b = set()
for i in a:
    if i[0]==1 or i[1]==N:
        b.add((i[0],i[1]))
for i in range(2,N):
    if (1,i) in b and (i,N) in b:
    	print('POSSIBLE')
    	exit()
print('IMPOSSIBLE')


Measured memory_bytes: 72024
#include <iostream>
#include <algorithm>

int a[100009];

int cmp(int a,int b){
    return a>b;
}
int main()
{
    int n;
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>a[i];
        a[i]--;
    }
    std::sort(a,a+n,cmp);
    int temp=0;
    while(temp+1<n && temp+1<=a[temp+1]){
        temp++;
    }
    int dis1=a[temp]-temp;
    int dis2=0;
    for(int i=temp+1;i<n;i++){
        if(a[i]>=temp) dis2++;
    }
    if(dis1%2 || dis2%2) std::cout<<"First"<<"\n";
    else std::cout<<"Second"<<"\n";
    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  string a,b;
  cin >> a >> b;
  ll mae = 0;
  ll res = 1;
  ll mod = pow(10,9) + 7;
  for(int i = 0;i < n;i++){
    if(i == 0){
      if(a[i] != b[i]){
        res *= 6;
        mae = 2;
        i++;
      }
      else{
        res *= 3;
        mae = 1;
      }
    }
    else{
      if(mae == 1){
        if(a[i] != b[i]){
          res *= 2;
          mae = 2;
          i++;
        }
        else{
          res *= 2;
          mae = 1;
        }
      }
      else{
        if(a[i] != b[i]){
          res *= 3;
          mae = 2;
          i++;
        }
        else{
          res *= 1;
          mae = 1;
        }
      }
    }
    res %= mod;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

// dp[i][j] := i個目までで容量がj以下の時の最大の価値.
int dp[3100][6100];

typedef tuple<int,int> P;

void solve() {
  int n, c; cin >> n >> c;
  vector<P> A;
  loop(i,0,n) {
    int a, b; cin >> a >> b;
    A.emplace_back(a, b);
  }
  sort(A.begin(), A.end());
  
  int max_ = 0;
  loop(i,0,n) {
    int a, b;
    tie(a, b) = A[i];
    loop(j,0,c+1) {
      chmax(dp[i+1][j], dp[i][j]);
      chmax(dp[i+1][j+a], dp[i][j] + b);
    }
  }
  
  loop(k,0,n) { // 最後に取る要素を全探索
    int score = get<1>(A[k]);
    if (k>0) score += dp[k][c-1]; // Aは時間昇順にソート済みなので、dp[k-1][c-1]には最後の注文が出来る時間までにk以外を使った最大価値に入っている.
    max_ = max(max_, score);
  }
  cout << max_ << endl;
}


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

using namespace std;

char s[200010];
int cnt[26];
typedef long long LL;

int main()
{
	scanf("%s",s);
	int len = strlen(s);
	LL ans = 1;
	LL sum = 0;
	for (int i=0;i<len;i++)
	{
		ans += sum - LL(cnt[s[i] - 'a']);
		cnt[s[i] - 'a']++;
		sum++;
	}
	printf("%lld\n",ans);
}

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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int ans = min(P + Q, min(P + R, Q + R));
  cout << ans << endl;
  return 0;
}

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

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

int main(){
  int n;cin>>n;
  
  for(int i=0;i<n;++i){
    bool pos=true;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll g=gcd(b,d);
    ll Max_Stock=b-g+a%g;
    if(Max_Stock>c)pos=false;
    if(a<b||d<b)pos=false;
    
    if(pos)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int m,f,r,x;

  while(1){
    scanf("%d %d %d",&m,&f,&r);
    (x=m+f);
    if(m==f&&f==r&&r==-1)break;

    if(m==-1||f==-1){
      printf("F\n");
    }else if(x>=80){
      printf("A\n");
    }else if(x>=65){
      printf("B\n");
    }else if(x>=50){
      printf("C\n");
    }else if(x>=30){
      if(r>=50){
	printf("C\n");
      }else{
	printf("D\n");
      }
    }else{
      printf("F\n");
    }
  }return 0;
}
      

Measured memory_bytes: 1012
# B.py
S = input()
if S[0] != "A":
	print("WA")
	exit()
i = 2
s = 0
j = 0
while i < len(S)-1:
	if S[i] == "C":
		s = s + 1
		j = i
	i += 1

if s != 1:
	print("WA")
	exit()

i = 1
while i < len(S):
	if i != j and S[i].isupper():
		print("WA")
		exit()
	i += 1

print("AC")


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>

bool heap_comp(uint64_t root, uint64_t leaf)
{
    return root>=leaf;
}

typedef struct {
    uint64_t *a;
} Heap;

Heap *heap_init(uint64_t size)
{
    Heap *h = malloc(sizeof(Heap));
    h->a = malloc(sizeof(uint64_t) * (size+1));
    h->a[0] = 1;
    return h;
}

void heap_term(Heap *h)
{
    free(h->a);
    free(h);
}

void heap_add(Heap *h, uint64_t x)
{
    h->a[h->a[0]] = x;

    for(uint64_t i=h->a[0]; i!=1; i=i>>1){
        if(heap_comp(h->a[i>>1], h->a[i])){
            break;
        }
        uint64_t tmp = h->a[i>>1];
        h->a[i>>1] = h->a[i];
        h->a[i] = tmp;
    }

    h->a[0] += 1;
}

uint64_t heap_pop(Heap *h)
{
    uint64_t res = h->a[1];

    if(h->a[0]!=1){
        h->a[1] = h->a[h->a[0]-1];
        h->a[0] -= 1;
        uint64_t ci;
        for(uint64_t i=1;;){
            if((i<<1) + 1 < h->a[0]){
                uint64_t mc = heap_comp(h->a[i<<1], h->a[(i<<1)+1]) ? h->a[i<<1] : h->a[(i<<1)+1];
                uint64_t mi = heap_comp(h->a[i<<1], h->a[(i<<1)+1]) ? i<<1 : (i<<1)+1;
                if(heap_comp(h->a[i], mc)){
                    break;
                } else {
                    ci = mi;
                }
            } else if((i<<1)+1 == h->a[0]){
                if(heap_comp(h->a[i], h->a[i<<1])){
                    break;
                } else {
                    ci = i<<1;
                }
            } else {
                break;
            }
            uint64_t tmp = h->a[ci];
            h->a[ci] = h->a[i];
            h->a[i] = tmp;
            i = ci;
        }
    }
    return res;
}

typedef Heap PQueue;
PQueue *pqueue_init(uint64_t size)
{
    return heap_init(size);
}

void pqueue_term(PQueue *pq)
{
    heap_term(pq);
}

void pqueue_add(PQueue *pq, uint64_t x)
{
    heap_add(pq, x);
}

uint64_t pqueue_pop(PQueue *pq)
{
    return heap_pop(pq);
}

int main()
{
    int N, M;
    scanf("%d%d\n", &N, &M);
    PQueue *pq = pqueue_init(N);
    for(int ni=0; ni<N; ni++){
        uint64_t A;
        scanf("%"PRIu64, &A);
        pqueue_add(pq, A);
    }
    for(int mi=0; mi<M; mi++){
        uint64_t mp = pqueue_pop(pq);
        pqueue_add(pq, mp/2);
    }

    uint64_t res = 0;
    for(int ni=0; ni<N; ni++){
        res += pqueue_pop(pq);
    }
    printf("%"PRIu64"\n", res);

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

int N,K;

int main(){
	cin >> N >> K;
	ll ans = 0;
	ll x = N/K;
	ans = x*x*x;
	if(K%2 == 0){
		x = (N+K/2)/K;
		ans += x*x*x;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
int a[11];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        a[x] = 1;
    }
    while (1) {
        int tmp = n;
        bool f = false;
        while (tmp > 0) {
            if (a[tmp % 10]) {
                f = true;
                break;
            }
            tmp /= 10;
        }
        if (!f) {
            cout << n << '\n';
            break;
        }
        n += 1;
    }
}

Measured memory_bytes: 256
N = int(input())
ACn, WAn, TLEn, REn = 0, 0, 0, 0
for i in range(N):
    J = input()
    if J == "AC":
        ACn += 1
    elif J == "WA":
        WAn += 1
    elif J == "TLE":
        TLEn += 1
    else:
        REn += 1
print("AC x " + str(ACn))
print("WA x " + str(WAn))
print("TLE x " + str(TLEn))
print("RE x " + str(REn))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define maxx ((ll)1e6+5)
#define pb push_back
#define ins insert
#define F first
#define S second
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sv[1000000]={0};
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<=maxx;i++){if(!sv[i]){for(int j=2*i;j<=maxx;j+=i)sv[j]=1;}}}//0 hai to prime
ll ncr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
using namespace std;
int main()
{
    fast
    ll n,i,j;
    facto();
    cin >> n;
    ll path=0;
    for(i=1;i<n;i++) path+=i;
    ld x[n],y[n],d[path],ans=0.0;
    for(i=0 ; i<n ; i++)
    	cin >> x[i] >> y[i];
    ll k=0;
    for(i=0 ; i<n ; i++)
    	for(j=i+1 ; j<n ; j++)
    	{
    		d[k] = sqrt(pow(abs(x[i]-x[j]),2) + pow(abs(y[i]-y[j]),2));
    		ans+=d[k];
    		k++;
    	}
    //	cout<<ans;
    ans/=fact[n];
    if(n==2) ans*=2;
    else    ans*=(2*fact[n-1]);
    //ans*=161280;
    cout << fixed << setprecision(6) << ans <<"\n";
    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    int p,q,r,s,n,ans=0;
    for(int i=a;i<=b;i++){
        n=i;
        p=n/10000;
        n=n%10000;
        q=n/1000;
        n=n%100;
        r=n/10;
        s=n%10;
        if(p==s and q==r)ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
wall = []
mask = [] 
res = 0
for i in range(10):
    mask.append(inpl())
for y in range(h):
    wall.append(inpl())
for k in range(10):
    for i in range(10):
        for j in range(10):
            mask[i][j] = min(mask[i][j], mask[i][k] + mask[k][j])
for i in range(h):
    for j in range(w):
        tmp = wall[i][j]
        if abs(tmp) == 1:
            continue
        res += mask[tmp][1]
print(res)

Measured memory_bytes: 42456
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
using namespace std;
using ll = long long;
using LP = pair<ll, int>;
const ll inf = 1e18;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int si, sj, gi, gj;
    cin >> si >> sj >> gi >> gj;
    si--; sj--; gi--; gj--;
    vector<string> g(h);
    rep(i, h) cin >> g[i];
    auto toId = [&](int i, int j, int v){
        return (i*w+j)*4+v;
    };
    auto modCeil = [&](ll x){
        return (x + k-1)/k*k;
    };
    //ここからダイクストラ
    vector<ll> dist(h*w*4, inf);
    priority_queue<LP, vector<LP>,greater<LP>> que;
    auto push = [&](int i, int j, int v, ll cost){
        int idx = toId(i, j, v);
        if (dist[idx] <= cost) return;
        dist[idx] = cost;
        que.emplace(cost, idx);
    };
    //初期化
    rep(v, 4) push(si, sj, v, 0);
    while(!que.empty()){
        ll cost = que.top().first;
        int id = que.top().second;
        int i = id/4/w;
        int j = id/4%w;
        int v = id%4;
        que.pop();
        if (cost > dist[id]) continue;
        //方向替え
        
        rep(nv, 4){
            int ni = i + di[nv];
            int nj = j + dj[nv];
            if (0 <= ni && ni < h && 0 <= nj && nj < w){
                if (g[ni][nj] == '.') {
                    if (nv != v){
                        //方向替え
                        push(ni, nj, nv, modCeil(cost)+1);
                    }else{
                        //直進
                        push(ni, nj, nv, cost+1);
                    }
                }
            }
           
            
        } 
            
        //直進
        // int ni = i + di[v], nj = j + dj[v];
        // if (0 <= ni && ni < h && 0 <= nj && nj < w){
        //     if (g[ni][nj] == '.') {
        //         push(ni, nj, v, cost+1);
        //     }
        // }
    }
    ll ans = inf;
    rep(i, 4) ans = min(ans, dist[toId(gi, gj, i)]);
    if (ans == inf) {
        cout << -1 << endl;
    }else
    {
        cout << modCeil(ans)/k << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 39940
N = int(input())
A = list(map(int, input().split()))
maxim = max(A)
counter = [0]*(maxim+1)
dif = [-1, 0, 1]
for i in A:
    for d in dif:
        j = i + d
        if j < 0 or maxim < j:
            continue
        else:
            counter[j] += 1
print(max(counter))

Measured memory_bytes: 20872
//ABC087B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int count = 0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k == x){
					count++;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
S = str(input())
M = []
con = 0
for j in S:
  if j == 'A' or j == 'C' or j == 'G' or j == 'T':
    con += 1
  else:
    if con != 0:
      M.append(con)
    con = 0
M.append(con)
print(max(M))

Measured memory_bytes: 9040
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {

  string s;
  cin>>s;
  if(s =="a" || s =="i" || s =="u" || s =="e" || s =="o"){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }

  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>

int main(void) {
 
  // 入力
  int n;
  scanf("%d",&n);
  int listA[n];
  for(int i=0;i<n;i++){
    scanf("%d",&listA[i]);
  }
  
  for(int i=n-2;i>=0;i--){
    if(listA[i]>listA[i+1]){
      listA[i]-=1;
    }
  }
  int flg=1;
  for(int i=0;i<n-1;i++){
    if(listA[i]>listA[i+1]){
      flg=0;
      break;
    }
  }
  if(flg==1)printf("Yes\n");
  else      printf("No\n");
  

  return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return int64(a)
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanInt64Slice(n int64) []int64 {
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = scanInt64()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	// n := scanInt()

	input := scanSlice(2)
	h := input[0]
	n := input[1]

	arr := scanSlice(n)
	// arr = sort.IntsAreSorted(arr)

	// maze := make([]string, 0)

	amount := int64(0)

	for i := 0; i < n; i++ {
		temp := arr[i]
		amount += int64(temp)
	}

	if amount >= int64(h) {
		fmt.Println("Yes")

	} else {
		fmt.Println("No")

	}

	// for i := 0; i < n; i++ {

	// }

	// fmt.Println(ans)

}

func calc() int {

	return 0

}

type position struct {
	x        int
	y        int
	distanse int
}

func binarySearch(arr []int, number int) int {

	l := -1
	r := len(arr)
	index := 0
	for {
		mid := l + (r-l)/2
		tmp := arr[mid]

		if r-l <= 1 || tmp == number {
			index = mid
			break
		} else if tmp < number {
			l = mid
		} else {
			r = mid
		}
	}
	return index
}

func factorial(n int) int64 {
	sum := int64(1)
	for i := 2; i <= n; i++ {
		sum *= int64(i)
	}
	return sum
}

func deleteNumOfArray(arr []int, position int) []int {
	left := arr[:position]
	r := arr[position+1:]
	appendArr := append(left, r...)
	return appendArr
}


Measured memory_bytes: 1920
#include <stdio.h>
int main(void)
{

	while (1) {
		int h, w;
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	
	int left = 0, right = n - 1;
	std::string L, R;
	cout << left << endl;
	cin >> L;
	if(L == "Vacant") return 0;
	cout << right << endl;
	cin >> R;
	if(R == "Vacant") return 0;
	while(true) {
		int mid = (left + right) / 2;
		
		cout << mid << endl;
		std::string s; cin >> s;
		
		if(s == "Vacant") break;
		if((right - mid + 1) % 2 != (s == R)) {
			left = mid;
			L = s;
		} else {
			right = mid;
			R = s;
		}
	}
	return 0;
}


Measured memory_bytes: 852
sx,sy,tx,ty=map(int,input().split())

ans=""
for _ in range(tx-sx):
    ans+="R"
for _ in range(ty-sy):
    ans+="U"
for _ in range(tx-sx):
    ans+="L"
for _ in range(ty-sy):
    ans+="D"

ans+="D"
for _ in range(tx-sx+1):
    ans+="R"
for _ in range(ty-sy+1):
    ans+="U"
ans+="L"

ans+="U"
for _ in range(tx-sx+1):
    ans+="L"
for _ in range(ty-sy+1):
    ans+="D"
ans+="R"
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int a, b;
    cin >> a >> b;
    // a-1 
    int ans = ((b-1) + (a-1) - 1) / (a-1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b;
    cin >> a >> b;
    int n=b-a;
    print(n*(n+1)/2-b);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

const int MOD = 1000000007;

// 二項係数nCr
const int MAX = 510000;

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

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

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  long long ans = 0;
  COMinit();
  for (int i = 1; i <= N; i++)
  {
    long long nowMaxS = 0, nowMinS = 0;
    nowMaxS = COM(i - 1, K - 1);
    nowMinS = COM(N - i, K - 1);
    ans += ((A[i - 1] % MOD) * (nowMaxS % MOD) - (A[i - 1] % MOD) * (nowMinS % MOD)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

// Aを予めソート


Measured memory_bytes: 12928
import copy

N,M = [int(i) for i in input().split()]

b = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

def solve(num):
  ret =  0
  c = copy.deepcopy(b)
  c_ = []
  for i in range(M):
    c_ += [(int(i%2 == num))] * p[i]
  #print(c,c_)
  for i in range(N):
    if c[i] != c_[i]:
      for j in range(i,N):
        if c_[i] == c[j]:
          ret += j-i
#          print(j-i)
          c[i],c[j]=c[j],c[i]
          break
      else:
        return 1000
  return ret


print(min(solve(0),solve(1)))



Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

ll gcm(ll a, ll b) {
    if (a < b) return gcm(b, a);
    if (b==0) return a;
    return gcm(b, a%b);
}

int main() {
    
    ll n; cin >> n;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ll t; cin >> t;
        ans = ans/gcm(ans, t)*t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		mut a: [usize; n],
	}

	a.sort();
	let x = a[n-1];
	let mut y = a[0];
	let mut amax = 0;
	for i in 0..n-1 {
		if amax < min(a[i], x-a[i]) {
			amax = min(a[i], x-a[i]);
			y = a[i];
		}
	}
	println!("{} {}", x, y);
}



Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll l,r;
	cin>>l>>r;
	ll y = floor(r/(double)2019);
	ll x = floor(l/(double)2019);
 	if(x!=y)	cout<<"0\n";
	else{
		ll ans = INT_MAX;
		for(ll i=l;i<=r;i++){
			for(ll j=i+1;j<=r;j++){
				// cout<<i<<" "<<j<<endl;
				ll val = i*j;
				val =val%2019;
				ans =min(ans,val);
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    if (a == b && a == c && b == c) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31272
n = int(input())
a = list(map(int, input().split()))
i = n-1
while (i > 1):
    if (a[i-1] > a[i]):
        a[i-1] -= 1
    i -= 1

j = 0
c = 0

while (j < n-1):
    if (a[j] > a[j+1]):
        c += 1
    j += 1
if (c == 0):
    print('Yes')
else:
    print('No')

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

namespace AtCoder.Beginner065
{
    public class ABC065A_Expired
    {
        public static void Main(string[] args)
        {
            
            // スペース区切りの整数の入力
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int x = nums[0];
            int a = nums[1];
            int b = nums[2];


            if( - a + b <= 0 )
            {
                Console.WriteLine("delicious");
                return;
            }
            
            if( -a + b <= x )
            {
                Console.WriteLine("safe");
                return;
            }

            // 結果出力
            Console.WriteLine("dangerous");

        }

    }
}

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

namespace AC
{
    class Program
    {

        static void Main(string[] args)
        {
            var ST = Read().Split(' ').ToArray();

            Console.WriteLine(ST[1] + ST[0]);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  string s; cin>>s;
  
  ll ans=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        vll a={i,j,k};
        ll pos=0;
        rep(ki,n){
          if(s[ki]-'0'==a[pos]){
            pos++;
            if(pos>=3){
              ans++;
              break;
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(void) {

	char c, boin[6] = "aiueo", co = 0;

	cin >> c;
	
	for (int i = 0; i < 5; i++)
		if (c == boin[i]) co = 1;

	if (co == 1) cout << "vowel" << endl;
	else cout << "consonant" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n-1)cin>>c[i];
  int ans=0;
  rep(i,n){
    ans+=b[a[i]-1];
    if(a[i]==a[i+1]-1)ans+=c[a[i]-1];
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	int A, P;
	cin >> A >> P;

	int ans = (A * 3 + P) / 2;



	cout << ans << endl;

	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;



int main(){
      int h, w; cin >> h >> w;
    int  V = 10, E = 10;
    // initialization of Floyd-Warshall
    vector<vector<long long> > dp(V, vector<long long>(V));
    
    // input
    for(int i = 0; i < V; ++i){
        for (int e = 0; e < E; ++e) {
            int c; cin >> c;
            dp[i][e] = c;
        }
    }
    // Floyd-Warshall
    for (int k = 0; k < V; ++k)
        for (int i = 0; i < V; ++i)
            for (int j = 0; j < V; ++j)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    ll ans = 0;
    for(int i = 0; i < h; ++i){
     	for(int j = 0; j < w; ++j){
     	     int a; cin >>a;
              if(a==-1){continue;}
              ans += dp[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<pair<Int,Int> > BA;
Int T;

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        Int a,b;

        cin>>a>>b;
        BA.push_back(make_pair(b,a));
    }

    sort(BA.begin(),BA.end());

    bool flag = false;
    for(int i = 0;i < N;i++) {
        if(T+BA[i].second > BA[i].first) {
            flag = true;
        } else {
            T += BA[i].second;
        }
    }

    if(!flag) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}



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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n)
    {
        cin >> x[i];
    }
    int dist = INF;

    for (int i = 0; i+k-1<n ; i++)
    {
        int dist_temp;
        dist_temp = min(abs(x[i])+abs(x[i+k-1]-x[i]), abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
        dist = min(dist, dist_temp);
    }
    
    cout << dist << endl;
}

Measured memory_bytes: 640
N,A,B,C,D=map(int,input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M//i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j//i)+1)))%M for j in range(N+1)]
print(Z[N])

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

using namespace std;

const long long inf = 1e16;

const int nax = 101;
long long dp[nax][nax * 1001];
int val[nax], w[nax];
int n;

long long rec(int idx, int v) {
  if (v == 0) {
    return 0;
  }
  if (v < 0) {
    return inf;
  }
  if(idx == n) {
    return inf;
  }
  long long &x = dp[idx][v];
  if(x != -1) {
    return x;
  }
  x = min(rec(idx + 1, v), w[idx] + rec(idx + 1, v - val[idx]));
  return x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long we;
  cin >> n >> we;
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    cin >> w[i] >> val[i];
    sum += val[i];
  }
  memset(dp, -1, sizeof dp);
  int res = 0;
  for(int i = 1; i <= sum; ++i) {
    long long zz = rec(0, i);
    if(zz <= we) res = i;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 80000