akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++) 
#define inf 10000000000000;
typedef long long ll;




int main(){

    int n;
    cin >> n;

    ll c=0;

    ll a[n+5];
    ll b[n+5];

    rep(i,n+1){
        cin>>a[i];
    }

    rep(i,n){
        cin >> b[i];
    }

    for(int i=0;i<n;i++){
        if(a[i]<=b[i]&&a[i]>=0){
            c+=a[i];
            b[i]-=a[i];
        }
        else{
            c+=b[i];
            b[i]=0;
        }

        if(b[i]<=0)continue;

        if(a[i+1]<=b[i]){
            c+=a[i+1];
            a[i+1]=0;
        }
        else{
            c+=b[i];
            a[i+1]-=b[i];
        }


    }

    cout << c << endl;
    return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b==a && c==7)
    {
        cout<<"YES";
    }
    else if(a==5 && c==a && b==7)
    {
        cout<<"YES";
    }
    else if(a==7 && b==5 && c==b)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 3528
#include<stdio.h>
#include<string.h>

#define M 1031555/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int h(int key,int i){ return (h1(key)+i*h2(key))%M;}

int find(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0){
            return 1;
        }else if(strlen(H[j])==0){
            return 0;
        }
        i++;
    }
}

int insert(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0)
            return 1;
        else if(strlen(H[j])==0){
            strcpy(H[j],str);
            return 0;
        }
        i++;
    }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 15848
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  
  if(n>m) swap(n, m);
  
  ll ans = 1;
  if(n==m) {
    rep2(i, n) (ans *= i) %= MOD;
    cout << ans*ans%MOD*2%MOD << newl;
  }else if(n+1==m) {
    rep2(i, n) (ans *= i) %= MOD;
    cout << ans*ans%MOD*m%MOD << newl;
  }else cout << 0 << newl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

