akhauriyash/Code-Regression huggingface dataset:
# AGC005A - STring
def main():
    X = input().rstrip()
    ans, s, t = 0, 0, 0
    for i in X:
        if i == "S":
            s += 1
        else:
            if t < s:
                t += 1
            else:
                ans += 1
    ans += s - t
    print(ans)


if __name__ == "__main__":
    main()

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

int main()
{
    ll n,k;
    cin>>n;
    ll a[n+7],b[n+6],c[n+6];
    ll dp[n+5][4];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];dp[1][2]=b[1];dp[1][3]=c[1];
    for(int i=2;i<=n;i++){
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
    }
    cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;
}


Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 1 << 19;
const LL MOD = 1000000007;
const LL INF = (LL) 1e9 + 5;

int N, a[MAXN], cnt[25];

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

	cin >> N;
	cnt[N] = 1;
	for (int i = 0; i < (1 << N); i++) {
		cin >> a[i];
	}
	sort(a, a + (1 << N), greater<int>());
	
	int l = 0, M = (1 << N);
	bool ok = true;
	while (l < M && ok) {
		int r = l, j = N;
		vector<int> take;
		
		while (r < M && a[r] == a[l]) {
			while (j > 0 && cnt[j] == 0) {
				j--;
			}
			if (cnt[j] == 0) {
				ok = false;
				break;
			}
			cnt[j]--;
			take.push_back(j);
			
			r++;
		}
		
		for (int x : take) {
			for (int i = 0; i < x; i++) {
				cnt[i]++;
			}
		}
		
		l = r;
	}
	
	cout << (ok ? "Yes\n" : "No\n");

	return 0;
}

Measured memory_bytes: 2080
require 'set'
n=gets.to_i
os = "&&&"
f = 0
set1 = Set.new
n.times do |i|
    s = gets.chomp
    if i > 0 && os[os.size-1] != s[0]
        f = 1;
    end
    if set1.add?(s) == nil
        f = 1;
    end
    os = s
end

puts (f == 1) ? "No" : "Yes"



