akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<bool, bool> pbb;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define open(i, j, k) for(int i = j; i <  k; i ++)
#define dec(i, j, k)  for(int i = j; i >= k; i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? x = y, true : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? x = y, true : false; }
int _()
{
	int ret = 0; bool f = true; char ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = false; ch = getchar(); }
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while(isdigit(ch));
	return f ? ret : -ret;
}
void _(int x)
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void __init()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
	srand(time(0) ^ ui(ul(new char)));
}
/* default code ends here */
#define maxn 100100
ll a[maxn], b[maxn];
int main()
{
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	__init();
	int n;
	cin >> n;
	enum(i, 1, n)
		cin >> a[i] >> b[i];
	enum(i, 1, n)
		a[i] += b[i];
	sort(a + 1, a + n + 1);
	ll ans = 0;
	enum(i, 1, n)
		ans -= b[i];
	for(int i = n; i > 0; i -= 2)
		ans += a[i];
	cout << ans << '\n';
	return 0;
}

















































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

int main(int argc, char** argv) {
    string str;
    cin >> str;
    int cnt{0}, max{0};
    for (char s : str) {
        if (s != 'A' && s !='T' && s != 'G' && s != 'C')
            cnt = 0;
        else {
            ++cnt;
            if (cnt > max) {
                max = cnt;
            }
        }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		String S=sc.next();
		int v=0;
		
		for(int i=1;i<S.length();i++) {
			
			if(S.charAt(i)!=S.charAt(i-1))v++;
			
			
		}
		p(v);
		
		
	}
	
		
	
	
		
	
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 23916
import sys,queue,math,copy,itertools,bisect,collections
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

X,Y,Z,K = LI()
A = LI()
B = LI()
C = LI()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

h = A[0] + B[0] + C[0] +1
l = 0
while h > l+1:
    m = (h+l) // 2

    num = 0
    for a in A:
        j = len(C) - 1
        for i in B:
            while i + C[j] < m - a:
                j -= 1
                if j < 0: break
            else:
                num += j + 1
                continue
            break
    if num >= K:
        l = m
    else:
        h = m

ans = []
for a in A:
    j = len(C) - 1
    for i in B:

        while i + C[j] <= l - a:
            j -= 1
            if j < 0: break
        else:
            for k in range(j+1):
                ans.append(a+i+C[k])
            continue
        break

ans.sort(reverse=True)
for _ in range(K-len(ans)):
    ans.append(l)
print(*ans, sep='\n')



Measured memory_bytes: 48728
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 15:03-

            int n = sc.nextInt();
            int diff = 0;
            for (int i = 1; i <= n; i++) {
                if (sc.nextInt() != i) diff++;
            }

            System.out.println((diff == 2 || diff == 0) ? "YES" : "NO");
        }
    }

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <tuple>

using namespace std;

void bills(int N, int Y, int &x, int &y, int &z) {
	for (x = 0; x <= N; x++) {
		for (y = 0; y <= N - x; y++) {
			z = N - x - y;
			if (x * 10000 + y * 5000 + z * 1000 == Y) {
				return;
			}
		}
	}
	x = -1;
	y = -1;
	z = -1;
}

