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 stay = Integer.parseInt(sc.next());
        int sale = Integer.parseInt(sc.next());
        int normalCost = Integer.parseInt(sc.next());
        int saleCost = Integer.parseInt(sc.next());
        if(stay > sale){
            System.out.println(sale * normalCost + (( stay - sale ) * saleCost));
        }else{
        System.out.println(stay * normalCost);
        }
    }
}


Measured memory_bytes: 21972
N,D,A=map(int,input().split())
monster=[]
for i in range(0,N):
    x,h=map(int,input().split())
    monster.append([x,h])

monster.sort()

H=[monster[i][1] for i in range(0,N)]

right_2d=[0 for i in range(0,N)]
for i in range(0,N):
    start=i
    end=N-1
    while end-start>1:
        test=(end+start)//2
        if 2*D+monster[i][0]>=monster[test][0]:
            start=test
        else:
            end=test
    if 2*D+monster[i][0]>=monster[end][0]:
        right_2d[i]=end
    else:
        right_2d[i]=start

imos=[0 for i in range(0,N+1)]
ans=0
for i in range(0,N):
    H[i]-=imos[i]
    if H[i]>0:
        count=(H[i]+A-1)//A
        ans+=count
        imos[i]+=A*count
        imos[right_2d[i]+1]-=A*count

    imos[i+1]+=imos[i]

print(ans)

Measured memory_bytes: 93604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		System.out.println((X-A)%B);
	}
}


Measured memory_bytes: 25300
var n,i,j:longint;a:array[1..100]of longint;
begin
	read(n);
	for i:=1 to n do begin
		read(j);
		a[j]:=a[j]+1;
	end;
	j:=0;
	n:=0;
	for i:=100 downto 1 do begin
		while a[i]>0 do begin
			a[i]:=a[i]-1;
			if j mod 2 > 0 then n:=n-i
			else n:=n+i;
			j:=j+1;
		end;
	end;
	write(n);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,y; cin >> n >> y;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; i + j <= n; j++) {
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        printf("%ld %ld %ld\n",i, j, n-i-j);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        mut n: u64,
    }

    let mut s = String::new();
    while n > 0 {
        n -= 1;
        let x = (n % 26) as u8 + 'a' as u8;
        n /= 26;
        s.push(x as char);
    }

    let s: String = s.chars().rev().collect();
    println!("{}", s);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 998244353
using namespace std;
using ll = long long;

int main() {
    int N, S; cin >> N >> S;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    ll dp[N + 1][S + 1] = {};
    dp[0][0] = 1;
    REP(i, 0, N) {
        REP(j, 0, S + 1) {
            dp[i + 1][j] = (dp[i + 1][j] + (dp[i][j] * 2) % MOD) % MOD;
            if (j + A[i] < S + 1) dp[i + 1][j + A[i]] = (dp[i + 1][j + A[i]] + dp[i][j]) % MOD;
        }
    }

    cout << dp[N][S] << endl;
    return 0;
}

Measured memory_bytes: 73928
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    NO_TLE
    int k,x;
    cin>>k>>x;
    int tmp=0;
    for(int i=x-k+1;;++i)
    {
        if(i>=-1000000)
        {
            cout<<i;
            tmp=i+1;
            break;
        }
    }
    for(int i=tmp;i<=x+k-1;++i)
    {
        if(i>=-1000000&&i<=1000000)
            cout<<' '<<i;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];

        int maximum = 0;
        int sum = 0;

        for(int i=0; i<N; i++){
            int input = sc.nextInt();
            maximum = Math.max(maximum, input);
            array[i] = input;
        }

        boolean flg = false;
        for(int i=0; i<N; i++){
            int num = array[i];

            if(num == maximum && flg == false){
                num = num / 2;
                flg = true;
            }

            sum+=num;
        }

        System.out.println(sum);
    }
}

