akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);



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

    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll ans = 0;
    if(n%2){
        ans = 1 + b[n/2] - a[n/2];
    }
    else{
        ans = (double)((b[n/2]+b[(n-1)/2]) - (a[n/2] + a[(n-1)/2]))+1;

    }
    cout << ans << endl;

    

}


Measured memory_bytes: 6788
/**
* @author Ashini Singha
* IIT,Jahangirnagar University
*/
#include<bits/stdc++.h>
using namespace std;
#define     ll          long long int
#define     fo(i,b,n)   for(int i=(b); i<(n) ; i++)
#define     xx          first
#define     yy          second
#define     pb          push_back
#define     sz(n)       int(n.size())
#define     pii         pair
#define     MP          make_pair
#define     PI          acos(-1.0)

#define read(x)         scanf("%d",&x)
#define read2(x,y)      scanf("%d%d",&x,&y)
#define readl(x)        scanf("%lld",&x)
#define readl2(x,y)     scanf("%lld%lld",&x,&y)
#define readd(x)        scanf("%lf",&x)
#define readd2(x,y)     scanf("%lf%lf",&x,&y)

#define pr(n)           printf("%d",n)
#define prn(n)          printf("%d\n",n)
#define prl(n)          printf("%lld",n)
#define prln(n)         printf("%lld\n",n)
#define prd(x)          printf("%lf",x)
#define prdn(x)         printf("%lf\n",x)
#define TC(n) printf("Case %d: ",n)
/*_____________E_N_D______________*/

const ll MOD = 1e9+7;

int main()
{
      ll base,power;
      readl2(base,power);
      ll ans=1ll;
      while(power)
      {
            if(power&1) ans =  (ans*base)%MOD;
            base= (base*base)%MOD;
            power/=2;
      }
      prln(ans);


      return 0;
}

Measured memory_bytes: 3184
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NMK[0]; var M = NMK[1]; var K = NMK[2];
            var friendship = new UnionFind(N);
            var friend = new int[N + 1];
            for (int i = 0; i < M; i++)
            {
                var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                friendship.unite(read[0], read[1]);
                friend[read[0]]++;
                friend[read[1]]++;
            }
            var suggestions = new int[N];
            for (int i = 0; i < N; i++) suggestions[i] = friendship.RootCount(i + 1) - friend[i + 1] - 1;
            for (int i = 0; i < K; i++)
            {
                var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                if (friendship.sameRoot(read[0], read[1]))
                {
                    suggestions[read[0] - 1]--;
                    suggestions[read[1] - 1]--;
                }
            }
            Console.WriteLine(string.Join(" ", suggestions));
        }
    }
    public class UnionFind
    {
        private int[] parents;
        // 同じ根に属する枝の数を格納する
        private int[] rootCount;

        public int RootCount(int branch)
        {
            return rootCount[root(branch)];
        }

        public UnionFind(int count)
        {
            parents = new int[count + 1];
            rootCount = new int[count + 1];
            for (int i = 0; i < count + 1; i++)
            {
                parents[i] = i;
                rootCount[i] = 1;
            }
        }

        private int root(int N)
        {
            if (parents[N] == N) return N;
            return parents[N] = root(parents[N]);
        }

        //木を併合する際に、枝の数も合算する
        public void unite(int X, int Y)
        {
            int rootX = root(X);
            int rootY = root(Y);
            if (rootX == rootY) return;
            rootCount[rootX] += rootCount[rootY];
            parents[rootY] = rootX;
        }

        public bool sameRoot(int X, int Y)
        {
            return root(X) == root(Y);
        }
    }
}


Measured memory_bytes: 22560
N = int(input())
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))

ans = 0
for i in range(len(arr_b)):
    if arr_b[i] >= arr_a[i]+arr_a[i+1]:
        ans += arr_a[i]+arr_a[i+1]
        arr_a[i] = 0
        arr_a[i+1] = 0

    elif arr_b[i] < arr_a[i]+arr_a[i+1]:
        if arr_b[i] <= arr_a[i]:
            ans += arr_b[i]
            arr_a[i] -= arr_b[i]

        elif arr_b[i] > arr_a[i]:
            ans += arr_b[i]
            arr_a[i+1] -= arr_b[i]
            arr_a[i+1] += arr_a[i]
            arr_a[i] = 0
print(ans)


Measured memory_bytes: 82020
s=input()
ls=len(s)
m=[0]*(2019)
m[0]+=1

cnt = 0
b = 0
for i in range(ls):
  a = (b + pow(10,cnt,2019)*int(s[ls - i -1])) % 2019
  m[a] += 1
  b = a
  cnt += 1

ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)


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

