akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stack>
#include<utility>
using namespace std;

void update(int x,int y,vector< vector<int> >& map){
	if(map[y][x]==1){
		map[y][x]=2;
	}else{
		return;
	}
	if(x!=0)update(x-1,y,map);
	if(y!=0)update(x,y-1,map);
	if(x!=0&&y!=0)update(x-1,y-1,map);
	if(y!=map.size()-1)update(x,y+1,map);
	if(x!=map[0].size()-1)update(x+1,y,map);
	if(y!=map.size()-1&&x!=0)update(x-1,y+1,map);
	if(y!=map.size()-1&&x!=map[0].size()-1)update(x+1,y+1,map);
	if(x!=map[0].size()-1&&y!=0)update(x+1,y-1,map);
}
int main(){
	while(true){
		vector< vector<int> > map;
		int w,h,tmp,sum=0;
		cin>>w>>h;
		if(w==0)break;
		map.resize(h);
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				map[y].resize(w);
				cin>>tmp;
				map[y][x]=tmp;
			}
		}
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(map[y][x]==1){
					sum++;
					update(x,y,map);
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

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

    int a, b;
    cin >> a >> b;
    if(a + b == 15)
        cout << "+";
    else if(a * b == 15)
        cout << "*";
    else
        cout << "x";

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


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

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

    int A, B, C, D;

    cin >> A >> B >> C >> D;

    int smaller = max(A, C);
    int larger = min(B, D);

    cout << max(0, larger-smaller) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
string str(ll i) {
    return i < 0 ? "" : str((i / 26) - 1) + (char)(65 + i % 26);
}
void go(ll a[], ll n) 
{ 
    
    ll xorr = 0; 
    for (int i = 0; i < n; i++) 
        xorr ^= a[i]; 
  
    
    for (int i = 0; i < n; i++)
    {
        a[i] = xorr ^ a[i]; 
        cout<<a[i]<<" ";
    }
} 
int main()
{
   ll n,k;
   cin>>n;
   ll a[n];
   ll s=0;
   map<ll,ll>mp;
   for(ll i=0;i<n;i++)
   {
       cin>>a[i];
       
   }
   go(a,n);
   
   
}

Measured memory_bytes: 5140
n,l=list(map(int,input().split()))
a=[0]*(n+1)
for i in range(1,n+1):
    a[i]=l+i-1
dp=[0]*(n+1)
for i in range(1,n+1):
    if a[i]<0:
        dp[i]=-1
    else:
        dp[i]=1
b=[]+a
for i in range(1,n+1):
    a[i]=abs(a[i])
a[0]=float('inf')
mini=min(a)

index=a.index(mini)
#print(index)
sum1=0
for i in range(1,n+1):
    if i==index:
        pass
    else:
        sum1+=b[i]
print(sum1)
    
    
    

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> ns(2);
    cin >> ns[0] >> ns[1];
    int q;
    cin >> q;
    vector<set<long long>> xss(2);
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < ns[i]; ++j) {
            long long x;
            cin >> x;
            xss[i].insert(x);
        }
        xss[i].insert(-1000000000000000LL);
        xss[i].insert(1000000000000000LL);
    }
    for (int i = 0; i < q; ++i) {
        long long x;
        cin >> x;
        auto it0 = xss[0].lower_bound(x);
        long long b0 = *it0 - x;
        --it0;
        long long a0 = x - *it0;
        
        auto it1 = xss[1].lower_bound(x);
        long long b1 = *it1 - x;
        --it1;
        long long a1 = x - *it1;
        
        long long case_1 = max(a0, a1);
        long long case_2 = max(b0, b1);
        long long case_3 = 2*min(a0, b0) + min(a1, b1);
        long long case_4 = min(a0, b0) +2*min(a1, b1);
        cout << min(min(case_1, case_2), min(case_3, case_4)) << "\n";
    }
    return 0;
}


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

