akhauriyash/Code-Regression huggingface dataset:
n = int(input())

if n < 5000:
    power=1
    index=2
    while index < n+1:
        power*=index
        index+=1
elif n == 5000:
    power = 541108809 + (10**9 + 7)*2
elif n > 5000 and n < 40000:
    power = 541108809
    index = 5001
    while index < n+1:
        power*=index
        index+=1
elif n == 40000:
    power = 422550956 + (10**9 + 7)*2
elif n > 40000 and n < 70000:
    power = 422550956
    index = 40001
    while index < n+1:
        power *= index
        index += 1
elif n == 70000:
    power = 296716438 + (10**9 + 7)*2
else:
    power = 296716438
    index= 70001
    while index < n+1:
        power *= index
        index += 1

if power > 10**9 + 7:
    print(power%(10**9 + 7))
else:
    print(power)

Measured memory_bytes: 3188
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

ll d;
vector<int> v;
ll pow10[110];
ll ans;
int difcur[110];

void DFS(int maxlen,int lvl=1,ll sumdif=0ll)
{
	if(lvl>=maxlen/2+1)
	{
		if(sumdif!=d)return;
		
		int cnt=9-abs(difcur[1]);
		
		for(int i=2;i<lvl;i++)cnt=cnt*(10-abs(difcur[i]));
		
		ans+=(maxlen%2==1 ? cnt*10ll : cnt*1ll);
		
		return;
	}
	
	if(sumdif+10ll*(pow10[maxlen-lvl]-pow10[lvl-1])<d||sumdif-10ll*(pow10[maxlen-lvl]-pow10[lvl-1])>d)return;
	
	for(int curdif=(lvl==1 ? -8 : -9);curdif<=(lvl==1 ? 8 : 9);curdif++)
	{
		difcur[lvl]=curdif;
		
		DFS(maxlen,lvl+1,sumdif+difcur[lvl]*(pow10[maxlen-lvl]-pow10[lvl-1]));
	}
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>d;
	
	if(d%9){cout<<0;return 0;}
	
	pow10[0]=1;
	for(int i=1;i<=18;i++)pow10[i]=pow10[i-1]*10;
	
	for(int i=1;i<=18;i++)DFS(i);
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3608
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 stack<int> S1;
 stack<pair<int,int> > S2;
 char ch;
 int sum=0;
 for(int i=0;cin>>ch;i++){
  if(ch=='\\')S1.push(i);
  else if(ch=='/'&&S1.size()>0){
   int j=S1.top();S1.pop();
   sum+=i-j;
   int a=i-j;
   while(S2.size()>0&&S2.top().first>j){
    a+=S2.top().second;S2.pop();
   }
   S2.push(make_pair(j,a));
  }
 }
 vector<int> ans;
 while(S2.size()>0){ans.push_back(S2.top().second);S2.pop();}
 reverse(ans.begin(),ans.end());
 cout<<sum<<endl;
 cout<<ans.size();
 for(int i=0;i<ans.size();i++){
  cout<<" "<<ans[i];
 }
 cout<<endl;
 return 0;
}


Measured memory_bytes: 3140
while True:
    (n, x) =  [int(i) for i in input().split()]
    if n == x == 0:
        break
 
    count = 0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if (a + b + c) == x:
                    count += 1
                elif (a + b + c) > x:
                    break
    print(count)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    std::vector<int> cities(N,0);
    for(int i=0;i<M*2;++i){
        int city;
        cin>>city;
        ++cities[city-1];
    }
    for(int i=0;i<N;++i)cout<<cities[i]<<endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    string s;
    cin >> s;

    cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
    return 0;
}

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


for i in range(N):
    cnt = 0
    while A[i] % 2 == 0:
        A[i] = A[i] / 2
        cnt += 1
    ans.append(cnt)
        
print(min(ans))
        

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

int main(void){
    int N;
    cin >> N;
    int alg[N];

    for(int i = 0; i < N; i++)
        cin >> alg[i];

    int count = 0;
    int check = 0;

    for(int i = 0; i < N; i++){
        if(alg[i] % 2 != 0){
            count--;
            break;
        }
    }

    while(check == 0){
    for(int i = 0; i < N; i++){
        alg[i] /= 2;
        if(alg[i] % 2 != 0)
            check++;
    }
    count++;
    }

    cout << count << endl;
    return 0;

}