//struct compare
//{
//  bool operator()(const int& l, const int& r)
//  {
//      return l>r;
//  }
//};

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
ll mod=998244353;
const int mx=300100;
int n,m;
vector<pLL>v;
ll dp[3030][3030];
ll fun(int pos,int l,int r)
{
    if(pos==n)
    {
        return 0;
    }
    ll &ret=dp[l][r];
    if(ret!=-1)
        return ret;
    ret=0;
    ll val=v[pos].ff;
    ll p=v[pos].sn;
    ret=max(ret,val*abs(p-l)+fun(pos+1,l+1,r));
    ret=max(ret,val*abs(p-r)+fun(pos+1,l,r-1));
    return ret;
}
int main()
{
    mem(dp,-1);
    sf(n);
    ll x;
    for(int i=0;i<n;i++)
    {
        sl(x);
        v.pb({x,i});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    cout<<fun(0,0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 75716
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[102];
int N;
int main(){
  N = rd(S);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<((N-1) + 1);Lj4PdHRW++){
      S[Lj4PdHRW] = 'x';
    }
  }
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200214-1

// --- original code ---
// char S[102]; int N;
// {
//   rd(S@N);
//   S[0..N-1] = 'x';
//   wt(S);
// }


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
  int N,K;
  cin>>N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int t=0;
  for(int i=0;i<K;i++)t+=a[i];
  cout<<t;
}
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

int n, m, cnt[MAX_N + INDEX];

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

    cin >> n >> m;

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

        cin >> a >> b;

        cnt[a]++;
        cnt[b]++;
    }

    for (int i = 1; i <= n; i++) {
        if (cnt[i] % 2 == 1) {
            cout << "NO" << endl;

            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python3
#AGC4 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

a,b,c = map(int,sys.stdin.readline().split())
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    print(min(a*b,b*c,c*a))


Measured memory_bytes: 38256
import math

N,M = map(int,input().split())
ans = 1
if N-M >= 2 or M-N >= 2:
    print(0)
else:
    if N > M:
        for i in range(1,N+1):
            if i == N:
                ans *= i
            else:
                ans *= i**2
            ans = ans % 1000000007
    elif N < M:
        for i in range(1,M+1):
            if i == M:
                ans *= i
            else:
                ans *= i**2
            ans = ans % 1000000007
    elif N == M:
         for i in range(1,N+1):
                ans *= i**2
                if i == N:
                    ans *= 2
                ans = ans % 1000000007
    print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    char c[h][w], ans[2 * h][w];
    for (int i = 0; i < h; i++) {
        for (int k = 0; k < w; k++) {
            cin >> c[i][k];
        }
    }

    for (int i = 0; i < 2 * h; i++) {
        for (int k = 0; k < w; k++) {
            ans[i][k] = c[i / 2][k];
        }
    }

    for (int i = 0; i < 2 * h; i++) {
        for (int k = 0; k < w; k++) {
            cout << ans[i][k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N],b[MAX_N];
int n;
int imos[MAX_N];
int sch[MAX_N];

int main()
{
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&a[i],&b[i]);
        imos[a[i]]++;
        imos[b[i]+1]--;
    }
    sch[0] = imos[0];
    rep(i,100002){
        sch[i+1] = sch[i] + imos[i+1];
    }
    int res = -1;
    rep(i,100002){
        if(sch[i] >= i-1 && i > res){
            res = i;
        }
    }
    cout << res - 1 << "\n";
}

Measured memory_bytes: 4660
#include<stdio.h>

int main (void){

    int paid;
    int recieved;
    int coin_num = 0;

    while(1){
    scanf("%d",&paid);
    if(paid==0)break;

    coin_num = 0;
    recieved = 1000 - paid;

    coin_num += recieved / 500;
    coin_num += recieved % 500 / 100;
    coin_num += recieved % 500 % 100 / 50;
    coin_num += recieved % 500 % 100 % 50 / 10;
    coin_num += recieved % 500 % 100 % 50 % 10 / 5;
    coin_num += recieved % 500 % 100 % 50 % 10 % 5;

    printf("%d\n",coin_num);
    }

    return 0;
}

Measured memory_bytes: 600
import java.util.*;
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 = sc.nextInt();
  int x = sc.nextInt();
  int max = a;
  if(max <= b)max = b;
  if(max <= c)max = c;
  System.out.println(a+b+c+(int)(max*Math.pow(2,x) - max));
}}


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

int main(){
  int N;
  string u;
  double x, ans; 
  
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> x >> u;
    if (u == "BTC") x = x * 380000.0;
    ans += x;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long
const int N = 2e5 + 5;
using namespace std;

int n, k, p[N], bit[N];
long long a[N], ans;

void update(int i){
    while (i < N){
        bit[i]++;
        i += i&(-i);
    }
}

int get(int i){
    int ans = 0;
    while (i > 0){
        ans += bit[i];
        i -= i&(-i);
    }
    return ans;
}

signed main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) a[i] += a[i-1] - k;
    for (int i = 0; i <= n; i++) p[i] = i;
    sort(p, p+1+n, [](int x, int y){return (a[x] < a[y] || (a[x] == a[y] && x < y));});
    for (int i = 0; i <= n; i++) a[p[i]] = i+1;
    update(a[0]);
    for (int i = 1; i <= n; i++){
        ans += get(a[i]);
        update(a[i]);
    }
    cout << ans;
}


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

using namespace std;

const int MOD = 1e9 + 7;
map<string, long long> DP[105];
int gN;

bool Valid(string last)
{
    for (int i = 0; i < 4; i++)
    {
        if (last[i] != 'A' && last[i] != 'C' && last[i] != 'T' && last[i] != 'G') return false;
    }
    for (int i = 0; i < 4; i++)
    {
        //Change, maybe?
        string s = last;
        if (i >= 1) swap(s[i - 1], s[i]);
        if (s.find("AGC") != string::npos)
        {
            //cout << s << "\n";
            return false;
        }
    }
    return true;
}

