akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

vector< int > g[100000];

int dfs(int idx, int pre = -1)
{
  int ret = 0;
  for(auto &to : g[idx]) {
    if(to == pre) continue;
    ret ^= dfs(to, idx) + 1;
  }
  return (ret);
}

int main()
{
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int X, Y;
    cin >> X >> Y;
    --X, --Y;
    g[X].push_back(Y);
    g[Y].push_back(X);
  }
  if(dfs(0, -1)) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;

int main(){
   ll n; cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
   set<ll> count;
   vector<ll> num(100100);
   rep(i,n){
      if(i == 0){
         count.insert(a[i]);
         continue;
      }
      num[i - 1] = count.size();
      count.insert(a[i]);
      num[i] = count.size();
      if(num[i - 1] == num[i])count.erase(a[i]);
   }
   print(count.size());
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N;
ll ans = 0;

int main(void) {
	cin >> N;
	int i = 1;
	while (1) {
		if (i*111 >= N){
			cout << 111 * i << endl;
			break;
		}
		i++;
}


	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto K = RD;

	long ans = 1;
	while (N >= K)
	{
		++ans;
		N /= K;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
vl divisors(ll N){
    vl vt;
    ll i=1;
    for(i=1;i*i<N;i++){
        if(N%i==0){
            vt.push_back(i);
            vt.push_back(N/i);
        }
    }
    if(i*i==N){
        vt.push_back(i);
    }
    sort(all(vt));
    return vt;
}



int main(){
    ll N;
    cin>>N;
    vl vt=divisors(N);
    ll ans=0;
    for(auto num:vt){
        if(num==1){
            continue;
        }
        ll m=N;
        while(m%num==0){
            m/=num;
        }
        if(m%num==1){
            ans++;
        }
    }
    ans+=divisors(N-1).size();
    out(ans-1);
    
    return 0;
}


Measured memory_bytes: 384
[N, A, B] = input().split()
SUM = 0
for i in range(1, int(N)+1):
  list_i = list(str(i))
  sum_i = sum(list(map(int, list_i)))
  if int(A) <= sum_i <= int(B):
    SUM += i
  else:
    continue
print(SUM)

Measured memory_bytes: 3060
// ------------------------------------
// Date:2018/ 3/15
// Problem:AGC 011 AirportBus a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int INF = 100000001;

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

  int N, C, K;
  cin >> N >> C >> K;
  vector< int > T(N);
  REP(i, N) cin >> T[i];

  sort(ALL(T));

  int cnt = 0;
  int limit = 0;
  int ans = 0;
  REP(ti, T.size()) {
    if (ti != 0 and (limit < T[ti] or cnt >= C)) {
      // 境界値よりも次の人が遅い もしくは 乗車人数がMAXのとき
      ans++;
      cnt = 0;
    }
    if (cnt == 0) {
      limit = T[ti] + K;
    }
    cnt++;
    // debug(ti);
    // debug(ans);
  }
  if (cnt > 0) {
    ans++;
    cnt = 0;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
nums = {}

for _ in range(N):
    a, b = map(int, input().split())
    if a in nums:
        nums[a] += b
    else:
        nums[a] = b

nums_list = list(nums.items())
nums_list.sort()

while True:
    K -= nums_list[0][1]
    if K <= 0:
        print(nums_list[0][0])
        break
    else:
        del nums_list[0]




Measured memory_bytes: 14564
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();

    int max = 100010;
    for (int i = a; i <= max; i++) {
      if (isPrime(i)) {
        System.out.println(i);
        return;
      }
    }
  }

  private static boolean isPrime(int num) {
    for (int i = 2; i < num; i++) {
      if (num % i == 0) {
        return false;
      }
    }
    return true;
  }
}


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

using namespace std;

int n,i;
int tablica[100003];
int dp[100003];

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(i=0;i<n;i++){
        cin >> tablica[i];
    }
    dp[0]=0;
    dp[1]=abs(tablica[0]-tablica[1]);
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(tablica[i-1]-tablica[i]), dp[i-2]+abs(tablica[i-2]-tablica[i]));
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
   int i,n,a,max=-1000000,min=1000000;
   long long int sum=0;
   
   scanf("%d",&n);
   for(i=1;i<=n;i++){
       scanf("%d",&a);
       if(a>max) max=a;
       if(a<min) min=a;
       sum=sum+a;
   }
   
   printf("%d %d %lld\n",min,max,sum);
   
   return 0;
}



