akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt(); // 宿泊日数
		int k = sc.nextInt();
		int x = sc.nextInt(); // k泊目までの宿泊費
		int y = sc.nextInt(); // k+1泊目以降の宿泊費
		sc.close();

		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= k) {
				sum += x;
			}
			if (i > k) {
				sum += y;
			}
		}

		System.out.println(sum);

	}

}


Measured memory_bytes: 21588
#include<stdio.h>
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int i;
    int d[11];
    for (i = 0; i < k; i++)
        scanf("%d", &d[i]);
    int a, b;
    int x;
    for (;; n++)
    {
        a = n;
        x = 0;
        while (a > 0)
        {
            b = a % 10;
            a /= 10;
            for (i = 0; i < k; i++)
            {
                if (b == d[i])
                {
                    x++;
                    break;
                }
            }
            if (x > 0)
                break;
        }
        if (x == 0)
            break;
    }
    printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 128
import random
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
for i in range(d):
    get = random.uniform(1, 27)
    if get == 27:
        get = 26
    print(int(i%26+1))

Measured memory_bytes: 78004
prime = []
numberlist = []
for i in range(2, 317):
	numberlist.append(i)
while True:
	if numberlist[0] > 17:
		break
	p = numberlist.pop(0)
	newnumberlist = []
	while numberlist != []:
		now = numberlist.pop(0)
		if now%p != 0: newnumberlist.append(now)
	prime.append(p)
	numberlist = newnumberlist
for i in range(0, len(numberlist)):
	prime.append(numberlist[i])

def primejudge(n):
	if n == 1: return False
	if n in prime: return True
	for i in range(0, len(prime)):
		if n % prime[i] == 0: return False
	return True

like2017 = []
cnt = 0
for i in range(0, 100001):
	if i % 2 == 1:
		if primejudge(i) and primejudge((i+1)//2): cnt += 1
	like2017.append(cnt)

Q = int(input())
for i in range(0, Q):
	left, right = map(int, input().split())
	print(like2017[right]-like2017[left-1])

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

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

  vector<ll> A(N), B(N);
  rep(i,0,N-1) cin >> A[i] >> B[i];

  ll p = 0;
  for (ll i = N-1; 0 <= i; --i)
  {
    ll d = A[i] + p;
    if (d % B[i] != 0)
    {
      p += B[i] - d % B[i];
    }
  }

  cout << p << endl;
  return 0;
}


Measured memory_bytes: 4808
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

solv hs = go 0 hs where
  go l [] = 0
  go l (h:hs)
    | h >= l = 1 + go h hs
    | otherwise = go l hs