int main()
{
	int N;
	int Y;

	cin >> N;
	cin >> Y;

	bool possible = true;



	int x, y, z;
	bills(N, Y, x, y, z);
		
	cout << x << " " << y << " " << z;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
int a[N];
long long s[N], mn[N], wall[N], inf(1ll << 60);
int main() {
	int n;
	scanf("%d", &n);
	for(int i(1); i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + 1 + n);
	
	for(int i(1); i <= n; i++) {
		s[i] = s[i - 1] + a[i];
	}
	wall[n + 1] = n + 1;
	for(int i(n); i >= 1; i--) {
		wall[i] = a[i] - 2 * s[i - 1] > 0 ? i : wall[i + 1];
	}
	int ans(0);
	for(int i(1), j; i <= n; i = j) {
		for(j = i; j <= n && a[i] == a[j]; j++);
		if(wall[j] == n + 1) {
			ans += j - i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Grand_Contest_035
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            var N = (int)Sarray()[0];
            var ai = Slist();
            ai.Sort();
            var bans = false;
            if (ai[0] == 0 && ai[N - 1] == 0)//全部0
            { bans = true; }
            else if (N % 3 == 0)
            {
                if (ai[0] == 0 && ai[N / 3 - 1] == 0 && ai[N / 3] == ai[N - 1])
                { bans = true; }
                if (
                     (ai[0] == ai[N / 3 - 1] && ai[N / 3] == ai[2 * N / 3 - 1] && ai[2 * N / 3] == ai[N - 1])
                     && (0 == (ai[0] ^ ai[N / 3] ^ ai[2 * N / 3]))
                   )
                { bans = true; }
            }
            if (bans)
            { WriteLine("Yes"); }
            else
            { WriteLine("No"); }
            Console.SetOut(sw);
        }
    }
}

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

int main(){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool ans = true;
    for (int i = 0; i < A; i++){
        if ('0' <= S.at(i) && S.at(i) <= '9'){
            continue;
        }
        else{
            ans = false;
        }
    }
    if (S.at(A) != '-'){
        ans = false;
    }
    for (int i = A+1; i < A+B+1; i++){
        if ('0' <= S.at(i) && S.at(i) <= '9'){
            continue;
        }
        else{
            ans = false;
        }
    }
    if (ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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


int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    vector<ll> cur(n,(ll)1e18);
    vector<int> ans(n);
    rep(i,n){
        rep(j,m){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<cur[i]){
                cur[i]=abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans[i]=j+1;
            }
        }
    }
    rep(i,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3632
a,b,c,k = map(int,input().split())
list1 = [a,b,c]
ans=0

if a+b+c < k:
  ans = a-c  
elif a+b < k:
  ans = a-(k-a-b)
elif a < k:
  ans = a
else :
  ans = k

print("{}".format(ans))

Measured memory_bytes: 61872
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;

int n;
string str[30];

int calc(int& i){
  int d=0;
  while(str[i][d]=='.') d++;
  int ans;
  bool e=0;
  if(str[i][d]=='+'){
    ans=0;
  }else if(str[i][d]=='*'){
    ans=1;
    e=1;
  }else{
    ans=(int)(str[i][d]-'0');
    i++;
    return ans;
  }
  i++;
  while(i<n && str[i].length()>d+1){
    if(e==0){
      ans+=calc(i);
    }else{
      ans*=calc(i);
    }
  }
  return ans;
}

int main()
{
	while(1){
      scanf("%d", &n);
      if(n==0) return 0;
      for(int i=0; i<n; i++){
        cin>>str[i];
      }
      int j=0;
      int ans=calc(j);
      printf("%d\n", ans);
    }
	return 0;
}



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

using namespace std;

struct Data
{
    int tx, ty, kx, ky, cost;
    Data() {}
    Data(int _tx, int _ty, int _kx, int _ky, int _cost)
    {
        tx = _tx;
        ty = _ty;
        kx = _kx;
        ky = _ky;
        cost = _cost;
    }
};

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int W, H, fld[50][50];
bool isUsed[50][50][50][50];

bool IsAbleToMove(int x, int y)
{
    return x < 0 || W <= x || y < 0 || H <= y || fld[y][x] == 1;
}

int main()
{
    while (cin >> W >> H, W || H)
    {
        int tx, ty, kx, ky;
        cin >> tx >> ty >> kx >> ky;
        tx--; ty--; kx--; ky--;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                cin >> fld[i][j];
            }
        }

        queue<Data> q;
        q.push(Data(tx, ty, kx, ky, 0));
        Data qf;
        fill_n((bool*)isUsed, 50 * 50 * 50 * 50, false);
        while (!q.empty() && q.front().cost < 100)
        {
            qf = q.front();
            q.pop();
            if (qf.tx == qf.kx && qf.ty == qf.ky)
            {
                printf("%d\n", qf.cost);
                goto END_OF_DATASET;
            }
            if (isUsed[qf.tx][qf.ty][qf.kx][qf.ky]) continue;
            isUsed[qf.tx][qf.ty][qf.kx][qf.ky] = true;
            for (int i = 0; i < 4; i++)
            {
                int ntx = qf.tx + dx[i], nty = qf.ty + dy[i];
                int nkx = qf.kx + dx[(i + 2) % 4], nky = qf.ky + dy[(i + 2) % 4];
                if (IsAbleToMove(ntx, nty))
                {
                    ntx = qf.tx;
                    nty = qf.ty;
                }
                if (IsAbleToMove(nkx, nky))
                {
                    nkx = qf.kx;
                    nky = qf.ky;
                }
                q.push(Data(ntx, nty, nkx, nky, qf.cost + 1));
            }
        }
        puts("NA");
        END_OF_DATASET:;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int count = 0;
  unordered_map<string,int> mp(N);
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  for(auto p:mp){
    count = max(count,p.second);
  }
  vector<string> vec(0);
  for(auto p:mp){
    if(p.second==count){
      vec.push_back(p.first);
    }
  }
  sort(vec.begin(),vec.end());
  for(auto x:vec)cout << x << endl;
}  

Measured memory_bytes: 25332
n, x = gets.split.map(&:to_i)
m = n.times.map { gets.to_i }.sort!
result = n
sum = 0
m.each {|n| sum += n}
nokori = x - sum

if (nokori) > 0 
  result += nokori / m[0] #必要な材料の最小値で割る
end

puts result



Measured memory_bytes: 1788
import math

a, b, h, m = map(int, input().split())

th1 = 2 * math.pi * (h / 12 + m / 720)
th2 = 2 * math.pi * m / 60
th = abs(th1 - th2)
ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(th))
print(ans)


Measured memory_bytes: 62452
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    constexpr int N = 1e7;
    vector<int> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        for(int j = 1; i * j <= N; j++) erato[i*j] = i;
    }
    int n; cin >> n;
    ll ans = 0;
    for(ll i = 1; i <=n; i++) {
        map<int,int> mp;
        ll x = i;
        while(x != 1) {
            mp[erato[x]]++;
            x /= erato[x];
        }
        ll mul = 1;
        for (auto p:mp) mul *= p.second+1;
        ans += i * mul;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 42160
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 510
#define M 250010
int a[N][N];
typedef struct
{
    int x1,x2,y1,y2;
}Node;
Node e[M];
int main()
{
    int i,j,k,n,m,s;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
        scanf("%d",&a[i][j]);
    s=0;
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
    if(a[i][j]%2)
    {
        if(j+1<=m)
        {
            e[s].x1=i;
            e[s].y1=j;
            e[s].x2=i;
            e[s].y2=j+1;
            s++;
            a[i][j+1]++;
        }
        else
        if(i+1<=n)
        {
            e[s].x1=i;
            e[s].y1=j;
            e[s].x2=i+1;
            e[s].y2=j;
            s++;
            a[i+1][j]++;
        }
    }
    printf("%d\n",s);
    for(i=0;i<s;i++)
        printf("%d %d %d %d\n",e[i].x1,e[i].y1,e[i].x2,e[i].y2);
    return 0;
}


Measured memory_bytes: 6784
N,M=map(int,input().split())
arr=[int(x) for x in input().split()]
s=[list(map(int,input().split())) for y in range(M)]
s.sort(key=lambda z: z[1], reverse=True)

sum_a=0
for a,b in s:
    arr+=[b]*a
    sum_a+=a
    if sum_a>=N:
        break

lst=sorted(arr)
ans=sum(lst[-N:])
print(ans)

Measured memory_bytes: 36636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int mod = 13;
const int modAns = 1'000'000'007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  string S;
  cin >> S;
  int N = S.length();

  vector<ll> dp(13, 0);
  dp[0] = 1;

  for (int i = N-1; i >= 0; i--) {
    vector<ll> prev(dp);
    rep(i, dp.size()) dp[i] = 0;

    if (S[i] == '?') {
      rep(k, 10) {
        int si = k;
        rep(j, 13) {
          int id = (si * (mint(10).pow(N-1-i)).x + j) % 13;
          dp[id] += prev[j];
          dp[id] %= modAns;
        }
      }
    }
    else {
      int si = S[i] - '0';
      rep(j, 13) {
        int id = (si * (mint(10).pow(N-1-i)).x + j) % 13;
        dp[id] += prev[j];
        dp[id] %= modAns;
      }
    }
  }

  cout << dp[5] << endl;


  return 0;
}