Measured memory_bytes: 2100
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  if(s[0]!=s[1] || s[1]!=s[2])cout<<"Yes"<<ENDL;
  else cout<<"No"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

//int reorder(int &g,int &m,int &l,int a,int b,int c);

void reorder(int &g,int &m,int &l,int a,int b,int c)
{
    if(a>=b && a>=c)
    {
        int g_;
        g = a;
        if(c!=-1)
        {
            reorder(g_,m,l,b,c,-1);
            m=g_;
            l= (b==m? c:b);
        }
    }
    if(b>=c && b>=a)
    {
        int g_;
        g = b;
        if(c!=-1)
        {
            reorder(g_,m,l,a,c,-1);
            m=g_;
            l= (a==m? c:a);
        }
    }
    if(c>=a && c>=b)
    {
        int g_;
        g = c;
        if(c!=-1)
        {
            reorder(g_,m,l,a,b,-1);
            m=g_;
            l= (a==m? b:a);
        }
    }
    
}

int main()
{
    int N,AB=0;
    cin >> N;
    
    int type1 = 0,type2 = 0,type3 = 0;
    rep(i,N)
    {
        string str;
        cin >> str;
        
        char last = str[str.length()-1];
        char begin = str[0];
        
        if(last == 'A' &&begin == 'B' )
            type3++;
        else if(last == 'A')
            type1++;
        else if(begin == 'B')
            type2++;
        
        if(str.find("AB") != string::npos)
        {
            rep(j,str.length())
            {
                if(j+1<=str.length()-1)
                {
                    if(str[j]=='A' && str[j+1] == 'B')
                    {
                        AB++;
                    }
                }
                
            }
        }
    }
    /*
    
    int g,m,l;
    
    reorder(g,m,l,type1,type2,type3);
    
    if(type3 != 0)
    {
        if (type1 != 0  && type2 != 0)
            cout <<  l*2+(m-l)*1+AB << endl;
        else if(type1 == 0 && type2 == 0)
            cout << type3-1+AB << endl;
        else
            cout << type3+AB << endl;
    }
    */
 
    
     if (type1 == 0  && type2 == 0)
     cout << max(0,type3- 1)  + AB << endl;
     else
     cout <<  type3 + min(type1,type2) + AB << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

std::vector<int64_t> solve(int64_t n) {
  int64_t sum = 0;
  std::vector<int64_t> ret;
  int i;
  for (i = 1;; ++i) {
    sum += i;
    if (sum >= n) {
      ret.reserve(i);
      break;
    }
  }
  while (n != 0) {
    if (n < i) {
      i = n;
      continue;
    }
    ret.push_back(i);
    n -= i;
    i--;
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  auto const res = solve(n);
  for (auto it = res.rbegin(); it != res.rend(); ++it) {
    std::cout << (*it) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        long k = Math.min(scan.nextLong(), s.length());
        for(int i = 0; i < k; i++){
            if(s.charAt(i) != '1'){
                System.out.println(s.charAt(i));
                return;
            }
        }
        System.out.println(1);
        scan.close();
    }
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int main()
{   
	
	 ld i,x,y,n,d;
    int count=0;
    cin>>n>>d;

    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        ld ans=sqrt((x*x)+(y*y));
        if(ans<=d)
            count++;
    }
    cout<<count;

	return 0;


}		

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int n;
	cin >> n;
	vector<int> ans(n,0);
	rep(i,n-1){
		int k;
		cin >> k;
		k--;
		ans[k] ++;
	}
	rep(i,n){
		cout << ans.at(i) << endl;
	}
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MX=200000+5;
const int inf=1e9;
typedef long long ll;


int T[4*MX], a[MX], b[MX], ans[MX];

void up(int p, int l, int h, int x, int vl)
{
    if(l==h)
    {
        T[p]=vl; return;
    }
    int m=(l+h)/2;
    if(x<=m) up(2*p, l, m, x, vl);
    else     up(2*p+1, m+1, h, x, vl);
    T[p]=min(T[2*p], T[2*p+1]);
}
int Q(int p, int l, int h, int x, int y)
{
    if(l>y || h<x)   return inf;
    if(l>=x && h<=y) return T[p];

    int m=(l+h)/2;

    return min(Q(2*p, l, m, x, y), Q(2*p+1, m+1, h, x, y));
}
int main()
{
    FasterIO;
    int n, k, m;
    string s;
    cin>>n>>m>>s; s="#"+s;
    n++;
    for(int i=n-1; i>=1; i--)
    {
        int x=i+1, y=min(n, i+m);
        int r=Q(1, 1, n, x, y);
        if(r==inf)
        {
            cout<<-1<<endl;
            return 0;
        }
        if(s[i]=='1') up(1, 1, n, i, inf), a[i]=inf;
        else          up(1, 1, n, i, 1+r), a[i]=1+r;
    }
    int x=a[1], id=1;
    for(int i=1; i<=n; i++)
    {
        if(a[i]==inf) continue;
        if(a[i]==x)
        {
            b[i]=id;
        }
        else
        {
            x=a[i];
            b[i]=id=i;
        }
    }
    x=a[1], id=1;
    for(int i=1; i<=n; i++)
    {
        if(a[i]==inf) continue;
        if(a[i]!=x)
        {
            cout<<i-id<<' ';
            id=i;
            x=a[i];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    K = 25 - N;
    cout<<"Christmas";
    rep(i,K) cout<<" Eve";
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, k;
    cin >>a >> b >> k;
    int cnt = 0;
    for(int i = min(a,b); i >= 1; i--){
        if(a%i == 0 && b%i == 0){
            cnt++;
            if(cnt == k){ cout << i;
            break;
        }
        }
    }
}

Measured memory_bytes: 256
import heapq
from collections import namedtuple

Data = namedtuple("Data", "time number")

all_player = []

for _ in range(3):
    player = [input().split(" ") for lp in range(8)]
    player = [Data(float(time), number) for number, time in player]

    heapq.heapify(player)
    data = heapq.heappop(player)
    print(data.number, data.time)
    data = heapq.heappop(player)
    print(data.number, data.time)

    all_player.extend(player)

heapq.heapify(all_player)
data = heapq.heappop(all_player)
print(data.number, data.time)
data = heapq.heappop(all_player)
print(data.number, data.time)



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

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var divs = new long[N + 1];
        for (int i = 1; i <= N; i++)
        {
            for (int j = i; j <= N; j+=i)
            {
                divs[j]++;
            }
        }

        long ans = 0;
        for (long i = 1; i <= N; i++)
        {
            ans += i * divs[i];
        }
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 105804
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, d, x, ai;
    cin >> n >> d >> x;
    
    for (int i = 0; i < n; ++i) {
        cin >> ai;
        x += (d + ai - 1) / ai;
    }
    
    cout << x << "\n";
    
    return 0;
}

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

using namespace std;
typedef long long LL;
char s[100005];

int main() {
    LL cnt1 = 0, cnt2 = 0;
    scanf("%s", s);
    LL len = strlen(s);
    for (LL i = 0; i < len; i++) {
        if (s[i] == '0')
            cnt1++;
        else if (s[i] == '1')
            cnt2++;
    }
    LL minn = 0;
    if (cnt1 >= cnt2)
        minn = cnt2;
    else
        minn = cnt1;
    printf("%lld\n", 2 * minn);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
 int N , M , C;
 cin >> N >> M >> C;
  
 vector<int> B(M);
 for(int i=0; i<M; i++)
   cin >> B.at(i);
  
 vector<vector<int>> A(N, vector<int>(M));
  for (int i=0; i<N; i++){
   for (int j=0; j<M; j++)
     cin >> A.at(i).at(j);
  }
 
  int ans =0;
  for (int i=0; i<N; i++){
    int count = 0;
    for (int j=0; j<M; j++){
     count += A.at(i).at(j) * B.at(j);
    }
    if (count + C > 0){
     ans++; 
    }
    count =0;  
  }
  
  cout << ans << endl;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, m;
    double sum= 0;
    cin>> n >> m;

    int a[n];

    for(int i=0; i<n; i++)
    {
        cin>> a[i];
        sum+= a[i];
    }

    sort(a, a+n, greater<int>());

    cout <<(a[m-1] <  ( sum/(4.0*m)) ? "No\n" :"Yes\n");


            return 0;
}




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


int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = 0;
    rep(i, N){
        if (i == 0){
            ans++;
        }
        else if (i > 0 && d[i] > d[i - 1]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
int main()
{
	int D;
    scanf("%d",&D);
    int C[26];
    for(int a = 0; a < 26; a++)
    {
        scanf("%d",&(C[a]));
    }
    int SCORE[365][26];
    for(int a = 0; a < 365; a++)
    {
        for(int b = 0; b <26; b++)
        {
        	scanf("%d",&(SCORE[a][b]));
        }
    }
    int HUMANABC[26] = {0};
    int KEKKA[365] = {0};
    for(int a = 0; a < 365; a++)
    {
    	for(int b = 0; b <26; b++)
        {
        	HUMANABC[b] += C[b];
        }
        int GOUKEI[26] = {0};
        for(int c = 0; c <26; c++)
        {
            GOUKEI[c] = SCORE[a][c] + HUMANABC[c];
        }
        for(int c = 0; c < 26; c++)
        {
            int n = 0;
            if(n < GOUKEI[c])
            {
                n = GOUKEI[c];
                KEKKA[a] = c;
            }
        }
        HUMANABC[KEKKA[a]] = 0;
    }
	for(int a = 0; a < 365; a++)
    {
    	printf("%d\n",KEKKA[a]);
    }
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main() 
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll N;
    cin>>N;
    ll x=N/500;
    ll ans=x*1000;
    N=N%500;
    if(N>=5)
    ans+=N-N%5;
    cout<<ans;
}


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

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

const int N = 3e5 + 5, md = 1e9 + 7;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}


inline int mul(int x, int y) { return 1ll * x * y % md; }

ll a[N];
int n, ans;

int main() {
   
  
  cin>>n;
for(register int i = 1; i <= n; i++)
	cin>>a[i];

 
 for(register int j = 0; j < 60; j++) {
	 int cnt = 0;
        for(register int i = 1; i <= n; i++)
		cnt += ((a[i]>>j)&1);
	ans = add (ans , mul((1LL << j) %md , mul(cnt,n-cnt)));
}

cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
 
#define pb 					push_back
 
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
 
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}
 
 
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}

int main() {

	long long n, a, b;
	cin >> n >>a >> b;
	long long ans= a*((n)/(a + b));
	ans+=min(a, n%(a +b));
	cout << ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+50;
int n;
int a , b, c, d;
string s;
int cnt;
int main(){
	cin >> n;
	cin >> a >> b >> c >> d;
	cin >> s;
	s = ' ' + s;
	if(c<d){
		cnt=0;
		for(int i=a;i<=d;i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cnt++;
				break;
			}
		}
		if(cnt>0) cout<<"No";
		else cout<<"Yes";
	}
	else{
		cnt = 0;
		for(int i=a;i<=c;i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cnt++;
				break;
			}
		}
		if(cnt){
			cout << "No";
		}else{
			cnt = 0;
			for(int i=b-1;i<=d-1;i++){
				if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]=='.'){
					cnt++;
					break;
				}
			}
			if(cnt) cout << "Yes";
			else cout << "No";
		}
	}
}

