akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

bool isPrime(ll x){
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(ll i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int a;
        cin>>a;
        ans+=isPrime(a);
    }
    fin(ans);
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>

struct MT {
public:
	int w;
	int h;
};

int max(int a, int b) {
	return a > b ? a : b;
}

int main() {
	std::ifstream ifs("input.txt");
	do {
		int n, m;
		std::cin >> n;
		std::vector<MT> mtA;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			int w, h;
			std::cin >> w;
			std::cin >> h;
			MT m;
			m.w = w;
			m.h = h;
			mtA.push_back(m);
		}

		std::cin >> m;
		for (int i = 0; i < m; i++) {
			int w, h;
			std::cin >> w;
			std::cin >> h;
			MT m;
			m.w = w;
			m.h = h;
			mtA.push_back(m);
		}

		std::sort(mtA.begin(), mtA.end(), [](const MT& lhs, const MT& rhs){return lhs.w < rhs.w; });

		/*
		std::cout << "testtest" << std::endl;
		for (int i = 0; i < n + m; i++) {
			std::cout << mtA[i].w << std::endl;
		}
		std::cout << "endtest" << std::endl;
		*/

		std::vector<int> paths(n + m);
		int minw = mtA[0].w;
		int mini;
		for (int i = 0; i < n + m; i++) {
			if (mtA[i].w == minw) {
				paths[i] = 1;
			}
			else {
				mini = i;
				break;
			}
		}

		for (int i = mini; i < n + m; i++) {
			for (int j = 0; mtA[j].w != mtA[i].w; j++) {
				if (mtA[j].h < mtA[i].h) {
					paths[i] = max(paths[i], paths[j] + 1);
					//std::cout << "i:" << i << "j:" << j << " paths[i]:" << paths[i] << " paths[j]:" << paths[j] << std::endl;
				}
			}
		}
		int maxpath = 0;
		for (int i = 0; i < n + m ; i++ ) {
			maxpath = max(maxpath, paths[i]);
		}
		std::cout << maxpath << std::endl;

	} while (1);


	return 0;
}

