akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) v.begin(),v.end()

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];

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

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



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

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int p[] = new int[n];
			int mini = 0;
			int count = 0;
			
			for(int i=0;i<n;i++) {
				p[i] = sc.nextInt();
			}
			
			
			
			for(int i=0;i<n;i++) {
				if(i==0) {
					mini = p[i];
				}
				else {
					mini = Math.min(mini, p[i]);
				}
				
				if(mini<p[i]) {
					count++;
				}
			}
			
			System.out.println(n-count);
			
			
		}

	}

Measured memory_bytes: 67020
L,R = map(int,input().split())

if R-L >= 2100 :
    ans = 0
else :
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j)%2019 < ans :
                ans = (i*j)%2019
                if ans == 0 :
                    break

print(ans)


Measured memory_bytes: 9096
import java.util.HashMap;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		HashMap<String, Integer> map = new HashMap<>();
		map.put("SAT", 1);
		map.put("FRI", 2);
		map.put("THU", 3);
		map.put("WED", 4);
		map.put("TUE", 5);
		map.put("MON", 6);
		map.put("SUN", 7);
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		System.out.println(map.get(s));
	}
}


Measured memory_bytes: 20820
def main():
  _max = max
  _range = range
  _input = input
  h, w = map(int, _input().split())
  s = [_input() + '#' for _ in _range(h)]
  s.append('#' * (w + 1))

  rt = [[-1] * w for _ in _range(h + 1)]

  tstart = [-1] * (w + 1)
  for i in _range(h + 1):
    si = s[i]
    rti = rt[i]
    ystart = -1
    for j in _range(w + 1):
      tj = tstart[j]
      if si[j] == '#':
        if ystart != -1:
          jy = j - ystart
          for k in _range(ystart, j):
            rti[k] += jy
          ystart = -1
        if tj != -1:
          itj = i - tj
          for k in _range(tj, i):
            rt[k][j] += itj
          tstart[j] = -1
      else:
        if ystart == -1:
          ystart = j
        if tj == -1:
          tstart[j] = i

  print(_max(map(_max, rt)))

main()


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

using namespace std;

int R,C;
int cnt;
int s = 0;
bool sen[11][10001];
bool flg[11];

int fnc(){
	int ret = 0;
	int senc[R+1][C+1];

	for(int i = 1;i <= R;i++){
		for(int j = 1;j <= C;j++){
			senc[i][j] = sen[i][j];
			if(flg[i] == 1){
				if(senc[i][j] == 1){
					senc[i][j] = 0;
				}else if(senc[i][j] == 0){
					senc[i][j] = 1;
				}
			}
		}
	}

	// for(int i = 1;i <= R;i++){
	// 	for(int j = 1;j <= C;j++){
	// 		cout << senc[i][j] <<" ";
	// 	}
	// 	printf("\n");
	// }

	int sum1;
	int sum0;
	int sum;

	for(int i = 1;i <= C;i++){
		sum1 = 0;
		sum0 = 0;
		for(int j = 1;j <= R;j++){
			if(senc[j][i] == 1)sum1++;
			if(senc[j][i] == 0)sum0++;
		}
		sum = max(sum1,sum0);
		//cout << sum << endl;
		ret += sum;
	}
	//cout << ret <<" "<< ++s << endl ;
	return ret;
}

int solve(int d){
	int ret = 0;

	if(d == R)return fnc();

	ret = max(ret,solve(d+1));
	flg[d+1] = 1;
	ret = max(ret,solve(d+1));
	flg[d+1] = 0;
	//cout << ret << endl;
	return ret;
}

int main(){
	while(cin >> R >> C,R){
		fill_n(flg,11,0);
		fill_n(*sen,11*10001,0);

		for(int i = 1;i <= R;i++){
			for(int j = 1;j <= C;j++){
				cin >> sen[i][j];
			}
		}
		cout << solve(0) << endl;
	} 
	return 0;
}

Measured memory_bytes: 3584
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
ans = 0
a = 0
while a != A.first+1 do
  b = 0
  while b != B.first+1 do
    c = 0
    while c != C.first+1 do
      if((a*500+b*100+c*50)==X.first)
        ans += 1
      end
      c += 1
    end
    b += 1
  end
  a += 1