main = do
  [n] <- map read . words <$> getLine :: IO [Int]
  hs <- readInts n <$> B.getLine
  print $ solv hs


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int 	A, B, C;
	cin >> A >> B >> C;
	bool ok = false;
	for (size_t i = 1; i <= B; i++) {
		if (A * i % B == C) {
			ok = true;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
ll dp[100005][13];
string S;

void solve() {
    cin >> S;
    int N = S.size();

    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        int c = S[i] == '?' ? -1 : S[i] - '0';
        for (int j = 0; j < 10; ++j) {
            if (c != -1 && c != j) continue;
            for (int k = 0; k < 13; ++k) {
                dp[i+1][(k*10 + j) % 13] += dp[i][k];
            }
            for (int j = 0; j < 13; ++j) {
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[N][5] << endl;
}

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


Measured memory_bytes: 10624
#include <cstdio>
#include <string>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  if (N == 0)
    return !printf("0\n");

  std::string s;
  while (N) {
    if (N % 2) {
      s += '1';
      --N;  // C++ の負の除算の都合
    } else {
      s += '0';
    }

    N /= -2;
  }

  std::reverse(s.begin(), s.end());
  printf("%s\n", s.c_str());
}


Measured memory_bytes: 256
import Data.Char
isnLatin :: Char -> Bool
isnLatin c | ord c >= 65 && ord c <= 90  = False
		   | ord c >= 97 && ord c <= 122 = False
		   | otherwise					 = True

main = do
	str <- getContents
	print $ length $ filter (== "A") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "B") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "AB") $ (map snd.map (span(isnLatin)).lines) str
	print $ length $ filter (== "O") $ (map snd.map (span(isnLatin)).lines) str

Measured memory_bytes: 3700
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll x[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  ll ret = 1LL << 60;
  for (int i=0; i<=N-K; i++) {
    ll l = x[i];
    ll r = x[i+K-1];
    ll l0 = abs(min(0LL, l));
    ll r0 = abs(max(0LL, r));
    ll d = min(l0*2+r0, r0*2+l0);
    ret = min(d, ret);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s = S()
print(chr(ord(s)+1))

Measured memory_bytes: 65900
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		final int N = 26;

		int D = sc.nextInt();
		int[] c = new int[N];
		for(int i=0; i<N; i++)
			c[i] = sc.nextInt();
		
		int[][] s = new int[D][N];
		for(int i=0; i<D; i++)
			for(int j=0; j<N; j++)
				s[i][j] = sc.nextInt();
		
		int[] t = new int[D];
		for(int i=0; i<D; i++)
			t[i] = sc.nextInt()-1;
		
		int score = 0;
		int[] last = new int[N];
		for(int i=0; i<D; i++) {
			score += s[i][t[i]];
			last[t[i]]=i+1;
			for(int j=0; j<N; j++)
				score -= c[j]*(i+1-last[j]);
		}

		int M = sc.nextInt();
		for(int i=0; i<M; i++) {
			int d = sc.nextInt();
			int to = sc.nextInt()-1;
			
			int from = t[d-1];

			score += s[d-1][to] + c[to]*(d-getIndex(t, to, d, false))*(getIndex(t, to, d, true)-d);
			score -= s[d-1][from] + c[from]*(d-getIndex(t, from, d, false))*(getIndex(t, from, d, true)-d);
			pw.println(score);
			t[d-1] = to;
		}

		sc.close();
		pw.close();
	}
	
	static int getIndex(int[] t, int type, int base, boolean isForward) {
		int ans = base;
		int diff = isForward ? 1 : -1;
		ans += diff;
		while(1 <= ans && ans <= t.length) {
			if(t[ans-1]==type)
				return ans;
			ans += diff;
		}
		return ans;
	}
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	
	if (N == 1) {
		cout << "Hello World";
	}else if(N == 2){
		int A, B;
		cin >> A >>B;
		cout << A+B << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

bool Fmeiji, Ftaisho, Fshowa, Fheisei = false;
void meiji(int year, int month, int day);
void taisho(int year, int month, int day);
void showa(int year, int month, int day);
void heisei(int year, int month, int day);
int year, month, day;
int main(void)
{
    int wagou;
    while ((scanf("%d %d %d", &year , &month, &day)) != EOF) {
    heisei(year, month, day);
    if (Fheisei == true) {
        wagou = year - 1988;
        printf("heisei %d %d %d\n", wagou, month, day);
    } else {
        showa(year, month, day);
        if (Fshowa == true) {
            wagou = year - 1925;
            printf("showa %d %d %d\n", wagou, month, day);
        } else {
            taisho(year, month, day);
            if (Ftaisho == true) {
                wagou = year - 1911;
                printf("taisho %d %d %d\n", wagou, month, day);
            } else {
                meiji(year, month, day);
                if (Fmeiji == true) {
                    wagou = year - 1867;
                    printf("meiji %d %d %d\n", wagou, month, day);
                } else {
                    printf("pre-meiji\n");
                }
            }
        }
        
    }
    }
    return 0;
}

void meiji(int year, int month, int day)
{
    if (year > 1868) {
        Fmeiji =true;
    } else if (year == 1868 && month > 9) {
        Fmeiji = true;
    } else if (year == 1868 && month == 9 && day >= 8) {
        Fmeiji = true;
    } else {
        Fmeiji = false;
    }
}

void taisho(int year, int month, int day)
{
    if (year > 1912) {
        Ftaisho =true;
    } else if (year == 1912 && month > 7) {
        Ftaisho = true;
    } else if (year == 1912 && month == 7 && day >= 30) {
        Ftaisho = true;
    } else {
        Ftaisho = false;
    }
}

void showa(int year, int month, int day)
{
    if(year > 1926) {
        Fshowa =true;
    } else if (year == 1926 && month > 12) {
        Fshowa = true;
    } else if (year == 1926 && month == 12 && day >= 25) {
        Fshowa = true;
    } else {
        Fshowa = false;
    }
}

void heisei(int year, int month, int day)
{
    if (year > 1989) {
        Fheisei =true;
    } else if (year == 1989 && month > 1) {
        Fheisei = true;
    } else if (year == 1989 && month == 1 && day >= 8) {
        Fheisei = true;
    } else {
        Fheisei = false;
    }
}

Measured memory_bytes: 1032
#include <iostream>
using namespace std;
using ll = long long;

template <class T> inline bool chmin(T& a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline T abs(const T& a) { 
  if(a < 0) {
    return -a; 
  } else {
    return a;
  }
}
template <class T> inline T max3(const T& a, const T& b, const T& c)
{
  return max(c, max(a, b));
}
template <class T> inline T min3(const T& a, const T& b, const T& c)
{
  return min(c, min(a, b));
}

const ll INF = (ll)1e12;

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

  if(H % 3 == 0 || W % 3 == 0) { // ３等分できる
    cout << 0 << endl;
    return 0;
  }
  ll min = INF;
  // 縦もしくは横に等分する場合の差は横または縦の１列ぶんになる
  chmin(min, H);
  chmin(min, W);
  // cout << "min : " << min << endl;
  for(int h = 1; h < H; ++h) {
    // cout << "h : " << h;
    auto s1 = h * W;
    auto s2 = (H - h) * (W / 2);
    auto s3 = (H - h) * (W / 2 + W % 2);
    // cout << " " << s1 << ", " << s2 << ", " << s3;
    chmin(min, abs(max3(s1, s2, s3) - min3(s1, s2, s3)));
    // cout << "min : " << min << endl;
  } 

  for(int w = 1; w < W; ++w) {
    // cout << "w : " << w;
    auto s1 = H * w;
    auto s2 = (W - w) * (H / 2);
    auto s3 = (W - w) * (H / 2 + H % 2);
    // cout << " " << s1 << ", " << s2 << ", " << s3;
    chmin(min, abs(max3(s1, s2, s3) - min3(s1, s2, s3)));
    // cout << "min : " << min << endl;
  }
  cout << min << endl;
  return 0;
}

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


int main(){
  int n,i,j;
  double ans,ave1,kai,kai1;
  ans=0.0;
  ave1=0.0;
  cin >> n;
  vector<int> x(n),y(n);
  for(i=0;i<n;++i){
    cin >> x[i] >> y[i];
  }
  kai=1.0;
  for(i=n;i>=1;--i){
    kai=kai*i;
  }
  kai1=1.0;
  for(i=n-1;i>=1;--i){
    kai1=kai1*i;
  }
  for(i=0;i<n-1;++i){
    for(j=i+1;j<n;++j){
      ans=ans+sqrt(pow(x[j]-x[i],2)+pow(y[j]-y[i],2))*2.0*kai1;
    }
  }
  ave1=(double)ans/(double)kai;
  printf("%.10lf",ave1);
  return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int r; cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int mx,mn=1<<30,a,n;
int main(void){
    scanf ("%d",&n);
    while (n--){
        scanf ("%d",&a);
        if (a>mx)mx=a;
        if (a<mn)mn=a;
    }
    printf ("%d\n",mx-mn);
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    string a;
    string b;
    cin >> a >> b;
    
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    }

    rep(i, a.size()) {
        if (a[i] > b[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
        else if (a[i] < b[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
d=input()
total1=0
total2=0
for i in range(a):
    if d[i]=="a":
        if total1+total2<b+c:
            print("Yes")
            total1+=1
        else:
            print("No")
    elif d[i]=="b":
        if total1+total2<b+c and total2<c:
            print("Yes")
            total2+=1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 9304
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let white: usize = s.next().unwrap().parse().unwrap();
	let black: usize = s.next().unwrap().parse().unwrap();
	let mut field = vec![[vec!['.'; 50], vec!['#'; 50]].concat(); 43];
	for i in 0..black - 1 {
		let w = i % 24;
		let h: usize = i / 24;
		field[1 + 2 * h][1 + 2 * w] = '#';
	}
	for i in 0..white - 1 {
		let w = i % 24;
		let h: usize = i / 24;
		field[1 + 2 * h][51 + 2 * w] = '.';
	}
	println!("{} 100", field.len());
	for i in 0..field.len() {
		println!("{}", field[i].iter().collect::<String>());
	}
}


Measured memory_bytes: 2132
/*
** 二分搜索
*/

# include <cstdio>

static int const maxn = 100000 + 5;

int binarySearch(const int s[], int n, int t) {
	int start = 0, end = n-1, mid;
	
	while (start <= end) {
		mid = start + (end-start)/2;
		if (s[mid] == t) return 1;
		else if (s[mid] < t) 
			start = mid + 1;
		else
			end = mid - 1;
	}
	return 0;
}

int main() {
	// freopen("infile", "r", stdin);
	// freopen("outfile", "w", stdout);
	
	int n, q, t, s[maxn];
	while (scanf("%d", &n) != EOF) {
		for (int i = 0; i < n; i++) 
			scanf("%d", &s[i]);
		scanf("%d", &q);
		
		int ans = 0;
		for (int i = 0; i < q; i++) {
			scanf("%d", &t);
			ans += binarySearch(s, n, t);
		}
		
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 256
Option Strict On
Imports System.Console
Imports System.Collections.Generic

Module Program
    Sub Main()
        Dim w As String = NextString()
        Dim dic As New Dictionary(Of Char, Integer)

        Dim ans As String = "Yes"

        For Each v As Char In w
            If Not dic.ContainsKey(v) Then
                dic(v) = 0
            End If

            dic(v) += 1
        Next

        For Each v As Integer In dic.Values
            If v Mod 2 <> 0 Then
                ans = "No"
                Exit For
            End If
        Next

        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of String)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return String.Join("", result)
    End Function

End Module


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

typedef long long ll;

ll N, M;

int main() {
  cin >> N >> M;
  ll w = 1;
  for (ll i = 0; i < M; ++i) w *= 2;
  cout << (1900 * M + 100 * (N - M)) * w << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
typedef pair < int , int > Pi;
bool data[5001][5001];
bool isOK(int x,int y){
  return x >= 0 && x < 5001 && y >= 0 && y < 5001 && data[x][y];
}
int main(){
  int n;
  int x[3000], y[3000];
  while(cin >> n , n){
    memset( data,false,sizeof(data));
    for(int i = 0 ; i < n ; i++ ){
      cin >> x[i] >> y[i];
      data[x[i]][y[i]] = true;
    }
    int ret = 0;
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < i ; j++ ){
        int xx = x[j] - x[i];
        int yy = y[j] - y[i];
        if(isOK(x[i] + yy,y[i] - xx) & isOK(x[j] + yy,y[j] - xx))
          ret = max( ret, xx * xx + yy * yy);
      }
    }
    cout << ret << endl;
  }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,K;
int C[222222],V[222222];
vint lis[222222];

int ans[222222];

signed main(){
	cin>>N>>K;
	rep(i,N){
		cin>>C[i]>>V[i];
		C[i]--;
		lis[C[i]].pb(V[i]);
	}
	rep(i,K){
		sort(all(lis[i]));
		reverse(all(lis[i]));
	}
	vector<pair<pint,int>>ord;
	rep(i,K){
		ord.pb({{lis[i][0]+lis[i][1],(lis[i].size()>2?lis[i][2]:-INF)},i});
	}
	sort(all(ord));reverse(all(ord));

	vint uku(ord.size()+1);
	uku.back()=-INF;
	for(int i=ord.size()-1;i>=0;i--){
		uku[i]=uku[i+1];
		int k=ord[i].se;
		if(lis[k].size()<3)continue;
		chmax(uku[i],lis[k][0]+lis[k][1]+lis[k][2]);
	}



	fill_n(ans,N+1,-INF);

	int n=0;
	int cur=0;
	vector<int>vs;
	priority_queue<int>nex;
	int sum=0;
	while(true){
		chmax(ans[n],sum);
		if(uku[cur]!=-INF)chmax(ans[n+3],sum+uku[cur]);


		if(n==N)break;
		bool ok=true;
		if(nex.size()==0){
			if(vs.size()){
				
				sum-=vs.back();
				nex.push(vs.back());
				vs.pop_back();
				n--;
			}
			ok=false;
		}
		else if(vs.size()==0){}
		else if(cur<K&&ord[cur].fi.fi>vs.back()+nex.top()){
			sum-=vs.back();
			nex.push(vs.back());
			vs.pop_back();
			n--;
			ok=false;
		}

		if(ok){
			sum+=nex.top();
			vs.pb(nex.top());
			nex.pop();
			n++;
		}
		else{
			int k=ord[cur].se;
			sum+=ord[cur].fi.fi;
			for(int i=2;i<lis[k].size();i++)nex.push(lis[k][i]);
			cur++;
			n+=2;
		}
	}
	for(int i=1;i<=N;i++){
		if(ans[i]==-INF)cout<<-1<<endl;
		else cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 21104
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, M = mulinputs()
datas = dict()
for i in range(1,N+1):
    datas[i] = []

while True:
    try:
        pi, Si = input().split()
        datas[int(pi)].append(Si)
    except EOFError:
        break

ac_cnt = 0
wa_cnt = 0
for v in datas.values():
    if 'AC' in v:
        ac_cnt += 1
        for judge in v:
            if judge == 'AC':
                break
            wa_cnt += 1

print(ac_cnt, wa_cnt)




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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int K, X;
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000005
ll mod=1000000007;
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[200007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<200005;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	facto();
	int n,k;
	cin>>n>>k;
	int a[n]={0};
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int sum=0,mn=0;
	for(int i=k;i<=n;i++)
	{
		sum=(sum+ncr(i-1,k-1)*a[i-1])%mod;
	}
	for(int i=1;n-i>=k-1;i++)
	{
		mn=(mn+ncr(n-i,k-1)*a[i-1])%mod;
	}
	cout<<(sum-mn+mod)%mod<<endl;
}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define HP 6
#define M(a, b) make_pair(a, b)

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int w, h;
int d[8][8];
int dp[8][8];
int dx[] = {0,-1,0,1}, dy[] = {-1,0,1,0};

int main(){
  while(scanf("%d%d", &w, &h) && w+h){
    int y, x;
    rep(i, h) rep(j, w){
      scanf("%d", &d[i][j]);
      if(d[i][j] != 2) continue;
      y = i; x = j;
      d[i][j] = 1;
    }

    rep(i, h) rep(j, w) dp[i][j] = INF;
    dp[y][x] = 0;

    queue<pii> q;
    q.push(M(HP, M(y, x)));
    map<pi, bool> m;
    int t = 1;    
    while(!q.empty()){
      int qsize = (int)q.size();
      rep(i, qsize){
	pii now = q.front(); q.pop();
	rep(j, 4){
	  int nt = now.F - 1, ny = now.S.F + dy[j], nx = now.S.S + dx[j];
	  if(nt == 0 || ny < 0 || nx < 0 || ny >= h || nx >= w || d[ny][nx] == 0) continue;
	  if(!m.count(M(ny, nx)) && d[ny][nx] == 4){
	    nt = 6;
	    m[M(ny, nx)] = true;
	  }else if(d[ny][nx] == 3){
	    printf("%d\n", t);
	    goto e;
	  }

	  q.push(M(nt, M(ny, nx)));
	}
      }
      t++;
    }
    puts("-1");
  e:;
  }
  return 0;
}

Measured memory_bytes: 1248
n = gets.chomp.to_i
s = gets.chomp.split("")

w, e = [], []
ww, ee = 0, 0
s.each do |c|
    w << ww
    if c == 'W'
        ww += 1
    end
end

s.reverse.each do |c|
    e << ee
    if c == 'E'
        ee += 1
    end
end

e.reverse!

ans = 10 ** 6
for i in 0..(n-1) do
    ans = (w[i] + e[i]) if ans > (w[i] + e[i])
end
puts ans

Measured memory_bytes: 34620
from collections import defaultdict
from bisect import bisect
N,M,*P = map(int,open(0).read().split())
d = defaultdict(list)
Z = set()
for n,m in zip(*[iter(P)]*2):
    d[n].append(m)
    Z.add(n)
for z in Z:
    d[z].sort()
for n,m in zip(*[iter(P)]*2):
    print(str(n).zfill(6)+str(bisect(d[n],m)).zfill(6))

Measured memory_bytes: 33896
function main(input) {
  const input_array = input.split(' ');
  const sum_price = input_array[1];
  const paper_money_count = input_array[0];
  
  for(count_10000=0; count_10000<=paper_money_count ;count_10000++){
    maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000);
    minimum_price = 10000 * count_10000 + 1000 * (paper_money_count - count_10000);
    if(sum_price > maximum_price || sum_price < minimum_price){
      continue;
    }
    for(count_5000=0; count_5000<=paper_money_count - count_10000 ;count_5000++){
      maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000) + 1000 * (paper_money_count - count_10000 - count_5000);
      if(sum_price > maximum_price){
        continue;
      }
      for(count_1000=0; count_1000<=paper_money_count - (count_10000 + count_5000) ;count_1000++){
        if(count_10000 + count_5000 + count_1000 != paper_money_count){
          continue;
        }
        if(count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000 == sum_price){
          console.log(`${count_10000} ${count_5000} ${count_1000}`);
          return;
        }
      }
    }
  }
 
  console.log('-1 -1 -1');
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
n, x, y = map(int, input().split())
x = x - 1
y = y - 1
kl = [0] * (n - 1)
 
for s in range(n - 1):
    for e in range(s+1, n):
        d = e-s
        if (e <= x)or(s >= y):
            kl[d - 1] += 1
        else:
            kl[min(d, abs(s-x)+abs(e-y)+1)-1] += 1
 
for i in kl:
    print(i)

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


int main(void) {
    string s;
    cin >> s;
    int judge = 1;
    for(int i = 0; i < s.size(); i++) {
        if(i%2 == 0) {
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                judge = 0;
            }
        } else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                judge = 0;
            }
        }
    }

    if(judge) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		
		// First visit to 2
		for (int i = y1; i < y2; i++) {
			System.out.printf("U");
		}
		for (int i = x1; i < x2; i++) {
			System.out.printf("R");
		}
		
		// First visit to 1
		for (int i = y2; i > y1; i--) {
			System.out.printf("D");
		}
		for (int i = x2; i > x1; i--) {
			System.out.printf("L");
		}
		
		// Second visit to 2
		System.out.printf("L");
		for (int i = y1; i < y2 + 1; i++) {
			System.out.printf("U");
		}
		for (int i = x1 - 1; i < x2; i++) {
			System.out.printf("R");
		}
		System.out.printf("D");
		
		// Second visit to 1
		System.out.printf("R");
		for (int i = y2; i > y1 - 1; i--) {
			System.out.printf("D");
		}
		for (int i = x2 + 1; i > x1; i--) {
			System.out.printf("L");
		}
		System.out.printf("U\n");
	}
	
}

Measured memory_bytes: 30884
# 解説放送を観て写経
import sys

N = int(input())
xyh = []
for _ in range(N):
  x, y, h = map(int, input().split())
  xyh.append((x, y, h))
for i in range(101):
  for j in range(101):
    needH = -1
    for x, y, h in xyh:
      if h>0:
        tmp = h+abs(i-x)+abs(j-y)
        if needH==-1:
          needH = tmp
        else:
          if needH!=tmp:
            needH = -2
            break
          
    if needH==-2:
      continue
      
    for x, y, h in xyh:
      if h==0:
        dist = abs(i-x)+abs(j-y)
        if needH>dist:
          needH = -2
          break
          
    if needH==-2:
      continue
      
    print(i, j, needH)
    sys.exit()


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n;
	cin >> n;
	int ans=0;
	priority_queue<int> que;
	rep(i,0,n){
		int a;
		cin >> a;
		while(!que.empty()&&que.top()>a) que.pop();
		if(que.empty()||que.top()!=a){
			que.push(a);
			++ans;
		}
	}
	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	//std::cin.tie(0);
	Solve();
	return 0;
}

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

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef vector<int> vi;

int main(){
    int n, k;
    while(cin >> n >> k, n || k){
	vi nums(n);
	int sum = 0;
	rep(i,k){
	    cin >> nums[i];
	    sum += nums[i];
	}
	int ans = sum;
	repi(i,k,n){
	    cin >> nums[i];
	    sum -= nums[i-k];
	    sum += nums[i];
	    if(sum > ans){
		ans = sum;
	    }
	}
	cout << ans << endl;
    }
}

Measured memory_bytes: 1532
s=list(input())

for i in range(len(s)):
            for j in range(i+1,len(s)):
                        if s[i]!=s[j]:
                                    pass
                        else:
                                    #print('s[i]',s[i],'s[j]',s[j])
                                    print('no')
                                    exit()
print('yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
set<string>s;
int main() {
  ios::sync_with_stdio(false);
  int n;cin>>n;
  for(int i=1;i<=n;i++){
  	string a;
  	cin>>a;
  	s.insert(a);
  }
  cout<<s.size()<<'\n';
 	return 0;
}

Measured memory_bytes: 19236
#include<iostream>

using namespace std;

int main ()
{

	while(1)
	{
		int H, W;
cin >> H >> W;
		if(H == 0 && W == 0)break;

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				if((j + i) % 2 == 0)
				{
					cout << '#';
				}
				else
				{
					cout << '.';
				}

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

Measured memory_bytes: 3080
#include <iostream>
#include <assert.h>
#include <cmath>
#include <iomanip>

int main(){
    int32_t N, K;
    std::cin >> N >> K;
    
    //Dice value M with prob 1/N
    //to over K, concecutive front count log2(K/M) is needed
    
    double res = 0;
    for(int32_t i = 1; i <= N; i++){
        double mult = (double) K / i;
        int32_t consec = (int32_t) std::ceil(std::log2(mult));
        double coin_prob = 0;
        if(consec >= 1){
            coin_prob = (double) 1 / (2 << (consec - 1));
        }
        else{
            coin_prob = 1;
        }
        res += coin_prob;
    }
    res = res / N;
    std::cout << std::setprecision(12) << res;

    return 0;
}


Measured memory_bytes: 384
import math

a, b, h, m = list(map(int, input().split()))
rh = (h + m/60) * 30 
rm = m * 6
rd = abs(rh -rm)
print(math.sqrt((a**2) + (b**2) - (2 * a * b * math.cos(math.radians(rd)))))


Measured memory_bytes: 9488
N = int(input())
*A, = list(map(int, input().split()))
flg = 1
cnt = 0
while flg:
    flg = 0
    for j in range(N-1,0,-1):
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j - 1]
            A[j - 1] = v
            flg = 1
            cnt += 1
print(*A)
print(cnt)


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

int main() {

	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if (u == s) a--;
	if (u == t) b--;
	cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3660
<?php
list($n, $m) = ints();
$bf = new BellmanFord($n, $m);
for ($i = 0; $i < $m; ++$i) {
    list($a, $b, $c) = ints();
    --$a;
    --$b;
    $c = -$c; // 最小値を求める問題に変換
    $bf->connect($a, $b, $c);
}
$bf->solve();
if (!$bf->negative[0][$n - 1]) echo -$bf->dist(0, $n - 1);
else echo 'inf';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

class BellmanFord
{
    private $n;
    private $d; // 最短距離を格納
    private $m; // 辺の数
    private $from;
    private $to;
    private $cost; // ノード間の距離を格納
    public $negative;

    function __construct($n, $m)
    {
        $this->n = $n;
        $this->m = $m;
    }
    function connect($x, $y, $w)
    {
        $this->from[] = $x;
        $this->to[] = $y;
        $this->cost[] = $w;
    }

    function solve($s = 0)
    {
        $n = $this->n;
        $d = $this->d;
        $m = $this->m;
        $from = $this->from;
        $to = $this->to;
        $cost = $this->cost;
        //var_dump($from, $to, $cost);
        $d[$s] = array_fill(0, $n, INF);
        $d[$s][$s] = 0;
        for ($k = 1; $k <= $n - 1; ++$k)
            for ($i = 0; $i < $m; ++$i)
                if ($d[$s][$to[$i]] > $d[$s][$from[$i]] + $cost[$i])
                    $d[$s][$to[$i]] = $d[$s][$from[$i]] + $cost[$i];

        $negative = $this->negative;
        $negative[$s] = array_fill(0, $n, false);
        for ($k = 1; $k <= $n; ++$k) {
            for ($i = 0; $i < $m; ++$i) {
                if ($d[$s][$to[$i]] > $d[$s][$from[$i]] + $cost[$i]) {
                    $d[$s][$to[$i]] = $d[$s][$from[$i]] + $cost[$i];
                    $negative[$s][$to[$i]] = $negative[$s][$from[$i]] = true;
                }
            }
        }

        $this->d = $d;
        $this->negative = $negative;
    }

    function dist($x, $y)
    {
        return $this->d[$x][$y];
    }
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

void genStrings(string s, vector <string> &list, int N, int cur)
{
    if (s.length()==N) {
        list.push_back(s);
        return;
    }
    int n=s.length();
    int prevchar = s[n-1] - 'a';
    for (int i=0; i<=cur; ++i)
    {
        genStrings(s+((char)('a'+i)), list, N, max(cur, i+1));
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    if (N==1)
    {
        cout << "a\n"; return 0;
    }
    vector <string> list;
    string s="a";
    genStrings(s, list, N, 1);
    sort(list.begin(), list.end());
    loop(i,0,list.size())
    {
        cout << list[i] << "\n";
    }
    return 0;
}

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

using namespace std;

int main() {   
/*
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif
*/
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    cout << s[i];
  }
  cout << " ";
  for (int i = 4; i < s.size(); i++) {
    cout << s[i];
  }      
  cout << "\n";
  return 0;
} 


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
const int maxn=1000000+5;
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	LL x,ans=0;
	cin>>x;ans=x/11*2;
	if(x%11!=0)
	{
		ans++;
		if(x%11>6) ans++;
	}
	cout<<ans;
	
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

vi k,l,r; 

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int t; cin >> t;
	while(t--){
		int n; cin >> n;
		set <int> pos;
		priority_queue <pii> fro, bac;
		rep(i,n) pos.insert(i+1);
		k.resize(n);
		l.resize(n);
		r.resize(n);
		rep(i,n) cin >> k[i] >> l[i] >> r[i];
		rep(i,n){
			if(l[i] > r[i]) fro.push(mp(l[i] - r[i], k[i]));
			if(r[i] > l[i]) bac.push(mp(r[i] - l[i], k[i]));
		}
		ll ans = 0; rep(i,n) ans += r[i];
		while(!fro.empty()){
			pii tt = fro.top();
			fro.pop();
			auto it = pos.upper_bound(tt.snd);
			if(it != pos.begin()){
				it--;
				pos.erase(*it);
				ans += tt.fst;
			}
		}
		int ss = sz(pos);
		pos.clear();
		rep(i,ss) pos.insert(n-i);
		while(!bac.empty()){
			pii tt = bac.top();
			bac.pop();
			auto it = pos.upper_bound(tt.snd);
			if(it == pos.end()){
				ans -= tt.fst;
			}else{
				pos.erase(*it);
			}
		}
		cout << ans << '\n';
		k.clear();
		l.clear();
		r.clear();
	}

	return 0;
}



Measured memory_bytes: 16608
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  vector<int> x(N);
  rep(i, N) {
    cin >> x[i];
  }
  int ans = 1000000000;
  for (int i = 0; i + K - 1 <= N - 1; i++) {
    int c1 = abs(x[i]) + x[i + K - 1] - x[i];
    int c2 = abs(x[i + K - 1]) + x[i + K - 1] - x[i];
    ans = min({c1, c2, ans});
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
     int t,n,i=4;
     while(i!=0){
          scanf("%d %d",&t,&n);
          switch(t){
              case 1:
                printf("%d\n",6000*n);
                break;
              case 2:
                printf("%d\n",4000*n);
                break;
              case 3:
                printf("%d\n",3000*n);
                break;
              case 4:
                printf("%d\n",2000*n);
                break;
          }
          i--;
     }
     return 0;
}

Measured memory_bytes: 600
#単一始点最短経路問題
#Bellman-Ford法よりも高速
#ただし、負の辺がある場合は使えない

#隣接リストとpriority queueを用いたDijkstra法
#O(M log N)
#負の辺が含まれるときうまくいかない-->負の辺が含まれるときはBellman-Ford法を使う必要がある
INF = 10 ** 9
#入力
N, M = map(int, input().split())
#辺を管理する隣接リスト

G = [[] for _ in range(N)]
for i in range(M):
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    #0-indexに変換して処理
    G[l-1] += [[s, r-1, i]]
    G[r-1] += [[s, l-1, i]]
# print (G)

#始点sから各頂点への最短距離を求める
def dijksrea(s): #始点s
    import heapq
    s -= 1 #始点を0-indexに変える
    d[s] = 0 #始点の距離を0にする
    pque = []
    heapq.heappush(pque, [0, s]) #要素を[距離、頂点]として管理　最初の位置を入れる

    while len(pque) != 0: #queの中に要素が残っている時
        p = heapq.heappop(pque) #最も距離が短いものを取り出す
        v = p[1] #距離が最も短い頂点
        if d[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
            continue
        for i in range(len(G[v])): #頂点vの隣接リストを走査
            e = G[v][i]
            if d[e[1]] > d[v] + e[0]: #距離が更新できるかを検討
                d[e[1]] = d[v] + e[0]
                prev[e[1]] = [v, e[2]]
                heapq.heappush(pque, [d[e[1]], e[1]]) #更新できた場合、その値をpqueに入れる

# dijksrea(1)
# print (d)
# print (prev)
#最短経路復元
# edge_num = []
def restore(g): #gまでの最短経路を復元
    g -= 1 #0-indexに直す
    path.append(g)
    edge_num.append(prev[g][1])
    g = prev[g][0]
    while g != -1:
        path.append(g)
        # ans_lst[prev[g][1]] = True #辺を使った処理をする
        edge_num.append(prev[g][1])
        g = prev[g][0]
    path.reverse()
    return path

ans_lst = [False] * M #False使われていない

for i in range(1, N):
    d = [INF] * N #頂点sからの距離
    prev = [[-1, -1] for _ in range(N)] #最短経路復元のためのリスト
    dijksrea(i) #スタート地点から最小距離を処理
    for j in range(i + 1, N + 1):
        path = []
        edge_num = []
        restore(j)
        for k in edge_num[:-1]:
            ans_lst[k] = True
        # print ('i, j',  i, j,  restore(j)) #ゴール地点まで
        # print (ans_lst)
        # print (edge_num)
# print (ans_lst)
print (ans_lst.count(False))


Measured memory_bytes: 3444
""" スニペット """
def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))
""" スニペット """
import math
# 2つ選ぶ通り数を算出 nC2
def choose2(n):
    return n*(n-1)//2
# インプット
N = get_int()
An = get_ints()
""" 全ての要素から2つのボールを選ぶ通り数を求める """
uni = [0] * (N+1)
# ユニーク数の配列を求める
for i in range(N):
    uni[An[i]] += 1
sumWay = 0
con = [0] * (N+1)	#con[i] := iC2
for i in range(N+1):
  con[i] = choose2(i)
# 各数値の2通りの選択通り数を足していく
"""
for i in range(N + 1):
    sumWay += con(uni[i])
"""
#↑を書きかえてみた
for i in uni:
  sumWay += con[i]
""" 全ての要素数 - 削除する要素の通り数 + 削除する要素を引いた際の通り数 を求める """
for i in range(N):
    print(sumWay - con[uni[An[i]]] + con[uni[An[i]]-1])


Measured memory_bytes: 33372
def main():
  n = int(input())
  nums = list(map(int, input().split()))
  cmin = 0
  for x in nums:
    cmin += (x - min(nums)) ** 2
  for i in range(min(nums), max(nums)+1):
    c = getcost(i, nums)
    if c < cmin:
      cmin = c
  print(cmin)
  
def getcost(x, nums):
  c = 0
  for n in nums:
    c += (n - x) ** 2
  return c
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:q:_) <- fmap (map read . words) getLine :: IO [Int]
  s <- getLine
  lrs <- replicateM q $ (\(a:b:_) -> (a,b)) . map read . words <$> getLine :: IO [(Int, Int)]
  putStr . unlines . map show $ solve s lrs

solve :: String -> [(Int, Int)] -> [Int]
solve s = map count
  where
    counts = countAC s
    countAC s = tail . reverse $ go [0] s
      where
        go xs [] = xs
        go (x:xs) (a:b:c)
          | a == 'A' && b == 'C' = go ((x+1):x:x:xs) c
          | otherwise = go (x:x:xs) (b:c)
        go (x:xs) _ = x:x:xs
    
    countArr = listArray (0, length s) (0:counts)
    count :: (Int, Int) -> Int
    count (l, r) = countArr ! r - countArr ! (l)



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

int main() {
  int n, k, r, s, p, sum = 0, con = 0;
  char *t;
  cin >> n >> k >> r >> s >> p;
  t = new char[n];
  cin >> t;
  for (int i = 0; i < k; i++) {
    for (int j = i; j < n; j += k) {
      if (j >= k && t[j] == t[j - k]) {
        con++;
      } else {
        con = 0;
      }
      if (con % 2 == 0) {
      	if (t[j] == 'r') sum += p;
      	if (t[j] == 's') sum += r;
      	if (t[j] == 'p') sum += s;
      }
    }
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 384