Measured memory_bytes: 512
def main():
    MOD = 10**9 + 7
    N, M = list(map(int, input().split(' ')))
    broken = [0 for _ in range(N + 1)]
    for _ in range(M):
        broken[int(input())] = 1
    dp = [0 for _ in range(N + 1)]
    dp[0] = 1
    for s in range(1, N + 1):
        if broken[s] == 1:
            continue
        n = dp[s - 1]
        if s - 2 >= 0:
            n += dp[s - 2]
        dp[s] += n
        dp[s] %= MOD
    print(dp[N])


if __name__ == '__main__':
    main()


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

int main(){
  int N,M;
  cin>>N>>M;
 vector<int> A(M);
 vector<int> B(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i)>>B.at(i);
  }
 vector<int> C(N);
  for(int i=1;i<=N;i++){
   int sum=0;
    for(int j=0;j<M;j++){
      if(A.at(j)==i||B.at(j)==i){
        sum++;
      }
    }
    C.at(i-1)=sum;
  }
  for(int i=0;i<N;i++){
cout<<C.at(i)<<endl;
  }
}

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

static const int64_t mod = 1000000007;

int64_t mpow(int64_t a, int64_t p)
{
  if (p == 0) return 1;
  if (p == 1) return a;
  if (p % 2 == 0) {
    auto t = mpow(a, p / 2);
    return t * t % mod;
  } else {
    return a * mpow(a, p - 1) % mod;
  }
}