Measured memory_bytes: 1236
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i, j in zip(a, range(n)):
    ans += b[i - 1]
    if j < n - 1 and a[j] == a[j + 1] - 1:
        ans += c[i - 1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{int to,id;};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<vector<edge>> g(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back({b,int(i)});
        g[b].push_back({a,int(i)});
    }
    int k=0;
    rep(i,n) chmax(k,int(g[i].size()));
    vector<int> ans(n-1);
    auto dfs=[&](auto &dfs,int v,int pre,int c)->void{
        int now=0;
        for(auto to:g[v]){
            if(to.to==pre) continue;
            now++;
            if(now==c) now++;
            ans[to.id]=now;
            dfs(dfs,to.to,v,now);
        }
    };
    dfs(dfs,0,-1,0);
    cout<<k<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 6912
#include<stdio.h>

typedef long long lld;
lld N, NN, ba[101010], sum;

int main(){
	scanf("%lld", &N), NN=N*(N+1)/2;
	for(int i=0; i<N; i++)scanf("%lld", &ba[i]), sum+=ba[i];
	if(sum % NN)puts("NO");
	else{
		sum /= NN;
		for(int i=0; i<N; i++){
			lld t = ba[i]+sum-ba[(i+1)%N];
			if(t<0 || t%N){puts("NO"); return 0;}
		}
		puts("YES");
	}
	return 0;
}

Measured memory_bytes: 896
n=int(input())
slist=[]
for i in range(n):
    slist.append(input())
alphabet=["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"]
times=[]
for i in alphabet:
    saitei=1000
    for j in range(n):
        kosu=slist[j].count(i)
        if kosu<saitei:
            saitei=kosu
    times.append(saitei)
ans=[]
for i in range(len(alphabet)):
    for j in range(times[i]):
        ans.append(alphabet[i])
for i in range(len(ans)):
    print(ans[i],end="")
print("")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

size_t N;
vector<size_t> g[105];
vector<size_t> d(105), f(105);
vector<bool> seen(105);

size_t t = 0;

void dfs(size_t now_node) {
    seen[now_node] = true;
    d[now_node] = ++t;
    for (auto &next_node: g[now_node]) {
        if (!seen[next_node]) {
            dfs(next_node);
        }
    }
    f[now_node] = ++t;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;

    for (size_t i = 0; i < N; ++i) {
        size_t u, k; cin >> u >> k;
        u--;
        for (size_t j = 0; j < k; ++j) {
            size_t v; cin >> v;
            v--;
            g[u].emplace_back(v);
        }
    }

    for (size_t idx = 0; idx < N; ++idx) {
        if (!seen[idx]) {
            dfs(idx);
        }
    }

    for (size_t idx = 0; idx < N; ++idx) {
        cout << idx + 1 << " " << d[idx] << " " << f[idx] << "\n";
    }

    return 0;
}



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

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

int N, A, B, C;
vector<int> l;
const int inf = 1 << 30;

int rec(int i, int a, int b, int c) {
    int ans = inf;
    if (i == N) {
        if (a && b && c) ans = abs(A-a) + abs(B-b) + abs(C-c);
        return ans;
    } 
    chmin(ans, rec(i+1, a, b, c));
    chmin(ans, rec(i+1, a+l[i], b, c) + (a ? 10 : 0));
    chmin(ans, rec(i+1, a, b+l[i], c) + (b ? 10 : 0));
    chmin(ans, rec(i+1, a, b, c+l[i]) + (c ? 10 : 0));
    return ans;
}

int main() {
    scanf("%d %d %d %d", &N, &A, &B, &C);
    l.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", & l[i]);
    
    int ans = rec(0, 0, 0, 0);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MN 100
#define MW 10000

int main(){
	int dp[MN+1][MW+1] = {0};
	int weight[MN];
	int price[MN];
	int n,w;
	cin >> n >> w;
	for(int i=0;i<n;++i){
		cin >> price[i] >> weight[i];
	}
	//dp[i][j] = iこの荷物をj以下の重さになるよう入れたときのコストの最大化
	for(int i=0;i<n;++i){
		for(int j=0;j<=w;++j){
			if(j >= weight[i])dp[i+1][j] = max(dp[i][j-weight[i]] + price[i],dp[i][j]);
			else dp[i+1][j] = dp[i][j];
		}
	}
	cout << dp[n][w] << endl;
}


Measured memory_bytes: 7032
package main

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

func main() {
	scanInit()

	k := nextInt()
	s := nextInt()
	cnt := 0
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			m := s - i - j
			if m >= 0 && m <= k {
				cnt++
			}
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            //int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int d = int.Parse(Console.ReadLine());

            string ans_eve = string.Concat(Enumerable.Repeat(" Eve", 25 - d));
            Console.WriteLine("Christmas" + ans_eve);

            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 11220
package main

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

var sc *bufio.Scanner

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

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

type node struct {
	len      int
	idxs     []int
	children map[rune](*node)
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, s := nextInt(), nextStr()
	rs := []rune(s)

	root := node{0, make([]int, n), make(map[rune](*node), 0)}
	for i := 0; i < n; i++ {
		root.idxs[i] = i
	}
	queue := []*node{&root}
	ans := 0
	for len(queue) > 0 {
		cur := queue[0]
		queue = queue[1:]
		if cur.idxs[len(cur.idxs)-1]-cur.idxs[0] < cur.len {
			continue
		}
		ans = cur.len
		for _, idx := range cur.idxs {
			if idx+cur.len >= n {
				continue
			}
			r := rs[idx+cur.len]
			child, ok := cur.children[r]
			switch {
			case ok:
				child.idxs = append(child.idxs, idx)
			default:
				child = &(node{cur.len + 1, []int{idx}, make(map[rune](*node), 0)})
			}
			cur.children[r] = child
		}
		for _, child := range cur.children {
			queue = append(queue, child)
		}
	}

	fmt.Println(ans)
}


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

int int_comp(const void *a, const void *b)
{
    return (*(int *)a) - (*(int *)b);
}

int main()
{
    int N;
    int M;
    int X[100000];
    int diff[100000];
    int i;
    int sum;
    int ret;

    scanf("%d %d", &N, &M);
    for(i = 0; i < M; i++) {
        scanf("%d", &X[i]);
    }

    if(N >= M) {
        printf("0\n");
        return 0;
    }

    qsort(&(X[0]), M, sizeof(X[0]), int_comp);
    for(i = 0; i < M-1; i++) {
        diff[i] = X[i+1] - X[i];
    }

    qsort(&(diff[0]), M-1, sizeof(diff[0]), int_comp);
    sum = 0;
    for(i = 0; i < M-N; i++) {
        sum += diff[i];
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
int max(int a,int b){
    if(a>b)
        return a;
    return b;
}
int knapsack(int W,int w[],int val[],int N){
    int dp[N+1][W+1];
    for(int i = 0;i <= N; i++)
        dp[i][0] = 0;
    for(int i = 0;i <= W; i++)
        dp[0][i] = 0;
    // for(int j = 0; j <= W; j++){
    //         cout << dp[0][j] << " ";
    //     }
    for(int i = 1;i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(w[i-1]<=j)
                dp[i][j] = max(val[i-1] + dp[i-1][j-w[i-1]],dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
   // for(int i = 0;i <= N; i++){

        cout << "\n";
   // }
    return dp[N][W];
}
int32_t main()
{
    IOS;
    int N,W;
    cin >> N >> W;
    int w[N],val[N];
    for(int i = 0;i < N; i++){
        cin >> w[i] >> val[i];
    }
    cout << knapsack(W,w,val,N) << "\n";
    return 0;
}

Measured memory_bytes: 82512
#include<stdio.h>

int main(){
  long long n,k,sa,sb,sc;
  long long a,b,c;
  scanf("%lld%lld",&n,&k);
  sa=(((k)+(k+n-1))*n)/2;
  sb=(((k+n)+(k+2*n-1))*n)/2;
  sc=(((k+2*n)+(k+3*n-1))*n)/2;
  if(sa+sb>sc){printf("-1\n");return 0;}
   a=(n/2);
   b=-1;
   for(c=0;c<n;c++){
    a--;
    if(a<0){a=n-1;}
    b+=2;
    if(b>=n){
      if(n%2==0){b--;}
      b%=n;
    }
    printf("%lld %lld %lld\n",k+a,k+n+b,k+2*n+c);
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long 
using namespace std;
const int N=12;
int mk[N],g[N];

int main(){
	int n,k;scanf("%d%d",&n,&k);
	fr(i,1,k) {
		int x;scanf("%d",&x);
		mk[x]=1;
	}
	int res=0;
	for(;n;n/=10) g[++res]=n%10;
	reverse(g+1,g+1+res);
	int F=1;
	fr(i,1,res){
		int flg=0;
		fr(j,0,9){
			if(!mk[j]&&j>=g[i]){
				flg=1;
				if(j>g[i]) {
					g[i]=j;int tmp=0;
					rf(t,9,0) if(!mk[t]) tmp=t;
					fr(t,i+1,res) g[t]=tmp;
					fr(t,1,res) printf("%d",g[t]);
					return 0;
				}
				g[i]=j;
				break;
			}
		}
		if(!flg) F=0;
	}
	if(!F){
		int tmp=0;
		rf(i,9,1) if(!mk[i]) tmp=i;
		printf("%d",tmp);
		rf(i,9,0) if(!mk[i]) tmp=i;
		fr(i,1,res) printf("%d",tmp);
	}
	else fr(i,1,res) printf("%d",g[i]);
	return 0;
}

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

int main() {
  long long x;
  cin >> x;
  
  long long ans = 0;
  ans += (x / 11) * 2;
  if(x % 11 > 6) ans += 2;
  else if(x % 11 > 0) ans += 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
 ll n,m,ans=0; cin>>n>>m;
  set<ll>v;
  ll a;
  rep(i,n) {
    cin>>a;
    v.insert(a);
           }
  
  if(v.size()!=1){
  ll ma=*rbegin(v);
  v.erase(ma);
  
  ll next=*rbegin(v);
  v.erase(next);
  ll i=ma/2;
  while(i<=m){
  bool t=true;
   
    if((i-next/2)%next!=0){
    t=false;
  }
    
    if(t){
    for (auto val : v) {
    if((i-val/2)%val!=0){
   t=false;   
    break;
  }
}
    }
    if(t)ans++;
  i+=ma;
  }
  }
 ///////////////////////////////// 
  else{
   ll ma=*rbegin(v);
  v.erase(ma);
  
  ll i=ma/2;
  while(i<=m){
  bool t=true;    

    for (auto val : v) {
    if((i-val/2)%val!=0){
   t=false;   
    break;
  }
    }
    
    if(t)ans++;
  i+=ma;
  }
  }
    
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n/3<<endl;
}

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

int main(){
  long long K,A,B;
  cin >> K >> A >> B;
  if(K>A && A<=B){cout << -1 << endl; return 0;}
  else if(A<=B){cout << 1 << endl; return 0;}
  long long q=(K-B+A-B-1)/(A-B);
  cout << q*2-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int a[102][102];//应设为 102，若为101，则下面的空间不够j+1; 
    char ch;
     int l1,l2;
    int n,m;
    cin>>n>>m;
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
      {
        cin>>ch;
        if(ch=='#')  //定义一下雷 
          a[i][j]=-1;
        }  
    for(int i=1;i<=n;i++)
    {
    for(int j=1;j<=m;j++)
      {
      if(a[i][j]==-1) 
        cout<<"#";
        else
      {               
      if(a[i-1][j]==-1) a[i][j]++;
      if(a[i-1][j-1]==-1) a[i][j]++;
      if(a[i-1][j+1]==-1) a[i][j]++;
      if(a[i][j-1]==-1) a[i][j]++;
      if(a[i][j+1]==-1) a[i][j]++;
      if(a[i+1][j-1]==-1) a[i][j]++;
      if(a[i+1][j]==-1) a[i][j]++;
      if(a[i+1][j+1]==-1) a[i][j]++;
      cout<<a[i][j];    
      }

      } 
      cout<<endl;
      }  
     return 0;    
}

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;

const int N = 210;

int n;
pii A[N];
pii B[N];
bool bio[N * 2];
vector<int> graf[N];
int veza[N * 2];

bool dfs(int node){
  bio[node] = true;
  for(auto it : graf[node]){
    if(veza[it] == 0 || (!bio[veza[it]] && dfs(veza[it]) == true)){
      veza[it] = node;
      return true;
    }
  }
  return false;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d %d", &A[i].fi, &A[i].se);
  for(int i = 0; i < n; i++) scanf("%d %d", &B[i].fi, &B[i].se);

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(A[i].fi < B[j].fi && A[i].se < B[j].se)
        graf[i + 1].pb(j + n);
    }
  }

  int sol = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= 2 * n; j++)
      bio[j] = false;
    sol += dfs(i);
  }

  printf("%d\n", sol);

  return 0;
}


Measured memory_bytes: 256
# 入力
N = int(input())
S = [list(input()) for _ in range(N)]

# 解は、B = 0として、A = 0, 1, ..., N - 1 のうち、よい盤面になるものの個数のN倍
ans = N * sum(
    all(
        S[i][j] == S[(j - A) % N][(i + A) % N]
        for i in range(N)
        for j in range(N)
    )
    for A in range(N)
)

# 出力
print(ans)


Measured memory_bytes: 45716
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005  //check the limits, man
ll pro(ll a,ll b)
{
    return (a*b)%M;
}
int sgn(ll x)
{
    if(x>0)
        return 1;
    if(x<0)
        return -1;
    return 0;
}
ll compute(vi &v,int n,int last)
{
    ll op=0;
    ll sum=0;
    int i;
    rep(i,n)
    {
        sum+=v[i];
        if(sum==0 || sgn(sum)==last)
        {
            op+=abs(sum);
            op++;
            sum=-last;
        }
        last=sgn(sum);
    }
    return op;
}
int main()
{
    int i,n;
    in(n);
    vi v(n);
    read(v,i,n);
    llout(min(compute(v,n,1),compute(v,n,-1)));
}







Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < (int)s.size()/2; i++){
        if(s[i] != s[(int)s.size()-i-1]) cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int five_thousand(int n){
    return n/=500;
}

int five(int n){
    return n /= 5;
}

int main(){
    int x; cin >> x;
    int ans = 0;
    ans = 1000*five_thousand(x);
    x -= five_thousand(x)*500;
    ans += 5 * five(x);
    cout  << ans;
    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc066.contest.atcoder.jp/tasks/arc066_b>
問題文============================================================
正の整数 N が与えられます。
 2 つの整数 u,v(0≦u,v≦N) であって、ある非負整数 a,b が存在して、a xor b=u、a+b=v
 となるようなものが何通りあるかを求めてください。
 ここで、xor はビットごとの排他的論理和を表します。
 なお、答えは非常に大きくなることがあるので、10^9+7 で割った余りを求めてください。
 1≦N≦10^18
=================================================================

解説=============================================================
================================================================
*/
const ll MOD = 1e9+7;
ll N;
ll memo[64][5][5];
void init(){
    for(int i = 0; i < 64;i++)for(int j = 0; j < 5;j++)for(int k = 0; k < 5;k++) memo[i][j][k] = -1;
}
ll dfs(int d,int a,int b){
    if(d < 0) return 1;
    ll& ret = memo[d][a][b];
    if(ret != -1) return ret;
    ret = 0;
    
    if(N&(1LL<<d)){ // d 桁目が 1
        ret += dfs(d-1,1,min(2,b*2+1));
        ret += dfs(d-1,a,min(2,b*2));
    }else{
        ret += dfs(d-1,a,min(2,b*2));
        if(a && b) ret += dfs(d-1,a,min(2,b*2-1));
    }
    if(b){
        if(N&(1LL<<d)){
            ret += dfs(d-1,1,min(2,b*2-1));
        }else{
            ret += dfs(d-1,a,min(2,b*2-2));
        }
    }
    ret %= MOD;
    return ret;
}
ll solve(){
    init();
    cin >> N;
    return dfs(60,0,0);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(solve(A, B, C, D));

        sc.close();
    }

    static int solve(int A, int B, int C, int D) {
        return Math.max(0, Math.min(B, D) - Math.max(A, C));
    }
}

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

int main() {
  string s;
  cin >> s;
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
typedef long long ll;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        cout<<a<<endl;
        return 0;
    }else{
        cout<<a-1<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define end '\n'
struct Frac {
  int numer, denom;
  Frac(int numer_, int denom_) : numer(numer_), denom(denom_) {}
  bool operator <(const Frac &other) const {
    return numer * other.denom < other.numer * denom;
  }
  bool operator ==(const Frac &other) const {
    return numer * other.denom == other.numer * denom;
  }
};
int dp[51][51];

int comb(int n, int k) {
    if(k < 0 || k > n) return 0;
    if(n == 0) return 1;
    if(dp[n][k] > 0) return dp[n][k];
    return dp[n][k] = comb(n-1, k-1) + comb(n-1, k);
}

signed main() {
  ios::sync_with_stdio(false);
  memset(dp, 0, sizeof(dp));
  int N, A, B; cin >> N >> A >> B;
  vector<int> V(N);
  REP(i,N) cin >> V[i];
  sort(V.rbegin(), V.rend());
  Frac ans(0, 1);
  int cnt = 0;
  for(int C = A; C <= B; C++) {
    int sum = 0;
    REP(i,C) sum += V[i];
    Frac tmp(sum, C);
    if(ans < tmp) {
      ans = tmp;
      cnt = 0;
    }
    if (ans == tmp) {
      int k = 0;
      REP(i,C) if(V[i] == V[C - 1]) k++;
      int n = 0;
      REP(i,N) if(V[i] == V[C - 1]) n++;
      cnt += comb(n, k);
    }
  }
  cout.setf(ios::fixed); cout.precision(10);
  cout << 1.0 * ans.numer / ans.denom << endl;
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int s,m,l;

  if( (a>=b) && (b>=c) ){ l=a, m=b, s=c; }
  if( (a>=c) && (c>=b) ){ l=a, m=c, s=b; }
  if( (b>=a) && (a>=c) ){ l=b, m=a, s=c; }
  if( (b>=c) && (c>=a) ){ l=b, m=c, s=a; }
  if( (c>=a) && (a>=b) ){ l=c, m=a, s=b; }
  if( (c>=b) && (b>=a) ){ l=c, m=b, s=a; }

  int sum;
  int lm = l-m;
  int ms = m-s;
  if( ms%2 == 1 ) sum = lm+(ms/2)+2; 
  else sum = lm+(ms/2);

  printf("%d\n", sum);
  return 0;
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ls = new int[m];
        int[] rs = new int[m];
        for(int tmp = 0; tmp<m; tmp++){
            ls[tmp] = sc.nextInt();
            rs[tmp] = sc.nextInt();
        }
        int l = 0;
        int r = INF;
        for(int tmp = 0; tmp< m; tmp++){
            int x = ls[tmp];
            l = Math.max(x,l);
            int y = rs[tmp];
            r = Math.min(y,r);
        }

        System.out.println(l <= r ? r - l + 1 : 0);
    }
}


Measured memory_bytes: 64712
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int x; cin >> x;
	for (int i = 1; i <= 300; i++) {
		int cur = (int)pow(i, 5);
		int dif = abs(x - cur);
		for (int j = 0; j < 301; j++) {
			if ((int)pow(j, 5) == dif) {
				if (cur >= x) cout << i << " " << j << endl;
				else cout << i << " " << -j << endl;
				return;
			}
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 4144
import java.util.Scanner;

class Solver {

    private final String S;

    Solver(Scanner in){
        S = in.next();
    }

    void solve() {
        System.out.println(S.matches("(dream(er)?|eraser?)+") ? "YES" : "NO");
    }
}

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	cin>>n;
	vint a(n),b(n);
	int min,cou = 0;
	cin>>min;cou++;
	rep(i, n-1){
		int d;cin>>d;
		chmin(min, d);
		if(min >= d){
			cou++;
		}
	}
	cout << cou << endl;
	return 0;
	
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

int f(int n) {
  int ret = 1;
  rep(i, n) {
    ret *= (i+1);
  }
  return ret;
}

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

  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) {
    a[i] = i;
  }

  int x[11], y[11];
  rep (i, n) {
    cin >> x[i] >> y[i];
  }
  double ans = 0;
  do {
    rep(i, n) {
      if ( i == 0 ) { continue; }
      int dx = x[a[i]] - x[a[i-1]];
      int dy = y[a[i]] - y[a[i-1]];
      double dist = sqrt(dx*dx + dy*dy);
      ans += dist;
    }
  } while (next_permutation(a.begin(), a.end()));
  
  cout << ans / f(n) << 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;
typedef long long ll;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	a += b + c + d;
	cout << a / 60 << endl << a % 60 << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int N, M;
	cin >> N >> M;
	int sum = 0;
	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		sum += a;
	}
	if (sum > N) cout << -1 << endl;
	else cout << N - sum << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;
int cum[4010][3];
int ans;

signed main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')cum[i + 1][0]++;
		if (s[i] == 'G')cum[i + 1][1]++;
		if (s[i] == 'B')cum[i + 1][2]++;
		for (int j = 0; j < 3; j++)cum[i + 1][j] += cum[i][j];
	}
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])continue;
			if (s[i] != 'R'&&s[j] != 'R') {
				ans += cum[n][0] - cum[j + 1][0];
				if (j + j - i < n&&s[j + j - i] == 'R')ans--;
			}
			else if (s[i] != 'G'&&s[j] != 'G') {
				ans += cum[n][1] - cum[j + 1][1];
				if (j + j - i < n&&s[j + j - i] == 'G')ans--;
			}
			else {
				ans += cum[n][2] - cum[j + 1][2];
				if (j + j - i < n&&s[j + j - i] == 'B')ans--;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>

int main() {

	char s[100001];
	int len;
	int h;
	int i;

	scanf("%s", s);

	len = strlen(s);
	if(len % 2 != 0) {
		printf("No\n");
		return 0;
	}

	h = len / 2;
	len--;

	for(i = 0; i < h;  i++) {

		if(s[i] == 'b') {
			if(s[len - i] != 'd') {
				break;
			}
		} else if(s[i] == 'd') {
			if(s[len - i] != 'b') {
				break;
			}
		} else if(s[i] == 'p') {
			if(s[len - i] != 'q') {
				break;
			}
		} else if(s[i] == 'q') {
			if(s[len - i] != 'p') {
				break;
			}
		} else {
			break;
		}
	}

	if(i == h) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <ctime>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5;
int n, f[N], t[N], p[N];
bool cycle(int a, int b, int c) { return (a<b&&b<c)||(b<c&&c<a)||(c<a&&a<b); }
int main()
{
    n = read(); 
    for(int i = 1; i <= n; ++i) p[read()] = i;
    for(int i = n-1; i; --i)
        if(t[i+1])
        {
            if(cycle(p[f[i+1]], p[i], p[i+1])) t[i] = t[i+1], f[i] = f[i+1];
            else t[i] = t[i+1]+1, f[i] = i+1;
        }
        else if(p[i] > p[i+1]) t[i] = 1, f[i] = i+1;
    printf("%d\n", t[1]);
    return 0;
}

Measured memory_bytes: 2560
a, b, c = map(int, input().split())
ans = 0
if (a+b) < c:  # 解毒クッキーが足りないとき
    ans += b
    ans += (a + b) + 1  # このとき毒クッキーは最大で(a+b)+1だけ食べることができる
elif (a+b) >= c:  # 解毒クッキーが毒クッキーと個数がそれ以下のとき
    ans += c
    ans += b
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int N, W;
int main() {
	cin >> N >> W;
	vector<int> v(N), w(N);
	int sum = 0;
	for(int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
		sum += v[i];
	}
	vector<vector<int> > dp(N + 1, vector<int>(sum + 1, 1999999999));
	dp[0][0] = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= sum; j++) {
			dp[i + 1][j] = dp[i][j];
			if(j >= v[i]) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
		}
	}
	for(int i = sum; i >= 0; i--) {
		if(dp[N][i] <= W) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

long long gcm(long long A, long long B)
{
    if (B == 0)
    {
        return A;
    }
    else
    {
        return gcm(B, A % B);
    }
}

void solve(long long A, long long B)
{
    cout << (A * B) / gcm(A, B) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	n := readInt64()
	a := make([]int64, 5)
	for i := range a {
		a[i] = readInt64()
	}
	sort.Sort(sortTarget0Slice(a))
	println((n+(a[0]-1))/a[0] + 4)

}

// -----------------------------------------------------------------------------

type sortTarget0Slice []int64

func (s sortTarget0Slice) Len() int {
	return len(s)
}

func (s sortTarget0Slice) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortTarget0Slice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
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; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	int n;
	string s;
	cin >> n >> s;
	ll r = 0,g = 0,b = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R') r++;
		if(s[i] == 'G') g++;
		if(s[i] == 'B') b++;
	}
	ll cnt = 0;
	for(int i = 1; i < n; i++){
		for(int j = i+1; j <= n; j++){
			int k = 2*j-i;
			if(j<k&&k<=n&&s[i-1]!=s[j-1]&&s[j-1]!=s[k-1]&&s[k-1]!=s[i-1]) cnt++;
		}
	}
	cout << r*g*b-cnt << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#define ll long long


using namespace std;

const ll MAXN=1e5+10;

struct V{
	ll x,order;
}vx[MAXN],vy[MAXN];

struct Edge{
	int va,vb;
	ll w;
}e[2*MAXN];

int pre[MAXN];

void init(int n){
	for(int i=1;i<=n;i++){
		pre[i]=i;
	}
}

bool cmpv(V a,V b){
	return a.x<b.x;
}
bool cmpe(Edge a,Edge b){
	return a.w<b.w;
}

int find(int v){
	if(pre[v]==v){
		return v;
	}
	else {
		pre[v]=find(pre[v]);
		return pre[v];
	}
}

ll Kruskal(int ver,int edges){
	ll tot=0,ale=0;//权重和已加入的顶点数 
	init(ver);
	for(int i=1;i<=edges&&ale<ver-1;i++){
		 int h=find(e[i].va);
		 int k=find(e[i].vb);
		 if(h!=k){
		 	tot+=e[i].w;//增加权重 
		 	ale++;//增加边 
		 	pre[h]=k;//加入集合 
		 } 
	}
	return tot; 
	
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&vx[i].x,&vy[i].x);
		vx[i].order=vy[i].order=i;
	}
	sort(vx+1,vx+n+1,cmpv);
	sort(vy+1,vy+n+1,cmpv);
	for(int i=1;i<n;i++){
		e[i].w=vx[i+1].x-vx[i].x;
		e[i].va=vx[i+1].order,e[i].vb=vx[i].order;
		
		e[i+n-1].w=vy[i+1].x-vy[i].x;
		e[i+n-1].va=vy[i+1].order,e[i+n-1].vb=vy[i].order;
	}
	//对边长按权重排序 
	sort(e+1,e+2*n-1,cmpe);
	//Kruskal算法 找最小生成树 
	ll ans=Kruskal(n,2*n-2);
	printf("%lld",ans);
	return 0;
}
 

Measured memory_bytes: 6784
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll odd = (n + 1) / 2;
  ll even = n / 2;
  cout << odd * even << endl;
  return 0;
}


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