//
//class Gauss {
//    //連立方程式の係数
//    //a[N][N](係数行列)とb[1](定数)を一緒にしたもの
//    double a[][];
//    int N;
//
//    Gauss(double[][] a, int N){
//        a = a;
//        N = N;
//    }
////    double a[][]={{1.0,1.0,1.0,1.0,10,0},
////            {2.0,1.0,3.0,2.0,21.0},
////            {1.0,3.0,2.0,1.0,17.0},
////            {3.0,2.0,1.0,1.0,14.0}};
////    int N=a.length;
//
//    //Gaussの消去法で連立方程式を解く
//    void gauss(){
//        //前進消去
//        double s;
//        for(int k=0; k<N-1; k++){
//            for(int i=k+1; i<N; i++){
//                s=a[i][k]/a[k][k];
//                for(int j=k+1; j<=N; j++){
//                    a[i][j] -= s * a[k][j];
//                }
//            }
//        }
//        //後退代入
//        for(int i=N-1; i>=0; i--){
//            s=a[i][N];
//            for(int j=i+1; j<N; j++){
//                s -= a[i][j] * a[j][N];
//            }
//            a[i][N] = s/a[i][i];
//        }
//    }
//    public static void run() {
//        Gauss gs= new Gauss();
//        gs.gauss();
//        //解の表示
//        System.out.println("ガウスの消去法による連立1次方程式の解");
//        for(int i=0; i<gs.N; i++){
//            System.out.println("x["+i+"] = "+gs.a[i][gs.N]);
//        }
//    }
//}


Measured memory_bytes: 21716
n = gets.to_i; h = gets.split.map &:to_i
line = false; count = 0
h.max.times do |i|
	n.times do |j|
		if line == false && h[j] >= i+1
			line = true
			count+=1
		end
		if line == true && h[j] < i+1
			line = false
		end
	end
	line = false
end
puts count


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

int LinearSearch(int *,int);

int n;

int main()
{
  int q,i,C=0;
  int *S,*T;

  scanf("%d",&n);
  S = (int *)malloc( n * sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  T = (int *)malloc( q * sizeof(int));
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    C += LinearSearch(S,T[i]);
  }

  printf("%d\n",C);
  
  free(S);
  free(T);

  return 0;
}
  
int LinearSearch (int *S,int T)
{
  int i;
  for(i=0;i<n;i++){
    if(S[i] == T) return 1;
  }
  return 0;
}
  



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define For(i,n) for(long i=0;i<(n);i++)
int main(void){
    long N;
    cin>>N;
    vector<long> num(N);
    long Max=0;
    /*For(i,N){
        cin>>num[i];
        Max=max(Max,num[i]);
    }*/
    cout<<(N-2)*180<<endl;
    
}


Measured memory_bytes: 256
s = input()
n = len(s)

#iよりleftのA、rightのC, leftの？, rightの?
la = [0 for _ in range(n)]
rc = [0 for _ in range(n)]
lq = [0 for _ in range(n)]
rq = [0 for _ in range(n)]

for i in range(n-1):
    if s[i] == 'A':
        la[i+1] = 1
    if s[i] == '?':
        lq[i+1] = 1
    if s[i+1] == '?':
        rq[i] = 1
    if s[i+1] == 'C':
        rc[i] = 1

for i in range(n-1):
    la[i+1] += la[i]
    lq[i+1] += lq[i]

for i in range(n-1, 0, -1):
    rc[i-1] += rc[i]
    rq[i-1] += rq[i]

ans = 0
mod = 10 ** 9 + 7

for i in range(n):
    if s[i] in ['B', '?']:
        l = la[i] * pow(3, lq[i], mod)
        if lq[i] > 0:
            l += lq[i] * pow(3, lq[i]-1, mod)
            l %= mod

        r = rc[i] * pow(3, rq[i], mod)
        if rq[i] > 0:
            r += rq[i] * pow(3, rq[i]-1, mod)
            r %= mod
        ans += l * r
        ans %= mod


print(ans)