constexpr int INF = (1LL << 31) - 1;

template <typename T>
class SegmentTree {
private:
  int n;
  T init;
  vector<T> seg;

  int size (int N) {
    int ret;
    for (ret = 1; ret < N; ret <<= 1);
    return ret;
  }

  T query(int a, int b, int k, int l, int r) {
    if (r <= a or b <= l) return init; // maxver
    if (a <= l and r <= b) return seg[k];

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }

public:
  SegmentTree (int N, T i = 0) : n(size(N)), seg(size(N) * 2, i), init(i) {}

  void update (int k, T val) {
    k += n - 1;
    seg[k] = val;
    while (k > 0) {
      k = (k - 1) / 2;
      // ???????????´
      seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }

  // [l, r) ???????????§???????????¨?????¨???!!! ... [l, r]??????find(l, r + 1)
  T find(int l, int r) {
    return query(l, r, 0, 0, n);
  }
};


int main() {
    int n, q, command, x, y;

    cin >> n >> q;

    SegmentTree<int> st(n, INF);

    for (int i = 0; i < q; ++i) {
        cin >> command >> x >> y;
        if (command == 0) {
            st.update(x, y);
        }
        else {
            cout << st.find(x, y + 1) << endl;
        }
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int x, y, z; cin >> x >> y >> z;
	x -= z;
	cout << (x/(y+z));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,e,n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int inf=1000000007;


int main(){
  int n,h;
  cin >> h >> n;
  vector<int> hp(h+1,inf);
  vector<int> attack(n);
  vector<int> mahou(n);
  rep(i,0,n) cin >> attack[i] >> mahou[i];

  hp[0]=0;

  rep(i,1,h+1){
    rep(j,0,n){
      if(attack[j]>=i) hp[i]=min(mahou[j],hp[i]);
      else hp[i]=min(hp[i-attack[j]]+mahou[j],hp[i]);
    }
  }
  cout << hp[h] << endl;
  return 0;
}

Measured memory_bytes: 3680
X, Y, A, B, C = map(int, input().split())

pList = list(map(int, input().split()))
qList = list(map(int, input().split()))
rList = list(map(int, input().split()))

pList.sort(reverse=True)
qList.sort(reverse=True)
rList.sort(reverse=True)

pList = pList[:X]
qList = qList[:Y]

appleList = pList + qList + rList
appleList.sort(reverse=True)
appleList = appleList[:X+Y]

print(sum(appleList))


Measured memory_bytes: 23328
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    vector<int> flag(N) ;
    bool pairwise = true ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
        flag[v[i]]++;
        if ( flag[v[i]] > 1 && v[i] != 1) {
            pairwise = false ;
        }
    }
    int gcd = v[0] ;
    for(int i = 1; i < n; i++){
        gcd = __gcd(gcd, v[i]) ;
    }
    vector<bool> c(N, false) ;
    for(int i = 2; i < N; i++){
        if ( c[i] == false ) {
            int cnt = flag[i] ; 
            for(int j = i + i; j < N; j += i){
                c[j] = true ;
                if ( flag[j] ) cnt++ ;
            }
            if ( cnt > 1 ) {
                pairwise = false ;
                break ;
            }
        }
    }
    if ( pairwise ) {
        cout << "pairwise coprime" << endl;
    }
    else if ( gcd == 1 ) {
        cout << "setwise coprime" << endl;
    }
    else{
        cout << "not coprime" << endl;
    }
    return 0; 
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  
  long int ans =0,ant=0;
  
  
  for(int i=0;i<s.size();i++){
    if(s[i] == 'B'){
      ans++;
    }
    
    else{
      ant += ans;
    }
  }
  
  cout << ant << endl;
  return 0;
}
    


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
char ch[maxn];
int n,a[maxn],s[maxn],nxt[maxn][3],id[3];
ll f[maxn];

inline void up(ll &x,ll y) { x = (x + y) % mod; }

bool check(){
	rep(i,1,n - 1) if ( a[i] == a[i + 1] ) return 0;
	return 1;
}
int main(){
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	rep(i,1,n) a[i] = ch[i] - 'a' + 1 , s[i] = (s[i - 1] + a[i]) % 3;
	if ( check() ){ 
		printf("1\n");
		return 0;
	}
	id[0] = id[1] = id[2] = n + 1;
	repd(i,n,0){
		rep(j,0,2) nxt[i][j] = id[j];
		id[s[i]] = i;
	}	
	ll ans = 0;
	f[0] = 1;
	rep(i,0,n - 1){
		up(f[nxt[i][(s[i] + 1) % 3]],f[i]);
		up(f[nxt[i][(s[i] + 2) % 3]],f[i]);
		if ( i && (s[n] - s[i] + 3) % 3 == 0 ) up(ans,f[i]);
	}
	up(ans,f[n]);
	cout<<ans<<endl;
}


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

int main(void) {
    string S, T;
    cin >> S >> T;
    int m = S.length(), n = T.length();
    int ans = 1000000;
    for (int i = 0; i < m - n + 1; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            sum += S[i + j] != T[j];
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
  int x;
  vector<int> r;
  int t = 0;
  while(x) {
    cin >> x;
    if(x) {
      r.push_back(x);
      t++;
    }
  }
  for(int i = 0; i < t; i++) cout << "Case " << i + 1 << ": " << r.at(i) << endl;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	pair<int, int> ans(1, n);
	rep(i, m){
		int l, r;
		cin >> l >> r;
		if(ans.first < l) ans.first = l;
		if(r < ans.second) ans.second = r;
	}
	if(ans.second - ans.first + 1 > 0) cout << ans.second - ans.first + 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

open InputUtility

module ARC074 =
    let private ``Chocolate Bar`` () = 
        let gr r a =
            Seq.max a - Seq.min a
            |> min r
        let check a b =
            let rec inner b c r =
                if c > a then r
                else
                    let nr =
                        let d = a - c
                        seq {
                            yield [b * c; d / 2L * b; (d + 1L) / 2L * b];
                            yield [b * c; b / 2L * d; (b + 1L) / 2L * d];
                        } |> Seq.fold gr r
                    inner b (c + 1L) nr
            inner b 1L System.Int64.MaxValue
        let g = ReadNext >> int64
        let h, w = g (), g ()
        min (check h w) (check w h)
        |> printfn "%d"

    let Entry = ``Chocolate Bar``

ARC074.Entry ()

Measured memory_bytes: 18212
import sys
input = sys.stdin.readline


class SegmentTree:
    def __init__(self, target, no_effect):
        target_size = len(target)
        leaves_size = 1
        while leaves_size < target_size:
            leaves_size *= 2
        self.tree_size = leaves_size * 2 - 1
        self.tree = [no_effect] * self.tree_size
        self.no_effect = no_effect
        self.initialize_tree(target, no_effect)

    @classmethod
    def initialize_func(cls, value):
        return 1 << (ord(value) - ord('a'))

    @classmethod
    def merge_func(cls, a, b):
        return a | b

    def merge_child_data(self, node):
        child1 = node * 2 + 1
        child2 = node * 2 + 2
        merged = self.merge_func(self.tree[child1], self.tree[child2])
        return merged

    def initialize_tree(self, target: list, no_effect=0):
        initial_leaf = self.tree_size // 2
        leaves = range(initial_leaf, initial_leaf+len(target))
        for value, leaf in zip(target, leaves):
            self.tree[leaf] = self.initialize_func(value)

        for parent in range(initial_leaf-1, -1, -1):
            self.tree[parent] = self.merge_child_data(parent)

    def update(self, new_value, index):
        leaf = self.tree_size//2 + index
        new_data = self.initialize_func(new_value)
        if self.tree[leaf] == new_data:
            return
        self.tree[leaf] = new_data

        parent = (leaf-1) // 2
        while parent >= 0:
            new_data = self.merge_child_data(parent)
            if self.tree[parent] == new_data:
                break
            self.tree[parent] = new_data
            parent = (parent-1) // 2

    def resolve_query(self, _from, to):
        result = self.no_effect
        left, right = _from + self.tree_size//2, to + self.tree_size//2
        while left <= right:
            result = self.merge_func(result, self.tree[left])
            result = self.merge_func(result, self.tree[right])
            left //= 2
            right = right//2 - 1

        return bin(result).count('1')


n = int(input())
S = input().replace('\n', '')
seg_tree = SegmentTree(target=S, no_effect=0)

Q = int(input())
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        index, new = int(query[1])-1, query[2]
        seg_tree.update(new, index)

    elif query[0] == '2':
        _from, to = int(query[1])-1, int(query[2])-1
        print(seg_tree.resolve_query(_from, to))


Measured memory_bytes: 44184
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

int solve(int a, int b, int c) {
  int n = 0;
  while (1) {
    if((a&1) || (b&1) || (c&1)) return n;
    if (a==b&&b==c&&c==a) return -1;

    int ta, tb, tc;
    ta = b/2 + c/2;
    tb = c/2 + a/2;
    tc = a/2 + b/2;
    a=ta;b=tb;c=tc;
    n++;
  }
}

int main() { 

  int a, b, c;

  cin >> a >>b>>c;

  int ans = solve(a,b,c);
  cout << ans << endl;

  return 0;
}


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

int top, s[1000];

int pop() {
  // return s[top];
  // top--; //returnで呼び出し元に戻っちゃうからだめ
  top--;
  return s[top + 1];
}

void push(int x) {
  top++;
  s[top] = x;
}

// O(1)
int main() {
  int a, b;
  top = 0;
  string c;
  while (cin >> c) {
    if (c == "+") {
      a = pop();
      b = pop();
      push(a + b);
    } else if (c == "-") {
      b = pop();
      a = pop();
      push(a - b);
    } else if (c == "*") {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(c.c_str()));
      // atoi()はchar*をintに変換
      // c_str()はstringをchar*に変換
      // char*はポインタ、char b[]は配列
    }
  }
  cout << pop() << endl;

  return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n != 0) {
            double xa = sc.nextDouble();
            double ya = sc.nextDouble();
            double ra = sc.nextDouble();
            double xb = sc.nextDouble();
            double yb = sc.nextDouble();
            double rb = sc.nextDouble();
            double d2 = Math.pow(xa - xb, 2) + Math.pow(ya - yb, 2);
            if (d2 <= Math.pow(ra + rb, 2)) {
                if (d2 < Math.pow(ra - rb, 2)) {
                    if (ra - rb >= 0)
                        System.out.println(2);
                    else
                        System.out.println(-2);
                } else
                    System.out.println(1);
            } else
                System.out.println(0);

            n--;
        }

    }
}