int64_t mcomb(int64_t n, int64_t k)
{
  if (n < k) return 0;
  if (k == 0) return 1;
  if (n - k < k) return mcomb(n, n - k);
  int64_t numer = 1;
  int64_t denom = 1;
  for (int i = 0; i < k; i++) {
    numer *= n - i;
    denom *= i + 1;
    numer %= mod;
    denom %= mod;
  }
  return numer * mpow(denom, mod - 2) % mod;
}

int main()
{
  int64_t n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cout << mcomb(n - k + 1, i) * mcomb(k - 1, i - 1) % mod << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> S;
  int open = 0, close = 0;
  int s = 0;
  for (char c : S) {
    if (c == '(') {
      s++;
    }
    else {
      s--;
      if (s<0) {
        s = 0;
        open++;
      }
    }
  }
  close = s;
  rep(i, open)cout<<"(";
  cout<<S;
  rep(i, close)cout<<")";
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	static String SweetsJudge(int k){
		for(int i=0; i<=k/4; i++){
			if((k-4*i)%7==0)return "Yes";
		}
		return "No";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(SweetsJudge(n));
	}
}

Measured memory_bytes: 23124
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += (p + 1) / 2
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 100504
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    int d[26];
    REP(i,26)d[i]=10000000;
    CASET{
        string s;
        int a[26]={};
        cin>>s;
        REP(i,SZ(s))a[s[i]-'a']++;
        REP(i,26)d[i]=min(d[i],a[i]);
    }
    REP(i,26){
        REP(j,d[i])putchar('a'+i);
    }
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
vector<ll> fac, finv, inv;

ll combCalc(ll n, ll k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll comb(ll x, ll y){
    fac = finv = inv = vector<ll>(x+1);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<=x; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
    return combCalc(x, y);
}


int main(){
    ll x, y;    cin >> x >> y;
    ll ex=x/2, ox=x%2, ans=0;
    
    while(0<=ex){

        if(2*ex+ox==x && ex+2*ox==y){
            ans = comb(ex+ox, ox);
            break;
        }

        ex -= 1; ox += 2;
    }
    cout << ans << endl;
}

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

// Begin Header {{{
using namespace std;

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

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

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

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

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    using ld = long double;
    var(ld, a, b, c);

    ld sq = 2.0L * sqrtl(a * b);
    cout << ((a + sq + b < c) ? "Yes" : "No") << "\n";

    return 0;
}


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

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

	int ans = 0;

	for(int i = 1; i <= n; i += 2) {
		int num = 0;
		for(int j = 1; j <= i; ++j) {
			if(i%j == 0)
				num++;
		}
		if(num == 8)
			ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int d,s=0;
	rep(i,0,4){
		cin>>d; s+=d;
	}
	o(s/60);
	o(s%60);
}