Measured memory_bytes: 3964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] t = new long[n];
        for (int i = 0; i < n; i++) {
            t[i] = Long.parseLong(sc.next());
        }

        long res = 1;
        for (int i = 0; i < n; i++) {
            res = lcm(res, t[i]);
        }

        System.out.println(res);
    }

    private static long gcd(long a, long b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    private static long lcm(long a, long b) {
        long g = gcd(a, b);
        return a / g * b;
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define eb emplace_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e6+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool mm[N];
vi primes(1,2);
//ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

// void pascal(){
// 	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
// 	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
// }

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

int main(){
	sieve();
	vi p;
	lli n; cin>>n;
	for(auto i:primes){
		if(i>n)break;
		if(n%i==0){
			int x = 0;
			while(n%i==0){x++; n/=i;}
			p.pb(x);
		}
	}
	if(n!=1)p.pb(1);
	sort(all(p));
	lli c = 0,sum=0;
	int j = 0;
	//for(auto i:p)cout<<i<<" ";cout<<ENDL;
	for(int i =1; ; i++){
		c+=i;
		if(j==sz(p))break;
		while(1){
			if(j==sz(p))break;
			if(p[j]>=c+(i+1))break;
			sum+=i;
			j++;
		}
	}
	cout<<sum<<ENDL;

}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool dp1[5005][5005];
bool dp2[5005][5005];

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    dp1[0][0] = true;
    rep(i, n) {
        rep(j, k+1) {
            dp1[i+1][j] = dp1[i][j];
            if (j-a[i]>=0) dp1[i+1][j] |= dp1[i][j-a[i]];
        }
    }
    dp2[n][0] = true;
    rrep(i, n) {
        rep(j, k+1) {
            dp2[i][j] = dp2[i+1][j];
            if (j-a[i]>=0) dp2[i][j] |= dp2[i+1][j-a[i]];
        }
    }
    int ans = 0;
    rep(i, n) {
        //debug(i);
        bool ok = false;
        vector<ll> v1;
        vector<ll> v2;
        rep(j, k+1) {
            if (dp1[i][j]) v1.push_back(j);
            if (dp2[i+1][j]) v2.push_back(j);
        }
        ll low = max(k-a[i], 0LL);
        for (ll e1: v1) {
            auto it = lower_bound(whole(v2), low-e1);
            if (it==v2.end()) continue;
            ll e2 = *it;
            if (e1+e2<k) {
                ok = true;
                break;
            }
        }
        if (!ok) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 52656
#include <stdio.h>
	
		

	int main(){
		int array[500000];
		int a[500000];
		int n;
		scanf("%d",&n);
		for( int i = 0;i < n; i++){
			scanf("%d",&a[i]);
		}
		int left = 250000, right = left+1;
		for(int i =0; i<n; ++i){
			if(i%2 == (n-1)%2){
				array[left--]=a[i];
			}else{
				array[right++]=a[i];
			}
		}

		for(int i = left +1; i< right; ++i){
				printf("%d ",array[i]);
		}
		
		return 0;
	}

Measured memory_bytes: 4864
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n%1000 == 0:
        print(0)
    else:
        maisu = n//1000 + 1
        oturi = 1000*maisu - n
        print(oturi)


if __name__ == '__main__':
    solve()


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int c = 0;
    if (s[0] == '1') ++c;
    if (s[1] == '1') ++c;
    if (s[2] == '1') ++c;
    cout << c << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void)
{
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);
    rep(i, a) cin >> A.at(i);
    rep(i, b) cin >> B.at(i);

    int minA = *min_element(A.begin(), A.end());
    int minB = *min_element(B.begin(), B.end());

    int min_cost = minA+minB;

    rep(i,m){
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;

        min_cost =min(min_cost,A.at(x) + B.at(y) - c);
    }
    cout << min_cost << endl;

    return 0;
}

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

#define unknown 'X'  // NOTE!!
#define say_same 'o'
#define say_diff 'x'
#define disable "-1"

#define Ss ss_sw_ws_ww.at(0UL)
#define Sw ss_sw_ws_ww.at(1UL)
#define Ws ss_sw_ws_ww.at(2UL)
#define Ww ss_sw_ws_ww.at(3UL)

string solve(const size_t N, string &s) {
    s = s.at(N - 1UL) + s + s.at(0UL);

    const string sheep = "WS";
    string ss(N + 2UL, unknown);
    vector<string> ss_sw_ws_ww(4UL, ss);
    Ss.at(1UL) = Ss.at(2UL) = Sw.at(1UL) = Ws.at(2UL) = sheep[true];
    Sw.at(2UL) = Ws.at(1UL) = Ww.at(1UL) = Ww.at(2UL) = sheep[false];
    if (s.at(1UL) == say_same) {
        Ss.at(0UL) = Ww.at(0UL) = sheep[true];
        Sw.at(0UL) = Ws.at(0UL) = sheep[false];
    } else {
        Ss.at(0UL) = Ww.at(0UL) = sheep[false];
        Sw.at(0UL) = Ws.at(0UL) = sheep[true];
    }

    for (size_t i = 2UL; i <= N; i++) {
        for (string &ss_i : ss_sw_ws_ww) {
            bool i_is_sheep   = (ss_i.at(i) == sheep[true]);
            bool im1_is_sheep = (ss_i.at(i - 1UL) == sheep[true]);
            if (s.at(i) == say_same)
                ss_i.at(i + 1UL) = sheep[(i_is_sheep == im1_is_sheep)];
            else
                ss_i.at(i + 1UL) = sheep[(i_is_sheep != im1_is_sheep)];
        }
    }

    for (const string &ss_i : ss_sw_ws_ww) {
        if (ss_i.at(N) == ss_i.at(0UL) && ss_i.at(N + 1UL) == ss_i.at(1UL))
            return ss_i.substr(1UL, N);
    }
    return disable;
}

int main() {
    size_t N;
    cin >> N;
    string s;
    cin >> s;

    cout << solve(N, s) << "\n";
    return 0;
}


Measured memory_bytes: 3900
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for ll in range(len(N)):
    a = [int(i) for i in N[ll].split(",")]
    l = []
    totalLen = 0
    for i in range(10):
        l.append(a[i])
        totalLen += a[i]
    v1 = a[10]
    v2 = a[11]
    midPoint = totalLen*v1/(v1+v2)
    ans = 10
    for i in range(10):
        midPoint -= l[i]
        if midPoint <= 0:
            ans = i+1
            break
    print(ans)



Measured memory_bytes: 5604
from math import sqrt


def get_distance(x1, y1, x2, y2):
    return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


def main():
    x = []
    y = []
    N = int(input())
    distance = 0
    for i in range(N):
        list = input().split(" ")
        x.append(int(list[0]))
        y.append(int(list[1]))
    for j in range(N):
        for k in range(j + 1, N):
            distance += get_distance(x[j], y[j], x[k], y[k])
    print(distance * 2 / N)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
LL h, w, n, m, s, ans = 0, num = 1, sum = 0, a[100000];
string str,stt;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
			ans = a[i] - 1;
			a[i] = 1;
		}
		else {
			int f = 0;
			if(a[i] > num+1) {
				f = 1;
				ans += a[i] / (num + 1) - (a[i] % (num + 1) == 0 ? 1 : 0);
				a[i] = 1;
			}
		}
		num = max(num, a[i]);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L[i+1:]):
        if l1 == l2:
            continue
        for k, l3 in enumerate(L[i+j+2:]):
            if (l2 == l3) or (l1 == l3):
                continue

            if (l1 + l2 > l3) and (l2 + l3 > l1) and (l1 + l3 > l2):
                cnt += 1

