akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  string s,t="YAKI";
  cin >> s;
  
  if(s[0]==t[0] && s[1]==t[1] && s[2]==t[2] && s[3]==t[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#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>;

#include <atcoder/all>
using namespace atcoder;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> a(N), b(M);
    rep(i,N) {
        cin >> a[i];
    }
    rep(i,M) {
        cin >> b[i];
    }
    vector<ll> c = convolution<998244353>(a,b);
    rep(i,N+M-1) {
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

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

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), L(N + 1, 0), R(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        L[i + 1] = gcd(L[i], A[i]);
        R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);

    }
  	int ans = 1;
    for (int i = 0; i < N; i++){
        ans = max(ans, gcd(L[i], R[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    string s,t;
    cin >> s >> t;
    int ans=0, ss = s.length();
    rep(i,ss){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main(){
    int  i;
    vector<int> a;
    for(i=0;i<3;i++){
        int b;
        cin >> b;
        a.push_back(b);
    }
    sort(a.begin(), a.end());
    cout << abs(a[1]-a[0])+abs(a[1]-a[2]) <<endl;;
    return 0;
}

Measured memory_bytes: 256
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::cmp::max;

#[fastout]
fn main() {
    input! {in_n: usize, in_k: i32, in_c: i32, in_s: Chars};
    let mut l_works = vec![0i32; in_n + 1];
    let mut r_works = vec![0i32; in_n + 1];
    let mut l_count = 0;
    let mut r_count = 0;
    let mut l_break = 0;
    let mut r_break = 0;

    for i in 0..in_s.len() {
        if l_break == 0 && in_s[i] == 'o' {
            l_count += 1;
            l_break = in_c + 1;
        }

        if r_break == 0 && in_s[in_n - i - 1] == 'o' {
            r_count += 1;
            r_break = in_c + 1;
        }

        l_works[i + 1] = l_count;
        r_works[in_n - i - 1] = r_count;

        l_break = max(l_break - 1, 0);
        r_break = max(r_break - 1, 0);
    }

    for i in 0..in_n {
        if l_works[i] + r_works[i + 1] < in_k {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 4696
h, n = gets.split.map(&:to_i)
ary = Array.new(20001, 0xffffffff)
ary[0] = 0

n.times do
    a, b = gets.split.map(&:to_i)
    
    h.times do |i|
        x, y = ary[i + a], ary[i] + b
        ary[i + a] = y if y < x
    end
end

puts ary.drop(h).min


Measured memory_bytes: 1916
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
A = [list(input()) for i in range(a)]
B = [list(input()) for i in range(b)]

for h in range(a-b+1):
    for w in range(a-b+1):
        count = 0
        for bh in range(b):
            for bw in range(b):
                if A[bh+h][bw+w] == B[bh][bw]:
                    count += 1
        if count == b * b:
            print("Yes")
            exit()
print("No")



Measured memory_bytes: 5196
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.13 21:01:49
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll a,b,c,d;cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
int n,a,b;
long long odp, tb[50];
char s[20];
int main()
{
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf("%s", &s);
		if(s[0]=='M')tb[1]++;
		if(s[0]=='A')tb[2]++;
		if(s[0]=='R')tb[3]++;
		if(s[0]=='C')tb[4]++;
		if(s[0]=='H')tb[5]++;
	}
	for(int i=1; i<=5; i++)
		for(int j=i+1; j<=5; j++)
			for(int g=j+1; g<=5; g++)
				odp+=tb[i]*tb[j]*tb[g];
	printf("%lld", odp);
}

Measured memory_bytes: 128
#include<iostream>
#define MAX_N 200000
using namespace std;
typedef long long LL;
LL N;
LL A[MAX_N+2];
LL forward_PST[MAX_N+2];
LL backward_PST[MAX_N+2];
LL f_bs(int n, LL val)
{
	int L = 1;
	int R = n;
	while(R-L > 1)
	{
		int M = (L+R)/2;
		if(2*forward_PST[M] <= val)
			L = M;
		else
			R = M;
	}
	if(val - 2*forward_PST[L] < 2*forward_PST[R] - val)
		return L;
	else
		return R;
}
LL b_bs(int n, LL val)
{
	int L = n;
	int R = N;
	while(R-L > 1)
	{
		int M = (L+R)/2;
		if(2*backward_PST[M] <= val)
			R = M;
		else
			L = M;
	}
	if(val - 2*backward_PST[R] < 2*backward_PST[L] - val)
		return R;
	else
		return L;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N;
	for(int i = 1; i <= N; i++)
		cin >> A[i];

	forward_PST[0] = 0;
	for(int i = 1; i <= N; i++)
		forward_PST[i] = forward_PST[i-1] + A[i];
	backward_PST[N+1] = 0;
	for(int i = N; i >= 1; i--)
		backward_PST[i] = backward_PST[i+1] + A[i];

	LL the_best = 1000000000000000;
	for(int c = 2; c <= N-2; c++) // left half stretches from [1,c]
	{
		LL left_c = f_bs(c,forward_PST[c]);
		LL right_c = b_bs(c+1,backward_PST[c+1]); 
		LL the_min = min(min(forward_PST[left_c],forward_PST[c]-forward_PST[left_c]),min(backward_PST[right_c],backward_PST[c+1]-backward_PST[right_c]));
		LL the_max = max(max(forward_PST[left_c],forward_PST[c]-forward_PST[left_c]),max(backward_PST[right_c],backward_PST[c+1]-backward_PST[right_c]));
		the_best = min(the_best,the_max-the_min);
	}
	cout<<the_best<<endl;
	
	cout<<flush;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
 
int main()
{
	int n = 0;
	int l = 0;
	int i = 0;
	int j = 0;
	// 	char str[0][101] = {0};
	char str[101][101];
	char tmp[101];
	
	scanf("%d %d", &n, &l);
 
	for(i = 0; i < n; i++){
		scanf( "%s", str[i]);
	}
 
	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			if(strcmp(str[j], str[j+1]) >= 1){
				strcpy(tmp, str[j+1]);
				strcpy(str[j+1], str[j]);
				strcpy(str[j], tmp);
			}
		}		
	}
 
	for(i = 0; i <= n; i++){
		printf("%s", str[i]); 
	}
 

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,a,b; cin >> n >> a >> b;
    cout << min(b, n * a) << endl;

    return 0;
}



Measured memory_bytes: 256
#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>;

const int INF = 100100010001;

int a[12][12];

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s, 1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if(s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j, m) if (d[j]<x) ok = false;
    if(ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
def f(n)
  return 0 if n <= 0 or 36 < n
  f1([], 4, n, 9).reduce(:+)
end

def f1(acc, cnt, n, limit)
  return [ncombination(acc + [0] * cnt)] if n == 0
  lbound = [1, (n / cnt).to_i].max
  ubound = [n, limit].min
  ubound.downto(lbound).flat_map {|x| f1(acc + [x], cnt - 1, n - x, x) }
end

def ncombination(xs)
  @table = {
    [4] => 1,
    [3,1] => 4,
    [2,1,1] => 24 / 2,
    [2,2] => 24 / 2 / 2,
    [1,1,1,1] => 24
  }
  h = {}
  xs.each do |x|
    h[x] ||= 0
    h[x] += 1
  end
  @table[h.values.sort_by{|x| -x }]
end


while line = gets
  puts f(line.to_i)
end

Measured memory_bytes: 6112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, t, a;

  cin >> n >> t >> a;

  double maxdiff = INF;
  int ans = -1;
  
  for(int i=0;i<n;i++){
    int h;
    cin >> h;
    auto p = abs(a - (t - h * 0.006));
    if(p < maxdiff){
      ans = i;
      maxdiff = p;
    }
  }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define INF 9223372036854775807
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){ fast;
	int n, m, x; cin>>n>>m>>x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n){
		cin>>c[i];
		rep(j, m){
			cin>>a[i][j];
		}
	}
	ll ans = INF;
	rep(i, 1<<n){
		vector<int> b(m);
		int sum = 0;
		rep(j, n){
			if(1<<j & i){
				sum += c[j];
				rep(k, m)
					b[k] += a[j][k];
			}
		}
		int f = 1;
		rep(j, m){
			if(b[j] < x){
				f = 0;
				break;
			}
		}
		if(!f) continue;
		ans = min(ans, sum);
	}
	cout<<(ans == INF ? -1 : ans)<<endl;
}


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, m; cin >> n >> m;
    if (n == 0) return;

    vi32 a(n), b(m); cin >> a >> b;
    int sum_a = 0, sum_b = 0;
    sum_a = accumulate(all(a), 0);
    sum_b = accumulate(all(b), 0);
    if (abs(sum_a - sum_b) % 2 == 1) {
      cout << -1 << '\n';
      continue;
    }
    int diff = (sum_a - sum_b) / 2;
    sort(all(a)), sort(all(b));
    int idx = -1, idx2 = -1;
    rep(i, n) {
      rep(j, m) if (a[i] - b[j] == diff) {
        idx = i, idx2 = j;
        break;
      }
      if (idx != -1) break;
    }
    if (idx != -1) {
      cout << a[idx] << " " << b[idx2] << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	


	ll n;
	cin>>n;
	ll h[n+1];
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	ll dp[n+1];
	memset(dp,0,sizeof dp);
	for(ll i=2;i<=n;i++)
	{
		dp[i]=inf;
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i>=3)
		{
			dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i]);
		}
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k,m=1000000007;cin>>n>>k;
    std::vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    std::vector<std::vector<ll> > dp(n,std::vector<ll>(k+1,0));
    std::vector<std::vector<ll> > rv(n,std::vector<ll>(k+1,0));
    for (int i = 0; i <= k; ++i)
    {
    	if(i<=a[0]){
	    	dp[0][i]=1;
	    	if(i>0)rv[0][i]=rv[0][i-1]+1;
	    	else rv[0][i]=1;
	    }
	    else rv[0][i]=rv[0][a[0]];
    }
    for (int i = 0; i <n; ++i)
    {
    	dp[i][0]=1;
    	rv[i][0]=1;
    }
    for (int i = 1; i < n; ++i)
    {
    	ll up,lw,f=0;
    	for (int j = 1; j <= k; ++j)
    	{
    		up=rv[i-1][j];
    		if(j>a[i])lw=rv[i-1][j-a[i]-1];
    		else lw=0;
    		dp[i][j]=(up-lw)%m;
    		rv[i][j]=(rv[i][j-1]+dp[i][j]);
    	}
    }
    cout<<dp[n-1][k]%m<<"\n";
    
}


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

int main(void) {
    int N,X,Y; cin >> N >> X >> Y;
    int A[N+10] = {0};
    for(int i=1; i<=N-1; i++) {
        for(int j=i+1; j<=N; j++) {
          //int mm = min({abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X)});
          int mm = min({abs(j-i),abs(X-i)+1+abs(j-Y)});
          A[mm]++;
        }
    }
    for(int i=1; i<=N-1; i++) cout << A[i] << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,x;
bool used[200005]={};
int ans[200005];
int main(){
	cin>>n>>x;
	if(x==1||x==2*n-1){
		puts("No");
	}
	else{
		ans[n] = x;
		ans[n-1] = 1;
		ans[n+1] = 2*n-1;
		used[x]=used[1]=used[2*n-1]=1;
		for(int i=2;i<x&&n>2;i++){
			if(!used[i]){
				ans[n+2] = i;
				used[i] = 1;
				break;
			}
		}
		for(int i=x+1;i<2*n-1&&n>2;i++){
			if(!used[i]){
				ans[n-2] = i;
				used[i] = 1;
				break;
			}
		}
		int nxt = 1;
		for(int i=1;i<=2*n-1;i++){
		    if(ans[i]) continue;
			while(used[nxt]) nxt++;
			ans[i] = nxt;
			used[nxt] = 1;
		}
		puts("Yes");
		for(int i=1;i<=2*n-1;i++) printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int a[110];
int main()
{
	int n;
	scanf("%d",&n);
	ll sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	} 
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			sum+=a[i]*a[j];
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define MAX (ll)(1e18)
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	ll t[n], a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> t[i] >> a[i];
		//cout << t[i] << " " << a[i] << endl;
	}
	ll tt[n], aa[n];
	tt[0] = t[0], aa[0] = a[0];
	//cout << tt[0] << " " << aa[0] << endl;
	for(int i = 1; i < n; i++)
	{
		ll lo = 0;
		ll hi = (MAX/max(t[i],a[i]))+1;
		while(hi-lo>1)
		{
			ll mid = (lo+hi)>>1;
			if(mid * t[i] >= tt[i-1] && mid * a[i] >= aa[i-1])
			{
				hi = mid;
			}
			else
			{
				lo = mid;
			}
		}
		tt[i] = hi * t[i];
		aa[i] = hi * a[i];
		//cout << hi << endl;
		//cout << t[i] << " " << a[i] << endl;
		//cout << tt[i] << " " << aa[i] << endl;
	}
	cout << tt[n-1] + aa[n-1] << endl;
	return 0;
}


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

#define int long long  
#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()
 
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007
 

int32_t main(){
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
     IOS
   string s;
   cin>>s;
   if(s=="Sunny")
    cout<<"Cloudy";
    else if(s=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int ans = 1, cnt = 1;
    bool flag = false;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        if (a) {
            if (!flag) flag = true;
            cnt++;
        } else if (flag) {
            cnt = 1;
            flag = false;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3108
fun main() {
  val (N, M) = readInts()
  val S = (1..M).map { readInts().drop(1) }
  val P = readInts()

  fun isAllLighting(b: Int): Boolean {
    S.forEachIndexed { i, s ->
      val p = P[i]
      var cnt = 0
      s.forEach { si ->
        val mask = 1.shl(si - 1)
        if (mask.and(b) > 0) cnt++
      }
      if (cnt % 2 != p) return false
    }
    return true
  }

  var cnt = 0
  for (b in 0 until 1.shl(N)) {
    if (isAllLighting(b)) cnt++
  }
  println(cnt)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 38120
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    string s;
    cin >> s;
    if(N >= 3200) print(s);
    else print("red");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  vector<ull> H(N);
  for(auto& h : H) cin >> h;

  ull res{};
  ull ans{};
  for(ui i = 0; i < N - 1; ++i)
  {
    if(H[i] >= H[i + 1])
    {
      ++res;
    }
    else
    {
      chmax(ans, res);
      res = 0;
    }
  }
  chmax(ans, res);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;

pair<int, int> A[100005];

int abs(int x){ return x < 0 ? -x : x; }

int main(){
    int N;
    scanf("%d", &N);
    for(int i=0; i<N; i++) scanf("%d", &A[i].first), A[i].second = i;
    sort(A, A+N);
    int res=0;
    for(int i=0; i<N; i++){
        if(abs(A[i].second-i)%2) res++;
    }
    printf("%d", res/2);
    return 0;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, a[2][20];
    cin >> n;
    rep(i, n) cin >> a[0][i];
    rep(i, n) cin >> a[1][i];

    int ans = 1e9;

    rep(i, 1 << n) {
        vector<int> vec, vec2[51];
        int num = 0, cnt[2][51] = {}, xx = 0;
        rep(j, n) {
            int x = (i >> j) & 1;
            xx += x + j & 1;
            vec.push_back(a[x][j]);
            vec2[a[x][j]].push_back((x + j & 1) + 2 * cnt[x + j & 1][a[x][j]]);
            cnt[x + j & 1][a[x][j]]++;
        }
        if(n / 2 != xx) continue;
        rep(j, n) FOR(k, j + 1, n) if(vec[j] > vec[k]) num++;
        sort(vec.begin(), vec.end());
        rep(j, 51) {
            if(lower_bound(vec.begin(), vec.end(), j) - vec.begin() & 1)
                rep(k, vec2[j].size()) if(vec2[j][k] % 2 == 0) vec2[j][k] += 2;
            rep(k, vec2[j].size()) {
                FOR(l, k + 1, vec2[j].size()) {
                    if(vec2[j][k] > vec2[j][l]) {
                        num++;
                    }
                }
            }
        }
        rep(j, n) cnt[j & 1][vec[j]]--;
        bool ok = 1;
        rep(j, 2) FOR(k, 1, 51) if(cnt[j][k] != 0) ok = 0;
        if(!ok) continue;
        // cout << 1 << endl;

        chmin(ans, num);
    }
    // cout << -1 << endl;
    cout << (ans != 1e9 ? ans : -1) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10,MOD=998244353;
ll N,K,L[16],R[16],D[MAXN];
inline ll lowbit(ll n) { return n&(-n); }
inline void add(ll pos,ll val){
    val=(val%MOD+MOD)%MOD;
    for(;pos<=N;pos+=lowbit(pos)) D[pos]=(D[pos]+val)%MOD;
}
inline void add(ll l,ll r,ll val){
    if(l>r) return ;
    add(l,val);
    add(r+1,-val);
}
inline ll query(ll pos){
    ll Ans=0;
    for(;pos;pos-=lowbit(pos)) Ans=(Ans+D[pos])%MOD;
    return Ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N>>K;
    for(int i=1;i<=K;i++) cin>>L[i]>>R[i];
    add(1,1,1);
    ll qry;
    for(int i=1;qry=query(i),i<=N;i++)
        for(int k=1;k<=K;k++)
            add(i+L[k],min(i+R[k],N),qry);
    cout<<query(N)<<endl;
    return 0;
}

Measured memory_bytes: 5208
n = int(input())
S = [[] for _ in range(n)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        S[i].append(s[j])
        S[i].sort()
alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = ''
cnt = 50
for i in range(26):
    for j in range(n):
        cnt = min(cnt, S[j].count(alp[i]))
    if cnt != 0:
        ans += alp[i]*cnt
    cnt = 50
print(ans)


Measured memory_bytes: 39408
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  int a[100];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int j=n-1;j>=0;j--){
    if(j==n-1){
      cout << a[j];
    }else{
      cout << " " << a[j];
    }
  }
  cout << endl;
}

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

typedef long long ll;

vector<ll> sieve(ll n){
    vector<ll> prime(n+1,1);
    for(ll i=2;i*i<=n;i++){
        if(prime.at(i) == 1){
            ll j=2*i;
            while(j <= n){
                prime.at(j) = 0;
                j += i;
            }
        }
    }
    
    return(prime);
}

ll nmax = 100100;
int main(){
    ll x;
    cin >> x;
  
  	const auto &list = sieve(nmax);
  
  	for(ll i=x;i<=nmax;i++){
		if(list.at(i) == 1){
          	cout << i << endl;
          	return(0);
        }
    }

    return(0);
}

Measured memory_bytes: 4048
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[300001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<3*n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n*3);
	ll sum=0;
	for(int i=n;i<3*n;i+=2){
		sum+=a[i];
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll a[n+2],b;
    a[0] = 0;
    a[n+1] = INF;
    rep(i,n){
        cin >> b;
        a[i+1] = (a[i]+b)%m;
    }
    sort(a,a+n+1);
    ll ans = 0,cnt = 1;
    rep(i,n+1){
        if (a[i] == a[i+1]) cnt++;
        else{
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    string s;
    cin>>s;
    ll ans=0;
    ll ar[s.size()+1];
    ll carry=0;
    ar[s.size()]=0;
    for(ll i=s.size()-1;i>=0;i--)
    {
        ll temp=s[i]-'0';
        ar[s.size()-1-i]=temp;
    }
    for(ll i=0;i<s.size();i++)
    {
        if(ar[i]<5)
        {
            ans+=ar[i];
        }
        else if(ar[i]>5)
        {
            ans+=(10-ar[i]);
            ar[i+1]++;
        }
        else 
        {
            if(ar[i+1]>=5)
            {
               ar[i+1]++;
               ans+=5;
            }
            else
            {
                ans+=5;
            }
        }
    }
    cout<<ans+ar[s.size()];
}

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

using namespace std;

int main()
{
	int n, m;
	cin>>n;
	vector<int>ans(n+1);
	for(int i=1; i<=100; i++)
	{
		for(int j=1; j<=100; j++)
		{
			for(int k=1; k<=100; k++)
			{
				m=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
				if(m<=n)
				ans[m]++;
				else
				break;
			}
		}
	}
	for(int i=0; i<n; i++)
	cout<<ans[i+1]<<"\n";
	return 0;
}


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

int main() {
    bool g = false, k = false;
	unsigned long long a[1000000], p = 1;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> a[i];
	    if (a[i] != 0 && 1000000000000000000 / a[i] < p)
            g = true;
        else
            if (a[i] == 0)
                k = true;
	    p *= a[i];
	}
	if ((g == true && k == true) || (k == true && g == false))
	    cout << 0;
	else
	    if (k == false && g == true)
	        cout << -1;
	    else
	        if (p <= 1000000000000000000)
	            cout << p;
	        else
	            cout << -1;
	            
	return 0;
}


Measured memory_bytes: 4424
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  if(A>=K){
    cout<<A-K<<" "<<B<<endl;
  }else{
    cout<<0<<" "<<max(0ll,B-(K-A))<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i, n) for (int i=2;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  int n,x=0;
  string s;
  cin >> n >> s;
  r(i, n) {
    if(s.at(i-2)=='A'&&s.at(i-1)=='B'&&s.at(i)=='C') x++;
  }
  cout << x << endl;
}

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

d = {};

for i in range(n):
    s = input();
    if s in d:
        d[s] += 1;
    else:
        d[s] = 1;

mx = 0;
for s in d:
    if d[s] > mx:
        mx = d[s];

res = [];

for s in d:
    if d[s] == mx:
        res.append(s);

res.sort();

for s in res:
    print(s);




Measured memory_bytes: 32096
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_1_C&lang=jp
# List

from collections import deque
#import cProfile
#import time
import sys

input = sys.stdin.readline

def loop_proc():
    q1 = deque()
    q2  = deque()
    l2 = []
    cur = 0
    rflag = True
    n = int(input())
    cnt = 0

    while (cnt < n):
        cnt += 1
        if (rflag == True):
            l = list(map(int,input().split()))
        else:
            l = l2
        c = l[0]
        rflag =True
        #追加する場合
        if ( c == 0 ):
            d = l[1]
            #APPEND() & POP()は読み飛ばす
            if (cnt < n ):
                l2 = list(map(int,input().split()))
                if (l2[0] == 2 ):
                    cnt += 1
                    continue
                rflag =False
            q1.append(d)
        #カーソル移動の場合
        elif(c == 1):

            cur = l[1]
            if cur <  0 :
                for i in range(abs(cur)):
                    q1.append(q2.pop())
            else:
                for i in range(abs(cur)):
                    q2.append(q1.pop())
#            print (q1,q2)
        #要素削除の場合
        elif(c == 2):
            q1.pop()

    while len(q2) != 0 :
        print (q2.popleft())
    while len(q1) != 0 :
        print (q1.pop())

#    for i in wl:
#        print (i)
loop_proc()
#pr = cProfile.Profile()
#pr.enable()
#pr.runcall(loop_proc)
#pr.print_stats()


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

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


    int turn = 0;
    while(1) {
        if (turn%2) {
            /* aoki. */
            A -= D;
            if (A  <= 0) {
                cout << "No" << endl;
                break;
            }
        } else {
            /* takahashi. */
            C -= B;
            if (C  <= 0) {
                cout << "Yes" << endl;
                break;
            }
        }
        turn++;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main()
{
    int n ;
    cin>>n;
    cin.ignore();
    int ac=0,wa=0,tle=0,re=0;
    while(n--){
            string a;
            cin>>a;
            if(a=="AC"){ac++;}
            else if(a=="WA"){wa++;}
            else if(a=="TLE"){tle++;}
            else if(a=="RE"){re++;}
        }
        cout<<"AC x "<<ac<<nl;
        cout<<"WA x "<<wa<<nl;
        cout<<"TLE x "<<tle<<nl;
        cout<<"RE x "<<re<<nl;
        
  


}



Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    string p;
    cin >> p;
    int ans = 0, a = 0;
    for (int i = 0; i < p.size(); i++) {
        if (p[i] == 'A' || p[i] == 'C' || p[i] == 'T' || p[i] == 'G') {
            a++;
        }
        else a = 0;
        ans = max(ans, a);
    }
    cout << ans << endl;
    
    return 0;

}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  string s;
  cin >> s;
  rep(i,s.size()){
    cout << 'x';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  cout<<N/3<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

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

    int k = 0;

    for(int i = 0; i < str.size() / 2; i++){
        if(str.at(i) == str.at(str.size() - i - 1)) 
            continue;
        else
            k++;
    }   

    cout << k << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<bool> has(n);
    for (ll i = 0; i < k; i++)
    {
        ll d;
        cin >> d;
        for (ll i = 0; i < d; i++)
        {
            ll a;
            cin >> a;
            has[a - 1] = true;
        }
    }
    ll cnt = 0;
    for (ll h : has)
    {
        if (!h)
            cnt++;
    }
    cout << cnt << endl;
}


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


int main(){


    int N , K; std::cin >> N >> K;

    int now = 1;

    for(int i = 0; i < N; i++){
        now += std::min(now , K);
    }

    std::cout << now;
    
    system("pause");

    return 0;

}

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

int power(int a, int b)
{
    int ans = 1;
    for(int i=0;i<b;i++)
        ans *= a;
    return ans;
}

int main()
{
    int dp[100010];
    int N;
    cin >> N;
    dp[0] = 0;
    int temp, temp2;
    for(int i=1;i<=N;i++)
    {
        temp = 100000;
        for(int j=1;j<=5;j++)
        {
            temp2 = i-power(9, j);
            if(temp2 >= 0)
                if((dp[temp2] + 1) < temp)
                    temp = dp[temp2] + 1;
        }
        for(int j=1;j<=6;j++)
        {
            temp2 = i-power(6, j);
            if(temp2 >= 0)
                if((dp[temp2] + 1) < temp)
                    temp = dp[temp2] + 1;
        }
        temp2 = i - 1;
        if((dp[temp2] + 1) < temp)
            temp = dp[temp2] + 1;
        dp[i] = temp;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i<N;i++)
  {
    cin >> vec[i];
  }
  int max = 0;
  int sum = 0;
  for(int i = 0;i < N;i++){
    sum += vec[i];
    if(vec[i] > max)
    {
      max = vec[i];
    }
  }
  sum -= max;
  if(sum > max){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    vector<ll> l(100);
    l[0] = 2,l[1] = 1;
    for(int i = 2; i <= n; i++) l[i] = l[i-1]+l[i-2];
    cout << l[n] << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif


    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i < n; ++i){
        if(n % i == 0){
            ans += n / i;
            ans -= 1;
        }
        else{
            ans += n / i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

ll k,now = 100;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>k;
  for(int i = 1;i <= 1e5;i++){
    now *= 1.01;
    if(now >= k){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


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

const int NIL = -1;
class Node {
public:
	int p, l, r;
	Node(int pp, int ll, int rr) { p = pp; l = ll; r = rr; }
};

vector<Node> T;
vector<int> D;

void rec( int u, int p)
{
	D[u] = p;
	if( T[u].r != NIL ) rec( T[u].r, p );
	if( T[u].l != NIL ) rec( T[u].l, p + 1 );
}

int main()
{
	int n;
	cin >> n;
	T = vector<Node>( n, Node( NIL, NIL, NIL ) );
	D = vector<int>( n );
	for( int i = 0; i < n; i++ ) {
		int id, k, l;
		cin >> id >> k;
		for( int j = 0; j < k; j++ ) {
			int c;
			cin >> c;
			if( j == 0 ) {
				T[id].l = c;
			}
			else {
				T[l].r = c;
			}
			l = c;
			T[c].p = id;
		}
	}

	int r;
	for( int i = 0; i < n; i++ ) {
		if( T[i].p == NIL ) r = i;
	}
	rec( r, 0 );

	for( int i = 0; i < n; i++ ) {
		cout << "node " << i << ": ";
		cout << "parent = " << T[i].p << ", ";
		cout << "depth = " << D[i] << ", ";
		if( T[i].p == NIL ) cout << "root, ";
		else if( T[i].l == NIL ) cout << "leaf, ";
		else cout << "internal node, ";
		cout << "[";
		for( int j = 0, c = T[i].l; c != NIL; j++, c = T[c].r ) {
			if( j ) cout << ", ";
			cout << c;
		}
		cout << "]" << endl;
	}
}



Measured memory_bytes: 7664
#include<bits/stdc++.h>
#define mp   make_pair
typedef long long ll;
using namespace std;
int main(){
    map<ll,ll>cnt,cnt1,diff;
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    long long ans=0;
    for(auto p:cnt){
        cnt[p.first] = (p.second*(p.second-1))/2;
        cnt1[p.first] = (p.second-1)*(p.second-2)/2;
        diff[p.first] = max(ll(0),cnt[p.first]-cnt1[p.first]);
        //cout<<p.first<<" "<<p.second<<"\n";
        ans+=cnt[p.first];
    }
    for(i=0;i<n;i++){
        ll res;
        res=ans-diff[a[i]];
        cout<<res<<"\n";
    }

    return 0;
}


Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  int N,count1=0,count2=0,count4=0,q;
  cin >> N;
  FOR(i,0,N){
    cin >> q;
    if(q%4){
      if(q%2)count1++;
      else count2++;
    }
    else count4++;
  }
  if(count2){
    if(count1 <= count4)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(count1 <= count4+1)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

typedef long long ll;



int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;

    vector<int> a(100010), p(100010);

    for(int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        a[l]++;
        a[r + 1]--;
    }

    for(int i = 1; i <= 100002; i++) {
        p[i] = p[i - 1] + a[i];
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(p[i] >= m) ans++;
    }

    cout << ans << endl;
}

/**
*/


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

#define MAX 50

long long N;
long long X;

long long num[MAX + 1][2];

long long dfs( long long n, long long x, long long add )
{
	if( n > 0 && x <= n ) {
		return add;
	}
	else if( num[n][0] - n <= x && x <= num[n][0] ) {
		return num[n][1] + add;
	}
	else if( x <= num[n - 1][0] - (n - 1) + 1 ) {
		return dfs( n - 1, x - 1, add );
	}
	else if( num[n - 1][0] - (n - 1) + 1 <= x && x <= num[n - 1][0] + 1 ) {
		return num[n - 1][1] + add;
	}
	else if( num[n - 1][0] + 1 < x && x <= num[n - 1][0] + 2 ) {
		return num[n - 1][1] + 1 + add;
	}
	return dfs( n - 1, x - ( num[n - 1][0] + 2 ), add + num[n - 1][1] + 1 );
}

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

	num[0][0] = 1;
	num[0][1] = 1;
	for( int i = 0; i < 50; i++ ) {
		num[i + 1][0] = num[i][0] + (1LL << (i + 1)) * 2;
		num[i + 1][1] = num[i][1] + (1LL << (i + 1));
	}

	long long ans = dfs( N, X, 0 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n,a,b = list(map(int,input().split()))
mod = 10**9 + 7

ans = (pow(2,n,mod) - 1) %mod
numerator = 1%mod
denominator = 1%mod
for i in range(1,b+1):
    numerator = (numerator*(n+1-i))%mod
    denominator = (denominator*pow(i,mod-2,mod))%mod
    if i == a or i == b:
        ans = (ans - (numerator*denominator))%mod

print(ans)

Measured memory_bytes: 3064