Measured memory_bytes: 1160
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

string s;
int N;
int main()
{
	cin>>s;
	N=s.size();
	int ans=N;
	rep1(i,s.size()-1){
		if(s[i]!=s[i-1]){
			ans=min(ans, max(i,N-i) );
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next());
		List<point> p=new ArrayList<>();
		for(int i=0;i<n;i++) {
			p.add(new point(Integer.parseInt(in.next()),Integer.parseInt(in.next())));
		}
		p.sort(Comparator.comparingInt(point::getx).thenComparingInt(point::gety));
		for(int i=0;i<n;i++) {
			System.out.println(p.get(i).x+" "+p.get(i).y);
		}
	}

}


class point{
	int x,y;
	point (int a,int b){
		x=a;
		y=b;
	}
	
	int getx() {
		return x;
	}
	
	int gety() {
		return y;
	}
}


Measured memory_bytes: 91724
N = int(input())
K = int(input())
S = [0]+[int(c) for c in str(N)]
L = len(S)-1
dp0 = [[0]*(K+1) for i in range(L+1)]
dp1 = [[0]*(K+1) for i in range(L+1)]
dp0[0][0] = 0
dp1[0][0] = 1
for i in range(1,L+1):
  for j in range(K+1):
    if j==0:
      if S[i]>0:
        dp0[i][j] = dp0[i-1][j]+dp1[i-1][j]
      else:
        dp0[i][j] = dp0[i-1][j]
    else:
      if S[i]>0:
        dp0[i][j] = dp0[i-1][j]+dp0[i-1][j-1]*9+dp1[i-1][j]+dp1[i-1][j-1]*(S[i]-1)
        dp1[i][j] = dp1[i-1][j-1]
      else:
        dp0[i][j] = dp0[i-1][j]+dp0[i-1][j-1]*9
        dp1[i][j] = dp1[i-1][j]
print(dp1[-1][-1]+dp0[-1][-1])


Measured memory_bytes: 3064
(let* ((n (read))
       (arr (make-array `(,n 3) :initial-element 0 :element-type 'fixnum))
       (dparr (make-array `(,n 3) :initial-element 0 :element-type 'fixnum)))
  (loop :for k :from 0 :upto (1- n) :do(progn (setf (aref arr k 0) (read))
                                              (setf (aref arr k 1) (read))
                                              (setf (aref arr k 2) (read))))
  (progn (setf (aref dparr 0 0) (aref arr 0 0))
         (setf (aref dparr 0 1) (aref arr 0 1))
         (setf (aref dparr 0 2) (aref arr 0 2)))
  (loop :for k :from 1 :upto (1- n) :do (progn (setf (aref dparr k 0) (+ (aref arr k 0)
                                                                         (max (aref dparr (1- k) 1) (aref dparr (1- k) 2))))
                                               (setf (aref dparr k 1) (+ (aref arr k 1)
                                                                         (max (aref dparr (1- k) 0) (aref dparr (1- k) 2))))
                                               (setf (aref dparr k 2) (+ (aref arr k 2)
                                                                         (max (aref dparr (1- k) 0) (aref dparr (1- k) 1))))))
  (princ (max (aref dparr (1- n) 0) (aref dparr (1- n) 1) (aref dparr (1- n) 2))))

Measured memory_bytes: 63908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = r / d - (l - 1) / d;
    cout << ans << '\n';
}

Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    s += "~";
    int n = s.size(), cur = 0;
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'A')
        {
            cur++;
        }
        else if (s[i] == 'B' && s[i + 1] == 'C')
        {
            ans += cur;
            i++;
        }
        else
        {
            cur = 0;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// ????????????????????????±?????????±???
 
int n;
int x[30], y[30];
 
double dist(int a, int b){
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]));
}
 