int main(void)
{
    long long int a,c=1;
    cin >> a;
    string b;
    cin >> b;
    for (int i=0;i<b.size()-1;i++){
        
        if (b.at(i)!=b.at(i+1)){
            c++;
        }
        
    
        
    }
    cout << c << endl; 
}

Measured memory_bytes: 3716
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int s = sc.nextInt();

        int i = 1;
        int a = s;
        HashSet<Integer> nums = new HashSet<>();
        nums.add(a);
        while (true) {
            i++;
            if (a % 2 == 0) {
                a /= 2;
            } else {
                a = 3 * a + 1;
            }
            if (nums.contains(a)) {
                System.out.println(i);
                return;
            }
            nums.add(a);
        }
    }
}

Measured memory_bytes: 21844
N=int(input())
A=[int(input()) for i in range(N)]
mod=998244353
DP=[[0]*90001 for i in range(N+1)]
DP[0][0]=pow(2,N,mod)
inv2=((mod+1)>>1)
for i in range(N):
  for j in range(300*i+1):
    DP[i+1][j]=(DP[i][j]+DP[i+1][j])%mod
    DP[i+1][j+A[i]]=DP[i][j]*inv2%mod
P=(pow(3,N,mod)-sum(DP[N][((sum(A)+1)>>1):])*3)%mod
DP=[[0]*90001 for i in range(N+1)]
DP[0][0]=1
for i in range(N):
  for j in range(300*i+1):
    DP[i+1][j]=(DP[i][j]+DP[i+1][j])%mod
    DP[i+1][j+A[i]]=DP[i][j]%mod