print(cnt)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,p=0;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
    for(int i=0;i<n;i++)
    {
        if(i+2<n)
        {
        if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
        {
            p=5;
            break;
        }
        }
    }
    if(p==5)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
#define LL  long long
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return

pair<int,int> A,B;

int main(){
    CIN(B);CIN(A);
    LL ans1,ans2,ans3,ans4;
    V<LL> v;
    ans1 = (-A>=B?(-A)-B:LINF)+1;
    ans2 = (A>=B?A-B:LINF);
    ans3 = (-A>=-B?(-A)-(-B):LINF)+2;
    ans4 = (A>=-B?A-(-B):LINF)+1;
    v.pb(ans1);
    v.pb(ans2);
    v.pb(ans3);
    v.pb(ans4);
    sort(ALL(v));
    COUT(v.at(0));
  return 0;
}


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

int main(){
  int a,b,c;cin >> a >> b >> c;
  if(a <= c && b >= c)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[[2]*n for i in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    A[i][x-1]=y
ans=0
for i in range(2**n):
  aa=0
  s=format(i,'18b')
  H=[]
  for j in range(n):
    if s[-1-j]=="1":
      H.append(j)
      aa=aa+1
  h=set(H)
  f=0
  for j in range(len(H)):
    for k in range(n):
      if A[H[j]][k]==2:
        continue
      if A[H[j]][k]==1:
        if k not in h:
          f=1
      else:
        if k in h:
          f=1
  if f==0:
    if aa>ans:
      ans=aa
print(ans)

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

int main() {
  int N , a , b , c , d;
  cin >> N;

  a = N / 1000;
  b = (N % 1000) / 100;
  c = ((N % 1000) % 100) / 10;
  d = ((N % 1000) % 100) % 10;
    
  if ( a == b && b == c ) {
    cout << "Yes" << endl;
  }
  else if ( b == c && c ==d ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b && a > c) cout << "A" << endl;
  else if(b > a && b > c) cout << "B" << endl;
  else cout << "C" << endl;
  return 0;
}




Measured memory_bytes: 3120
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       int n=s.nextInt();
       long[] arr=new long[n];
       long[] pre=new long[n];
       long ss=0;
       for(int i=0;i<n;i++){
        arr[i]=s.nextLong();
        ss+=arr[i];
       }
       pre[0]=arr[0];
       for(int i=1;i<n;i++){
        pre[i]=pre[i-1]+arr[i];
      }
        long res=Long.MAX_VALUE;
      for(int i=0;i<n;i++){
        res=Math.min(res,Math.abs(ss-pre[i]-pre[i]));
      }
       
        System.out.println(res);
        }
    }


Measured memory_bytes: 93860
import heapq as hq
N = int(input())
peak = []
peak_num = 0

def search(lst, n, length):
	l = 0
	r = length
	while r - l > 1:
		p = (l+r) // 2
		if lst[p] < n:
			r = p
		else:
			l = p
	return l

