akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+10;
int n,a[N],b[N];
long long ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",a+i,b+i);
	for (int i=n;i;--i){
		a[i]=(a[i]+ans)%b[i];
		if (a[i]) ans+=b[i]-a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
    int k;
    char a[4]="ACL";
    scanf("%d",&k);

    for(int i=0;i<k;i++){
        printf("%s",a);
    }
}

Measured memory_bytes: 1684
s = input()
l = [int(s[i]) for i in range(4)]
a, b, c, d = map(int, l)
m = 100*a+10*b+c
n = 100*b+10*c+d
if m%111 == 0 or n%111 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[k-1]){
      s[i]='*';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################


int main(){
  boost;
  
  
  string n;
  cin>>n;
  ll ans=0;
  for(int i=0;i<n.size();i++){
	  ans+=(n[i]-'0');
  }
  if(ans%9==0)
  cout<<"Yes";
  else 
  cout<<"No";
}



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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    vector<lint> l(n);
    lint maxl = 0;

    lint ans = 0;
    REP(i, n) { cin >> l[i];
        maxl = max(maxl, l[i]);
        ans += l[i];
    }
    cout << ((ans-maxl>maxl)?"Yes":"No") <<"\n";

    return 0;
}

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

using namespace std;
 int par[100010];
  int rank1[100010];
  int size[100010];
  int num;

  void init(int n1){
    for(int i=0;i<n1;i++){
      par[i] = i;
      rank1[i] = 0;
      size[i] = 1;
    }
    num = n1;
  }
  
  int find(int x){
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
  }
void link(int x, int y) {
    if(rank1[x]  > rank1[y]) {
      par[y] = x;
      size[x] = size[x] + size[y];
    }else if(rank1[x] < rank1[y]){
      par[x] = y;
      size[y] = size[x] + size[y];
    }else if(x != y) {
      par[y] = x;
      rank1[x]++;
      size[x] = size[x] + size[y];
    }
  }
  
  void unite(int x, int y){
    if (find(x) != find(y)) num--;
    link(find(x), find(y));
  }
  
  bool same(int x , int y){
    return find(x) == find(y);
  }

  int union_size(int x) {
    if (x != par[x]) {
      size[x] = union_size(find(x));
    }
    return size[x];
  }
 
