akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<atcoder/all>
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<set>
#include<vector>
using namespace std;
//using namespace atcoder;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
vector<vector<i64>> edges;
i64 cnt,n;
void dfs(set<i64> st, i64 now){
    if(st.count(now))return ;
    st.insert(now);
    if(st.size() == n){
        cnt++;
        return ;
    }
    for(auto v:edges[now])dfs(st,v);
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 m;
cin >> n >> m;
edges.resize(n);
rep(i,m){
    i64 a,b;
    cin >> a >> b;
    edges[a - 1].emplace_back(b - 1);
    edges[b - 1].emplace_back(a - 1);
}
set<i64> st;
dfs(st,0);
cout << cnt << endl;
}

Measured memory_bytes: 3636
N, Y = map(int, input().split())

for a in range(N + 1):
    for b in range(N - a + 1):
        c = N - a - b
        if 10000*a+5000*b+1000*c == Y:
            print(a,b,c)
            exit()
                
print(-1,-1,-1)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	ll ans=0;
	for(ll i=2;i*i<=n;++i){
		if(n%i==0){
			ll z=i;
			while(n%z==0){
				n/=z;
				z*=i;
				++ans;
			}
			while(n%i==0){
				n/=i;
			}
		}
	}
	if(n!=1) ++ans;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  if (s[0] != 'A') {
    cout << "WA" << "\n";
    return 0;
  }
  bool ok = false;
  FOR(i, 2, s.size()-1) {
    if (s[i] == 'C') {
      if (ok) {
        cout << "WA" << "\n";
        return 0;
      }
      ok = true;
    }
  }
  if (!ok) {
    cout << "WA" << "\n";
    return 0;
  }
  FOR(i, 1, s.size()) {
    if (isupper(s[i]) && s[i] != 'C') {
      cout << "WA" << "\n";
      return 0;
    }
  }
  cout << "AC" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int gcd(int a, int b) {

	if (a == b) return a;
	if (a < b) swap(a, b);

	while (a % b > 0) {
		int c = a % b;

		a = b; b = c;
	}

	return b;
}



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

	long long answer = 0;

	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= n; b++) {

			int aaa = gcd(a, b);

			for (int c = 1; c <= n; c++) {

				answer += gcd(aaa, c);

			}
		}
	}

	cout << answer << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
void solve()
{   
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    ll n;
    cin>>n;
    vector<char> v;
    while(n)
    {
        int rem = n%26;
        if(rem==0)
            {rem = 26;
             n--;}
        v.pb(char(rem-1+'a'));
        n/=26;   
    }
    for(int i=v.size()-1;i>=0;--i)
        cout<<v[i];
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	for (int i = a; i <= b; ++i)
	{
		if(i%n ==0){
			cout<<"OK"<<"\n";
			return 0;
		}
	}
	cout<<"NG"<<"\n";
	return 0;
}

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

int main(){
    int r,c;
    cin >> r >> c;
    int a[r+1][c+1]={};
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> a[i][j];
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j!=c)printf("%d ",a[i][j]);
            else printf("%d\n",a[i][j]);
        }
    }
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {

	ll x, y; char z;
	while (cin >> x >> z >> y) {
		if (z == '?') { break; }
		else {
			switch (z) {
			case '+':cout << x + y << endl;
				break;
			case '-':cout << x - y << endl;
				break;
			case '*':cout << x * y << endl;
				break;
			case '/':cout << x / y << endl;
			}
		}
	}

}



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

#define ll long long int
#define ri register int

using namespace std;