for i in range(N):
	a = int(input())
	if peak_num == 0:
		peak.append(a)
		peak_num += 1
	elif peak[peak_num-1] >= a:
		peak.append(a)
		peak_num += 1
	else:
		n = search(peak, a, peak_num)
		if peak[n] < a:
			peak[n] = a
		else:
			peak[n+1] = a
print(peak_num)

Measured memory_bytes: 7192
#include<bits/stdc++.h> 
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
int a,b;
int main(){
    read(a);
    read(b);
    int ans=ceil(1.0*(b-1)/(a-1));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n, k, count = 0;
    long long res;
    cin >> n >> k;

    long long zero = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == 0)
            zero++;
    }
    res = zero * zero * zero;

    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            if (i % k == k / 2)
                count++;
        }
        res += (count * count * count);
    }
    cout << res << endl;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

const int MOD = (int)1e9 + 7;
ll n;
ll memo[64][3];
ll dp(int bit, int st){
    if (bit < 0) return 1;
    ll &res = memo[bit][st];
    if (res != -1) return res;
    res = 0;
    if (st == 1) {
        for (int i = 0; i <= 2; i++){
            if (i == 2){
                continue;
            } else if (i == 1){
                if (n & (1LL << bit)) res += dp(bit - 1, 1);
            } else {
                if (n & (1LL << bit)) res += dp(bit - 1, 2);
                else res += dp(bit - 1, 1);
            }
        }
    } else if (st == 0) {
        for (int i = 0; i <= 2; i++){
            res += dp(bit - 1, 0);
        }
    } else if (st == 2){
        for (int i = 0; i <= 2; i++){
            if (i == 2){
                if (n & (1LL << bit)) res += dp(bit - 1, 2);
                else res += dp(bit - 1, 1);
            } else if (i == 1){
                if (n & (1LL << bit)) res += dp(bit - 1, 0);
                else res += dp(bit - 1, 2);
            } else {
                res += dp(bit - 1, 0);
            }
        }
    }
    res %= MOD;
    if (false && (1LL << bit) <= n) {
        cerr << bit << ' ' << st << ' ';
        debug(res);
    }

    return res;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    memset(memo, -1, sizeof memo);
    cout << dp(61, 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

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

    int x = 7 % k;

    set<int> s;
    int i = 1;
    while(s.count(x) == 0){
        if(x == 0){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x *10+7) % k;
        i++;
    }
    cout << -1 << endl;

}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin>> n;
    vector<int> l(n);
    rep(i,n)cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                vector<int> hen;
                hen.push_back(l[i]);
                hen.push_back(l[j]);
                hen.push_back(l[k]);
                if(*max_element(all(hen))<((l[i]+l[j]+l[k])-*max_element(all(hen))))
                {
                    if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>

#define _max(_a_,_b_) ((_a_)>(_b_)?(_a_):(_b_))

typedef long long LLONG;

inline LLONG getnum()
{
	register char c=0;
	while(!(c>='0' && c<='9'))
		c=getchar();
	register LLONG a=0;
	while(c>='0' && c<='9')
		a=a*10+c-'0',c=getchar();
	return a;
}

LLONG a[205050],b[205050];
#define GetLen(_arr,_l,_r) (std::lower_bound(&(_arr)[1],&(_arr)[N+1],_r)-std::lower_bound(&(_arr)[1],&(_arr)[N+1],_l))
LLONG ta[205050],tb[205050];

int main()
{
	register int N=getnum();
	LLONG mxv=0;
	for(register int i=1;i<=N;i++)
		a[i]=getnum(),mxv=_max(mxv,a[i]);
	for(register int i=1;i<=N;i++)
		b[i]=getnum(),mxv=_max(mxv,b[i]);
	register unsigned dig=1;
	while(mxv)
		dig++,mxv>>=1;
	
	LLONG ans=0,pw2=1;
	while(dig--)
	{
		for(register int i=1;i<=N;i++)
			ta[i]=a[i]&((pw2<<1)-1),tb[i]=b[i]&((pw2<<1)-1);
		std::sort(&tb[1],&tb[N+1]);
		register bool sum=0;
		for(register int i=1;i<=N;i++)
			sum^=GetLen(tb,pw2-ta[i],(pw2<<1)-ta[i])&1,
			sum^=GetLen(tb,pw2+(pw2<<1)-ta[i],(pw2<<2)-ta[i])&1;
		ans|=pw2*sum,pw2<<=1;
	}
	printf("%llu\n",ans);
	
	return 0;
}

Measured memory_bytes: 6528
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(1);
  return n[0] == 7 || n[1] == 7 || n[2] == 7 ? "Yes" : "No";
}

Measured memory_bytes: 29632
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<stdio.h>
using namespace std;


struct node {
	node* r, * l, * p;
	int key;

};
node* root, * NIL;

int box[10000] = {};
int t;

void insert(int k) {
	node* y = NIL;
	node* x = root;
	node* z;

	z = (node*)malloc(sizeof(node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->l;
		}
		else {
			x = x->r;
		}
	}
	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->l = z;
		}
		else {
			y->r = z;
		}
	}

}
void search(node* u,int k) {
	if (u == NIL)return;
	if (k == u->key) {
		t = 1;
	}
	if (u->key > k) {
		search(u->l, k);
	}
	else {
		search(u->r, k);
	}
}