Measured memory_bytes: 18968
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (s.equals(u)) {
            a--;
        } else {
            b--;
        }
        System.out.println(a + " " + b);
        sc.close();
    }
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var p = consoleReader.Split.Double;
            var dp = new double[N, N + 1];
            dp[0, 0] = 1 - p[0];
            dp[0, 1] = p[0];
            for (int i = 1; i < N; i++)
            {
                dp[i, 0] = dp[i - 1, 0] * (1 - p[i]);
                for (int j = 1; j <= i + 1; j++)
                {
                    dp[i, j] = dp[i - 1, j] * (1 - p[i]) + dp[i - 1, j - 1] * p[i];
                }
            }
            double sum = 0;
            for (int i = N / 2 + 1; i <= N; i++)
            {
                sum += dp[N - 1, i];
            }
            return sum;
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> Split { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 81120
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		String ans = "NG";
		for(int i=A; i<=B; i++) {
			if(i % K == 0) {
				ans = "OK";
				break;
			}
		}

		System.out.println(ans);

	}


}


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

struct Edge {
    int to;
    ll distance;
};
struct Data {
    int from;
    int index;
    ll distanceFromK;
};
//
int N;
//経路
vector<Edge> edgeMap[100001];
//Kからの距離
ll minD[100001];

//全都市のKからの距離を計算
//K,およびその先から伸びるすべての辺を探索。最大でも100000回ですむはず
void calcFromK(int from, int curr, ll distance) {
    minD[curr] = distance;

    //都市 d.curr から伸びている辺を全部あさる。ただし来た道は除外
    auto arr = edgeMap[curr];
    for (auto &e: arr) {
        if (e.to != from) {
            calcFromK(curr, e.to, distance + e.distance);
        }
    }
}
//x -> k -> yな距離を計算
ll solve(int x, int y, int k) {
    return minD[x] + minD[y];
}

int main()
{
    cin >> N;
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        edgeMap[a].push_back({b, c});
        edgeMap[b].push_back({a, c});
    }
    int Q, K;
    cin >> Q >> K;
    vector<ll> ans;
    calcFromK(-1, K, 0);
    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        ans.push_back(solve(x, y, K));
    }

    for (auto a : ans) {
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m;
char A[N],B[N];
int inq[26][N];
void solve(){
	scanf("%s",A+1);
	n=strlen(A+1);
	scanf("%s",B+1);
	m=strlen(B+1);
	memset(inq,-1,sizeof(inq));
	for(int i=1;i<=n;i++)
		inq[A[i]-'a'][i]=i;
	for(int i=n;i>=1;i--){
		for(int j=0;j<26;j++)
			if(inq[j][i]==-1)inq[j][i]=inq[j][i+1];
	}
	for(int j=0;j<26;j++)if(~inq[j][1])inq[j][n+1]=inq[j][1]+n;
	for(int i=n;i>=1;i--){
		for(int j=0;j<26;j++)
			if(inq[j][i]==-1)inq[j][i]=inq[j][i+1];
	}/*
	for(int i=0;i<26;i++){
		for(int j=1;j<=n;j++){
			printf("%d ",inq[i][j]);
		}puts("");
	}*/
	int k=1;
	long long ans=0;
	for(int i=1;i<=m;i++){
		if(inq[B[i]-'a'][1]==-1){
			puts("-1");
			return;
		}
		ans+=inq[B[i]-'a'][k]-k+1;
		k=inq[B[i]-'a'][k]+1;
		// printf("k=%d\n",k);
		k=(k-1)%n+1;
	}
	printf("%lld\n",ans);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 10624
#include<iostream>

using namespace std;

int main(){

  int in;
  
  while(1){

    cin >> in;

    if(in == 0) break;

    int sum = 0;

    while(in != 1){
      if(in % 2 == 0){
	in /= 2;
	sum++;
      }else{
	in = in*3+1;
	sum++;
      }
    }
    cout << sum << endl;

  }

  return 0;
}

Measured memory_bytes: 0
#set
input = gets.chomp.to_f
nontax_price = (input / 1.08).to_i
answer = ':('

#main

def chk(i,input)
  if i * 1.08 >= input && i * 1.08 < input + 1 then
    print("#{i}\n")
    exit
  end
end

nontax_price.upto(nontax_price + 1) do |i|
  chk(i,input)
end

print ("#{answer}\n")

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, a, b;
    cin >> n >> a >> b;
    int c1=0, c2=0, c3=0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (p <= a) c1++;
        else if (p <= b) c2++;
        else c3++;
    }

    cout << min(c1, min(c2, c3)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,ans=0,v[20],c;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&v[i]);
  for(int i=0;i<n;i++){
    scanf("%d",&c);
    if(v[i]-c>0)ans+=v[i]-c;
  }
  printf("%d",ans);
  return 0;
}
    
  

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
    int n; sd(n);
    vector<int> a(n);
    vector<int> there(30);
    int x = 0;
    for(int i = 0; i < n; i++){
        sd(a[i]); x ^= a[i];
        for(int j = 0; j < 30; j++) if(a[i] >> j & 1){
            there[j] = 1;
            break;
        }
    }
    int ans = 0;
    for(int i = 29; i >= 0; i--){
        if(x >> i & 1){
            if(!there[i]){
                printf("-1\n");
                return 0;
            }
            x ^= (1 << (i + 1)) - 1;
            ans++;
        }
    }
    printf("%d\n", ans);
}

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