bool solve(){
    for(int i=0;i<n;i++){
        if(dist(n, 0) + dist(0, i) >= dist(n+1, i)) return false;
    }
    return true;
}
 
int main(){
    while(1){
        cin >> n;
        if(n == 0) break;
        cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i];
        }
 
        if(solve()) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 2964
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

int N,D,T,cnt=0,ans=0;
int a1[20][20];

int main()
{
	cin>>N>>D;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=D;j++)
			cin>>a1[i][j];
	for(int i=1;i<=N;i++)
		for(int j=N;j>i;j--)
		{
			ans=0;
			for(int k=1;k<=D;k++)
				ans+=(a1[i][k]-a1[j][k])*(a1[i][k]-a1[j][k]);
			T=int(sqrt(ans));
			if(T*T==ans)
				cnt++;
		}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int a[maxn]; 
int main()
{
	int n;
	int num=1;
	cin>>n;
	memset(a,0,sizeof(a));
	a[n]=1;
	while(1)
	{
		if(n%2==0)
		{
			n=n/2;
		}
		else
		{
			n=3*n+1;
		}
		num++;
		if(a[n]!=0)
		{
			cout<<num<<endl;
			break;
		}
		else
		{
			a[n]=1;
		}
	}
	 
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
string s;
bool u[30];
int main(){
	string stupid="zyxwvutsrqponmlkjihgfedcba";
	cin>>s;
	if(s==stupid)
	{
		cout<<-1;
		return 0;
	}
	if(s.size()==26)
	{
		char ch[26];
		for(int i=0;i<26;i++)
			ch[i]=s[i];
		next_permutation(ch,ch+26);
		for(int i=0;i<26;i++)
		{
			if(ch[i]>s[i])
			{
				cout<<ch[i];
				return 0;
			}
			cout<<ch[i];
		}
	}
	else
	{
		for(int i=0;i<s.size();i++)
			u[s[i]-'a']=true;
		for(int i=0;i<26;i++)
			if(!u[i])
			{
				cout<<s<<char(i+'a');
				return 0;
			}
	}
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 300020
using namespace std;
int read(){
	int nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,c[M],od[M],L[M],R[M];
void add(int ps,int x){for(int k=ps;k<=m;k+=(k&-k)) c[k]+=x;}
int sum(int ps){int tt=0;for(int k=ps;k;k-=(k&-k)) tt+=c[k]; return tt;}
void write(int x){if(x>9) write(x/10); putchar(x%10+'0');}
bool cmp(int x,int y){return R[x]-L[x]<R[y]-L[y];}
void check(int x){add(L[x],1),add(R[x]+1,-1);}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++) L[i]=read(),R[i]=read(),od[i]=i;
	sort(od+1,od+n+1,cmp);
	for(int i=1,now=1,ans,ps;i<=m;i++,write(ans),putchar('\n')){
		for(;now<=n&&R[od[now]]-L[od[now]]<i;now++) check(od[now]);
		for(ans=n-now+1,ps=i;ps<=m;ps+=i) ans+=sum(ps);
	}
	return 0;
}

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


int main() {
  //input
  long long n; cin >> n;
  vector<long long> a(5); for(int i=0;i<5;i++) cin >> a[i];
  //comp
  int i=0;
  long long tmp;
  tmp = min({a[0],a[1],a[2],a[3],a[4]});
  long long ans = (n + (tmp-1)) / tmp;
  //output
  cout << ans+4 << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	rep(i,n) {cin >> vec.at(i);	}
	int ans = 0;
	rep(i, n - 2) {
		if ((vec.at(i) - vec.at(i + 1)) * (vec.at(i + 2) - vec.at(i + 1))<0) {
			ans++;
		}
	}
	cout << ans << endl;

	
}



Measured memory_bytes: 256
// I hate Factorization

func main() {
    let x = Int(readLine()!)!
    for i in 1...120 {
        for j in -120..<i {
            let result = i * i * i * i * i - j * j * j * j * j
            if result == x {
                print("\(i) \(j)")
                return
            }
        }
    }
}

main()

Measured memory_bytes: 7888
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int a[maxn];
int n, k;

vector<vector<int> > es;

int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
    if (i) {
      es[a[i]].pb(i);
    }
  }
  return 1;
}

