akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n;
    n = sc.nextInt();
    int v[] = new int[n];
    int c[] = new int[n];
    int m=0;
    for(int i=0;i<n;i++){
    	v[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
    	c[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
    	if(v[i] - c[i] > 0){
    		m += v[i] -c[i];
    	}
    }
    System.out.println(m);
  }
}

Measured memory_bytes: 22608
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n,k := scanInt(), scanInt()
	a := scanInts(n)
	counts := make([]int, n)

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i]>a[j] {
				counts[i]++
			}
		}
	}

	ans := 0

	for i := 0; i < n; i++ {
		cnt := 0
		for j := i+1; j < n; j++ {
			if a[i]>a[j] {
				cnt++
			}
		}

		ans = (ans + k*cnt%mod)%mod
		ans = (ans + ((k-1)*k/2%mod)*counts[i]%mod)%mod
	}

	fmt.Println(ans)
	
}

const mod = 1000000007


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	  cin>>a[i];
	  sort(a,a+n);
	  int sum=0;
	  for(int i=0;i<k;i++)
	     sum+=a[i];
	     cout<<sum<<endl;
	     return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int> A(n);
  rep(i, n) cin>>A[i];
  int m; cin>>m;
  vector<int> B(m);
  rep(i, m) cin>>B[i];

  map<int, int> mp;
  rep(bit, (1<<n)) {
    int tmp=0;
    rep(i, n) {
      if (bit&(1<<i)) tmp+=A[i];
    }
    mp[tmp]++;
  }
  rep(i, m) {
    if (mp.count(B[i])) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
}



Measured memory_bytes: 3116
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.00000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200010];


    void solve() throws IOException {

        int n = in.nextInt();
        int[] cnt = new int[100010];

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            cnt[x]++;
            cnt[x+1]++;
            if (x > 0)
                cnt[x-1]++;
        }

        int max = 0;
        for (int i = 0; i < 100010; i++)
            max = Math.max(max, cnt[i]);

        out.println(max);
    }


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

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}

Measured memory_bytes: 35824
#include <iostream>
using namespace std;
int main(void){
   int N,T,h;
   cin>>N;
   T=1;
   int H[N];
   for(int i=0;i<N;i++){
       cin>>H[i];
    }
    h=H[0];
    
    for(int i=0;i<N-1;i++){
        
        if(h<=H[i+1]){
           T=T+1;
           h=H[i+1];
           
       }
      
    }
   
   cout<<T<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if((s[2]==s[3])&&(s[4]==s[5]))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  } else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Left" << endl;
  }
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

template<typename T>
vector<vector<vector<T>>>
Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(
      d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

FiniteField Solve() {
  string s;
  int64 op_max;
  cin >> s >> op_max;

  // for (int i = 0; i < 100; i++) s.push_back('0');
  // for (int i = 0; i < 200; i++) s.push_back('1');
  // op_max = 1E9;
  
  if (op_max == 0) return 1;

  auto encode_fn = [](const string& s) -> vector<int> {
    vector<int> xs;
    int count = 0;
    for (char c : s) {
      if (c == '1') {
        count++;
      } else if (c == '0') {
        xs.push_back(count);
        count = 0;
      }
    }
    xs.push_back(count);
    reverse(xs.begin(), xs.end());
    return xs;
  };
  vector<int> xs = encode_fn(s);
  int n = xs.size();
  if (n == 1) return 1;

  int m = 0;
  for (char c : s) {
    if (c == '1') {
      m++;
    }
  }

  if (m == 0) return 1;

  if (DEBUG) cout << "xs: " << xs << endl;

  auto dp = Make3DVector<FiniteField>(n + 1, m + 1, m + 1, 0);

  dp[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= j; k++) {
        dp[i][j][k] += dp[i - 1][j][k];
        for (int l = 1; k + l <= j; l++) {
          dp[i][j][k] += dp[i - 1][j][k + l];
        }
        for (int l = 1; j - l >= 0 && k - l >= 0 && l <= xs[i - 1]; l++) {
          dp[i][j][k] += dp[i - 1][j - l][k - l];
        }
      }
    }
  }

  FiniteField ans = 0;
  for (int i = 0; i <= m && i <= op_max; i++) {
    ans += dp[n][i][0];
  }
  return ans;
}

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

  cout << Solve().Value() << endl;
}

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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define inputLong(a) scanf("%lld", &a)
#define clr(a) memset(a, 0, sizeof(a))
#define printn(a) cout<<a<<"\n"
#define print(a) cout<<a