int main()
{
	int s[10000], t, n, q, count = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> t;
		for (int j = 0; j < n; j++)
			if (s[j] == t)
			{
				count++;
				break;
			}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3132
N = gets.to_i
steps = gets.split.map(&:to_i)
dp = []
dp[0] = 0
dp[1] = (steps[0]-steps[1]).abs
pos = 2
while pos < N
    dp[pos] = [(steps[pos] - steps[pos-1]).abs + dp[pos -1], (steps[pos] - steps[pos-2]).abs  + dp[pos -2]].min
    pos+=1
end
puts dp[N-1]


Measured memory_bytes: 11404
#include <iostream>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

int main() {

  int A, B;
  cin >> A >> B;

  int s=1, cnt=0;
  while (s < B) {
	s += A-1;
	cnt++;
  }

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

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

void print_sort(int A[], int N) {
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      printf("%d\n", A[i]);
    } else {
      printf("%d ", A[i]);
    }
  }
}

void insertion_sort(int A[], int N) {
  print_sort(A, N);

  for (int i = 1; i < N; i++) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

    print_sort(A, N);
  }
}

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

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

  insertion_sort(A, N);
}


Measured memory_bytes: 3140
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int h, w, d;
  cin >> h >> w >> d;
  int b[h][w];
  REP(i, h){
    REP(j, w) cin >> b[i][j];
  }
  map<int, P> m;
  REP(i, h){
    REP(j, w){
      m[b[i][j]-1] = {i, j};
    }
  }
  int c[h*w-d];
  REP(i, h*w-d){
    c[i] = abs(m[i+d].second - m[i].second) + abs(m[i+d].first-m[i].first);
  }
  int cs[h*w];
  REP(i, d) cs[i] = 0;
  REP(i, h*w-d) cs[i+d] = c[i] + cs[i];
  int q;
  cin >> q;
  REP(i, q){
    int r, l;
    cin >> r >> l;
    r--;
    l--;
    cout << cs[l]-cs[r] << endl;
  }
	return 0;
}


Measured memory_bytes: 7808
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,k
    integer(int32):: r,s,p
    integer(int32):: i,j,ans
    character(:),allocatable:: t
    character(1):: old
    logical,allocatable:: w(:)


    read*, n,k
    read*, r,s,p
    allocate(character(n):: t)
    allocate(w(n))
    read*, t
    ans=0
    old=t(1:1)
    do i=1,k
        if (t(i:i) == 'r') then
            ans=ans+p
        else if (t(i:i) == 's') then
            ans=ans+r
        else
            ans=ans+s
        end if
    end do
    w(1:k) = .true.
    w(k+1:) = .false.

    do i=k+1,n
        if (t(i:i) == t(i-k:i-k) .and. w(i-k)) cycle
        if (t(i:i) == 'r') then
            ans=ans+p
        else if (t(i:i) == 's') then
            ans=ans+r
        else
            ans=ans+s
        end if
        w(i) = .true.
    end do

    print'(i0)', ans