void preorder(node* u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->l);
	preorder(u->r);
}


void inorder(node* u) {
	if (u == NIL)return;
	inorder(u->l);
	printf(" %d", u->key);
	inorder(u->r);
}


int main() {
	int n, i, y;
	string ord;

	scanf("%d", &n);
	//scanf_s("%d", &n);

	for (i = 0;i < n;i++) {
		cin >> ord;
		if (ord == "insert") {
			scanf("%d", &y);
			//scanf_s("%d", &y);
			insert(y);
		}
		if (ord == "find") {
			scanf("%d",&y);
			//scanf_s("%d", &y);
			t = 0;
			search(root,y);
			if (t == 0) {
				printf("no\n");
			}
			else {
				printf("yes\n");
			}

		}
		if (ord == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}

	}
	return 0;
}


Measured memory_bytes: 22044
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int H, W; long L;
string[] F;
bool input() {
    scanf("%d %d %lld\n", &H, &W, &L);
    if (H == 0 && W == 0 && L == 0) return false;
    F = new string[H];
    foreach (i; 0 .. H) {
        F[i] = readln.chomp;
    }
    return true;
}

int[char] M;
static this() {
    M = [ 'N': 0, 'E': 1, 'S': 2, 'W': 3 ];
}

void getPos(out int y, out int x, out int dir) {
    foreach (int i; 0 .. H) {
        foreach (int j; 0 .. W) {
            if (F[i][j] in M) {
                y = i; x = j; dir = M[ F[i][j] ];
                return;
            }
        }
    }
    assert(0);
}

const dy = [-1, 0, 1, 0],
      dx = [0, 1, 0, -1];

void turn(int y, int x, ref int dir) {
    int ndir = dir;
    int ny = y + dy[ndir],
        nx = x + dx[ndir];
    while (ny < 0 || ny >= H || nx < 0 || nx >= W || F[ny][nx] == '#') {
        ndir = (ndir + 1) % 4;
        ny = y + dy[ndir];
        nx = x + dx[ndir];
    }
    dir = ndir;
}

void step(ref int y, ref int x, ref int dir) {
    int ndir = dir;
    int ny = y + dy[ndir],
        nx = x + dx[ndir];
    while (ny < 0 || ny >= H || nx < 0 || nx >= W || F[ny][nx] == '#') {
        ndir = (ndir + 1) % 4;
        ny = y + dy[ndir];
        nx = x + dx[ndir];
    }
    y = ny; x = nx; dir = ndir;
}

struct P {
    int y, x, dir;
    string toString() const {
        return format("%d %d %s", y + 1, x + 1, "NESW"[dir]);
    }
}

void solve1() {
    int y, x, dir; getPos(y, x, dir);
    foreach (i; 0 .. L) {
        step(y, x, dir);
    }
    writeln(P(y, x, dir));
}

