akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N, M;
int s[12][12];
int p[12];

signed main()
{
	cin >> N >> M;
	memset(s, -1, sizeof s);
	rep(i, M) {
		int k; cin >> k;
		rep(j, k) cin >> s[i][j], --s[i][j];
	}
	rep(i, M) cin >> p[i];

	int ans = 0;

	for (int S = 0; S < (1 << N); ++S) {
		bool ok = true;

		rep(i, M) {
			int counter = 0;
			rep(j, N) {
				if (s[i][j] != -1) {
					counter += (S >> s[i][j]) & 1;
				}
			}

			if (counter % 2 != p[i]) ok = false;
		}

		if (ok) ans++;
	}

	cout << ans << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
int N;
vector<int> G[100005];
int color[100005];
unordered_map<string, int> M;
int color_count;

void bfs() {
  queue<P> que;
  que.push(make_pair(0,0));
  while(!que.empty()) {
    P p = que.front(); que.pop();
    int now = p.first;
    int c = p.second;
    int color_idx = 0;
    rep(j, G[now].size()) {
      int next = G[now][j];
      int a = now, b =next;
      if (now > next) swap(a, b);
      string t = to_string(a)+'-'+to_string(b);
      int idx = M[t];
      if (color[idx] >= 0) continue;
      if (color_idx==c) color_idx++;
      if (color_idx>=color_count) color_idx=0;
      color[idx] = color_idx;
      que.push(make_pair(next, color_idx));
      color_idx++;
    }
  }
}

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

  cin >> N;
  int a,b;
  rep(i, N-1) {
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    string t = to_string(a)+'-'+to_string(b);
    M[t]=i;
  }

  rep(i, N) {
    int d = G[i].size();
    color_count = max(color_count, d);
  }
  fill(color, color+N, -1);
  bfs();
  cout << color_count << "\n";
  rep(i, N-1) cout << color[i]+1 << "\n";
  return 0;
}

Measured memory_bytes: 18340
#include<stdio.h>
#include<math.h>
int main(void)
{
    long long int a,b,n;
    scanf("%lld",&n);
    for(a=sqrt(n);a>0;a--)
    {
        if(n%a==0)
        {
            b=n/a;
            break;
        }
    }
    printf("%lld",a+b-2);
    return 0;
}

Measured memory_bytes: 128
/*
 * ALDS1_3_B.cpp
 *
 *  Created on: Apr 25, 2018
 *      Author: 13743
 */

#include<iostream>
#include<queue>

using namespace std;

struct Process {
	char name[10];
	int time;
};