long long alter[3][100010];

int main()
{
    long long N;
    long long num;
    int a[100010];
    int b[100010];
    cin>>N;

    for(int i = 0; i<3 ; i++)
    {
        for(int j =0; j<N; j++)
        {
            inputLong(num);
            alter[i][j] = num;
        }

    }

    sort(alter[0], alter[0] + N);
    sort(alter[2], alter[2] + N);

    long long result =0;
    long long upper, lower,value;
    long long first,last,mid;
    for(int i=0; i<N; i++)
    {
        value = alter[1][i];
        first = 0;
        last = N-1;

        while(first<=last)
        {
            mid = (first + last)/2;

            if(alter[0][mid] >= value)
                last = mid - 1;
            else if(alter[0][mid] < value)
            {
                first = mid + 1;
            }

        }

        upper = last+1;

        value = alter[1][i];
        first = 0;
        last = N-1;

        while(first<=last)
        {
            mid = (first + last)/2;

            if(alter[2][mid] <= value)
                first = mid + 1;
            else if(alter[2][mid] > value)
            {
                last = mid - 1;
            }

        }

        lower = N- first;

        //rintf("upper value: %d lower value: %d\n",upper,lower);

        result += (upper*lower);

    }

    printn(result);

    return 0;

}


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

int main(){
    long long N, L;
    cin >> N >> L;
    vector<long long> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    int M = -1;
    for(int i = 1; i < N; i++){
        if(A[i] + A[i - 1] >= L){
            M = i;
            break;
        }
    }
    
    if(M == -1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
        for(int i = 1; i < M; i++){
            cout << i << endl;
        }
        for(int i = N - 1; i > M; i--){
            cout << i << endl;
        }
        cout << M << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
n = 50021
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    try:
        n = int(input())
        i, a, b = 0, 0, 0
        while a == 0 or b == 0:
            i += 1
            if n - i - 1 >= 0 and a == 0 and c[n - i - 1] == 1:
                a = n - i
            if n + i - 1 < 50021 and b == 0 and c[n + i - 1] == 1:
                b = n + i
        print(a,b)
    except:
        break



Measured memory_bytes: 5908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	DSU dsu(n);
	for(int i=0;i<m;i++)
	{
		int u,v; cin>>u>>v; u--; v--; dsu.merge(u,v);
	}
	ll ans=0;
	for(ll i=0;i<=n;i++)
	{
		if(dsu.getstat(0)<=i&&dsu.getstat(1)<=n-i)
		{
			ans=max(ans,(i*(i-1)+(n-i)*(n-i-1))/2);
		}
	}
	cout<<ans-m<<'\n';
}	


Measured memory_bytes: 3056
A['   '];B,X,Y;W,J,I;main(M){scanf("%*d%d",&M);for(;~scanf("%d%d",&X,&Y);){for(B=Y+1,J=1;J*J<=M;J++)I=(X+J-1)/J,W=Y/J+1,A[I]++,A[W<B?W:B]--,B=I;for(I=1;I<B;I++)(X-1)/I<Y/I?A[I]++,A[I+1]--:0;}for(I=1;I<=M;I++)A[I]+=A[I-1],printf("%d\n",A[I]);}

Measured memory_bytes: 1280
import math
A,B=map(int,input().split())
for i in range(10**5):
    a=math.floor(i*0.08)
    b=math.floor(i*0.10)
    if a==A and b==B:
        print(i)
        exit()
    if a>A or b>B:
        print(-1)
        exit()

Measured memory_bytes: 3316
x,y=$<.map{|s|s.split.map &:to_i}.transpose;_,*x=x;a=x.max;h,*b=y;c=0;p b.select{|x|x>a}.sort.reverse.any?{|d|c+=1;1>h-=d}?c:~-h/a-~c

Measured memory_bytes: 14960
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 long long int sum=0;
 while(n)
 {
 	if(n%3!=0 && n%5!=0)
 	sum+=n;
 	n--;
 }
 cout<<sum<<endl;
 return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program {
    public class Solver {

        const long MOD = (long)1e9 + 7;
        static long ModPow(long x, long k) {
            long ret = 1;
            for (; k > 0; k /= 2, x = x * x % MOD)
                if (k % 2 == 1) ret = ret * x % MOD;
            return ret;
        }
        static long Inverse(long x) { return ModPow(x, MOD - 2); }
        static void Add(ref long x, long y) { x = (x + y) % MOD; }


        static void Main() {
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var fact = new long[n + 1];
            var ifact = new long[n + 1];
            fact[0] = ifact[0] = 1;
            for (int i = 1; i <= n; i++) {
                fact[i] = fact[i - 1] * i % MOD;
                ifact[i] = Inverse(fact[i]);
            }
            //cycle
            if (d.All(x => x == 2)) {
                Console.WriteLine(fact[n - 1] * Inverse(2) % MOD);
                return;
            }

            var dp = new long[n + 5, 2];
            dp[0, 0] = 1;
            foreach (var x in d) {
                var next = new long[n + 5, 2];
                for (int i = 0; i <= n; i++)
                    for (int k = 0; k < 2; k++) {
                        Add(ref next[i, k], dp[i, k] * ifact[x - 1]);
                        if (x >= 2) Add(ref next[i + 1, k], dp[i, k] * ifact[x - 2]);
                        if (k == 0 && x >= 3) Add(ref next[i + 1, k + 1], dp[i, k] * ifact[x - 3]);
                    }
                dp = next;
            }


            long ans = 0;
            for (int i = 3; i < n; i++) {
                var coef = fact[n - i - 1] * fact[i - 1] % MOD;
                Add(ref ans, dp[i, 1] * coef);
            }
            Console.WriteLine(ans * Inverse(2) % MOD);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  int cnt=0;
  int magic=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    if(i!=0){
      if(a[i] == a[i-1]){
        cnt++;
      }else{
        cnt = 0;
      }
    }
    if(cnt%2 == 1){
      magic++;
    }
  }
  cout << magic << endl;
}

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

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	using vs = std::vector<std::string>;
	std::vector<vs> S(H, vs(W));
	for (auto& e: S)
		for (auto& f: e)
			std::cin >> f;
	for (int i{}; i < H; i++)
		for (int j{}; j < W; j++)
		{
			if (S[i][j] == "snuke")
			{
				printf("%c%d\n", 'A' + j, 1 + i);
				return 0;
			}
		}

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, M;
LL x[1000], y[1000], z[1000];
int main(){
	cin >> N >> M;
	for(int i=0; i<N; i++) cin >> x[i] >> y[i] >> z[i];
	LL ans = 0;
	for(int i=-1; i<=1; i+=2){
		for(int j=-1; j<=1; j+=2){
			for(int k=-1; k<=1; k+=2){
				LL tmp[1000];
				for(int l=0; l<N; l++){
					tmp[l] = i*x[l] + j*y[l] + k*z[l];
				}
				sort(tmp, tmp+N, greater<LL>());
				LL sum = 0;
				for(int l=0; l<M; l++){
					sum += tmp[l];
				}
				ans = max(ans, sum);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int N, Q;
    cin >> N;
    multiset<int>S;
    for (int i=0; i < N; i++) {
        int s;
        cin >> s;
        S.insert(s);
    }

    cin >> Q;
    multiset<int>T;
    for (int i=0; i < Q; i++) {
        int s;
        cin >> s;
        T.insert(s);
    }

    multiset<int> result;
    set_intersection(S.begin(), S.end(),
                        T.begin(), T.end(),
                        std::inserter(result, result.end()));
    cout << result.size() << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  string c;
  if(a==b)  c="==";
  if(a>b)  c=">";
  if(a<b)  c="<";
  
  cout << 'a' << " "<< c << " "<< 'b' << endl;
  
}


Measured memory_bytes: 3140
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define ld long double
#define ri register int
#define rep(i,a,b) for(ri i=a;i<=b;++i)
#define rep2(i,a,b,c) for(ri i=a;i<=b;i+=c)
#define REP(i,a,b) for(ri i=a;i>=b;--i)
#define REP2(i,a,b,c) for(ri i=a;i>=b;i-=c)
using namespace std;

const int N=1e5+5;
int a[N],f1[N],f2[N];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ri n;cin>>n;
	rep(i,1,n) cin>>a[i];
	f1[1]=f2[1]=1;
	rep(i,2,n){
		if(a[i]>a[i-1]) f1[i]=min(f1[i-1],f2[i-1]+1),f2[i]=min(f1[i-1]+1,f2[i-1]+1);
		else if(a[i]<a[i-1]) f1[i]=min(f1[i-1]+1,f2[i-1]+1),f2[i]=min(f1[i-1]+1,f2[i-1]);
		else f1[i]=f1[i-1],f2[i]=f2[i-1];
	}
	cout<<min(f1[n],f2[n]);
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 count(int a){
	int c=0;
	for(int i=1; i<=a; ++i){
		if(a%i==0) c++;
	}
	return c;
}

int main(){
	int n;
	cin >> n;
	
	int c=0;
	for(int i=1; i<=n; i+=2){
		if(count(i)==8) c++;
	}
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 3580
def main():
    A,B,C = map(int,input().split())
    if A==B and A!=C:
        print("Yes")
    elif A==C and A!=B:
        print("Yes")
    elif B==C and B!=A:
        print("Yes")
    else:
        print("No")


if __name__=='__main__':
    main()


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

using namespace std;

char A[105][105];

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; ++i) {
    	string str;
    	cin >> str;
    	for (int j = 0; j < w; ++j) {
    		A[i][j] = str[j];
    	}
    }
    for (int i = 0; i < 2 * h; ++i) {
    	for (int j = 0; j < w; ++j) {
    		cout << A[((i + 2) / 2) - 1][j];
    	}
    	cout << "\n";
    }
}

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



int main(){
    
    long h, n,at,bt,o;
    cin >> h >> n;
    
    vector<long> a;
    vector<long> b;
    int n_t = n + 1;
    int h_t = h + 1;
    vector<vector<long>> dp(n_t, vector<long>(h_t));
    
    for(int i=0;i<n;i++){
        cin >> at >> bt;
        a.push_back(at);
        b.push_back(bt);
    }
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=h;j++){
            dp[i][j] = 0;
        }
    }
    
    
    
    for(int i=0;i<n;i++){
        for(int j=0;j<h;j++){
            
            if(j - a[i] < 0){
                o = b[i];
            }else{
                o = dp[i+1][j+1-a[i]] + b[i];
            }
            if(i != 0){
                dp[i+1][j+1] = min(dp[i][j+1], o);
            }else{
                dp[i+1][j+1] = o;
            }
            
        }
    }
    
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=h;j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    cout << dp[n][h] << endl;
    
}


Measured memory_bytes: 78592
n=gets.to_i
ans=0

n.times{|a|
    
    n.times{|b|
        if (a+1).gcd(b+1)==1
            ans+=n
        else
        
        n.times{|c|
            
            aa=(a+1).gcd(b+1)
            abc=(aa).gcd(c+1)
            ans+=abc
        }
        end
        
    }
    
}

puts ans

Measured memory_bytes: 14376
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
 
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; }
 
const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
 
int N;
vector<vector<ll>> dp;
vector<ll> a;
vector<ll> sum;
 
 //添え字が面倒な時は再帰メモ化がいい
ll dfs(int left, int right) {
	if (left == right) return 0; //くっついてないときのcostは0
	if (dp[left][right] != INF) return dp[left][right]; //すでに計算済みなら返す
	ll cost = sum[right + 1] - sum[left]; //くっつけるcost
	ll res = INF; //[left, right]の解
	for (int k = left; k < right; k++) { //中継地点
       //dfs(left, k)とdfs(k+1,right)で(left,k)とk+1,rightに分けられる、kをずらすことによって分け方のを変えていく(1,2,3)だったら１と2,3とか1,2と３とか
		chmin(res, dfs(left, k) + dfs(k + 1, right) + cost);
	}
	return dp[left][right] = res; //dpに格納してから返すのを忘れずに
}
 
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	scanf("%d", &N);
	a.resize(N); for (int i = 0; i < N; i++) scanf("%lld", &a[i]);
	sum.resize(N + 1); for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i]; //a[i]の累積和
 
	//dp[l][r] := [l, r]のmin
	dp = vector<vector<ll>>(N, vector<ll>(N, INF));
 
	//解は[0, N-1]の最小値
	printf("%lld\n", dfs(0, N - 1));
	return 0;
}