if sum(A)&1==0:
  P+=DP[N][sum(A)>>1]*3
print(P%mod)

Measured memory_bytes: 490860
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int a, b;
  readf("%d %d\n", &a, &b);
  auto p = readln.chomp.split.to!(int[]);
  int[] g1, g2, g3;
  foreach (e; p) {
    if (e <= a) {
      g1 ~= e;
    } else if (e <= b) {
      g2 ~= e;
    } else {
      g3 ~= e;
    }
  }
  writeln(min(g1.length, min(g2.length,g3.length)));
}


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

const long long INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	long long h[n+1];
	rep(i, n) cin >> h[i];

	long long dp[100010];
	rep(i, 100010) dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
		if (i > 1) {
			dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));	
		}
		
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	//正方形だから解ける。１→２のｘ軸」y軸の差分を逆転させて、１起点に４を、２起点に３を求める。
	//１→２のｘの差分、ｙの差分求める
	xl := x2-x1
	yl := y2-y1
	x3 := x2 - yl
	y3 := y2 + xl
	x4 := x1 - yl
	y4 := y1 + xl
	fmt.Println(x3, y3, x4, y4)
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    int len=s.length();
    for(int i=len-1;i>=2;i--){
        if(i%2) continue;
        string pre=s.substr(0,i/2),post=s.substr(i/2,i/2);
        if(pre==post){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256