int main()
{
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if ((i - j) >= 0)
			{
				dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
			}
		}
		
	}
	cout << dp[n - 1] << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int h_num,t_num,o_num;
  h_num = N / 100;
  N %= 100;
  t_num = N / 10;
  o_num = N % 10;
  if(h_num == 7){
   cout << "Yes" << endl; 
  }
  else if(t_num == 7){
    cout << "Yes" << endl;
  }
  else if(o_num == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

int main() {
	int n; std::cin >> n;
	std::vector<int> nums(n); for (auto& num : nums) std::cin >> num;
	int max = 0;
	for (auto i = 0; i < n; ++i) {
		if (nums[max] < nums[i]) {
			max = i;
		}
	}
	int second_max = (max == 0) ? 1 : 0;
	for (auto i = 0; i < n; ++i) {
		if (max != i && nums[second_max] < nums[i]) {
			second_max = i;
		}
	}
	for (auto i = 0; i < n; ++i) {
		if (i != max) {
			std::cout << nums[max] << std::endl;
		}
		else {
			std::cout << nums[second_max] << std::endl;
		}
	}
}

Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		int MAX = 1000000;
		int[][] ans = new int[2][MAX];
		Arrays.fill(ans[0], MAX * 2);
		Arrays.fill(ans[1], MAX * 2);
		ans[0][0] = ans[1][0] = 0;
		for (int i = 1;; ++i) {
			int tetra = i * (i + 1) * (i + 2) / 6;
			if (tetra >= MAX) break;
			for (int j = 0; j + tetra < MAX; ++j) {
				ans[0][j + tetra] = Math.min(ans[0][j] + 1, ans[0][j + tetra]);
			}
			if (tetra % 2 != 0) {
				for (int j = 0; j + tetra < MAX; ++j) {
					ans[1][j + tetra] = Math.min(ans[1][j] + 1, ans[1][j + tetra]);
				}
			}
		}
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			System.out.println(ans[0][N] + " " + ans[1][N]);
		}
	}
}

Measured memory_bytes: 29884
import kotlin.math.*
fun main(args: Array<String>) {
  val n = readLine()!!.split(' ').map(String::toDouble)
  var angle = 0.0
  if(Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0) > PI){
    angle = 2.0*PI - Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)
  }else{
    angle = Math.abs(n[2]*PI/6.0 - n[3]*11*PI/360.0)
  }
  println(Math.sqrt(n[0]*n[0] + n[1]*n[1] - 2*n[0]*n[1]*cos(angle)))
  //val s = cos(PI)
  //println(s)
}

Measured memory_bytes: 36648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll N, M;
  cin >> M >> N;
  if (N / 2 < M) {
    cout << N / 2 << endl;
    return 0;
  }
  ll ans = M;
  N -= 2*M;
  ans += N / 4;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    vector<long long> h(n);
    rep(i, n) cin >> h[i];
    vector<long long> dp(n, INFLL); dp[0] = 0;
    rep(i, n-1){
        for(ll j=1; j<=k; j++){
            if(i+j >= n) continue;
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int result = 0;
  if(a == b){
    if(a == c){
      result = 1;
    }else{
      result = 2;
    }
  }else{
    if(a == c || b == c){
      result = 2;
    }else{
      result = 3;
    }
  }

  cout << result;
  return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define INF 1000000
#define WHITE 0
#define BLACK 1
int d[MAX],color[MAX];
int n;

typedef struct{
  int num,str,cost;
}Ver;
Ver M[500000];

void dijkstra(int x){
  int i,u=1;
  for(i=0;i<n;i++)d[i]=INF;
  d[0]=0;
  while(u!=0){
    u=0;
    for(i=0;i<x;i++){
      if(M[i].cost+d[M[i].str]<d[M[i].num]){
	d[M[i].num]=M[i].cost+d[M[i].str];
	u=1;
      }
    }
  }
}

int main(){
  int i,j,u,k,v,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      M[count].str=u;
      scanf("%d",&M[count].num);
      scanf("%d",&M[count].cost);
      count++;
    }
  }
  dijkstra(count);

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}



Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0,X=0;cin>>N;vector<int>d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);S+=d.at(i);
  }
  for(int i=0;i<N;i++)X+=(S-d.at(i))*d.at(i);
  cout<<X/2<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n = 0 ;
  int i ; 
  int count = 0 ;
  scanf("%d",&n);

  int a[n] ;
  for (i = 0 ; i < n ; i++){
    scanf("%d",&a[i]);
  }


  for (i = 0 ; i < n - 1 ; i++ ){
    if (a[i] == a[i+1]){
      count++;
      i++;

    }
  }
  printf("%d\n",count);
  return 0 ;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  if (s.at(1) == t.at(1)) {
    if (s.at(0) == t.at(2) && s.at(2) == t.at(0)) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#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 oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  vll A(n);
  ll sum=0;
  ll all=0;
  FOR(i,0,n){
    ci(A[i])
    all+=A[i];
    if(i%2==0){
      sum+=A[i];
    }
  }
  all/=2;
  A[n-1]-=sum-all;
  rFOR(i,n-2,0){
    A[i]-=A[i+1];
  }
  FOR(i,0,n){
    co(2*A[i])
  }
}