int main(){
  
  int n , m , k;
  cin >> n >> m >> k;
  int a[100010],b[100010],c[100010],d[100010];
  int frie[100010]{};
  int block[100010]{};
  
  init(n);
  
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
   unite(a[i] , b[i]);
    frie[a[i]]++; frie[b[i]]++;
  }
  
  for(int i=0;i<k;i++){
     cin >> c[i] >> d[i];
     c[i]--; d[i]--;
   if(same(c[i], d[i])){
     block[c[i]]++; block[d[i]]++;
  }
  }

      for(int i=0;i<n;i++){
        cout << union_size(i) - frie[i] - block[i] -1 << " ";
       
      }
      cout << endl;
      }

  
 

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int x,y;
	scanf("%d %d",&x,&y);
	if(x==2) {
		printf("No\n");
	}
	if(x==4||x==6||x==9||x==11) {
		if(y==4||y==6||y==9||y==11) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	if(x==1||x==3||x==5||x==7||x==8||x==10||x==12) {
		if(y==1||y==3||y==5||y==7||y==8||y==10||y==12) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

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

int main(){
    fcin;
    vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string s;
    cin >> s;

    int i;
    int n = v.size();
    for(i = 0; i < n; i++) if(v[i] == s) break;
    
    int ans = 0;
    while(true){
        i++;
        ans++;
        i %= 7;
        if(v[i] == "SUN") break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i++<n;)
ll INF=1e+18;

int main(){
  ll n,X,x[200010],rw[200010]={},temp,ans=INF,p;
  cin>>n>>X;
  fr(i,n) cin>>x[i];
  fr(i,n) rw[i]=rw[i-1]+x[i];
  fr(i,n){
    p=n-2*i;
    temp=(n+i)*X+5*rw[n];
    while(p>0){
      temp+=2*rw[p];
      p-=i;
      if(temp<0){
        temp=INF;
        break;
      }
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
from itertools import permutations

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

a = [[0] * C for _ in range(3)]
for y in range(N):
    for x in range(N):
        t = ((x + 1) + (y + 1)) % 3
        a[t][c[y][x] - 1] += 1

result = float('inf')
for b in permutations(range(C), 3):
    t = 0
    for i in range(3):
        for j in range(C):
            t += a[i][j] * D[j][b[i]]
    result = min(result, t)
print(result)


Measured memory_bytes: 5620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 20;
int n;
char str[maxn] = "MARCH";
map<char, int> mp;
LL num[maxn], ans;
char name[maxn];

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    for(int i = 0; str[i]; ++i) {
        mp.insert(make_pair(str[i], i));
    }
    while(cin >> n) {
        ans = 0;
        memset(num, 0, sizeof(num));
        for(int i = 0; i < n; ++i) {
            cin >> name;
            if(mp.find(name[0]) != mp.end()) {
                ++num[mp[name[0]]];
            }
        }
        for(int i = 0; i < 5; ++i) {
            for(int j = i + 1; j < 5; ++j) {
                for(int k = j + 1; k < 5; ++k) {
                    ans += num[i] * num[j] * num[k];
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def calc(arr, n)
  (1...n).each{|i| arr[i] += arr[i-1] }
  arr.each{ |v| $list[v] ||= 0; $list[v] += 1 }
end
def calc2(arr, n)
  (1...n).each{|i| arr[i] += arr[i-1] }
  arr.each{ |v| $list[v].nil? ? next : $res += $list[v] }
end
loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  $list = {}
  $res = 0
  l = n.times.map{ gets.to_i }
  k = m.times.map{ gets.to_i }
  (0...n).each{ |i| calc(l[i..-1], n - i) }
  (0...m).each{ |i| calc2(k[i..-1], m - i) }
  p $res
end

Measured memory_bytes: 64664
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll ans2 = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
int main() {
	cin >> N >> M;
	vl P(M);
	vector<string> S(M);
	vl isAC(N), isWA(N);
	for (i = 0; i < N; i++) {
		isAC[i] = 0;
		isWA[i] = 0;
	}
	for (i = 0; i < M; i++) {
		cin >> P[i] >> S[i];
		if (isAC[P[i] - 1] == 0 && S[i] == "WA") {
			isWA[P[i] - 1]++;
		}
		else if (isAC[P[i] - 1] == 0 && S[i] == "AC") {
			isAC[P[i] - 1] = 1;
			ans += isWA[P[i] - 1];
			ans2++;
		}
	}
	cout << ans2 << endl << ans;
}

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

int main() {
  int N, M;
  map<string, int> map;
  cin >> N;
  rep (i, N) {
    string s; cin >> s;
    map[s] ++;
  }
  cin >> M;
  rep(i, M) {
    string t; cin >> t;
    map[t] --;
  }
  int ret = -1;
  for (auto ite=map.begin(); ite!=map.end(); ite++) {
    ret = max(ret, ite->second);
    
  }
  cout << max(0, ret) << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
    $input = trim(fgets(STDIN));
    $input2 = trim(fgets(STDIN));
    $data = explode(" ",$input2);
 
    $max = $data[0];
    $min = $data[0];
    $sum = $data[0];
 
    for($i=1;$i<$input;$i++) {
        if ($data[$i] > $max) {
            $max = $data[$i];
        }
        else if ($data[$i] < $min) {
            $min = $data[$i];
        }
        $sum += $data[$i];
    }
  
    echo $min . " " . $max . " ". $sum;
 
?>

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

int main(){
  int g,n,x;
  cin >> g >> n >> x;
  map<int,int>kane;
  int baf;
  for(int i=0;i<n;i++){
    cin >> baf;
    kane[baf]=1;
  }
  int monA=0,monB=0;
  for(int i=x;i<g;i++){
    if(kane[i]==1)
      monA++;
  }
  for(int i=x;i>0;i--){
    if(kane[i]==1)
      monB++;
  }
  cout << min(monA,monB) << endl;
  return 0;
}

Measured memory_bytes: 3600
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M, X := nextInt(), nextInt(), nextInt()
	Am := make(map[int]bool)
	var cnt1, cnt2 int
	for i := 0; i < M; i++ {
		Am[nextInt()] = true
	}
	for i := X; i <= N; i++ {
		if _, exist := Am[i]; exist {
			cnt1++
		}
	}
	for i := X; i >= 0; i-- {
		if _, exist := Am[i]; exist {
			cnt2++
		}
	}
	fmt.Println(MinOf(cnt1, cnt2))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	int N {};
	std::cin >> N;
	int d[N] {};
	for (int i {}; i < N; i++)
		std::cin >> d[i];

	int ans {};
	for (int i {}; i < N - 1; i++)
		for (int j {i + 1}; j < N; j++)
			ans += d[i] * d[j];

	std::cout << ans;
}

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

int main(){
    int N, X;
    cin >> N >> X;
    int mi=X, cnt=0;
    vector<int> m(N);
    for(int i=0; i<N; i++) cin >> m[i];
    
    for(int i=0; i<N; i++){
        X -= m[i];
        mi = min(mi,m[i]);
        cnt++;
    }
    
    while(1){
        X -= mi;
        if(X<0) break;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
res = 0
for i in range(1, N + 1):
  u = max(i - K, 0)
  v = N // i
  x = max(N % i - K + 1, 0)
  res += u * v + x - (K == 0)
  #print(i, u, v, x)
  #print(res)
print(res)

Measured memory_bytes: 39920
package main

import (
	"fmt"
)

func main() {
	var W, a, b int
	l := 0
	fmt.Scan(&W, &a, &b)
	if a <= b {
		if b > a+W {
			l = b - (a + W)
		}
	} else {
		if b+W < a {
			l = a - (b + W)
		}
	}
	fmt.Println(l)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;



int main(){
  string s,ans;
  cin >>s;
  if(s[0]==s[1] && s[1]==s[2]) ans="No";
  else ans="Yes";
 
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){

	int n;
	cin>>n;
	long ans=1;
	for(int i=2;i<=n;i++){
		ans *= i;
	}
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
    int a,b,c,sign,sign1=0,time,t,sum;
    scanf("%d %d %d",&a,&b,&c);
    if(!(60 % (a+b)))
            sign1=1;
    for(time=0,t=0,sign=0;;sign=1-sign){
        if(!sign){
            time+=a;
        }
        else{
            time+=b;
        }
        if(time >= c && time-a <= c && !sign){
            sum=t*60+c;
            break;
        }
        if(time >= 60){
            t++;
            time-=60;
            if(time >= c && !sign){
                sum=t*60+c;
                break;
            }
            if(sign1 || (!time && sign)){
                sum=-1;
                break;
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}

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

int N,K;
int D[10];

bool minv(int v){
    int n;
   while(v){
        n=v%10;
        for(int k=0;k<K;k++){
            if(n==D[k]){
                return false;
            }
        }
        v/=10;
    }
    return true;
}

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

    
    
    
    for(int i=N;i<10*N;i++){
       if(minv(i)){
           cout<<i<<endl;
           return 0;
       }
    }
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)

const long long MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll m=0, a=0, r=0, c=0, h=0;
    string s;
    rep(i, n){
        cin >> s;
        if(s[0] == 'M'){
            m++;
        }else if(s[0] == 'A'){
            a++;
        }else if(s[0] == 'R') {
            r++;
        }else if(s[0] == 'C'){
            c++;
        }else if(s[0] == 'H'){
            h++;
        }
    }

    ll out = 0;
    out += m*a*r;
    out += m*a*c;
    out += m*a*h;
    out += m*r*c;
    out += m*r*h;
    out += m*c*h;
    out += a*r*c;
    out += a*r*h;
    out += a*c*h;
    out += r*c*h;

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


Measured memory_bytes: 256
N,A,B,C,D=map(int,input().split())

Sstr=input()


if "##" in Sstr[A:C-1]:
    print("No")
elif "##" in Sstr[B:D-1]:
    print("No")
else:
    
    if C<D:
        print("Yes")
    else:
        if "..." in Sstr[B-2:D+1]:
            print("Yes")
        
        else:
            print("No")
 

Measured memory_bytes: 3572
def main():
    S = input()
    for index, s in zip(range(len(S)), list(S)):
        # 奇数文字目 Lがダメ
        if (index + 1) % 2 == 1 and s == "L":
            print("No")
            return
        # 偶数文字目 Rがダメ
        elif (index + 1) % 2 == 0 and s == "R":
            print("No")
            return

    print("Yes")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

int gcd(int a, int b){
        int r;
       
        while ((r = a % b) != 0){
            a = b;
            b = r;
        }
        return b;
    }

int main(void){
    int a, b;
     
     while(cin >> a >> b){
         int lcm = b/gcd(a,b)*a;
         cout<<gcd(a,b)<<" "<<lcm<<endl;
     }
     return 0;
}



Measured memory_bytes: 3072
#include <cstdio>

int N;
int A[200010], B[200010];
long long res;

void solve()
{
	int i;
	int mn = 2000000000;
	for(i=0; i<N; i++){
		if(A[i] > B[i]){
			if(B[i]<mn)
				mn = B[i];
		}
	}
	if(mn == 2000000000){
		printf("0\n");
		return ;
	}
	long long sum = 0;
	for(i=0; i<N; i++)
		sum += A[i];
	res = sum - mn;
	printf("%lld\n", res);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d%d", &A[i], &B[i]);
	}
	solve();
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	long long r, D, x; cin >> r >> D >> x;
	for (size_t i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
	int i,n,p,d1,d2,ps,d,max;
	max=-1;
	scanf("%d",&n);
	while(!(n==0)){
		p=0;
		d1=0;
		d2=0;
		max=-1;
		for(i=1;i<=n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			d=d1+d2;
			if(max<d){
				max=d;
				ps=p;
			}
		}
		printf("%d %d\n",ps,max);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
import itertools
N, M, X = map(int, input().split())

books = list()
for i in range(N):
    books.append(list(map(int, input().split())))

minprice = 1<<34
canComp = False
for i in itertools.product([0, 1], repeat=N):
    ok = True
    known = [0] * M
    price = 0
    for n, j in enumerate(i):
        if j == 1:
            book = books[n]
            price += book[0]
            for a, know in enumerate(book[1:]):
                known[a] += know

    for know in known:
        if know < X:
            ok = False
            break
    if ok:
        canComp = True
        minprice = min(minprice, price)
    
if canComp:
    print(minprice)
else:
    print(-1)

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

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

  vector<int> fib(50, 1);
  for(int i=0; i<N-1; i++) fib[i+2] = fib[i+1] + fib[i];

  cout << fib[N] << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int a,b,k;
  cin>>a>>b>>k;
  int c=0;
  int ans=0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0) c++;
    if(c==k) {
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
n = int(input())
Adj = []
for i in range(n):
    X = list(map(int, input().split()))[2:]
    for j in range(len(X)):
        X[j] -= 1
    Adj.append(X)
    
A = [[0]*n for _ in range(n)]
for i in range(n):
    for j in Adj[i]:
        A[i][j] = 1
for i in range(n):
    print(*A[i])


Measured memory_bytes: 6384
s = input()
s = list(s)
ans = []

for i in range(len(s)):
  if(s[i] == '0'):
    ans.append('0')
  elif(s[i] == '1'):
    ans.append('1')
  else:
    if(len(ans) != 0):
      ans.pop(-1)

str = ''.join(ans)
print(str)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a int64
	var b int64
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	if a%2 == 1 && b%2 == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

int main() {
    int p{}, q, r{};
    std::cin >> p >> q >> r;
    const int a = p + q;
    const int b = q + r;
    const int c = r + p;
    std::cout << std::min(std::min(a, b), c) << std::endl;
    return 0;
}

Measured memory_bytes: 256
###########################################
class Bit():
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        return
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return
def programer1B():
    N, K = LI()
    A = LI()
    bit = Bit(max(A))
    cur = 0
    for i, a in enumerate(A):
        bit.add(a, 1)
        cur += i + 1 - bit.sum(a)
    As = 0
    A.sort()
    now = 0
    for i in range(1,N):
        if A[i]!=A[i-1]:
            now = i
        As += now
#    print(cur,As)
    ans = (As*(K**2) - (As-2*cur)*K)//2
    ans %=mod
    print(ans)
    return

def ABC106():
    N, M, Q = LI()
    R = []
    for i in range(M):
        l, r = LI()
        R.append([l,r,0])
    for i in range(Q):
        p, q = LI()
        R.append([p,q,i+1])
    R.sort(key=lambda x:x[1])
#    print(R)
    B = Bit(N+1)
    ans = [0]*Q
    for x,y,t in R:
        if t==0:
            B.add(x,1)
        else:
            cur = B.sum(y+1) - B.sum(x-1)
            ans[t-1] = cur
    for v in ans:
        print(v)
    return

####################################################################
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod, mod2, inf
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18

if __name__ == '__main__':
#    programer1B()
    ABC106()


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

namespace AtCoder
{
    class Program
    {

        static void Main()
        {
            //ここから
            int[] str = ReadLineToIntArray();
            int N = str[0];
            int M = str[1];
            int C = str[2];

            int[] B = ReadLineToIntArray();

            int ans = 0;
            
            for(int i = 0; i < N; i++)
            {
                int[] A = ReadLineToIntArray();
                int sum = C; ;
                for(int j = 0; j < M; j++)
                {
                    sum += A[j] * B[j];
                }
                if (sum > 0) { ans++; }
            }

            //ここまで


            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }



        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }



    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
const int N=1000023;
int child[N][30];
int nxt=1;
bool isend[N];
vector <int> paths[N];
void construct_trie(vector <string> v,int n)
{
    for(int i=0;i<n;i++)
    {
        string s=v[i];
        int node=0;
        for(auto ch:s)
        {
            if(child[node][ch-'a']==0)
            {
                child[node][ch-'a']=nxt++;
            }
            node=child[node][ch-'a'];
            paths[i].push_back(node);
        }
        isend[node]=1;
    }
}
int main()
{
    int n;
    cin>>n;
    vector <string> v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        reverse(s.begin(),s.end());
        v.push_back(s);
    }
    construct_trie(v,n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        string s=v[i];
        int cnt[30]={0};
        for(int j=s.length()-1;j>=0;j--)
        {
            cnt[s[j]-'a']++;
            int node=0;
            if(j>0)
                node=paths[i][j-1];
            for(char ch='a';ch<='z';ch++)
            {
                if(cnt[ch-'a']==0)
                    continue;
                int x=child[node][ch-'a'];
                if(x!=0 && isend[x])
                    ans++;
            }
        }
    }
    ans-=n;
    cout<<ans<<'\n';
}

Measured memory_bytes: 152240
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main()
{
    int sum = 0;
    int a[3];

    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    if ( sum >= 22)
        printf("bust\n");
    else 
        printf("win\n");

    return 0;
}

Measured memory_bytes: 128
n = int(input())
happiness = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n + 1)]

# dp[i + 1][j] := i 日目までの活動履歴のうち、最終日であるi日目には活動
# j(0: A, 1: B, 2: C) を選んだ場合の、得られる幸福度の最大値
# dp[ i ][ 0 ] から dp[ i + 1 ][ 1 ] への遷移
# dp[ i ][ 0 ] から dp[ i + 1 ][ 2 ] への遷移
# dp[ i ][ 1 ] から dp[ i + 1 ][ 0 ] への遷移
# dp[ i ][ 1 ] から dp[ i + 1 ][ 2 ] への遷移
# dp[ i ][ 2 ] から dp[ i + 1 ][ 0 ] への遷移
# dp[ i ][ 2 ] から dp[ i + 1 ][ 1 ] への遷移
# 日付
for i in range(n):
    for j in range(3):
        for k in range(3):
            if i == 0:
                dp[i + 1][k] = happiness[i][k]
            elif j == k:
                continue
            else:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + happiness[i][j])

print(max(dp[-1]))


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

int main() {
    vector<vector<int>> V(3, vector<int>(3));
    int map[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) {cin >> V[i][j]; map[i][j] = 0;}
    }
    
    int N; cin >> N;
    vector<int> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(V[j][k] == A[i]) map[j][k] = 1;
            }
        }
    }
    
    if((map[0][0] && map[1][0] && map[2][0]) || (map[0][1] && map[1][1] && map[2][1]) || (map[0][2] && map[1][2] && map[2][2]) ||(map[0][0] && map[0][1] && map[0][2]) ||(map[1][0] && map[1][1] && map[1][2]) ||(map[2][0] && map[2][1] && map[2][2]) || (map[0][0] && map[1][1] && map[2][2]) ||(map[0][2] && map[1][1] && map[2][0])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>b){
    for(int i=0;i<a;i++){
		cout<<b;
    }
  }
   else{
     for(int i=0;i<b;i++){
       cout<<a;
     }
   }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int h,w,m;
    cin>>h>>w>>m;
    vector<int> y(m),x(m);
    map<pair<int,int>,int> bomb;
    for(int i=0; i<m; i++){
        cin>>y[i]>>x[i];
        y[i]--;
        x[i]--;
        bomb[make_pair(y[i],x[i])]++;
    }
    
    map<int,int> ycnt,xcnt;
    for(int i:y) ycnt[i]++;
    for(int i:x) xcnt[i]++;

    vector<pair<int,int>> yp,xp;
    for(auto i:ycnt) yp.push_back(make_pair(i.second,i.first));
    for(auto i:xcnt) xp.push_back(make_pair(i.second,i.first));
    sort(yp.begin(),yp.end(),greater<>());
    sort(xp.begin(),xp.end(),greater<>());

    int ans = yp[0].first+xp[0].first;
    if(bomb[make_pair(yp[0].second,xp[0].second)]){
        ans--;
        for(auto i:yp){
            if(bomb[make_pair(i.second,xp[0].second)]){
                ans = max(ans, i.first+xp[0].first-1);
            }else{
                ans = max(ans, i.first+xp[0].first);
            }
        }
        for(auto i:xp){
            if(bomb[make_pair(yp[0].second,i.second)]){
                ans = max(ans, yp[0].first+i.first-1);
            }else{
                ans = max(ans, yp[0].first+i.first);
            }
        }
    }
    cout<<ans<<endl;
}

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

string s;
int p;
map<string, int> size;
map<pair<string,int>, int> value;

int rec() {
  if(isdigit(s[p])) {
    string num = "";
    while(isdigit(s[p])) num += s[p++];
    return atoi(num.c_str());
  } else {
    int st = p;
    while(s[p] != '[') ++p;
    string name = s.substr(st, p - st);
    ++p;
    int index = rec();
    if(!size.count(name)) throw 0;
    if(index >= size[name]) throw 0;
    if(!value.count(make_pair(name, index))) throw 0;
    return value[make_pair(name, index)];
  }
}

int main() {
  while(1) {
    vector<string> line;
    for(string t; cin >> t && t != ".";) line.push_back(t);
    if(line.empty()) return 0;
    size.clear();
    value.clear();

    int ans = 0;
    for(int i = 0; i < line.size(); ++i) {
      s = line[i];
      if(s.find('=') == string::npos) {
	// declaration
	for(int i = 0; i < s.size(); ++i) {
	  if(s[i] == '[') {
	    string name = s.substr(0, i);
	    string num = s.substr(i+1);
	    num = num.substr(0, num.size()-1);
	    size[name] = atoi(num.c_str());
	    break;
	  }
	}
      } else {
	// assignment
	try {
	  string tmp = s;
	  int n = tmp.find('[');
	  int m = tmp.find('=');
	  s = tmp.substr(m+1) + "$";
	  p = 0;
	  int right = rec();
	  s = tmp.substr(n+1) + "$";
	  p = 0;
	  string name = tmp.substr(0, n);
	  int index = rec();
	  if(!size.count(name)) throw 0;
	  if(index >= size[name]) throw 0;
	  value[make_pair(name, index)] = right;
	} catch(...) {
	  ans = i+1;
	  break;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1476
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main(){
	//freopen("in.txt", "r", stdin);
	int a, b, c; cin >> a >> b >> c; print((a + b + c == 2 * max(a, max(b, c))) ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<ll,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m;
vector<pint> v[2][101010];
ll a[2][101010],dist[2][101010];

void bfs(int x,int flag){
    priority_queue<pint,vector<pint>,greater<pint>> q;
    dist[flag][x]=0;
    q.push({0LL,x});
    while(q.size()){
        pint p=q.top();q.pop();
        ll d=p.first,now=p.second;
        for(auto to:v[flag][now]){
            if(dist[flag][to.second]>dist[flag][now]+to.first){
                dist[flag][to.second]=dist[flag][now]+to.first;
                q.push({dist[flag][to.second],to.second});
            }
        }
    }
}

int main(){
    cin>>n>>m;
    int s,t;
    cin>>s>>t;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        ll a,b;
        cin>>a>>b;
        x--;y--;
        v[0][x].push_back({a,y});
        v[1][x].push_back({b,y});
        v[0][y].push_back({a,x});
        v[1][y].push_back({b,x});
    }
    rep(i,n)rep(j,2)dist[j][i]=longinf;
    bfs(s-1,0);
    bfs(t-1,1);
    ll ans[n];
    rep(i,n)ans[i]=dist[0][i]+dist[1][i];
    rep(i,n-1)ans[n-i-2]=min(ans[n-i-1],ans[n-i-2]);
  rep(i,n)ans[i]=(ll)1e15-ans[i];
    rep(i,n)printf("%ld\n",ans[i]);
    return 0;
}


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

int main(){
  int x,y; cin >> x >> y;
  int result;
  if(x>0){
    if(y>0){
      if(x>y){
        result=2+x-y;
      }else{
        result=y-x;
      }
    }else if(y==0){
      result=1+x;
    }else{
      result=1+abs(x+y);
    }
  }else if(x==0){
    if(y>0){
      result=y;
    }else{
      result=1-y;
    }
  }else{
    if(y>0){
      result=1+abs(x+y);
    }else if(y==0){
      result=-x;
    }else{
      if(x>y){
        result=2+x-y;
      }else{
        result=y-x;
      }
    }
  }
  cout << result << endl;
}

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;

    int ans = 1000;
    for(int i=0; i<s.length(); i++)
    {
        int lans = 0;
        for(int j=0; j<t.length(); j++)
        {
            if(i+j >= s.length())
            {
                lans = 1000;
                break;
            }
            if(s[i+j] != t[j]) lans++;
        }
        chmin(ans, lans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
h, w, d = [int(i) for i in input().split(" ")]
a = [[] for i in range(0, h)]

for i in range(0, h):
    a[i] = [int(j) for j in input().split(" ")]

q = int(input())
l = []
r = []

for i in range(0, q):
    li, ri = [int(i) for i in input().split(" ")]
    l.append(li)
    r.append(ri)

cor = [[0, 0] for i in range(0, h * w + 1)]
s = [0] * (h * w + 1)

for i in range(0, h):
    for j in range(0, w):
        cor[a[i][j]] = [i, j]

def mp(p, q):
    global cor
    return abs(cor[p][0] - cor[q][0]) +  abs(cor[p][1] - cor[q][1])

for m in range(1, d + 1):
    x = m + d
    while x <= h * w:
        s[x] = s[x - d] + mp(x, x - d)
        x += d

for i in range(0, q):
    print(s[r[i]] - s[l[i]])

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)



int main(){
	int N; cin >> N;
	vector<string> S(N);
	repp(i,0,N) cin >> S[i];
	int ans = 0;
	repp(k,0,N){
		bool b = 1;
		repp(i,0,N) repp(j,0,N) if(S[(i+k)%N][j] != S[(j+k)%N][i]) b = 0;
		if(b) ans += N;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
from math import factorial

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

for i in range(N-2):
  a += (P[i]-1-len([s for s in P[:i] if s < P[i]]))*factorial(N-i-1)
if P[N-2]>P[N-1]: a+=1

for i in range(N-2):
  b += (Q[i]-1-len([s for s in Q[:i] if s < Q[i]]))*factorial(N-i-1)  
if Q[N-2]>Q[N-1]: b+=1  
  
print(max(a,b)-min(a,b))  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const int MOD = 1e9 + 7;


int main() {
	// freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 1000 == 0) cout << 0 << endl;
	else cout << 1000 - (n % 1000) << endl;
	return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x=ii()
if x<=6:
    print(1)
    exit()
elif x<=11:
    print(2)
    exit()

ans = (x//11)*2
cnt = x%11

if cnt==0:
    print(ans)
elif cnt<=6:
    print(ans+1)
else:
    print(ans+2)

Measured memory_bytes: 66668
#!/usr/bin/python3

s = input()
k = int(input())

l = len(s)
all = set()
for i in range(l):
    cnt = 0
    for j in range(i, l):
        all.add(s[i:j + 1])
        cnt += 1
        if cnt >= k:
            break

print(sorted(all)[k - 1])

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    vi s(n + 1);
    rep(i, 0, n + 1) {
        char c;
        cin >> c;
        s[i] = c == '1' ? 0 : 1;
    }

    int curr = n;
    vi ans;

    // O(n)
    while (curr != 0) {
        // 到達可能な範囲．
        auto left = s.begin() + max(0, curr - m);
        auto right = s.begin() + curr;

        // 進行可能な範囲のうち，最も遠い点．
        int next = distance(s.begin(), find(left, right, 1));

        // 進行可能な点が無い場合．
        if (next == curr) { break; }

        ans.push_back(curr - next);
        curr = next;
    }

    if (curr != 0) {
        cout << -1 << endl;
    } else {
        reverse(all(ans));
        for (int a : ans) { cout << a << " "; }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int calc(int a, int b){
	int r;
	while(true){
		r = a%b;
		if (r==0){
			//return a/b;
			return b;
		}else{
			a = b;
			b = r;
		}
	}
}

int main(){
	int N, X, tmp, d, max_d;
	int x;
	cin >> N >> X;
	cin >> x;
	max_d = abs(X-x);
	for (int i=0; i<N-1; i++){
		cin >> x;
		d = abs(X-x);
		if (d >= max_d){
			if(d%max_d != 0){
				max_d = calc(d, max_d);
			}
		}else{
			if(max_d%d == 0){
				max_d = d;
			}else{
				max_d = calc(max_d, d);
			}
		}
	}
	cout << max_d << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	n := readInt()
	fmt.Println(int64(math.Pow(float64(n), 3.0)))
}

var reader = bufio.NewReaderSize(os.Stdin, 1024*1024)

func Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func readInt() int64 {
	temp := readLine()
	res, _ := strconv.ParseInt(temp, 10, 64)
	return res
}

func readInts() []int64 {
	nums := strings.Split(readLine(), " ")
	res := make([]int64, len(nums))
	for i, str := range nums {
		res[i], _ = strconv.ParseInt(str, 10, 64)
	}
	return res
}

func readLine() string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}


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

int main(void) {
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += min(x * 2, abs(k - x) * 2);
    }
    cout << ans << endl;
}


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

int main(){
    int x,n; cin >> x >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int reg_l, reg_r;
    for(int i = x; i > -201; i--) {
        auto itr = find(p.begin(), p.end(), i);
        if(distance(p.begin(),itr)==p.size()) {
            reg_l = i;
            break;
        }
    }
    for(int i = x; i < 301; i++) {
        auto itr = find(p.begin(), p.end(), i);
        if(distance(p.begin(),itr)==p.size()) {
            reg_r = i;
            break;
        }
    }
    cout << ( x-reg_l <= reg_r-x ? reg_l : reg_r ) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define rep(i,a,b) for (rg int i=(a);i<=(b);i++)
#define per(i,a,b) for (rg int i=(b);i>=(a);i--)
#define pb push_back
#define lowbit(x) (x&(-x))
#define replow(i,a,b) for(rg int i = (a);i<=(b);i+=lowbit(i))
#define perlow(i,a,b) for(rg int i = (b);i>=(a);i-=lowbit(i))
#define mk make_pair
#define VI vector<int>
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define fi first
#define se second
#define il inline
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define inf 0x3f3f3f3f
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<15],*p1 = buf,*p2 = buf;
inline ll read(){
    #define num ch-'0'
    char ch;bool flag=0;ll res;
    while(!isdigit(ch=getc()))
    (ch=='-')&&(flag=true);
    for(res=num;isdigit(ch=getc());res=res*10ll+num);
    (flag)&&(res=-res);
    #undef num
    return res;
}
inline void write(ll x){
	if (x < 0) x = ~x + 1ll, putchar('-');
	if (x > 9) write(x / 10ll);
	putchar(x % 10ll + '0');
}
#define mid ((l + r)>>1)
#define ls (x<<1)
#define rs ((x<<1)|1)
#undef mid
#undef ls
#undef rs
void solve()
{
	ll n = read();
	ll lim = (ll)sqrt(n * 1.0);
	per(i,1,lim)
	{
		if(n % i == 0)
		{
			cout<<(i+n/i-2);
			break;
		}
	}
}
int main()
{///
	#ifndef ONLINE_JUDGE
	freopen("data.txt","r",stdin);
	#endif
//	int T = read();
//	while(T--)
	solve();
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
long long c[110000];
int las[110000];
long long dp[110000];
long long bit[110000];
long long sum(int a,int b){
	if(a)return (sum(0,b)+mod-sum(0,a-1))%mod;
	long long ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret%mod;
}
void add(int a,long long b){
	for(;a<110000;a|=a+1)bit[a]=(bit[a]+b)%mod;
}
int main(){
	int a;
	long long x,y;
	scanf("%d%lld%lld",&a,&x,&y);
	for(int i=0;i<a;i++){
		scanf("%lld",c+i);
	}
	if(x>y)swap(x,y);
	for(int i=2;i<a;i++){
		if(c[i]-c[i-2]<x){
			printf("0\n");return 0;
		}
	}
	int now=0;
	for(int i=0;i<a;i++){
		las[i+1]=now;
		if(c[i+1]-c[i]<x)now=i+1;
	}
	dp[0]=1;
	add(0,1);
	for(int i=1;i<=a;i++){
		int at=upper_bound(c,c+a,c[i-1]-y)-c;
 
		long long tmp=0;
		if(las[i-1]<=at)tmp=sum(las[i-1],at);
		dp[i]=tmp;
		add(i,tmp);
	//	printf("%d: %d %d %lld\n",i,at,las[i-1],dp[i]);
	}
	long long ret=0;
	for(int i=las[a];i<=a;i++)ret+=dp[i];
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 1; i <= N; i++){
    for(int j = i; j <= N; j++){
      if(i == j) continue;
      if(i % 2 == 0 && j % 2 == 1) count++;
      else if(j % 2 == 0 && i % 2 == 1) count++;
    }
  }
  cout  << count;
}


Measured memory_bytes: 256