Measured memory_bytes: 1536
//20190619
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int a,b,k;
    cin >> a >> b >> k;

    int i;
    int m;
    if(a > b) m = a;
    else m = b;

    vector<int> ans;
    for(i = 1; i<=m ;i++){
        if(a%i == 0 && b%i ==0){
            ans.push_back(i);
        }
    }

    cout << ans[ans.size()-k] << endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

B = [0] * N
C = []

C.append(0)
now = 0
B[0] = 1
for i in range(N):
    now = A[now] - 1
    if B[now] == 1:
        break
    else:
        C.append(now)
        B[now] = 1

mae = 0
for i in range(len(C)):
    if C[i] == now:
        mae = i
        break

ato = len(C) - 1

if K + 1 <= mae:
    print(C[K] + 1)
else:
    print(C[mae + (K - mae) % (ato - mae + 1)] + 1)


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

int main(){
  int n,i,sum=0;
  cin>>n;
  int v[n],c[n];
  for (i=0;i<n;i++)cin>>v[i];
  for (i=0;i<n;i++)cin>>c[i];
  for (i=0;i<n;i++){
    v[i]-=c[i];
    sum+=max(0,v[i]);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w: Vec<char> = read::<String>().chars().collect();
    let mut cnt = std::collections::HashMap::new();
    for &c in &w {
        *(cnt.entry(c).or_insert(0)) += 1;
    }
    println!("{}", if cnt.values().all(|x| x % 2 == 0) { "Yes" } else { "No" });
}


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

typedef long long ll;

#define   f(i,n) 					for(ll i=0;i<(n);i++)
#define   ff(i,n) 					for(ll i=1;i<=(n);i++)
#define   m0(X) 					memset((X), 0, sizeof((X)))
#define   m1(X) 					memset((X), -1, sizeof((X)))
#define   pb(x) 					push_back(x)
#define   F     					first
#define   S  						second
#define   mp 						make_pair
#define   inf                       1LL<<60LL

#define debug(args...)do{cerr<< #args << " : ";shaon(args);}while(0)
void shaon () { cerr << endl; }
template <typename T, typename ... north>
void shaon(T arg, const north &... rest){cerr << arg << ' ';shaon(rest...);}

const ll N=3e3+3;
string a, b, tp;
vector <string > lcs;
ll dp[N][N];

ll LCS (ll i=0, ll j=0)
{
    if(i==a.length() || j==b.length()) return 0;
    ll &r=dp[i][j];
    if(r!=-1) return r;
    r=0;
    if(a[i]==b[j]) r=1+LCS(i+1,j+1);
    else r=max(LCS(i+1,j),LCS(i,j+1));
    return r;
}

void storeLCS (ll i=0, ll j=0)
{
    if(i==a.length() || j==b.length()){
        lcs.pb(tp);
        cout<<tp;
        exit(0);
        return;
    }
    if(a[i]==b[j]){
        tp.pb(a[i]);
        storeLCS (i+1,j+1);
        tp.pop_back();
    }
    else{
        ll p = dp[i+1][j], q = dp[i][j+1];
        if (p>q) storeLCS (i+1,j);
        else if(p<q) storeLCS (i,j+1);
        else {
            storeLCS (i+1,j);
            storeLCS (i,j+1);
        }
    }
}

int main()
{
    m1(dp);

    cin>>a>>b;

    ll k=LCS(0,0);
    storeLCS();

//    cout<<lcs[0];

    return 0;
}


















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

int main()
{
  int h, w;
  cin >> h >> w;
  char grid[h][w];
  int m_distance[h][w];

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> grid[y][x];
      m_distance[y][x] = 2000;
      if (grid[y][x] == '#') {
        m_distance[y][x] = 0;
        continue;
      }
      if (x > 0 && m_distance[y][x - 1] < m_distance[y][x]) {
        m_distance[y][x] = m_distance[y][x - 1] + 1;
      }
    }
    for (int x = w - 1; x > 0; x--) {
      if (m_distance[y][x - 1] > m_distance[y][x]) {
        m_distance[y][x - 1] = m_distance[y][x] + 1;
      }
    }
  }

  for (int x = 0; x < w; x++) {
    for (int y = 1; y < h; y++) {
      if (m_distance[y - 1][x] < m_distance[y][x]) {
        m_distance[y][x] = m_distance[y - 1][x] + 1;
      }
    }
    for (int y = h - 1; y > 0; y--) {
      if (m_distance[y - 1][x] > m_distance[y][x]) {
        m_distance[y - 1][x] = m_distance[y][x] + 1;
      }
    }
  }

  int ans(0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      ans = max(ans, m_distance[y][x]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  int d,n;
  cin>>d>>n;
  if(n==100) n++;
  for(int i=0;i<d;i++) n*=100;
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;
ll n[5];

map<char, int> m;

int main () {
  m['M'] = 1;
  m['A'] = 2;
  m['R'] = 3;
  m['C'] = 4;
  m['H'] = 5;

  cin >> N;
  rep(i,N) {
    string S;
    cin >> S;
    if(m[S[0]]) n[m[S[0]] - 1]++;
  }

  ll ans = 0;
  for(int i = 0; i < 5; i++) {
    for(int j = i+1; j < 5; j++) {
      for(int k = j+1; k < 5; k++) {
        ans += n[i]*n[j]*n[k];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 17;
int n;
int x[N];
int l[N];
int idx[N];

int cmp(int a, int b)
{
	return x[a] + l[a] < x[b] + l[b];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) cin >> x[i] >> l[i];
	iota(idx, idx + n, 0);
	sort(idx, idx + n, cmp);
	int ans = 0;
	int najdali = -INF;
	FOR(it, 0, n)
	{
		int i = idx[it];
		if (x[i] - l[i] >= najdali)
			ans++, najdali = x[i] + l[i];
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int main(){
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9){
        cout << -1 << endl;
    } else {
        cout << a * b << endl;
    }
    return 0;
}

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

const int mod=1000;
const int maxn=2e5+10;

ll h[maxn];
int n,m,val[maxn];
map<ll,ll> mp;

int main()
{
    scanf("%d",&n);
    ll ans=0;
    for( int i=1;i<=n;i++ ) 
    {
    	scanf("%lld",&h[i]);
    	if( i-h[i]>=0 ) ans+=mp[i-h[i]];
		mp[i+h[i]]++;	
    }
    
    printf("%lld\n",ans);
//    i-j=ai+aj
//    i-ai=j+aj
//    i-ai=j+aj
//    i+ai=j+aj

}



Measured memory_bytes: 18980
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

ll n, k[100005], l[100005], ans, rem;
int main() {
	cin >> n;
	for (int i = 0; i < n + 1; ++i) { cin >> k[i]; }
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
		ll mon = min(k[i], l[i]);
		ans += mon, l[i] -= mon;
		ll  monn = min(k[i + 1], l[i]);
		ans += monn, k[i + 1] -= monn;
	}
	cout << ans << endl;
}


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

int main()
{
	int n;
	cin >> n;
	int x;
	vector<int> v;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		v.push_back(x);
	}
	int count = 0;
	int now, prev, next;
	for (int i = 1; i <= n - 2; i++)
	{
		now = v[i];
		next = v[i + 1];
		prev = v[i - 1];

		if ((now > next && now < prev) || (now > prev && now < next))
			count++;
	}
	cout << count << endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a;
    int ans=0;
    for (int i=0; i<n; i++) {
        cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

vvl G;
vl ans;

void dfs(ll v, ll p = -1) {
    for(auto u : G[v]) { 
        if(u == p) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    ll n, q;
    cin >> n >> q;    

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ans.resize(n);
    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    rep(i, n) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 24320
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var Ni = ReadSplitInt();
            Println(Ni[0] - Ni[1] + 1);
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

N, K = ZZ()
A = ZZ()
for i in range(N):
    A[i] -= 1

def mul(a, b):
    return [a[b[i]] for i in range(len(a))]

def beki(a, b):
    res = list(range(len(a)))
    while b > 0:
        if b & 1:
            res = mul(res, a)
        a = mul(a, a)
        b >>= 1
    return res

A = beki(A, K)
print(A[0] + 1)

Measured memory_bytes: 182404
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int main(void){

  string s;
  cin>>s;
  if((s.length()%2==0)^(s[0]==s[s.length()-1])) cout<<"Second\n";
  else cout<<"First\n";
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int min(int a,int b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}
int max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}


int main(){
  int n,m;
  int i;
  int ans=0;
  int tmpl,tmpr;
  scanf("%d%d",&n,&m);
  int l[m];
  int r[m];
  for(i=0;i<m;i++){
    scanf("%d%d",&l[i],&r[i]);
  }
  tmpl=l[0];
  tmpr=r[0];
  for(i=1;i<m;i++){
  tmpl= max(tmpl,l[i]);
  }
  for(i=1;i<m;i++){
  tmpr= min(tmpr,r[i]);
  }

  if(tmpl<=tmpr){
    for(i=tmpl;i<=tmpr;i++){
      ans++;
    }
    printf("%d",ans);
  }else{
    printf("%d",0);
  }

  return 0;
}


Measured memory_bytes: 896
import collections

if __name__ == "__main__":
    N = int(input())
    L = list(map(int, input().split()))

    set_L = list(set(L))
    set_L.sort()
    count_L = collections.Counter(L)

    count = 0
    for i in range(len(set_L)):
        for j in range(i+1, len(set_L)):
            for k in range(j+1, len(set_L)):
                if set_L[i] + set_L[j] > set_L[k]:
                    count = count + count_L[set_L[i]] * count_L[set_L[j]] * count_L[set_L[k]]

    print(count)


Measured memory_bytes: 9388
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int n = in.nextInt();
        int debt = 100000;
        double rate = 1.05;

        while (n --> 0) {
            debt *= rate;
            int rem = debt % 1000;
            if (rem != 0) {
                debt = debt - rem + 1000;
            }
        }

        System.out.println(debt);
    }
}

Measured memory_bytes: 25940
// C - Numbers on a Circle
#include <iostream>
#include <set>
#include <vector>

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

  int n;
  std::cin >> n;
  std::vector<int> a(n), b(n);
  for (int i = 0; i < n; i++)
    std::cin >> a[i];
  for (int i = 0; i < n; i++)
    std::cin >> b[i];
  std::set<std::pair<int, int>, std::greater<std::pair<int, int>>> s;
  for (int i = 0; i < n; i++)
    s.insert(std::make_pair(b[i], i));

  long long ans = 0;
  while (!s.empty()) {
    int i = s.begin()->second;
    s.erase(s.begin());
    int d = b[i] - a[i], t = b[(i + 1) % n] + b[(i - 1 + n) % n];
    if (d != 0 && d < t) {
      ans = -1;
      break;
    }
    ans += d / t;
    b[i] -= d / t * t;
    if (b[i] != a[i])
      s.insert(std::make_pair(b[i], i));
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 11264
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
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 N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, D, A = in.nextInt
  case class Monster(x: Long, hp: Long)
  val Monsters = Array.fill(N)(Monster(in.nextLong, in.nextLong)).sortBy(_.x)

  case class Attack(x: Long, damage: Long)
  val q = new scala.collection.mutable.Queue[Attack]

  def calcDamage(pos: Long, cur: Long): Long = {
    q.headOption match {
      case None => cur
      case Some(attack) => 
        if (attack.x < pos) {
          q.dequeue
          calcDamage(pos, cur - attack.damage)
        } else cur
    }
  }

  def attack(i: Int, sum: Long, preDamage: Long): Long = {
    if (i == N) sum
    else {
      val m = Monsters(i)
      val newDamage = calcDamage(m.x, preDamage)
      if (m.hp <= newDamage) attack(i + 1, sum, newDamage)
      else {
        val attacks = (m.hp - newDamage + A - 1) / A
        q += Attack(m.x + 2 * D, A * attacks)
        attack(i + 1, sum + attacks, newDamage + A * attacks)
      }
    }
  }

  println(attack(0, 0L, 0L))
}

Measured memory_bytes: 125916
#include<stdio.h>
void swap (int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}
int partition (int array[], int left, int right) {
  int i = left, j = right + 1, pivot = left;
  do {
    do { i++; } while (array[i] > array[pivot]);
    do { j--; } while (array[pivot] > array[j]);
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);
  swap(&array[pivot], &array[j]);
  return j;
}
void quick_sort (int array[], int left, int right) {
  int pivot;
  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);
    quick_sort(array, pivot+1, right);
  }
}
int main(){
  int n,k,ans = 0;
  scanf("%d %d",&n,&k);
  int a,cnt[200000];
  for(int i = 0;i < 200000;i++){
    cnt[i] = 0;
  }
  for(int i = 0;i < n;i++){
    scanf("%d",&a);
    cnt[a - 1]++;
  }
  quick_sort(cnt,0,199999);
  for(int i = k;i < 200000;i++){
    ans += cnt[i];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 896
n=int(input())
s=input()
ans=0
for i in range(10):
  idx1=s.find(str(i))
  for j in range(10):
    idx2=s.find(str(j),idx1+1,n)
    for k in range(10):
      idx3=s.find(str(k),idx2+1,n)
      if idx1==-1 or idx2==-1 or idx3==-1:
        continue
      else:
        ans+=1
print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	ll x,y; cin >>x>>y;
	int ans=0;
	ll cnt=x;
	while(cnt<=y){
		ans++;
		cnt*=2;
	}
	cout << ans<< endl;
}

Measured memory_bytes: 256
# 変更後2 後ろから数える　デバッグ用

H,W,N = map(int,input().split())
init_r,init_c = map(int,input().split())
S = input()
T = input()

r = W+1
l = 0
u = 0
d = H+1

# print(r,l,u,d)
ans = "YES"

for i in range(N):
    t = N-1-i
#     print("index:",t)
    #savor's turn
    direction = T[t]
#     print(direction)
    if direction == "R" and l != 0:
        l -= 1
    elif direction == "L" and r != W+1:
        r += 1
    elif direction == "U" and d != H+1:
        d += 1
    elif direction == "D" and u != 0:
        u -= 1
#     print(r,l,u,d)
    
#     killer's turn
    t = N-1-i
    direction = S[t]
#     print(direction)
    if direction == "R":
        r -=1
        if r == 1:
            ans = "NO"
            break
    elif direction == "L":
        l +=1
        if l == W:
            ans = "NO"
            break
    elif direction == "U":
        u +=1
        if u == H:
            ans = "NO"
            break
    elif direction == "D":
        d -=1
        if d == 1:
            ans = "NO"
            break
    if r <= l:
        ans = "NO"
        break    
    if d <= u:
        ans = "NO"
        break
        
#     3 >= 2
# 2 <= 3
#     print(r,l,u,d)
#     print(r,l)
#     print(r,l)

if init_c <= l or init_c >= r:
    ans = "NO"

        
if init_r <= u or init_r >= d:
    ans = "NO"




    
print(ans)

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

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

long lcm(long a, long b){
    return a/gcd(a,b)*b;
}

int main(){
    long n;
    cin >> n;
    long t[n];
    F(n) cin >> t[i];
    for(int i=1;i<n;++i){
        t[i]=lcm(t[i],t[i-1]);
    }
    cout << t[n-1] << endl;
    return 0;
}

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

int main ()
{
    char ara[2];
    scanf("%s",ara);
    if(ara[0]== '9' || ara[1]== '9')
        printf("Yes\n");
    else
        printf("No\n");

    return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N, 0);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  int alice = 0, bob = 0, count = 0;
  for(int i = N - 1; i >= 0; i--) {
    if(count % 2 == 0) alice += data.at(i);
    else bob += data.at(i);
    count++;
  }
  cout << alice - bob << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;


int main(){
    int N;cin >> N;
    vector<pair<LL,LL>> vec;
    for(int a = 0;a < N;a++){
        int b,c;cin >> b >> c;
        vec.push_back({b,c});
    }
    LL ins = 0;
    for(int a = N-1;a >= 0;a--){

        ins += (vec.at(a).second-((vec.at(a).first+ins)%vec.at(a).second))%vec.at(a).second;
    }
    cout<<ins<<endl;
}

Measured memory_bytes: 2420
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

xx = inputs[0][0]
aa = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

if xx < aa
  puts 0
else
  puts 10
end


Measured memory_bytes: 3836