Measured memory_bytes: 2048
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>

const int maxn = 2e5 + 100;

const int oo = 2123456789;

int n, m, LOG[maxn], par[maxn];
std::pair<int, int> q[maxn], st[maxn][18][2], ans[maxn];
std::vector<int> g[maxn];
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > heap;

int main() {
	scanf("%d", &n);
	LOG[1] = 0;
	for (int i = 2; i <= n; ++i) {
		LOG[i] = LOG[i >> 1] + 1;
	}
	for (int i = 1; i <= n; ++i) {
		if(i & 1) {
			scanf("%d", &st[i][0][1].first);
			st[i][0][0].first = oo;
		}
		else {
			scanf("%d", &st[i][0][0].first);
			st[i][0][1].first = oo;
		}
		st[i][0][0].second = st[i][0][1].second = i;
	}
	for (int f = 0; f < 2; ++f) {
		for (int LOG = 1; LOG < 18; ++LOG) {
			for (int i = 1, j = i + (1 << LOG - 1); j <= n; ++i, ++j) {
				st[i][LOG][f] = std::min(st[i][LOG - 1][f], st[j][LOG - 1][f]);
			}
		}
	}
	q[m++] = std::make_pair(1, n);
	n = 0;
	for (int it = 0; it < m; ++it) {
		int l = q[it].first, r = q[it].second, lg = LOG[r - l + 1], i = std::min(st[l][lg][l & 1], st[r - (1 << lg) + 1][lg][l & 1]).second, j;
		lg = LOG[r - i + 1];
		j = std::min(st[i][lg][r & 1], st[r - (1 << lg) + 1][lg][r & 1]).second;
		if(i > l) {
			par[m] = n;
			g[n].push_back(m);
			q[m++] = std::make_pair(l, i - 1);
		}
		if(j < r) {
			par[m] = n;
			g[n].push_back(m);
			q[m++] = std::make_pair(j + 1, r);
		}
		if(i + 1 < j) {
			par[m] = n;
			g[n].push_back(m);
			q[m++] = std::make_pair(i + 1, j - 1);
		}
		ans[n++] = std::make_pair(st[i][0][i & 1].first, st[j][0][j & 1].first);
	}
	heap.push(std::make_pair(ans[0].first, 0));
	while(!heap.empty()) {
		int i = heap.top().second;
		heap.pop();
		printf("%d %d ", ans[i].first, ans[i].second);
		for (int u: g[i]) {
			heap.push(std::make_pair(ans[u].first, u));
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
vector<int> e;
bool used[222222];
bool showed[222222];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	memset(used,0,sizeof(used));
	rep(i,m){
		int ee;
		cin>>ee;
		e.pb(ee);
		used[ee]=true;
	}
	reverse(all(e));
	rep(i,e.size()){
		if(showed[e[i]])continue;
		cout<<e[i]<<endl;
		used[e[i]]=true;
		showed[e[i]]=true;
	}
	repl(i,1,n+1){
		if(!used[i])cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int n, m;
int edge[100][100];

int main(void)
{
    cin >> n >> m;
    long long ans = 0;
    int array[n - 1];
    REP(i, n - 1)
    {
        array[i] = i + 2;
    }

    REP(i, m)
    {
        int a, b;
        cin >> a >> b;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }

    do
    {
        bool flag = true;
        if (edge[1][array[0]] == 0)
            flag = false;
        REP(i, n - 2)
        {
            if (edge[array[i]][array[i + 1]] == 0)
                flag = false;
        }
        if (flag)
            ans++;
    } while (next_permutation(array, array + n - 1));

    cout << ans << endl;
}


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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

struct activity{
ll A,B,C;};

ll solve(ll n,vector<activity>v){
    ll dp[n+1][3];
dp[1][0]=v[1].A;
dp[1][1]=v[1].B;
dp[1][2]=v[1].C;
for(int i=2;i<=n;i++)
{
    dp[i][0]=v[i].A+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=v[i].B+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=v[i].C+max(dp[i-1][1],dp[i-1][0]);
}

return max(dp[n][0],max(dp[n][1],dp[n][2]));

}

int main()
{
    FIO;
    ll a,b,c,d,e,f=0,sum=0,ans,ck=0,m,n,k,p,q,r,t,add=0,x,y,z;

    string s;

    cin>>n;
    vector<activity>v(n+1);
    for(int i=1;i<=n;i++){cin>>v[i].A;cin>>v[i].B;cin>>v[i].C;}
    ans=solve(n,v);
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 10308
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
const int maxn=1e5+5;
using namespace std;
string s;
inline int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9')
		f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9')
		x = x * 10 + ch - 48, ch = getchar();
	return x * f;
}
bool isp(int l,int r) {
	while(l<r) {
		if(s[l]!=s[r])
			return false;
		l++,r--;
	}
	return true;
}
int main() {
	cin>>s;
	int n=s.size();
	if(isp(0,n-1)&&isp(0,(n-1)/2-1)&&isp((n+3)/2-1,n-1))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N; cin>>N;
    int T[4]={0,0,0,0}; string s;
    for (int i=0; i<N; i++) {
        cin>>s;
        if (s=="AC") {
            T[0]++;
        } else if (s=="WA") {
            T[1]++;
        } else if (s=="TLE") {
            T[2]++;
        } else if (s=="RE") {
            T[3]++;
        }
    }
    printf("AC x %d\n",  T[0]);
    printf("WA x %d\n",  T[1]);
    printf("TLE x %d\n", T[2]);
    printf("RE x %d\n",  T[3]);
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=998244353;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli p[1000007];
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    p[1]=1;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {
                qrr[i]=0;
                if (p[j]==0)
                p[j]=i;
            }
        }
    }
    return 0;
}
lli find(lli x)
{
    vll v;
    lli prev=p[x],sum;
    while (prev!=x)
    {
        sum=0;
        while (x%prev==0)
        {
            sum++;
            x/=prev;
        }
        v.pb(sum);
        prev=p[x];
    }
    if (x!=1)
    {
        v.pb(1);
    }
    if (v.size()==0)
    {
        return 2;
    }
    sum=1;
    for (int i=0;i<v.size();i++)
    {
        sum*=(v[i]+1);
    }
    
    return sum;
}
int main()
{
    fio;
    lli n;
    cin>>n;
    sieve(n);
    lli ans=0;
    //for (int i=1;i<=n;i++)
    //cout<<p[i]<<"\n";
    for (int i=n-1;i>1;i--)
    {
        ans+=find(i);
    }
    ans++;
    cout<<ans<<"\n";
    return 0;
}

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

int main(){
  // input
  int N;
  cin >> N;
  vector<int> V(N),C(N);
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  // compute
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(V.at(i) > C.at(i)){
      ans += V.at(i) - C.at(i);
    }
  }
  
  // output
  cout << ans << endl;
}

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100;
const int K = 3;

struct Input {
	int n, m;
	int w[N], v[N];
	
	bool read () {
		if (!(cin >> n >> m)) {
			return 0;
		}
		forn (i, n) {
			scanf("%d%d", &w[i], & v[i]);
		}
		return 1;
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	int ans;
	
	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		int d[N + 1][N * K + 1];
		
		void solve () {
			memset(d, 0, sizeof d);
			forn (i, n) {
				ford (j, i + 1) {
					forn (k, i * K + 1) {
						umx(d[j + 1][k + w[i] - w[0]], d[j][k] + v[i]);
					}
				}
			}
			ans = 0;
			forn (i, m / w[0] + 1) {
				forn (j, min(n * K, m - i * w[0]) + 1) {
					umx(ans, d[i][j]);
				}
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 384
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let x: i32 = input();
    let l: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut d = vec![0; n + 1];
    for i in 0..n {
        d[i + 1] = d[i] + l[i];
    }
    println!("{}", d.iter().filter(|&&d| d <= x).count());
}


Measured memory_bytes: 4352
T = int(input())

while(T > 0):
    N, A, B, C, D = map(int, input().split())
    memo = {}
    def d(n):
        if n == 0:
            return 0

        if n == 1:
            return D

        if n in memo:
            return memo[n]

        ret = n * D

        if (n % 2 == 0):
            ret = min(ret, A + d(n // 2))
        else:
            ret = min(ret, (n%2)*D + A + d(n // 2), (2-n%2)*D + A + d((n+(2-n%2))//2))

        if (n % 3 == 0):
            ret = min(ret, B + d(n // 3))
        else:
            ret = min(ret, (n%3)*D + B + d(n // 3), (3-n%3)*D + B + d((n+(3-n%3))//3))

        if (n % 5 == 0):
            ret = min(ret, C + d(n // 5))
        else:
            ret = min(ret, (n%5)*D + C + d(n // 5), (5-n%5)*D + C + d((n+(5-n%5))//5))

        memo[n] = ret
        return ret

    print(d(N))
    T -= 1




Measured memory_bytes: 10904
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  long k, a, b; rd(k, a, b);

  if(a>=k){writeln(1); return;}
  auto d=a-b;
  if(d<=0){writeln(-1); return;}
  auto tmp=(k-a+d-1)/d;
  writeln(tmp*2+1);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string S;
int N; // Size of S
int dp[100001][13]; // dp[ i ][ j ]...上 i 桁までで j ( mod 13 ) となる数
int main(){
    cin>>S;
    N=S.size();
    dp[0][0]=1;
    int x;
    for(int i=0;i<N;i++){
        if(S[i]!='?'){
            x=(int)S[i]-'0';
            for(int j=0;j<13;j++){
                dp[i+1][(j*10+x)%13]=dp[i][j];
            }
        }else{
            for(int x=0;x<10;x++){
                for(int j=0;j<13;j++){
                    dp[i+1][(j*10+x)%13]+=dp[i][j];
                    dp[i+1][(j*10+x)%13]%=1000000007;
                }
            }
        }
    }
    cout<<dp[N][5]<<endl;
}

Measured memory_bytes: 5504
import sys
from math import log2, ceil

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    for i in range(1, n+1):
        if i >= k:
            res += n - i + 1
            break
        res += pow(2, -ceil(log2(k / i)))

    return res / n

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  if(n%1000==0)cout<<0<<endl;
  else cout<<1000-n%1000<<endl;
}

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


int main(){
  int n,tmp;
  // vector<int> s;
  priority_queue<int> ps;
  // int max1=0,max2=0;
  cin >> n;
  // bool stat[]
  for(int i=0;i<n;i++){
    cin >> tmp;
    ps.push(tmp);
  }
  int cnt=0;
  int max[2]={};
  while(ps.size() >=2){
    int a = ps.top();
    ps.pop();
    int b = ps.top();
    if(a==b){
      ps.pop();
      max[cnt++] = a;
      if(cnt>1)
        break;
    }
  }

  cout << (long long)max[0]*max[1] << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

int main(){
    int N,K;
    string S;
    cin>>N>>K>>S;
    int kazu=1;
    
    for(int i=1;i<N;i++){
        if(S.at(i)!=S.at(i-1)) kazu++;
    }
    
    if(kazu>2*K) kazu-=2*K;
    else kazu=1;
    cout<<N-kazu<<endl;
    
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);



mint dp[101][4][4][4];

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

  // A:0 C:1 G:2 T:3
  // AGC: 021
  // NG AGC(021), ACG(012), GAC(201), A?GC(0?21), AG?C(02?1)

  REP(i,4)REP(j,4)REP(k,4){
    if(i==0 && j==2 && k==1)continue;
    if(i==2 && j==0 && k==1)continue;
    if(i==0 && j==1 && k==2)continue;
    dp[3][i][j][k]=1;
  }

  FOR(i,4,n+1){
    REP(c1,4)REP(c2,4)REP(c3,4)REP(c4,4){
      if(c2==0 && c3==2 && c4==1)continue;
      if(c2==0 && c3==1 && c4==2)continue;
      if(c2==2 && c3==0 && c4==1)continue;
      if(c1==0 && c3==2 && c4==1)continue;
      if(c1==0 && c2==2 && c4==1)continue;
      dp[i][c2][c3][c4] += dp[i-1][c1][c2][c3];
    }
  }

  mint ans=0;
  REP(i,4)REP(j,4)REP(k,4)ans+=dp[n][i][j][k];

  cout << ans.x << endl;
}



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

using namespace std;

long long mod = 1000000007;

int dp[2005];

int main()
{
    int n;
    cin>>n;
    dp[0] = 1;
    for(int i=3;i<=n;i++) {
        for(int j=3;j<=i;j++) {
            dp[i] += dp[i-j];
            dp[i] %= mod;
        }
    }
    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 3588
n = int(input())
t = [0 for i in range(n)]
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    t[i], x[i], y[i] = list(map(int, input().split()))

t_0 = 0
x_0 = 0
y_0 = 0

can = True

dt = t[0] - t_0
dx = x[0] - x_0
dy = y[0] - y_0
dist = abs(dx) + abs(dy)

if dt >= dist and dt % 2 == dist % 2:
    can = True
else:
    can = False

for i in range(1, n):
    dt = t[i] - t[i - 1]
    dx = x[i] - x[i - 1]
    dy = y[i] - y[i - 1]
    dist = abs(dx) + abs(dy)
    if dt >= dist and dt % 2 == dist % 2:
        can = True
    else:
        can = False
        break

if can:
    print("Yes")
else:
    print("No")

pass


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int x,a,b;
	cin>>x>>a>>b;
	if (b<=a){
		cout<<"delicious";
	}
	else if (a+x>=b){
		cout<<"safe";
	}
	else {
		cout<<"dangerous";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int md = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    if (a >= md) a -= md;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector <vector <char>> f(n, vector <char> (m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> f[i][j];
        }
    }
    vector <vector <int>> dp(n + 1, vector <int> (m + 1));
    dp[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (f[i - 1][j - 1] == '#') continue;
            add(dp[i][j], dp[i - 1][j]);
            add(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << dp[n][m] << '\n';
}

Measured memory_bytes: 5248
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X,A,B;
    cin >> X >> A >> B;
    if(B <= A){
      cout << "delicious\n";
    }else if(B <= A+X){
      cout << "safe\n";
    }else{
      cout << "dangerous\n";
    }
    return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
int l[111111];

signed main(){
   cin>>n;
   rep(i,n)cin>>l[i];
   sort(l,l+n);
   rep(i,n){
   	for(int j=i+1;j<n;j++){
   		int dis=distance(l+j+1,lower_bound(l,l+n,l[i]+l[j]));
   		ans+=dis;
   	}
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;};
typedef struct Node_struct Node;
Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for (i =0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void rec(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) rec(T[u].l, p + 1);
  if(T[u].r != -1) rec(T[u].r, p);
}

int main(){
  int i, j, k;
  int N;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &N);
  for(i=0;i<N;i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<N; i++){
    scanf("%d %d", &id, &k);
    for(j =0, sib= NIL; j<k; j++){
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child;
      else T[sib].r = child;
      sib = child;
    }
  }

  for(i=0; i<N; i++){
    if(T[i].p == -1) root = i;
  }
  rec(root, 0);
  for(i=0; i<N; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 4252
//Author: master19
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define all(arr) arr.begin(),arr.end()
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define Sort(arr) sort(arr.begin(), arr.end())
#define time() std::chrono::high_resolution_clock::now();
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
#define Time(start, finish) std::chrono::duration<double> elapsed = finish - start; cout << elapsed.count() << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
void debug_out() { cerr << endl; }
template <typename HeadStart, typename... TailEnd>
void debug_out(HeadStart H, TailEnd... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll lets_do_it();
pair < ll, ll > xy[] = {{-1, 0}, {1, 0} , {0, -1}, {0, 1}};
pair < ll, ll > dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
bool isValid(ll x, ll y, ll row, ll col){
    return ((x>=0) && (y >=0)  && (x < row) && (y < col));
}
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    return 0;
}
ll lets_do_it(){
    // Your code goes by here !!
    ll num;
    cin >> num;
    ll count = 0;
    for(int i=1; i<=num; i++){
        ll value = num/i;
        if(value * i == num)
            value--;
        count += value;
    }
    cout << count << endl;




    return 0;
}


Measured memory_bytes: 3620
s=input()
state=0
mai=0
for i in range(len(s)):
  k=int(s[len(s)-1-i])
  if state==1:
    k=k+1
    if k<0:
      k=10+k
  elif state==2:
    if k>=5:
      k=k+1
      if k<0:
        k=10+k
  if k>5:
    mai+=10-k
    state=1
  elif k<5:
    mai+=k
    state=0
  elif k==5:
    state=2
    mai+=k
if k>=6:
  mai+=1
print(mai)

Measured memory_bytes: 5492
let main = (standardInput) => {
    let asa = standardInput.split(' ');
    let w = Number.parseInt(asa[0]);
    let h = Number.parseInt(asa[1]);
    let x = Number.parseInt(asa[2]);
　  let y = Number.parseInt(asa[3]);   
　  let r = Number.parseInt(asa[4]);

if(((x-r)<0 || (x+r)>w) || ((y-r)<0 || (y+r)>h)){
    console.log('No');
}else if(((x-r)>=0 && (x+r)<=w) || (((y-r)>=0 && (y+r)<=h))){
    console.log('Yes');
}
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15356
n = int(input())
a = list(map(int, input().split()))
if n%2:
  b = [i for i in range(n-1, 0, -2)]*2
  b.append(0)
else:
  b = [i for i in range(n-1, 0, -2)]*2
if sorted(a)!=sorted(b):
  print(0)
else:
  print(pow(2, n//2, 10**9+7))

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define ll long long int
#define fori(n) for(int i=0;i<n;i++)
using namespace std;
int main(){
string a;
cin>>a;
if((a[0]=='7'||a[1]=='7')||a[2]=='7') cout<<"Yes";
else cout<<"No";




 return 0;    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
   fast
   ll n;
   cin>>n;
   cout<<n*n*n<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define sc second
#define fr first
#define mp make_pair
const int N = 100000 , MOD = 1e9 + 7;
const int OO = 1e9 + 5000;
int main() {
	map<string,ll > me;
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		me[s]++;
	}
	ll ans = 0;
	for (auto c : me) {
		ans += (c.second*c.second - c.second)/2;
	}
	cout << ans << endl;
}

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

int main() {
  int n,m;
  ll answer=0,z=0;
  cin>>n>>m;
  int a,b,c;
  ll vec[n][3];
  ll vecb[n][3];
  vector<ll> sum(n);
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>vec[i][j];
    }
  }
  
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        
        
        for(int a=0;a<n;a++){
          for(int b=0;b<3;b++){
            vecb[a][b]=vec[a][b];
          }
        }
        if(i==1){
          for(int a=0;a<n;a++){
            vecb[a][0]*=-1;
          }
        }
        if(j==1){
          for(int a=0;a<n;a++){
            vecb[a][1]*=-1;
          }
        }
        if(k==1){
          for(int a=0;a<n;a++){
            vecb[a][2]*=-1;
          }
        }
        for(int a=0;a<n;a++){
          sum.at(a)=vecb[a][0]+vecb[a][1]+vecb[a][2];
        }
        sort(sum.begin(),sum.end());
        reverse(sum.begin(),sum.end());
        for(int a=0;a<m;a++){
          z+=sum.at(a);
        }
        answer=max(z,answer);
        z=0;
      }
    }
  }
  cout<<answer<<endl;      
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

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

int main() {
	ll A, B, H, M;
	cin >> A >> B >> H >> M;
	auto ans = sqrt(A*A+B*B-2*A*B*cosl(11 * M_PI * (60 * H + M) / 360));

	cout << setprecision(numeric_limits<double>::max_digits10) << ans << endl;
	return 0;
}


Measured memory_bytes: 3548
A,B,K = map(int,input().split())
for i in range(K):
    if(i%2==0):
        if(A%2==0):
            A = A//2
            B += A
        else:
            A = (A-1)//2
            B += A
    else:
        if(B%2==0):
            B = B//2
            A += B
        else:
            B = (B-1)//2
            A += B
print('%d %d'%(A,B))


Measured memory_bytes: 3060