akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var abc = CRL().ArrayInts();
        var s = Math.Min(abc[0], abc[1]);
        var e = Math.Max(abc[0], abc[1]);
        if (s <= abc[2] && e >= abc[2])
        {
            CWL("Yes");
        }
        else
        {
            CWL("No");
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();

    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();

    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

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

ll max(ll a, ll b) {
    if (a < b) return b;
    return a;
}
ll min(ll a, ll b) {
    if (a > b) return b;
    return a;
}
int main() {
    ll a,b,k; cin >> a >> b >> k;
    ll tmp1 = a-k;
    ll tmp2 = b-max(0,k-a);
    cout << max(0, tmp1) << " " << max(0, tmp2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

string str[100];
int n, ednd;

int check(int a) {
    for(int i = 0; i < a; i++) 
        if(!str[i].compare(str[a])) return 0;
    return 1;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> str[i];
    
    for(int i = 1; i < n; i++) {
        //cout << str[i] << endl;
        if(!check(i)) {
            ednd = 1;
            break;
        }
        if(str[i-1][str[i-1].size()-1] != str[i][0]) {
            ednd = 1;
            break;
        }
    }
    if(!ednd) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
n,k,*p=map(int,open(0).read().split())
s=[p[0]]*n
for i in range(1,n):
  s[i]=s[i-1]+p[i]
ans=s[k-1]
for i in range(n-k):
  ans=max(ans,s[i+k]-s[i])
print((ans+k)/2)

Measured memory_bytes: 25036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;
int main(){
    ll A,B; cin>>A>>B;
    ll N;cin>>N;
    ll x=min(N,B-1);
    ll ans=floor(A*x/B)-A*floor(x/B);
    cout<<ans;
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = A * (N / (A + B));
    N %= (A + B);
    ans += std::min(N, A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7
list.sort(A)


binom = 1 # (k-1) choose (k-1)
ans = binom * (A[K - 1] - A[N - K]) % p #
inv = [0, 1]    # inv[i] : inverse of i mod p

# (i choose k-1) = (i-1 choose k-1) * i / (i-k+1)
for i in range(2, N):
    if i <= N - K:
        inv.append(( inv[p % i] * (p - p // i) ) % p )

    if i >= K:
        binom = (((i * inv[i - K + 1]) % p) * binom ) % p # i choose (k-1)
        ans = (ans + binom * (A[i] - A[N - 1 - i])) % p

print(ans)


Measured memory_bytes: 14416
#include<stdio.h>
int main(){
  int d,n,i,j;
  scanf("%d",&d);
  scanf("%d",&n);
  if(n ==100) n++;
  j = 1;
  for(i = 0;i < d;i++){
    j *= 100;
  }
  n *= j;
  printf("%d\n",n);
  return 0;
}


Measured memory_bytes: 128
n,m = [int(x) for x in input().split()]
ab = []
cd = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    ab.append(tmp)
for _ in range(m):
    tmp = [int(x) for x in input().split()]
    cd.append(tmp)

for i in range(n):
    ans = 0
    man = 10**9
    for j in range(m):
        tmp = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if man > tmp:
            man = tmp
            ans = j + 1

    print(ans)

Measured memory_bytes: 3064
N = int(input())
data = []
for i in range(N):
    a,b,c = map(int,input().split())
    data.append([a,b,c])
    


dp = [ [0 for col in range(3)] for row in range(N) ]

dp[0][0] = data[0][0]
dp[0][1] = data[0][1]
dp[0][2] = data[0][2]


# Maintain three scores for each day, one for each activity
# 

for day in range(1,N):
    for choice in range(3):
        for prev_choice in range(3):
            if choice != prev_choice:
                dp[day][choice] = max(dp[day][choice],dp[day-1][prev_choice]+data[day][choice])
                
best = max(dp[-1][:])
                
        
    
print (best)

Measured memory_bytes: 74776
def rch(dis, mov, goal)
  dp = [{}]
  dp[0][0] = 1
  mov.each.with_index{|step,i|
    next if i%2==dis
    h = {}
    dp[-1].each_key{|k|
      h[k-step] = 1 if i!=0
      h[k+step] = 1
    }
    dp << h
  }
  dp[-1][goal]
end

def rchX(mov, x)
  rch(1, mov, x)
end

def rchY(mov, y)
  rch(0, mov, y)
end

s = gets.chomp
x, y = gets.split.map &:to_i

mov = []
count = 0

s.chars{|c|
  if c=='F' then
    count+=1
  elsif c=='T'then
    mov << count
    count = 0
  end
}
mov << count

puts (rchX(mov, x)&&rchY(mov, y)) ? 'Yes' : 'No'

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

using namespace std;

bool cmp(pair<int,int> a, pair<int,int> b){

    return a.second == b.second ? a.first < b.first: a.second < b.second;
}

int main(){

    
    int n;
    cin>>n;
    vector<pair<int,int> >A; 

    for(int i=0,s,t; i<n; ++i)
        cin>>s>>t, A.push_back(make_pair(s,t));

    sort(A.begin(), A.end(), cmp);

    // for(auto x: A)
    //         cout<<x.first<<"\t"<<x.second<<endl;
    // cout<<endl;

    long long sum(0);
    for(auto x: A){
        sum += x.first;
        if(sum>x.second) 
            return cout<<"No"<<endl, 0;
    }
    cout<<"Yes"<<endl;        
        
    return 0;
}

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

int main (){
  int a,b;
  int r = 0;
  cin >> a >> b;
  
  for(int i = a; i <= b; i++){
    int s = i % 10, t = i / 10000 % 10;
    int u = i / 10 % 10, v = i /1000 % 10;
    
    if(s == t && u == v)
      r++;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long long sum = 0;
  int n, k;
  cin >> n >> k;
  long long a[n];
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for(int i = 0; i < n - k; ++i) sum += a[i];
  cout << sum;
	
}

Measured memory_bytes: 1792
n, m, j = list(map(int,input().split())), list(map(int,input().split())), set()
[j.add((n[2 * i + 1],n[2 * i + 2])) for i in range(n[0])]
[j.add((m[2 * i + 1],m[2 * i + 2])) for i in range(m[0])]
j = list(j)
j.sort(key = lambda x:x[1])
j.sort(key = lambda x:x[0])
print(*["{0}:{1:02d}".format(i[0],i[1]) for i in j])


Measured memory_bytes: 5640
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int xx,yy,i,tmp,ans,a,n,c,x,y,b;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	ans=1000000007;
	for(i=0;i<=max(x,y)*2;i+=2)
	{
		tmp=c*i;
		xx=x-i/2;
		yy=y-i/2;
		if(xx<0)xx=0;
		if(yy<0)yy=0;
		tmp+=a*xx;
		tmp+=b*yy;
//		if(i>199999)
//		printf("%d %d %d %d\n",i,tmp,xx,yy);
		ans=min(tmp,ans);
	}
//	printf("%d\n",i);
	printf("%d\n",ans);
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 1000000007 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;
void solve(){
int n;
cin>>n;
int a[n];
int ans=0;
int sum=0;

fo(i,n){
    cin>>a[i];
sum+=a[i];
}
fo(i,n){
   sum-=a[i];
   ans+=((sum%Mod)*(a[i]%Mod))%Mod;
}


cout<<ans%Mod;


}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
  solve();
  


}

Measured memory_bytes: 5168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int N, X;
    int i;
    cin >> N >> X;
    vector<int> m(N); 
    int result = N;

    for(i = 0; i < N; i++){
        cin >> m[i];
        X -= m[i];
    }
    result += X / *min_element(m.begin(), m.end());
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdtr1c++.h>
using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    double S = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        S += 1.0 / x;
    }
    cout << fixed << setprecision(10) << 1.0 / S;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

int calc(int x) {
    int ret = 0;
    while (x > 0) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    int ans = 100000;
    for (int i = 1; i < n; i++) {
        int a = i;
        int b = n - i;
        ans = min(ans, calc(a) + calc(b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long sa;
		n = n - (n/k)*k;
		
		
		while (true) {
			if(n > k) {
				sa = n - k;
			}else {
				sa = k - n;
			}
			if(n > sa) {
				n = sa;
			}else {
				break;
			}
			
		}
		System.out.println(n);
	}
	
}


Measured memory_bytes: 23124
n, m = map(int,input().split())
A = [[0]*m for i in range(n)]
B = [0]*m
C = [0]*n

for i in range(n):
    A[i] = list(map(int,input().split()))

for j in range(m):
    B[j] = int(input())

for i in range(n):
    for j in range(m):
        C[i] += A[i][j] * B[j]


for i in range(n):
    print(str(C[i]))


Measured memory_bytes: 5952
import sys


def main():
    # input = sys.stdin.readline
    N = int(input())

    test = [dict() for _ in range(N)]

    count = 0

    for i in range(N):
        M = int(input())
        for _ in range(M):
            j, b = map(int, input().split())
            test[i][j-1] = bool(b)

    for i in range(2**N):
        bit = format(i, 'b')
        bit = '0' * 15 + bit
        bit = bit[-N:]

        honest = set()
        liar = set()
        for i, s in enumerate(bit):
            if s == '1':
                honest.add(i)
            else:
                liar.add(i)

        m = len(honest)
        for j in honest:
            for g, r in test[j].items():
                if r and g in liar:
                    m = 0
                elif not r and g in honest:
                    m = 0

        count = max(count, m)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)

Ac = sorted([i for i in c.keys() if c[i] >= 2], reverse=True)

if len(Ac) >= 2 and c[Ac[0]] >= 4:
    print(max(Ac[0] * Ac[1], Ac[0] * Ac[0]))
elif len(Ac) >= 2:
    print(Ac[0] * Ac[1])
elif len(Ac) == 1 and c[Ac[0]] >= 4:
    print(Ac[0] * Ac[0])
else:
    print(0)


Measured memory_bytes: 18600
import java.util.Scanner;

public class Main {

	int N;
	int INF = Integer.MAX_VALUE/10;

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int R = in.nextInt();
		boolean[] town = new boolean[N+1];
		for (int i = 0; i < R; i++) {
			town[in.nextInt()] = true;
		}
		int[][] edge = new int[N+1][N+1];
		for (int i = 0; i < N+1; i++) {
			for (int j = 0; j < N+1; j++) {
				edge[i][j] = INF;
			}
		}
		
		for (int i = 0; i < M; i++) {
			int A = in.nextInt();
			int B = in.nextInt();
			int C = in.nextInt();
			edge[A][B] = C;
			edge[B][A] = C;
		}
		solveWF(edge);
		System.out.println(getAns(town,edge,-1));

	}
	
	private int getAns(boolean[] town, int[][] edge,int prev){
		int plus = Integer.MAX_VALUE;
		boolean active = false;
		for (int i = 0; i < town.length; i++) {
			if(town[i]){
				active = true;
				town[i] = false;
				plus = Math.min(plus, ((prev==-1)?0:edge[prev][i]) + getAns(town,edge,i));
				town[i] = true;
			}
		}
		return (active)?plus:0;
	}
	
	private void solveWF(int[][] edge){ // none - INF
		for(int k=0;k<edge.length;k++){
			for(int i=0;i<edge.length;i++){
				for(int j=0;j<edge.length;j++){
					edge[i][j] = Math.min(edge[i][j],edge[i][k]+edge[k][j]);
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 45916
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    T = {0: 1}
    t = 0
    r = 0
    for i in range(len(A)):
        t = (t + A[i]) % M
        r += T.get(t, 0)
        T[t] = T.get(t, 0) + 1
    print(r)
main()


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

#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORU(i,j,k) for(int i=(j);i<=(k);++i)
#define FORD(i,j,k) for(int i=(j);i>=(k);--i)

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

string TYPE(int*)  { return "%d";   }
string TYPE(lli*)  { return "%lld"; }
string TYPE(char*) { return "%c";   }

void RD() {}
template<typename T, typename... Args> 
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}

void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args> 
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args> 
void PR(Args... args)
{ PR(true, args...); }

vector<string> split(const string& s, char c)
{
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args)
{
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}

const long long int oo = 4 * 1E18;

struct Coord
{
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    {
        return Coord(x + droite.x, y + droite.y);
    }
};

struct AB
{
    int k;
    vector<lli> arbre;
    AB(int _k = 20, lli def = 0)
    {
        k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x)
    {
        int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud)
    {
        if(noeud)
        {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
        }
    }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1)
    {
        if(q < p)
            q = 1 << (k-1);
        if(deb <= p && q <= fin)
            return arbre[noeud];
        if(deb >= q || fin <= p)
            return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

lli x[1000*1000];

int main()
{
	int n;
	lli a, b;
	RD(&n, &a, &b);
	FOR(i, n)
		RD(x+i);
	lli r = 0;
	FOR(i, n-1)
		r += min(a * (x[i+1] - x[i]), b);
	PR(r);
    return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val h = readLine()!!.split(' ').map { it.toInt() }

    val noRoot = BooleanArray(n){true}
    val highest = BooleanArray(n){true}

    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        noRoot[a-1] = false
        noRoot[b-1] = false
        if (h[a-1] <= h[b-1]) highest[a-1] = false
        if (h[a-1] >= h[b-1]) highest[b-1] = false
    }
    var ans = 0
    repeat(n) {
        if (noRoot[it] || highest[it]) ans++
    }
    println(ans)

}


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

int main(void) {
  int N, M;
  cin >> N  >> M;
  vector< pair<int, int> > ab(M);
  int i = 0, j;
  for(; i < M; i++) cin >> ab[i].second >> ab[i].first;
  sort(ab.begin(), ab.end());
  int a = 0;
  bool r;
  vector<bool> b(N - 1, 1);
  for(i = 0; i < M; i++) {
    r = 0;
    for(j = ab[i].second - 1; j < ab[i].first - 1; j++) {
      if(!b[j]) {
        r = 1;
        break;
      }
    }
    if(!r) {
      a++;
      b[j - 1] = 0;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 1024
using System;

namespace ABC093_D___Grid_Components
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var A = AB[0]; var B = AB[1];
            var isBlack = new bool[100, 100];
            for (int i = 0; i < 50; i++) for (int j = 0; j < 100; j++) isBlack[i, j] = true;
            for (int i = 50; i < 100; i++) for (int j = 0; j < 100; j++) isBlack[i, j] = false;

            var white = 1; var black = 1;

            for (int i = 0; i < 49; i += 2)
            {
                for (int j = 0; j < 100; j++)
                {
                    if (white == A) break;
                    if ((i % 2) == (j % 2))
                    {
                        isBlack[i, j] = false;
                        white++;
                    }
                }
                if (white == A) break;
            }

            for (int i = 99; i > 50; i -= 2)
            {
                for (int j = 0; j < 100; j++)
                {
                    if (black == B) break;
                    if ((i % 2) == (j % 2))
                    {
                        isBlack[i, j] = true;
                        black++;
                    }
                }
                if (black == B) break;
            }

            Console.WriteLine("100 100");
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    Console.Write(isBlack[i, j] ? "#" : ".");
                }
                Console.Write("\n");
            }
        }
    }
}


Measured memory_bytes: 13248
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int N;
	cin>>N;
	
	int K;
	cin>>K;

	int X;
	cin >> X;

	int Y;
	cin >> Y;

	int sum = 0;
	if(K > N){
		sum = X * N;
	}
	else{
		sum = X * K;
		sum = sum + (Y *(N-K));
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>().chars().collect::<HashSet<_>>();
    if n.contains(&'7') {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2140
import java.util.Comparator;
import java.util.Scanner;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(final String[] args) {

        final Scanner scanner = new Scanner(System.in);
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();
        final int c = scanner.nextInt();

        final BiFunction<Integer, Integer, Stream<Long>> listGenerator = (length, limit) -> IntStream.range(0, length)
                .mapToObj(i -> scanner.nextLong())
                .sorted(Comparator.reverseOrder())
                .limit(limit);

        final long answer = Stream.of(
                listGenerator.apply(a, x),
                listGenerator.apply(b, y),
                listGenerator.apply(c, c))
                .flatMap(Function.identity())
                .sorted(Comparator.reverseOrder())
                .limit(x + y)
                .mapToLong(Long::longValue)
                .sum();

        System.out.println(answer);
    }
}


Measured memory_bytes: 104056
import sys
sys.setrecursionlimit(10**6)
from collections import deque

n, m = map(int, input().split())
l = [[] for i in range(n)]
union = []
vis = [-1]*n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

q = deque()

def dfs(a):
    if vis[a] == -1:
        vis[a] = 0
        temp.append(a)
        for j in l[a]:
            q.append(j)
    if len(q) > 0:
        b = q.popleft()
        dfs(b)
    return temp

for i in range(n):
    temp = []
    union.append(dfs(i))

for i in union:
    ans = max(ans, len(i))

print(ans)

Measured memory_bytes: 361744
#include <bits/stdc++.h>
 
#define int long long
 
using namespace std;

int a[100001];
 
 main () {
	ios_base::sync_with_stdio (0);	
	cin.tie (0), cout.tie (0);
	int n;
	cin >> n;
	int kol = 0;
	int mn = n;
	int mx = 0;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		mn = min (mn, a[i]);
		mx = max (mx, a[i]);
	}
	if (mx > n - 1) {
		cout << "No";
		return 0;
	}
	int kol1 = 0;
	for (int i = 1;i <= n;i ++) {
		if (a[i] == mn) kol1 ++;
	}   
	int kol2 = n - kol1;
	if (mx - mn > 1) {
		cout << "No";
		return 0;
	}
	if (mx == mn) {
		if (mx == n - 1) {
			cout << "Yes";
			return 0;
		}
		if (n / mx > 1) {
			cout << "Yes";
		}
		else cout << "No";
	}
	else {
		if (mn == 1) {
			if (kol1 > 1) {
				cout << "No";
				return 0;
			}
		}
		if (kol2 == 1) {
			cout << "No";
			return 0;
		}
		if ((kol1 - 1) + kol2 / 2 >= mn && kol1 + kol2 / 2 >= mx) {
			cout << "Yes";
		}
		else cout << "No";
	}
	return 0;
}

Measured memory_bytes: 1024
def main():
	N, A, B = map(int, input().split())
	v = list(map(int, input().split()))
	v.sort(reverse=True)
	ave_ans = sum(v[:A])/A
	cmp_v = v[A-1]
	cmp_v_in = 0
	cmp_v_out = 0
	def get_total(values):
		ans = 0
		for v in values:
			if v == cmp_v:
				ans += 1
		return ans
	cmp_v_in = get_total(v[:A])
	cmp_v_out = get_total(v[A:])
	fact = [0]*51
	fact[0] = 1
	fact[1] = 1
	for i in range(2, 51):
		fact[i] = fact[i-1]*i

	def C(n, k):
		return fact[n]//(fact[k]*fact[n-k])

	print(ave_ans)

	choose_ans = C(cmp_v_in+cmp_v_out, cmp_v_in)
	if cmp_v_in == A:
		for i in range(1, min(B-A+1, cmp_v_out+1)):
			choose_ans += C(cmp_v_in+cmp_v_out, cmp_v_in+i)
	print(choose_ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

typedef long long LL;
const int N = 2e5 + 5;

char s[N];
int fail[N], n, cyc;
LL l, r, add[27], sub[27], tots[27], tott[27];
LL tab[90], cnts[90], cntt[90];

inline void solve1() {
  for (int i = 1; i <= cyc; i ++) add[s[i] - 'a'] ++;
  for (int i = 0; i < 26; i ++) {
    sub[i] = add[i] * (l / cyc);
    add[i] *= r / cyc;
  }
  for (int i = 1; i <= l % cyc; i ++) sub[s[i] - 'a'] ++;
  for (int i = 1; i <= r % cyc; i ++) add[s[i] - 'a'] ++;
}

inline void dfs(LL x, LL *res) {
  if (x <= n) {
    for (int i = 1; i <= x; i ++) res[s[i] - 'a'] ++;
    return;
  }
  int p;
  for (p = 1; tab[p + 1] <= x; p ++);
  for (int i = 0; i < 26; i ++) res[i] += cnts[p] * tots[i] + cntt[p] * tott[i];
  dfs(x - tab[p], res);
}

inline void solve2() {
  tab[0] = cyc; tab[1] = n;
  cnts[1] = 1;
  cntt[0] = 1;
  for (int i = 1; tab[i] <= r; i ++) {
    tab[i + 1] = tab[i] + tab[i - 1];
    cnts[i + 1] = cnts[i] + cnts[i - 1];
    cntt[i + 1] = cntt[i] + cntt[i - 1];
  }
  for (int i = 1; i <= n; i ++) tots[s[i] - 'a'] ++;
  for (int i = 1; i <= cyc; i ++) tott[s[i] - 'a'] ++;
  dfs(l, sub);
  dfs(r, add);
}

int main() {
  scanf("%s", s + 1);
  scanf("%lld%lld", &l, &r);
  l --;
  n = strlen(s + 1) >> 1;
  for (int i = 2, j = 0; i <= n; i ++) {
    while (j && s[j + 1] != s[i]) j = fail[j];
    if (s[i] == s[j + 1]) fail[i] = ++ j;
    else fail[i] = j;
  }
  cyc = n - fail[n];
  if (n % cyc == 0) solve1();
  else solve2();
  LL tot = 0;
  for (int i = 0; i < 26; i ++) {
    printf("%lld ", add[i] - sub[i]);
    tot += add[i] - sub[i];
  }
  cerr << "!!!!!!!!!!!!!" << tot << endl;
  return 0;
}


Measured memory_bytes: 896
using System;

namespace CODE_FESTIVAL_2016_Grand_Final_C___Cheating_Nim
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static int solver()
        {
            var N = int.Parse(Console.ReadLine());
            var piles = new int[N];
            var bits = new bool[30];
            for (int i = 0; i < N; i++)
            {
                piles[i] = int.Parse(Console.ReadLine());
                for (int j = 0; j < 30; j++)
                {
                    if ((piles[i] & (1 << j)) > 0)
                    {
                        bits[j] = true;
                        break;
                    }
                }
            }

            var xorSum = 0;
            foreach (int g in piles) xorSum ^= g;

            var result = 0;
            for (int bit = 29; bit >= 0; bit--)
            {
                if ((xorSum & (1 << bit)) == 0) continue;
                if (!bits[bit]) return -1;
                result++;
                xorSum ^= (1 << bit) - 1;
            }
            return result;
        }
    }
}


Measured memory_bytes: 17344
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

x,y=get_i
puts x.gcd(y)


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,t,a; cin>>N>>t>>a;
  vii Ki(N);
  rep(i,0,N-1){
    int X,Y; cin>>X>>Y;
    Ki[X-1].push_back(Y-1);
    Ki[Y-1].push_back(X-1);
    }
  vi T(N,-1),A(N,-1);
  queue<int> Q;
  Q.push(t-1);
  Q.push(-1);
  int count=0;
  while(Q.size()>1){
    int K=Q.front();
    Q.pop();
    if(K==-1){
      count++;
      Q.push(-1);
      }
    else{
      T[K]=count;
      rep(i,0,Ki[K].size()){
        if(T[Ki[K][i]]==-1)
          Q.push(Ki[K][i]);
        }
      }
    }
  count=0;
  Q.pop();
  Q.push(a-1);
  Q.push(-1);
  while(Q.size()>1){
    int K=Q.front();
    Q.pop();
    if(K==-1){
      count++;
      Q.push(-1);
      }
    else{
      A[K]=count;
      rep(i,0,Ki[K].size()){
        if(A[Ki[K][i]]==-1)
          Q.push(Ki[K][i]);
        }
      }
    }
  int ans=0;
  rep(i,0,N){
    if(T[i]<=A[i])
      ans=max(ans,A[i]-1);
    }
  cout<<ans<<endl;
  }


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	int n,sum=0;cin>>n;
	for(int i=1;i<=n;++i)
	{
		int x;cin>>x;
		if(i%2&&x%2)
		sum++;
	}
	cout<<sum;
 } 

Measured memory_bytes: 3584
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] d = new int[10];
    for(int i = 0; i < k; i++) {
      int c = sc.nextInt();
      d[c] = 1;
    }
    int ans = 0;
    for(int i = n; i < 1000000; i++) {
      int p = 0;
      int s = i;
      while(s > 0) {
        if(d[s % 10] == 1) p++;
        s /= 10;
      }
      if(p == 0) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

const M: i64 = 1000000000 + 7;

fn main() {
    let nm: Vec<_> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();

    let xs: Vec<i64> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();
    let ys: Vec<i64> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();

    let mut rx = 0;
    let mut ry = 0;
    for i in 0..nm[0] {
        rx += xs[i] * (i as i64 * 2 - nm[0] as i64 + 1);
        rx %= M;
    }
    for i in 0..nm[1] {
        ry += ys[i] * (i as i64 * 2 - nm[1] as i64 + 1);
        ry %= M;
    }

    println!("{}", rx * ry % M);
}


Measured memory_bytes: 11512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll t;
  cin>>t;
  deb(t+t*t+t*t*t)
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair

  int main()
  {
          ll n,flag=0;
          cin>>n;
         vll v;
         char c;
         while(n>0)
         {
             ll d;
             d=n%26;
             if(d==0)
             {
             flag=1;
             n=n-1;
             }
             else
             flag=0;
             if(flag==1)
             v.pb(26);
             else
             v.pb(d);
            // pr2(d,n);
              n=n/26;
         }
         for(auto it=v.rbegin();it!=v.rend();++it)
         {
             c=*it+96;
             cout<<c;
         }
  }

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, m, p, d[100001];
  cin >> n >> m >> p;
  rep(i, m) {
    cin >> d[i];
    d[i] -= p;
    d[i] = (d[i] + n) % n;
  }
  sort(d, d + m);
  ll ch = min(d[m - 1], n - d[0]);
  rep(i, m - 1) {
    ch = min(ch, min((d[i] * 2) + (n - d[i + 1]), ((n - d[i + 1]) * 2) + d[i]));
  }
  cout << ch * 100 << endl;
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    int n = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s.at(s.size() - i - 1) - '0';
        int ten = 1;
        for (int j = 0; j < i; j++) {
            ten *= 10;
        }
        n += (s.at(s.size() - i - 1) - '0') * ten;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $v = explode(" ", trim(fgets(STDIN)));

  sort($v);

  $ans = $v[0];
  for ($i=1; $i<$n; $i++) {
    $ans = ($ans + $v[$i]) / 2;
  }

  echo $ans;

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct Compress{
    vector<T> xs;
    Compress() = default;
    Compress(const vector<T> &vs){
        add(vs);
    }
    Compress(const initializer_list<vector<T>> &vs){
        for(auto &p : vs)   add(p);
    }

    // vs 内の座標をすべて追加
    void add(const vector<T> &vs){
        copy(begin(vs), end(vs), back_inserter(xs));
    }

    void add(const T &x){
        xs.emplace_back(x);
    }
    
    void build(){
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
    }

    // vs 内の座標を座標圧縮したものを返す
    vector<int> get(const vector<T> &vs) const{
        vector<int> ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x){
            return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    // 座標 x を座標圧縮したものを返す (x が xs 内で何番目にあるかを返す)
    int get(const T &x) const{
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
    }

    // 座標圧縮後の k が示す実際の座標を返す
    const T &operator[](int k) const{
        return xs[k];
    }
};

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

    int N;
    cin >> N;
    vector<int> sx(N), sy(N), tx(N), ty(N);
    Compress<int> xs, ys;
    for(int i = 0; i < N; ++i){
        cin >> sx[i] >> sy[i] >> tx[i] >> ty[i];
        xs.add(sx[i]), xs.add(tx[i]);
        ys.add(sy[i]), ys.add(ty[i]);
    }
    xs.build(), ys.build();

    int H = xs.xs.size(), W = ys.xs.size();
    vector<vector<int>> S(H + 5, vector<int>(W + 5, 0));
    for(int i = 0; i < N; ++i){
        int ly = ys.get(sy[i]), ry = ys.get(ty[i]);
        for(int j = xs.get(sx[i]); j < xs.get(tx[i]); ++j){
            ++S[j][ly];
            --S[j][ry];
        }
    }
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            S[i][j + 1] += S[i][j];
        }
    }

    ll ans = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(!S[i][j])    continue;
            ans += (ll)(xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const ll mod = 1e9+7;

ll modpow(ll n, ll m)
{
    if(m==0)return 1LL;
    else
    {
        ll u = modpow(n, m/2)%mod;
        if(m%2==0)
        {
            return (u*u)%mod;
        }

        else
        {
            return (((u*u)%mod)*n)%mod;
        }
    }
}

ll nCr(ll n, ll k)
{
    ll ans = 1LL;
    for(int i = 0; i < k; i++)ans=(ans*(n-i))%mod;
    ll trebaDaGaInverzujes=1LL;
    for(int i = 1; i <= k; i++)trebaDaGaInverzujes=trebaDaGaInverzujes*i%mod;
    return ((ans%mod)*(modpow(trebaDaGaInverzujes, mod-2)%mod))%mod;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    //cout <<modpow(2LL,n)-1LL<< ' ' << nCr(n,a) << ' ' << nCr(n,b) << '\n';
    ll resenje = (modpow(2LL,n)-1LL)-nCr(n,a)-nCr(n,b);
    cout<<(resenje+mod*100)%mod<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll>v(n*2);
    vector<ll>v2(n);
    cin>>v[0];
    for(int i=1;i<n;i++){
    	cin>>v[i];
    //	v.push_back(v[i]);
    }
    sort(v.begin(),v.end(),greater<ll>());
    ll sum=0;

    v2.push_back(v[0]);
    for(int i=1;i<n*2;i++){
    	if(v[i]!=0){
    		v2.push_back(v[i]);
    	        	v2.push_back(v[i]);

    	}
         }
    sort(v2.begin(),v2.end(),greater<ll>());

    for(int i=0;i<n*2;i++){
        //	cout<<v2[i]<<endl;;
        }
    for(int i=0;i<n-1;i++){
    	sum+=v2[i];
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 12544
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
set<pair<int,int> >S;
int n,a[200005],b[200005];
int get(int x){
	if(x==0)return b[n];
	if(x==n+1)return b[1];
	return b[x];
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(b[i]!=a[i])S.insert(make_pair(-b[i],i));
	}
	int ans=0;
	while(!S.empty()){
		pair<int,int>p=*S.begin();
		S.erase(S.begin());
		int v=p.first,id=p.second;
		int sub=get(id+1)+get(id-1);
		int nxt=(!S.size()?0ll:-S.begin()->first);
		int mul=(b[id]-max(max(get(id+1),get(id-1)),a[id]))/sub;
		mul=max(mul,1ll);
		b[id]-=sub*mul;
		ans+=mul;
		if(b[id]<a[id]){
			puts("-1");
			return 0;
		}
		if(b[id]!=a[id])S.insert(make_pair(-b[id],id));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15872
import math

a, b, x = map(int, input().split())
t1 = x * (2/(a*(b**2)))
if t1 < (a/b):
  print(90.-math.degrees(math.atan(t1)))
else:
  tmp = 2 * b - x * (2/(a**2))
  if tmp < 0.000001:
    print(0.)
  else:
    t2 = a/(2 * b - x * (2/(a**2)))
    print(90.-math.degrees(math.atan(t2)))


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a, ll b) { ll r = 1; a %= mod; while (b) { r = r * ((b % 2) ? a : 1) % mod, a = a * a % mod, b >>= 1; }return r; }



int main() {
	int a, b; cin >> a >> b;
	if (a < b)printf("0");
	else printf("10");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,A,B;
  string S;
  cin>>N>>A>>B>>S;
  int passed=0;
  int kaigai=0;
  for(int i=0; i<N; i++){
   if(S.at(i)=='a') {
     if(passed<A+B){
       cout<<"Yes"<<endl;
       passed++;
     }
     else{
       cout<<"No"<<endl;
     }
   }
   if(S.at(i)=='b') {
     kaigai++;
     if(passed<A+B && kaigai<=B){
       cout<<"Yes"<<endl;
       passed++;
     }
     else{
       cout<<"No"<<endl;
     }
   }
   if(S.at(i)=='c') {
     cout<<"No"<<endl;
   }
  }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll a[200005];
void solve(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	ll cnt=0;
	ld l=0,r=pow(10,10);
	while(cnt<=200){
		ld m=(l+r)/2;
		ll val=0;
		for(ll i=1;i<=n;i++)
			val+=floor(a[i]/m);
		if(val<=k)
			r=m;
		else
			l=m;
		cnt++;
	}
	cout<<ll(ceil(l));
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 5292
#include <stdio.h>

int main(void){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  int s, p, q, t;
  s=x+r;
  p=x-r;
  q=y+r;
  t=y-r;
  if(s<=W && q<=H){
    if(p>=0 && t>=0)
      printf("Yes\n");
    else 
      printf("No\n");
  }else
    printf("No\n");

 return 0;
}

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

using namespace std;

typedef long long ll;

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

	if (
		(N % 1 == 0 && N /1 <= 9) ||
		(N % 2 == 0 && N /2 <= 9) ||
		(N % 3 == 0 && N /3 <= 9) ||
		(N % 4 == 0 && N /4 <= 9) ||
		(N % 5 == 0 && N /5 <= 9) ||
		(N % 6 == 0 && N /6 <= 9) ||
		(N % 7 == 0 && N /7 <= 9) ||
		(N % 8 == 0 && N /8 <= 9) ||
		(N % 9 == 0 && N /9 <= 9) 

		)
	{
	 	cout << "Yes" << endl;
	} 
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
#define MAX_N 200
using namespace std;
ll gcd(ll a, ll b){
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a, b)*b;
}
int main(void){
  int n;
  ll ans = 1;
  cin >> n;
  for(int i = 0; i < n; i++){
    ll t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}

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

const int MAXN = 100005;

int A[MAXN];

int N, Ans;

int main() {
	ios::sync_with_stdio(false);

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

	{
		int i = 0;

		for(; i <= N;) {
			bool isu = true, isd = true;
			for(i += 2; i <= N; i++) {
				if(A[i-1] == A[i]) continue;
				if(A[i-1] < A[i]) {
					isd = false;
				} else {
					isu = false;
				}
				if(!isd && !isu) { i--; break; }
			}
			if(N < i) break;
			Ans++;
		}
	}

	cout << (Ans+1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll a, b, c, d;
ll mn[500010], mx[500010];
bool check(ll f)
{
	return abs(f-b) <= d && abs(f-b) >= c;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	if (a > b) swap(a, b);
	for (ll i = 0; i <= n-2; i++)
	{
		ll curr = a + i*d - (n-2-i)*c;
		if (curr < b-d) continue;
		if (check(curr))
		{
			printf("YES\n");
			return 0;
		}
		ll mxcanadd = (d-c)*(n-2);
		ll diff = curr-(b-c);
		assert(diff > 0);
		if (diff <= mxcanadd)
		{
			printf("YES\n");
			return 0;
		}
		if (curr < b+c) continue;
		diff = curr-(b+c);
		assert(diff > 0);
		if (diff <= mxcanadd)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (a[i] & 1) continue;
    if (a[i] % 3 != 0 & a[i] % 5 != 0) ok = false; 
  }
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;

int main(){
    int N,R,T;
    cin >> N >> R;
    T = R;
    if(N <= 9){
        R = T + (100 * (10 - N));
        cout << R << endl;
    }else cout << R << endl;
    return 0;
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, m, h, w;

int main() {
  init_ios();
  cin >> n >> m >> h >> w;
  cout<<n*m-h*m-w*n+h*w<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;cin >> n;
    vector<int> a(n);
    vector<bool> b(n,false);
    int mn = INF;
    int count = 0;
    rep(i,n) {
        cin >> a[i];
        if(mn>a[i]){
            mn = a[i];
            count++;
        }
    }
    cout <<count<<endl;


}



Measured memory_bytes: 1024