long long DFS(int N, string last)
{
    if (DP[N].count(last)) return DP[N][last];
    if (N == gN) return 1;
    for (char c : "ACGT")
    {
        if (Valid(last + "" + c))
        {
            string s = last.substr(1);
           // cout << s << " c:" << c << "\n";
            DP[N][last] = (DP[N][last] + DFS(N + 1, s + "" + c)) % MOD;
        }
    }
    return DP[N][last];
}

int main()
{
    cin >> gN;
    cout << DFS(0, "TTT");
}

Measured memory_bytes: 4072
N = int(input())
cards = []
for i in range(N):
    line = input().split()
    a = line[0]
    num = int(line[1])
    cards.append((a, num))

tarinai_list = []
for a in ['S', 'H', 'C', 'D']:
    for num in range(1, 14):
        find = False
        for card in cards:
            if a == card[0] and num == card[1]:
                find = True
                break
        if not find:
            tarinai_list.append((a, num))
for l in tarinai_list:
    print(' '.join(map(str, l)))


Measured memory_bytes: 5600
using System;


namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            
            while (true)
            {
                String[] input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                int x = int.Parse(input[1]);
                int cunt = 0;
                if (n == 0 && x == 0)
                {
                    break;
                }

                for (int i = 1; i <= n; i++)
                {
                    for (int k = i + 1; k <= n; k++)
                    {
                        for (int p = k + 1; p <= n; p++)
                        {
                            if (i + k + p == x)
                            {
                                cunt = cunt + 1;
                                
                            }
                            else if (n <= 3 && n >= 100)
                            {
                                break;
                            }
                        }
                    }
                }
                Console.WriteLine(cunt);
            }
        }
    }
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((b / a) > c)
    {
        cout << c << endl;
    }
    else
    {
        cout << b / a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    lli n, a, b, m, sum;
    cin >> n >> a >> b;
    sum = (n / (a+b)) * a;
    m = n % (a+b);
    if (m < a){
        sum += m;
    }
    else{
        sum += a;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

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

    int N,M;
    while(true){
        cin >> N >> M;
        if(N==0 && M==0) break;
        int x,y;
        char C[M+2][N+2];
        rep(i,M+2) rep(j,N+2) C[i][j]='#';
        rep(i,M){
            rep(j,N){
                cin >> C[i+1][j+1];
                if(C[i+1][j+1]=='@'){
                    x=i+1; y=j+1;
                }
            }
        }
        queue<pi> que;
        que.emplace(x,y);
        int ans=0;
        while(!que.empty()){
            int a=que.front().fi,b=que.front().se;
            que.pop();
            if(C[a][b]=='#') continue;
            ans++;
            C[a][b]='#';
            rep(i,4){
                if(C[a+dx[i]][b+dy[i]]=='.'){
                    que.emplace(a+dx[i],b+dy[i]);
                }
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;

int n, vis[maxn], Ans;
ll a[maxn], mx;

inline void solve(ll k) {
	vis[0] = 0;
  for(int i = 1, j = n;i <= n;i ++) {
	  if(vis[i]) continue;
		while(j > 0 && (vis[j] || a[i] + a[j] > k)) j --;
		if(j && i != j && a[i] + a[j] == k) {
		  vis[i] = 1;
			vis[j] = 1;
			Ans ++;
		}
	}
}

int main() {
	scanf("%d", &n);
	mx = - 1;
	for(int i = 1;i <= n;i ++) scanf("%lld", &a[i]), mx = max(mx,a[i]);
	int len = 1;
	while((1LL << (len + 1)) <= mx) len ++;
	len ++;
	Ans = 0;
	memset(vis,0,sizeof(vis));
	sort(a + 1,a + n + 1);
	for(int i = len;i >= 0;i --) {
		solve(1LL << i);
	}
	printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  if(N % 10 == 2)ans++;
  if((N / 10) % 10 == 2)ans++;
  if((N / 100) % 10 == 2)ans++;
  if((N / 1000) % 10 == 2)ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();

    public static void main(String args[]) throws Exception
    {
		long curr=sc.nextLong();
		if(curr<=6)
		{
			out.println(1);
		}
		else if(curr<=11)
		{
			out.println(2);
		}
		else
		{
			long val1=(curr/11L);curr-=(val1*11L);long add=((curr==0?0:(curr<=6?1:2)));
			out.println((val1*2)+add);
		}
		out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

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

int main(){
  int n,m;
  cin>>n>>m;
  int a[100005];
  rep(i,n){
    cin>>a[i];
  }
  int ma[100005];
  ma[n-1]=a[n-1];
  for(int i=n-2; i>=0; i--){
    ma[i]=max(ma[i+1],a[i]);
  }
  rep(i,n){
    a[i]=ma[i]-a[i];
  }
  int ans=0,a_max=0;
  rep(i,n){
    if(a_max<a[i]){
      ans=1;
      a_max=a[i];
    }
    else if(a_max==a[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}

signed main(){

    fastIO
    int n;
    cin >> n;
    int arr[n], xor_all = 0;
    for (int i = 0; i < n; i++) {
    	cin >> arr[i];
    	xor_all ^= arr[i];
    }
    for (int i = 0; i < n; i++) {
    	cout << (arr[i]^xor_all) << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 5212
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long[] a;
	static long[][] dp;
	static boolean[][] visited;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		a=new long[n];
		dp=new long[n][n];
		visited=new boolean[n][n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
		}
		System.out.println(dfs(0,n-1));
	}
	static long dfs(int l,int r){
		if(visited[l][r]) return dp[l][r];
		if(l==r) return a[l];
		visited[l][r]=true;
		return dp[l][r]=Math.max(a[l]-dfs(l+1,r),a[r]-dfs(l,r-1));
	}
}

Measured memory_bytes: 130224
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    if x < 0:
        j = p-1
        for i in range(m)[::-1]:
            while j >= 0 and plus[j]*minus[i] <= x:
                j -= 1
            cnt += p - j - 1
    else:
        j = 0
        for i in range(m)[::-1]:
            while j < m and minus[j]*minus[i] > x:
                j += 1
            cnt += max(0,i-j)
        j = p-1
        for i in range(p):
            while j >= 0 and plus[j]*plus[i] > x:
                j -= 1
            cnt += max(0,j-i)
        cnt += zero*(zero-1)//2 + m*p + zero*(m+p)
    
    return cnt >= k

n,k = LI()
a = LI()
a.sort()
minus = [x for x in a if x < 0]
plus = [x for x in a if x > 0]
m,p = len(minus),len(plus)
zero = bl(a,1) - br(a,-1)
ok,ng = 10**18,-10**18-1

while ok - ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 87636
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 400000;
int a[N], b[N], psa[N], psb[N], it1 = 0, it2 = 0;

int32_t main(){
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < N; i++){
		a[i] = 10000000000000000ll;
		b[i] = 10000000000000000ll;
		psa[i] = 10000000000000000ll;
		psb[i] = 10000000000000000ll;
	}
	psa[0] = 0;
	psb[0] = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		psa[i + 1] = (i == 0 ? a[0] : psa[i] + a[i]);
	}
	for (int i = 0; i < m; i++){
		cin >> b[i];
		psb[i + 1] = (i == 0 ? b[0] : psb[i] + b[i]);
	}
	int ans = 0;
	for (int i = 0; i <= n; i++){
		if (k < psa[i])
			continue;
		int x = k - psa[i];
//		for (int i = 0; i <= m + 1; i++){
//			cout << psb[i] << ' ';
//		}
//		cout << endl;
		int y = upper_bound(psb, psb + N, x) - psb - 1;
//		cout << y << endl;
		ans = max(ans, y + i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 16052
from sys import exit
def fun(arr,i,j,k):
    ans = arr[0]
    if i == '+':
        ans += arr[1]
    else:
        ans += -arr[1]
    if j == '+':
        ans += arr[2]
    else:
        ans -= arr[2]
    if k == '+':
        ans += arr[3]
    else:
        ans -= arr[3]
    return ans
s = raw_input().strip()
s = [int(x) for x in s]
for i in ['+','-']:
    for j in ['+','-']:
        for k in ['+','-']:
            if fun(s,i,j,k) == 7:
                print str(s[0])+i+str(s[1])+j+str(s[2])+k+str(s[3])+"=7"
                exit(0)

Measured memory_bytes: 28396
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = a + b;
		
		if (ans >= 24) {
			System.out.println(ans - 24);
		} else {
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int X, N, M;


int main()
{
	
	IN >> X >> N >> M;

	X -= N;
	X -= (X / M) * M;

	printf("%d\n", X);


	return 0;
}

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

int h, w;
const int N = 88;
int A[N][N], B[N][N];
int ans = INT_MAX;

bool mem[N][N][4 * N * N];

void solve(int i, int j, int sum) {
    if(i == h || j == w) return;
    if(i == h - 1 && j == w - 1) {
        ans = min({ans, abs(sum + A[i][j]), abs(sum + B[i][j])});
        return;
    }

    int s = sum + 2 * N * N;
    if(mem[i][j][s]) return;
    mem[i][j][s] = true;

    solve(i + 1, j, sum + A[i][j]);
    solve(i + 1, j, sum + B[i][j]);
    solve(i, j + 1, sum + A[i][j]);
    solve(i, j + 1, sum + B[i][j]);
}

int main() {
    //ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> A[i][j];
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int temp = A[i][j];
            cin >> B[i][j];
            A[i][j] -= B[i][j];
            B[i][j] -= temp;
        }
    }

    solve(0, 0, 0);
    cout << ans;
}

Measured memory_bytes: 211840
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;

	bool b = false;
	for (int i = 0; i <= X; i++) {
		int n = 2 * i + 4 * (X - i);
		if (n == Y) b = true;
	}

	cout << (b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3596
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    println!("{}", if a <= c && c <= b { "Yes" } else { "No" });
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;


ll factorial(ll n,ll mod){
  static ll dp[100000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1,mod))%mod;
}

ll powl(ll x,ll r,ll mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod){
  return powl(x,mod-2,mod);
}

ll combination(ll n,ll m,ll mod){
  return (((factorial(n,mod)*inverse(factorial(m,mod),mod))%mod)*inverse(factorial(n-m,mod),mod))%mod;
}



ll n;
typedef tuple<ll,ll> tll;
map<tll, ll> mem;
set<tll> used;

ll gcd(ll a,ll b){
    while(a > 0){
        b %= a;
        swap(a,b);
    }
    return b;
}

tll get_minimal(ll a,ll b){
    if(a == 0 && b == 0){
        return make_tuple(0ll,0ll);
    }
    ll g = gcd(abs(a), abs(b));
    a /= g;
    b /= g;
    if(a < 0){
        a *= -1;
        b *= -1;
    }
    if(a < b){
        a *= -1;
        b *= -1;
    }
    return make_tuple(a,b);

}

tll get_opo(tll x){
    ll a,b;
    tie(a,b) = x;
    swap(a,b);
    b *= -1;
    if(a < 0){
        a *= -1;
        b *= -1;
    }
    if(a < b){
        a *= -1;
        b *= -1;
    }
    ll a_,b_;
    tie(a_,b_) = x;
    assert((a_*a + b_*b) == 0);
    return make_tuple(a,b);
}

ll calc_comb(ll x, ll y){
    return powl(2, x, mod) + powl(2, y, mod) - 1;
}

ll ans = 1;

int main(){
    // for(ll i = 0;i < 10000;i++){
    //     for(ll j = 0;j < 10000;j++){
    //         ll a,b;
    //         tie(a,b) = get_opo(get_minimal(i,j));
    //
    //     }
    // }
    // cerr << "test_ok" << endl;
    cin >> n;
    for(ll i = 0;i < n;i++){
        ll a,b;
        cin >> a >> b;
        mem[get_minimal(a,b)]++;
    }
    for(auto x : mem){
        if(x.first == make_tuple(0ll, 0ll)){
            continue;
        }

        tll ab = x.first;
        tll opo = get_opo(x.first);
        if(used.count(opo) || used.count(ab)) continue;
        used.insert(opo);
        used.insert(ab);
        ans *= calc_comb(mem[ab], mem[opo]);
        ans %= mod;
    }

    ans = (ans - 1 + mod) % mod;
    ans += mem[make_tuple(0ll, 0ll)];
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 53540
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree< ll, null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mod;

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

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

  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  mod = p;

  if(10 % p == 0){
    ll ans = 0;
    for(int i = 0; i < n; i++){
      if((s[i] - '0') % p == 0) ans += i + 1;
    }
    cout << ans << endl;
    return 0;
  }

  vector < ll > dp(p, 0);
  ll x = 0, ans = 0;
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    ll num = s[i] - '0';
    x = (10 * x + num) % p;
    ll val = x * pwr(10, n - i - 1);
    val %= p;
    //ans += dp[x];
    dp[val]++;
  }

  for(int i = 0; i < p; i++){
    if(dp[i] >= 2) ans += (dp[i] * (dp[i] - 1)) / 2;
  }

  cout << ans << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  
  for(int i = 1; i <= sqrt(n); i++) {
    for(int j = 1; j <= sqrt(n); j++) {
      int xx = pow(i, j);
      if(xx <= n)
        ans = max(ans, xx);
    }
  }
    
  cout << ans << "\n";

}


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

using namespace std;

const int N = 3e3 + 5;
const int mod = 998244353;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }
inline int fpow( int b , int k ) {
  int res = 1;
  while( k ) {
    if( k & 1 ) res = 1LL * res * b % mod;
    b = 1LL * b * b % mod; k >>= 1;
  }
  return res;
} 

int f[N][N] , a , b , c , d;

int main( void ) {
  cin >> a >> b >> c >> d;
  f[a][b] = 1;
  for( int i = a ; i <= c ; ++i )
    for( int j = b ; j <= d ; ++j )
      if( i != a || b != j ) {
        inc( f[i][j] , 1LL * f[i - 1][j] * j % mod );
        inc( f[i][j] , 1LL * f[i][j - 1] * i % mod );
        dec( f[i][j] , 1LL * f[i - 1][j - 1] * ( i - 1 ) % mod * ( j - 1 ) % mod );
      }
  printf("%d",f[c][d]);
  return 0;
}


Measured memory_bytes: 38832
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> a(n), b(m);
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int j = 0; j < m; j++) cin >> b[j];
		int sa = 0, sb = 0;
		for (int i = 0; i < n; i++) sa += a[i];
		for (int j = 0; j < m; j++) sb += b[j];
		int _i = 0, _j = 0, mini = INT_MAX;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if (sa - a[i] + b[j] == sb - b[j] + a[i])
					if (a[i] + b[j] < mini) {
						_i = i; _j = j; mini = a[i] + b[j];
					}
		if (mini < INT_MAX) cout << a[_i] << ' ' << b[_j] << endl;
		else cout << -1 << endl;
	}
}

Measured memory_bytes: 1196
n, m = $stdin.readline.chomp.split.map(&:to_i)
a = $stdin.readline.chomp.split.map(&:to_i)
q = []
h = Hash.new(0)

a.each do |i|
  cnt = 0
  while i & 1 == 0
    i >>= 1
    cnt += 1
  end
  h[cnt] += 1
  q << i
end

if h.keys.size > 1
  puts "0"
else
  l = q.inject(&:lcm) * (1 << (h.keys.first - 1))
  puts (m + l) / (2 * l)
end

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

int main()
{
  	bool flag = true;
 	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	while(true)
    {
      	c -= b;
      	if(c <= 0)
        {
          flag = false;
          break;
        }
      	a -= d;
      	if(a <= 0)
        {
          flag = true;
          break;
        }
    }

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


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,x,sum=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==x)
					sum++;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,b=0;
  cin >> n;
  for(int i=1;i<n+1;i++) {
    string s=to_string(i);
    a=s.length();
    b=b+a%2;
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
/*
        _/﹋\_                                _/﹋\_
        (҂`_´)                                (҂`_´) 
        <,︻╦╤─҉- - - - - - - - => - => - =>  <,︻╦╤─҉- - - - - - - - => - => - =>   
        _/﹋\_                                _/﹋\_                          
*/
//ARC
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    int n;
    cin>>n;
    int ans=0;
    int a;
    for(int i=1;i<=n; i++)
    {
        cin>>a;
        if(i&1&&a&1)
        ++ans;
    }
    cout<<ans;
    return 0;
}
//Date: ###### Sat Jul 11 17:34:34 IST 2020
//------------------------------------------------------------------------------

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>

int differ(int a,int b){
        b-=a;
        if(b<0)
                b*=-1;
        return b;
}

int main(void){
        int n,i,p,x[100],y[100],max=-1;
        double sum;

        scanf("%d",&n);
        for(i=0;i<n;i++)
                scanf("%d",&x[i]);
        for(i=0;i<n;i++){
                scanf("%d",&y[i]);
                if(differ(x[i],y[i])>max)
                        max=differ(x[i],y[i]);
        }
        for(p=1;p<=3;p++){
                sum=0;
                for(i=0;i<n;i++)
                        sum+=pow(differ(x[i],y[i]),p);
                printf("%f\n",pow(sum,(1/(double)p)));
        }
        printf("%d\n",max);
        return 0;
}

Measured memory_bytes: 700
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n, c, k, t[100000];
int bs, p;

int main(){
	cin >> n >> c >> k;
	lp(n)
		cin >> t[i];
	sort(t, t + n);
	
	bs = 1;
	p = 0;

	lp(n) {
		if (t[i] > t[p] + k || i > p + c - 1) {
			p = i;
			bs++;
		}
	}
	cout << bs << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int gcd(int M, int N) {
	if (M < N) std::swap(M, N);
	if (N == 0) return M;
	else return gcd(N, M%N);
}
int main(void) {
	int N;
	int ans = 0;
	std::cin >> N;
	std::vector<int> a(N + 1), b;
	std::cin >> a[0];

	for (int i = 1; i <= N; ++i) {
		std::cin >> a[i];
	}
	SORT(a);
	for (int i = 1; i <= N; ++i) {
		if (a[i] - a[i - 1] != 0) {
			//ans = std::min(ans, a[i] - a[i - 1]);
			b.push_back(a[i] - a[i - 1]);
		}
		
	}
	if (b.size() == 1) {
		std::cout << b[0] << std::endl;
	}
	else if(b.size() == 2){
		std::cout << gcd(b[0], b[1]) << std::endl;
	}
	else {
		ans = gcd(b[0], b[1]);
		for (size_t i = 2; i < b.size(); ++i) {
			ans = gcd(ans, b[i]);
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
using namespace std;

int main(){
    int A, B;
    cin >> A >>B;

    if(B % A == 0){
        cout << A + B << endl;
    }
    else{
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = [input() for i in range(N)]
a = list(map(int, a))

i = 1
count = 0
Flag = False
while count < N:
    i = a[i-1]
    count += 1
    if i == 2:
        Flag = True
        break

if Flag:
    print(count)
else:
    print(-1)

Measured memory_bytes: 13436
n, k = input().split()

sunuke = [ 0 ] * int(n)

for i in range( int( k ) ):
    d = int( input() )
    a = input().split()
    for a_i in a:
        sunuke[ int( a_i ) - 1 ] = 1

cnt = 0
for sunuke_i in sunuke:
    if sunuke_i == 0:
        cnt = cnt + 1

print( cnt )

Measured memory_bytes: 9216
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 string s;
		 cin >> s;
		 int res = 0,count = 0;
		 for(int i = 0; i < (int) s.size();i++){
			 if(s[i] == 'R'){
				 count += 1;
				 res = max(res,count);
			 }else{
				 res = max(res,count);
				 count = 0;
			 }
		 }
		 cout << max(res,count) << "\n";
	 }
}



Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
int main(){


     for (int i = 1; ; i++)
     {
     char ch;
     int a,b;
     if(ch == '?') break;
     scanf("%d ",&a);   
     scanf(" %c", &ch);
     scanf(" %d",&b);
     if(ch == '+')printf("%d\n",a+b);
     if(ch == '-')printf("%d\n",a-b);
     if(ch == '*')printf("%d\n",a*b);
     if(ch == '/')printf("%d\n",a/b);
     }
        
    return 0;
}



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

int main() {
	int n,a,b,ds,sum=0;
	cin >> n >> a >> b;
	for(int i=1;i<n+1;i++){
		ds=i%10+i/10%10+i/100%10+i/1000%10+i/10000;
		if((ds>=a)&&(ds<=b)){
		sum=sum+i;                                  
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  string a,b;
  cin>>a>>b;
  bool e=1;
  rep(i,a.size()){
  if(a[i]!=b[i])
    e=0;
  }
  if(e)
    cout<<"Yes";
  else
    cout<<"No";
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 405, p = 998244353;
int n, A[N], B[N], SA, SB, inv[N], fac[N], a[N][N], f[N][N][N];

int mul(int x, int y) { return 1LL * x * y % p; }
void add(int &x, int y) { x += y; if (x >= p) x -= p; }
void del(int &x, int y) { x -= y; if (x < 0) x += p; }

int ksm(int x, int y) {
	int res = 1;
	for (; y; y >>= 1, x = mul(x, x)) if (y & 1) res = mul(res, x);
	return res;
}

int main() {
	n = read();
	for (int i = 1; i <= n; ++ i) read(A[i], B[i]), SA += A[i], SB += B[i];
	fac[0] = 1;
	for (int i = 1; i <= 400; ++ i) fac[i] = mul(fac[i - 1], i);
	inv[400] = ksm(fac[400], p - 2);
	for (int i = 399; i >= 0; -- i) inv[i] = mul(inv[i + 1], i + 1);
	for (int i = 1; i <= n; ++ i) {
		a[i][0] = 1;
		for (int j = 1; j <= SB; ++ j) {
			a[i][j] = mul(a[i][j - 1], A[i]);
		}
	}
	f[0][0][0] = p - 1;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 0; j <= SA; ++ j) {
			for (int k = 0; k <= SB; ++ k) {
				// if (!f[i - 1][j][k]) continue;
				add(f[i][j][k], f[i - 1][j][k]);
				for (int l = 0; l < B[i]; ++ l) {
					if (A[i] > j || l > k) break;
					del(f[i][j][k], mul(f[i - 1][j - A[i]][k - l], mul(a[i][l], inv[l])));
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= SA; ++ i) {
		int inv = ksm(i, p - 2), t = mul(SA, inv);
		for (int j = 0; j <= SB; ++ j) add(ans, mul(f[n][i][j], mul(t, fac[j]))), t = mul(t, inv);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 259712
//
// Created by yamunaku on 2020/01/18.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    ll n,k,s;
    cin >> n >> k >> s;
    if(s==IINF){
        rep(i,k){
            cout << IINF << endl;
        }
        rep(i,n-k){
            cout << 1 << endl;
        }
    }else{
        rep(i,k){
            cout << s << endl;
        }
        rep(i,n-k){
            cout << IINF << endl;
        }
    }
    return 0;
}

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


using namespace std;

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

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

int main(){

	int n;
	cin >> n;

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

	for(int i = 0; i < n; i++){
		if(i) cout << " ";
		cout << a[n - i - 1];
	}
	cout  << endl;

	return 0;
}

Measured memory_bytes: 1160