akhauriyash/Code-Regression huggingface dataset:
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int N = sc.nextInt();
        final int M = sc.nextInt();
        int[] lg = new int[M];
        int[] rg = new int[M];
        for (int i = 0; i < M; i++) {
            lg[i] = sc.nextInt();
            rg[i] = sc.nextInt();
        }
        
        OptionalInt lmax = Arrays.stream(lg).max();
        OptionalInt rmin = Arrays.stream(rg).min();
        long ans = IntStream.rangeClosed(1, N).filter(i -> lmax.getAsInt() <= i && rmin.getAsInt() >= i).count();
        
        out.println(ans);
        
        out.flush();
    }
}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 27988
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	double r; cin>>r;
	cout<<2*M_PI*r<<"\n";
	return 0;	
}



Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
int gcd(int a,int b){
	return b? gcd(b,a%b):a;
}
int main(){
	int n=read(); int x=read(); int ans=0;
	rep(i,1,n) {
		int u=read(); u=abs(u-x);
		if (i==1) ans=u; else ans=gcd(ans,u);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Builder as Builder
import qualified Data.Maybe as Maybe
import qualified Data.Char as Char
import qualified Data.Map.Strict as Map
import System.IO as IO
import Data.Function ((&))
import Data.Monoid ((<>))

main :: IO ()
main = do
    input <- getInput
    solve input
        & map (\n -> Builder.intDec n <> Builder.byteString "\n")
        & mconcat
        & Builder.hPutBuilder IO.stdout

getInput :: IO (Int, Int, Int)
getInput =
    let
        parser = (,,) <$> parseInt <*> parseInt <*> parseInt
    in
    runParser parser <$> B.getContents

solve :: (Int, Int, Int) -> [Int]
solve (n, x, y) =
    let
        -- 頂点 i と頂点 j の距離 (i < j)
        distance i j =
            let
                -- 辺(x, y)を経由しないときの距離
                d1 = j - i
                -- i -> x -> y -> j という経路を使うときの距離
                d2 = abs (x - i) + 1 + abs (j - y)
                -- i -> y -> x -> j という経路を使うときの距離
                d3 = abs (y - i) + 1 + abs (j - x)
            in
                d1 `min` d2 `min` d3

        allPairDistances = do
            i <- [1..n]
            j <- [(i+1)..n]
            return $ distance i j

        distanceFrequency =
            frequency allPairDistances
    in
        map (\k -> Map.findWithDefault 0 k distanceFrequency) [1..n-1]

frequency :: [Int] -> Map.Map Int Int
frequency xs =
    let
        increment = Map.alter $ \v ->
            case v of
                Nothing    -> Just 1
                Just count -> Just (count + 1)
    in
        foldr increment Map.empty xs

-------------------------------------------------------------------------------

newtype Parser a =
    Parser (B.ByteString -> (a, B.ByteString))

instance Functor Parser where
    fmap f (Parser parser) =
        Parser $ \input ->
            let (v, remainder) = parser input in
                (f v, remainder)

instance Applicative Parser where
    pure v =
        Parser $ \input ->
            (v, input)

    (Parser parser1) <*> (Parser parser2) =
        Parser $ \input ->
            let
                (f, remainder1) = parser1 input
                (v, remainder2) = parser2 remainder1
            in
                (f v, remainder2)

instance Monad Parser where
    return = pure

    (Parser parser1) >>= f =
        Parser $ \input ->
            let
                (v, remainder) = parser1 input
                Parser parser2 = f v
            in
                parser2 remainder

consumeSpace :: Parser ()
consumeSpace =
    Parser $ \input ->
        ((), B.dropWhile Char.isSpace input)

parseInt_ :: Parser Int
parseInt_ =
    Parser $ \input ->
        Maybe.fromJust (B.readInt input)

parseInt :: Parser Int
parseInt =
    consumeSpace *> parseInt_

runParser :: Parser a -> B.ByteString -> a
runParser (Parser parser) input =
    fst $ parser input

-------------------------------------------------------------------------------


Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main(){
    
        int x,n;cin>>n;
        vector <int> v;
        for (int i=0;i<n;i++){
            cin>>x; v.PB(x);
        }
        sort (v.begin(),v.end());
        int c=0;
        for (int i=0;i<n-2;i++){
            for (int j=i+1;j<n-1;j++){
                for (int k=j+1;k<n;k++){
                     if (v[i]!=v[j] && v[j]!=v[k] && v[i]+v[j]>v[k]) c++;
                }
            }
           
        }
        cout<<c<<endl;
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
using namespace std;
int h, w, maxid, n, b; double maxn = 1000000000.00;
int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		maxn = 1000000000.00;
		for (int i = 0; i < n; i++){
			cin >> b >> h >> w;
			if (maxn >= abs(10000.00*w / (h*h) - 22.00)) {
				maxn = abs(10000.00*w / (h*h) - 22.00);
				maxid = b;
			}
		}
		cout << maxid << endl;
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	VI a(5);
	ll n;
	cin >>n;
	rep(i,5) cin >> a[i];
	
	VI cur(6), rcd(101);
	cur[0] = n;
	rep(i, 100){
		repr(j, 4, 0){
			ll h= min(a[j], cur[j]);
			cur[j] -=h; cur[j+1] +=h;
		}
		if(cur[5]==n){
			cout << i+1 <<"\n"; return 0;
		}
		rcd[i]=cur[5];
	}

	ll df = rcd[99] - rcd[98];
	ll zn = (n - rcd[99] + df -1) / df;
	cout << 100 + zn <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<double, ll> P;
struct edge { ll to; double cost; };
vector<edge> G[100010];
ll n;
const ll INF = 100000000000000000;
double sx, sy, tx, ty, x[1010], y[1010], r[1010], d[1010];

void dijkstra(ll s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + n + 2, INF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (ll i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(void){
    // Your code here!
    cin >> sx >> sy >> tx >> ty >> n;
    for (ll i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> r[i];
    }
    for (ll i = 1; i <= n; i++){
        for (ll j = i + 1; j <= n; j++){
            double len = max(sqrt(pow((x[i] - x[j]), 2) + pow((y[i] - y[j]), 2)) - r[i] - r[j], (double)0);
            G[i].push_back(edge{j, len});
            G[j].push_back(edge{i, len});
        }
    }
    for (ll i = 1; i <= n; i++){
        double len = max(sqrt(pow((x[i] - sx), 2) + pow((y[i] - sy), 2)) - r[i], (double)0);
        G[0].push_back(edge{i, len});
        len = max(sqrt(pow((x[i] - tx), 2) + pow((y[i] - ty), 2)) - r[i], (double)0);
        G[i].push_back(edge{n + 1, len});
    }
    dijkstra(0);
    double ans = min(d[n + 1], sqrt(pow(sx - tx, 2) + pow(sy - ty, 2)));
    printf("%.10lf\n", ans);
}


Measured memory_bytes: 24964
#include <stdio.h>

#define N 1000000

int insertionSort(int *,int,int);
void shellSort(int *,int);

int main(){

  int g=1;
  int i;
  int j;
  int n;
  int data[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  shellSort(data,n);
  
  return 0;
}

int insertionSort(int *A, int n, int g){

  int i;
  int j;
  int v;
  int cnt=0;

  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
  while( j >= 0 && A[j] > v){
   A[j+g] = A[j];
   j = j - g;
   cnt++;
   }
   A[j+g] = v;
  }
  return cnt;
}

void shellSort(int *A, int n){

  int  i;
  int  m=5;
  int  cnt=0;
  int  m_cnt=0;
  int  G[5]={1000,100,10,4,1};
  
  for(i=0;i<m;i++){
  if(G[i]<=n){
  cnt += insertionSort(A, n, G[i]);
  m_cnt++;
   }
  }

  printf("%d\n",m_cnt);
    
  for(i=0;i<m-1;i++){
  if(G[i]<=n){
  printf("%d ",G[i]);
   }
  }
  
  printf("%d\n",G[i]);
  printf("%d\n",cnt);
  for(i=0;i<n;i++){
  printf("%d\n",A[i]);
  }
}

Measured memory_bytes: 4508
import math

N = int(input())
ans = 0

def solve(x):
    if x==2:
        return 1
    elif x%2==0:
        return 0
    else:
        for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
            if x%i ==0:
                return 0
        return 1
for i in range(N):
    if solve(int(input())) ==1:
        ans +=1
print(ans)

Measured memory_bytes: 7824
import java.util.*;
// import java.io.*;
class Main{
  public static void main(String args[])throws Exception{
    // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int count = 0;
    int number = 0;
    // int n = Integer.parseInt(br.readLine());
    int n = sc.nextInt();
    // String [] S = br.readLine().split("\\s+");
    long [] array_s = new long[n];
    for(int i =0; i<n; i++){
      array_s[i] = sc.nextLong();
    }

    // int q = Integer.parseInt(br.readLine());
    int q = sc.nextInt();
    // String [] T = br.readLine().split("\\s+");
    long [] array_t = new long[n];
    long t;
    for(int i = 0; i<q; i++){
      t = sc.nextLong();
      for(int j = 0; j<n; j++){
        if(t == array_s[j]){
          count++;
          break;
        }
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 39464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int x=s.size()-t.size(),y=t.size(),maximum=0;
  for(int i=0;i<=x;i++){
    int count=0;
    for(int j=0;j<y;j++){
      if(s.at(i+j)==t.at(j)){
        count++;
      }
      maximum=max(count,maximum);
    }
  }
  int z=t.size()-maximum;
  cout<<z<<endl;
}
      
      

Measured memory_bytes: 3636
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize,
    }
    println!("{}", N * 800 - (N / 15) * 200);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b;
    cin>>a>>b;
    string ans="";
    if(a>=b){
        for(ll i=0; i<a; i++) {
            ans += to_string(b); 
        }
        
    }else{
        for(ll i=0; i<b; i++) {
            ans += to_string(a); 
        }
        
    }
    cout<<ans<<endl;

    return  0;
}


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

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

    long N;
    long answer = 0;
    cin >> N;

    for (long i = 1; i * i < N; i++)
    {
        if (N % i == 0 && i < N / i - 1)
        {
            answer += (N / i - 1);
        }
    }

    cout << answer << '\n';

    return 0;
}


Measured memory_bytes: 256
import math
import heapq
import sys
from collections import Counter

#N,K=map(int, input[].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

A,B,C=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

if A+B<C:
    print(B+(A+B+1))
else:
    print(B+C)

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

int main(){
    int a;
    cin >> a;
    
    cout << a + (a * a) + (a * a * a) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
int n,a,b;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>a>>b;
	int ans=min(a*n,b);
	cout<<ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  set<int> S;
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (S.count(A)) S.erase(A);
    else S.insert(A);
  }
  
  cout << S.size() << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

ll n,m,q;
vl a,b,c,d;

ll f(vl A,ll now){
    if(now == n){
        ll score = 0;
        rep(i,q){
            if(A[b[i]]-A[a[i]] == c[i]) score += d[i];
        }
        return score;
    }
    ll ret = 0;
    for(ll i = A[now-1];i<=m;i++) {
        A[now] = i;
        ret = max(ret,f(A,now+1));
    }
    return ret;
}

int main(void) {
    cin>>n>>m>>q;
    a = vl(q);
    b = vl(q);
    c = vl(q);
    d = vl(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    ll ans = f(vl(n,1),1);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.nextLine().reverse
    val ans = if (f(s)) "YES" else "NO"
    println(ans)
  }

  def f(s: String): Boolean = {
    if (s == "") true else {
      s match {
        case x if s.take(5) == "maerd" => f(s.drop(5))
        case x if s.take(7) == "remaerd" => f(s.drop(7))
        case x if s.take(5) == "esare" => f(s.drop(5))
        case x if s.take(6) == "resare" => f(s.drop(6))
        case _ => false
      }
    }
  }
}


Measured memory_bytes: 114044
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    
    scanf("%d %d\n", &h, &w);
    
    while((h!=0) && (w!=0)){
        for (j=0;j<h;j++){
            for(i=0;i<w;i++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d\n", &h, &w);        
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int left = 0, right = 0, tmp;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp;
        if (tmp < x)
        {
            left++;
        }
        else
        {
            right++;
        }
    }
    cout << min(right, left) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n;cin>>n;
    int d,x;cin>>d>>x;
    vector<int> A(n);cin>>A;
    int count=0;
    rep(i,n){
        int v = 0;
        while(1 + v*A[i]<=d) {count++;v++;}
    }
    cout<<x+count<<endl;
    return 0;
}







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

using namespace std;

class Solver {
public:
	static void solve() {
		string s;
		cin >> s;

		int len = 0;
		bool in = false;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == ')')in = false;
			if (in)len++;
			if (s[i] == '(')in = true;
		}

		if (len == 0) {
			int child = 0;
			int parent = 1;
			bool inDot = false;
			for (int i = 0; i < s.size(); i++) {
				if (s[i] == '.') {
					inDot = true;
					continue;
				}

				child *= 10;
				child += s[i] - '0';

				if (inDot)parent *= 10;
			}
			int gcd = GCD(child, parent);
			cout << child / gcd << '/' << parent / gcd << endl;
		}
		else {
			bool inDot = false;
			int dotCnt = 0;
			int child = 0;
			for (int i = 0; i < s.size() - len - 2; i++) {
				if (s[i] == '.') {
					inDot++;
					continue;
				}

				child *= 10;
				child -= s[i] - '0';
				if (inDot)dotCnt++;
			}
			child += -child * pow(10, len);
			child += stoi(s.substr(s.size() - len - 1, len));
			int parent = (pow(10, len) - 1) * pow(10, dotCnt);
			int gcd = GCD(child, parent);
			cout << child / gcd << '/' << parent / gcd << endl;
		}
	}

	static int GCD(int x, int y) {
		if (y == 0)return x;
		else return GCD(y, x % y);
	}
};

int main() {
	Solver::solve();
}


Measured memory_bytes: 3380
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool binarySearch(int temp, int arr[], int n){
    int left = 0;
    int right = n-1;
    int mid;
    while(left <= right){
        mid = (left+right)/2;
        if(temp == arr[mid]){
            return true;
        } else if(temp > arr[mid]){
            left = mid + 1;
        } else {
            right = mid-1;
        }
    }
    return false;
}

int main()
{

    int n,m;
    int count = 0;
    cin>>n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    cin>>m;
    int temp;
    for(int i = 0;i<m;i++){
        cin>>temp;
        if(binarySearch(temp, a, n)){
            count++;
        }
    }
    cout<<count<<endl;

    return 0;





}

Measured memory_bytes: 3452
import java.util.*;
import java.lang.*;
import java.io.*;
class Counter<T> extends HashMap<T,Integer>{
    public Counter(){
        super();
    }
    public Integer get(Object elm){
        return getOrDefault(elm,0);
    }
    public void add(T elm){
        put(elm, get(elm)+1);
    }
    
}
class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long W = sc.nextLong();
        int N = sc.nextInt();
        Counter<Pair<Long,Long>> count = new Counter<>();
        for(int n=0;n<N;n++){
        	long A = sc.nextLong();
        	long B = sc.nextLong();
        	for(long a=A-1;a<=A+1;a++)for(long b=B-1;b<=B+1;b++){
        	    if(a>=2 && a<=H-1 && b>=2 && b<=W-1)
        	        count.add(new Pair<Long,Long>(a,b));
        	}
        }
        long[] ans = new long[10];
        ans[0] = (H-2)*(W-2);
        for(Pair<Long,Long> p:count.keySet()){
        	ans[count.get(p)]++;
        	ans[0]--;
        }
        for(int i=0;i<10;i++) System.out.println(ans[i]);
        
    }
}


Measured memory_bytes: 195640
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,k,q;
int byk[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k>>q;
    for(int i=1;i<=q;i++){
        int x;
        cin>>x;
        byk[x]++;
    }
    for(int i=1;i<=n;i++){
        if(k-(q-byk[i])<=0) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let s: String = iter.next().unwrap().parse().unwrap();

    let ans = if s == "Sunny" {
        "Cloudy"
    } else if s == "Cloudy"{
        "Rainy"
    } else {
        "Sunny"
    };
    // let ans: String = match &s{
    //     "Sunny" => "Cloudy",
    //     "Cloudy" => "Rainy",
    //     "Rainy" => "Sunny",
    //     _ => "",
    // };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
lines = [list(map(int, line.split())) for line in sys.stdin]
for i in range(0, len(lines), 2):
    a = lines[i]
    b = lines[i + 1]
    hit = sum(1 for i in range(len(a)) if a[i] == b[i])
    blow = sum(1 for bi in b if bi in a) - hit
    print(hit, blow)  

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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  set<string> st;
  int n;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
}

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

int main()
{
ll l , n ;
cin >> l >> n ;
vector<ll> x(n);
vector<ll> xx(n);

rep(i, n){
  cin >> x[i];
  xx[n-i-1]=l-x[i];
}
vector<ll> s;
s.push_back(0);
rep(i,n){
  s.push_back(x[i]+s[i]);
}
vector<ll> ss;
ss.push_back(0);
rep(i,n){
  ss.push_back(xx[i]+ss[i]);
}
ll te;
rep(i,n){
  if((n-i)%2){
    te=(s[i+(n-i)/2]-s[i]+ss[(n-i)/2])*2+x[i+(n-i)/2];
    ans=max(ans,te);
    te=(ss[i+(n-i)/2]-ss[i]+s[(n-i)/2])*2+xx[i+(n-i)/2];
    ans=max(ans,te);
  }
  else{
  te=(s[i+(n-i)/2]-s[i]+ss[(n-i)/2])*2-xx[(n-i)/2-1];
  ans=max(ans,te);
  te=(ss[i+(n-i)/2]-ss[i]+s[(n-i)/2])*2-x[(n-i)/2-1];
  ans=max(ans,te);
}
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 8048
n = int(input())
y = 0
for i in range(n):
  x = 0
  for j in range(n):
    if (i + 1) % (j + 1) == 0:
      x += 1
  if (i + 1) % 2 == 1 and x == 8:
    y += 1
print(y)

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#define int long long
typedef struct{
  char name[11];
  int time;
}data;
int head;
int tail;
signed main(){
  int n,q,i;
  data Q[100001];
  
  data ans[100001];
  int sum,j,cnt;
  int mod=100000;
  scanf("%lld%lld",&n,&q);
  head=0;
  tail=n;
  for(i=0;i<n;i++){
    scanf("%s%lld",Q[i].name,&Q[i].time);
  }
  sum=0;
  j=0;
  while(head!=tail){
    cnt=0;
    for(i=head;i<tail;i++){
      if(Q[i%mod].time<=q){
	ans[j]=Q[i%mod];
	ans[j].time+=sum;
	j++;
	sum+=Q[i%mod].time;
      }
      else{
	Q[(cnt+tail)%mod]=Q[i%mod];
	Q[(cnt+tail)%mod].time-=q;
	sum+=q;
	cnt++;
      }
    }
    head=tail;
    tail+=cnt;
	
  }
  for(i=0;i<n;i++){
    printf("%s %lld\n",ans[i].name,ans[i].time);
  }
  return 0;
}



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

int W , H , sx , sy ;
int ans ;
char p ;
int dx[] = {-1,0,1,0} ;
int dy[] = {0,1,0,-1} ;
int table[23][23] ;

void DFS( int x , int y , int cnt ){
	if( cnt+1 >= ans ) return ;
	
	for( int i=0 ; i<4 ; i++ ){
		int nx = x + dx[i] , ny = y + dy[i] ;
		
		if( table[ny][nx] == 1 ){ continue ; }
		else { while( table[ny][nx] != 4 ){
			
			if( table[ny][nx] == 1 ){
				table[ny][nx] = 0 ;
				DFS( nx-dx[i] , ny-dy[i] , cnt+1 ) ;
				table[ny][nx] = 1 ;
				break ;
			}
			else if( table[ny][nx] == 3 ){
				ans = min( ans , cnt+1 ) ;
				return ;
			}
			
			nx += dx[i] ;
			ny += dy[i] ;
		}}
	}
	
	return ;
}

int main(){
	
	while( cin >> W >> H , W ){
		for( int i=0 ; i<=H+1 ; i++ ){
			for( int j=0 ; j<=W+1 ; j++ ){
				if( i==0 || j==0 || i==H+1 || j==W+1 ) table[i][j] = 4 ;
				else{ 
					cin >> table[i][j] ;
					if( table[i][j] == 2 ){
						sx = j ; 
						sy = i ;
					}
				}
			}
		}
		
		ans = 11 ;
		DFS( sx , sy , 0 ) ;
		if( ans == 11 ) ans = -1 ;
		cout << ans << endl ;
	}
	
return 0;
}

Measured memory_bytes: 1160
a={};b=0
for _ in [0]*int(input()):
    x,y,w=map(int,input().split())
    for i in range(2):
        for j in range(2):
            if (x+i,y+j) not in a:a[(x+i,y+j)]=0
            a[(x+i,y+j)]+=w
            b=max(b,a[(x+i,y+j)])
print(str(b)+' / 1')

Measured memory_bytes: 100312
while 1:
    n = int(input())
    if n == 0:
        break

    word = []
    for _ in range(n):
        data = list(input().split())
        for d in data:
            word.append(d)

    k = input()
    word_u = list(set(word))
    dic = []
    for w in word_u:
        if w[0] == k:
            dic.append([w, word.count(w)])

    dic = sorted(dic, key=lambda x: (-x[1], x[0]))
    if dic == []:
        print("NA")
    else:
        print(' '.join(d[0] for d in dic[:5]))


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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

#define int ll
void solve() {
	int a,b,c;
	cin >> a >> b >> c;
	int x = (c - (a + b));
	int p = x;
	x = (x * x);
	int y = 4 * a * b;
	if(y < x and p > 0) {
		cout << "Yes" << endl;
	}  
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end

# n = gets.to_s.to_i
n,m = gets.to_s.split.map{|e|e.to_i}
a = gets.to_s.split.map{|e|e.to_i}
# m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
# s = gets.to_s.chomp

s = a.sum

if s <= n
  puts n - s
else
  puts -1
end

Measured memory_bytes: 14612
N, M = map(int, input().split())
Alist = list(map(int, input().split()))
numlist = [[1,i] for i in Alist]
BC = [list(map(int, input().split())) for i in range(M)]
numlist += BC
numlist = sorted(numlist, key=lambda x:x[1], reverse=True)
ret = 0
for pair in numlist:
    if N <= 0:
        break
    if N >= pair[0]:
        ret += pair[0]*pair[1]
        N = N - pair[0]
    else:
        ret += N*pair[1]
        break
print(ret)

Measured memory_bytes: 47864
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s; cin >> s;
	for(ll i = 0; i < s.size(); i++){
		if(i + 1 < s.size() && s[i] == s[i + 1]){
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}else if(i + 2 < s.size() && s[i] == s[i + 2]){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

auto main() -> i32 {
	i32 n;
	i64 d;
	scanf("%d%ld", &n, &d);
	i32 ans = 0;
	for (i32 i = 0; i < n; ++i) {
		i64 x, y;
		scanf("%ld%ld", &x, &y);
		if (x * x + y * y <= d * d) {
			ans += 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1736
import sys
input = sys.stdin.readline
n = int(input())
v = [[0]+[]*(n+1) for i in range(n+1)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    v[a].append([b,c])
    v[b].append([a,c])

q,k = map(int,input().split())
l = [k]
while l:
    now = l.pop()
    for i in v[now][1:]:
        if v[i[0]][0] == 0:
            v[i[0]][0] = i[1]+v[now][0]
            l.append(i[0])

for i in range(q):
    x,y = map(int,input().split())
    print(v[x][0]+v[y][0])

Measured memory_bytes: 48964
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define vecp vector <pii>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
int main()
{
    fast
    string s;
    cin>>s;
    fr(i,s.size()) cout<<"x";
    return 0;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
A, B, C = [], [], [[0 for j in range(l)] for i in range(n)]
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    B.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    print(' '.join(map(str, C[i])))


Measured memory_bytes: 6888
N = int(input())
H = list(map(int, input().split()))

maxi = 0
for i in range(N):
    if H[i] > maxi:
        maxi = H[i]
    elif H[i] < maxi:
        if maxi - H[i] > 1:
            print("No")
            break
else:
    print("Yes")


Measured memory_bytes: 14252
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      int x=sc.nextInt();
	    if(x==0) {
	      out.println(1);
	    }else {
	      out.println(0);
	    }
	      out.flush();
	    }
//	    static int binarySearch(int i,int j,int a[]) {
//	      
//	    }
	
	static boolean vis[]=new boolean[10001];
	      static int gcd(int a, int b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 
	    static  void dfs(int n,boolean flag,ArrayList<ArrayList<Integer>> adj,int src,boolean vis[],ArrayList<Integer> centroid,int size[]) {
	        vis[src]=true;
	        size[src]=1;
	        for(int i:adj.get(src)) {
	          if(vis[i]==false){
	            dfs(n,flag,adj,i,vis,centroid,size);
	            size[src]+=size[i];
	            if(size[i]>n/2) {
	              flag=false;
	            }
	          }
	        }
	        if(n-size[src]>n/2) {
	          flag=false;
	        }
	        if(flag==true) {
	          centroid.add(src);
	        }
	    }
	
	     
	      
}

Measured memory_bytes: 35724
n, m = [int(x) for x in input().split()]
s = input()
c = n
h = []
while(True):
	d = m
	while d > 0:
		if c - d >= 0:
			if s[c - d] == '0':break
		d -= 1
	if d == 0:
		print(-1)
		break
	c -= d
	h.append(str(d))
	if c == 0:
		h.reverse()
		print(' '.join(h))
		break

Measured memory_bytes: 10100
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  vi a(n),b(n),c(n);
  REP(i,n){
	  cin>>a[i];
	  a[i]--;
  }
  REP(i,n){
		cin>>b[i];
  }
  REP(i,n-1){
	  cin>>c[i];
	  //c[i]--;
  }

  REP(i,n){
	  ans+=b[a[i]];
	  if (i!=n-1){
		if ((a[i]+1)==a[i+1]){
			ans+=c[a[i]];
		}
	  }
	  
  }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int h, w, sx, sy, gx, gy;
char c[210][210];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
bool used[210][210];

bool in(int x, int y){
    return 0<=x && x<h && 0<=y && y<w && c[x][y] != '#';
}

vector<vector<int>> bfs(vector<pii> &init){
    vector<vector<int>> d(h, vector<int>(w, MAX));
    queue<pii> que;
    for(auto &p: init){
        d[p.fi][p.se] = 0;
        que.push(p);
    }
    while(!que.empty()){
        int x, y;
        tie(x, y) = que.front(); que.pop();
        rep(i, 4){
            int nx = x+dx[i], ny = y+dy[i];
            if(in(nx, ny) && d[nx][ny] == MAX){
                d[nx][ny] = d[x][y] + 1;
                que.emplace(nx, ny);
            }
        }
    }
    return d;
}

void dfs(int x, int y){
    if(used[x][y]) return;
    used[x][y] = true;
    rep(i, 4){
        int nx = x+dx[i], ny=y+dy[i];
        if(in(nx, ny)) dfs(nx, ny);
    }
}

int main(){
    scanf("%d%d", &h, &w);
    rep(i, h)rep(j, w){
        scanf(" %c", &c[i][j]);
        if(c[i][j] == '@') sx = i, sy = j;
        if(c[i][j] == '%') gx = i, gy = j;
    }
    vector<pii> init;
    init.emplace_back(sx, sy);
    auto d_pr = bfs(init);
    init.clear();
    rep(i, h)rep(j, w)if(c[i][j] == '$') init.emplace_back(i, j);
    auto d_sl = bfs(init);

    rep(i, h)rep(j, w)if(d_pr[i][j] >= d_sl[i][j]) c[i][j] = '#';
    rep(i, h)rep(j, w) used[i][j] = false;
    dfs(sx, sy);
    puts(used[gx][gy] ? "Yes" : "No");
}


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

using namespace std;

#define roop(i, n) for(int i = 0;i < n;i++)
#define ll long long int

int main(void){

    vector<int> h, w;

    int count = 0;
    while(1){
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        h.push_back(a);
        w.push_back(b);
        count++;
    }

    for(int i = 0;i < count;i++){
        for(int j = 0;j < h[i];j++){
            for(int k = 0;k < w[i];k++){
                if(j % 2 == 0){
                    if(k % 2 == 0) cout << '#';
                    else cout << '.';
                }else{
                    if(k % 2 == 0) cout << '.';
                    else cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }



    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#define maxn 200005

using namespace std;
int n,sum=0;

struct job{
	int a,b;
}jobs[maxn];

int cmp(job x,job y){
	return x.b<y.b;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>jobs[i].a>>jobs[i].b;
	}
	sort(jobs+1,jobs+n+1,cmp);
	
	for(int i=1;i<=n;i++){
		sum+=jobs[i].a;
		if(sum>jobs[i].b){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int k,i,now;

signed main(){
	scanf("%d",&k);
	if(k%2==0 || k%5==0){
		printf("-1\n");
		return 0;
	}
	while(i<1000000){
		i++;
		now=(now*10+7)%k;
		if(now==0){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  vector<int> v(5);
  for (int i=0; i<5; i++) cin>>v[i];
  int best = 1e9;
  for (int i=0; i<5; i++) {
    int cur=0;
    for (int j=0; j<5; j++) {
      if (i==j) continue;
      int r = ((v[j]+9)/10)*10;
      cur += r;
    }
    cur += v[i];
    best = min(best, cur);
  }
  cout<<best<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    static final int N=3000;
    static boolean[] f(int a,int b){
        boolean[]r=new boolean[N];
        Queue<Integer>q=new ArrayDeque<Integer>();
        q.add(0);
        while(q.size()>0){
            int t=q.poll();
            if(t>=N)continue;
            if(r[t])continue;
            r[t]=true;
            q.add(t+a);
            q.add(t+b);
        }
        return r;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        int d=scan.nextInt();
        int e=scan.nextInt();
        int f=scan.nextInt();
        boolean[]ab=f(a,b);
        boolean[]cd=f(c,d);
        double m=0.0;
        int mx=100*a,my=0;
        for(int i=1;i<N;++i)
            if(ab[i])
                for(int j=0;j<N;++j)
                    if(cd[j]&&j<=e*i&&100*i+j<=f){
                        double r=(double)j/(double)i;
                        if(m<r){
                            m=r;
                            mx=100*i+j;
                            my=j;
                        }
                    }
        System.out.println(mx+" "+my);
    }
}


Measured memory_bytes: 22100