Measured memory_bytes: 772
a = list(input())

if a[0] == a[1] and a[1] == a[2] :
    if a[0] == "R" :
        print("3")
    elif a[0] == "S":
        print("0")
elif a[0] == a[1] or a[1] == a[2] :
    if a[1] == "R" :
        print("2")
    else :
        print("1")
else :
    print("1")


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    double r0, w0, c, r;
    while(cin>>r0>>w0>>c>>r, r0) {
        int ans = 0;
        while(true) {
            if(r0/w0 >= c) break;
            r0 += r;
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
# coding: utf-8
# Your code here!
N=int(input())
List=list(map(int, input().split()))
MinList=[]
ansList=[]

zahyou=1
while zahyou<=100:
    MinList=[]
    hito=0
    while hito<N:
        #print((List[hito-1]-zahyou)**2)
        MinList.append((List[hito]-zahyou)**2)
        hito+=1
    ansList.append(sum(MinList))
    #print(sum(MinList))
    zahyou+=1
#print(ansList)
print(min(ansList))

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

int main() {
    iostream::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    set<char> cnt;
    for (int i = 0; i < s.size(); i++) cnt.insert(s[i]);
    if (cnt.find('N') == cnt.end() && cnt.find('S') != cnt.end()) {
        cout << "No" << '\n';
        return 0;
    } else if (cnt.find('N') != cnt.end() && cnt.find('S') == cnt.end()) {
        cout << "No" << '\n';
        return 0;
    } else if (cnt.find('W') == cnt.end() && cnt.find('E') != cnt.end()) {
        cout << "No" << '\n';
        return 0;
    } else if (cnt.find('W') != cnt.end() && cnt.find('E') == cnt.end()) {
        cout << "No" << '\n';
        return 0;
    }
    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
eval'N,K,*A='+`dd`.split*?,
d=(0..255).map{[0]*-~N}
d[0][0]=1
A.map{|a|N.times{|j|256.times{d[_1^a][N-j]+=d[_1][N+~j].*N-j}}}
p d[K].sum.%10**9+7

Measured memory_bytes: 21336
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

struct NODE {
	int q; int e;
} dui[100005];

int n, w;
int zuo, you;
char a[55][55];
int sum[55][55];
int vis[55][55];

bool bfs(int x, int y)
{
	vis[x][y] = 1;
	while(zuo <= you)
	{
		if(dui[zuo].q == n && dui[zuo].e == w) break;
		for(int i = -1; i <= 1; i++)
			for(int j = -1; j <= 1; j++)
			{
				if(i * j == 0 && vis[dui[zuo].q + i][dui[zuo].e + j] == 0 && a[dui[zuo].q + i][dui[zuo].e + j] == '.') {
					dui[++you].q = dui[zuo].q + i, dui[you].e = dui[zuo].e + j;
					sum[dui[zuo].q + i][dui[zuo].e + j] = sum[dui[zuo].q][dui[zuo].e] + 1;
					vis[dui[zuo].q + i][dui[zuo].e + j] = 1;
				}
			}
		zuo++;
	}
}

int main()
{
	zuo = you = 1;
	for(int i = 1; i <= 50; i++)
		for(int j = 1; j <= 50; j++) sum[i][j] = -111;
	scanf("%d %d", &n, &w);
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= w; j++) 
		{
			scanf(" %c", &a[i][j]);
			if(a[i][j] == '#') ans++;
		}
	}
	dui[1].q = dui[1].e = 1;
	sum[1][1] = 1;
	bfs(1, 1);
	if(sum[n][w] < 0) printf("-1\n");
	else printf("%d\n", n * w - ans - sum[n][w]);
}

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

 
 
int main(){
    int N;
    int l[100100];
    int r[100100]; 
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> l[i] >> r[i];
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans = ans + (r[i] - l[i] + 1);
    }
    cout << ans << endl;
}
 



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int last_index = S.length() - 1;
    for (int i = 0; i < S.length() / 2; i++) {
        if (S[i] != S[last_index - i]) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
	
	int n,m;
	cin >> n >> m;
	vector< vector<int> > a ( n, vector<int>(m) );  //????????????????????????????????????????????°????????????
	vector<int> b(m), c(n);


	for(int i = 0; i < a.size(); i++){
		for(int j = 0; j < b.size(); j++){
			cin >> a[i][j];
		}
	}

	for(int j = 0; j < b.size(); j++){
		cin >> b[j];
	}

	for(int i = 0; i < a.size(); i++){
		c[i] = 0;
		for(int j = 0; j < b.size(); j++){
			c[i] += a[i][j] * b[j];
		}
	}

	for(int i = 0; i < a.size(); i++){
		cout << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,flg=0,len;
	char s[101];
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len;i++){
		if(i%2==0&&s[i]=='L'){
			flg=1;
			break;
		}
		if(i%2!=0&&s[i]=='R'){
			flg=1;
			break;
		}
	}
	if(flg==1){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  vector<char> a(n);
  for(int i = 0; i < n; i++){
    a[i] = s[i];
  }
  
  a.erase(unique(a.begin(), a.end()), a.end());
  cout << a.size() << endl;
  
  return 0;
}

Measured memory_bytes: 512
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

can_make = [False] * 2001
for bit in range(2 ** n):
    total = 0
    for i in range(n):
        if bit & 1 << i > 0:
            total += A[i]
    if total <= 2000:
        can_make[total] = True

for m in M:
    if can_make[m]:
        print("yes")
    else:
        print("no")





Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin>>N;
  long long size=N.size();
  long long count=0;
  for(long long i=0;i<size;i++){
    count+=(N.at(i)-48);
  }
  if(N =="0"){
    cout<<"Yes";
  }
  else if(count%9==0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}
    
    


Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
typedef std::vector<int> TList;

TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int Count(const TList& S, const TList& T)
{
    int Sum = 0;
    for(TList::const_iterator It = T.begin(); It != T.end(); ++It){
        Sum += std::binary_search(S.begin(), S.end(), *It) ? 1 : 0;
    }
    return Sum;
}
int main()
{
    TList S = Input();
    TList T = Input();
    std::cout << Count(S, T) << std::endl;
}

Measured memory_bytes: 1564
#include <stdio.h>
 
class Dice4{
public:
    int number[6];
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
};
 
int main(){
    int n,k,j;
    scanf("%d",&n);
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
                &array[i].number[3],&array[i].number[4],&array[i].number[5]);
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 2624
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS
const int INF=2001001001;
int N,M = 0;
int a[1005];
int d[1005];
int c[1005]={};
int dp[1005][1005];
//     place/day
int main() {
	cin >> N >> M;
	for(int i=1;i<=N;i++){
        cin>>d[i];
    }
    for(int i=1;i<=M;i++){
        cin>>c[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            dp[i][j]=INF;
            if(i==0){
                dp[0][j]=0;
            }
        }
    }
    
    for(int j=1;j<=M;j++){//day
        for(int i=1;i<=N;i++){//place
            dp[i][j]=min(dp[i][j-1],dp[i-1][j-1]+c[j]*d[i]);
        }
    }
    int ans=INF;
    for(int j=1;j<=M;j++){//day
        ans=min(dp[N][j],ans);
    }
    cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 6292
s=input()
p=input()
s_len=len(s)
p_len=len(p)
s_list=list(s)
p_list=list(p)
i=0;j=0;ans='No'
while i<=s_len:
    for j in range(p_len):
        if s_list[(i+j)%s_len]!=p_list[j]:
            break
    else:
        ans='Yes'
        break
    i+=1
print(ans)


Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
int n;
char str[333333];

int main(void) {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  int W = 0;
  long long ans = 0;
  for (int i = n; i >= 1; i --) {
    if (str[i] == 'W') {
      ++ W; 
    } else {
      ans += W;
    }
  }
  cout << ans << "\n";    
}


Measured memory_bytes: 384
x, k, d = gets.split(" ").map &:to_i
if (k*d) <= x.abs
  puts x.abs - k*d
  exit
end
l = x.abs/d
if (k - l)%2 == 1
  puts (x.abs - l*d -d).abs
else
  puts x.abs - l*d
end

Measured memory_bytes: 14352
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    int N;
    cin >> N;
    ll ans = 0;
    for (int i=1; i<=N; i++) {
        ans += N/i;
        if (N%i == 0) ans--;  // C=0はダメなので、それを除く
    }
    cout << ans << endl;
}


int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,k,ii,jj;
ll n,m,x;
ll memo,big=0;
bool kakutei[100005];
ll yama[100005],b[100005];


int main(){
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        if(x>big){
            yama[i]=x;
            kakutei[i]=true;
            big=x;
            
        }else{
            yama[i]=big;
            
        }
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    big=0;
    for(i=n-1;i>=0;i--){
        if(kakutei[i] && yama[i]>b[i]){
            p(0);
            return 0;
        }
        if(b[i]>big){
            
            yama[i]=b[i];
            kakutei[i]=true;
            big=b[i];
        }else{
            yama[i]=min(yama[i],b[i]);
        }
    }
    ll ans=1;
    for(i=0;i<n;i++){
        if(kakutei[i])continue;
        if(!kakutei[i]){
            ans *= yama[i];
            ans %= mod;
        }
    }
    p(ans);
    return 0;
}


Measured memory_bytes: 6656
//
//  main.cpp
//  C - Maximal Value
//
//  Created by Hashizo on 2019/09/07.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll total = 0;
	ll n;
	cin >> n;

	vector<ll> b(n-1);
	REP(i, n-1) {
		cin >> b[i];
	}

	total = b[0] + b[n-2];
	FOR(i, 0, n-2) {
		total += min(b[i], b[i+1]);
	}
	
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
int main(){
    string a;
    cin>>a;
    for(int i=0;i<a.length();i++){
        if(a[i]=='C'){
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
from itertools import accumulate
N, M, K = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

accA = list(accumulate(As)) + [0]
accB = list(accumulate(Bs))

ans = 0
for numA in range(N+1):
    t = accA[numA-1]
    if t > K:
        break
    numB = bisect_right(accB, K-t)
    tmp = numA + numB
    ans = ans if ans > tmp else tmp
print(ans)


Measured memory_bytes: 48976
N[7];//p`N ([0]=S,[1`5]=p`N,[6]=G)
X[7][1024],Y[7][1024];//p`NÌÀW
M[7][1024];//Å¬Ú®
#define INF 1e9
C(p,q){
	int i,j,t,d,np;
	for(j=0;j<N[q];j++){
		d=INF;
		for(i=0;i<N[p];i++){
			t=M[p][i]+abs(X[p][i]-X[q][j])+abs(Y[p][i]-Y[q][j]);
			if(t<d)
				d=t;
		}
		M[q][j]=d;
	}
}
main(){
	int test;
	int x,y,c,i,b,d,a,a0,ae;
	char l[1001];
	for(;scanf("%*d%d",&y)*y;){
		a=0;
		memset(N,0,sizeof(N));
		for(;y--;){
			scanf("%s",l);
			for(x=0;c=l[x];x++){
				if(c>='1'){
					if(c<='5')
						i=c-'0';
					else if(c=='S')
						i=0;
					else if(c=='G')
						i=6;
					X[i][N[i]]=x;
					Y[i][N[i]]=y;
					a+=!N[i]++;
				}
			}
		}
		if(a==7)
			a0=1,ae=6;
		else if(a==6){
			for(i=1;i<=5;i++)
				if(!N[i])
					a0=i,ae=i+1;
		}else 
			a0=ae=0;
//for(test=0;test<10;test++){//###test
		d=INF;
		for(a=a0;a<ae;a++){
			M[0][0]=0;
			C(0,1+a%5);
			for(i=0;i<3;i++)
				C(1+(a+i)%5,1+(a+i+1)%5);
			C(1+(a+3)%5,6);
			if(M[6][0]<d){
				d=M[6][0];
				b=a;
			}
		}
//}//###test
		printf(d!=INF?"%d %d\n":"NA\n",b,d);
	}
	{int n;for(n=1e6;n--;)getchar();}exit(0);//delay(0.52s)
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

void solve() {
  int n; scanf("%d", &n);
  puts(n>=30?"Yes":"No");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3676
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

ll dp[3010][3010] = { 0 };
ll state[3010][3010];

int main(void) {
	string s, t, ans = "";
	cin >> s >> t;
	for (int i = 1;i <= s.length();i++) {
		for (int j = 1;j <= t.length();j++) {
			if (s[i - 1] != t[j - 1]) {
				if (dp[i - 1][j] > dp[i][j - 1]) {
					dp[i][j] = dp[i - 1][j];
					state[i][j] = 1;
				}
				else {
					dp[i][j] = dp[i][j - 1];
					state[i][j] = 2;
				}
			}
			else {
				if (dp[i - 1][j - 1]+1 > dp[i][j - 1]) {
					if (dp[i - 1][j - 1]+1 > dp[i - 1][j]) {
						dp[i][j] = dp[i - 1][j - 1] + 1;
						state[i][j] = 3;
					}
					else {
						dp[i][j] = dp[i - 1][j];
						state[i][j] = 1;
					}
				}
				else {
					if (dp[i - 1][j] > dp[i][j - 1]) {
						dp[i][j] = dp[i - 1][j];
						state[i][j] = 1;
					}
					else {
						dp[i][j] = dp[i][j - 1];
						state[i][j] = 2;
					}
				}
			}
		}
	}
	//cout << dp[s.length()][t.length()] << endl;
	ll x = s.length(), y = t.length();
	while (x >= 1 && y >= 1) {
		if (state[x][y] == 1) x--;
		else {
			if (state[x][y] == 2)y--;
			else {
				ans += s[x - 1];
				x--;
				y--;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

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


int main(){
  int N,K; cin>>N>>K;
  vector<ll> V;
  int ind=-1,flag=1;
  rep(i,N){
    ll x; cin>>x;
    if(x==0&&flag){
      K--;
      flag=0;
      ind=i;
    }else if(x>0&&flag){
      flag=0;
      ind=i;
      V.push_back(0);
    }
    V.push_back(x);
  }
  if(flag){
    V.push_back(0);
    ind=N;
  }

  ll ans=1e18;
  for(int i=0;i<=K;i++){
    int j=K-i;
    if(ind-j<0||ind+i>=V.size()) continue;
    ll tmp=abs(V[ind-j])+abs(V[ind+i]);
    if(ind-j!=ind&&ind+i!=ind) tmp+=min(abs(V[ind-j]),abs(V[ind+i]));
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = n;
    REP(i,n - 1){
        if(s[i] != s[i + 1]){
            ans = min(ans, max(i + 1, n - (i + 1)));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512