int res;
int dfs(int v) {
  int mx = 0;
  for (int u : es[v]) {
    int got = dfs(u);
    mx = max(mx, got);
  }
  if (v && a[v] && mx == k - 1) {
    ++res;
    return 0;
  }
  return mx + 1;
}

void solve() {
  res = 0;
  if (a[0]) {
    ++res;
  }
  dfs(0);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    int N, X; cin >> N >> X;
    int sum = 0, ans = N;
    vector<int> m(N);
    rep(i,N)  cin >> m[i];
    sort(m.begin(),m.end());
    rep(i,N)  sum += m[i];

    int res = X - sum;
    ans += res / m[0];

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	ll x;
	cin>>n>>x;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll out=0;
	rep(i,n)out+=in[i];
	rep(i,n){
		vi nex(n,inf);
		rep(j,n)nex[(j+1)%n]=min(in[(j+1)%n],in[j]);
		in=nex;
		ll sum=0;
		rep(j,n)sum+=in[j];
		out=min(out,sum+(i+1)*x);
	}
	cout<<out<<endl;
}
 
 







Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3

output:
5
0 0
2 1
4 2
3 3
1 3
"""

import sys
from operator import attrgetter

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        # print('COUNTER_CLOCKWISE')
        flag = 1
    elif cross(a, b) < -1 * EPS:
        # print('CLOCKWISE')
        flag = -1
    elif dot(a, b) < -1 * EPS:
        # print('ONLINE_BACK')
        flag = 2
    elif abs(a) < abs(b):
        # print('ONLINE_FRONT')
        flag = -2
    else:
        # print('ON_SEGMENT')
        flag = 0
    return flag


def convex_check_Andrew(_polygon):
    upper, lower = list(), list()
    _polygon.sort(key=attrgetter('real', 'imag'))

    upper.extend((_polygon[0], _polygon[1]))
    lower.extend((_polygon[-1], _polygon[-2]))

    for i in range(2, points):
        n1 = len(upper)
        while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
            n1 -= 1
            upper.pop()
        upper.append(_polygon[i])

    for j in range(points - 3, -1, -1):
        n2 = len(lower)
        while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
            n2 -= 1
            lower.pop()
        lower.append(_polygon[j])

    # change to ccw inplace
    lower.reverse()
    # find bottom-left of the hull and split lower
    lower_min = min(lower, key=attrgetter('imag', 'real'))
    init_index = lower.index(lower_min)
    # ignore upper part's last and first, in ccw 
    return lower[init_index:] + upper[-2:0:-1] + lower[:init_index]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    points = int(_input[0])
    p_info = map(lambda x: x.split(), _input[1:])

    polygon = [int(x) + int(y) * 1j for x, y in p_info]
    ans = convex_check_Andrew(polygon)
    print(len(ans))
    for ele in ans:
        print(int(ele.real), int(ele.imag))

Measured memory_bytes: 31048
import java.util.Scanner;

//AtCoder Beginner Contest 157
//A	Duplex Printing
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		if (N%2==0) {
			System.out.println(N/2);
		} else {
			System.out.println((N/2)+1);
		}

	}
}


Measured memory_bytes: 21844
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll k;
    cin >> k;

    int v1 = 7%k;
    int v2 = 1;
    int cnt = 1;
    while(cnt < k+2) {
        if(v1 == 0) break;
        v2 = (10*v2)%k;
        v1 = (v1+7*v2)%k;
        cnt++;
    }

    if(cnt < k+2) cout << cnt << endl;
    else cout << -1  << endl;
    return 0;
}


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

int main(){
    int X,Y;
    cin >> X >> Y;
    int ashi=0;
    bool judge=false;
    for(int i=0; i<X+1; i++){
        ashi=i*4+(X-i)*2;
        if(ashi==Y){
            judge=true;
            break;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624