end program main

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    int t[n], x[n], y[n];
    REP(i, n) cin >> t[i] >> x[i] >> y[i];
    int a = 0, b = 0;
    REP(i, n){
        int d = abs(x[i] - (i ? x[i-1]: 0)) + abs(y[i] - (i ? y[i-1] : 0));
        if(t[i] < d || (t[i] - (i ? t[i-1] : 0) - d) % 2){ No; RET; }
        a = x[i]; b = y[i];
    }
    Yes;
RET;}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n, m;
    cin >> n >> m;
    vvint path(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    vint route(n);
    rep(i, n) route[i] = i;
    int ans = 0;
    do{
        bool flag = true;
        rep(i, n - 1){
            int dep = route[i];
            int arr = route[i + 1];
            auto result = find(path[dep].begin(), path[dep].end(), arr);
            if(result == path[dep].end()){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }while(next_permutation(route.begin() + 1, route.end()));

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


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(i <= k) continue;
        ll num = n/i;
        ans += num * (i-k);
        int nn = n%i;
        if(nn >= k) {
            ans += 1+nn-k;
            if(k==0) ans--;
        }
    }

    cout << ans << endl;
}

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

int A, B, C, D;
int main() {
  cin >> A >> B >> C >> D;

  cout << max(A * B, C * D) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    double x[100] = {0}, y[100] = {0}, p_1 = 0, p_2 = 0, p_3 = 0, p_infinity = -1;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%lf", &x[i]);
    for(int i = 0; i < n; i++) scanf("%lf", &y[i]);

    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
     }
    printf("%.6lf\n" ,p_1);
    printf("%.6lf\n", sqrt(p_2));
    printf("%.6f\n", cbrt(p_3));
    printf("%.6lf\n", p_infinity);
    return 0;
}



Measured memory_bytes: 2920
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
typedef long long int ll;

int mod = 1e9 + 7;
char mat[1001][1001];
int n, m;
// int dp[1001][1001];

// int find(int i, int j) {
// 	if (i == n - 1 && j == m - 1)
// 		return 1;

// 	if (i >= n || j >= m)
// 		return 0;

// 	if (mat[i][j] == '#')
// 		return 0;

// 	if (dp[i][j] != -1)
// 		return dp[i][j];

// 	dp[i][j] = (find(i + 1, j) + find(i, j + 1)) % mod;
// 	return dp[i][j] % mod;
// }

int main() {
	cin >> n >> m;
	// memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> mat[i][j];

	int dp[n + 1][m + 1];
	memset(dp, 0, sizeof dp);
	dp[0][1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (mat[i - 1][j - 1] == '#') {
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
		}
	}
	cout << dp[n][m];
	// cout << find(0, 0);
	return 0;
}



Measured memory_bytes: 8408
# coding: utf-8
class UnionFind
  attr :id, :rank

  def initialize(n)
    @id   = (0..n).to_a
    @rank = Array.new(n,0)
  end

  def root(i)
    if @id[i] == i or i == @id[@id[i]]
      i
    else
      @id[i] = root(@id[i])
      @id[i]
    end
  end

  # find, check if p and q has the same root
  def same?(p, q)
    root(p) == root(q)
  end

  # union, to merge components containing p and q
  # set id of p's root to the id of q's root
  def unite(p, q)

    i = root(p)
    j = root(q)

    return if i == j

    if @rank[i] < @rank[j]
      @id[i] = j
    else
      @id[j] = i;
      @rank[i]+=1  if @rank[i] == @rank[j]
    end
  end
end


lines = $stdin.read
array = lines.split("\n")

n = array[0].split(" ")[0].to_i
q = array[0].split(" ")[1].to_i

un = UnionFind.new(n)

for i in 1..q
  com = array[i].split(" ")[0]
  x   = array[i].split(" ")[1].to_i
  y   = array[i].split(" ")[2].to_i

  if com == '0'
    # unite(4,3) id[4] = 3, 4の頭を3にする
    un.unite(x, y)
  else
    # same
    puts un.same?(x, y) ? "1" : "0"
  end
end


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

