akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()

	ans := 0
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n-1)

	for i := 0; i < n; i++ {
		a[i] = scanInt() -1
	}
	for i := 0; i < n; i++ {
		b[i] = scanInt()
	}
	for i := 0; i < n-1; i++ {
		c[i] = scanInt()
	}

	pre := n

	for i := 0; i < n; i++ {
		d := a[i]
		ans+=b[d]
		if pre+1 == d {
			ans+=c[d-1]
		}
		pre = d
		// fmt.Println(ans)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

int h, w, c; 
vector<vector<char>> clear_char(const char ch, const vector<vector<char>> &from) {
    vector<vector<char>> to = from;
    // 横
    for (int i=0; i<h; i++) {
        for (int j=0; j+c-1<w; j++) {
            bool isY = true;
            for (int k=0; k<c; k++) {
                isY &= from[i][j+k] == ch;
            }
            if (isY)
                for (int k=0; k<c; k++) {
                    // cout << "clear: " << to[i][j+k] << endl;
                    to[i][j+k] = '.';
                }
        }
    }

    // 縦
    for (int i=0; i<w; i++) {
        for (int j=0; j+c-1<h; j++) {
            bool isY = true;
            for (int k=0; k<c; k++) {
                isY &= from[j+k][i] == ch;
            }
            if (isY)
                for (int k=0; k<c; k++) {
                    // cout << "clear: " << to[j+k][i] << endl;
                    to[j+k][i] = '.';
                }
        }
    }
    return to;
}

vector<vector<char>> drop(vector<vector<char>> board) {
    for (int x=0; x<w; x++) {
    for (int unusethis=0; unusethis<h; unusethis++) {
            for (int i=h-1; i>=1; i--) {
                if (board[i][x] == '.') {
                    board[i][x] = board[i-1][x];
                    board[i-1][x] = '.';
                }
            }
    }}
    return board;
}

bool can_clear(const vector<vector<char>> &from) {
    vector<vector<char>> to = drop(from);
    for (char c='A'; c<='Z'; c++) to = clear_char(c, to);

    to = drop(to);
    if (from != to) return can_clear(to);
    bool can = true;
    for (auto l: to) for (auto x: l)
        can &= x == '.';
    return can;
}

int main() {
    cin >> h >> w >> c;
    vector<vector<char>> board(h, vector<char>(w));
    for (int y=0; y<h; y++)
        for (int x=0; x<w; x++) {
            cin >> board[y][x];
        }
    bool f = false;
    for (int i=0; i<h; i++)
        for (int l=0; l<w; l++) {
            if (l+1<w) {
                auto b = board;
                char tmp = b[i][l];
                b[i][l]   = b[i][l+1];
                b[i][l+1] = tmp;
                f |= can_clear(b);
            }
        }
    f |= can_clear(board);
    cout << (f ? "YES" : "NO") << endl;
}



Measured memory_bytes: 3236
W, H, N = map(int, input().split())

X = [0, W]
Y = [0, H]

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1 and X[0] < x:
        X[0] = x
    elif a == 2 and x < X[1]:
        X[1] = x
    elif a == 3 and Y[0] < y:
        Y[0] = y
    elif a == 4 and y < Y[1]:
        Y[1] = y
    
if X[1] > X[0] and Y[1] > Y[0]:
    result = (X[1] - X[0]) * (Y[1] - Y[0])
else:
    result = 0

print(result)


Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
const string add = "+", sub = "-", mul = "*", divStr = "/", qus = "?";
int calc(int a, int b, string op) {
	int result;
	if (add == op) {
		result = a + b;
	}
	else if (sub == op) {
		result = a - b;
	}
	else if (mul == op) {
		result = a * b;
	}
	else if (divStr == op) {
		result = a / b;
	}
	return result;
}

void Main() {
	string op;
	int a, b;
	while (true) {
	cin >> a >> op >> b;
		if (qus == op) {
			break;
		}
		cout << calc(a, b, op) << endl;
	}
}
int main() {
	cout << fixed;
	cout << setprecision(6);
	Main();
}


Measured memory_bytes: 3076
N, x = map(int, input().split())
if N == 2:
    if x != N:
        print("No")
        exit(0)
else:
    if abs(N - x) > N - 2:
        print("No")
        exit(0)
print("Yes")

if N == 2:
    for i in range(3):
        print(i+1)
else:
    left = []
    right = []
    if x < 2 * N - 2:
        ans = [x+2, x-1, x, x+1]
        s = [i for i in range(1, 2*N) if i < x - 1 or i > x+2]
        for i in range((2*N - 5) // 2):
            print(s.pop())
        for i in range(4):
            print(ans[i])
        for i in range(((2*N - 5) // 2) + 1):
            print(s.pop())

    else:
        ans = [x-2, x+1, x, x-1]
        s = [i for i in range(1, 2*N) if i < x - 2 or i > x+1]
        for i in range((2*N - 5) // 2):
            print(s.pop())
        for i in range(4):
            print(ans[i])
        for i in range(((2*N - 5) // 2) + 1):
            print(s.pop())



Measured memory_bytes: 11216
n = int(input())
a = list(map(int, input().split()))
# 4の倍数と2の倍数を数える
four = 0
two = 0
ele = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0 and a[i] % 4 != 0:
        two += 1
    else:
        ele += 1

"""
ele += two % 2
two = two//2
print(two, end=" ")
print(four, end=" ele=")
print(ele)
if ele <= (two+four) or (ele-(four+two) == 1):
    print("Yes")
else:
    print("No")
"""
if ele <= four:
    print("Yes")
elif ele-four == 1 and two == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 15020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
	return 0;
} 

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


void solve(long long N, long long K, std::vector<long long> H){
  sort(H.begin(), H.end());

  long long acc = 0;
  for(int i = 0; i < (N - min(N, K)); i++){
    acc += H[i];
  }

  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  ll a, b, c;
  scanf("%lld %lld.%lld", &a, &b, &c);
  b *= 100LL;
  b += c;
  a *= b;
  a /= 100;
  cout << a << endl;

  return 0;
}

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

int N,M;
int p[333][333];
int pnt[333];
bool invalid[333];
int c[333];
bool ok(int x){
	memset(invalid,0,sizeof(invalid));
	for(int i=1; i<=N; i++)pnt[i] = 1;

	while(1){
		bool flag = false;
		memset(c,0,sizeof(c));
		for(int i=1; i<=N; i++){
			while(pnt[i] <= M && invalid[p[i][pnt[i]]])pnt[i] ++;
			if(pnt[i] > M)return false;
			c[p[i][pnt[i]]] ++;
		}
		for(int i=1; i<=M; i++)
			if(c[i] > x){
				invalid[i] = true;
				flag = true;
			}
		if(!flag)return true;
	}
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1; i<=N; i++)
		for(int j=1; j<=M; j++)
			scanf("%d",&p[i][j]);
	int lo = 1, hi = N;
	while(lo != hi){
		int mi = (lo + hi)/2;
		if(ok(mi))
			hi = mi;
		else
			lo = mi+1;
	}
	printf("%d\n",lo);
	return 0;
}


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

constexpr int MOD = 1e9 + 7;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    long long N, K; cin >> N >> K;
    vector<long long> counts(K+1);
    for (int i = 1; i <= K; i++) {
        int t = K / i;
        counts[i] = modpow(t, N);
    }
    for (int i = K; 1 <= i; i--) {
        for (int j = K / i; 2 <= j; j--) {
            counts[i] -= counts[i*j];
            counts[i] = (counts[i] + MOD) % MOD;
        }
    }
    long long ans = 0;
    for (int i = 1; i <= K; i++) {
        ans += counts[i] * i;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.bisect_k = 1 << (N.bit_length() - 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        k = self.bisect_k
        while k > 0:
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
            k //= 2
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
B = [memo[a] for a in A]
M = len(memo) + 10

bit = BIT(M)
for b in B:
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


Measured memory_bytes: 24988
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long

ll MOD=1e9+7;
ll a[100005];
using namespace std;

int main(){
	ll n;
	cin>>n;
	
	ll flag=1; 
	ll ans=1;
	
	if(n%2==0){ 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			if(x>=n || x%2==0 || a[x]>2){ 
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			if(a[x]==1)
				ans=ans*2%MOD;
		}
	} 
	
	else{
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			if(x!=0 && a[x]==1)
				ans=ans*2%MOD;
		}
	}
	
	if(flag)
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

import numpy as np
from numba import i8, njit

#AOTにするとさらに早くなる?
@njit(i8(i8, i8[:]), cache=True)
def binary_search(n, a):
    right = np.max(a) + 10 ** 9
    left = np.min(a) - 10 ** 9

    def calc(b):
        score = 0
        for i in range(n):
            score += abs(a[i] - (b + i + 1))
        return score

    while right - left > 1:
        middle = (right + left) // 2
        if calc(middle) < calc(middle+1):
            right = middle
        else:
            left = middle
    
    return calc(right)

def Main():
    n = read_int()
    a = np.array(read_int_list(), dtype=np.int64)
    
    print(binary_search(n, a))

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 128400
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <tgmath.h>
#define MOD 1000000007
using namespace std;

#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
string S;
int main(){
    cin >> S;
    int len = S.length();
    int mem = INT_MAX;
    bool check = false;
    rep(i,len-1){
        if(S[i]!=S[i+1]){
            mem = min(mem,max(i+1,len-(i+1)));
            check = true;
        }
    }
    if(!check)mem = len;
    cout << mem << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int hoge_rows(vector<string> &vec, vector<vector<int>> &rows, int h, int w,
              int pos_h, int pos_w = 0, int cnt = 0) {
  if (pos_w == w) {
    return cnt;
  } else if (vec[pos_h][pos_w] == '.') {
    return rows[pos_h][pos_w] =
               hoge_rows(vec, rows, h, w, pos_h, pos_w + 1, cnt + 1);
  } else {
    rows[pos_h][pos_w] = 0;
    hoge_rows(vec, rows, h, w, pos_h, pos_w + 1, 0);
    return cnt;
  }
}

int hoge_cols(vector<string> &vec, vector<vector<int>> &cols, int h, int w,
              int pos_h, int pos_w, int cnt = 0) {
  if (pos_h == h) {
    return cnt;
  } else if (vec[pos_h][pos_w] == '.') {
    return cols[pos_h][pos_w] =
               hoge_cols(vec, cols, h, w, pos_h + 1, pos_w, cnt + 1);
  } else {
    cols[pos_h][pos_w] = 0;
    hoge_cols(vec, cols, h, w, pos_h + 1, pos_w, 0);
    return cnt;
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  for (auto &v : vec)
    cin >> v;

  vector<vector<int>> rows(h, vector<int>(w, 0));
  vector<vector<int>> cols(h, vector<int>(w, 0));
  for (int i = 0; i < h; ++i)
    hoge_rows(vec, rows, h, w, i);
  for (int i = 0; i < w; ++i)
    hoge_cols(vec, cols, h, w, 0, i);

  int vmax = 0;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      vmax = max(vmax, cols[i][j] + rows[i][j] - 1);

  cout << vmax << endl;
}

Measured memory_bytes: 42268
using System;

class Atcoder96
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        if (n % 2 == 0)
            Console.WriteLine((n / 2) * (n / 2));
        else
            Console.WriteLine(((n - 1) / 2) * ((n + 1) / 2));
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
map<int,vector<int> > ma;
bool cans[505];
bool can[505][505];
int a[505][505];
int main(){
    int n,m,q;
    scanf("%d %d %d",&n,&m,&q);
    //cin>>n>>m>>q;
    int t1,t2;
    for(int i=0;i<m;i++){
        scanf("%d %d",&t1,&t2);
        ma[t1].push_back(t2);
    }
    for(map<int,vector<int> >::iterator it=ma.begin();it!=ma.end();++it)
        sort(it->second.begin(),it->second.end());

    for(int i=0;i<q;i++){
        scanf("%d %d",&t1,&t2);
        int sum=0;
        if(can[t1][t2])
            sum=a[t1][t2];
        else{
            for(int k=t1;k<=t2;k++){
                //int l=ma[k].size();
                if(!cans[k]){
                    sort(ma[k].begin(),ma[k].end());
                    cans[k]=1;
                }
                vector<int>::iterator up=upper_bound (ma[k].begin(), ma[k].end(), t2);
                sum+=(up- ma[k].begin());
            }
            a[t1][t2]=sum;
            can[t1][t2]=1;
        }

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

    }
}

Measured memory_bytes: 3328
/*
[abc139] C - Lower
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;
const int INF = 1e9 + 1;

int N;
int H[MAX_N + 1];

ll solve() {
    H[N] = INF;
    int ans = 0;
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (H[i - 1] >= H[i]) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    cout << solve() << endl;

    return 0;
}


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

bool cmp(int x,int y)
{

    return x>y;
}
ll a[300000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {

        cin>>a[i];
    }
    if(k>=n)
    {

        cout<<0<<'\n';
        return 0;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
    {

        if(k!=0)
        {

            k--;

        }
        else
        {

            ans+=a[i];
        }
    }
    cout<<ans<<'\n';


}
















Measured memory_bytes: 1792
require 'date'

S = gets.chomp
first = S.slice(0..1)
last = S.slice(2..3)

date = '01'

# first - last
begin
  Date.parse("#{first}-#{last}-#{date}")
  f_l = true
rescue ArgumentError
  f_l = false
end


# last - first
begin
  Date.parse("#{last}-#{first}-#{date}")
  l_f = true
rescue ArgumentError
  l_f = false
end

if f_l && l_f
  puts 'AMBIGUOUS'
elsif f_l && !l_f
  puts 'YYMM'
elsif !f_l && l_f
  puts 'MMYY'
else
  puts 'NA'
end


Measured memory_bytes: 2168
#include <stdio.h>
#include <iostream>

using namespace std;

#define N 8

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initialize() {
	for(int i=0;i<N;i++) {
		row[i]=col[i]=0;
	}
	for(int i=0;i<2*N-1;i++) {
		dpos[i]=dneg[i]=0;
	}
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			X[i][j]=0;
		}
	}
}

void printBoard() {
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			if(X[i][j]) {
				if(row[i]!=j) return;
			}
		}
	}
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			if(row[i]==j) printf("Q");
			else printf(".");
		}
		printf("\n");
	}
}

void recursive(int i) {
	if(i==N) {
		printBoard(); return;
	}
	for(int j=0;j<N;j++) {
		if(col[j]==1 || dpos[i+j]==1 || dneg[i-j+N-1]==1) continue;
		row[i]=j;
		col[j]=dpos[i+j]=dneg[i-j+N-1]=1;
		recursive(i+1);
		row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=0;
	}
}

int main() {
	initialize();
	
	int k;
	
	scanf("%d",&k);
	
	while(k>0) {
		int r,c;
		scanf("%d %d",&r,&c);
		X[r][c]=1;
		k--;
	}
	
	recursive(0);
	
	return 0;
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(i64, x);
  i64 norm = x / 11 * 2;
  i64 mod = x % 11;

  if (mod == 0) OUTL(norm);
  else if (mod <= 6) OUTL(norm + 1);
  else OUTL(norm + 2);

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Select(v => int.Parse(v)).Aggregate((n, m) => (n == 2 || m == 2 ? 2 : 0) + (n == 4 || n == 6 || n == 9 || n == 11 ? 1 : 0) + (m == 4 || m == 6 || m == 9 || m == 11 ? -1 : 0)) == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs first
#define sc second




int c[200005];

int main() {
	int n, m;

	cin >> n >> m;
	FILL0(c);

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		if (min(a, b) == 1) c[max(a, b)]++;
		if (max(a, b) == n) c[min(a, b)]++;
	}
	reP(i, n) {
		if (i == n) {
			puts("IMPOSSIBLE");
			break;
		}
		if (c[i + 1] == 2) {
			puts("POSSIBLE");
			break;
		}
	}

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005];
int main()
{
	ll n,i,j,k;
	cin >> n >> k;
	ll a[n];
	for(i=0;i<n;i++)
		cin >> a[i];
		
	dp[1]=dp[0]+abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		ll cnt=0;
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(j=i-1;j>=0;j--)
		{
			if(cnt==k)
				break;
				
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
			cnt++;
		}
	}
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <cstdio>
#include <cctype>
#include <cassert>
using namespace std;
inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifdef _dfcmydd
#define dd c = getchar()
#else
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	x = 0;
	char dd;
	bool flg = false;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if (c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}
int n,l,r;
int a[510000];
int pd(int num){
	if(a[n]<=num && (a[n-1]<=num || a[n+1]<=num))
		return 1;
	if(a[n]>num && (a[n-1]>num || a[n+1]>num))
		return 0;
	for(int i=1;i<n-1;i++){
		if((a[n+1+i]<=num && a[n+i]<=num) || (a[n-i-1]<=num && a[n-i]<=num))
			return 1;
		if((a[n+1+i]>num && a[n+i]>num) || (a[n-i-1]>num && a[n-i]>num))
			return 0;
	}
	return a[1]<=num;
}
int main() {
//	freopen("pyramid.in", "r", stdin);
//	freopen("pyramid.out", "w", stdout);
	read(n);
	for(int i=1;i<=n*2-1;i++)
		read(a[i]);
	l=1,r=n*2-1;
	while(l<r){
		int mid=(l+r)>>1;
		if(pd(mid))
			r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}

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

int main()
{
    long long int S, i, j, div;
    div = 1;
    cin >> S;
    if (S == 1 || S == 2)
    {
        cout << 0 << endl;
    }
    else if (S == 3 || S == 4 || S == 5)
    {
        cout << 1 << endl;
    }
    else
    {
        vector<long long int> a(S + 1);
        a[1] = 0;
        a[2] = 0;
        a[3] = 1;
        a[4] = 1;
        a[5] = 1;
        for (i = 0; i < 9; i++)
        {
            div *= 10;
        }
        div += 7;
        for (i = 6; i < S + 1; i++)
        {
            a[i] = 1;
            for (j = 3; j < i - 2; j++)
            {
                a[i] += a[j];
                a[i] = a[i] % div;
            }
        }
        cout << a[S] << endl;
    }
    return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int main(){
	std::set<std::string> kei;
	int n;
	cin >> n;
	RC(i, n){
		std::string s;
		cin >> s;
		kei.insert(s);
	}
	cout << kei.size() << endl;
}


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<uint64_t> a(n);
  rep(i, n) std::cin >> a[i];

  int i = 0;
  bool ok = true;
  while (ok) {
    rep(i, n) {
      if (a[i] % 2 != 0) {
        ok = false;
        break;
      }
      a[i] /= 2;
    }
    i++;
  }

  std::cout << i - 1 << std::endl;
  return 0;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <vector>
#include <iostream>
#include <cmath>
#include <set>
#include <string>
using namespace std;



int main()
{
  string st;
  cin >> st;
  if (st.length()%2==0)
  {
    for (int i = 0; i < st.length(); i++)
    {
      if (i % 2 == 0 && st[i] == 'h')
      {
      }
      else if (i % 2 == 1 && st[i] == 'i')
      {
      }
      else
      {
        cout << "No" << endl;
        break;
      }
      if (i + 1 == st.length())
        cout << "Yes" << endl;
    }
  }
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  val balls = readLine.trim.split(' ').map(_.toInt)
  val odd = balls.count(_ % 2 == 1)
  val even = balls.count(_ % 2 == 0)
  if (odd == 0 || even == 0){
    println(0)
  }else {
    if (odd % 2 == 0) {
      println(n - 2)
    }else {
      println(n - 1)
    }
  }
}


Measured memory_bytes: 85032
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] T = new int[N];
		for(int i = 0;i < N;i++)
		{
			T[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i = 0;i < M;i++)
		{
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i = 0;i < N;i++)
		{
			sum += T[i];
		}
		for(int i = 0; i < M;i++)
		{
			int y = P[i];
			int num = sum - T[y - 1];
			int ans = num + X[i];
			System.out.println(ans);
		}
	}

}


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

int main()
{
    int numa, numb, numc;
    cin >> numa >> numb >> numc;
    vector<int> v;
    for(int i=1;i<=numb;i++){
        v.push_back((numa*i)%numb);
    }
    for(int i=0;i<numb;i++){
        if(v[i]==numc){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc068/tasks/arc079_b
# 重要な考察
# すべての要素がNを超えているとき、N回操作するすべての要素は-1される。
# つまりN*(K//N)回操作されたときに、すべての要素はN+K//N-1(=base)になってほしい
# 残りのK%N回の操作でこの数列がどう変化するかは愚直にシミュレーションしてもいいし、計算しても求まる

ra = range
enu = enumerate
K = int(input())
N = 50

base = N + K // N - 1
n_operate = K % N

ans = []
# はじめのK%N要素はbase-K%N-1となる
for _ in ra(K % N):
    ans.append(base + N - K % N + 1)

for _ in ra(N - K % N):
    ans.append(base - K % N)
print(N)
print(*ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//s(std::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	VL arr(n),tmp;
	fr(i,0,n)
		rl(arr[i]);
	tmp=arr;
	sort(ALL(tmp));
	ll ct=0;
	fr(i,0,n)
	{
		if(arr[i]!=tmp[i])
			ct++;
	}
	if(ct<=2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  vector<pii> A_pair(N);
  int ptr = 0;
  for (auto a : A) {
    A_pair[ptr] = make_pair(a.first, a.second);
    ptr++;
  }
  sort(rall(A_pair));
  ll a = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if (a == 0) {
      if (A_pair[i].second > 1 && A_pair[i].second < 4) {
        a = A_pair[i].first;
      } else if (A_pair[i].second >= 4) {
        a = A_pair[i].first;
        b = A_pair[i].first;
      }
    } else if (A_pair[i].second > 1 && b == 0) {
      b = A_pair[i].first;
    }
  }
  cout << a * b << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 5760
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,x = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))+[0]
    ans=0
    for i in range(N):
        eated = max(0,a[i]+a[i-1]-x)
        ans += eated
        a[i]-=eated
    print(ans)

Measured memory_bytes: 16292
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long V[50];
int main(void){
  int N;
  int K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  long long ans = LLONG_MIN;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N; j++){
      if(i + j > N || i + j > K){
        break;
      }
      int put_back = K - i - j;
      long long tmp_ans = 0;
      vector <long long> negs;
      for(int k = 0; k < i; k++){
        tmp_ans += V[k];
        if(V[k] < 0){
          negs.push_back(V[k]);
        }
      }
      for(int k = 0; k < j; k++){
        tmp_ans += V[N - 1 - k];
        if(V[N - 1 - k] < 0){
          negs.push_back(V[N - 1 - k]);
        }
      }
      sort(negs.begin(), negs.end());
      for(int k = 0; k < min((int)negs.size(), put_back); k++){
        tmp_ans -= negs[k];
      }

      ans = max(ans, tmp_ans);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	string s;
	cin >> s;
	if(s[2]==s[3]&&s[4]==s[5]){
		puts("Yes");
			return;
	}
	puts("No");
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;


int main(){
    IOS
    ll n, sum = 0 , maxsum = 0 ; 
    cin>>n;
    map<string,int> m;
    std::vector<string> s(n ,"");
    f(0,n){cin>>s[i]; m[s[i]] += 1;}
    for(auto x : m){
        sum = x.second;
        if(sum>maxsum) maxsum = sum;
    }
    
    for(auto i = m.begin();i!=m.end() ;i++){
        if(i->second == maxsum) cout<<i->first<<endl;
    }
    return 0;
}

Measured memory_bytes: 25472
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	FASTIO
	int x, n;

	cin >> x >> n;

	unordered_map <int, bool> mp;
	vector <int> v(n);
	for(int i = 0; i < n; i ++)
	{
		cin >> v[i];
		mp[v[i]] = true;
	}

	int val = 0;
	while(true)
	{
		int negVal = x - val;
		int posVal = x + val;
		if(mp[negVal] == false)
		{
			cout << negVal << endl;
			break;
		}
		else if(mp[posVal] == false)
		{
			cout << posVal << endl;
			break;
		}
		val += 1;
	}
}

Measured memory_bytes: 3660
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int n,k;cin>>n>>k;
	vector<int> a(n);
	for(int &i:a)cin>>i;
	int sum=accumulate(a.begin(),a.end(),0LL);
	set<int>s;
	for(int i=1;i*i<=sum;i++)if(sum%i==0){s.insert(sum/i);s.insert(i);}
	int ans=1;
	for(int x:s)
	{
		int need=0;
		vector<int> r(n);
		for(int i=0;i<n;i++)r[i]=a[i]%x;
		sort(r.begin(),r.end());
		int tot=accumulate(r.begin(),r.end(),0LL);
		int l=n-tot/x;
		need=accumulate(r.begin(),r.begin()+l,0LL);
		if(need<=k)ans=max(ans,x);
	}
	cout<<ans;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(a) cout << a << ": "
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
int fpow(int x, int y, int m) {
    int r = 1;
    while(y > 0) {
        if(y & 1) r = (r * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return r;
}
void sliczny() {
    int n, res;
    int ans1 = 0, ans2 = 0;
    int m = 0;
    string s;
    cin >> n;
    cin >> s;
    for(int i=0; i<n; i++) {
        if(s[i] == '1') {
            m++;
        }
    }
    
    int m1 = m - 1;
    int m2 = m + 1;
    for(int i=0; i<n; i++) {
        if(s[i] == '1') {
            if(m1 > 0) {
                int k1 = fpow(2, n - i - 1, m1);
                ans1 = (ans1 % m1 + k1 % m1) % m1;
            }
            int k2 = fpow(2, n - i - 1, m2);
            ans2 = (ans2 % m2 + k2 % m2) % m2;
        }
    }
    for(int i=0; i<n; i++) {
        int answ = 1;
        if(s[i] == '1') {
            if(m1 == 0) { answ = 0; res = 0; }
            else {
                res = (ans1 - fpow(2, n - i - 1, m1)) % m1;
                if(res < 0) res += m1;
            }
        }
        else {
            res = (ans2 + fpow(2, n - i - 1, m2)) % m2;
        }
        while(res != 0) {
            int h = __builtin_popcount(res);
            res %= h;
            answ++;
        }
        cout << answ << '\n';
        //cout << res << '\n';
        
    }
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
  //cin >> T; 
    for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
        sliczny();
    }
  return 0;
}


Measured memory_bytes: 3780
#include<iostream>

using namespace std;

int main() {

	int A, B, C;

	cin >> A >> B >> C;

	if ((A == B && A != C) || (B == C && B != A) || (C == A && C != B)) {
		cout << "Yes";
		return 0;
	}

	cout << "No";
	return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    vector<ll> nums(n + 1, 0);
    map<ll, ll> cnt;
    ++ cnt[0];
    rep(i, n){
        ll num;
        cin >> num;
        nums[i + 1] = num + nums[i];
        ++ cnt[nums[i + 1]];
    }

    ll ans = 0;
    for(auto itr = cnt.begin(); itr != cnt.end(); ++ itr){
        if(itr->second > 1){
            ans += (itr->second * (itr->second - 1)) / 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <stdlib.h>


int a,b,c,d;

int main(){
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(abs(c-a) <= d || (abs(a-b) <= d && abs(c-b) <= d))
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());
    ll ans = 0;
    rep(i, n) {
        if (i >= k)
            ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


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

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

  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }

  int M;
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }

  int score = 0;
  for (int i = 0; i < N; i++) {
    int tmp_score = 0;
    string declear = s.at(i);
    for (int j = 0; j < N; j++) {
      if (declear == s.at(j)) {
        tmp_score++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (declear == t.at(j)) {
        tmp_score--;
      }
    }
    if (tmp_score > score) {
      score = tmp_score;
    }
  }

  cout << score << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    REP(i, 3) {
        if (s[i] == 'S') {
            cnt = 0;
        } else {
            ++cnt;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3628