int main() {
	int n, q;
	cin >> n >> q;
	queue<Process> flow;
	for(int i=0; i<n; i++) {
		Process pr;
		cin >> pr.name >> pr.time;
		flow.push(pr);
	}

	int nowTime = 0;
	while(!flow.empty()) {
		Process pr = flow.front();
		flow.pop();
		pr.time -= q;
		nowTime += q;
		if(pr.time <= 0) {
			nowTime += pr.time;
			cout << pr.name << " " << nowTime << endl;
			continue;
		}
		flow.push(pr);
	}
}





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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int x;
  cin >> x;
  if(x < 1200){
    cout << "ABC" << endl;
  }else{
    cout << "ARC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
alpha = []
while True:
    n = float(raw_input())
    if n == 0:
        break
    nums_str = raw_input().split()
    nums = []
    for s in nums_str:
        nums.append(float(s))
    ave = sum(nums)/n
    n_sum = 0.0
    for num in nums:
        n_sum += (num-ave)**2
    alpha.append(n_sum/n)
for a in alpha:
    print math.sqrt(a)

Measured memory_bytes: 6496
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let mut ans = 0;
    let mut i = 0;
    let mut stack = Vec::new();

    while i < s.len() {
        if i < s.len() - 1 {
            if s[i] != s[i + 1] {
                ans += 2;
                i += 2;
                continue;
            }
        }
        if !stack.is_empty() {
            if *stack.last().unwrap() != s[i] {
                stack.pop();
                ans += 2;
                i += 1;
                continue;
            }
        }
        stack.push(s[i]);
        i += 1;
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, tmp;
	cin>>n;
	cin>>tmp;
	int ans=0;
	REP(i, n-1){
		cin>>a;
		if(a==tmp){
			++ans;
			tmp=1000;
		}
		else{
			tmp=a;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
var
  ch:char;
  st:string;
begin
  while not eof do
   begin
     read(ch);
     if (ch='1') or (ch='0') then st:=st+ch;
     if (ch='B') and (length(st)>0) then delete(st,length(st),1);
   end;
  writeln(st);
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n;
    cin >> n;
    vector<bool> v(n), v2(n-1);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        v[i] = x == 1;
    }
    for (int i = 0; i < n-1; ++i) {
        v2[i] = v[i]^v[i+1];
    }
    int ans = 0, a = 0, b = 0, c = 0;
    for (int i = 0; i < n-1; ++i) {
        if(v2[i]) {
            a++; b++; c++;
        }else {
            c = b+1;
            b = a+1;
            a = 0;
        }
        ans = max({ans, a, b, c});
    }
    cout << ans+1 << "\n";
    return 0;
}



Measured memory_bytes: 3228
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> u, std::vector<long long> v){

    i64 ans = n * (n + 1) * (n + 2) / 6;
    for(int i = 0; i < n - 1; ++i){
        if(u[i] > v[i])
            swap(u[i], v[i]);
        --u[i];
        i64 preans = ans;
        i64 len = v[i] - u[i];
        ans -= (u[i] + 1) * (n - v[i] + 1);
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> u(N-1);
    std::vector<long long> v(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(u), std::move(v));
    return 0;
}


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

int main() {
    int X, rest;
    cin>>X;
    int five = X/500;
    rest = (X - five*500) / 5;
    long happy = five * 1000 + rest * 5;
    cout << happy << endl;    
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int a,b,c; cin >> a >> b >> c;
        if((b-a)==(c-b))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool a[100001];
int main()
{
	int n;
	cin>>n;
	int li,lj;
	for(int i=1;i<=n;i++)
	{
		cin>>li>>lj;
		for(int j=li;j<=lj;j++)
		{
			a[j]=1;
		}
	}
	int ans=0;
	for(int i=0;i<=100001;i++)if(a[i])ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n, a, b, c, d int
	var s string
	fmt.Scan(&n, &a, &b, &c, &d, &s)
	a, b, c, d = a-1, b-1, c-1, d-1

	x := c
	if x < d {
		x = d
	}
	for i := a; i < x; i++ {
		if s[i] == '#' && s[i+1] == '#' {
			fmt.Println("No")
			return
		}
	}

	if c > d {
		ok := false
		for i := b; i <= d; i++ {
			if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' {
				ok = true
				break
			}
		}
		if !ok {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")

}


Measured memory_bytes: 1664
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N, M, S = map(int, input().split())
    Edge = [[] for _ in range(N)] #time, nextnode, cost
    maxCost = 0
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        Edge[u-1].append((b, v-1, a))
        Edge[v-1].append((b, u-1, a))
        maxCost = max(a, maxCost)
    exchange = [None] * N #c枚, Dmin
    for i in range(N): exchange[i] = [int(c) for c in input().split()]
    maxCost *= N

    minTime = [[10 ** 20 for _ in range(maxCost + 1)] for i in range(N)]
    q = []
    heapify(q)
    heappush(q, (0, 0, S)) #time, node, money
    while q:
        cT, cN, cM = heappop(q)
        if minTime[cN][min(maxCost, cM)] == 10 ** 20:
            minTime[cN][min(maxCost, cM)] = cT
            if cM < maxCost: heappush(q, (cT + exchange[cN][1], cN, cM + exchange[cN][0]))
            for addTime, nextNode, payCost in Edge[cN]:
                if cM >= payCost: heappush(q, (cT + addTime, nextNode, cM - payCost))
    
    for i in range(1, N): print(min(minTime[i]))

    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

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

int main () {
	int N;
	cin >> N;
	vector<string> s(N);
	rep(i, N) cin >> s[i];

	int ans = 0, a = 0, b = 0, ba = 0;
	rep(i, N) {
		if (s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') ba++;
		else if (s[i][0] == 'B') b++;
		else if (s[i][s[i].size()-1] == 'A') a++;

		rep(j, s[i].size() - 1) {
			if (s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
		}
	}

	if (ba && a) ans++, a--;
	if (ba && b) ans++, b--;
	ans += max(0, ba - 1) + min(a, b);

	cout << ans << endl;
}


Measured memory_bytes: 768
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 main.cpp -o main
*
*/

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

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

	int n, w;
	cin >> n >> w;
	int mmax = n*1000+1;
	int bn = n + 1;
	int dd[bn][mmax];

	// initialize
	for (int nn = 0; nn < bn; nn++) {
	  for (int v = 0; v < mmax; v++) {
	    dd[nn][v] = -1;
	  }
	}

	for (int nn = 0; nn <= n; nn++) {
	  dd[nn][0] = 0;
	}
	for (int nn = 1; nn < bn; nn++) {
	  int www, nu;
	  cin >> www >> nu;
	  for (int v = 1; v < mmax; v++) {
	    // don't use item nn-1
	    int cur = -1;
	    if (dd[nn-1][v] != -1) {
	      cur = dd[nn-1][v];
	    }

	    // use item nn-1
	    if (nu <= v) {
	      int rem_v = v - nu;
	      if (dd[nn-1][rem_v] != -1) {
		int cand = dd[nn-1][rem_v] + www;
		if (cand <= w && (cur == -1 || cand < cur)) {
		  cur = cand;
		}
	      }
	    }

	    if (cur != -1) {
	      dd[nn][v] = cur;
	    }
	  }
	}
	bool done = false;
	for (int v = mmax-1; v >= 0; v--) {
	  if (done) {
	    break;
	  }
	  for (int nn = 0; nn < bn; nn++) {
	    if (dd[nn][v] != -1) {
	      cout << v << '\n';
	      done = true;
	      break;
	    }
	  }
	}

	if (!done) {
	  cout << 0 << '\n';
	}
	return 0;
}



Measured memory_bytes: 39680
use std::io;

fn main() {
	let mut buf = String::new();
	let a = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut ret = 0;
	for n in 0..7 {
		if a[n] == s {
			ret = 7 - n;
			break;
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	vector<int> rs(26,-1);
	vector<int> rt(26,-1);
	for(int i=0;i<s.length();i++){
		int a=s[i]-'a';
		int b=t[i]-'a';
		if(rs[a]!=-1 || rt[b]!=-1){
			if(rs[a]!=b || rt[b]!=a){
				cout << "No" << endl;
				return 0;
			}
		}else{
			rs[a]=b;
			rt[b]=a;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
 const int n = 1e6+ 5;
 bool Is_Brime(int x) {
     if (x <= 1)
         return false;
     for (int i = 2; i * i <= x; i++) {
         if (x % i == 0) {
             return false;
         }
     }
     return true;
 }
     int main(){
         int x;
         cin >> x;
         while (true) {
             if (Is_Brime(x)) {
                 cout << x << endl;
                 return 0;

             }
             x++;
         }
   
    
     }

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

int main() {
	int n,a[100005],ans=1;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	
	bool check = true;
	if(n%2!=0){
		for(int i=0;i<n;i++){
			if(a[i] != (1+i)/2*2)check=false;
		}
	}
	if(n%2==0){
		for(int i=0;i<n;i++){
			if(a[i] != i/2*2+1)check=false;
		}
	}
	
	int ex = 1000000007;
	for(int i=0;i<n/2;i++) {
		ans *= 2;
		ans = ans%ex;
	}
	
	if(check==1)cout<<ans<<endl;
	
	else if(check==0)cout<<0<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<vector<int>> g;
ll k = 0;
vector<ll> num;
void dfs0(int now, int pre) {
    for (int nxt : g[now]) {
        if (nxt == pre) continue;
        dfs0(nxt, now);
    }
    num[now] = k;
    k++;
}
ll ans = 0;
void dfs1(int now, int pre) {
    for (int nxt : g[now]) {
        if (nxt == pre) continue;
        ans += min(num[now], num[nxt]);
        dfs1(nxt, now);
    }
}
int main() {
    int n;
    cin >> n;
    g.resize(n);
    num.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    sort(all(c));
    dfs0(0, -1);
    rep(i, n) num[i] = c[num[i]];
    dfs1(0, -1);
    cout << ans << endl;
    rep(i, n) cout << num[i] << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n,x,t;
  std::cin>>n>>x>>t;

  std::cout<<((n+x-1)/x)*t<<"\n";
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define inf LLONG_MAX

ll power(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)	ans*=x;
		y=y>>1;
		x*=x;
	}
	return ans;
}

ll mul(ll x,ll y)
{
	return x*y;	
}


void solve()
{
	ll n,a,i,j,res,ans;
	cin>>a;
	string b;
	cin>>b;

	ans=0;		
	ans+=mul(a,b[3]-'0');
	ans+=mul(a,b[2]-'0')*10;
	ans+=mul(a,b[0]-'0')*100;

	ans/=100;
	
	
	cout<<ans<<endl;
}


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3860
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n, D[64][3][2], Mod = 1000000007, Res;
void Add(int a, int b, int c, long long d){
    D[a][b][c] = (D[a][b][c]+d)%Mod;
}
int main(){
    int i, j, k;
    D[60][0][0] = 1;
    scanf("%lld",&n);
    for(i=59;i>=0;i--){
        long long t = 1ll << i;
        int ck = (n >> i) & 1;
        for(j=0;j<3;j++){
            for(k=0;k<2;k++){
                if(j*2-2+ck >= 0)Add(i, min(j*2 - 2 + ck, 2), k|ck, D[i+1][j][k]);
                if(j*2-1+ck >= 0 && (k|ck))Add(i, min(j*2 - 1 + ck, 2), k, D[i+1][j][k]);
                Add(i, min(j*2 + ck, 2), k|ck, D[i+1][j][k]);
            }
        }
    }
    for(i=0;i<3;i++)for(j=0;j<2;j++) Res=(Res+D[0][i][j])%Mod;
    printf("%lld\n",Res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int a, b, x;
	cin >> a >> b >> x;
	if(a + b >= x && a <= x){
		cout << "YES";
	}
	else cout << "NO";
	
}


 
 
int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

int main()
{
  int n, l, r, ans = 0;

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

Measured memory_bytes: 256
import Data.List
main=map read.words<$>getLine>>=putStr.f
 where f (a:b:[k]) = g a b ([a..(a+k-1)]++[(b-k+1)..b])
       g a b x = h (nub[y|y<-x,a<=y,y<=b])
       h x = concat[(show y)++['\n']|y<-x]

Measured memory_bytes: 636
from collections import Counter

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

#cnt = 0
#for i in range(N):
#  for j in range(i, N):
#    if j - i == A[i] + A[j]:
#      cnt += 1

Ap = [A[i]+i for i in range(len(A))]
Am = [i-A[i] for i in range(len(A))]

S = set(Ap) & set(Am)

Cp = Counter(Ap)
Cm = Counter(Am)

cnt = 0
for i in S:
  cnt += Cp[i]*Cm[i]
  
print(cnt)

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

int merge(	std::vector<int>::iterator left,
			std::vector<int>::iterator mid, 
			std::vector<int>::iterator right){
	int cnt = 0;
	std::vector<int> L,R;

	for(std::vector<int>::iterator i=left; i!=mid; i++) L.push_back(*i);
	L.push_back(1000000000);
	for(std::vector<int>::iterator i=mid; i!=right; i++) R.push_back(*i);
	R.push_back(1000000000);

	std::vector<int>::iterator ri = R.begin();
	std::vector<int>::iterator li = L.begin();
	
	for(std::vector<int>::iterator k=left; k!=right; k++){
		if(*li>*ri){
			*k = *ri;
			ri += 1;
		}else{
			*k = *li;
			li += 1;
		}
		cnt += 1;
	}
	return cnt;
}

int mergeSort(	std::vector<int>::iterator left, 
				std::vector<int>::iterator right ){
	int cnt = 0;
	if(right-left>1){	
		int num = right - left;
		std::vector<int>::iterator mid = left + num/2;
		cnt += mergeSort(left,mid);
		cnt += mergeSort(mid,right);
		cnt += merge(left,mid,right);
	}
	return cnt;
}

int main(int argc, char const *argv[]){
	int n,cnt;
	std::cin >> n;
	std::vector<int> S(n);
	for(int i=0; i<n; i++) std::cin >> S[i];
	cnt = mergeSort(S.begin(),S.end());
	for(int i=0; i<n; i++) std::cout << S[i] << ((i<n-1)?" ":"\n");
	std::cout << cnt << std::endl;

	return 0;
}


Measured memory_bytes: 7376
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, a, mn = INF, sum = 0, neg = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		mn = min(mn, abs(a));
		sum += abs(a);
		if (a < 0) neg = 1 - neg;
	}
	if (neg) cout << sum - 2 * mn << endl;
	else cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
s = input()
t = input()

def is_restorable(a,b):
    ans = True
    for x,y in zip(a,b):
        if ans:
            if x == y or x == '?':
                pass
            else:
                ans = False
    return ans

s = s[::-1]
t = t[::-1]
s_ = list(s)

can_restore = False

for i,x in enumerate(s):
    if i+len(t) <= len(s):
        if not can_restore:
            if is_restorable(s[i:i+len(t)],t):
                can_restore = True
                s_[i:i+len(t)] = t

s_ = s_[::-1]
s_ = ''.join(s_)

ans = s_.replace('?','a')

if can_restore:
    print(ans)
else:
    print('UNRESTORABLE')

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  int alice=0;
  vector<int> a(N);
  for(int i=0;i<N;i++)
  {
    int s;
    cin >>s;
    a[i]=s;
    sum+=a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int j=0;j<N;j+=2)
  {
    alice+=a[j];
  }
  cout<<2*alice-sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e5+10;
const ll Mod=1e9+7;
vector <ll> G[Maxn];
queue <ll> Q;
ll cnt[Maxn],fa[Maxn];
bool vis[Maxn];
ll n,k;
inline ll read(){
    ll s = 0, w = 1; char ch = getchar();
    while(ch < '0' || ch > '9'){ if(ch == '-') w = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
inline void write(ll x){
    if (x < 0) x = ~x + 1, putchar('-');
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
ll bfs(ll S){
    ll ans=k%Mod;
    Q.push(S);
    ll temp=Q.front();
    Q.pop();    vis[temp]=true;
    for(auto i:G[temp]){
        fa[i]=temp;
        Q.push(i);
    }
    while(!Q.empty()){
        ll temp=Q.front();
        vis[temp]=1;
        Q.pop();
        ll now=(fa[temp]==S)?k-1-cnt[fa[temp]]:k-2-cnt[fa[temp]];
        if(now<=0)    return 0;
        ans=(ans*now)%Mod;
        cnt[fa[temp]]++;
        for(auto i:G[temp]){
            if(!vis[i]){
                fa[i]=temp;
                Q.push(i);
            }
        }
    }
    return ans%Mod;
}
int main() {
    n=read();k=read();
    for(ll i=1;i<=n-1;i++){
        ll a,b;
        a=read();   b=read();
        G[a].push_back(b);
        G[b].push_back(a);
    }
    write(bfs(1));
    return 0;
}


Measured memory_bytes: 11480
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

ll calc(ll dp[],ll k,ll a[],ll n)
{
    if(k<a[1]) return -1;
    ll i;
    for(i=1;i<=n&&k>=a[i];++i)
    {
        if(dp[k-a[i]]==0) dp[k-a[i]]=calc(dp,k-a[i],a,n);
        if(dp[k-a[i]]==-1) return 1;
    }
    return -1;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k;
    cin >> n ;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll dp[n][n];
    memset(dp,0,sizeof(dp));
    repr(i,n-1,0)
    {
        repp(j,i,n)
        {
            if(i==j) dp[i][j]=a[i];
            else
            {
                dp[i][j]=std::max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
            }
        }
    }
    cout << dp[0][n-1] ;
    return 0;
}

Measured memory_bytes: 70656
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n;
    let an;
    let ans;
    // init
    n = Number(input.shift());
    an = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = "APPROVED";
    for (var ane of an) {
        if (ane % 2 == 0) {
            if (ane % 3 == 0 || ane % 5 == 0) {
                continue;
            }
            else {
                ans = "DENIED";
                break;
            }
        } else {
            continue;
        }
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


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

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

dp = [[0]*(N+1) for _ in range(N+1)]
B = [(a, i) for i, a in enumerate(A)]
B.sort(reverse=True)

for l, (a, i) in enumerate(B):
    length = N-l
    for left in range(l+1):
        dp[left+1][left+length] = max(dp[left+1][left+length], dp[left][left+length] + a*abs(i-left))
        dp[left][left+length-1] = max(dp[left][left+length-1], dp[left][left+length] + a*abs(left+length-1-i))
ans = 0    
for n in range(N+1):
    ans = max(ans, dp[n][n])
print(ans)

Measured memory_bytes: 100348
//inspiration: https://www.hackerrank.com/topics/digit-dp
#include <iostream>
#include <cstdio>
#include <cstring>
 using namespace std;

#define int long long 
const int mod=1e9+7;
string s;
int dp[10005][2][105],n,d;

int solve(int idx,bool smaller,int rem)
{
  if(idx==n)
  {
    return (rem!=0)?0:1;
  }
  if(dp[idx][smaller][rem]!=-1)
    return dp[idx][smaller][rem];

  int limit=9;
  if(smaller)
    limit=s[idx]-'0';

  int cnt=0;
  
  for(int i=0;i<=limit;i++)
  {
    bool smflag;
    if(i<(s[idx]-'0'))
      smflag=0;
    else
      smflag=smaller;

    cnt=(cnt % mod + solve(idx+1,smflag,(rem+i) % d) % mod) % mod;
  }

  return dp[idx][smaller][rem]=cnt;
}

int32_t main()
{
  cin>>s>>d;
  n=s.size();
  if(d>9*n)
  {
    cout<<0; exit(0);
  }

  memset(dp,-1,sizeof(dp));

  int ans=solve(0,1,0);

  cout<<(ans+mod-1)%mod;
  
 
  return 0;  
}   

Measured memory_bytes: 17664
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


int main() {
    ll x; cin >> x;
    ll ans = 0;
    ll tmp = 100;
    while (tmp < x) {
        ans++;
        tmp += tmp /100;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
function main(input) {
  const [w, h, x, y] = input.trim().split(" ").map(n => Number(n));
  const result = [];
  result.push(w*h/2);
  if (x === w/2 && y === h/2) {
    result.push(1);
  } else {
    result.push(0);
  }
  console.log(result.join(" "));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(void) {
    ll N;
    cin>>N;
    ll A[N];
    ll ma=0;
    ll x=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(ma<A[i]){
            x=i;
            ma=A[i];
        }
    }
    sort(A,A+N);
    reverse(A,A+N);
    for(int i=0;i<N;i++){
        if(i==x) cout<<A[1]<<endl;
        else cout<<A[0]<<endl;
    }
    
}

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


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		while(true){
			int d = sc.nextInt();

			if(d == 0){
				break;
			}

			int n = sc.nextInt();
			int m = sc.nextInt();

			int[] store = new int [n + 1];
			store[n] = d;
			for(int i = 1; i < n; i++){
				store[i] = sc.nextInt();
			}

			int[] deliv = new int[m];
			for(int i = 0; i < m; i++){
				deliv[i] = sc.nextInt();
			}

			System.out.println(solve(store, deliv, d));
		}
	}
	
	static int solve(int[] store, int[] deliv, int d){
		int result = 0;

		Arrays.sort(store);

		for(int i = 0; i < deliv.length; i++){
			int index = Arrays.binarySearch(store, deliv[i]);

			//ちょうど店と同じ座標
			if(index >= 0){
				continue;
			}

			else {
				index++;
				index *= -1;

				result += Math.min(deliv[i] - store[index - 1], store[index] - deliv[i]);
			}
		}

		return result;
	}
}



Measured memory_bytes: 67360
#include <bits/stdc++.h>
using namespace std;
int main(){
  // int型の2次元配列(3×4要素の)の宣言
  vector<string> data(3);
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < 3; i++) {
    cin >> data.at(i);
  }

  cout << data.at(0).at(0) << data.at(1).at(1) << data.at(2).at(2) << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;
  cout << 2018;
  for (int i = 4; i < s.size(); ++i) {
    cout << s[i];
  }

  cout << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,flag = 0;
	cin >> N;
	for (int i = 0;i < 25;i++){
		for (int j = 0;j< 15;j++){
			if (4 * i + 7 * j == N){
				flag = 1;
				// cout << i << j << endl;
				break;
			}
		}
	}
	if (flag == 1){
		cout<< "Yes" <<endl;
	}
	else{
		cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        int h, w, i, j;

        for(;;){
                scanf("%d %d",&h,&w);
                if(h == 0 && w == 0)
                        break;
                else{
                        for(i=1; i<=h; i++){
                                if(i == 1 || i == h){
                                        for(j=0; j<w; j++)
                                                putchar('#');
                                }else{
                                        for(j=1; j<=w; j++){
                                                if(j == 1 || j == w)
                                                        putchar('#');
                                                else
                                                        putchar('.');
                                        }
                                }
                                printf("\n");
                        }
                        printf("\n");
                }
        }
        return 0;
}

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

int main(){
	int n , q ; 
	cin >> n >> q; 
	string s ; 
	cin >> s ; 
	vector<int> sum(n+1,0) ; 
	for(int i=0;i<=(int)s.size()-2;i++){
		string tmp = s.substr(i,2) ; 
		if ( tmp == "AC" ){
			sum[i+2-1] = 1 ; 
		}
		debug() << imie(sum) ; 
	}
	for(int i=1;i<(int)sum.size();i++){
		sum[i] += sum[i-1] ; 
	}
	debug() << imie(sum) ; 
	while(q--){
		int l , r ; 
		cin >> l >> r ; 
		l--,r--;
		debug() << imie(l) imie(sum[l]); 
		debug() << imie(r) imie(sum[r]); 
		cout << sum[r] - sum[l] << endl;
	}
    return 0 ;
}


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

int H[105];

int calc(int l, int r)
{
    int mn = 105;
    for (int i = l; i <= r; i++) if (H[i] < mn) mn = H[i];
    int res = mn;
    for (int i = l; i <= r; i++) H[i] -= mn;
    int p = l;
    while (p <= r)
    {
        while (p <= r && !H[p]) p++;
        if (p > r) break;
        l = p;
        while (p <= r && H[p]) p++;
        res += calc(l, p - 1);
    }
    return(res);
}

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> H[i];
    cout << calc(1, N) << '\n';
    return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll x;

ll solve(){
    cin >> x;

    ll a = x / 11;
    ll r = x % 11; 
    return a * 2 + (r > 6 ? 2 : (r == 0 ? 0 : 1));
}

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

    cout << solve() << "\n";
    
    return 0;
}


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

int main(){
    int n; cin>>n;
    int r=0,l=1e9;
    for(int i=0;i<n;i++){
        int s; cin>>s;
        r=max(r,s);
        l=min(l,s);
    }
    cout<<r-l<<endl;
}

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

int main() {
    long long int n, c, k;
    cin>>n>>c>>k;
    long long int a[n];
    for(long long int i = 0;i<n;i++){
        cin>>a[i];
    }
    sort(a, a+n);
    long long int temp = 1;
    long long int ans = 1;
    long long int newbus = 0;
    for (long long int i = 1; i < n; i++) {
      temp++;
      if (a[i] - a[newbus] > k || temp > c) {
        temp = 1;
        newbus = i;
        ans++;
      }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, m;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++){
		string s;
		cin >> s;
		mp[s]--;
	}
	int ans = 0;
	for (auto x : mp){
		ans = max(ans, x.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[] as = new long[N];
			long[] bs = new long[N];
			for(int i = 0; i < N; i++) {
				as[i] = sc.nextLong();
				bs[i] = -sc.nextLong();
			}
			
			Arrays.sort(as);
			Arrays.sort(bs);
			
			for(int i = 0; i < N; i++) {
				bs[i] = -bs[i];
			}
			
			final int index = (N / 2);
			//System.out.println(as[index] + " " + bs[index]);
			
			if(N % 2 == 0) {
				final long fst_part = (as[index] - as[index - 1]);
				final long snd_part = (bs[index - 1] - bs[index]);
				//System.out.println(fst_part + " " + snd_part);
				System.out.println((bs[index] - as[index]) * 2 + 1 + fst_part + snd_part);
			}else {
				System.out.println(bs[index] - as[index] + 1);
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 61232
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define N 101

int main(){
  int a[N],b[N][N];
  int i,n,k,j,l=0,tmp=0;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&a[i-1],&a[i]);
  }

  for(i=1;i<=n;i++){
    b[i][i]=0;
  }
  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      k=i+j-1;
      b[i][k]=INT_MAX;
      for(l=i;l<=k-1;l++){
        tmp=b[i][l]+b[l+1][k]+a[i-1]*a[l]*a[k];

    if(b[i][k]>tmp){
      b[i][k]=tmp;
    }else{
      b[i][k]=b[i][k];
    }
      }
    }
  }
  printf("%d\n",b[1][n]);
  return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    while(true){
        int N; cin >> N;
        if(N==0) break;
        int H,W; cin >> H >> W;
        int cnt[H+1][W+1];
        rep(i,H+1){
            rep(j,W+1){
                cnt[i][j]=0;
            }
        }
        rep(i,N){
            int a,b; cin >> a >> b;
            cnt[a][b]=1;
        }
        rep(i,H) rep(j,W) cnt[i+1][j+1]+=cnt[i+1][j];
        rep(i,H) rep(j,W) cnt[i+1][j+1]+=cnt[i][j+1];
        int S,T; cin >> S >> T;
        int ans=0;
        rep(i,H-S+1){
            rep(j,W-T+1){
                chmax(ans,cnt[i+S][j+T]-cnt[i+S][j]-cnt[i][j+T]+cnt[i][j]);
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int dp[100120];
  for(int i=0;i<100120;i++){
    dp[i]=1000000000;
  }
  
  dp[0]=0;
  
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[j+i]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024