int main() {
  int N;
  cin >> N;
  string S;
  
  for (int i = 0; i < N ; i++) {
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N-1) {
      cout << "Three" <<endl;
    }
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
bool vis[26],now[26];
vector<int> G[26];
bool dfs(int v){
	vis[v]=1;
	now[v]=1;
	for(int u:G[v]){
		if(now[u]){
			now[v]=0;
			return 1;
		}
		if(!vis[u]){
			bool b=dfs(u);
			if(b){
				now[v]=0;
				return 1;
			}
		}
	}
	now[v]=0;
	return 0;
}
bool solve(int N){
	rep(i,26) vis[i]=now[i]=0,G[i].clear();
	string s_[500];
	rep(i,N) cin>>s_[i];
	rep(i,N-1){
		string s=s_[i],t=s_[i+1];
		int S=s.size(),T=t.size();
		int j=0;
		while(j<S&&j<T&&s[j]==t[j]) j++;
		if(j==S) continue;
		if(j==T) return 0;
		G[s[j]-'a'].pb(t[j]-'a');
	}
	bool no=0;
	rep(i,26){
		if(!vis[i]) no|=dfs(i);
	}
	return !no;
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		if(solve(N)) puts("yes");
		else puts("no");
	}
}

Measured memory_bytes: 1260
n=int(input())
a=list(map(int,input().split()))

boxes=[0]*n #if ball in boxes[i-1]=boxes no.i
'''
b=[]
#m=len(b)
i=n #iの番号が書いた箱、インデックスはa[i-1]について
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	if boxes[i-1]:
		b.append(i)
	i-=1
#print(boxes)

print(len(b))
print(*b) #space区切り
'''
for i in reversed(range(n)):
	boxes[i]=(a[i]+sum(boxes[i::i+1]))%2

print(sum(boxes))
for i in range(n):
	if boxes[i]:
		print(i+1,end=" ")

Measured memory_bytes: 8384
#include<bits/stdc++.h>
// #include<iostream>
// #include<vector>
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//typedef vector<int> vi;
//using ll = long long; //only for C++11 compiler and newer
 
using namespace std;
template<typename T>
inline T Abs(T a){return a < 0 ? -a : a; }
template<typename T>
inline T Max(T a, T b){return a < b ? b : a; }
template<typename T>
inline T Min(T a, T b){return a > b ? b : a; }
 
int main(){
    //fast()
    //freopen("input.txt","r",stdin);
    int n; cin >> n;
    cout << (n / 2) + (n % 2) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ulli unsigned long long int
#define endl '\n'

int main()
{
	lli n;cin>>n;
	string s;
	cin>>s;
	lli r=0,g=0,b=0;
	for(lli i=0;i<n;i++){
		if(s[i]=='R')r++;
		else if(s[i]=='G')g++;
		else b++;
	}
	lli temp=r*g*b;

	for(lli i=0;i<n;i++){
		for(lli j=i+1;j<n;j++){
			if(s[i]==s[j])continue;
			lli k=j+(j-i);
			if(k>=n)continue;
			if(s[k]==s[i] || s[k]==s[j])continue;
			temp--;
		}
	}
	cout<<temp;

    return 0;
}


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

using namespace std;

template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

struct Vertex
{
	int color;
	Vertex(int a) : color(a) {}
	Vertex() : Vertex(0) {}
};

using vertex = Vertex;

struct Edge
{
	int to;
	Edge(int t) : to(t) {}
	Edge() {}
};
using edge = Edge;
using graph = Graph<vertex, edge>;

long long res[3];

template<class V, class E>
bool is2graph_dfs(Graph<V, E>& G, int pos, int par = -1, int color = 1)
{
	if (par == -1) {
		if (G.v[pos].color) return true;
	}
	if (G.v[pos].color && G.v[pos].color != color) return false;
	if (G.v[pos].color) return true;
	G.v[pos].color = color;
	res[color]++;
	for (auto& n : G.e[pos]) {
		if (n.to == par) continue;
		if (!is2graph_dfs(G, n.to, pos, 3 - color)) return false;
	}
	return true;
}

template<class V, class E>
bool is2graph(Graph<V, E>& G)
{
	for (int i = 0; i < G.size(); i++) {
		if (!is2graph_dfs(G, i)) return false;
	}
	return true;
}

int main()
{
	int N, M;
	cin >> N >> M;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G.add_edge(a, b);
		G.add_edge(b, a);
	}
	if (is2graph(G)) {
		cout << res[1] * res[2] - M << endl;
	} else {
		cout << (long long) N * (N - 1) / 2 - M << endl;
	}
}


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

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

    string T = "ATGC";
    int longest = 0;
    int now = 0;
    for(int i = 0; i < S.size(); i++){
        bool isATGC = false;
        for(int j = 0; j < T.size(); j++){
            if(S[i] == T[j]){
                isATGC = true;
            }
        }
        if(!isATGC){
            now = 0;
        }else{
            now++;
        }
        longest = max(now, longest);
    }
    
    cout << longest << endl;
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
C=[[int(x) for x in input().split()] for j in range(10)]
A=[[int(x) for x in input().split()] for j in range(H)]

