akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll X; cin >> X;
  auto a = X / 11;
  auto b = X % 11;
  if (b == 0) {
    cout << a*2 << CRLF;
  } else if (b <= 6) {
    cout << (a*2 + 1) << CRLF;
  } else {
    cout << (a*2 + 2) << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

int main() {
	int a, b;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b;
		int max, min;
		vector<int> v;
		priority_queue<int> big;
		priority_queue<int, vector<int>, greater<int>> small;
		for (int j = 0; j < b; j++) {
			int in;
			cin >> in;
			v.push_back(in);
		}
		for (int j = 0; j < b-1; j++) {
			int d = v[j+1] - v[j];
			big.push(d);
			small.push(d);
		}
		if (big.top() < 0) max = 0;
		else max = big.top();
		if (small.top() > 0) min = 0;
		else min = small.top() * -1;
		cout << max << " " << min << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<set>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	int n,m;
	bool a[1001];
	int cnt,cn2;
	int j;

	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		for(int i=0;i<1001;i++) a[i]=true;
		cnt=0;
		cn2=n;
		j=1;
		while(1){
			if(a[j]==true&&cn2==1) break;
			if(a[j]==true) cnt++;
			if(cnt==m) cnt=0,cn2--,a[j]=false;
			j++;
			if(j==n+1) j=1;
		}
		cout<<j<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
<?php
  list($n, $t) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $ans = $t;
  $y = $t;
  for($i=1; $i<$n; $i++){
    if($y >= $a[$i]){
      $ans += ($a[$i] - $y + $t);
      $y = $a[$i] + $t;
    }else{
      $ans += $t;
      $y = $a[$i] + $t;
    }
  }
  echo $ans;

Measured memory_bytes: 31704
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(ab.Any(x => x % 2 == 0) ? "No" : "Yes");
    }
}

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

int main() {
	int N, M, ans = 0;
	cin >> N >> M;

	vector<int> V(M, 0);

	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;

		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;

			A--;

			++V[A];
		}
	}

	for (int i = 0; i < M; i++) if (V[i] == N) ans++;
	
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 1000

ll BegFrom[MAX_N] = {}; // i を含む、 i 以降に始まったものの数
ll EndFrom[MAX_N][MAX_N] = {}; // i 以降に始まって、j を含まない、 j より後に終わったものの数
ll N, M, Q;
vector< pair<ll, ll> > Lr;
vector< pair<ll, ll> > Pq;

signed main()
{
    cin >> N >> M >> Q;
    REP(i, M) {
        ll l, r;
        cin >> l >> r;
        Lr.push_back({l, r});
        BegFrom[l+1]--;
        for(int j = 1; j <= l; ++j) {
            EndFrom[j][r]--;
        }
    }
    REP(i, Q) {
        ll p, q;
        cin >> p >> q;
        Pq.push_back({p, q});
    }

    BegFrom[1] = M;
    for(ll i = 2; i <= N; ++i) {
        BegFrom[i] += BegFrom[i-1];
    }
    for(ll i = 1; i <= N; ++i) {
        EndFrom[i][0] = BegFrom[i];
        for(ll j = 1; j <= N; ++j) {
            EndFrom[i][j] += EndFrom[i][j-1];
        }
    }

    REP(i, Q) {
        printf("%lld\n", BegFrom[Pq[i].first] - EndFrom[Pq[i].first][Pq[i].second]);
    }

    return 0;
}


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

void solve()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int p = 0;
	for (int i = 0; i < k; ++i)
	{
		p += a[i];
	}
	cout<<p<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

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

#define MAX 500000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2],R[MAX/2+2];

llong merge(int A[], int left, int mid, int right) {
    int i, j, k;
    llong cnt = 0;
	int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = 0, j = 0;
    for(int k = left; k < right; k++) {
        if(L[i] <= R[j]) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
            cnt += n1 -i; 
        }
    }
	return cnt;   
} 
 
