akhauriyash/Code-Regression huggingface dataset:
const main = (input) => {
    const reverse = (s) => {
        return s.split('').reverse().join('');
    };

    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    const index = 0;

    while(true) {
        const w = WORDS.find((w) => S.startsWith(w, index));
        if (!w) break;
        index += w.length;
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9624
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){
  if(a < b){ a = b; return true;} return false;
}
template<class T> inline bool chmin(T& a, T b){
  if(a > b){ a = b; return true;} return false;
}

int main(){
  int n,we,V;
  cin >> n >> we;
  vector<long long> w(n);
  vector<int> v(n);
  V = 0;
  for(int i=0;i < n;i++){
    cin >> w.at(i) >> v.at(i);
    V += v.at(i);
  }
  
  vector<vector<long long>> dp(n+1,vector<long long>(V+1,INT_MAX));
  for(int i=0;i < V+1;i++){
    if(i-v.at(0) <= 0){
      chmin(dp.at(1).at(i),w.at(0));
    }
    chmin(dp.at(1).at(i),dp.at(0).at(i));
  }
  for(int i=1;i < n;i++){
    for(int j=0;j < V+1;j++){
      if(j-v.at(i) <= 0){
        chmin(dp.at(i+1).at(j),w.at(i));
        chmin(dp.at(i+1).at(j),dp.at(i).at(j));
      }
      else{
        int x = j-v.at(i);
        if(x < 0){
           x = 0;
        }
        chmin(dp.at(i+1).at(j),dp.at(i).at(x) + w.at(i));
      }
      chmin(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  /*
  for(int i=1;i < n+1;i++){
    for(int j=0;j < V+1;j++){
      cout << dp.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
  
  int ans;
  for(int i=V;i >= 0;i--){
    if(dp.at(n).at(i) <= we){
      ans = i;
      break;
    }
  }
   cout << ans << endl;     
      
}

Measured memory_bytes: 83068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll n,r=0,b=0;
	string s;
	cin >> n >> s;
	FOR(i,0,n){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

int main(){
  long long int mi = 100000000000,ma = -100000000000,a,n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    ma = max(ma,a-mi);
    mi = min(mi,a);
  }
  cout << ma<< endl;
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n;
    cin >> n;
    
    vi h(n);
    rep(i, n){
        cin >> h[i];
    }

    vi dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    repA(i, 2, n - 1){
        dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
    }
    cout << dp[n - 1] << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();

		if (n < 105) 
			System.out.println(0);
		else if (n < 135) 
			System.out.println(1);
		else if (n < 165) 
			System.out.println(2);
		else if (n < 189)
			System.out.println(3);
		else if (n < 195)
			System.out.println(4);
		else
			System.out.println(5);
	}
}

Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; ll n = s.size();
  bool flag = true;
  
  rep(i,n){
    rep(j,n){
      if(i != j and s[i] == s[j]){
        flag = false;
      }
    }
  }
  
  if(flag) cout << "yes" << endl;
  else cout << "no" << endl;
  
  
}

Measured memory_bytes: 3548
from collections import deque

N, K = map(int, input().split())
x = list(map(int, input().split()))

x_upper = []

for i in reversed(x):
    if i<0:
        break
    if i>=0:
        x_upper.append(i)
        x.pop()
        
#絶対値昇順へソート
x.reverse()
x_upper.reverse()

lenXu = len(x_upper)
lenX = len(x)

if K>lenXu:
    l = K-lenXu-1
    h = lenXu-1
else:
    l = -1
    h = K-1

S = []
while l<K and l<lenX:
    if h<0:
        S.append(x[l]*(-1))
    elif l<0:
        S.append(x_upper[h])
    else:
        if (x[l]*(-1))<x_upper[h]:
            S.append((x[l]*(-1))*2 + x_upper[h])
        else:
            S.append((x[l]*(-1)) + x_upper[h]*2)
    l += 1
    h -= 1

print(min(S))


Measured memory_bytes: 14628
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int array[] = new int[1000000];
		int i = 0;
		array[0] = num;
		
		do{
			if(array[i] % 2 == 0) {
				array[i+1] = array[i] / 2; 
			}else {
				array[i+1] = array[i] * 3 + 1;
			}
			i++;
		}while(!proc(array,array[i],i));
		
		System.out.println(i + 1);
	}
	
	public static boolean proc(int array[], int val, int len) {
		for(int i = 0; i < len; i++) {
			if(val == array[i]) {
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 26068
use num_integer::gcd;
use proconio::*;

#[fastout]
fn main() {
    input! {
        n : usize,
    }
    let mut ans = 0;
    for a in 1..=n {
        for b in 1..=n {
            for c in 1..=n {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
#include <stdio.h>

int p[4][3][10] = {0}, b, f, r, v, n;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
            p[b - 1][f - 1][r - 1] += v;
    }

    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                printf(" %d", p[b][f][r]);
            }
            printf("\n");
        }
        if (b != 3)
        {
            printf("####################\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define loop(n) for (int _i = 0; _i < (n); _i++)
#define rep(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;

int encode(int i, int j) {
    if (i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}

int seen[2000000];
int d[2000000];
int dfs(const Graph &G, int now) {
    if (seen[now] == 2) return d[now];
    seen[now] = 1;
    for (auto e : G[now]) {
        if (seen[e.to] == 1) {
            cout << -1 << endl;
            exit(0);
        }
        chmax(d[now], dfs(G, e.to) + 1);
    }
    seen[now] = 2;
    return d[now];
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    Graph G(N * (N - 1) / 2 + 1);
    rep(i, 0, N) {
        int now = 0;
        loop(N - 1) {
            int j;
            cin >> j;
            j--;
            int next = encode(i, j);
            G[now].push_back({next});
            now = next;
        }
    }

    cout << dfs(G, 0) << endl;
    return 0;
}


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

string solve(string const &a, string const &b)
{
    vector<vector<int> > dp(a.length()+4,vector<int>(b.length()+4,0));
    for(int i=1 ; i<=a.length() ; ++i)
    {
        for(int j=1 ; j<=b.length() ; ++j)
        {
            if(a[i-1]==b[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i=a.length(),j=b.length();
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans+=a[i-1];
            --i;
            --j;
        }
        else if(dp[i-1][j]>=dp[i][j-1])
        --i;
        else
        --j;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    string ans=solve(a,b);
    for(int i=ans.length()-1 ; i>=0 ; --i)
    cout<<ans[i];
    cout<<endl;
    return 0;
}

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



namespace Test1 {

    class ClassMain {




        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }


                for (int i = 0; i < n; i++) {
                    Console.WriteLine("Case " + (i + 1) + ":");
                    int s = int.Parse(Console.ReadLine());

                    for (int j = 0; j < 10; j++) {
                        s = makeRand_(s);
                        Console.WriteLine(s);
                    }

                }
                break;


            }
        }

        public static int makeRand_(int s) {
            int rnd = 0;
            s = s * s;
            string str = s + "";
            string zeros = new String('0', 8 - str.Length);
            str = zeros + str;
            str = str.Substring(2, 4);
            rnd = int.Parse(str);
            return rnd;
        }
    }

}

Measured memory_bytes: 5616
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String a=sc.next();
String b=sc.next();
a+=b;
double i=Double.valueOf(a);
int j=(int)Math.sqrt(i);
if(Math.pow(j,2)==i){System.out.println("Yes");}else{System.out.println("No");}
}}

Measured memory_bytes: 20688
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  int l,r;
  l=a/k;r=b/k;
  if(l!=r)
    cout<<"OK"<<endl;
  else if(a%k==0 || b%k==0)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;
}


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

int main() {
  int n;
  cin >>n ;
  if(n == 100000)
    cout << 90909 << endl;
  else if(n > 9999)
    cout << n - 9090 << endl;
  else if(n > 999)
    cout << 909 << endl;
  else if(n > 99)
    cout << n - 90 << endl;
  else if(n > 9)
    cout << 9 << endl;
  else
    cout << n << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        if (400 <= X && X <= 599) {
            System.out.println(8);
            return;
        }
        if (X <= 799) {
            System.out.println(7);
            return;
        }
        if (X <= 999) {
            System.out.println(6);
            return;
        }
        if (X <= 1199) {
            System.out.println(5);
            return;
        }
        if (X <= 1399) {
            System.out.println(4);
            return;
        }
        if (X <= 1599) {
            System.out.println(3);
            return;
        }
        if (X <= 1799) {
            System.out.println(2);
            return;
        }
        if (X <= 1999) {
            System.out.println(1);
            return;
        }
    }
}


Measured memory_bytes: 35664
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)


int main()
{
    int N, M, a, b;
    cin >> N >> M;

    vector<vector<bool>> G(N, vector<bool>(N, false));
    rep(i,M) {
        cin >> a >> b; a--; b--;
        G[a][b] = G[b][a] = true;
    }

    vector<int> nodes(N);
    rep(i, N) nodes[i] = i;
    int ans = 0;
    do {
        if (nodes[0] != 0) continue;
        bool is_ok = true;
        rep(i, N-1) {
            if (!G[nodes[i]][nodes[i+1]]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) ans++;
    } while (next_permutation(nodes.begin(), nodes.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, S := ReadInt(), ReadString()

	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, N+1)
	}
	for i := N - 1; i >= 0; i-- {
		for j := N - 1; j >= 0; j-- {
			if S[i] == S[j] {
				dp[i][j] = 1 + dp[i+1][j+1]
			} else {
				dp[i][j] = 0
			}
		}
	}
	ans := 0
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			now := Min(dp[i][j], j-i)
			ans = Max(ans, now)
		}
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 209468
#include <iostream>
#include <string>
#include <cmath>
  
using namespace std;
  
int var[11];
  
int solve();
int getVal(int &itr, const string &form);
  
int main(void) {
  
    while (solve()){}
  
    return 0;
}
  
int solve() {
  
    //  input
    string eq,exp[2];
    cin >> eq;
  
    //  the end of dataset
    if (eq == "#") { return 0; }
  
    int sep = eq.find("=");
  
        //  lfs
        exp[0] = eq.substr(0, sep);
        //  rhs
        exp[1] = eq.substr(sep+1, string::npos);
  
    //  brute force
    bool isEqual = true;
    for (int i = 0; i < (1 << 12); i++) {
  
        for (int j = 0; j < 11; j++) {
            if (i & (1 << j)) {
                var[j] = 1;
            }
            else {
                var[j] = 0;
            }
        }
  
        int itr[2] = { -1, -1};
  
        int rhs, lhs;
        lhs = getVal(itr[0], exp[0]);
        rhs = getVal(itr[1], exp[1]);
        isEqual &= ( lhs == rhs );
  
    }
  
    //  output
  
    if (isEqual) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
  
  
    return 1;
}
  
int getVal(int &itr, const string &form) {
  
    //  formula?????§?£???
    ++itr;
    if (form[itr] == 'T') { return 1; }
    if (form[itr] == 'F') { return 0; }
    if ('a' <= form[itr] && form[itr] <= 'k') { return var[form[itr]-'a']; }
  
    // operator -
    if (form[itr] == '-' && form[itr+1] != '>' ) {
        return 1 - getVal(itr, form);
    }
  
    if (form[itr] == '(') {
  
        //  binary operator
        int lhs, rhs;
        char ope;
  
        lhs = getVal(itr, form);
  
        itr++;
        ope = form[itr];
        if (ope == '-') { itr++; }
  
        rhs = getVal(itr, form);
  
        //  ')'
        itr++;
  
        if (ope == '+') {
            return max(lhs, rhs);
        }
        else if (ope == '*') {
            return min(lhs, rhs);
        }
        else if (ope == '-') {
            if (lhs == 1 && rhs == 0) { return 0; }
            else return 1;
        }
  
    }
  
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    bool answer = false;
    sort(vec.begin(), vec.end());
    int sum = 0;
    for (int i=0; i<N-1; i++) {
        sum += vec.at(i);
    }

    if (sum > vec.at(N-1)) {
        answer = true;
    } else {
        answer = false;
    }

    if (answer) {
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN=100005;
vector <int> E[MAXN];
int In[MAXN];
int Q[MAXN], head, tail;
int n, m, dp[MAXN];

int main()
{
	scanf ("%d%d", &n, &m);
	for (int i=1; i<=m; i++){
		int a, b;
		scanf ("%d%d", &a, &b);
		E[a].push_back (b);
		In[b]++;
	}
	
	for (int i=1; i<=n; i++)
		if (!In[i])
			Q[++tail] = i;
	
	int res=0;
	while (head < tail){
		int x=Q[++head];
		res = max (res, dp[x]);
		for (int i=0; i<E[x].size(); i++){
			int y=E[x][i];
			In[y]--;
			dp[y] = max (dp[y], dp[x]+1);
			if (!In[y])  Q[++tail] = y;
		}
	}
	
	printf ("%d\n", res);
	return 0;
}

Measured memory_bytes: 6912
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())

def isAllOdd (a):
    for i in a:
        if i % 2 == 0:
            return False
    return True

def isAllEven (a):
    for i in a:
        if i % 2 == 1:
            return False
    return True

ans = 'first'
if N == 1:
    if a[0] % 2 == 1:
        ans = 'first'
    else:
        ans = 'second'
elif a.count(1) in [N-1, N]:
    ans = 'first'
else:
    if isAllOdd(a) or isAllEven(a):
        ans = 'second' 
    
print(ans)

Measured memory_bytes: 7004
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define ll long long
int main()
{  double a,b,h,m;
cin>>a>>b>>h>>m;
   double angle=abs(((h*30)+(30*m/60)-m*6));
   if(angle>360-angle)
       angle=360-angle;
    
   double ans=(a*a)+(b*b)-2*a*b*cos(angle*3.14159265359/180);
   cout<<setprecision(15)<<sqrt(ans);

}

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

const int INFTY = (1 << 30);
const int MAX = 200005;

long long merge(int A[], int n, int left, int mid, int right) {
  long long num_inversions {0};

  // define L, R
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = INFTY;

  // merge
  int l_i {0}, r_i {0};
  for (int i = left; i < right; i++) {
    if (L[l_i] <= R[r_i]) {
      A[i] = L[l_i];
      l_i++;
    } else {
      A[i] = R[r_i];
      r_i++;
      num_inversions += (n1 - l_i);
    }
  }
  return num_inversions;
}

long long mergeSort(int A[], int n, int left, int right) {
  int mid {0};
  long long num1, num2, num3;
  if (left + 1 < right) {
    mid = (left + right) / 2;
    num1 = mergeSort(A, n, left, mid);
    num2 = mergeSort(A, n, mid, right);
    num3 = merge(A, n, left, mid, right);
    return num1 + num2 + num3;
  } else {
    return 0;
  }
}

int main() {
  // input
  int n;
  cin >> n;
  int A[MAX];
  for (int i = 0; i < n; i++) cin >> A[i];

  // main part
  long long ans = mergeSort(A, n, 0, n);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4636
#include<iostream>
#include<vector>
#include<cstdlib>

#define INF 1 << 30 //1<<31 で負の数

using namespace std;

int main() {

	int N;
	cin >> N;

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

	vector<int> s(N, INF);
	s[0] = 0;

	for (int i = 0; i < N - 1; i++) {
		int a = s[i] + abs(h[i] - h[i + 1]);
		if (a < s[i + 1]) s[i + 1] = a;
		
		if (i == N - 2) break;

		a = s[i] + abs(h[i] - h[i + 2]);
		if (a < s[i + 2]) s[i + 2] = a;
	}

	cout << s[N - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
void solve() {
	int X; cin >> X;
	int ok = X, ng = 0;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		int res = (1 + mid)*mid / 2;
		if (res >= X)ok = mid;
		else ng = mid;
	}
	print(ok);
}


signed main() {
	solve();
}



Measured memory_bytes: 384
import heapq

N = int(input())
A = list(int(x) for x in input().split())
heapq.heapify(A)
com1 = heapq.heappop(A)
ans = True

for _ in range(N-1):
    com2 = heapq.heappop(A)

    if com1 == com2:
        ans = False
        break

    com1 = com2

if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 25172
#include <iostream>

int main(){
    int N,yo;
    std::cin >> N;

    yo=N%10;

    if(yo == 3){
        std::cout << "bon" << std::endl;
    }
    else if (yo == 0 || yo == 1 || yo == 6 || yo == 8){
        std::cout << "pon" << std::endl;
    }
    else{
        std::cout << "hon" << std::endl;
    }


}





Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2010;
const ll inf=10000000000000000;
int n;
int x,y;
ll ans,ans_fin;
vector<int>e[N];
ll f[N],sum[N],g[N];
char s[N];
void dfs(int now,int fa,int d)
{
	int len=e[now].size();
	if (s[now]=='1') sum[now]=1,ans+=(ll)d;
	ll f1=0,g1=0,s1=0,t1=0;
	for (int i=0;i<len;i++) {
		int u=e[now][i];
		if (u==fa) continue;
		dfs(u,now,d+1);
		sum[now]+=sum[u];
		f[u]+=sum[u];
		f1+=f[u]; g1+=g[u];  
		if (s1<f[u]) {
			s1=f[u]; t1=g[u];
		}
	}
	if (s1*2<=f1) {
		f[now]=f1%2; g[now]=g1+f1/2; 
	} else {
		f[now]=s1*2-f1; g[now]=g1+f1-s1;
		if ((g1-t1)*2<=f[now]) {
			f[now]-=(g1-t1)*2; g[now]+=(g1-t1);
		}
		else {
			f[now]=f[now]%2; g[now]+=f[now]/2;
		}
	}
}
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		e[x].push_back(y); e[y].push_back(x);
	}
	ans_fin=inf;
	for (int i=1;i<=n;i++) {memset(f,0,sizeof(f)); memset(sum,0,sizeof(sum)); memset(g,0,sizeof(g)); ans=0; dfs(i,0,0); if (f[i]==0) ans_fin=min(ans_fin,ans);}
	if (ans_fin==inf) printf("%d\n",-1);
	else 
	printf("%lld\n",ans_fin/2);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define r(a, b) for(ll i = a; i < b; i++)
#define pb push_back
using namespace std;
#define mod 998244353
const long long int INF = 1e10;
vector<ll>v;
ll res(ll m){
    if(m==0){
        return 1;
    }
    else{
        return pow(2,m)+res(m-1);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h;
    cin>>h;
    ll m=log2(h);
    cout<<res(m)<<"\n";
    return 0;
}



Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

int n,w,x[2][100010]={0};
int dp[110][100010]={0};

signed main() {
	cin>>n>>w;
    rep(i,n){
        cin>>x[0][i]>>x[1][i];
    }
	
    rep(i,n){
        rep(j,w){
            dp[i+1][j+1]=dp[i][j+1];
            if(j+1-x[0][i]>=0){
                dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1-x[0][i]]+x[1][i]);
            }
        }
    }

    cout<<dp[n][w]<<endl;

	
	return 0;
}


Measured memory_bytes: 81408
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>

using namespace std;

typedef long long LL;

const LL mod=1e9+7;

int n,x,y;
struct node
{
	int c,w,id;
	friend bool operator < (node a,node b)
	{
		return a.w<b.w;
	}
}a[210000];
int pp[210000];
vector<node> g[210000];
int fa[210000],sz[210000];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
void Union(int x,int y)
{
	int fx=find(x),fy=find(y);
	if (fx!=fy) fa[fx]=fy,sz[fy]+=sz[fx];
}

LL f[210000],ff[210000],inv[210000];
LL ans=1;
int c[210000];
map<int,int> S[210000];
map<int,int>::iterator it;
int minn=1e9,pos;
int main()
{
	f[0]=1;
	for (int i=1;i<=200010;i++)
		f[i]=(f[i-1]*(LL)i)%mod;
	ff[1]=ff[0]=inv[1]=inv[0]=1;  
	for (int i=2;i<=200010;i++)
	{
    	inv[i]=(LL)(mod-mod/i)*inv[mod%i]%mod;
    	ff[i]=inv[i];
	}
	for (int i=2;i<=200010;i++)
		inv[i]=(inv[i-1]*inv[i])%mod;
	scanf("%d %d %d",&n,&x,&y);
	for (int i=1;i<=n;i++)
	{
		scanf("%d %d",&a[i].c,&a[i].w);
		c[i]=a[i].c;
		a[i].id=fa[i]=i;
		sz[i]=1;
		g[a[i].c].push_back(a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		sort(g[i].begin(),g[i].end());
		for (int j=1;j<g[i].size();j++)
			if (g[i][0].w+g[i][j].w<=x) Union(g[i][0].id,g[i][j].id);
	}
	sort(a+1,a+1+n);
	for (int i=2;i<=n;i++)
		if (a[i].c!=a[1].c&&a[i].w+a[1].w<=y) 
		{
			Union(a[i].id,a[1].id);
			if (a[i].w<minn) pos=i,minn=a[i].w;
		}
	for (int i=1;i<g[a[1].c].size();i++)
		if (minn+g[a[1].c][i].w<=y) Union(a[pos].id,g[a[1].c][i].id);
	for (int i=1;i<=n;i++)
	{
		int fx=find(i);
		S[fx][c[i]]++;
	}
	for (int i=1;i<=n;i++)
	{
		int fx=find(i);
		if (pp[fx]) continue;
		pp[fx]=1;
		ans=ans*f[sz[fx]]%mod;
		it=S[fx].begin();
		for (;it!=S[fx].end();it++)
			ans=ans*inv[(*it).second]%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;


int main() {long N;
cin >> N;
vector<long> x(N+1);
erep(i, 1, N) cin >> x[i];
vector<long> y = x;//???
sort(y.begin()+1, y.end());

erep(i, 1, N){
    long ans;
    if(x[i] <= y[N/2]){
        ans = y[N/2+1];
    }
    else ans = y[N/2];
    show(ans);
}




  return 0;
 
}



Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if (a <= c && c <= b)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

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 vs = vector<string>;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vi a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> a[i];
    }

    const ll INF = LLONG_MAX / 4;

    vll left(3 * N, -INF);
    {
        priority_queue<ll> best;
        ll bsum = 0;
        for (int i = 0; i < 3 * N; i++) {
            while (best.size() > N - 1) {
                bsum += best.top();
                best.pop();
            }

            if (best.size() == N - 1)
                left[i] = a[i] + bsum;

            bsum += a[i];
            best.push(-a[i]);
        }
    }

    vll right(3 * N, INF);
    {
        priority_queue<ll> best;
        ll bsum = 0;
        for (int i = 3 * N - 1; i >= 0; i--) {
            best.push(a[i]);
            bsum += a[i];

            while (best.size() > N) {
                bsum -= best.top();
                best.pop();
            }

            if (best.size() == N)
                right[i] = bsum;
        }
    }

    ll ans = -INF;
    for (int i = 0; i + 1 < 3 * N; i++)
        ans = max(ans, left[i] - right[i + 1]);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 7916
import sys
 
N, K = map(int, sys.stdin.readline().strip().split())
S = sys.stdin.readline().strip()
 
l = x = ans = 0
for r in range(N):
    if S[r] == '0' :
        if r == 0 or S[r-1] == '1':
            x += 1
    if x > K:
        while S[l] == '1':
            l += 1
        while S[l] == '0':
            l += 1
        x -= 1
    ans = max(ans, r-l+1)
print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	int red, green; cin >> red >> green;
	int r, g, c; cin >> r >> g >> c;

	vector<ll> rA(r), gA(g), cA(c);
	for (auto &x : rA) { cin >> x; }
	for (auto &x : gA) { cin >> x; }
	for (auto &x : cA) { cin >> x; }

	sort(rA.rbegin(), rA.rend());
	sort(gA.rbegin(), gA.rend());
	sort(cA.rbegin(), cA.rend());

	vector<ll> candidates;
	ll ans = 0;
	for (int i = 0; i < red; i++) { candidates.push_back(rA[i]); }
	for (int i = 0; i < green; i++) { candidates.push_back(gA[i]); }
	for (int i = 0; i < min((int)cA.size(), red + green); i++) { candidates.push_back(cA[i]); }
	
	sort(candidates.rbegin(), candidates.rend());
	for (int i = 0; i < red + green; i++) { ans += candidates[i]; }

	cout << ans << endl;
}

Measured memory_bytes: 8816
#include <iostream>
using namespace std;
long long a,b,c,x,y,sum,t;
int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>x>>y;
    t=min(x,y);
    if(a+b>2*c)
    {
        sum=t*c*2;
        x-=t;
        y-=t;
    }
    else
    {
        sum=t*(a+b);
        x-=t;
        y-=t;
    }
    sum+=min(x*a,x*c*2)+min(y*b,y*c*2);
    cout<<sum;
    return 0;
}


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

int main() {
    int n;
   
 
   cin >> n;
  
  // cout << n << endl;
  
  int a[n][2];
  
for(int i = 0;i<n;i++){
  
     for(int j = 0;j<2;j++){ 
        
        cin >> a[i][j];
       

     }
  
}
  
  int ans = n;
  
  for(int i = 0;i<n;i++){
  
    
        
       ans = ans+a[i][1]-a[i][0];
       

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int h[100010];
    rep(i, n) cin >> h[i];
    int ok = INF;
    int ng = 0;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int cnt = 0;
        rep(i, n) {
            int num = max(0LL, h[i] - b * mid);
            cnt += (num + a - b - 1) / (a - b);
        }
        if(cnt <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

template <class TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a)
{
  while (*sdbg != ',')
    cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
  os << "[";
  for (auto vv : V)
    os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

vvi g;
vi toporder, vis;
void dfs(int u)
{
  vis[u] = 1;
  for(auto v: g[u])
  if(!vis[v]) dfs(v);

  toporder.push_back(u);
}

void topsort()
{
  for(int i = 0; i < g.size(); i++)
  if(!vis[i])
  dfs(i);
  reverse(all(toporder));
}
main()
{
  int n, m, i, j, u, v;
  cin >> n >> m;
  g.assign(n, vi());
  vis.assign(n, 0);
  for(i = 0; i < m; i++)
  {
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
  }
  topsort();
  vector<int> dp(n);
  for(i = 0; i < n; i++)
  {
    u = toporder[i];
    for(auto v: g[u])
    dp[v] = max(dp[v], dp[u] + 1);
  }
  cout << *max_element(all(dp));
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a*b<=0)
    cout<<"Zero"<<endl;
  else if(b<0){
    if((b-a+1)%2==0)
      cout<<"Positive"<<endl;
    else
      cout<<"Negative"<<endl;
  }
  else
    cout<<"Positive"<<endl;
}

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

int main() {
    ll x;
    cin >> x;
    vector<ll> p;

    p.push_back(2);
    for (int i=3; i<=100003; i++) {
        ll m = ll(sqrt(double(x)));
        bool flag = true;
        for (int j=2; j<=m; j++) {
            if (i % j == 0) {
                flag = false;
                break;
            }
        }
        if (flag) p.push_back(i);
    }

    rep(i, p.size()) {
        if (x <= p[i]) {
            cout << p[i] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1400
R ,G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
	for g in range(N // G + 1):
		if (N - R * r - G * g) % B == 0 and 0 <= (N - R * r - G * g) // B <= N // B:
			ans += 1
print(ans)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

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

	for(int i=1;i<=9;i++){
		if(a%i ==0 && (i<=9 && a/i <=9 )){
			cout << "Yes" << endl;
			return 0;
		}
	}

	 cout << "No" << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, x, y;
    cin>>n>>x>>y;
    int i;
    int weight[n+5] = {};
    vector< vi> graph(n+5);
    FOR0(i, n-1)
    {
        graph[i].pb(i+1);
        graph[i+1].pb(i);
    }
    x--;y--;
    graph[x].pb(y);
    graph[y].pb(x);
    FOR0(i, n)
    {
        queue<int> q;
        int dis[n+5] = {};
        int j;
        FOR0(j, n) dis[j] = -1;
        dis[i] = 0;
        q.push(i);
        while(!q.empty())
        {
            int u = q.front();
            q.pop();
            int j, si = graph[u].size();
            FOR0(j, si)
            {
                int v = graph[u][j];
                if(dis[v] != -1) continue;
                dis[v] = dis[u] + 1;
                q.push(v);
            }
        }
        FOR(j, i+1, n) weight[dis[j]]++;
    }
    FOR(i, 1, n) cout<<weight[i]<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int hour, min, sec;
    int h1, m1, s1, h2, m2, s2;
    int s;
    int i;
    
    for (i = 0; i < 3; i++){
        scanf("%d%d%d%d%d%d", &h1, &m1, &s1, &h2, &m2, &s2);
        s = (h2 - h1) * 3600 + (m2 - m1) * 60 + s2 - s1;
        
        printf("%d %d %d\n", s / 3600, (s % 3600) / 60, (s % 3600) % 60);
    }
    
    return (0);
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    if((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())
*F, = map(int, input().split())
A.sort()
F.sort(reverse=True)

def f(x):
    ans = 0
    for i,j in zip(A, F):
        ans += (i*j-x+j-1)//j if i*j-x>=0 else 0
    return ans<=K

l, r = -1, 10**18+1
while r-l>1:
    mid = (r+l)//2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)

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

int main(){
  int i,j,k;
  int ans;
  string str;
  string left="qazwsxedcrfvtgb";
  string right="yhnujmikolp";

  while(1){
    ans = 0;
    cin >> str;

    int len_str =  str.size()-1;
    int len_right = right.size();
    int len_left = left.size();

    if(str == "#") break;
    for(i = 0 ; i < len_str ; i++){
      for(j = 0 ; j < len_left ; j++){
	for(k = 0 ; k < len_right ; k++){
	  if(str[i]==left[j]&&str[i+1]==right[k]){
	    ans++;
	  }
	}
      }
    }

    for(i = 0 ; i < len_str ; i++){
      for(j = 0 ; j < len_right ; j++){
	for(k = 0 ; k < len_left ; k++){
	  if(str[i]==right[j]&&str[i+1]==left[k]){
	    ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
 
using namespace std;
 
int main(){
int num[3],c5=0,c7=0;
cin >> num[0] >> num[1] >> num[2];
for(int i =0;i<3;i++){
if(num[i]==5){
c5++;
}
if(num[i]==7){
c7++;
}
}
if(c5==2 && c7==1){
cout << "YES" <<endl;
}else{
cout << "NO" << endl;
}
return 0;
}

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

int main(){
    int a,b;
    while(cin>>a>>b){
        int sum = a + b;
        int result = 0;
        while (true) {
            sum = sum / 10;
            result++;
            if (sum == 0) {
                cout << result << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector < vector <int> > dp(n+1,vector <int> (n+1,0));
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      dp[i][j]=__gcd(i,j);
  long long int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      for(int k=1;k<=n;k++){
        ans+=dp[i][dp[j][k]];
      }
   cout<<ans;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,j;
    cin>>a;
    b=a%10;
    if(b==2 || b==4 || b==5 || b==7 || b==9)
        cout<<"hon"<<endl;
    else if(b==6 || b==1 || b==8 || b==0)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
    return 0;
}


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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i;
	string s;
	t = 1;
	while(t--) {
	 cin >> s;
	 n = s.size( );
	 for(i = 0; i < n; i++) {
	  if(s[i] == ',')
	   cout << " ";
	  else
	   cout << s[i];
	 }
	 cout << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
int arr[100001];
int n,k;
int func(int x) {
if(x==0) {
    return 0;
}
int &ret = dp[x];
if(ret!=-1)
return ret;
ret = 0;
int i;
for(i=0;i<n;i++) {
if(x>=arr[i]) {
    ret = ret | !func(x-arr[i]);
}
}
return ret;
}
signed main() {

cin>>n>>k;
int i;
for(i=0;i<n;i++)
cin>>arr[i];
memset(dp,-1,sizeof(dp));
if(func(k))
cout<<"First\n";
else
cout<<"Second\n";
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=1000000007;
ll dp[100001][2];
vector<int> g[100001];
int n;
//0:white
ll dfs(int v,int par,int co){
    if(dp[v][co]!=-1) return dp[v][co];
    ll ret=0;
    bool flag=false;
    dp[v][co]=1;
    rep(i,g[v].size())if(g[v][i]!=par){
        ret=0;
        flag=true;
        if(co==0){
            ret+=dfs(g[v][i],v,1);
        }
        ret+=dfs(g[v][i],v,0);
        ret%=mod;
        dp[v][co]*=ret;
        dp[v][co]%=mod;
    }
    return dp[v][co];
}
int main(){
    cin>>n;
    int xi,yi;
    memset(dp,-1,sizeof(dp));
    rep(i,n-1){
        cin>>xi>>yi;
        --xi,--yi;
        g[xi].pb(yi);
        g[yi].pb(xi);
    }
    ll ans=0;
    ans+=dfs(0,-1,0);
    ans%=mod;
    ans+=dfs(0,-1,1);
    cout<<ans%mod<<endl;
    return 0;
}


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

int main(void){
  int N=0, M=0;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  vector<int> sum(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(s.at(i)==s.at(j)){
        sum.at(i)++;
      }//if
    }//for j
    for(int j=0;j<M;j++){
      if(s.at(i)==t.at(j)){
        sum.at(i)--;
      }
    }
   }//for i

  int max_sum=sum.at(0);
  for(int i=0;i<N;i++){
    if(max_sum < sum.at(i)){
      max_sum=sum.at(i);
    }
  }
  
  if(max_sum<=0){
    cout << 0 << endl;
  }else{
    cout << max_sum << endl;
  }
  
}

Measured memory_bytes: 3632