Measured memory_bytes: 256
/*
.....   .   .   .   .
  .    . .   . .   . .
  .   .....   .   .....
  .  .     .  .  .     .
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
   
using namespace std;
   
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
   
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}



#define left left228
#define right right228
#define set set228

const int maxn = 228228;

int delta[maxn];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> x(n + 1), y(n + 1);
    int res = h - 1;
    map< pair<int, int>, bool> is;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        is[{x[i], y[i]}] = 1;
    }
    int d = 0;
    for (int xc = 1; xc <= h; ++xc) {
        if (is[{xc, xc - d}]) {
            ++d;
        }
        delta[xc] = d;
    }
    for (int i = 1; i <= n; ++i) {
        if (y[i] + delta[x[i]] < x[i]) {
            uin(res, x[i] - 2);
        }
    }
    ++res;
    cout << res << '\n';
    return 0;
}
  
  
  
  

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

const ll m=1000000007;




int main(){
    int d;
    cin>>d;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
    else if(d==23)cout<<"Christmas Eve Eve"<<endl;
    else if(d==24)cout<<"Christmas Eve"<<endl;
    else cout<<"Christmas"<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] al = new int[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextInt()-1;
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(al[al[i]] == i) ans++;
        }
        System.out.println(ans/2);
    }
}


Measured memory_bytes: 50212
#include <iostream>

using namespace std;

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

int main()
{
  int N;
   cin >> N;
    int sum = 0;

for (int i = 0; i < N; i++)
{
    for (int j = 0; j < N; j++)
    {
        for (int k = 0; k < N; k++)
        {
           sum += gcd(gcd(i+1,j+1),k+1);
        }
        
    }
    
    
}
cout << sum << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  rep(i,0,h){
      rep(j,0,w){
          cin >> c[i][j];
      }
  }
  rep(i,0,h){
      rep(j,0,w){
           cout << c[i][j]; 
      }
      cout << endl;
      rep(j,0,w){
           cout << c[i][j]; 
      }
      cout << endl;
  }
}

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

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

int w, h;
int C[100][100];
bool R[100][100];

void dfs_visit(int h, int w, int y, int x){
    if(y < 0 || h <= y || x < 0 || w <= x || C[y][x] == 0){
        return;
    }
    
    if(R[y][x]){
        return;
    }
    
    R[y][x] = true;
    
    dfs_visit(h, w, y-1, x-1);
    dfs_visit(h, w, y-1, x);
    dfs_visit(h, w, y-1, x+1);
    dfs_visit(h, w, y, x-1);
    dfs_visit(h, w, y, x+1);
    dfs_visit(h, w, y+1, x-1);
    dfs_visit(h, w, y+1, x);
    dfs_visit(h, w, y+1, x+1);
}

int dfs(int h, int w){
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == 1 && !R[i][j]){
                cnt++;
                dfs_visit(h, w, i, j);
            }
        }
    }
    
    return cnt;
}


int main(void){

    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) break;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                C[i][j] = 0;
                R[i][j] = false;
                cin >> C[i][j];
            }
        }
        
        cout << dfs(h, w) << endl;
    }
    
    return 0;

    
}




Measured memory_bytes: 3312
input = gets.split("\s").map(&:to_i)
x_min = 0
x_max = input[0]
y_min = 0
y_max = input[1]
n = input[2]

n.times do
  input = gets.split("\s").map(&:to_i)
  if input[-1] == 1
    x_min = input[0] if input[0] > x_min
  elsif input[-1] == 2
    x_max = input[0] if input[0] < x_max
  elsif input[-1] == 3
    y_min = input[1] if input[1] > y_min
  else
    y_max = input[1] if input[1] < y_max
  end
end

w = x_max - x_min
h = y_max - y_min
w = 0 if w < 0
h = 0 if h < 0
puts w * h

Measured memory_bytes: 1788
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
ll enter[200000];
int main()
{
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	ll n;
	cin>>n;
	ll temp;
	for(ll i=1;i<=n;i++)
	{
		cin>>temp;
		enter[temp]=i;
	}
	for(ll i=1;i<n;i++)
		cout<<enter[i]<<' ';
	cout<<enter[n]<<endl;
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);    //整数の入力
      int N = sc.nextInt();
      if(N <= 999){
        System.out.println("ABC");
      } else {
        System.out.println("ABD");
      }
  }
} 

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0021
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0 ; i < n ; i++)
            {
                decimal[] items = ReadDecAr();
                decimal slopeA = (items[2] - items[0]) * (items[7] - items[5]);
                decimal slopeB = (items[6] - items[4]) * (items[3] - items[1]);
                Console.WriteLine(slopeA == slopeB  ? "YES" : "NO");
            }
           
        }

        static decimal[] ReadDecAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => decimal.Parse(e)); }

    }

}



Measured memory_bytes: 15792
n, k = map(int, input().split())
x = list(map(int, input().split()))
cost = float("INF")
for i in range(n - k + 1):
    if x[i] > 0:
        cost = min(cost, x[i + k - 1])
    elif x[i + k - 1] < 0:
        cost = min(cost, abs(x[i]))
    else:
        r = x[i + k - 1]
        l = abs(x[i])
        cost = min(cost, min(r, l) * 2 + max(r, l))
print(cost)

Measured memory_bytes: 14228
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

vector<int> ans;

int digitsum(int x){
  int res = 0;
  while(x != 0){
    res += x%10; x /= 10;
  }
  return res;
}

void check(int x){
  int y = digitsum(x);
  while(!ans.empty()){
    int p = ans.back();
    if(p*y > x*digitsum(p)) ans.pop_back();
    else break;
  }
  ans.pb(x);
}

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

  int K; cin >> K;
  for(int i = 1; i < 100; i++) check(i);
  int a = 0, b = 1;
  while(a < 1e12){
    for(int i = 100; i < 1000; i++) check(i*b+a);
    a = a*10+9;
    b *= 10;
  }
  REP(i, K) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
const int inf = 1<<30, maxn = 1<<19;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	using ll = long long;
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	for(auto &i : a) cin >> i;
	for(auto &i : b) cin >> i;
	for(int i = 1; i < n; i++) a[i] += a[i-1];
	for(int i = 1; i < m; i++) b[i] += b[i-1];
	ll ans = 0;
	for(ll t = 0, j = m, i = 0; i <= n; i++) {
		while(j > 0 && t + b[j-1] > k) j--;
		if(t <= k) ans = max(ans, i+j);
		if(i != n) t = a[i]; 
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6364
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Weather_Prediction(void) {

	string S; cin >> S;

	string weather[3] = { "Sunny","Cloudy","Rainy" };
	for (int loop = 0; loop < 3; loop++) {
		if (S == weather[loop]) {
			cout << weather[(loop + 1) % 3] << flush;
			break;
		}
	}
	return;
}

void B_Tap_Dance(void) {

	string S; cin >> S;

	for (int index = 0; index < S.size(); index++) {
		if (index % 2 == 0 && S[index] == 'L' || index % 2 == 1 && S[index] == 'R') {
			cout << "No" << flush;
			return;
		}
	}
	cout << "Yes" << flush;
	return;
}

int main(void) {

	//A_Weather_Prediction();
	B_Tap_Dance();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;


signed main(){
    int n;
    int h[105]={};
    cin >> n;
    iFOR(i,1,n+1) cin >> h[i];
    int miv = INF;
    int sum = 0;
    iFOR(i,1,n+1){
        sum+=max(h[i]-h[i-1],0);
    }
    cout << sum fin;
  return 0;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    optimize_cin();

    string SA, SB, SC;
    cin >> SA >> SB >> SC;
    reverse(ALL(SA));
    reverse(ALL(SB));
    reverse(ALL(SC));

    char turn = 'a';

    while (true)
    {
        if (turn == 'a' && SZ(SA) == 0)
        {
            cout << "A" << "\n";
            break;
        }
        else if (turn == 'b' && SZ(SB) == 0)
        {
            cout << "B" << "\n";
            break;
        }
        else if (turn == 'c' && SZ(SC) == 0)
        {
            cout << "C" << "\n";
            break;
        }

        if (turn == 'a')
        {
            turn = SA.back();
            SA.pop_back();
        }
        else if (turn == 'b')
        {
            turn = SB.back();
            SB.pop_back();
        }
        else if (turn == 'c')
        {
            turn = SC.back();
            SC.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    a.append(m)

minv=a[0]
maxv=a[1]-a[0]

for i in range(1,n):
    maxv=max(maxv,a[i]-minv)
    minv=min(minv,a[i])

print(maxv)


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

int main() {
    int n, ans = 0;
    cin >> n;
    int a[n];
    for(int i = 0 ; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            ans += a[i]*a[j];
        }
    }

    cout << ans << '\n';

    return 0;
}


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

int main() {
  long long n,m,x; cin >> n >> m >> x;
  vector<long long> c(n);
  vector<vector<long long>> a(n, vector<long long>(m));
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
    for(int j = 0; j < m; j++){
      cin >> a.at(i).at(j);
    }
  }

  long long cost = 100000000;
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<long long> out(m);
        vector<int> S;
      long long tmp = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { 
                S.push_back(i);
            }
        }
      for(int j : S){
                  tmp += c.at(j);
        for(int k = 0; k < m; k++){
          out.at(k) += a.at(j).at(k);

        }
      }
      for(int j = 0; j < m; j++){
        if(out.at(j) < x) break;
        if(j == m-1){
          if(tmp < cost) cost = tmp;
        }
      }
    }
  if(cost == 100000000){
    cout << -1;
  }else{
    cout << cost;
  }
}


Measured memory_bytes: 3628
int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);

	h = S / 3600;
	S = S - h*3600;
	m = S / 60;
	S = S - m*60;
	s = S;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2104
n, m = map(int, input().split())
al = list(list(map(int, input().split())) for _ in range(n))
al_s = sorted(al, key=lambda x: x[0])
drink = m
cost = 0
for a in al_s:
    if drink >= a[1]:
        cost += a[0] * a[1]
        drink -= a[1]
    else:
        cost += a[0] * drink
        break
print(cost)

Measured memory_bytes: 29796
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,x;
        while (true) {
            int result = 0;
            n = input.nextInt();
            x = input.nextInt();
            if (n == 0 && x == 0){
                break;
            }
            for (int i = 1; i < n+1; i++){
                for (int j = i+1; j < n+1; j++){
                    for (int k = j+1; k < n+1; k++){
                        if (i+j+k == x){
                            result += 1;
                        }
                    }
                }
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26424
H,W,K = map(int, input().split())
s = [0]*H
for i in range(0,H): s[i] = list(input())

ans = [0]*H
for i in range(0,H): ans[i] = [0]*W

cur = 0
non = 10*3
for h in range(0,H):
  if "#" in s[h]: #苺があるとき苺ごとに分ける
    cur += 1
    for w in range(0,W):
      ans[h][w] = cur
      if s[h][w] == "#":
        if "#" in s[h][w+1:]:
          cur +=1  
  else:
    if cur == 0:
      non = h #最初の苺の前の列
    else:
      for w in range(0,W):
        ans[h][w] = ans[h-1][w]

if non != 10*3:
  for h in range(0,non+1):
    for w in range(0,W):
      ans[h][w] = ans[non+1][w]

for h in range(0,H):
  res = ""
  for w in range(0,W):
    if w != 0:
      res += " "
    res += str(ans[h][w])
  print(res)

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

namespace Competitive
{
    internal class Combination
    {
        public int[] A;
        public bool[] F;
        public int N;
        public bool Flag;
        public int Target;

        public Combination(int[] a, int target)
        {
            A = a;
            N = A.Length;
            F = new bool[N];
            Flag = false;
            Target = target;
        }

        public void Judge()
        {
            int ret = 0;

            for(int i = 0; i < N; i++)
                if (F[i])
                    ret += A[i];

            if (ret == Target)
                Flag = true;
        }

        public bool Run()
        {
            Run(0);
            return Flag;
        }

        private void Run(int i)
        {
            // 特定の条件時の処理
            if (i == N)
            {
                Judge(); return;
            }

            F[i] = false;
            Run(i + 1);

            F[i] = true;
            Run(i + 1);
        }
    }

    internal class Solution
    {
        public int n, q;
        public int[] A, M;

        public void Run()
        {
            n = Input.ReadInt();
            A = Input.ReadIntArray();
            q = Input.ReadInt();
            M = Input.ReadIntArray();

            for (int i = 0; i < q; i++)
            {
                var runner = new Combination(A, M[i]);
                Console.WriteLine(runner.Run() ? "yes" : "no");
            }
        }

    }

    
    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 9344
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {

  ll a,b,x;
  cin >> a >> b >>x;
  ll b_num = 0;
  ll a_num = 0;

  b_num = b/x;
  a_num = a/x;
  if(a%x == 0){
    cout << b_num - a_num + 1 <<endl;
  }
  else{
    cout << b_num - a_num <<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for(long long i=0; i<N; i++)
        cin >> A[i];

    long long sm = 0;
    for(long long i=0; i<N; i++) sm += A[i];
    vector<long long> div = divisor(sm);
    sort(div.begin(), div.end(), greater<long long>());
    for(long long d : div){
        vector<long long> B(N);
        for(long long i=0; i<N; i++)
            B[i] = A[i] % d;
        sort(B.begin(), B.end());
        long long pls = 0;
        long long mns = 0;
        for(long long i=0; i<N; i++) pls += (d-B[i]);
        if(pls <= K && mns <= K){
            cout << d << endl;
            return 0;
        }
        for(long long i=0; i<N; i++){
            pls -= (d-B[i]);
            mns += B[i];
            if(pls <= K && mns <= K){
                cout << d << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc173
{
    class Program
    {
        static void Main(string[] args)
        {
            var hwk = Console.ReadLine().Split(' ');
            var h = int.Parse(hwk[0]);
            var w = int.Parse(hwk[1]);
            var k = int.Parse(hwk[2]);
            var ct = new char[h][];
            for (var i = 0; i < h; ++i)
            {
                ct[i] = Console.ReadLine().ToCharArray();
            }

            var selects = 0;
            for (var x = 0; x < Math.Pow(2, h); ++x)
            {
                for (var y = 0; y < Math.Pow(2, w); ++y)
                {
                    var blacks = 0;
                    for (var i = 0; i < h; ++i)
                    {
                        if ((x >> i & 1) == 1)
                        {
                            continue;
                        }
                        for (var j = 0; j < w; ++j)
                        {
                            if ((y >> j & 1) == 1)
                            {
                                continue;
                            }
                            if (ct[i][j] == '#')
                            {
                                ++blacks;
                            }
                        }
                    }
                    if (blacks == k)
                    {
                        ++selects;
                    }
                }
            }
            Console.WriteLine(selects);
        }
    }
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var lcm = 1L;
            for (var i = 0; i < N; i++)
            {
                var tmp = long.Parse(Console.ReadLine());
                lcm = Lcm(tmp, lcm);
            }
            Console.WriteLine(lcm);
        }

        static long Gcd(long a, long b)
        {
            if (b > a) return Gcd(b, a);
            if (b == 0) return a;
            return Gcd(b, (a % b));
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }
}


Measured memory_bytes: 11092
#if 0
15?????????.????????£????????????????????£???.
#endif

#include <queue>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string cmd; // while????????´????????????????????????????????°???????????¨??????
  priority_queue<int> Q;
  while (cin >> cmd && cmd != "end") {
    if (cmd == "insert") {
      int k;
      cin >> k;
      Q.push(k);
    } else if (cmd == "extract") {
      int n = Q.top();
      Q.pop();
      cout << n << endl;
    }
  }
}

Measured memory_bytes: 7104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<bool> is_prime;

int main() {
    ll N;
    cin >> N;
    ll sup = pow(10, 6);
    is_prime.assign(sup + 1, true);
    for (ll i = 2; i <= sup; i++) {
        if (is_prime[i] == true) for (ll j = i * 2; j <= sup; j += i) {
            is_prime[j] = false;
        }
    }
    int cnt = 0;
    for (ll i = 2; i <= sup; i++) {
        if (is_prime[i]) {
            ll i_temp = i;
            while (N % i_temp == 0)
            {
                cnt++;
                N /= i_temp;
                i_temp *= i;
            }
            if (N <= i) break;
        }
    }
    if (N > sup) cnt++;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL l,r;
  cin >> l >> r;
  if(l/2019 != r/2019) {
    cout << 0 << endl;
    return 0;
  }

  LL answer = 2019;
  FOR(j,l+1,r+1) FOR(i,l,j) {
    answer = min(answer, i*j%2019);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val n = readLine.toInt

  var t = 0
  var h = 0

  for (i <- 0 until n) {
    val Seq(st, sh) = readLine.split(' ').toList
    if (st > sh)
      t += 3
    else if (st < sh)
      h += 3
    else {
      t += 1
      h += 1
    }
  }

  println("%d %d".format(t, h))
}


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

int main(){
  int n;
  cin >> n;
  vector<int> list(n);
  for (int i; i<n; i++){
    cin >> list.at(i);
  }
  sort(list.begin(), list.end());
  cout << list[n-1]-list[0] << endl;
}

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

public class Solution
{
    static List<string> Patterns = new List<string>();

    static void GetPatterns(string baseStr, int len)
    {
        if (len == 0)
        {
            Patterns.Add(baseStr);
            return;
        }

        var list = baseStr.Distinct().ToList();
        if (list.Count == 0)
        {
            list.Add('a');
        }
        else
        {
            list.Add((char)(list.Max() + 1));
        }
        foreach (var c in list)
        {
            GetPatterns(baseStr + c, len - 1);
        }
    }

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        GetPatterns("", n);
        Patterns.Sort();

        Console.WriteLine(string.Join(Environment.NewLine, Patterns));
    }
}

Measured memory_bytes: 31944
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>


std::vector<int> V[100000];
int C[100000];
int color;
int maxi;

int main () {
    int n, m, q;
    std::cin >> n >> m;

    for (int i; i < m; i++) {
        int s, t;
        std::cin >> s >> t;
        V[s].push_back(t);
        V[t].push_back(s);
    }

    for (int i = 0; i < n; i++) {
        if(C[i] == 0) {
            color++;
            std::queue<int> Q;
            Q.push(i);
            while (Q.size()) {
                C[Q.front()] = color;
                for (auto t: V[Q.front()]) {
                    if (C[t] == 0) {
                        C[t] = color;
                        Q.push(t);
                    }
                }
                Q.pop();
            }
        }
    }

    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        std::cin >> s >> t;
        if ((C[s] == C[t]) && (C[s] != 0)) {
            std::cout << "yes" << std::endl;
        }
        else{
            std::cout << "no" << std::endl;
        }
    }

}


Measured memory_bytes: 8984
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 MOD = 1000000007;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 n, m;
    cin >> n >> m;
    vector<bool> b(n + 1, false);
    for (int i = 0; i < m; ++i) {
        i64 a; cin >> a;
        b[a] = true;
    }
    vector<i64> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        if(b[i]) continue;
        if(!b[i + 1]) dp[i + 1] = (dp[i] + dp[i + 1]) % MOD;
        if(i != n - 1 && !b[i + 2]) dp[i + 2] = (dp[i] + dp[i + 2]) % MOD;
    }
    cout << dp[n] << endl;
 }

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

using namespace std;

#define MAX 110
#define INF (1<<29)
typedef pair<int, int> pii;

struct Edge {
    int to, cost;
    Edge (int to, int cost) : to(to), cost(cost) {}
};

int main()
{
    int N, M, P;
    while (cin >> N >> M >> P, N) {
        int d[MAX][MAX];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
        
        vector<Edge> G[MAX];
        
        int a, b, c;
        for (int i = 0; i < M; i++) {
            cin >> a >> b >> c;
            d[a][b] = d[b][a] = c;
            G[a].push_back(Edge(b, c));
            G[b].push_back(Edge(a, c));
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

        priority_queue<pii> Q;
        Q.push(pii(d[0][N-1], N-1));
        
        vector<bool> visited(MAX, 0);
        visited[N-1] = 1;

        vector<double> cnt(MAX, 0);
        cnt[N-1] = 1;
        
        while (!Q.empty()) {
            pii p = Q.top(); Q.pop();
            int v = p.second;
            for (int i = 0; i < (int)G[v].size(); i++) {
                Edge &e = G[v][i];
                if (d[0][e.to] + e.cost == d[0][v]) {
                    cnt[e.to] += cnt[v];
                    if (!visited[e.to]) {
                        visited[e.to] = 1;
                        Q.push(pii(d[0][e.to], e.to));
                    }
                }
            }
        }

        priority_queue<pii, vector<pii>, greater<pii>> Q2;
        Q2.push(pii(0, 0));

        vector<bool> visited2(MAX, 0);
        visited2[0] = 1;

        double dp[MAX] = {};
        dp[0] = 1;
        
        while (!Q2.empty()) {
            pii p = Q2.top(); Q2.pop();
            int v = p.second;
            for (int i = 0; i < (int)G[v].size(); i++) {
                Edge &e = G[v][i];
                if (visited[e.to] && d[0][v] + e.cost == d[0][e.to]) {
                    dp[e.to] += dp[v] * cnt[e.to] / cnt[v];                    
                    if (!visited2[e.to]) {
                        visited2[e.to] = 1;
                        Q2.push(pii(d[0][e.to], e.to));
                    }
                }
            }
        }

        int child;
        for (int i = 0; i < P; i++) {
            cin >> child;
            printf("%.10f\n", dp[child]);            
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll ans = 0;
    ll temp = 1;

    rep(i, n){
        if(a[i] == temp){
            temp++;
        }
        else{
            ans++;
        }
    }

    if(temp == 1){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
    string s;
    if(getline(cin, s)){
        int i=1;
        int n = s.size();
        for(int i=0;i<n;i++){
            if(islower(s[i])){
                s[i] = toupper(s[i]);
            }
            else if(isupper(s[i])){
                s[i] = tolower(s[i]);
            }
        }    
        for(int i=0;i<n;i++){
            cout << s[i];
        }
        cout << endl;
    return 0;
    }
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>

bool check(int mid, std::vector<int> &a, int K) {
  std::vector<std::vector<bool>> dp(a.size() + 1, std::vector<bool>(K, false));
  dp[0][0] = true;
  for (int i = 1; i <= (int) a.size(); ++i) {
    if (i - 1 == mid) {
      for (int j = 0; j < K; ++j) {
        dp[i][j] = dp[i - 1][j];
      }
      continue;
    }
    for (int j = 0; j < K; ++j) {
      dp[i][j] = dp[i - 1][j] || (j >= a[i - 1] ? dp[i - 1][j - a[i - 1]] : false);
    }
  }
  for (int i = std::max(K - a[mid], 0); i < K; ++i) {
    if (dp[a.size()][i]) { return true; }
  }
  return false;
}

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int min = -1;
  int max = (int) a.size();
  while (max > min + 1) {
    auto mid = (min + max + 1) / 2;
    if (check(mid, a, K)) {
      max = mid;
    } else {
      min = mid;
    }
  }
  std::cout << max << std::endl;
  return 0;
}

Measured memory_bytes: 3576
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split('\n');
    for (var i = 0; i < inputs.length; i++){
    	if (inputs[i] === '0 0'){
    		break;
    	}
    	var input = inputs[i].split(' ')
    	.map(Number).sort(function(a,b){
    		return a - b;
    	})
    	.join(' ');
   console.log(input);
  }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    int K;
    cin >> K;
    vll A(K);

    for (int i=0;i<K;i++) cin >> A[i];

    reverse(A.begin(), A.end());

    ll low = 2;
    ll high = 2;

    for (ll a: A) {
        ll lowi = (low + a-1) / a;
        ll highi = high / a;

        if (lowi > highi) {
            cout << -1 << endl;
            return 0;
        }

        low = a*lowi;
        high = a*highi + a-1;

    }

    cout << low << " " << high << endl;
    
}


Measured memory_bytes: 1024