llong mergeSort(int A[], int left, int right) {
    int mid;
    llong v1, v2, v3;
    if(left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1 + v2 + v3;
    } else return 0;
}

int main() {
	int A[MAX], n, i;
	
	cin >> n;
	for(i = 0; i < n; i++) {
		cin >> A[i];
	}
	
	llong ans = mergeSort(A, 0, n);
	cout << ans << endl;
	
	return 0; 
}

Measured memory_bytes: 4648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
string s[100][100];
int main() {
  int n;cin>>n;
  vector<int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<v[n-1]<<endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int64_t> a(N);
    int64_t sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int64_t x = 0, y = 0;
    int64_t mnv = 1e15;
    for (int i = 0; i < N - 1; i++)
    {
        x += a[i];
        y = sum - x;
        mnv = min(mnv, abs(x - y));
    }
    cout << mnv << endl;
}

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

using namespace std;
using ll = long long;

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

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  vector<int> l(n + 1), r(n + 1);
  rep(i, n) {
    l[i + 1] = gcd(l[i], a[i]);
    r[i + 1] = gcd(r[i], a[n - 1 - i]);
  }

  int ans = 0;
  rep(i, n) { ans = max(ans, gcd(l[i], r[n - 1 - i])); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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 int MAX = 710000;

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(){
    int X,Y;
    cin >> X >> Y;
    if ((X+Y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    int Z=(X+Y)/3;
    COMinit();
    cout << COM(Z,X-Z) << endl;
}

Measured memory_bytes: 16896
N = int(input())
a = list(map(int, input().split()))
j = 1
ans = 0

for i in range(N):
  if i != N-1 and a[i] == j:
    j += 1
  
  elif i != N-1 and a[i] != j:
    ans += 1

  elif i == N-1 and a[i] == j:
    break
  
  else:
    ans += 1
    break

if N == 1 and a[0] == 1:
  ans = 0
    
elif ans == N:
  ans = -1
  
print(ans)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define MN 200000
int a[MN+5],b[MN+5];
int main()
{
	int n,i;long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),b[i]=a[i]=a[i]-i;
	sort(b+1,b+n+1);
	for(i=1;i<=n;++i)ans+=abs(a[i]-b[n+1>>1]);
	printf("%lld",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  if((a+b) % 2 == 0){
    c = (a+b)/2;
  }else{
    c = (a+b)/2 + 1;
  }
  cout << c << endl;
}


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

int main(){
	int t;
	cin>>t;
	int sum =0;
	vector<int>v(t);
	for(int i = 0;i<t;i++){
		cin>>v[i];
		sum+=v[i];
	}
	int mini = sum;
	int pref_sum = 0;
	for(int i = 0;i<t;i++){
		pref_sum +=v[i];
		mini = min(mini,abs(pref_sum-(sum-pref_sum)));
	}
	cout<<mini;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 1002;
ll a[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	vector<ll> v;
	for(int i=1;i<=n;i++)
	{
		ll s = 0;
		for(int j=i;j<=n;j++)
		{
			s += a[j];
			v.pb(s);
		}
	}
	ll mask = 0;
	for(int i=50;i>=0;i--)
	{
		ll c = (mask|(1LL<<i));
		int z = 0;
		for(auto u:v)
		{
			if((u&c) == c)
				z++;
		}
		if(z>=k)
			mask = c;
	}
	cout<<mask<<"\n";
	return 0;
}

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

int bubble(int n, vector<int> &v) {
  int cnt = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = n - 1; i >= 1; i--) {
      if (v.at(i) < v.at(i - 1)) {
        swap(v.at(i), v.at(i - 1));
        cnt++;
        flag = true;
      }
    }
  }
  return cnt;
}

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  int ans = bubble(n, v);
  for (int i = 0; i < n; i++) {
    if (i == n - 1)
    cout << v.at(i) << endl;
    else
    cout << v.at(i) << " ";
  }
  cout << ans << endl;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	string s; cin >> s;
	stack<LL> st;
	LL cnt = 0;
	rep(i, 0, s.length()) {
		if(st.empty())	st.push(s[i]-'0');
		else if(st.top() == s[i]-'0')	st.push(s[i]-'0');
		else	st.pop(), cnt++;
	}
	pll(2*cnt); nl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N; cin >> N;
  
  vector < pair < pair<ll, ll>, int> > XY(N), YX(N);

  for (int i = 0; i < N; i++){
    ll X, Y; cin >> X >> Y;
    XY[i].first = make_pair(X, Y); XY[i].second = i;
    YX[i].first = make_pair(Y, X); YX[i].second = i;
  }
  sort(XY.begin(), XY.end());
  sort(YX.begin(), YX.end());

  vector < pair<ll, int> > graph[N];

  for (int i = 0; i < N - 1; i++){
    ll X1 = XY[i].first.first, X2 = XY[i+1].first.first;
    int now = XY[i].second, next = XY[i+1].second;
    graph[now].push_back(make_pair(X2 - X1, next));
    graph[next].push_back(make_pair(X2 - X1, now));

    ll Y1 = YX[i].first.first, Y2 = YX[i+1].first.first;
    now = YX[i].second; next = YX[i+1].second;
    graph[now].push_back(make_pair((Y2 - Y1), next));
    graph[next].push_back(make_pair((Y2 - Y1), now));
  }

  vector <bool> visited(N);
  ll ans = 0;

  priority_queue <pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;
  que.push(make_pair(0, 0));
  while (!que.empty()){
    pair<ll, int> Q = que.top(); que.pop();

    if (visited[Q.second] == false){
      ans += Q.first;
      visited[Q.second] = true;

      for (int i = 0; i < graph[Q.second].size(); i++){
        pair <ll, int> P = graph[Q.second][i];
        if (visited[P.second] == false){
          que.push(P);
        }
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}

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

int main(){
    string S;  cin >> S;

    string up = S.substr(0,2);
    string down = S.substr(2,2);
    if("01" <= up && up <= "12" && "01" <= down && down <= "12"){
        cout << "AMBIGUOUS" << endl;
    }else if("01" <= up && up <= "12"){
        cout << "MMYY" << endl;
    }else if("01" <= down && down <= "12"){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
char s[1010000];
int main(){
	ios::sync_with_stdio(0);
	cin>>s+1;
	int n=strlen(s+1);
	int flag=1;
	for(int i=1;i<=n;i++){
		if(i>1)flag&=s[i]!=s[i-1];
	}
	if(flag){cout<<1<<'\n';return 0;}
	int now=0,p[3]={0,-1,-1},f[101000]={1};
	for(int i=1;i<=n;i++){
		now=(now+s[i]-'a'+1)%3;
		if(!now&&i<n) f[i]=1;
		auto upd=[](int&a,int b){a+=b;if(a>=mod) a-=mod;};
		if(~p[(now+2)%3]) upd(f[i],f[p[(now+2)%3]]);
		if(~p[(now+1)%3]) upd(f[i],f[p[(now+1)%3]]);
		p[now]=i;
	}
	cout<<f[n]<<'\n';
	return 0;
}


Measured memory_bytes: 768
use proconio::input;
 
fn main() {
  input! {
    n: u64
  }
  
  let mut result: u64 = 0;

  for i in 1..=n {      
    if i % 3 != 0 && i % 5 != 0 {
      result += i;
    }
  }
  
  println!("{}", result);
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n;
        cin>>n;
        LL a[n];
        LL b[n];
        LL c[n];
        LL d[n+1][4];
        fr(i,0,n){
            cin>>a[i]>>b[i]>>c[i];
        }
        d[0][1]=a[0];
        d[0][2]=b[0];
        d[0][3]=c[0];
        fr(i,1,n)
        {  
            d[i][1]=max(d[i-1][2],d[i-1][3])+a[i];
            d[i][2]=max(d[i-1][1],d[i-1][3])+b[i];
            d[i][3]=max(d[i-1][1],d[i-1][2])+c[i];
        }
        cout<<max(d[n-1][1],max(d[n-1][2],d[n-1][3]))<<endl;
    return 0;
}

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

int main()
{   
    int w,h,n;
    cin>>w>>h>>n;
    int x[n],y[n],a[n];
    int b=0,c=w,d=0,e=h;
    
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
        if(a[i]==1)b=max(x[i],b);
        else if(a[i]==2)c=min(x[i],c);
        else if(a[i]==3)d=max(y[i],d);
        else e=min(y[i],e);
    }
    if(b>=c || d>=e) cout<<0<<endl;
    else cout<<(c-b)*(e-d)<<endl;


}

Measured memory_bytes: 256
n = int(input())
a  = list(map(int, input().split()))
a.sort()
dp = [0]*a[n-1]
ans = 0
temp2 = 0
for i in range(n):
  if temp2 == a[i]:
    ans -= 1
    temp2=0
  if dp[a[i]-1] == 0:
    ans += 1
    temp = a[i]
    temp2 = a[i]
    while temp <= a[n-1]:
      dp[temp-1] = 1
      temp = temp+a[i]
  #print(dp)    
print(ans)    

Measured memory_bytes: 33096
s = input()

n = len(s)
l = list()

for a in range(0, n):
    l.append(s[a])

l.sort()
l = list(set(l))
n = len(l)

if n == 26:
    print('None')
else:
    for a in range(0, n):
        l[a] = int(ord(l[a]))
    for a in range(97, 123):
        if a not in l:
            print(chr(a))
            break


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if(N % 2 ==0){
    cout << 0.50000000 << endl;
  }
  
  else{
    cout << ((N + 1.0) / 2.0 ) / N <<endl;
  }
    
}

Measured memory_bytes: 256
n,a=map(int,input().split())
x=list(map(int,input().split()))
x=sorted([x[i]-a for i in range(n)])
dp=[[0]*5001 for i in range(n+1)]
dp[0][2500]+=1
for i in range(n):
    for j in range(5001):
        dp[i+1][j]+=dp[i][j]
        if 0<=j-x[i]<=5000:
            dp[i+1][j]+=dp[i][j-x[i]]
print(dp[-1][2500]-1)

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

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

  vector<bool> prime(1e5, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < 1e5; ++i) {
    if(prime[i]) {
      for(int j = i * i; j < 1e5; j += i) {
        prime[j] = false;
      }
    }
  }
 
  int n;
  while(cin >> n, !cin.eof()) {
    for(int i = n - 1;; --i) {
      if(prime[i]) {
        cout << i << " ";
        break;
      }
    }
    for(int i = n + 1;; ++i) {
      if(prime[i]) {
        cout << i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>

using namespace std;

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

    long long inf = 1000000000000000000;

    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long ans = 1;
    for (int i = 0; i < n; i++) {
        if (inf / ans < a[i]) {
            ans = -1;
            break;
        }
        ans *= a[i];
    }

    cout << ans << endl;
}


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


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

    ll ans = 0;
    vector<int> f(n+1);
    for(int i = 1; i <= n; ++i) {
        int j = i;
        while(j <= n) {
            ++f.at(j);
            j += i;
        }
    }

    for(int i = 1; i <= n; ++i) {
        ans += (ll)i * f.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42332
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

ll gcd_ori(ll a, ll b){
    if(a<b) swap(a, b);
    if(b == 0){
        return a;
    }

    return gcd_ori(b, a % b);
}

int main() {
    int n;cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    ll ans = 0;
    rep(i, n){
        ans += a.at(i)-1;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
  int n,min =1000000,max = -1000000,a;
  long long sum;
  cin >> n;
  sum = 0;
  
  for(int rup = 1;rup<=n;rup++){
    
    cin >> a;
    
    sum += a;
    
      if(a<min){
        min = a;
      }
    
      if(a>max){
        max = a;
      }

    a = 0;
  }
  cout << min << ' ' << max << ' ' << sum << endl;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var strs = new Dictionary<string, long>();

            long ans = 0;

            for (int i = 0; i < n; i++)
            {
                string str = new string(Console.ReadLine().ToCharArray().OrderBy(x => x).ToArray());

                if (strs.ContainsKey(str))
                {
                    ans -= Combination(strs[str], 2);
                    strs[str]++;
                    ans += Combination(strs[str], 2);
                }
                else
                {
                    strs.Add(str, 1);
                }

            }

            Console.WriteLine(ans);

        }

        static long Combination(long n, long r)
        {
            return Permutation(n, r) / Permutation(r, r);
        }

        static long Permutation(long n, long r)
        {
            long ans = 1;
            for (int a = 0; a < r; a++)
            {
                ans *= n - a;
            }
            return ans;
        }
    }
}

Measured memory_bytes: 28960
import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] d = new int[N];
    for (int i = 0; i < N; i++) {
      d[i] = sc.nextInt();
    }
    Arrays.sort(d);
    
    int ans = 0;
    int mid = N/2;
    if (d[mid] != d[mid-1]) {
      ans = d[mid] - d[mid-1];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 51856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  for(int i = 1; i <= 5; i++){
    int a; cin >> a;
    if(a == 0){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, t, indx, l, r;
    char ch;
    string s;
    cin >> n >> s >> q;
    map<char, set<int> > cache;
    for (int i = 0; i < n; i++) {
        cache[s[i]].insert(i);
    }
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> indx >> ch;
            indx--;
            if (s[indx] == ch) continue;
            cache[s[indx]].erase(indx);
            s[indx] = ch;
            cache[ch].insert(indx);
        } else {
            cin >> l >> r;
            l--, r--;
            int res = 0;
            for (char c = 'a'; c <= 'z'; c++) {
                auto iter = cache[c].lower_bound(l);
                if (iter == cache[c].end()) continue;
                if (*iter <= r) res++;
            }
            cout << res << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 24220
#coding:utf-8
from math import gcd

def main():
    k = int(input())
    ans = 0

    for a in range(1, k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                ans += gcd(gcd(a, b), c)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9024
/*
                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
    #include <bits/stdc++.h>
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
    bool isPrime(int n) 
    { 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
    } 
    signed main()
    {   jaldi
        int n,x,count=0;
        cin>>n>>x;
        while(n)
        {   count++;
            n/=x;   
        }
        cout<<count;
    }   


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int n,k,ans = 0,x[110];
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> x[i];
		ans += min(k - x[i], x[i]);
	}
	cout << ans * 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main(){
	int N;
	cin >> N;
	int cnt[26];
	ll ans = 1;
	for(int i=0; i<26; i++) cnt[i] = 0;
	for(int i=0; i<N; i++){
		char t;
		cin >> t;
		cnt[t - 'a']++;
	}
	for(int i=0; i<26; i++){
		ans = (ans * (cnt[i] + 1))%mod;
	}
	cout << ans - 1 << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

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

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l, r; cin >> l >> r;
    ll ans = INT_MAX;
    for (ll left = l; left <= min(l + 2019, r); ++left) {
        for (ll right = left+1; right <= min(r, left+1+2019); ++right) {
            ans = min(ans, (right * left) % 2019);
        }
        if (ans == 0) break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=2e5+1;
const ll M=2e5+5;
const ll mod=1e9+7;
const ll INF=1e18;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n;
string s;
ll dp[N][2];

ll F(ll idx,ll prev)
{
	if(idx==n){return 0;}
	if(dp[idx][prev]!=-1){return dp[idx][prev];}
	if(s[idx]=='.')
	{
		if(prev){return dp[idx][prev]=1+F(idx+1,1);}
		else{return dp[idx][prev]=min(F(idx+1,0),1+F(idx+1,1));}
	}
	else
	{
		if(prev){return dp[idx][prev]=F(idx+1,1);}
		else{return dp[idx][prev]=min(1+F(idx+1,0),F(idx+1,1));}
	}
}

int main()
{
	ms(dp,-1);
	cin>>n>>s;
	cout<<min((s[0]!='.')+F(1,0),(s[0]!='#')+F(1,1))<<endl;
}


Measured memory_bytes: 9988
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line[] = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        
        int ans = a - 1;
        
        if (b >= a) ans++;
        System.out.println(ans);
    }
}


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

long solve(long n, long p){
    if(n == 1){
        return p;
    }
    long res = 1, count = 0;
    for(long i = 2; i*i <= p; i++){
        while(p % i == 0){
            count++;
            p /= i;
            if(count >= n){
                res *= i;
                count = 0;
            }
        }
        count = 0;
    }
    return res;
}

int main(){
    long n, p;
    cin >> n >> p;
    cout << solve(n, p) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main()
{
    vector<int> b(101, 0);
    int t;
    while (cin >> t) b[t]++;

    vector<pair<int, int> > v;
    for (int i = 1; i < 101; ++i) v.push_back(make_pair(-b[i], i));
    sort(v.begin(), v.end());
    for (int i = 0; i < 101; ++i) if (v[i].first == v[0].first)
        cout << v[i].second << endl;

    return 0;
}

Measured memory_bytes: 0
k, n = map(int, input().split())
a = list(map(int, input().split()))

d = []
for i in range(n-1):
  d.append(abs(a[i] - a[i+1]))
d.append(k+a[0] - a[n-1])

m = max(d)
print(sum(d) - m)

Measured memory_bytes: 86140
#include<stdio.h>
int main(void)
{
	double n,t,x,h,max=0,z,i;
	scanf("%lf %lf",&n,&t);
	for(i=0;i<n;i++){
		scanf("%lf %lf",&x,&h);
		z=t*h/x;
		if(max<z) max=z;
	}
	printf("%.4lf\n",max);
}	


Measured memory_bytes: 2732
n = int(input())
l= []
x = 0
for elt in range(n):
    inp = input()
    l.append(inp)
for elt in range(len(l)):
    if l.count(l[elt]) > 1 :
        print("No")
        x+=1
        break

    else:
        if elt < len(l)-1:
            if l[elt][-1] != l[elt+1][0]:
                print("No")
                x += 1
                break
if x == 0:
    print("Yes")




Measured memory_bytes: 3060
n = int(input())
ans = 9*10
def f(x):
    kurainowa = 0
    while x>0:
        kurainowa += x%10
        x = x // 10
    return kurainowa
for a in range(1,n):
    b = n-a
    if ans > f(a) + f(b):
        ans = f(a) + f(b)
print(ans)

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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  
  bool exist[26];
  for(int i=0; i<26; i++) exist[i]= false;
  
  //文字列に各アルファベットがあるか探索．あればexistの対応する要素がtrue
  char s = 'a';
  for(int i=0; i<26; i++){
    for(int j=0; j<N; j++){
      if(S[j] == s) exist[i] = true;
    }
    s = (char)(s+1);//探索対象の文字を次のアルファベットへ
  }
  
  bool None = false;
  for(int i=0; i<26; i++){
    if (exist[i] == false){
      None = true;
      cout << (char)(i+'a') << endl;
      break;
    }
  }
  
  if (None == false) cout << "None" << endl;
      
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N,K,S;
  cin>>N>>K>>S;
  if(S==1e9){
    REP(i,K)cout<<S<<" ";
    REP(i,N-K)cout<<1<<" ";
    cout<<endl;
  }else{
    REP(i,K)cout<<S<<" ";
    REP(i,N-K)cout<<1000000000<<" ";
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
int main(){
  int n,k; cin >> n >> k;
  map<int,int> m;
  rep(i,n){
    int in; cin >> in;
    m[in]++;
  }
  vi t;
  for(auto i:m){
    t.pb(i.SEC);
  }
  sort(ALL(t));
  int ans = 0;
  if((int)t.size() <= k) {cout << 0 << endl; return 0;}
  for(int i = 0;(int)t.size() - i  > k; i++){
    ans += t[i];
    //cerr << t[i] << i << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10748
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32)::x,a,b 

    read*, x,a,b

    if (a-b >= 0) then
        print'(a)', 'delicious'
    else if(b-a <= x) then
        print'(a)', 'safe'
    else
        print'(a)', 'dangerous'
    end if
end program main

Measured memory_bytes: 256
import bisect

n = int(input())
A = list(map(int, input().split()))
q = int(input())

minA = A[0]
maxA = A[-1]

for i in range(q):
    query = int(input())

    if (query < minA) or (maxA < query):
        print(0)
    else:
        if A[bisect.bisect_left(A, query)] == query:
            print(1)
        else:
            print(0)


Measured memory_bytes: 17220
import itertools

N, K = map(int, input().split())

# 2a = xk, 2b = ykのとき a+b = (x+y)k/2
# x+yが偶数、すなわちx,yの偶奇が一致するならばa+bはkの倍数となる。他の組合せでも同様
# a,b,cの候補リストを用意して重複順列計算

abc_list_even = []
abc_list_odd = []

for a in range(1, N+1):
    if (2*a)%K == 0:
        if ((2*a)//K)%2 == 0:
            abc_list_even.append(a)
        else:
            abc_list_odd.append(a)

print(len(abc_list_even)**3 + len(abc_list_odd)**3)

Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long d, n;
    cin>>d>>n;
    long long temp=1;
    for(int i=0; i<d; i++){
        temp=temp*100;
    }
    if(n<100)temp*=n;
    else temp*=101;
    cout<<temp<<endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    long long ans = 0;
    for (int div = 1 ; div <= n ; div++)
        for (int mul = div ; mul <= n ; mul += div)
            ans += mul;

    cout << ans;
}

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

int main(){
    string str;
    long long int b , c ,d;
    char s;
    cin >> str;
    b = str.length();
    int N[b];
    transform(begin(str), end(str), N, [](char c) {return c - '0'; });
    for(int i = 0;i<b;i++){
        d += N[i];
    }
    if(d % 9 == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }


}

Measured memory_bytes: 4500
n = int(input())
b_list = list(map(int,input().split()))



if n == 2:
    ans = 2*b_list[0]

else:
    ans = b_list[0]
    
    for i in range(n-2):
        ans += min(b_list[i:i+2])

    ans += b_list[n-2]
    
print(ans)




Measured memory_bytes: 2940
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main(){
  int a, b;
  string op;
  cin >> a >> op >> b;
  if (op == "+"){
  cout << a + b << endl;
  }else{
  cout << a-b <<endl;
  }
  return 0;
}


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

int dp[101][76];

// DP 素因数分解
// https://betrue12.hateblo.jp/entry/2018/12/02/224027
int main() {
  int N;
  cin >> N;
  map<int, int> prime_division;  //素因数
  for (int i = 2; i <= N; i++) {
    int n = i;
    for (int p = 2; p <= n; p++) {
      while (n % p == 0) {
        prime_division[p]++;
        n /= p;
      }
    }
  }

  vector<int> nums;
  for (auto p : prime_division) nums.push_back(p.second);
  int len = nums.size();

  vector<int> div75 = {1, 3, 5, 15, 25, 75};
 
  dp[0][1] = 1; //i 番目の素因数まで見た時に、それまでの約数の個数が j であるような選び方の個数
  
  for (int i = 0; i < len; i++) {
    for (auto d1 : div75) {
      for (auto d2 : div75) {
        if (d1 * d2 <= 75 && nums[i] + 1 >= d2) {
          dp[i + 1][d1 * d2] += dp[i][d1];
        }
      }
    }
  }
  cout << dp[len][75] << endl;
  return 0;
}

Measured memory_bytes: 256
'''
ABC076_C
'''
s = input()
t = input()

ls = len(s)
lt = len(t)

ans = 'UNRESTORABLE'
for i in sorted(range(ls - lt + 1), reverse=True):
    ds = s[i:i+lt]
    flg = True
    for j in range(lt):
#        if not((ds[j] == t[j]) or (ds[j] == '?')):
        if (ds[j] != t[j]) and (ds[j] != '?'):
            flg = False
            break
    if flg:
        ans = s[:i] + t + s[i+lt:]
        ans = ans.replace('?', 'a')
        break
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int N, mod[5];

int main() {
  scanf("%d", &N);
  for (int i = 0; i != N; ++i) {
    int a; scanf("%d", &a);
    if (a % 4 == 0) ++mod[4];
    else if (a % 2 == 0) ++mod[2];
    else ++mod[1];
  }
  if (mod[2] && mod[2] + mod[4] < 2) {
    puts("No");
    return 0;
  }
  if (mod[2] && mod[4] < mod[1]) {
    puts("No");
    return 0;
  }
  if (!mod[2] && mod[4] + 1 < mod[1]) {
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}

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

void steps(int n);
int step(int n);

int main()
{
    int q;
    cin >> q;
    int n;
    for(int i = 0; i < q; i++){
        cin >> n;
        steps(n);
    }
    return 0;
}

void steps(int n)
{
    int count = -1;
    while(n != -1){
        n = step(n);
        count++;
    }
    cout << count << endl;
}

int step(int n)
{
    if(n < 10){
        return -1;
    }
    int fst = n;
    int snd = 0;
    int m = 10;
    int max = 0;
    while(fst > 0){
        fst /= 10;
        snd = n % m;
        m *= 10;
        if(max < fst * snd){
            max = fst * snd;
        }
    }
    return max;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	while(n!=0){
		ll val = n%26;
		if(val==0) val=26;
		s+= (val-1+'a');
		n/=26;
		if(val==26) n--;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	
	
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;  //桁数が大きいため
  cin >> a >> b;
	if (a % 2 != b % 2) {
		cout << "IMPOSSIBLE" << endl;  //偶奇が異なると解は存在しない
	} else { 
		cout << (a + b) / 2 << endl;
	}
}

Measured memory_bytes: 256
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

H, W, K = map(int, readline().split())
S = [list(map(int, list(readline().rstrip()))) for _ in range(H)]

answer = 10 ** 10
for i in product((0, 1), repeat=H - 1):
    cnt = sum(i)
    if cnt >= answer:
        continue
    cuts = []
    cuts.append(S[0].copy())
    for j in range(H - 1):
        if i[j] == 1:
            cuts.append(S[j + 1].copy())
        else:
            tmp1 = cuts[-1]
            tmp2 = S[j + 1]
            for k in range(W):
                tmp1[k] += tmp2[k]
    for j in cuts:
        if any(k > K for k in j):
            break
    else:
        h = len(cuts)
        tmp = [0] * h

        for j in range(W):
            for k in range(h):
                tmp[k] += cuts[k][j]
            for k in tmp:
                if k > K:
                    cnt += 1
                    tmp = [cuts[l][j] for l in range(h)]
                    break
        if cnt < answer:
            answer = cnt

print(answer)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;



int main(){
    int H,W;
    LL D;
    cin >> H >> W >> D;
    map<LL,P> mp;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            LL a;
            cin >> a;
            mp[a]=make_pair(i,j);
        }
    }
    LL imos[H*W+1];
    memset(imos,0,sizeof(imos));
    for(int k=1;k<=D;k++){
        LL sum=0;
        imos[k]=sum;
        for(int i=k;i<=H*W;i+=D){
            P p,q;
            p=mp[i];
            if(i+D>H*W) break;
            q=mp[i+D];
            sum+=abs(p.first-q.first)+abs(p.second-q.second);
            imos[i+D]=sum;
        }
    }
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int L,R;
        cin >> L >> R;
        cout << imos[R]-imos[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424