int main() {
  string n;
  cin >> n;

  //検索して"7"が含まれるか判断(含まれない場合"string::npos"が返却される)
  if (n.find("7") != string::npos)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  ll cnt = 0;
  ll pos = 0;

  rep(i, A + B + 1){
    if(S[i] == '-'){
      cnt++;
      pos = i;
    }
  }

  if((cnt == 1) && (pos == A))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string s, f;
char ci;
int q, ti, fi;
bool reverse_flag = false;

int main(void) {
	cin >> s;
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> ti;
		if (ti == 1)
			reverse_flag = !reverse_flag;
		else {
			cin >> fi >> ci;
			if (reverse_flag == false) {
				if (fi == 1)
					f.push_back(ci);
				else
					s.push_back(ci);
			}
			else {
				if (fi == 2)
					f.push_back(ci);
				else
					s.push_back(ci);
			}
		}
	}
	reverse(f.begin(), f.end());
	s = f + s;
	if (reverse_flag)
		reverse(s.begin(), s.end());

	cout << s << endl;
	return 0;
}

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

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

int main(){
  int a[3],k;
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  cin >> k;
  for (int i = 0; i < k; i++){
   sort (a,a+3,greater<int>());
   a[0] *= 2 ;
  }
  cout << a[0] + a[1] + a[2] << '\n';
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;


int main(){
    int n, x, k, y;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    int ans = min(n, k) * x;
    n -= min(n, k);
    ans += n * y;
    printf("%d\n", ans);
}

Measured memory_bytes: 256
N = int(input())
tmp = N
ans = []
if tmp%2 == 1:
    tmp -= 1
for i in range(1,tmp+1):
    for j in range(1,tmp+1):
        if i < j and j != tmp+1-i:
            ans.append((i,j))
if N%2 == 1:
    for i in range(1,N):
        ans.append((i,N))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 74220
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n, m;
		cin >> n >> m;
		int a[n];

		rep(i, 0, n)
		cin >> a[i];

		int x[n], y[n];
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));

		rep(i, 0, m)
		{
			int l, m1;
			cin >> l >> m1;

			x[l-1]++;
			x[m1-1]++;

			if(a[l-1]>a[m1-1])
				y[l-1]++;
			else if(a[l-1]<a[m1-1])
				y[m1-1]++;
		}


		int ans = 0;

		rep(i, 0, n)
		ans+= (x[i]==y[i]);

		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 5996
a,b,c,d,e = map(int, input().split())
if a ==0:
    print(1)
    exit()
elif b ==0:
    print(2)
    exit()
elif c ==0:
    print(3)
    exit()
elif d ==0:
    print(4)
    exit()
else:
    print(5)


