akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

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

int dp[1<<10][331];

int main(){
  int n,s,comb,x,y;
  while(~scanf("%d%d",&n,&s)){
    memset(dp,0,sizeof(dp));
    if( s>330 ){
      puts("0");
      continue;
    }
    rep(k,10)dp[1<<k][k] = 1;

    REP(i,1,n){
      comb = (1<<i)-1;
      while( comb < 1<<10 ){
	rep(j,s+1)if( dp[comb][j] ){
	  rep(k,10)if( !(comb&(1<<k)) ){
	    if( j+(i+1)*k>s )break;
	    dp[comb|(1<<k)][j+(i+1)*k] += dp[comb][j];
	  }
	}
	x = comb & -comb;
	y = comb + x;
	comb = ((comb&~y)/x>>1)|y;
      }
    }

    int ans = 0;
    comb = (1<<n)-1;
    while( comb < 1<<10 ){
      ans += dp[comb][s];
      x = comb & -comb;
      y = comb + x;
      comb = ((comb & ~y)/x>>1)|y;
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

int main() {
	vector<int> v;
	int n; cin >> n;

	for (int i = 0; i < n; i++) {
		int z; cin >> z;
		v.push_back(z - 1);
	}

	int now = 0, count = 0;
	for (;;) {
		if (now == 1) {
			cout << count << endl;
			break;
		}
		if (count > n) {
			cout << -1 << endl;
			break;
		}
		count++;
		now = v[now];
	}

	return 0;
}

Measured memory_bytes: 1020
l, r = list(map(int, input().split(' ')))
mod = 2019
s1 = l % mod
rem = mod - s1
ans = -1
# print(l + rem)
if l + rem > r:
    maxi = r
    lowe = l
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mini = ((i%mod) * (j%mod)) % mod
            if mini < ans or ans == -1:
                ans = mini
    print(ans)
    # print(((l%mod) * (l+1%mod)) % mod) 
else:
    print(0)



Measured memory_bytes: 41964
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

char a[7][7];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int res = 0;
	for (int mn = 0 ; mn < (1 << n); mn++) {
		for (int mm = 0; mm < (1 << m); mm++) {
			int cur = 0;
			for (int i = 0; i < n; i++) {
				if (mn & (1 << i))
					continue;
				for (int j = 0; j < m; j++) {
					if (mm & (1 << j))
						continue;
					if (a[i][j] == '#')
						cur++;
				}
			}
			if (cur == k)
				res++;
		}
	}
	cout << res << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(100005), b(100005);
    int init_a = 0;
    int init_b = 0;
    int mx_a, mx_b;
    rep(i,n) {
        if (i%2 == 0) {
            int x;
            cin >> x;
            a[x]++;
            if (a[x] > init_a) {
                init_a = a[x];
                mx_a = x;
            }
        }
        else {
            int x;
            cin >> x;
            b[x]++;
            if (b[x] > init_b) {
                init_b = b[x];
                mx_b = x;
            }
        }
    }
    if (mx_a != mx_b) cout << n - a[mx_a] - b[mx_b] << endl;
    else {
        sort(a.rbegin(),a.rend());
        sort(b.rbegin(),b.rend());
        int ans = 1e9;
        ans = min(ans,n-a[1]-b[0]);
        ans = min(ans,n-a[0]-b[1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
char N_[9],W_[20];
main()
{
	read(0,N_,9);
	int N=0;
	for(int i=0;N_[i]>='0';i++)N=N*10+N_[i]-'0';
	long ans=0;
	int i=1;
	while(i<=N)
	{
		long j=N/(N/i)+1;
		ans+=(j-i)*(i+j-1)*(N/i)*(N/i+1)/4;
		i=j;
	}
	i=20;
	do{W_[--i]=ans%10+'0';}while(ans/=10);
	write(1,W_+i,20-i);
}

Measured memory_bytes: 1392
text = gets.chomp!

L_alpha = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
S_alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

L_alpha.each do |t|
  if text == t
    puts "A"
  end
end

S_alpha.each do |t|
  if text == t
    puts "a"
  end
end



Measured memory_bytes: 14096
n = int(input())
x = 1
y = ""
z = 1
while True:
    z = 1
    x += 1
    if x % 3 == 0:
        y += " "
        y += str(x)
    else:
        while True:
            b = int(x % 10 ** (z - 1))
            a = int((x - b) / 10 ** z)
            c = a % 10 ** z
            d = a % 10 ** (z - 1)
            if a == 3 or b == 3 or c == 3 or d == 3:
                y += " "
                y += str(x)
                break
            z += 1
            if a < 3 and z > 3:
                break
    if x >= n:
        break
print(y)


Measured memory_bytes: 5624
const main = function(input){
  var nums = input.split(" ").map(i => parseInt(i));
  var add = nums[0]+nums[1];
  var sub = nums[0]-nums[1];
  var mul = nums[0]*nums[1];
  
  var ans = Math.max(add,sub,mul) + 0;
  
  console.log(ans);
  
}


main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Measured memory_bytes: 7372
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def Fac(n):
    if n == 1:
        return 1
    else:
        return n * Fac(n-1)

def answer(P):
    l = list(range(1, len(P)+1))
    ans = 0
    for pi in P:
        if len(l) <= 2:
            ans += sum([i<pi for i in l])+1
            break
        else:
            ans += sum([i<pi for i in l]) * Fac(len(l)-1)
            l.remove(pi)
    return ans

print(abs(answer(P)-answer(Q)))

Measured memory_bytes: 3188
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, K = getNM()
query = [getList() for i in range(N)]

# x軸, y軸を作る
x_axis = set()
y_axis = set()
for i in query:
    x_axis.add(i[0])
    y_axis.add(i[1])
x_axis = sorted(list(x_axis))
y_axis = sorted(list(y_axis))

# 経路圧縮
dp = [[0] * len(x_axis) for i in range(len(y_axis))]
for i in query:
    x = x_axis.index(i[0])
    y = y_axis.index(i[1])
    dp[y][x] += 1

dp_n = [[0] * len(x_axis) for i in range(len(y_axis))]

# 累積和
def bi_cumul_sum(dp_n, dp_bef, h, w):
    # 縦１行目、横１行目
    for i in range(h):
        dp_n[i][0] = dp_bef[i][0]
    for i in range(h):
        for j in range(1, w):
            dp_n[i][j] = dp_n[i][j - 1] + dp_bef[i][j]
    # 全て
    for i in range(1, h):
        for j in range(w):
            dp_n[i][j] += dp_n[i - 1][j]

bi_cumul_sum(dp_n, dp, len(y_axis), len(x_axis))

# 範囲内に含まれる点の数を計算する
def judge(sx, ex, sy, ey, dp):
    mother = dp[ey][ex]
    minus1 = 0
    minus2 = 0
    plus = 0
    if sx > 0:
        minus1 = dp[ey][sx - 1]
    if sy > 0:
        minus2 = dp[sy - 1][ex]
    if sx > 0 and sy > 0:
        plus = dp[sy - 1][sx - 1]
    return mother - minus1 - minus2 + plus

ans = float('inf')
for sy in range(len(y_axis)):
    for ey in range(sy, len(y_axis)):
        for sx in range(len(x_axis)):
            for ex in range(sx, len(x_axis)):
                if judge(sx, ex, sy, ey, dp_n) >= K:
                    opt = (x_axis[ex] - x_axis[sx]) * (y_axis[ey] - y_axis[sy])
                    ans = min(ans, opt)
print(ans)

Measured memory_bytes: 85620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N; cin >> N;
    vector<string> W;
    rep(i, N) {
        string str; cin >> str;
        W.push_back(str);
    }
    string ans = "Yes";
    
    ll wsize = W.size();
    
    vector<string> Wcopy;
    Wcopy = W;
    sort(all(Wcopy));
    Wcopy.erase(unique(all(Wcopy)), Wcopy.end());
    ll wcopysize = Wcopy.size();
    
    if(wsize != wcopysize){
        ans = "No";
        cout << ans << ln;
        return 0;
    }

    rep(i, N-1){
        reverse(all(W[i]));
        if(W[i][0] != W[i+1][0]){
            ans = "No";
            break;
        }
    }
    
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
def bubblesort(c,n)
  0.upto(n-1){|i|
    (n-1).downto(i+1){|j|
      c[j],c[j-1]=c[j-1],c[j] if c[j].value<c[j-1].value
    }
  }
end
def selectionSort(c,n)
  0.upto(n-1){|i|
    minj=i
    i.upto(n-1){|j|
      if c[j].value < c[minj].value
        minj = j
      end
    }
    temp=c[i]
    c[i]=c[minj]
    c[minj]=temp
  }
end

class Card
  attr_accessor :value,:mark
  def initialize(v,m)

    @value=v
    @mark=m
  end
  def getcard
  end
end

n=gets.to_i
cs=gets.split
cards=[]
cs.each{|c|
  cards<<Card.new(c[1],c[0])
}
bub=cards.dup
bubblesort(bub,n)

sel=cards.dup
selectionSort(sel,n)

bub.each_with_index{|bu,i|
  print "#{bu.mark}#{bu.value} " if i!=bub.size-1
  print "#{bu.mark}#{bu.value}" if i==bub.size-1
}
print "\n"

puts "Stable"

sel.each_with_index{|se,i|
  print "#{se.mark}#{se.value} " if i!=bub.size-1
  print "#{se.mark}#{se.value}" if i==bub.size-1
}
print "\n"
flag=false
sel.each_with_index{|se,i|
  if sel[i].mark != bub[i].mark
    flag=true
    break
  end
}
puts flag ? "Not stable" : "Stable"


Measured memory_bytes: 6868
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)

ll d[40][40];
ll a[9];
double ss[520][40];

int main(){
	int n,m,s,t;
	while(scanf("%d%*d%d%d%d",&n,&m,&s,&t),n){
		rep(i,0,n)scanf("%lld",a+i);
		rep(i,1,31)rep(j,1,31)d[i][j]=(i==j?0:INF);
		rep(_,0,m){
			ll x,y,z;
			scanf("%d%d%d",&x,&y,&z);
			d[x][y]=d[y][x]=z;
		}
		rep(k,0,1<<n)rep(i,1,31)ss[k][i]=INF;
		ss[0][s]=0;
		rep(k,0,1<<n)rep(i,1,31)if(ss[k][i]!=INF){
			rep(j,1,31)if(d[i][j]!=INF)rep(b,0,n)if(!bit(k,b)){
				ss[k|1<<b][j]=min(ss[k|1<<b][j],ss[k][i]+(double)d[i][j]/a[b]);
			}
		}
		double ans=INF;
		rep(k,0,1<<n)ans=min(ans,ss[k][t]);
		if(ans>1e9)puts("Impossible");
		else printf("%.9f\n",ans);
	}
}


Measured memory_bytes: 1992
#include <iostream>                            
#include <math.h>                              
#include <string>                              
#include <climits>                             
                                               
using namespace std;                           
int main(void){                                
  string s;                                    
  cin >> s;                                    
  int a = 753,min = INT_MAX,hikaku;            
  for(int i = 0; i < s.size()-2;++i){          
    hikaku = abs(stoi(s.substr(i,3))-a);       
    if(min > hikaku) min = hikaku;             
  }                                            
  cout << min << endl;                         
  return 0;                                    
}                                              
                                               

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(N);
  vector<int> B(M);
  vector<long long> sumA(N + 1);
  vector<long long> sumB(M + 1);
  sumA[0] = 0;
  sumB[0] = 0;
  rep(i, N)
  {
    cin >> A[i];
    sumA[i + 1] = sumA[i] + A[i];
  }
  rep(i, M)
  {
    cin >> B[i];
    sumB[i + 1] = sumB[i] + B[i];
  }

  int mx = 0;
  int a = 0;
  int b = 0;
  while (a < N)
  {
    if (sumA[a + 1] > K)
      break;
    a++;
  }

  K -= sumA[a];
  mx = a;
  while (b < M)
  {
    if (sumB[b + 1] <= K)
    {
      b++;
      mx = std::max(mx, a + b);
      continue;
    }
    else if (a > 0)
    {
      K += A[a - 1];
      a--;
      continue;
    }
    else
    {
      break;
    }
  }

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 8004
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif*/
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define GRAYCODE(i) ((i) ^ ((i) >> 1))

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




struct Point{
    double x, y;
    Point(): x(0), y(0){};
    Point(double X, double Y): x(X), y(Y){};
};


void koch(int n, Point s, Point g){
    if(!n) return;
    double angle = M_PI * 60.0 / 180;
    // s -> p -> q -> r -> g
    Point p, q, r;
    p.x = (2*s.x + g.x) / 3;
    p.y = (2*s.y + g.y) / 3;
    r.x = (s.x + 2*g.x) / 3;
    r.y = (s.y + 2*g.y) / 3;
    q.x = (r.x - p.x)*cos(angle) - (r.y - p.y)*sin(angle) + p.x;
    q.y = (r.x - p.x)*sin(angle) + (r.y - p.y)*cos(angle) + p.y;

    koch(n-1, s, p);
    cout << fixed << setprecision(8) << p.x << " " << p.y << "\n";
    koch(n-1, p, q);
    cout << fixed << setprecision(8) << q.x << " " << q.y << "\n";
    koch(n-1, q, r);
    cout << fixed << setprecision(8) << r.x << " " << r.y << "\n";
    koch(n-1, r, g);
    return;
}

int main(){
    Point a(0, 0), b(100, 0);
    int n; cin >> n;
    cout << fixed << setprecision(8) << a.x << " " << a.y << "\n";
    koch(n, a, b);
    cout << fixed << setprecision(8) << b.x << " " << b.y << "\n";
    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;



int main() {
	int n, l;
	while (cin >> n >> l && !(n==0 &&l==0)) {
		vi v(1e7, -1);
		v[n] = 0;
		for (int i = 1; i <= 100; i++) {
			stringstream ss;
			ss << setw(l) << setfill('0') << n;
			string s, t;
			s = ss.str();
			sort(all(s));
			t = s;
			reverse(all(t));
			n = atoi(t.c_str()) - atoi(s.c_str());
			if (v[n] >= 0) {
				cout << v[n] << " " << n << " " << i - v[n] << endl;
				break;
			}
			v[n] = i;
		}
	}
}

Measured memory_bytes: 40176
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

char ch[N];
int Cnt[N], n;

int main() {
    scanf("%s", ch + 1);
    n = strlen(ch + 1);
    int lstL, lstR;
    lstL = 0;
    rep (i, 1, n - 1) {
        if (ch[i] == 'R' && ch[i + 1] == 'L') {
            int res = i - lstL;
            Cnt[i] += (res + 1) / 2;
            Cnt[i + 1] += res / 2;
        } else if (ch[i] == 'L') lstL = i;
    }
    lstR = n + 1;
    dep (i, n, 2) {
        if (ch[i] == 'L' && ch[i - 1] == 'R') {
            int res = lstR - i;
            Cnt[i] += (res + 1) / 2;
            Cnt[i - 1] += res / 2;
        } else if (ch[i] == 'R') lstR = i;
    }
    rep (i, 1, n) printf("%d%c", Cnt[i], " \n"[i == n]);
    return 0;
}



Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
void output(pdi d) {
	printf("%d %.2lf\n", d.second, d.first);
}
int main() {
	vector<vector<pdi>> input = vector<vector<pdi>>(3, vector<pdi>(8, make_pair(0,0)));
	vector<pdi> h;
	rep(i, 3) {
		rep(j, 8) cin >> input[i][j].second >> input[i][j].first;
		sort(input[i].begin(), input[i].end(), greater<pdi>());
		rep(j, 2) {
			output(input[i].back());
			input[i].pop_back();
		}
		rep(j, input[i].size()) h.push_back(input[i][j]);
	}
	sort(h.begin(), h.end(), greater<pdi>());
	rep(i, 2) {
		//output(h[h.size() - 1 - i]);
		output(h.back());
		h.pop_back();
	}
	
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	segtree<ll> seg(2 * n, LINF, [](ll a, ll b) {return min(a, b); }, [](ll a, ll b) {return b; });
	for (int i = 0; i < n; i++) {
		seg.change(i, a[i]);
		seg.change(n + i, a[i]);
	}
	ll ans = LINF;
	for (ll i = 0; i < n; i++) {
		ll cnt = i * x;
		for (int j = n; j < 2 * n; j++) {
			cnt += seg.query(j - i, j + 1);
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
}

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

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

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

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

    cout << accumulate(l.begin() + n - k, l.end(), 0) << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

#define LEN 3000

int main(void){
    int n;
    int k;
    int a[LEN];
    int max = 0;
    int tmp;
    int i;

    scanf("%d", &n);
    for(k = 0; k < n; k++){
        scanf("%d", &a[k]);
    }

    max = 0;
    for(k = 0; k < n; k++){
        max +=  a[k];
    }
    max -=  n;

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

    return 0;
}

Measured memory_bytes: 128
def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def is_pairwise():
    C = [0] * (10**6 + 1)
    max_a = 0
    for a in A:
        C[a] += 1
        max_a = max(max_a, a)
    if sum(C[2::2]) > 1: return False
    for i in range(3, max_a + 1, 2):
        if sum(C[i::i]) > 1: return False
    return True

def solve():
    if is_pairwise(): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 127256
n,m = gets.split.map(&:to_i)
mtr = Array.new(n){Array.new(m)}
n.times do |i|
        mtr[i] = gets.split.map(&:to_i)
end

b = Array.new(m)
c = Array.new(n,0)

m.times do |i|
 b[i] = gets.to_i
end

n.times do |i|
    m.times do |j|
      c[i] += mtr[i][j]*b[j]
    end
end
n.times do |i|
    puts "#{c[i]}"
end



Measured memory_bytes: 9080
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
for i in A:
    if i==0:
        ans=0
        break
    elif i==1:
        continue
    elif ans!=-1:
        ans=ans*i
        if ans>mod:
            ans=-1
print(ans)

Measured memory_bytes: 21648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n, m, x; cin >> n >> m >> x;
    vector<ll> C(n);
    vector<vector<ll>> A(n, vector<ll>(m));
    rep(i, n){
        cin >> C[i];
        rep(j, m){
            cin >> A[i][j];
        }
    }
    ll mn = LINF;
    for (int bit = 0; bit < (1 << n); bit++) {
        vector<ll> score(m); ll money = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)){
                //i番目のビットが立っていた時の処理
                money += C[i];
                rep(j, m){
                    score[j] += A[i][j];
                }
            }
        }
        // 探索後の処理
        bool ok = true;
        rep(i, m){
            if(score[i]<x)ok = false;
        }
        if(ok) chmin(mn, money);
    }
    if(mn==LINF)mn = -1;
    cout << mn << ln;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int x;
  cin>>x;
  if(x==7||x==5||x==3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 1E3;

int32_t main() {
	int n;
	cin >> n;
	vi a(n);
	map<int, int> m;
	int res = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		//debug(i + 1, a[i] - (i + 1), -a[i] - (i + 1));
		m[-a[i] - (i + 1)]++;
		int cnt = m[a[i] - (i + 1)];
		res += cnt;
	}
	cout << res << '\n';
}


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

int main(){
	int n, m;
	string s;
	cin >> n >> m >> s;
	
	int x = n;
	bool flag = true;
	vector<int> v;
	
	while(x > 0 && flag){
		for(int i = m; i > 0; i--){
			if(x - i >= 0){
				if(s[x-i] == '0') {
					x -= i;
					v.push_back(i);
					break;
				}
			}
			if(i == 1) flag = false;
		}
	}
	
	if(flag){
		reverse(v.begin(), v.end());
		for(auto it : v) cout << it << ' ';
		cout << endl;
	}
	else{
		cout << -1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1144
N,M=gets.split.map &:to_i
A=[*1..N].map{gets.split.map &:to_i}
A.sort!
m=M
c=0
while m>0 do
   a=A[0]
   if a[1]<m then
       m-=a[1]
       c+=a[1]*a[0]
   else
       c+=a[0]*m
       m=0
   end
   A.shift
end
p c
   

Measured memory_bytes: 11896
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


int main(){
    ll n;
    ll a[101];
    ll sum=0;
    cin>>n;
    REP(i, 0, n){
        cin>>a[i];
        sum+=a[i];
    }

    ll work=sum/n;
    RREP(i, 0, work+1){
        ll cnt=0;
        bool flag=true;
        REP(i, 0, n){
            cnt+=a[i];
            if(cnt>=work){
                cnt-=work;
            }
            else{
                flag=false;
                break;
            }
        }

        if(flag){
            cout<<work<<endl;
            break;
        }
        work--;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = a == b ? c : a == c ? b : a;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int cakeNum = sc.nextInt();
    int[][] cake = new int[H][W];
    int cakeId = 1;
    for (int i = 0; i < H; i++) {
      String line = sc.next();
      for (int j = 0; j < W; j++) {
        if (line.charAt(j) == '#') cake[i][j] = cakeId++;
      }
    }

    cakeId = 1;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (cake[i][j] == cakeId) {
          findBiggestCake(cake, i, j);
          cakeId++;
        }
      }
    }

    for (int i = 0; i < H; i++) {
      String out = "";
      for (int j = 0; j < W; j++) {
        out += " " + cake[i][j];
      }
      System.out.println(out);
    }
  }

  private static void findBiggestCake(int[][] cake, int i, int j) {
    int cakeId = cake[i][j];
    int hUp = 0, hDown = 0, wLeft = 0, wRight = 0;
    // go up
    while (j+hUp-1 >= 0 && cake[i][j+hUp-1] == 0) hUp--;
    while (j+hDown+1 < cake[0].length && cake[i][j+hDown+1] == 0) hDown++;
    while (i+wLeft-1 >= 0) {
      boolean isOk = true;
      for (int k = hUp; k <= hDown; k++) {
        if (cake[i+wLeft-1][j+k] != 0) isOk = false;
      }
      if (isOk) wLeft--;
      else break;
    }

    while (i+wRight+1 < cake.length) {
      boolean isOk = true;
      for (int k = hUp; k <= hDown; k++) {
        if (cake[i+wRight+1][j+k] != 0) isOk = false;
      }
      if (isOk) wRight++;
      else break;
    }

    for (int m = wLeft; m <= wRight; m++) {
      for (int n = hUp; n <= hDown; n++) {
        cake[m+i][n+j] = cakeId;
      }
    }
  }
}

Measured memory_bytes: 152040
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
using namespace std;
typedef long int li;
typedef long long int lli;
const int INF = 0xfffffff;

int main() {
	int n, m, x, y;
	string ans = "No War";
	cin >> n >> m >> x >> y;
	int xwa[105] = { 0 };
	int z = -200;
	for (int i = 0; i < n; i++) {
		cin >> xwa[i];
		z = max(z, xwa[i]);
	}
	z = max(z, x);
	z++;
	if (z > y) ans = "War";
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		if (a < z) ans = "War";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math

N = int(input())
A = list(map(int, input().split()))

dic = {}
for a in A:
    if not a in dic:
        dic[a] = 1
    else:
        dic[a] += 1

ans = 0
for a in dic:
    if dic[a] > 1:
         ans += dic[a] * (dic[a] - 1) // 2

ansdic = {}

for a in dic:
    ansdic[a] = ans
    if dic[a] > 1:
        ansdic[a] = ans - (dic[a] - 1)

for a in A:
    print(ansdic[a])


Measured memory_bytes: 34260
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S;

bool dfs(int idx, int pre, int prepre, vector<int> C) {
  if (idx==N) return true;
  rep(i,3) {
    if (i==pre || i==prepre) continue;
    if (C[i]==0) continue;
    C[i]--;
    bool flag = dfs(idx+1, i, pre, C);
    if (flag) return true;
    C[i]++;
  }
  return false;
}

int main() {
  INCANT;
  cin >> S;
  N = S.size();
  vector<int> C(3);
  for (auto p: S) C[p-'a']++;
  string ans = dfs(0,'-', '-', C)? "YES":"NO";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14416
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
typedef pair<int, int> P;

int n, m;
P p[100000];

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		p[i] = P(b - 2, a - 1);
	}
	sort(p, p + m);
	
	int l = 0;
	int ans = 0;
	for (i = 0; i < m; i++) {
		//cout << p[i].second << " " << p[i].first << endl;
		if (l <= p[i].second) {
			l = p[i].first + 1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll k, q, d[MAXN], n, m, x;

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

    cin >> k >> q;
    for (ll i = 0; i < k; i++) cin >> d[i];

    while (q--) {
        cin >> n >> x >> m;
        ll sum = x % m, t = 0;
        for (ll i = 0; i < k; i++) {
            sum += d[i] % m * ((n - 1) / k);
            if ((n - 1) % k > i) sum += d[i] % m;
            t += (d[i] % m == 0) * (((n - 1) / k) + ((n - 1) % k > i));
        }
        cout << n - 1 - sum / m - t << endl;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 384
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next

  val notFound =
    Set('a','b','c','d','e',
        'f','g','h','i','j',
        'k','l','m','n','o',
        'p','q','r','s','t',
        'u','v','w','x','y','z') &~ s.distinct.toSet

  val res = if(notFound.isEmpty) "None" else notFound.toList.sorted.head

  println(res)




}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct UnionFind {
   public:
    explicit UnionFind(int64_t n) : g(n) { std::iota(g.begin(), g.end(), 0L); }

    int64_t root(int64_t v) {
        if (g[v] != v) {
            g[v] = root(g[v]);
        }

        return g[v];
    }

    void unite(int64_t v, int64_t u) { g[root(v)] = root(u); }

    bool same(int64_t v, int64_t u) { return root(v) == root(u); }

   private:
    std::vector<int64_t> g;
};

int main() {
    int64_t n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;

        uf.unite(a, b);
    }

    unordered_set<int64_t> k;
    for (auto i : irange(0L, n)) {
        k.insert(uf.root(i));
    }

    cout << k.size() - 1 << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  int x = 0,y = 0;
  rep1(i,n){
    x += 800;
    if(i%15==0)y += 200;
  }
  cout << x-y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main()
{
    ll x; 
    cin >> x;
    ll t = 1;
    ll p = 0;
    
    while (p < x){
        p += t;
        t++;
    }
    cout << t - 1 << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int x,n;
    cin >> x >> n;
    int p[102] = {0};
    int i,j;
    for(i=0;i<n;i++){
        cin >> j;
        p[j]=1;
    }
    if(p[x]==0){
        cout << x << endl;
        return 0;
    }
    for(i=1;i<100;i++){
        if(p[x-i]==0){
            cout << x-i << endl;
            return 0;
        }
        if(p[x+i]==0){
            cout << x+i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    ll x;
    cin >> x;

    ll res = x/11;
    res *= 2;
    ll a = x%11;
    if (a > 0) res++;
    if (a > 6) res++;

    cout << res << endl;

    return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int arr[100005];

int main(){

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

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

    string s; cin >> s;
    int n = s.size(), k; cin >> k;

    for(int i = 0; i < n; ++i){
        int num = s[i] - 'a';
        num = (26 - num) % 26;
        //cout << num << " REE\n";
        if(k >= num){
            arr[i] = 0;
            k -= num;
        } else {
            arr[i] = s[i] - 'a';
        }
    }

    arr[n - 1] += k;
    arr[n - 1] %= 26;

    for(int i = 0; i < n; ++i)
        cout << ((char) (arr[i] + 'a'));

    cout << "\n";

    return 0;

}


Measured memory_bytes: 976
n = int(input())
s = list(input())
w = [0]
e = [0]
for i in range(n):
    if s[i] == 'W':
        w.append(w[i]+1)
        e.append(e[i])
    else:
        e.append(e[i]+1)
        w.append(w[i])
e.append(e[-1])
# print(e)
# print(w)
ans = int(1e9)
for i in range(n):
    if w[i] + (e[-1] - e[i+1]) < ans:
        ans = w[i] + (e[-1] - e[i+1])
print(ans)

Measured memory_bytes: 20428
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			String[] f = new String[n];
			int[] w = new int[n];
			int[] s = new int[n];
			int smax = 0;
			for(int i = 0; i < n; i++) {
				f[i] = sc.next();
				w[i] = sc.nextInt();
				s[i] = sc.nextInt();
				smax = Math.max(s[i], smax);
			}
			Data[][] dp = new Data[(1 << n)][smax+1];
			
			dp[0][smax] = new Data();
			dp[0][smax].G = 0;
			dp[0][smax].ix = 1;
			dp[0][smax].id = -1;
			
			for(int i = 0; i < (1 << n); i++) {
				for(int j = smax; j >= 0; j--) {
					for(int k = 0; k < n; k++) {
						if(dp[i][j] == null) continue;
						if((i & (1 << k)) == 0 && (j - w[k]) >= 0) {
							Data a = dp[i|(1 << k)][Math.min(j - w[k], s[k])];
							Data b = new Data();
							b.id = k;
							b.ix = dp[i][j].ix;
							
							b.G = dp[i][j].G + b.ix * w[k];
							b.ix++;
							b.down = dp[i][j];
							
							if(a == null || a.G > b.G) {
								if(b.ix == 2) {
									dp[i|(1 << k)][s[k]] = b;
								}
								else {
									dp[i|(1 << k)][Math.min(j - w[k], s[k])] = b;
								}
							}
						}
					}
				}
			}

			
			
			int min = Integer.MAX_VALUE;
			int id = 0;
			
			for(int i = 0; i < smax+1; i++) {
				if(dp[(1 << n)-1][i] != null && min > dp[(1 << n)-1][i].G) {
					min = dp[(1 << n) -1][i].G;
					id = i;
				}
			}
			ArrayDeque<Data> sxx = new ArrayDeque<Data>();
			Data p = dp[(1 << n) -1][id];
			sxx.add(p);
			while(p.down != null) {
				sxx.add(p.down);
				p = p.down;
			}
			sxx.pollLast();
			while(!sxx.isEmpty()) {
				System.out.println(f[sxx.pollLast().id]);
			}

			
		}
	}
	
	static class Data {
		int id;
		Data down;
		int G;
		int ix;
	}
		
}

Measured memory_bytes: 49052
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n ; 
    cin >> n ;
    vector<int> v(n) ; 
    for(int &x : v){
    	cin >> x ; 
    }
    sort(v.begin(),v.end()) ; 
    double x = (v[0] + v[1]) / 2.0 ;
    for(int i=2;i<n;i++){
    	x = (x + v[i]) / 2.0 ;
    }
    cout << x << endl;
    return 0 ;
}


Measured memory_bytes: 256
//Rafiqul Islam, MBSTU,ICT

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test ;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
#define endl "\n"
#define all(v) v.begin(),v.end()
#define SET(a)      memset((a), -1, sizeof(a))
#define CLR(a)      memset((a), 0, sizeof(a))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const ll mod = 1e9 + 7;;
const ll maxn = 1e6+5;

ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x)%mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x)%mod;  // Change x to x^2
    }
    return res%mod;
}
ll modOp(ll a, ll b)
{
    ll c = a % b;
    if (c < 0)
        c += b;
    return c;
}
ll iv[maxn + 1];
void mod_inv()
{
    iv[1] = 1;
    for(ll i = 2 ; i <= maxn ; i++ )
    {

        iv[i] = (mod - mod/i * iv[mod%i]%mod)%mod;
        //cout << iv[i] << endl;
    }
}

ll Logn(ll n, ll base)
{
    return (n > base - 1) ? 1 + Logn(n / base, base) : 0;
}
vector<vector<int>> adj;
vector<int>sub_tree_size;
vector<array<int,2>> edge;
void dfs(int child, int parant)
{
    sub_tree_size[child] = 1;
    for(int x: adj[child])
    {
        if(x == parant)
            continue;

        dfs(x,child);
        sub_tree_size[child] += sub_tree_size[x];
    }

}

void run_case()
{
    int n, k, a;
    vector<ll>dp, v;

    cin >> n >> k;
    dp.assign(n,LLONG_MAX);
    for(int i = 0 ; i < n ; i++)
    {
        cin >> a, v.pb(a);
    }
    dp[0] = 0;
    for(int i = 1; i < n ; i++)
    {
        for(int j = i-1; (j >= i-k && j >= 0); j--)
        {
            dp[i] = min(dp[i], (dp[j]+abs(v[i] - v[j])));
        }
    }
    cout << dp[n-1] << endl;

    //cout << m << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    run_case();
    //main();
    return 0;
}


Measured memory_bytes: 5056