Measured memory_bytes: 12000
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


D, = map(int,readline().split())
#D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(c,s,ans): # ans: 0-indexed としたときのスコアの計算
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        #print(score) # i日目のスコア
    return score


ans = [max(range(26),key=lambda x: si[x]) for si in s]

output(ans)




Measured memory_bytes: 9392
import Control.Applicative
import Data.List

main :: IO ()
main = do
    s <- getLine
    putStrLn $ show (solve (sort s))

solve :: String -> Int 
solve s | "000" == s = 0
        | "001" == s = 1
        | "011" == s = 2
        | "111" == s = 3

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int mo = 998244353;
ll n,a[555555],b[55];
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
int main() {
	read(n);rep(i,1,n)read(a[i]);sort(a+1,a+n+1);
	ll tot=1;rep(i,1,n)tot=tot*gcd(a[i],i-1)%mo;cout<<tot;
	return 0;
	n=5;srand(time(0));
	while(1){
	a[0]=1;rep(i,1,n)a[i]=rand()%3+a[i-1];
	memset(b,0,sizeof(b));b[0]=1;
	rep(i,1,n){per(j,i,1)b[j]=(1LL*b[j-1]*a[i]+1LL*b[j]*(i-1));b[0]=0;}
	rep(i,1,n)printf("%d:%lld %lld\n",i,a[i],b[i]);
	ll res=0;rep(i,1,n)res=gcd(res,b[i]);printf("%lld\n",res);
	ll tot=1;rep(i,1,n)tot*=gcd(a[i],i-1);assert(res==tot);
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
#include<bits/stdc++.h>
using namespace std;
int n,k,i,w[150];
bool cmp(const int&a,const int&b){
	return a<b;
}
int main(){
	n=rd(),k=rd();
	for (i=1;i<=n;i++)
		w[i]=rd();
	sort(w+1,w+n+1,cmp);
	for (i=1;i<=n;i++)
		if (k>=w[i]) k-=w[i];
		else break;
	if (i==n+1&k>0) i--;
	writeln(i-1);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a[] = {0, 0, 0, 0};
    for(int i=0; i<6; i++){
        int n;
        cin >> n;
        if(++a[n] == 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s, t = sc.next()
  val a, b = sc.nextInt()
  val u = sc.next()
  var num_s = -1
  var num_t = -1
  if (s==u) {
    num_s = a - 1
    num_t = b
  } else {
    num_s = a
    num_t = b - 1
  }
  println(s"${num_s} ${num_t}")
}


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

using namespace std;

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

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, tot = 0, a = 0, b = 0, c = 0;

    cin >> n;

    for(int i = 0; i < n; ++i){
        string j;
        cin >> j;
        if(j[0] == 'B' && j[j.size() - 1] == 'A'){
            ++c;
        } else if(j[0] == 'B'){
            ++b;
        } else if(j[j.size() - 1] == 'A'){
            ++a;
        }

        for(int k = 1; k < j.size(); ++k){
            if(j[k - 1] == 'A' && j[k] == 'B')
                ++tot;
        }

    }

    if(a == 0 && b == 0){
        // use itself to create
        cout << tot + max(0, c - 1);
    } else {
      	// insert anywhere
        cout << tot + min(a, b) + c;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
struct Node{
  int p,l,r;
};
int n,id,k[N],c[N][20];
struct Node T[N];

int main(){
  int i,j,count=0,a;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i=0; i<n; i++){
    scanf("%d",&id);
    scanf("%d",&k[id]);
    for(j=0; j<k[id]; j++){
      scanf("%d",&c[id][j]);
      T[id].l = c[id][0];
      T[c[id][j]].p = id;
      if(j>0){
	T[c[id][j-1]].r = c[id][j];
      }
    }
  }

  for(id=0; id<n; id++){
    printf("node %d: parent = %d, depth = ",id,T[id].p);
    i = id;
    while(T[i].p != -1){
      count++;
      i = T[i].p;
    }
    printf("%d, ",count);
    count = 0;
    if(T[id].p == -1) printf("root, ");
    else if(T[id].l == -1) printf("leaf, ");
    else printf("internal node, ");
    
    if(T[id].l != -1) {
      printf("[%d",T[id].l);
      for(i=1; i<k[id]; i++)
	printf(", %d",c[id][i]);
      printf("]\n");
    }
    else printf("[]\n");
  }
 

  return 0;
}

Measured memory_bytes: 2956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll k;
  string s;
  cin >> k >> s;
  ll n=s.size();
  ll ans=0;
  fact(n+k);
  for(ll i=0;i<=k;i++) {
    ans+=mpow(25,i)*comb(n+i-1,i)%mod*mpow(26,k-i)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

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

    int n, m;
    cin >> n >> m;

    vector<int> p(m), y(m);
    for (int i = 0; i < m; ++i) cin >> p[i] >> y[i];

    vector<pair<int, int>> data(m);
    for (int i = 0; i < m; ++i) {
        data[i].first = y[i];
        data[i].second = i;
    }

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

    vector<int> idx(n);
    vector<string> name(m);
    for (int i = 0; i < m; ++i) {
        string fst = to_string(p[data[i].second]);
        string snd = to_string(++idx[p[data[i].second] - 1]);
        fst = string(6 - fst.size(), '0') + fst;
        snd = string(6 - snd.size(), '0') + snd;
        name[data[i].second] = fst + snd;
    }

    for (auto x : name) cout << x << endl;

    return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    int K; cin >> K;
    vector<int> data(N);
    for(int i = 0; i < N; i++){
        data[i] = 0;
    }

    for(int i = 0; i < K; i++){
        int tmp; cin >> tmp;
        for(int j = 0; j < tmp; j++){
            int sunuke; cin >> sunuke;
            if(data[sunuke-1] == 0){
                data[sunuke-1] = 1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(data[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char str[N];int ru[N],f[N];queue<int> q;
    void main()
	{
        scanf("%s",str+1);int n=strlen(str+1)+1;ll ans=0;
        fo(i,1,n-1) ru[i+(str[i]=='<')]++;fo(i,1,n) if(!ru[i]) q.push(i);
        while(sz(q))
        {
            int x=q.front();q.pop();ans+=f[x];
            if(str[x-1]=='>') {ru[x-1]--;if(!ru[x-1])q.push(x-1),f[x-1]=f[x]+1;}
            if(str[x]=='<') {ru[x+1]--;if(!ru[x+1])q.push(x+1),f[x+1]=f[x]+1;}
        }write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n,a;
  while(cin>>n,n!=0){
    int d[10]={0};
    for(int i=0;i<n;i++){
      cin>>a;
      d[a]++;
    }
    for(int i=0;i<10;i++){
      if(d[i]==0)printf("-");
      for(int j=0;j<d[i];j++){
	printf("*");
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vl = vector<ll>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
ll n;
vl l;
int main() {
	cin >> n;
	l.resize(n);
	REP(i, n){
		cin >> l[i];
	}
	sort(ALL(l));
	ll ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			auto ite = upper_bound(l.begin() + j + 1, l.end(), abs(l[i]-l[j]));
			auto ite2 = lower_bound(l.begin() + j + 1, l.end(), l[i]+l[j]);
			ans += ite2 - ite;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <numeric>
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;

#define _(x) {cout << #x << " = " << x << " ";}
#define fast ios::sync_with_stdio(false);cin.tie(NULL)

#define fi first 
#define se second 
#define mp make_pair
#define pb push_back

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define clr(v,d) memset(v,d,sizeof(v))
#define sz(v) ((int)((v).size()))

const int MAXN = 1e5 + 10;
ll n,m,j,k,s,t,e,q,l,r,a,b;
char c;
int main()
{   
	
	fast;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
}

Measured memory_bytes: 256
#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>;
 
const int m = 2019;
 
int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  int x = 1, tot = 0;
  vector<int> cnt(m);
  ll ans = 0;
  rep(i,n) {
    cnt[tot]++;
    tot += (s[i]-'0')*x;
    tot %= m;
    ans += cnt[tot];
    x = x*10%m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
    int l,r;
    cin>>l>>r;
    r = min(l+2019,r);
    int ans=2018;
    for(long long i=l;i<=r;i++){
        for(long long j=i+1;j<=r;j++){
            int x=i*j%2019;
            ans=min(ans,x);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())
    s = input().rstrip()
    eng_list = 'abcdefghigklmnopqrstuvwxyz'
    eng_dict = {}
    for i in eng_list:
        eng_dict[i] = 1
    for i in s:
        try:
            eng_dict[i] += 1
        except KeyError:
            eng_dict[i] = 2
    ans = 1
    size = 10**9+7
    for i in eng_dict.values():
        ans = (ans*i)%size
    print((ans-1)%size)


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

using namespace std;

const int INF = 1 << 30;

struct edge
{
  int to, cost;
};

int main()
{
  int N, K, S;
  int X[2000], Y[2000], Z[2000];

  while(cin >> N >> K >> S, N) {
    for(int i = 0; i < N; i++) {
      cin >> X[i] >> Y[i] >> Z[i];
    }

    vector< edge > g[2000];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < i; j++) {
        int latte = max(0, S - abs(X[i] - X[j]));
        int malta = max(0, S - abs(Y[i] - Y[j]));
        int beeet = max(0, S - abs(Z[i] - Z[j]));
        int ukuku = latte * malta + malta * beeet + beeet * latte;
        if(latte > 0 && malta > 0 && beeet > 0) {
          g[i].emplace_back((edge) {j, ukuku});
          g[j].emplace_back((edge) {i, ukuku});
        }
      }
    }

    int ret = -1;
    for(int i = 0; i < N; i++) {
      bool v[2000] = {};
      function< void(int, int, int) > dfs = [&](int idx, int k, int sz)
      {
        if(v[idx]++) return;
        if(k == 0) {
          if(K >= 3) for(auto &e: g[idx]) if(e.to == i) sz += e.cost;
          ret = max(ret, sz);
        } else {
          for(auto &e : g[idx]) dfs(e.to, k - 1, sz + e.cost);
        }
        v[idx] = false;
      };
      dfs(i, K - 1, 0);
    }
    if(ret == -1) cout << -1 << endl;
    else cout << 6 * S * S * K - ret * 2 << endl;
  }
}

Measured memory_bytes: 3232
N = int(input())

A = map(int, input().split())
AI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)

def solve(a, i, prev):
  pl, pr, ps = i, 0, 0
  for l, r, s in prev:
    yield l, r-1, max(s+abs(r-i)*a, ps+abs(i-pl)*a)
    pl, pr, ps = l, r, s
  yield pl+1, pr, ps+abs(i-pl)*a

prev = [(1, N, 0)]
for a,i in AI:
  prev = [*solve(a,i, prev)]

print(max(s for l, r, s in prev))


Measured memory_bytes: 9960
#include <bits/stdc++.h>
#define endl '\n'
#define sync_cin                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0)
using namespace std;

#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;



int main()
{
    sync_cin;
    int a, b;
    cin >> a >> b;
    int ans;
    if (a > b) ans = a + a - 1;
    else if (a < b) ans = b + b - 1;
    else ans = a + b;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  vector<vector<int>> vec(2, vector<int>(26, 0));
  rep(i, S.size()){
    char s = S[i];
    int x;
    if(s=='a') x = 0;
    if(s=='b') x = 1;
    if(s=='c') x = 2;
    if(s=='d') x = 3;
    if(s=='e') x = 4;
    if(s=='f') x = 5;
    if(s=='g') x = 6;
    if(s=='h') x = 7;
    if(s=='i') x = 8;
    if(s=='j') x = 9;
    if(s=='k') x = 10;
    if(s=='l') x =11;
    if(s=='m') x =12;
    if(s=='n') x =13;
    if(s=='o') x =14;
    if(s=='p') x =15;
    if(s=='q') x =16;
    if(s=='r') x =17;
    if(s=='s') x =18;
    if(s=='t') x =19;
    if(s=='u') x =20;
    if(s=='v') x =21;
    if(s=='w') x =22;
    if(s=='x') x =23;
    if(s=='y') x =24;
    if(s=='z') x =25;
    vec[0][x]++;
  }
  rep(i, T.size()){
    char s = T[i];
    int x;
    if(s=='a') x = 0;
    if(s=='b') x = 1;
    if(s=='c') x = 2;
    if(s=='d') x = 3;
    if(s=='e') x = 4;
    if(s=='f') x = 5;
    if(s=='g') x = 6;
    if(s=='h') x = 7;
    if(s=='i') x = 8;
    if(s=='j') x = 9;
    if(s=='k') x = 10;
    if(s=='l') x =11;
    if(s=='m') x =12;
    if(s=='n') x =13;
    if(s=='o') x =14;
    if(s=='p') x =15;
    if(s=='q') x =16;
    if(s=='r') x =17;
    if(s=='s') x =18;
    if(s=='t') x =19;
    if(s=='u') x =20;
    if(s=='v') x =21;
    if(s=='w') x =22;
    if(s=='x') x =23;
    if(s=='y') x =24;
    if(s=='z') x =25;
    vec[1][x]++;
  }
  sort(vec[0].begin(), vec[0].end());
  sort(vec[1].begin(), vec[1].end());
  
  bool y = true;
  rep(i, 26){
    if(vec[0][i] != vec[1][i]){
      y = false;
      break;
    }
  }
  if(y) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}
    




Measured memory_bytes: 776
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  int n {N/100};
  if (N%10 > n || (N/10)%10 > n) {
    ++n;
  }
  cout << n << n << n << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second 
vector<ll> v1;
vector<ll> v2;
ll n,ans = 0;
string s;
ll comp(char a,char b,char c)
{
    ll i,j,k,an=0;
    for(j=1;j<n-1;j++)
    {
        if(s[j]==a)
        {
            for(i=0;i<j;i++)
                if(s[i]==b)
                    v1.pb(i);
            for(k=j+1;k<n;k++)
                if(s[k]==c)
                    v2.pb(k);
            ll check = 2*j;
            if(v1.size()!=0 && v2.size()!=0){
            for(i=0;i<v1.size();i++)
            {
                for(k=0;k<v2.size();k++)
                    if(check!=v1[i]+v2[k])
                        an++;
            }}
        }
        v1.clear();
        v2.clear();
    }
    // cout<<an<<"\n";
    return an;
}
void solve()
{   
    cin>>n;
    cin>>s;
    ans+=comp('R','G','B');
    ans+=comp('B','G','R');
    ans+=comp('G','R','B');
    ans+=comp('B','R','G');
    ans+=comp('G','B','R');
    ans+=comp('R','B','G');
    cout<<ans;
}
int main(){ 
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // # ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif  
    // clock_t tStart = clock();
    // ll t;
    // cin>>t;
    // while(t--)
        solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3628
def main():
    s = [i[0] for i in open(0).read().split()[1:]]
    c = (s.count("M"),s.count("A"),s.count("R"),s.count("C"),s.count("H"))
    a = 0
    for i in range(3):
        for j in range(3-i):
            for k in range(3-i-j):
                a += c[i]*c[i+j+1]*c[i+j+k+2]
    print(a)

main()

Measured memory_bytes: 11036
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();

		//処理
		long base = 2 * (x/11);
		if(x - base / 2 * 11 > 0) base++;
		if(x - base / 2 * 11 > 6) base++;

		//出力
		System.out.println(base);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int mod = 1e9 + 7;

int A, B, C;

int main() {
    cin >> A >> B >> C;
    cout << (A + B + C > 21? "bust" : "win") << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n;
	int b, f, r, v;
	int num[4][3][10];

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				num[i][j][k] = 0;
			}
		}
	}

	cin >> n;


	for (int m = 0; m < n; m++) {

		cin >> b >> f >> r >> v;

		//b?£?f???r???????????¨?±????v????????????
		num[b-1][f-1][r-1] += v;
	}

	//??????
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					cout << " " << num[i][j][k];
				}
				cout << endl;
			}
			if (i != 3) {
				cout << "####################" << endl;
			}
		}

	return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

class A {
	int a, b, c;
public:
	void solve()
	{
		int m{ a };
		if (m < b) m = b;
		if (m < c) m = c;

		cout << (a + b + c + 9 * m) << endl;
	}

	A()
	{
		cin >> a >> b >> c;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();

		int[] num = Arrays.stream(str.split(" "))
			.mapToInt(Integer::parseInt)
			.toArray();
		Arrays.sort(num);

		str = Arrays.stream(num).mapToObj(String::valueOf).collect(Collectors.joining(" "));
		System.out.println(str);
	}
}



Measured memory_bytes: 31392
sx,sy,tx,ty = map(int,input().split())
a = tx-sx
b = ty-sy

c = "R"*a + "U"*b
d = "L"*a + "D"*b
e = "D" + "R"*(a+1) + "U"*(b+1) + "L"
f = "U" + "L"*(a+1) + "D"*(b+1) + "R"

g = c + d + e + f
print(g)
#print(g.count("R"),g.count("L"),g.count("U"),g.count("D"))



Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a+b == c) {
		printf("Yes");
	}
	else if(a==b+c){
		printf("Yes");
	}
	else if (b==c + a ) {
		printf("Yes");
	}
	else{
		printf("No");
	}

}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = b-a;
        System.out.println((c + 1) * c / 2 -b);
    }
}

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


int main()
{
        char numbuff[100000+1];
        long long int numbers[1000];
        int numnum;
        long long int i,j;
        long long int L, R;
        int inputc;


        numnum = 0;
        j = 0;
        while( (inputc = getc(stdin)) != EOF ) {
                if( inputc == ' ' || inputc == '\n' ) {
                        numbuff[j]  = '\0';
                        numbers[numnum++] = atoll(numbuff);
                        j=0;
                        continue;
                }
                else {
                        numbuff[j++] = inputc;
                }
        }
#ifdef DBG
        for( int k =0; k < numnum; k++ ) { printf("<%lld>", numbers[k]); } printf("\n");
        printf("get numbuff\n");
#endif

        L = numbers[0];
        R = numbers[1];

        /*
        L = L%2019;
        R = R%2019;
        if( L > R ) {
                R+=2019;
        }
        */


#ifdef DBG
        printf("L=%lld R=%lld\n", L, R );
#endif
        long long int tmpamari;
        long long int min_amari = 2018;
        for( i = L; i < R; i++ ) {
                for( j = i+1; j <= R; j++ ) {
                        tmpamari = (i*j)%2019;
                        if( tmpamari <= min_amari ) {
                                min_amari = tmpamari;
                                if( min_amari == 0 ) {
                                        printf("%lld\n", min_amari );
                                        return 0;
                                }
                        }
                }
        }

        printf("%lld\n", min_amari );
        return 0;

}



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

int main(){
	int x;
	cin >> x;
	if(x >= 400 && x <= 599){
		cout << 8 << endl;
	}else if(x >= 600 && x <= 799){
		cout << 7 << endl;
	}else if(x >= 800 && x <= 999){
		cout << 6 << endl;
	}else if(x >= 1000 && x <= 1199){
		cout << 5 << endl;
	}else if(x >= 1200 && x <= 1399){
		cout << 4 << endl;
	}else if(x >= 1400 && x <= 1599){
		cout << 3 << endl;
	}else if(x >= 1600 && x <= 1799){
		cout << 2 << endl;
	}else if(x >= 1800 && x <= 1999){
		cout << 1 << endl;
	}
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  int T[N];
  for(int i = 0; i < N; i++) {
    cin >> T[i];
  }
  int M;
  cin >> M;
  int P[M],X[M];
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  int presum = 0;
  for(int i = 0; i < N; i++) {
    presum += T[i];
  }
  for(int i = 0; i < M; i++) {
    cout << presum - T[P[i] - 1] + X[i] << endl;
  }

}


Measured memory_bytes: 256
N, M = map(int, input().split())

LR = []
for _ in range(M):
  l, r = map(int, input().split())
  LR.append((l, r))

L_max = 1
R_min = N

for lr in LR:
  if (L_max < lr[0]):
    L_max = lr[0]

  if (R_min > lr[1]):
    R_min = lr[1]

result = R_min - L_max + 1
if(result <= 0):
  print(0)
else:
  print(result)


Measured memory_bytes: 16592
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		Set<Integer> set = new HashSet<>();
		while(n!=0)
		{
			set.add(n%10);
			n=n/10;
		}
		if(set.contains(7)==true)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}

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

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

    long long n, k, s = 0;
    cin >> k >> n;
    vector<long long> a(n );

    for(long long i = 0; i < n; i++){
        cin >> a[i];
        a[i] %= k;
    }
    sort(a.begin(), a.end());
    for(long long i = 1; i < n; i++){
        s += a[i] - a[i-1];
    }

    long long mini = s;
    for(long long i = 1; i < n; i++){
        long long d = -abs(-a[i] + a[i-1]) + abs(a[i-1] - (i >= 2 ? a[i-2] : -(k - a[n-1])));
//        cerr << s << " " << d << "\n";
        s += d;
        mini = min(s, mini);
    }

    cout << mini << "\n";


    return 0;
}


Measured memory_bytes: 1792