def dijkstra(s):
  use=[0 for i in range(10)]
  d=[1000000000000 for j in range(10)]
  d[s]=0
  while True:
    v=-1
    for i in range(10):
      if use[i]==0 and (v==-1 or d[i]<d[v]):
        v=i
    if v==-1:
      break
    use[v]=1
    for j in range(10):
      d[j]=min(d[j],d[v]+C[v][j])
  return d[1]

ans=[0 for i in range(10)]
for i in range(10):
  ans[i]=dijkstra(i)

res=0
for i in range(W):
  for j in range(H):
    if A[j][i]!=-1:
      res+=ans[A[j][i]]
print(res)

Measured memory_bytes: 3316
#include <iostream>
#include <string>

int main(){
	int a;
	std::string s;
	std::cin >> a;
	std::cin >> s;
	if(a>=3200){
		std::cout << s << std::endl;
	}
	else{
		std::cout << "red" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# 12
# 12 6 3 1
# 12 4 1

def check(d, n):
    if d == 1: return False
    while n % d == 0:
        n //= d
    return n % d == 1

n = ni()
ans = 0
for d in range(1, n+1):
    if d*d > n: break
    if n % d == 0:
        if check(d, n):
            ans += 1
        if d * d < n and check(n//d, n):
            ans += 1

for d in range(1, n):
    if d*d > n-1: break
    if (n-1) % d == 0:
        if d != 1:
            ans += 1
        if d * d < n-1 and n//d != 1:
            ans += 1
print(ans)


Measured memory_bytes: 40940
n, m = map(int, input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
for r in range(n-m+1):
    for c in range(n-m+1):
        flg = True
        for i in range(m):
            for j in range(m):
                if B[i][j] != A[i+r][j+c]:
                    flg = False
                    break
        if flg:
            print('Yes')
            exit()
print('No')

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

string S;

int main(){
    cin>>S;

    int ans=0;
    for(int i=0;i<S.size()/2;i++){
        if(S[i]!=S[S.size()-i-1]){
            ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())

a, b = map(int, input().split())
mini = a+b
maxi = a+b

mini1 = a-b
maxi1 = a-b

for i in range(n-1):
    a, b = map(int, input().split())
    
    mini = min(a+b, mini)
    maxi = max(a+b, maxi)
    mini1 = min(a-b, mini1)
    maxi1 = max(a-b, maxi1)
    
ans = max(maxi-mini, maxi1-mini1)
print(ans)

Measured memory_bytes: 9148
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	return (len(dict(Counter(l))))
	

T = int(input())
L = []
for _ in range(T):
	l = input()
	L.append(l)
print(solve(L))



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int MAT=21;
struct Mat { ll v[MAT][MAT]; Mat(){ZERO(v);};};
const ll mo=1000000007;

Mat mulmat(Mat& a,Mat& b,int n=MAT) {
	ll mo2=4*mo*mo;
	int x,y,z; Mat r;
	FOR(x,n) FOR(y,n) r.v[x][y]=0;
	FOR(x,n) FOR(z,n) FOR(y,n) {
		r.v[x][y] += a.v[x][z]*b.v[z][y];
		if(r.v[x][y]>mo2) r.v[x][y] -= mo2;
	}
	FOR(x,n) FOR(y,n) r.v[x][y]%=mo;
	return r;
}

Mat powmat(ll p,Mat a,int n=MAT) {
	int i,x,y; Mat r;
	FOR(x,n) FOR(y,n) r.v[x][y]=0;
	FOR(i,n) r.v[i][i]=1;
	while(p) {
		if(p%2) r=mulmat(r,a,n);
		a=mulmat(a,a,n);
		p>>=1;
	}
	return r;
}


int T;
int N;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	Mat A;
	FOR(i,10) {
		A.v[i^1][i]=1;
		if(i%2==0) {
			for(j=1;j<10;j+=2) if(j>i+1) A.v[j][i]++;
			for(j=10;j<21;j++) A.v[j][i]++;
		}
	}
	for(i=10;i<21;i++) {
		for(j=i;j<21;j++) A.v[j][i]++;
	}
	
	cin>>T;
	while(T--) {
		cin>>N;
		
		if(N<5) {
			cout<<0<<endl;
		}
		else {
			Mat B=powmat(N-4,A);
			cout<<B.v[20][0]<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3616
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    x = int(input())

    ans = x // 11 * 2
    remainder = x % 11

    if remainder == 0:
        pass
    elif remainder <= 6:
        ans += 1
    else:
        ans += 2

    print(ans)


main()


Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; i++) {
        int A, B; cin >> A >> B; A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    int ans = N;
    vector<bool> visited(N);
    function<void(int, int)> recur = [&](int i, int k) {
        visited[i] = true;
        if (k == 0) return;
        for (int next : G[i]) if (!visited[next]) {
            recur(next, k-1);
        }
    };
    if (K % 2 == 0) {
        for (int i = 0; i < N; i++) {
            fill(begin(visited), end(visited), false);
            visited[i] = true;
            recur(i, K/2);
            ans = min<int>(ans, N-count(begin(visited), end(visited), true));
        }
    } else {
        for (int i = 0; i < N; i++) for (int j : G[i]) if (i < j) {
            fill(begin(visited), end(visited), false);
            visited[i] = visited[j] = true;
            recur(i, K/2);
            recur(j, K/2);
            ans = min<int>(ans, N-count(begin(visited), end(visited), true));
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/
//C++(GCC9.2.1)
/*---------------------文法の確認--------------------*/
//vector<型> 配列名(要素数, 初期値);    //初期値の指定
//配列変数.push_back(何とか）　　　　　　//配列の末尾に要素を追加
//配列変数.pop_back                    //配列の末尾の要素を削除
//sort(vec.begin(), vec.end())        //配列変数vecをソートする（要素を小さい順に並び替える
//reverse(vec.begin(), vec.end())     //配列変数vecの要素の並びを逆にする
//返り値の型 関数名(引数1の型 引数1の名前, 引数2の型 引数2の名前, ...) { //
//  処理                                                             //関数定義
//}                                                                 //
//参照先の型 &参照の名前 = 参照先;      //参照
/*int sum(int n) {
    if (n == 0) {
        return 0;
    }
                                                                    //再帰関数の例
    // sum関数の中でsum関数を呼び出している
    int s = sum(n - 1);
    return s + n;
}*/

/*---------------------終わり----------------------------------------------*/

//宣言

signed main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) cout << k << endl;
    else if (k <= a) cout << a << endl;
    else cout << a - (k - a - b) << endl;
    return 0;
}

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

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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

int func(int x,int y,int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

ll N;

int main()
{
    cin >> N;
    
    loop(i, 1, N + 1)
    { //1-Nまで
        int ans=0;
        int upper=int(floor(sqrt(i)));
        loop(x, 1, upper) //z>=y>=x関係
        {//1-upper-1
            loop(y, x, upper)
            {//x-upper-1
                loop(z, y, upper)
                {//y-upper-1
                    if(func(x,y,z)==i){
                        if(x==y && y==z){
                            ans++;
                        }else if (x==y || y==z || x==z)
                        {
                            ans+=3;
                        }else{
                            ans+=6;
                        }
                        
                    }
                }
            }
        }
        // cout<<"--"<<i<<"--"<<endl;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3624