void solve() {

    if (L <= H * W * 4) {
        solve1();
        return;
    }

    int y, x, dir; getPos(y, x, dir);

    auto U = new int[][][](H, W, 4);
    foreach (i; 0 .. H) foreach (j; 0 .. W) U[i][j][] = -1;
    P[long] X;
    int t = 0;
    int cycle;
    while (true) {
        if (U[y][x][dir] >= 0) {
            cycle = t - U[y][x][dir];
            t = U[y][x][dir];
            break;
        }
        U[y][x][dir] = t;
        X[t] = P(y, x, dir);
        turn(y, x, dir);
        step(y, x, dir);
        t++;
    }

    //writeln([t, cycle]);
    writeln(X[(L - t) % cycle + t]);
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 2152
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
  	long long a,b;

    while(cin>>a>>b){
      int m = __gcd(a,b);
      cout<<(a/m) * (b/m) * m<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
int x[2010];
long long int y[2010];
int a;
struct str{
	int first;
	int second;
};

bool operator<(str a, str b)
{
	if(a.first==b.first) return a.second<b.second;
	return a.first<b.first;
}
std::vector<str> V;
long long int check[2010][2010];
long long int func(int s,int t)
{
	if(s>t) return 0;
	if(check[s][t]) return check[s][t];
	
	int k = (s-1) + (a-t);
	int val = V[a-1-k].first;
	int ind = V[a-1-k].second;
	
	long long int s1 = func(s,t-1) + (long long int)val*(t-ind);
	long long int s2 = func(s+1,t) + (long long int)val*(ind-s);
	return check[s][t] = s1>s2?s1:s2;
}
int main()
{
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	for(int i=1;i<=a;i++) V.push_back({x[i],i});
	std::sort(V.begin(),V.end());
	
	printf("%lld",func(1,a));
}

Measured memory_bytes: 26040
n=int(input())
t=[]
for i in range(n):
    x,y=map(int,input().split())
    t.append([x,y])
sum=0
for p in range(n-1):
    for q in range(p,n):
        l=(t[p][0]-t[q][0])**2+(t[p][1]-t[q][1])**2
        sum+=l**(1/2)
print((2*sum)/n)


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

unsigned gcd_eucidean(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main()
{
  int x, y;
  scanf("%d %d", &x, &y);
  printf("%d\n", gcd_eucidean(x, y));

  return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define int long long
#define N1097 1000000007
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
#define REP(val, count) for(int (val)=0; (val)<(count); ++(val))

using namespace std;

int a[100000];
int b[100000];

signed main()
{
	int n;

	cin >> n;
	REP(i, n)
	{
		int aa, bb;
		cin >> a[i] >> b[i];
	}

	int sum = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		int aa = a[i] + sum;
		if (aa % b[i] == 0) continue;
		int bai = aa / b[i];
		int m = b[i] * (bai + 1);
		int cnt = m - aa;
		sum += cnt;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1920
#include <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    int N;
    NSMutableArray *heights = [[NSMutableArray alloc] initWithCapacity:N];
    scanf("%d", &N);
    NSInteger i = N;
    for(i=0;i<N;i++){
        int h;
        scanf("%d", &h);
        [heights addObject:[NSNumber numberWithInt: h]];
    }
    
    NSInteger result = 0;
    NSInteger current = 0;
    NSInteger prev = -1;
    for(NSNumber *h in heights) {
        NSInteger height = h.integerValue;
        if (prev == -1) {
            prev = height;
            continue;
        }
        if (prev >= height) {
            current ++;
            result = MAX(current, result);
        } else {
            current = 0;
        }
        prev = height;
    }
    
    printf("%d", result);
    return 0;
}

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

int main() {
    double n, m, d;
    cin>>n>>m>>d;
    if(d==0){
        cout<<setprecision(20)<<(m-1)/n<<endl;
    }
    else{
        cout<<setprecision(20)<<(n-d)*2*(m-1)/(n*n)<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> P(N);
    vector<ll> idx(N);
    Rep (i, N) {
        cin >> P[i];
        P[i]--;
        idx[P[i]] = i;
    }

    set<ll> s;
    ll ans = 0;
    for (ll i = N-1; i >= 0; i--) {
        s.insert(idx[i]);
        auto itr = s.find(idx[i]);
        vector<ll> l(2, -1), r(2, N);
        Rep (i, 2) {
            if (itr == s.begin()) break;
            itr--;
            l[i] = *itr;
        }
        itr = s.find(idx[i]);
        Rep (i, 2) {
            itr++;
            if (itr == s.end()) break;
            r[i] = *itr;
        }

        // cout << l[1] << "\t" << l[0] << "\t" << 
        ans += (i + 1) * ((l[0]-l[1])*(r[0]-idx[i]) + (r[1]-r[0])*(idx[i]-l[0]));
        // cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6528
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)
	ans := 0
	l := 0
	for r := 0; r <= n; r++ {
		if r == n || aa[l]+2 < aa[r] {
			if ans < r-l {
				ans = r - l
			}
			l++
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;

int N, M, K;

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
    cin >> N >> M >> K;
    UnionFind uf(N);              // Union-Find Tree で考える
    vector<int> edges_num(N, 0);  // 自身から出る辺の数
    vector<int> A(M), B(M);
    REP(i, M) {
        cin >> A.at(i) >> B.at(i);
        A[i]--, B[i]--;
        edges_num[A[i]]++;
        edges_num[B[i]]++;
        uf.unite(A[i], B[i]);
    }
    vector<int> C(K), D(K);
    REP(i, K) {
        cin >> C.at(i) >> D.at(i);
        C[i]--, D[i]--;
    }

    vector<int> ans(N);
    REP(i, N) { ans[i] = uf.treeSize(i) - 1 - edges_num[i]; }
    REP(i, K) {  // 同じ連結成分にあるブロック関係を引く
        if (uf.isSame(C[i], D[i])) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }

    REP(i, (int)ans.size()) {
        cout << ans[i];
        if (i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

public class Main {
    int n, m;
    long[] ds, ts;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            line = br.readLine();
            n = Integer.parseInt(line);
            ds = new long[n];
            String[] ss = br.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                ds[i] = Long.parseLong(ss[i]);
            }
            m = Integer.parseInt(br.readLine());
            ts = new long[m];
            ss = br.readLine().split(" ");
            for (int i = 0; i < m; i++) {
                ts[i] = Long.parseLong(ss[i]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void solve() {
        HashMap<Long, Integer> nMap = new HashMap<>();
        HashMap<Long, Integer> mMap = new HashMap<>();
        for (long l: ds) {
            int i = nMap.getOrDefault(l, -1);
            if (i == -1)
                nMap.put(l, 1);
            else
                nMap.put(l, i+1);
        }
        for (long l: ts) {
            int i = mMap.getOrDefault(l, -1);
            if (i == -1)
                mMap.put(l, 1);
            else
                mMap.put(l, i+1);
        }
        Iterator<Long> itr = mMap.keySet().iterator();
        boolean flg = true;
        while (itr.hasNext()) {
            long trg = itr.next();
            int cnt = mMap.get(trg);
            int ncnt = nMap.getOrDefault(trg, -1);
            flg &= ncnt >= cnt;
        }
        if (flg)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


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

const int MAX = 100000;

int main() {

    int n;

    cin >> n;

    int x6 = 1;
    int x9 = 1;

    vector<int> dp(n + 1);

    dp[1] = 1;

    for(int i = 2; i <= n; ++i) {

        if(x6 * 6 == i)
            x6 *= 6;
        if(x9 * 9 == i)
            x9 *= 9;

        int a = 1 + dp[i - 1];
        int b = 1 + dp[i - x6];
        int c = 1 + dp[i - x9];

        dp[i] = min(a, min(b, c));
    }

    cout << dp[n] << endl;

    return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mod 1e9+7
#define ll long long
using namespace std;


int main()
{
	
	int n,k;
	cin>>n>>k;
	vector<ll>a;
	for(int i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	vector<ll>dp(k+1,0);
	vector<ll>p(k+1,1);
	dp[0]=1;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(j==0)
			{	
				p[j]=dp[j];
				 // cout<<dp[j]<<" ::"<<p[j]<<":: ";
				continue;
			}
			p[j]=(dp[j]+p[j-1])%(ll)(1e9+7);

			if(j-(a[i]+1)>=0)
				dp[j]=(p[j]-p[j-a[i]-1]+(ll)(1e9+7))%(ll)(1e9+7);
			else
				dp[j]=p[j];


			// cout<<dp[j]<<" ::"<<p[j]<<":: ";

		}
		// cout<<endl;
	}
	cout<<dp[k];	
}

Measured memory_bytes: 4768
#include <iostream>
#include <cstdint>

using namespace std;

int main() {
    
    int64_t x, y;
    
    cin >> x;
    
    y = (x / 11) * 2;
    
    if (x % 11 > 0) {
        if (x % 11 <= 6)
            y += 1;
        else
            y += 2;
    }
    
    cout << y << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

import javax.swing.plaf.synth.SynthSplitPaneUI;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 121008
#include<iostream>

int main()
{
  int n;
  std::cin >> n;
  bool result = false;
  for(auto i = 1;i < 10;++i)
  {
    if(!(n%i))
    {
      if(static_cast<double>(n)/i < 10)
      {
        result = true;break;
      }
    }
  }
  std::cout << (result?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    string st;
    cin>>st;
    long long len = st.size() -1;
    int flag = 0;
    for(int i=1; i<len+1; i++)
    {
        if(st[i]!='9')
        {
            flag = 1;
            break;
        }
    }
    long long ans = st[0]-'0' -1+len*9;
    if(flag == 0)
        ans++;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n.size(); i++)
        sum += n[i] - '0';
    if ( stoi(n) % sum == 0 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
function Main(input) {
input = input.split("\n");
var count =input[0];
const a = count.split(" ")[0];
const b = count.split(" ")[1];
const c = count.split(" ")[2];
const d = count.split(" ")[3];

const result1=Math.max(a,c)
const result2=Math.min(b,d)


const result=b-c-a;
if(result2<result1){
console.log(0);
}else{
    console.log(result2-result1);
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    double a,b,x;cin>>a>>b>>x;
    double S=a*b,s=x/a;
    if(s*2>=S){
        s=S-s;
        CST(10)<<atan(2*s/a/a)*180/M_PI<<endl;
    }
    else{
        CST(10)<<atan(b*b/2/s)*180/M_PI<<endl;
    }
    return 0;
}

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

int main()
{
    int n; cin>>n;
    long t, a; cin>>t>>a;
    while (--n) {
        long x, y; cin>>x>>y;
        if (t<=x && a<=y)
            t=x, a=y;
        else {
            long d=max((t+x-1)/x, (a+y-1)/y);
            t=x*d, a=y*d;
        }
    }
    cout<<a+t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    LL ans = a[0];
    REP(i,1,n/2) ans += a[i] * 2;
    if (n % 2) ans += a[n/2];
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
using namespace std;
 
int main(void){
  int n, i;
  vector<int> t(100001, 0);
  vector<int> x(100001, 0);
  vector<int> y(100001, 0);
 
  cin >> n;
 
  for(i = 1; i <= n; i ++)
    cin >> t.at(i) >> x.at(i) >> y.at(i);
 
  for(i = 1; i <= n; i ++){
    int dist = abs(x.at(i)-x.at(i-1)) + abs(y.at(i)-y.at(i-1));
    int dt = t.at(i)-t.at(i-1);
    if(dist > dt) break;
    if(dist%2 == dt%2) continue;
    else break;
  }
 
  if(i == n+1) cout << "Yes" << endl;
  else cout << "No" << endl;
 
  return 0;
}

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

int main() {
  double N;
  cin >> N;
  string str;
  cin >> str;

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'R') {
      count++;
    }
  }

  if (count > N / 2) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
L = [int(input()), list(map(int, input().split(' '))), list(map(int, input().split(' '))), list(map(int, input().split(' ')))]
print(sum([L[2][L[1][i]-1]+L[3][L[1][i]-2] if i>0 and L[1][i]-L[1][i-1]==1 else L[2][L[1][i]-1] for i in range(L[0])]))

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

void testcase(){
    string s,t;
    cin >> s >> t;
    int ns=s.length();
    int nt=t.length();
    int mx=0;
    for(int i=0;i<ns-nt+1;i++){
        int c=0;
        for(int j=0;j<nt;j++){
            if(s[i+j]==t[j])
                c++;
        }
        mx=max(mx,c);
    }
    cout << nt-mx;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 3560
fun main(args: Array<String>) {
    abc144b()
}

fun abc144b() {
    val n = readLine()!!.toInt()
    val numbers = (1..9).map { i -> (1..9).map { it * i } }.flatten()

    val answer = if (n in numbers) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 33568