Measured memory_bytes: 9044
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  cin >> n;
  if (n == 0) {
    printf("0\n");
    return 0;
  }
  vi ansbit;
  while (n != 0) {
    if (n % 2 == 0) {
      ansbit.push_back(0);
    } else {
      ansbit.push_back(1);
      n -= 1;
    }
    n /= (-2);
  }
  reverse(all(ansbit));
  for (int x : ansbit) {
    printf("%d", x);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

using namespace std;
string repeat(string s, ll n) {
    string s1 = "";
    for (ll i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

// void optimizeIO(){
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     cout.tie(NULL);
// }
ll gcd(ll a, ll b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll a[200001];
ll n,k;
bool check(ll mid){
        ll count = 0;
        for(ll i = 0; i<n; i++)count += (a[i]%mid == 0 ? (a[i]/mid)-1 : a[i]/mid);
        return count <= k;
}

void  solve(){

  cin>>n>> k;

         for(ll i = 0; i<n; i++)cin >> a[i];
         ll start = 1,end = 1e12;
         ll ans = 0;
         while(start <= end){
             ll mid = start + (end - start) / 2;
             if(check(mid)){
                 ans = mid;
                 end = mid-1;
             }
             else start = mid+1;
         }
         //
         cout << min(ans,*max_element(a,a+n)) << "\n";
}
int main(){
    // optimizeIO();
    // tc
    { solve();
    }
}


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

using namespace std;


int main()
{
  int H,W;
  cin >> H >> W;

  vector<string>S(H+1);
  for( int i=0;i<H;i++ )
    {
      cin >> S[i];
      S[i] = S[i]+'#';
    }
  
  H++;
  W++;  
  for( int j=0;j<W;j++ )
    S[H-1] = S[H-1]+'#';
  
  vector<vector<int>> h(H,vector<int>(W,-1));
  vector<vector<int>> w(H,vector<int>(W,-1));

  for(int i=0;i<H;i++)
    {
      int tmp = 0;
      for(int j=0;j<W;j++)
	{
	  //	  cout << i << " " << j << " " << tmp << endl;
	  if(S[i][j] == '#')
	    {
	      for(int k=j-1;k>=0&&S[i][k]!='#';k--)
		w[i][k] = tmp;
	      tmp = 0;
	    }
	  else
	    tmp++;
	}
    }
  //  cout << "err\n" ;
  for(int j=0;j<W;j++)
    {
      int tmp = 0;
      for(int i=0;i<H;i++)
	{
	  if(S[i][j] == '#')
	    {
	      for(int k=i-1;k>=0&&S[k][j]!='#';k--)
		h[k][j] = tmp;
	      tmp = 0;
	    }
	  else
	    tmp++;
	}
    }
  
  int ans = 0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      {
	//	cout << i << " " << j << " " << h[i][j] << " " << w[i][j] << endl;
	if(S[i][j] != '#')
	  ans = max(ans, h[i][j]+w[i][j]);
      }
  cout << ans-1 << endl;
}


Measured memory_bytes: 35712
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	a, b, n := io.NextInt(), io.NextInt(), io.NextInt()
	max := b - 1
	if n < max {
		max = n
	}
	x := sort.Search(max, func(x int) bool {
		return f(a, b, x+1) < f(a, b, x)
	})
	io.Println(f(a, b, x))
}

func f(a, b, x int) int {
	return a*x/b - a*(x/b)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define N 100500
#define int long long
using namespace std;
struct Data{int a, b;}d[N];
bool cmp(Data x, Data y){
	return x.a - x.b > y.a - y.b;
}
int n, m, c[N], f[N], s[N], g[N], h[N], Ans, mnp, mn[N << 2], nn;
int Min(int a, int b){return g[a] <= g[b] ? a : b;}
void build(int rt, int l, int r){
	if(l == r){
		mn[rt] = l;
		//printf("g[%d] = %d\n", r, g[l]);
		return ;
	}
	int mid = (l + r) >> 1;
	build(rt << 1, l, mid);
	build(rt << 1 | 1, mid + 1, r);
	mn[rt] = Min(mn[rt << 1], mn[rt << 1 | 1]);
	//printf("%d  %d  %d  %d\n", rt, l, r, mn[rt]);
}
int qry(int rt, int l, int r, int y){
	if(l == r) return g[l] <= y ? l : (n + 1);
	int mid = (l + r) >> 1;
	if(g[mn[rt << 1]] <= y) return qry(rt << 1, l, mid, y);
	if(g[mn[rt << 1 | 1]] <= y) return qry(rt << 1 | 1, mid + 1, r, y);
	return n + 1;
}
int query(int rt, int l, int r, int x, int y){
	//printf("%d  %d  %d  %d  %d\n", rt, l, r, x, y);
	if(x <= l) return qry(rt, l, r, y);
	int mid = (l + r) >> 1, p1 = n + 1, p2;
	if(x <= mid) p1 = query(rt << 1, l, mid, x, y);
	p2 = query(rt << 1 | 1, mid + 1, r, x, y);
	//printf("%d  %d  %d  %d  %d  %d  %d  %d\n", rt, l, r, x, y, p1, p2, Min(p1, p2));
	return min(p1, p2);
}
int getsum(int x, int y){
	if(y < x) return h[y];
	return h[y] - (d[x].a - d[x].b) + (d[y + 1].a - d[y + 1].b);
}
int find(int x, int y){
	int l = 0, r = nn, mid;
	while(l <= r){
		mid = (l + r) >> 1;
		if(getsum(x, mid) >= y) r = mid - 1;
		else l = mid + 1;
	}
        if(r == nn) r = n;
	return r + 1;
}
void work(int x){
	//printf("x ====== %d\n", x);
	int pos = query(1, 1, n, x, d[x].a - d[x].b);
	pos = min(pos, mnp);
	int fin = find(x, m - d[x].a);
	//printf("fin == %d  pos == %d\n", fin, pos);
	if(pos <= fin) return ;
	Ans = min(Ans, fin + 1);
}
signed main(){
	scanf("%lld%lld", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%lld%lld", &d[i].a, &d[i].b);
	for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
	sort(d + 1, d + n + 1, cmp);
	nn = n;
	while(d[nn].a - d[nn].b <= 0) nn--;
	for(int i = 1; i <= n; i++){
		f[i] = d[i].a - d[i].b - c[i];
		s[i] = s[i - 1] + f[i];
		g[i] = s[i] + (d[i + 1].a - d[i + 1].b);
		h[i] = d[i].a - d[i].b + h[i - 1];
	}
	g[n + 1] = INT_MAX;
	build(1, 1, n);
	mnp = n + 1;
	for(int i = 1; i <= n; i++)
		if(s[i] <= 0) {mnp = i; break;}
	Ans = LLONG_MAX;
	/*work(1);
	return 0;*/
	for(int i = 1; i <= n; i++)
		work(i);
	if(Ans == LLONG_MAX) puts("-1");
	else printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 10812
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	long long int N;
	int max;
	cin >> N;
	max = 100;
	for(long long int i = 1; i <= sqrt((double)N); i++){
		if(N % i == 0){
			int buff = (int)floor(log10((double)(N / i)) + 1);
			if(max > buff){
				max = buff;
			}
		}
	}
	cout << max << endl;
	cin >> N;
	return 0;
}

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

long long int foo(long long int n){return n?foo(n-1)*10:1;}

int main(){
	long long int N, K, D[20] = {}, d;
	
	cin>>N>>K;
	
	for(int i = 1; i <= K; i++){
		cin>>d;
		D[d] = 1;
	}
	
	long long int i = N;
	while(1){
		long long int j = i, k, count = 0, f  = 1, temp, l;
		while(j){//cout<<j<<" "<<count<<endl;
			j/= 10;
			count++;
		}//cin>>temp;
		/*
		while(j){
			k = j%10;cout<<j<<" "<<k<<endl;
			if(D[k]){
				f = 0;
				temp = i-foo(count);
				if(temp >= N) i = temp;
				i += foo(count);
				break;
			}
			j /= 10;
			count++;
		}*/
		j = i;//cout<<"count"<<count<<endl;
		while(count-- >= 1){//cout<<"count "<<count<<endl;
			k = (j/foo(count))%10;
			//cout<<(j/foo(count))%10<<endl;
			if(D[k]){//cout<<"rji;soduiopv:JKL:J"<<endl;
				f = 0;//cout<<"sadjffke'vp'z"<<endl;
				if(temp >= N) i = temp;//cout<<"fvepsduf0u"<<endl;
				for(l = 0; l <= 9; l++){
					if(D[l] == 0 &&  i-foo(count)*(k-l) >= N){temp=l;break;}
				//	cout<<"AFYdgkjdfhdjklsgfulhfjkhg"<<D[l]<<" "<<foo(count)<<endl;
				}
				//temp = i-foo(count);
				//if(temp >= N) i = temp;
				
				i += foo(count) * (l-k);
				//cout<<i<<" "<<(l-k)<<" "<<foo(count)<<endl;
				break;
			}
		}
		if(f) break;
	}
	
	cout<<i<<endl;
}


Measured memory_bytes: 256
count = Hash.new(0)

sentence = gets

words = sentence.split(/ /)

words.each do |word|
    count[word] += 1
end

#??????????????????????????????????????????
max = 0
many_word = ""
count.each{|key, value|
  if value > max
    max = value
    many_word = key
  end
}

#?????????????????°????????????????????????
max = 0
longest_word = ""
count.each_key{|key|
  if key.length > max
    max = key.length
    longest_word = key
  end
}

puts "#{many_word} #{longest_word}"


Measured memory_bytes: 8612
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

getInt = readInt <$> BS.getLine

makeAlign :: Int -> [Int]
makeAlign s
  | s `mod` 2 == 0 = s : makeAlign (s `div` 2)
  | otherwise = s : makeAlign (3 * s + 1)

judge :: [Int] -> Int -> [Int] -> Int -> Int
judge [] (-1) (z : z2 : zs) n = judge [z] z2 zs (n + 2)
judge xs y (z : zs) n
  | y `elem` xs = n
  | otherwise = judge (xs ++ [y]) z zs (n + 1)

main = do
  s <- getInt
  let align = makeAlign s
  print $ judge [] (-1) align 0


Measured memory_bytes: 764
def is_match(s1,s2):
  if len(s1)!=len(s2):
    return False
  count=0
  for i in range(len(s1)):
    if s1[i] == s2[i] or s1[i]=='?' or s2[i]=='?':
      count+=1
  if count==len(s1):
    return True
  else:
    return False        

rs = list(reversed(input()))
rt = list(reversed(input()))  
  
si = 0
while si <len(rs):  
  tmp = rs[si:si+len(rt)]
  
  if is_match(tmp,rt):  
    rs[si:si+len(rt)] = rt
    break
  else:
    si+=1

if si==len(rs):
  print('UNRESTORABLE')
else:
  print(''.join(rs).replace('?','a')[::-1])

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

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt =0
for ai,bi in zip(a,b):
    if ai<=bi:
        cnt+= (bi-ai)//2
    else:
        cnt+= bi-ai

if cnt>=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10480
#include<iostream>
using namespace std;
int e,ans;
int main(){
  while(1){
    cin>>e;
    if(e==0)break;
    ans=e;
    for(int y=0;y*y<=e;y++){
      for(int z=0;z*z*z+y*y<=e;z++){
	int x=e-y*y-z*z*z;
	ans=(ans<x+y+z?ans:x+y+z);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

template<class t>
vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
  sort(line.begin(),line.end(),comp);
  return line;
}

template<class t>
vector<t> reversed(vector<t> line){
  reverse(line.begin(),line.end());
  return line;
}

int n;
int k;
int c;
vector<int> work;

void setup(){
  n = in();
  k = in();
  c = in();
  work.resize(n);
  foreach(i,work){
    char d;
    cin >> d;
    if(d=='o')i=true;
    else i = false;
  }
}

vector<int> cul_work(vector<int> work){
  int la = -INF;
  vector<int> res;
  rep(i,n){
    if(work[i] and i-la>c){
      res.push_back(i);
      la = i;
    }
  }
  return res;
}

int main(){
  setup();
  vector<int> front = cul_work(work);
  vector<int> back = cul_work(reversed(work));
  if(front.size()>k){
    return 0;
  }
  back = reversed(back);
  foreach(i,back)i=n-1-i;
  rep(i,k){
    if(front[i]==back[i])cout<<front[i]+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 4452
N,M=map(int,input().split())
L=sorted(list(map(lambda x: (1,int(x)), input().split()))
         +[tuple(map(int,input().split())) for _ in range(M)]
         ,key=lambda x: x[1],reverse=True)
ans,k=0,0
for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n
print(ans)

Measured memory_bytes: 38940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N, K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i, N){
    cin>>A[i];
  }
  ll Left=0;
  ll Right=MOD;
  while(Right-Left>1){
    ll Half=Left+Right;
    Half/=2;
    ll Count=0;
    rep(i, N){
      Count+=(A[i]/Half-1);
      if(A[i]%Half)Count++;
    }
    //cout<<Half<<" "<<Count<<endl;
    if(Count>K){
      Left=Half;
    }else{
      Right=Half;
    }
  }
  cout<<Right<<endl;
} 

Measured memory_bytes: 4788
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
plus_a = [abs(a) for a in A]
z_cnt = 0
minus_cnt = 0
for i in A:
    if i == 0:
        z_cnt += 1
    elif i < 0:
        minus_cnt += 1


if z_cnt or minus_cnt % 2 == 0:
    print(sum(plus_a))
else:
    print(sum(plus_a) - min(plus_a) * 2)

Measured memory_bytes: 60272
#b = [int(e) for e in input().split()]
a=input()
a=int(a)
b=input()
b=int(b)
c=input()
c=int(c)
d=input()
d=int(d)


count=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            x = 500*i+100*j+50*k
            if(x == d):
                count += 1

print(count)

Measured memory_bytes: 3064
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
#print(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
  dp[i] = (dp[i-1]+dp[i-2])%mod
  if i in a:
    dp[i] = 0
print(dp[-1])


Measured memory_bytes: 13192
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << b ? "Yes" : "No"; }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int dp[201][201];

int gcd(int x, int y)
{
	if (dp[x][y] > 0) return dp[x][y];

	int r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	dp[x][y] = y;
	return y;
}


int gcd(int x, int y, int z)
{
	if (dp[x][y] > 0) return gcd(dp[x][y], z);

	int r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	dp[x][y] = y;
	return gcd(y, z);
}


signed main()
{
	int K;
	cin >> K;

	int sum = 0;
	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			for (int k = 1; k <= K; k++)
			{
				sum += gcd(i, j, k);
			}
		}
	}

	cout << sum << endl;
}




Measured memory_bytes: 3944
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Main main = new Main();
		main.exec();

	}

	private void exec() {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		double[] v = new double[n];
		for(int i = 0 ; i < n ; i++) {
			v[i] = (double)sc.nextInt();
		}
		Arrays.sort(v);
		double ans = v[0];
		for(int i = 1 ; i < n ; i++) {
			ans = (ans + v[i]) / 2;
		}
		System.out.println(ans);
		sc.close();

	}

}


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

using namespace std;
#define int long long
#define N 1666666
int a[N];
map<int,int> mp;
signed main(){
	for(int x=1;x<=200;x++)
		for(int y=x;y<=200;y++)
			for(int z=y;z<=200;z++){
				set<int> s;
				s.insert(x);s.insert(y);s.insert(z);
				if(s.size()==1) mp[x*x+y*y+z*z+x*y+y*z+z*x]++;
				else if(s.size()==2) mp[x*x+y*y+z*z+x*y+y*z+z*x]+=3;
				else mp[x*x+y*y+z*z+x*y+y*z+z*x]+=6;
			}
				
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cout<<mp[i]<<'\n';
	return 0;
}

Measured memory_bytes: 14052
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pl(T x){cout << x << " ";}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }
// 全頂点から各点への最短距離を求める。O(V^3)
void warshall_floyd(arr<int>& d) {
   int n = d.size();
    for (int k = 0; k < n; k++){       // 経由する頂点
      for (int i = 0; i < n; i++) {    // 始点
        for (int j = 0; j < n; j++) {  // 終点
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }
int main()
{
    int h, w; cin >> h >> w;
    arr<int> d(10, vector<int>(10, 0));
    rep(i, 10) rep(j, 10) cin >> d[i][j];
    warshall_floyd(d);

    ll ans = 0;
    rep(i, h) rep(j, w){
        int a; cin >> a;
        if(a==1 || a==-1) continue;
        ans += d[a][1];
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3608
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
	int k;cin >> k;
	int a,b;cin >> a >> b;
	for(int i = a;i <= b;++i)
		if(i % k == 0)
		{
			puts("OK");
			return 0;
		}
	puts("NG");
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


signed main(){
    int w, h;
    while(cin >> w >> h, w+h){
        vector<VI> hor(h), ver(w);
        rep(i, 0, h) hor[i].pb(1);
        rep(i, 0, w) ver[i].pb(i != 0);
        rep(i, 0, 2*h-1){
            int x;
            if(i%2 == 0) rep(j, 0, w-1) cin >> x, hor[i/2].pb(x);
            else rep(j, 0, w) cin >> x, ver[j].pb(x);
        }
        rep(i, 0, h) hor[i].pb(1);
        rep(i, 0, w) ver[i].pb(i != w-1);
        vector<VI> d(h, VI(w));
        queue<PII> q;
        q.push({ 0, 0 });
        d[0][0] = 1;
        while(!q.empty()){
            PII p = q.front(); q.pop();
            int y = p.first, x = p.second;
            if(isin(y, 0, h) and isin(x+1, 0, w) and hor[y][x+1] == 0 and d[y][x+1] == 0) d[y][x+1] = d[y][x]+1, q.push({ y, x+1 });
            if(isin(y+1, 0, h) and isin(x, 0, w) and ver[x][y+1] == 0 and d[y+1][x] == 0) d[y+1][x] = d[y][x]+1, q.push({ y+1, x });
            if(isin(y, 0, h) and isin(x-1, 0, w) and hor[y][x] == 0 and d[y][x-1] == 0) d[y][x-1] = d[y][x]+1, q.push({ y, x-1 });
            if(isin(y-1, 0, h) and isin(x, 0, w) and ver[x][y] == 0 and d[y-1][x] == 0) d[y-1][x] = d[y][x]+1, q.push({ y-1, x });
        }
        cout << d[h-1][w-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (b <= c || d <= a)cout << 0 << "\n";
	else cout << min(b, d) - max(a, c) << "\n";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
MX = 55555
is_prime = [True]*MX
is_prime[0] = False
is_prime[1] = False
for i in range(2, MX):
    if not is_prime[i]:
        continue
    for j in range(2*i, MX, i):
        is_prime[j] = False
ans = [i for i, j in enumerate(is_prime) if j and i%5==1]
print(*ans[:n])

Measured memory_bytes: 3444
//https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int N,K;
    cin>>N>>K;
    if((N+1)/2>=K){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll x;
    cin>>x;
    ll eleven=11;
    ll div=x/11;
    ll rem=x%11;
    cout<<div*2+((rem<=6)?(rem!=0):2)<<endl;
    return 0;
}




Measured memory_bytes: 256
N, M, X, Y = list(map(int, input().split()))
a = []
for i in range(2):
    a.append(list(map(int, input().split())))

if X < Y:
    xs = sorted(a[0])
    ys = sorted(a[1])
    if xs[-1] < ys[0] and xs[-1] < Y and ys[0]>X:
        print('No War')
    else:
        print('War')
else:
    print('War')


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
 
typedef struct LLIST LList;
struct LLIST {
  LList *prev, *next;
  int v;
};

void add(LList *prev, LList *e);
void removeElem(LList *e);
LList *findElem(LList *root, int v);
void printList(LList *root);



int main(int argc, char *argv[]) {
  int n;
  char s[16];
  scanf("%d", &n);
  LList root;
  root.next = &root;
  root.prev = &root;
 
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    if (s[0] == 'i') {
      LList *e = malloc(sizeof(LList));
      scanf("%d", &e->v);
      add(&root, e);
    } else if (s[0] == 'd') {
      if (s[6] == 'F') {
        removeElem(root.next);
      } else if (s[6] == 'L') {
        removeElem(root.prev);
      } else {
        int v;
        scanf("%d", &v);
        LList *e = findElem(&root, v);
        if (e) {
          removeElem(e);
        }
      }
    }
  }
  printList(&root);
  return 0;
}

void add(LList *prev, LList *e) {
  e->next = prev->next;
  e->prev = prev;
  prev->next->prev = e;
  prev->next = e;
}

void removeElem(LList *e) {
  LList *prev = e->prev, *next = e->next;
  prev->next = next;
  next->prev = prev;
  free(e);
}


LList *findElem(LList *root, int v) {
  LList *p = root->next;
  while (p != root) {
    if (p->v == v) return p;
    p = p->next;
  }
  return NULL;
}


void printList(LList *root) {
  LList *p = root->next;
  while (p != root) {
    printf("%d", p->v);
    p = p->next;
    if (p != root) putchar(' ');
  }
  putchar('\n');
}



Measured memory_bytes: 32968
#include <iostream>
#include <math.h>
using namespace std;
void douitu(void);
int N, c[100], after[100], work, minj, cou = 0;
char cc[100], cafter[100], cwork;
bool flag = 1;
int main(void)
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> cc[i] >> c[i];
		cafter[i] = cc[i]; after[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j > i; j--) {
			if (after[j] < after[j - 1]) {
				work = after[j];		 cwork = cafter[j];
				after[j] = after[j - 1]; cafter[j] = cafter[j - 1];
				after[j - 1] = work;	 cafter[j - 1] = cwork;
			}
		}
	}
	douitu();
	if (flag == 1) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	flag = 1;
	for (int i = 0; i < N; i++) {
		cafter[i] = cc[i]; after[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (after[j] < after[minj]) {
				minj = j;
			}
		}
		if (minj != i) {
			work = after[i];		cwork = cafter[i];
			after[i] = after[minj]; cafter[i] = cafter[minj];
			after[minj] = work;		cafter[minj] = cwork;
		}
	}
	douitu();
	if (flag == 1) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}
void douitu(void)
{
	for (int i = 0; i < N; i++) {
		cout << cafter[i] << after[i];
		if (i != N - 1) cout << " ";
		else cout << endl;
	}
	for (int i = 0; i < N - 1  && flag == 1; i++) {
		if (after[i] == after[i + 1]) {
			if (i == N - 1 || after[i] != after[i + 2]) {
				for (int j = 0, k = 0; j < N && k - 1 <= cou; j++) {
					if (after[i] == c[j]) {
						if (cafter[i - (cou) + k] == cc[j]) { k++; }
						else { flag = 0; break; }
					}
				}
				cou = 0;
			}
			else {
				cou++;
			}
		}
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll n; cin >> n;
    vl a(n);
    ll cnt;
    rep(i,n){
        cin >> a[i];
        if(a[i] < 0){
            a[i] *= -1;
            cnt++;
        }      
    }
    sort(all(a));
    ll sum = 0;
    ll ans;
    if(cnt % 2 != 0){
        REP(i,1,n){
            sum += a[i];
        }
        ans = sum - a[0];
    }else{
        rep(i,n){
            sum += a[i];
        }
        ans = sum;
    }
    cout << ans << "\n";
}

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

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

	bool loop = true;

	while (loop) {
		if (s[0] == 'd'&& s[ + 1] == 'r'&& s[2] == 'e'&& s[3] == 'a'&& s[4] == 'm') {
			if (s[5] == 'e'&& s[6] == 'r'&& s[7] != 'a') {
				s.erase(s.begin(), s.begin() + 7);
			}
			else {
				s.erase(s.begin(), s.begin() + 5);
			}
		}
		else if (s[0] == 'e'&& s[1] == 'r'&& s[2] == 'a'&& s[3] == 's'&& s[4] == 'e') {
			if (s[5] == 'r') {
				s.erase(s.begin(), s.begin() + 6);
			}
			else {
				s.erase(s.begin(), s.begin() + 5);
			}
		}
		else {
			loop = false;
		}
	}

	if (s.length() == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main(){
    int n; 
    cin>>n;
    int a=0,b=0,c=0; 
    for(int i=0;i<n;i++){
        int t; cin>>t;
        if(t%4==0) a++;
        else if(t%2==0) b++;
        else c++;
    }
    if(b==0&&c<=a+1||b>=1&&c<=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
x = int(input())
a = 1
while True:
    if a ** 5 == x:
        print(a, end = ' ')
        print(0)
        sys.exit()
    for b in range(1, int(abs(x - a ** 5) ** (1/5)) + 1):
        if abs(a ** 5 - x) == b ** 5:
            if a ** 5 - x > 0:
                print(a, end = ' ')
                print(b)
                sys.exit()
            else:
                print(a, end = ' ')
                print(-b)
                sys.exit()
    a += 1

Measured memory_bytes: 9472
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    A, B, C = in_nn()
    K = in_n()

    cnt = 0

    while A >= B:
        B *= 2
        cnt += 1

    while B >= C:
        C *= 2
        cnt += 1

    if cnt <= K:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <stdio.h>

int main(void)
{
    int i;
    int x[10000];

    for (i = 1; i <= 10000; i++)
    {
        scanf("%d", &x[i]);
        if (x[i] == 0)
            break;
        printf("Case %d: %d\n", i, x[i]);
    }

    return 0;
}


Measured memory_bytes: 2612
#include <stdio.h>

int power( int, int );

int main( void ) {
	int i, power2[ 1001 ], power3[ 101 ], e, ee, x, y, z, min;

	for ( i = 0; i < 1001; i++ )
		power2[ i ] = power( i, 2 );
	for ( i = 0; i < 101; i++ )
		power3[ i ] = power( i, 3 );

	while ( scanf( "%d", &e ), e ) {
		min = e;
		for ( z = 0; power3[ z ] <= e; z++ ) {
			ee = e - power3[ z ];

			for ( y = 0; power2[ y ] <= ee; y++ ) {
				x = ee - power2[ y ];

				if ( x + y + z < min )
					min = x + y + z;
			}
		}

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

	return 0;
}

int power( int x, int n ) {
	int tmp = 1;

	while( n-- )
		tmp *= x;

	return tmp;
}

Measured memory_bytes: 604
n=int(input())
a=[int(input()) for i in range(n)]
d={}
d[1]=1
r=0
cnt=0
while a[r]!=2:
  if a[r] not in d:
    d[a[r]]=1
    r=a[r]-1
    cnt+=1
  else:
    print(-1)
    exit()
print(cnt+1)

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(4);
	
	int k;
	bool flag = false;
	vector<int> antennas(10);

	cin >> antennas[0] >> antennas[1] >> antennas[2] >> antennas[3] >> antennas[4] >> k;

	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (i != j) {
				if (abs(antennas[i] - antennas[j]) > k) {
					flag = true;
					break;
				}
			}
		}
		if (flag) break;
	}

	if (flag) {
		cout << ":(\n";
	} else {
		cout << "Yay!\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, a, b, c, q, k, x, y;
    cin >> n;
    unordered_map<int, vector<pair<int, ll>>> e;
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b >> c;
        e[a-1].push_back({b-1, c});
        e[b-1].push_back({a-1, c});
    }
    cin >> q >> k;
    vector<ll> dis(n, INT_MAX);
    dis[k-1] = 0;
    vector<int> dq = {k-1};
    while(!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            for(auto p: e[node]) {
                int neibor = p.first;
                if (dis[neibor] == INT_MAX) {
                    dis[neibor] = dis[node] + p.second;
                    new_dq.push_back(neibor);
                }
            }
        }
        dq.swap(new_dq);
    }

    while(q--) {
        cin >> x >> y;
        cout << dis[x-1] + dis[y-1] << endl;
    }
    return 0;
}





Measured memory_bytes: 14500