end
puts ans

Measured memory_bytes: 1788
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 998244353
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, K = NMI()
    LR = [NLI() for _ in range(K)]
    dp = [0] * (N*2+10)
    dp[1] = 1
    now = 0

    for i in range(1, N+1):
        now = (now + dp[i]) % MOD
        for l, r in LR:
            dp[i+l] = (dp[i+l] + now) % MOD
            dp[i+r+1] = (dp[i+r+1] - now) % MOD

    print(dp[N])


if __name__ == "__main__":
    main()

Measured memory_bytes: 24732
int main(int argc,const char*argv[])
{
    int S,h,m,s;
    scanf("%d",&S);
    
    h=S/3600;
    m=S/60-60*h;
    s=S%60;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
#include<iostream>

static inline void eat(const char s, int& i)
{
  if(s == '+')
    i++;
  else
    i--;
}
int main()
{
  char s;
  int n = 0;
  for(int i = 0; i < 4; ++i)
  {
    std::cin >> s;
    eat(s, n);
  }
  std::cout << n << std::endl;
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; ++i){
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    int max = l[0];
    int others = 0;
    for (int i=1; i<n; ++i){
        others += l[i];
    }
    if (max < others){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

void solve(ll index){
	ll n;
	cin >> n;
	map<ll,ll> m;
	forn(i,n) {
		ll t1;
		cin >> t1;
		m[t1]++;
	}
	if(m.find(0)!=m.end() && (ll)m.size()==1){
		cout << "Yes" << ln;
	}
	else if(n%3){
		cout << "No" << ln;
	}
	else if((ll)m.size()==2){
		if(m[0]==n/3) cout << "Yes" << ln;
		else cout << "No" << ln;
	}
	else if((ll)m.size()==3){
		ll temp = -1;
		bool bo=1;
		ll now=0;
		for(auto it : m){
			if(temp==-1){
				temp = it.se;
			}
			if(temp!=it.se){
				bo = 0;
			}
			now ^= it.fi;
		}
		if(bo && !now) cout << "Yes" << ln;
		else cout << "No" << ln;
	}
	else{
		cout << "No" << ln;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve(i+1);
    return 0;
}

Measured memory_bytes: 5120
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 405
#define MOD 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, C, A[maxN], B[maxN];
ll power[maxN][maxN], pref[maxN][maxN], dp[maxN][maxN];

int main () {
    scanf("%d%d", &n, &C);
    fto(i, 1, n) scanf("%d", &A[i]);
    fto(i, 1, n) scanf("%d", &B[i]);

    fto(i, 1, maxN-1) {
        power[i][0] = 1;
        fto(j, 1, maxN-1) power[i][j] = (power[i][j-1]*i)%MOD;
    }
    fto(i, 1, maxN-1) {
        fto(j, 0, maxN-1) pref[i][j] = (pref[i-1][j]+power[i][j])%MOD;
    }

    dp[0][0] = 1;
    fto(i, 1, n) {
        fto(k, 0, C) {
            fto(j, 0, k) dp[i][k] = (dp[i][k]+dp[i-1][k-j]*(pref[B[i]][j]-pref[A[i]-1][j]+MOD))%MOD;
        }
    }

    printf("%lld", dp[n][C]);


    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

double fr(double a, double b, double c){
    if( a > b ) swap(a, b);
    if( b > c ) swap(b, c);
    return sqrt( a*a + b*b );
}

int main(){
    double a, b, c;
    while( cin >> a >> b >> c, a||b||c ){
        double r = fr(a, b, c);
        int n;
        cin >> n;
        while( n-- > 0 ){
            double rr;
            cin >> rr;
            if( 2*rr > r ){
                cout << "OK" << endl;
            }else{
                cout << "NA" << endl;
            }
        }
    }
    return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int x;
    cin >> x;
    cout << x / 500 * 1000 + (x%500) / 5 * 5 << endl;
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] d = new int[n];
    Arrays.fill(d, -1);
    int m = sc.nextInt();
    for (int i = 0; i < m; i++) {
      int si = sc.nextInt() - 1;
      int ci = sc.nextInt();
      if(d[si] != -1 && d[si] != ci){
        System.out.println(-1);
        return;
      }
      if(n != 1 && si == 0 && ci == 0){
        System.out.println(-1);
        return;
      }
      d[si] = ci;
      a[si] = ci;
    }
    if(d[0] == -1 && n != 1){
      a[0] = 1;
    }
    int answer = 0;
    int pow = 1;
    for(int i = 0; i < n; i++){
      answer += a[n - 1 - i] * pow;
      pow *= 10;
    }
    System.out.println(answer);
  }
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MOD = 998244353;
const int MAX = 4000 + 5;
int comb[MAX][MAX], pot[MAX];
int k, n;

inline int add(int a, int b) {
    a += b;
    if(a >= MOD) {
        a -= MOD;
    }
    return a;
}

inline int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> k >> n;
    fori(i, 0, MAX) {
        fori(j, 0, i + 1) {
            if(i == j || j == 0) {
                comb[i][j] = 1;
            }
            else {
                comb[i][j] = add(comb[i - 1][j], comb[i - 1][j - 1]);
            }
        }
    }
    pot[0] = 1;
    fori(i, 1, MAX) {
        pot[i] = mult(pot[i - 1], 2);
    }
    fori(i, 2, 2 * k + 1) {
        int ans = 0;
        if(i % 2 == 0) {
            int homp = min(k, i - 1);
            int p = max(0, homp - i / 2);
            fori(q, 0, min(p, n) + 1) {
                int total = mult(comb[p][q], pot[q]); 
                int symbols = q + k - 2 * p - 2;
                int desired = n - q;
                total = mult(total, comb[symbols + desired][symbols]);
                ans = add(ans, total);
            }
            fori(q, 0, min(p, n - 1) + 1) {
                int total = mult(comb[p][q], pot[q]); 
                int symbols = q + k - 2 * p - 2;
                int desired = n - q - 1;
                total = mult(total, comb[symbols + desired][symbols]);
                ans = add(ans, total);
            }
        }
        else {
            int homp = min(k, i - 1);
            int p = max(0, homp - i / 2);
            fori(q, 0, min(p, n) + 1) {
                int total = mult(comb[p][q], pot[q]); 
                int symbols = q + k - 2 * p - 1;
                int desired = n - q;
                total = mult(total, comb[symbols + desired][symbols]);
                ans = add(ans, total);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 61568
# D - Sum of Divisors
N = int(input())
ans = (1 + N) * N

for i in range(2, N//2 + 1):
	j = 2
	
	while True:
		if i * j <= N:
			
			ans += i * j
			j += 1
		else:
			break

print(ans - 1)

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

int main(){
    long long int n, k;
    cin >> n >> k;
    vector<int> h(n);
    long long int result = 0;

    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }

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

    for(int i = 0; i < n - k; i++){
        result += h.at(i);
    }

    cout << result << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    
int n;
cin>>n;
vector<int> arr(n,0);

for(int i=0;i<n;i++)
cin>>arr[i];

int count=0;
for(int i=0;i<n;i+=2)
{
    if(arr[i]%2==1)
    count++;
}
cout<<count<<endl;

}

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

using namespace std;

#define int long long
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

int G[505][505];

signed main()
{
  int n, m;
  while(cin >> n >> m, n || m) {
    fill(G[0], G[505], inf);
    int cnt = 0;
    map<string, int> stat;
    string s, p, g; cin >> s >> p >> g;
    stat[s] = cnt++; stat[p] = cnt++; stat[g] = cnt++;
    while(m--) {
      string a, b; int d, t;
      cin >> a >> b >> d >> t;
      if(stat.find(a) == stat.end()) stat[a] = cnt++;
      if(stat.find(b) == stat.end()) stat[b] = cnt++;
      G[stat[a]][stat[b]] = G[stat[b]][stat[a]] = d / 40 + t;
    }
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
	for(int k = 0; k < n; k++) G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
      }
    }
    cout << G[stat[s]][stat[p]] + G[stat[p]][stat[g]] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5216
import sys

def r(n, k, sl):

    sl.sort(key=lambda x: -x[1])

    gmk = set()
    gop = 0
    ce = []
    for ti, di in sl[:k]:
        if ti in gmk:
            ce.append(di)
        gmk.add(ti)
        gop += di

    gscr = len(gmk)**2 + gop

    for ti, di in sl[k:]:
        if 0 >= len(ce):
            break
        if ti in gmk:
            continue
        gmk.add(ti)
        odi = ce.pop()
        gop = gop - odi + di
        nscr = len(gmk)**2 + gop
        gscr = max(gscr, nscr)

    return gscr


def main():
    input = sys.stdin.readline
    n, k = list(map(int, input().split()))
    sl = [tuple(map(int, input().split())) for _ in range(n)]
    print(r(n, k, sl))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21400
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  int d=10000000;
  int ans;
  for(int i=0;i<n;i++){
    if(d>abs(a*1000-t*1000+h[i]*6)){
      d=abs(a*1000-t*1000+h[i]*6);
      ans=i+1;
    }
  }
  cout << ans << endl;
}            

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

int main() {
  string S,T; 
  cin>>S>>T;
  bool flag=false;
  if(S==T)flag=true;
  rep(i,S.size()-1){
    char X = S[S.size()-1];
    S.pop_back();
    S = X+S;
    if(S==T)flag=true;
  }
  if(flag)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    string s;
    cin>>s;
    int con =0;
    int ans = 0;

    rep(i,3)
    {
        if(s[i]=='R') con ++;
        else
        {
            ans = max(con,ans);
            con=0;
            
        }
    }

    ans = max(con,ans);

    cout<<ans<<endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
vector<ll> x;
ll p[110000];
int main(){
  ll n,k,suml=0,sumr=0,c=0,st,ans=0;
  cin>>n>>k;
  string s,r;
  cin>>s;
  rep(i,0,n-1){
      if(s[i]!=s[i+1]&&k>0){
          i++;
          r[0]=s[i];
          if(s[i]=='L')s[i]='R';
          else s[i]='L';
          while(r[0]==s[i+1]){
              if(s[i+1]=='L')s[i+1]='R';
              else s[i+1]='L';
              i++;
          }
          k--;
      }
  }
  rep(i,0,n-1)if(s[i]=='L' && s[i]==s[i+1])suml++;
  rep(i,0,n-1)if(s[i]=='R' && s[i]==s[i+1])suml++;
  cout<<suml;
}

Measured memory_bytes: 512
A, B, C, K = map(int, input().split())

ans = 0
if 0 <= K - A:
    K -= A
    ans += A
else:
    print(K)
    exit()

if K == 0:
    print(ans)
    exit()

if 0 <= K - B:
    K -= B
else:
    print(ans)
    exit()

if K == 0:
    print(ans)
    exit()


if 0 <= K - C:
    ans += -1 * C
else:
    print(ans - K)
    exit()

print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main(){
	ll a,b,c=1,d=0,ans=0;
	cin >>a>>b;
	while(c < b){
		c -= 1;
		c += a;
		ans++;
	}
	cout << ans <<endl;
	return 0;

}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


N, M = map(int, input().split())

u = UnionFind(N+1)

for i in range(M):
    A, B = map(int, input().split())
    u.union(A, B)

print(max([u.get_size(i) for i in range(1, N+1)]))

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

void Main() {
  char a;
  cin >> a;
  if (a < 'a') cout << "A" << endl;
  else cout << "a" << endl;
}

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



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  long double ans=0.0;
  for(int i=1;i<=N;i++){
    double res=1.0;
    int tmp=i;
    while(tmp<=K-1){
      tmp*=2;
      res*=0.5;
    }
    ans+=res;
  }

  cout<<fixed<<setprecision(12)<<ans/N<<endl;

  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; ++i){
		int n,m;
		cin >> n >> m;
		ans += m - n + 1;
	}
	cout << ans << endl;

	return 0;
}



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

int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool ok = true;
    for(int i=0;i<a;i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i=a+1;i<a+b+1;i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

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

int main() {
    int N;  cin >> N;
    map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string s;  cin >> s;
        ++mp[s];
    }
    auto itr_max = mp.begin();
    int cnt_max = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second > cnt_max) {
            itr_max = itr;
            cnt_max = itr->second;
        }
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second == itr_max->second) cout << itr->first << endl;
    }
}


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

int main()
{
  string s;
  cin >> s;
  
  if (s == "SUN") cout << 7;
  else if (s == "SAT") cout << 1;
  else if (s == "FRI") cout << 2;
  else if (s == "THU") cout << 3;
  else if (s == "WED") cout << 4;
  else if (s == "TUE") cout << 5;
  else if (s == "MON") cout << 6;
  else cout << -1;
  
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    char ch = fgetc(stdin);
    int rez = 0;
    char s[7] = {'a', 'e', 'i', 'o', 'u'};
    for (int i = 0; i < 5; i++)
        if(ch == s[i])
            rez = 1;
    if (rez == 1)
        printf("vowel");
    else
        printf("consonant");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K;cin>>N>>K;
  vector<long>H(N);
  for(long i=0;i<N;i++)cin>>H[i];
  sort(H.begin(),H.end(),greater<long>());
  long ans=0;
  for(long i=0;i<N;i++){
    if(K>0)K--;
    else ans+=H[i];
  }
  cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

long long N;
long long M;
long long Q;
std::vector<long long> a(Q);
std::vector<long long> b(Q);
std::vector<long long> c(Q);
std::vector<long long> d(Q);
ll ma=0;
void dfs(vector<ll> v){
    if(v.size()==N){
        ll sum=0;
        for (long long i = 0; i < Q; i++) if(v[b[i]-1]-v[a[i]-1]==c[i]) sum+=d[i];
        chmax(ma,sum);
    }else{
        for (long long i = v[v.size()-1]; i <= M; i++) {
            vector<ll> t=v;
            t.push_back(i);
            dfs(t);
        }
    }
}

int main(){
    scanf("%lld",&N);
    scanf("%lld",&M);
    scanf("%lld",&Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }

    vector<ll> v={1};
    dfs(v);
    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 3696
#include<stdio.h>
int main () {
	int n , x , count = 0;
	int i , s , j;
	while(1) {
		scanf("%d %d" , &n , &x);
		if (n == 0 && x == 0) break;
		count = 0;
		for(i = 1; i <= n; i++) {
			for(s = i + 1; s <= n; s++) {
				for(j = s + 1; j <= n; j++) {
					if (i + s + j == x) count++;
				}
			}
		}
		printf("%d\n" , count);
	}
}

Measured memory_bytes: 600
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
struct A{
    ll count0 = 0;
    ll sum = 0;
    ll num = 0;
};


A f(A n){
    A temp;
    temp.count0 = 0;
    temp.sum = 0;
    temp.num = 0;
    if(n.num < 10){
        temp.count0 = 1;
        temp.sum = n.num;
        return temp;
    }
    ll x = 10;
    temp.sum += n.num;
    temp.count0 ++;
    while(n.num > x){
        //p123
        ll l = n.num / x;
        ll r = n.num % x;
        A temp0;
        temp0.num = l;
        temp0.count0 = 0;
        temp0.sum = 0;
        temp0 = f(temp0);
        temp.count0 += temp0.count0;
        temp.sum += temp0.count0*r+temp0.sum;
        x *= 10;
    }
    return temp;
}


int main(){
    ll n;
    sld(n)
    A x;
    x.count0 = 0;
    x.sum = 0;
    x.num = n;
    x = f(x);
    //pld(x.count0) pn
    //pld(x.num) pn
    pld(x.sum) pn


    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int x; cin >> x;
	int a; cin >> a;
	int b; cin >> b;
	cout << (x - a) % b << endl;
    return;
}

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



Measured memory_bytes: 256
n = int(input())
alphabets = [chr(i) for i in range(97, 97+26)]
alphab_num = {}
for a in alphabets:
    alphab_num[a] = [0]*n
for i in range(n):
    s = input()
    for ss in s:
        alphab_num[ss][i] += 1

ans = ''
for a in alphabets:
    for _ in range(min(alphab_num[a])):
        ans += a
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n,x,t;cin>>n>>x>>t;
  int m=(n-1)/x+1;
  int res=m*t;
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3588
using System;
class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int K = int.Parse(input[1]);
    string S = Console.ReadLine();
    
    int hpy = Hpy(S, N);
    int X = 0, Y = 0; // X=(+2できる回数), Y=(+1できる回数)
    
    X = (CountStr(S, "RL") + CountStr(S, "LR")) / 2;
    
    if (S.Substring(0, 1) != S.Substring(S.Length - 1, 1))
    {
      Y = 1;
    }
    
    // 操作
    if (K <= X)
    {
      hpy += K * 2;
    }
    else
    {
      hpy += X * 2 + Y;
    }
    
    Console.WriteLine(hpy);
  }
  
  static int Hpy(string S, int N)
  {
    int buf = 0;
    for (int i = 1; i < N; i++)
    {
      if (S.Substring(i-1, 1) == S.Substring(i, 1))
      {
        buf++;
      }
    }
    return buf;
  }
  
  static int CountStr(string S, string str)
  {
    return (S.Length - S.Replace(str, "").Length) / str.Length;
  }
}

Measured memory_bytes: 17336
#include<bits/stdc++.h>
using namespace std;
int n;
int b[105];
int ans;
int main() {
	cin>>n;
	for(int i=1;i<n;i++) cin>>b[i];
	if(n==2) {cout<<2*b[1];return 0;}
	ans+=b[1]+b[n-1];
	for(int i=1;i<n-1;i++) ans+=min(b[i],b[i+1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    int x,y; cin >> x >> y;
    if(y >= x*2 && y <= x*4 && y%2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

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

const double EPS = 1e-5;
const int MOD = 1e9+7;

const int N = 50;
const int M = 50;

vector<string> a,b;

int n,m;

int main(){
  string str;
  int count;
  int al,bl;
  cin >> n >> m;

  repn(i,n){
    cin >> str;
    a.emplace_back(str);
  }

  repn(i,m){
    cin >> str;
    b.emplace_back(str);
  }

  //cout << endl;

  repn(i,n-m+1){
    repn(j,n-m+1){
      //cout << a[i].substr(j,m) << " " << b[0] << endl;
      if(a[i].substr(j,m) == b[0]){
        //cout << "match" << endl;
        count = 1;
        for(al = i + 1, bl = 1; bl < m ; ++al, ++bl){
          if(a[al].substr(j,m) == b[bl]){
            ++count;
          }else{
            break;
          }
        }
        if(count == m){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    int n, k;
    cin >> n >> k;
    VI a(n);
    FOR (i, 0, n)
        cin >> a[i];

    FOR (j, 0, k) {
        VI ans(n+1);
        FOR (i, 0, n+1) {
            ans[min(n, i + a[i] + 1)]--;
            ans[max(0, i - a[i])]++;
        }
        FOR (i, 1, n+1)
            ans[i] += ans[i-1];

        assert(ans[n] == 0);

        FOR (i, 0, n) {
            if (ans[i] != n)
                goto bad;
        }
        a = ans;
        break;
        bad: a = ans;
    }
    FOR (i, 0, n)
        cout << a[i] << " ";
    cout << "\n";
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 5576
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main()
{
	int N, i, A[100000], ord[100000];
	
	scanf("%d", &N);
	
	lop(i, N){
		scanf("%d", &A[i]);
		ord[A[i]]=i;
	}
	
	lop(i, N){
		printf("%d ", ord[i]);
	}
	
return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    ll x, ans;
    cin>>x;
    
    ans = (x/11);
    x -= ans*11;
    ans *= 2;
    //cout<<ans;
    if(x>6){
        cout1(ans+2);
    }else if(x>0){
        cout1(ans+1);
    }else{
        cout1(ans);
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NW = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, W) = (NW[0], NW[1]);
        var wv = new (int w, int v)[N];
        for (int i = 0; i < N; i++)
        {
            var _wv = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            wv[i] = (_wv[0], _wv[1]);
        }

        void ChMin<T>(ref T min, T value) where T : IComparable { if (value.CompareTo(min) < 0) min = value; }
        void ChMax<T>(ref T max, T value) where T : IComparable { if (value.CompareTo(max) > 0) max = value; }

        var dp = new long[N + 1, 100100];
        for (int i = 0; i < dp.GetLength(0); i++)
            for (int j = 0; j < dp.GetLength(1); j++)
                dp[i, j] = long.MaxValue>>2;

        dp[0, 0] = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < 100100; j++)
            {
                ChMin(ref dp[i + 1, j], dp[i, j]);
                if (j >= wv[i].v)
                    ChMin(ref dp[i + 1, j], dp[i, j - wv[i].v] + wv[i].w);
            }
        }

        var ans = 0;
        for (int j = 0; j < 100100; j++)
        {
            if (dp[N, j] <= W)
                ChMax(ref ans, j);
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 120184
#include <cstdio>
int main()
{
    int a, b;
    char ch;
    while (true)
    {
        scanf("%d %c %d", &a, &ch, &b);
        if (ch == '?')
            break;
        switch (ch)
        {
        case '+':
            printf("%d\n", a + b);
            break;
        case '-':
            printf("%d\n", a - b);
            break;
        case '*':
            printf("%d\n", a * b);
            break;
        case '/':
            printf("%d\n", a / b);
            break;
        default:
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2684
N, M, Q = map(int, input().split())

x = [[0 for j in range(N + 1)] for i in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    x[L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i][j - 1]

for j in range(1, N + 1):
    for i in reversed(range(1, N + 1)):
        x[i - 1][j] += x[i][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(x[p][q])


Measured memory_bytes: 9460
#include <cstdio>
#include <functional>
#include <algorithm>
using namespace std;

int x[100010];
int diff[100010];

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    int n, k; scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
      scanf("%d", x+i);
    }
    if (k >= n) {
      puts("0");
      continue;
    }
    for (int i = 0; i < n-1; ++i) {
      diff[i] = x[i+1] - x[i];
    }
    sort(diff, diff+n-1, greater<int>());
    int sum = 0;
    for (int i = 0; i < k-1; ++i) {
      sum += diff[i];
    }
    printf("%d\n", x[n-1] - x[0] - sum);
  }
}

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

using namespace std;

#ifdef NeverBeRed
//#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second

template<typename T, typename U>
T pow_mod(T a, U b, int mod)
{
	T r = 1;
	for (; b > 0; b >>= 1)
	{
		if (b & 1) r = (ll)r * a % mod;
		a = (ll)a * a % mod;
	}
	return r;
}

namespace ntt
{
	const int mod = 924844033;
	const int root = 5; // primitive root of mod

	int base = 1;
	vector<int> roots;

	void ensure_base(int nbase)
	{
		if (nbase <= base) return;
		roots.resize(nbase);
		for (int mh = base; mh << 1 <= nbase; mh <<= 1)
		{
			int wm = pow_mod(root, (mod - 1) / (mh << 1), mod);
			roots[mh] = 1;
			for (int i = 1; i < mh; ++i)
				roots[i + mh] = (ll)roots[i + mh - 1] * wm % mod;
		}
		base = nbase;
	}

	void fft(int a[], int n, int sign)
	{
		ensure_base(n);

		for (int i = 1, j = 0; i < n - 1; ++i)
		{
			for (int k = n >> 1; (j ^= k) < k; k >>= 1);
			if (i < j) swap(a[i], a[j]);
		}

		for (int m, mh = 1; (m = mh << 1) <= n; mh = m)
			for (int i = 0; i < n; i += m)
				for (int j = i; j < i + mh; ++j)
				{
					int y = (ll)a[j + mh] * roots[j - i + mh] % mod;
					if ((a[j + mh] = a[j] - y) < 0) a[j + mh] += mod;
					if ((a[j] += y) >= mod) a[j] -= mod;
				}

		if (sign < 0)
		{
			int inv = pow_mod(n, mod - 2, mod);
			for (int i = 0; i < n; ++i) a[i] = (ll)a[i] * inv % mod;
			reverse(a + 1, a + n);
		}
	}

	vector<int> convolve(vector<int> x, vector<int> y)
	{
		int n = x.size() + y.size() - 1, sz = 1;
		while (sz < n) sz <<= 1;
		x.resize(sz);
		y.resize(sz);
		fft(x.data(), sz, +1);
		fft(y.data(), sz, +1);
		for (int i = 0; i < sz; ++i)
			x[i] = (ll)x[i] * y[i] % mod;
		fft(x.data(), sz, -1);
		x.resize(n);
		return x;
	}
}

namespace combinatorics
{
	const int mod = 924844033, N = 2e5+5; // mod must be prime
	int fac[N], ifac[N];

	void init()
	{
		fac[0] = ifac[0] = 1;
		for (int i = 1; i < N; ++i)
		{
			fac[i] = (ll)fac[i-1] * i % mod;
			ifac[i] = pow_mod(fac[i], mod-2, mod);
		}
	}

	int comb(int n, int k)
	{
		return (ll)fac[n] * ifac[n-k] % mod * ifac[k] % mod;
	}
}

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

	int n;
	cin >> n;
	vector<vector<int>> adj(n);
	for (int i = 1, u, v; i < n; ++i)
	{
		cin >> u >> v;
		--u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	vector<int> c(n), sz(n);
	function<void(int, int)> dfs = [&](int u, int p)
	{
		sz[u] = 1;
		for (auto v : adj[u])
			if (v != p)
			{
				dfs(v, u);
				sz[u] += sz[v];
				++c[sz[v]];	
			}
		++c[n - sz[u]];
	};
	dfs(0, -1);

	using namespace combinatorics;
	init();
	
	vector<int> y(n+1);
	for (int i = 0; i < n; ++i)
	{
		c[i] = (ll)c[i] * fac[i] % mod;
		y[n-1-i] = ifac[i];
	}

	auto r = ntt::convolve(c, y);
	for (int i = 0; i < n; ++i)
		cout << (((ll)n * comb(n, i+1) - (ll)r[n+i] * ifac[i+1]) % mod + mod) % mod << "\n";

	return 0;
}


Measured memory_bytes: 37216
from collections import defaultdict
N, M=map(int, input().split())
A=list(map(int, input().split()))
d=defaultdict(int)
for a in A:
  d[a]+=1
for i in range(M):
  B, C=map(int, input().split())
  d[C]+=B
index_list=sorted(d)
ans=0
ans_size=0
for i in range(len(index_list)-1, -1, -1):
  card=index_list[i]
  if d[card]+ans_size>=N:
    ans+=(N-ans_size)*card
    break
  else:
    ans+=d[card]*card
    ans_size+=d[card]
print(ans)

Measured memory_bytes: 87320
#include <stdio.h>
int main(void){
    long a, b, c, d;
    scanf("%ld %ld %ld %ld ", &a, &b, &c, &d);
    long max = a * c;
    if(max < a * d) max = a * d;
    if(max < b * c) max = b * c;
    if(max < b * d) max = b * d;
    printf("%ld\n",max);
}


Measured memory_bytes: 2156
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B;
  cin>>B>>A;
  A--;
  B--;
  char ans[100][100];
  for(int i=0;i<100;++i) {
    for(int j=0;j<100;++j) {
      if(i<50) ans[i][j] = '.';
      else ans[i][j] = '#';
    }
  }
  for(int i=1;i<99;++i) {
    for(int j=1;j<99;++j) {
      if(i%2==0) continue;
      if(A>0) {
        if(ans[i-1][j]=='.' && ans[i][j-1]=='.' && ans[i+1][j]=='.' && ans[i][j+1]=='.') {
          ans[i][j] = '#';
          A--;
        }
      }
      else if(B>0) {
        if(ans[i-1][j]=='#' && ans[i][j-1]=='#' && ans[i+1][j]=='#' && ans[i][j+1]=='#') {
          ans[i][j] = '.';
          B--;
        }
      }
    }
  }
  cout<<100<<" "<<100<<endl;
  for(int i=0;i<100;++i) {
    for(int j=0;j<100;++j) {
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3648