akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;

    vector<vector<char> > G(n,vector<char>(m));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++) cin>>G[i][j];
    }

    int t=n+m;
    int ways=0;
    for(int i=0;i<(1<<t);i++)
    {
        vector<int> ava(t,1);
        for(int r=0;r<n;r++) if(i&(1<<r)) ava[r]=0;
        for(int col=0;col<m;col++) if(i&(1<<(n+col))) ava[col+n]=0;

        int cnt=0;
        for(int row=0;row<n;row++)
        {
            if(ava[row]==0) continue;
            for(int col=0;col<m;col++)
            {
                if(ava[col+n]==0) continue;
                if(G[row][col]=='#') cnt++;
            }
        }
        if(cnt==k) ways++;
    }
    cout<<ways<<endl;
    return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef long long ll;

void solve() {
  int X;
  cin >> X;
  int i = 0, cur = 0;
  while (cur < X) {
    cur += i;
    i++;
  }
  cout << i - 1 << endl;
}

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

  solve();

  return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -Wall #-}

foldM_' :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
foldM_' _ _ [] = return ()
foldM_' f z (x:xs) = do
    z' <- f z x
    z' `seq` foldM_' f z' xs

readInt :: String -> Int
readInt = read

data BST a = Empty | Node a (BST a) (BST a)
    deriving (Show)

bstInsert :: (Ord a) => BST a -> a -> BST a
bstInsert Empty x = Node x Empty Empty
bstInsert (Node y l r) x
    | x <= y    = Node y (bstInsert l x) r
    | otherwise = Node y l (bstInsert r x)

bstPreorder :: (Ord a) => BST a -> [a]
bstPreorder Empty = []
bstPreorder (Node x l r) = [x] ++ bstPreorder l ++ bstPreorder r

bstInorder :: (Ord a) => BST a -> [a]
bstInorder Empty = []
bstInorder (Node x l r) = bstInorder l ++ [x] ++ bstInorder r

doCmd :: BST Int -> [String] -> IO (BST Int)
doCmd node ("insert":arg0:_) = do
    let x = readInt arg0
    return $ bstInsert node x
doCmd node ("print":_) = do
    putStrLn . concatMap ((' ':) . show) $ bstInorder  node
    putStrLn . concatMap ((' ':) . show) $ bstPreorder node
    return node
doCmd _ _ = error "invalid command"

main :: IO ()
main = do
    _    <- getLine
    cmds <- fmap (map words . lines) getContents

    let bst = Empty :: BST Int

    foldM_' doCmd bst cmds



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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    static const int LESS = 1;
    static const int MORE = 0;

    string N;
    int K;
    cin >> N >> K;

    int n = N.size();

    s64 dp[n + 1][K + 1][2];
    rep (i, n + 1)
    {
        rep (j, K + 1)
        {
            rep (k, 2)
            {
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][MORE] = 1;
    rep (i, n)
    {
        rep (j, K + 1)
        {
            dp[i + 1][j][MORE] += (N[i] == '0') ? dp[i][j][MORE] : 0;
            dp[i + 1][j][LESS] += dp[i][j][LESS] + ((N[i] == '0') ? 0 : dp[i][j][MORE]);
            if (j != K)
            {
                dp[i + 1][j + 1][MORE] += (N[i] == '0') ? 0 : dp[i][j][MORE];
                dp[i + 1][j + 1][LESS] += dp[i][j][LESS] * 9 + ((N[i] == '0') ? 0 : dp[i][j][MORE] * (int)(N[i] - '1'));
            }
        }
    }

    cout << dp[n][K][MORE] + dp[n][K][LESS] << "\n";
    return 0;
}



Measured memory_bytes: 256
x, y = [int(x) for x in input().split()]
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VL a(n), b(n), c(n);
    VL ansv(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    REP(i, n){
        int min = -1;
        int max = n;
        while(max - min > 1){
            int mid = (max + min) / 2;
            if(mid == -1 or mid == n) break;
            if(b[i] < c[mid]) max = mid;
            else min = mid;
        }
        ansv[i] = (ll)(n - max);
    }
    REP(i, n){
        int min = -1;
        int max = n;
        while(max - min > 1){
            int mid = (max + min) / 2;
            if(mid == -1 or mid == n) break;
            if(b[i] > a[mid]) min = mid;
            else max = mid;
        }
        ansv[i] *= (ll)min + 1;
    }

    ll ans = 0;
    REP(i, n) ans += ansv[i];
    cout << ans << "\n";
    return 0;
}


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

long long N, K, A[100000];
long long bit_add[40][2];


long long go(int bit_pos, bool any_ok){
    if(bit_pos == -1){
        return 0;
    }
    if(any_ok){
        return max(bit_add[bit_pos][0], bit_add[bit_pos][1]) + go(bit_pos - 1, true);
    }else{
        if((K >> bit_pos) & 1){
            return max(go(bit_pos - 1, false) + bit_add[bit_pos][1], go(bit_pos - 1, true) + bit_add[bit_pos][0]);
        }else{
            return go(bit_pos - 1, false) + bit_add[bit_pos][0];
        }
    }
}

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

    for(int i = 0; i < 40; i++){
        long long base = (1LL << i);
        for(int j = 0; j < N; j++){
            if(A[j] & base){
                bit_add[i][0] += base;
            }else{
                bit_add[i][1] += base;
            }
        }
    }

    for(int i = 0; i < 40; i++){
        //cout << bit_add[i][0] << "\t" << bit_add[i][1] << endl;
    }

    long long ans = go(39, false);
    cout << ans << endl;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str_x = scan.next();
		String str_y = scan.next();
		int x = 0;
		int y = 0;
		
		if(str_x.equals("A")) {
			x = 10;
		} else if(str_x.equals("B")) {
			x = 11;
		} else if(str_x.equals("C")) {
			x = 12;
		} else if(str_x.equals("D")) {
			x = 13;
		} else if(str_x.equals("E")) {
			x = 14;
		} else if(str_x.equals("F")) {
			x = 15;
		}
		if(str_y.equals("A")) {
			y = 10;
		} else if(str_y.equals("B")) {
			y = 11;
		} else if(str_y.equals("C")) {
			y = 12;
		} else if(str_y.equals("D")) {
			y = 13;
		} else if(str_y.equals("E")) {
			y = 14;
		} else if(str_y.equals("F")) {
			y = 15;
		}
		if(x > y) {
			System.out.println(">");
		} else if(x < y) {
			System.out.println("<");
		} else {
			System.out.println("=");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int j = 1;
		while (i * j < N) {
			ans++;
			j++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
}


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

const int MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> dp(n+1, 0);
    vector<bool> broken(n+1, false);

    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        broken[x] = true;
    }

    dp[0] = 1;
    dp[1] = !broken[1];

    for (int i = 2; i <= n; i++) {
        if (!broken[i]) {
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        }
    }
    
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
def d_Menagerie(N, S):
    s = S + S[0:2]  # 円環状に並んでいることを考慮
    for ans in ['SS', 'SW', 'WS', 'WW']:  # Sは羊、Wは狼。1番と2番の種類を仮定する
        cond = False
        for i in range(1, N + 1):
            if (ans[-1] == 'S' and s[i] == 'o') or (ans[-1] == 'W' and s[i] == 'x'):
                # この場合、今注目している動物の両隣は同じ種類。
                # よって、今注目している動物の右隣を左隣と同じにする。
                ans += ans[-2]
            else:
                # 両隣は違う種類。右隣を左隣と逆にする。
                ans += ('S' if ans[-2] == 'W' else 'W')
        if ans[:2] == ans[N:]:
            # sの最初の2文字(仮定)と最後の2文字が一致した文字列のみ受理する。
            # 1つ見つければ良いので、すぐにbreakする
            cond = True
            ans = ans[:N]
            break
    # 目的の文字列が存在すればその文字列を返し、存在しなければ-1を返す
    if cond:
        return ans
    else:
        return '-1'
    return None

N = int(input())
S = input().strip()
print(d_Menagerie(N, S))

Measured memory_bytes: 3444
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int ans[200010];
int boss[200010];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>boss[i];
		ans[boss[i]]++;
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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

public class Test
{
	public static void Main()
	{
        int n = int.Parse(Console.ReadLine());
        string[] line = Console.ReadLine().Split(' ');
        int[] nums = new int[n];
        int ans = 0;
        for(int i = 0 ; i < line.Length ; i++){
            nums[i] = int.Parse(line[i]);
            ans += nums[i]-1;
        }
        Console.WriteLine(ans);
    }                                                                                                                                   
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<bool> v(26, false);
  rep(i, 0, s.size()) { v[s[i] - 'a'] = !v[s[i] - 'a']; }
  bool ans = true;
  for (auto b : v) {
    if (b) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  getchar();
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

string S;
int print_ans(int bit){
    REP(i,S.size()-1){
        if(bit&(1<<i)){
            cout<<S[i]<<'+';
        }
        else{
            cout<<S[i]<<'-';
        }
    }
    cout<<S[S.size()-1]<<"=7"<<endl;
    return 0;
}

int main(){
    cin>>S;
    for( int bit = 0; bit<(1<<S.size()-1); bit++)
    {
        int sum = S[0]-'0';
        for(int j = 0;j<S.size()-1;j++){
            int tmp = S[j+1] - '0';
            if(bit&(1<<j)){
                sum += tmp;
            }else{
                sum -= tmp;
            }
        }
        if(sum==7){
            print_ans(bit);
            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 ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    string s;
    cin>>s;
    rep(i,0,sz(s)){
    	if (s[i]=='7'){
    		cout<<"Yes"<<endl;
    		return;
    	}
    }
    cout<<"No"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# primeFactorDecomposition(12): {2: 2, 3: 1}
def prime_factor_decomposition(n):
    import math
    m = defaultdict(int)
    while n > 1:
        find_factor = False
        for i in range(2, int(math.sqrt(n)) + 1):

            if n % i == 0:
                m[i] += 1
                n //= i
                find_factor = True
                break

        if not find_factor:
            m[n] += 1
            break

    return m


def main():
    N = int(input())
    MOD = 10 ** 9 + 7

    d = defaultdict(int)
    for x in range(1, N + 1):
        p = prime_factor_decomposition(x)
        for k, v in p.items():
            d[k] += v

    ans = 1
    for k, v in d.items():
        ans *= (v + 1)
        ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  char c;
  cin >> c;

  cout << char(c + 1) << endl;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> ps(n);
    for(int i = 0; i < n; ++i){
        cin >> ps.at(i);
    }
    ll ans = 0;
    for(int i = 1; i < n - 1; ++i){
        if((ps.at(i - 1) < ps.at(i) && ps.at(i) < ps.at(i + 1)) ||
           (ps.at(i + 1) < ps.at(i) && ps.at(i) < ps.at(i - 1))){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N, A, B;
    is >> N >> A >> B;
    if(!is) return;
    cout << min(A*N, B) << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();

        int ans = 0;

        for (int i = 1; i <= N; i++) {
            if (i % 2 == 0) {
                continue;
            }
            int cnt = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    cnt++;
                }
            }
            if (cnt == 8) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

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

  int M = N;
  int tmp=0;
  while(tmp<N)
    tmp += 1000;
  
  cout << tmp-N << endl;

  return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i<b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = a;i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, X;
    cin >> N >> X;
    if(X==1||X==2*N-1){
        cout << "No" << endl;
        return 0;
    }
    else{
        cout << "Yes" << endl;
        if(N==2){
            cout << "1 2 3" << endl;
            return 0;
        }
        //2*N-1,X,1,X+1||X-1,2*N-1,X,1
        if(X+1!=2*N-1){
            vl a;
            vl b={2*N-1,X,1,X+1};
            FOR(i,1,2*N){
                if(i!=X&&i!=1&&i!=X+1&&i!=2*N-1){
                    a.pb(i);
                }
            }
            rep(i,2*N-1){
                if(i<N-2){
                    cout << a[i] << ' ';
                }
                else if(i<N+2){
                    cout << b[i-N+2] << ' ';
                }
                else{
                    cout << a[i-4] << ' ';
                }
            }
            return 0;
        }
        else{
            vl a;
            vl b={X-1,2*N-1,X,1};
            FOR(i,1,2*N){
                if(i!=X&&i!=1&&i!=X-1&&i!=2*N-1){
                    a.pb(i);
                }
            }
            rep(i,2*N-1){
                //cout << i << endl;
                if(i<N-2){
                    cout << a[i] << ' ';
                }
                else if(i<N+2){
                    cout << b[i-N+2] << ' ';
                }
                else{
                    cout << a[i-4] << ' ';
                }
            }
            return 0;
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e=a*c;
	ll f=b*c;
	ll g=a*d;
	ll h=b*d;
	ll ans1=max(e,f);
	ll ans2=max(g,h);
	cout<<max(ans1,ans2)<<endl;
	return 0;
}


Measured memory_bytes: 3636
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 3 2"# => "YES",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        r: usize,
        g: usize,
        b: usize,
    }

    let ans:usize = format!("{}{}{}", r, g, b).parse().unwrap();

    (if ans % 4 == 0 { "YES" } else { "NO" } ).to_string()
}

Measured memory_bytes: 4352
import math
import fractions

def is_one_or_prime(num):
    dest = int(math.sqrt(num))
    for i in range(2, dest+1):
        if num % i == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a, b = map(int, input().split())
g = fractions.gcd(a, b)
l = make_divisors(g)
count = 0
for e in l:
  if is_one_or_prime(e):
    count += 1
print(count)


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

int main(){
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << (h2 - h1)* 60 + m2 - m1 - k << endl;
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF =  1e9;
const ll LINF = 1e18;
const ll MOD = 1e9+7;
const int SIZE = 100;

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll a, b, c, d, e, f;
	ll ans;
	scanf ("%lld %lld %lld %lld", &a, &b, &c, &d);
	e = max(a, c);
	f = min(b, d);
	ans = f - e;
	if (ans < 0) {
		ans = 0;
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>

using namespace std;

struct Point {
  double x;
  double y;
};

int main()
{
  int N;
  vector<Point> points;

  // 入力
  cin >> N;
  for (int i = 0; i < N; i++) {
    double x;
    double y;
    cin >> x >> y;
    points.push_back({x, y});
  }

  double R_max = 1000;
  double R_min = 0.0;

  for (int k = 0; k < 50; k++) {
    double R_mid = (R_max + R_min) / 2.0;
    double square_R = pow(R_mid, 2);
    vector<Point> nodes;
    vector<pair<Point *, Point *>> points_of_make_this_node;
    // 交点を列挙
    for (int i = 0; i < N - 1; i++) {
      for (int i_large = i + 1; i_large < N; i_large++) {

        Point center;
        Point n_vector;
        double square_K;

        square_K = pow(points[i].x - points[i_large].x, 2) + pow(points[i].y - points[i_large].y, 2);

        if (4 * square_R < square_K) continue; // ガード

        center.x = (points[i].x + points[i_large].x) / 2;
        center.y = (points[i].y + points[i_large].y) / 2;
        n_vector.x = (points[i].y - points[i_large].y);
        n_vector.y = (points[i_large].x - points[i].x);

        nodes.push_back({center.x + n_vector.x * pow(square_R / square_K - 1.0 / 4.0, 0.5),
                         center.y + n_vector.y * pow(square_R / square_K - 1.0 / 4.0, 0.5)});
        points_of_make_this_node.push_back(pair<Point *, Point *>(&points[i], &points[i_large]));
        nodes.push_back({center.x - n_vector.x * pow(square_R / square_K - 1.0 / 4.0, 0.5),
                         center.y - n_vector.y * pow(square_R / square_K - 1.0 / 4.0, 0.5)});
        points_of_make_this_node.push_back(pair<Point *, Point *>(&points[i], &points[i_large]));
      }
    }

    // それぞれのノードについてN個のどの点からも距離がR以下か判定
    bool update_flag = false;
    if (nodes.empty()) {
      update_flag = false;
    }

    for (int i = 0; i < nodes.size(); i++) {
      bool valid_node_flag = true;

      for (int k = 0; k < N; k++) {
        if (points_of_make_this_node[i].first == &points[k] || points_of_make_this_node[i].second == &points[k]) continue;
        double square_distance = pow(nodes[i].x - points[k].x, 2) + pow(nodes[i].y - points[k].y, 2);
        if (square_distance > square_R) {
          valid_node_flag = false;
          break;
        }
      }
      if (valid_node_flag == true) {
        update_flag = true;
        break;
      }
    }

    // Rを更新
    if (update_flag == true) {
      R_max = R_mid;
    }
    else {
      R_min = R_mid;
    }
  }

  cout << fixed << setprecision(8) << R_max;

  return 0;
}


Measured memory_bytes: 452
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) ;
#endif


typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
//#define debug(x) cerr << #x << " : " << (x) << " "
const double PI = 3.14159265358979323846;
const double eps = (1e-8);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}



int solve(int cnt)
{
    int sum = 0;
    for (int i = 1; ;i++)
    {
        sum += i;
        if (sum > cnt)
            return i - 1;
    }
    assert(false);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    ll n;
    cin >> n;
    int ans = 0;
    for (int i = 2; i <= n/i; ++i)
    {
        int cnt = 0;
        while(n%i == 0)
        {
            cnt++;
            n /= i;
        }
        if (cnt)
            ans += solve(cnt);
    }

    if (n > 1)
        ans++;

    cout << ans << '\n';
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  ll A[N], B[N];
  for (int i = 0; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  ll s = 0;
  for (int i = 0; i < N; i++) {
    s += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    A[i] -= min(A[i], B[i]);
    s += min(A[i + 1], B[i]);
    A[i+1] -= min(A[i + 1], B[i]);
  }
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 1792
from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())
ans_li = []
abcd = [tuple(map(int,input().split())) for _ in range(Q)]
for A in combinations_with_replacement(range(1,M+1),N):
    ans = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] == c:
            ans += d
    ans_li.append(ans)
print(max(ans_li))


Measured memory_bytes: 12508
def dfs(s,n):
    if int(s)>n:
        return 0
    cur = 0
    if all(s.count(c) > 0 for c in '753'):
        cur = 1
    for c in "753":
        cur += dfs(s+c,n)
    return cur
def examC():
    N = I()
    ans = dfs("0",N)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 55004
#-*-coding:utf-8-*-

def main():
    o = input()
    e = input()
    password = ''
    if len(o) == len(e):
        for i in range(len(o)):
            password += o[i] + e[i]
    else:
        for i in range(min(len(o), len(e))):
            password += o[i] + e[i]
        password += o[-1]
    print(password)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG
                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}


int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
int main() {
  int N; cin >> N;
  vector<int> W(N);
  rep(i, N) {
    cin >> W.at(i);
  }
  const int INF = 1e8;
  vector<int> S(N+1, 0);
  rep(i, N) S.at(i+1) = S.at(i) + W.at(i);
  int ans = INF;
  for (int i = 1; i < N; i++) {
    int left, right;
    left = S.at(i);
    right = S.at(N) - S.at(i);
    ans = min(ans, abs(right-left));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

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

int main() {
  int a,b,c,X;
  
  cin >> X ;
  a = X / 100;
  b = (X - 100*a) / 10;
  c = X - 100*a - 10*b;
  
  cout << a + b + c << endl;


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

signed main() {

    SS(ll,N,P);

    auto pr = prime_factor(P);

    ll res = 1;
    for (auto itr=pr.begin(); itr!=pr.end(); ++itr) {
        if (itr->second>=N) res *= pow(itr->first,itr->second/N);
    }
    p(res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define tam 310000
#define offset 100000
#define se second
#define fi first
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
ll f(ll num,ll base)
{
    if (num==0)
        return 0;
    //cout<<num%base<<" ";
    return num%base+f(num/base,base);
}
int main()
{
    ll n,s;
    cin>>n>>s;
    if (s==n)
    {
        cout<<n+1<<endl;
        return 0;
    }
    forr(i,2,1e6){
    if (f(n,i)==s)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    ll val=2,minn=1e18;
    while(val<=n)
    {
        ll iz=val,der=n+1,mid;
        while(iz+1<der)
        {
            mid=(iz+der)/2;
            if (n/mid==n/val)
                iz=mid;
            else
                der=mid;
        }
        ll fo=f(n,val);
        ll X=n/val;
        //cout<<val<<" "<<iz<<" "<<" "<<iz-val<<" "<<X<<" "<<f(n,val)-f(n,val+1)<<endl;
        if (fo>=s&& (fo-s)%X==0&& (fo-s)/X<=iz-val)
            minn=min(minn,val+(fo-s)/X);
        val=der;

    }

    if (minn==1e18)
    cout<<-1<<endl;
    else
    cout<<minn<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, m, color[100005];
vector<int> g[100005];

bool check(int v, int c) {
    color[v] = c;
    rep(i, 0, g[v].size()) {
        if (color[g[v][i]] == c) return false;
        if (color[g[v][i]] == 0 && !(check(g[v][i], -c))) return false;
    } 
    return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b); g[b].pb(a);
    }
    if (!check(0, 1)) {
        cout << n * (n-1) / 2 - m << endl;
        return 0;
    }
    ll b = 0, w = 0;
    rep(i, 0, n) {
        if (color[i] == 1) w++;
    } 
    cout << w * (n - w) - m << endl;
    return 0;
}


Measured memory_bytes: 6912
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int sum = accumulate(a.begin(),a.end(),0LL);

  sort(a.begin(),a.end());

  if(sum-a[n-1] > a[n-1])  cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  for (int i = 0; i < b; i++) {
    int amari = a * i % b;
    if (amari == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n - 1, 0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9 + 7;
#define ll long long
signed main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int now = 0;
  int nex = 1;
  int ca = 1000;
  int cr = 0;
  bool f = false;
  a.push_back(-9999);
  while (now < n)
  {
    if (f && a[now] > a[nex])
    {
      f = false;
      ca += cr * a[now];
    }
    else if (!f && a[now] < a[nex])
    {
      f = true;
      cr = ca / a[now];
      ca -= cr * a[now];
    }
    now++;
    nex++;
  }
  cout << ca << endl;

  return 0;
}


Measured memory_bytes: 3560
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		
		char[] slime = sc.next().toCharArray();
		int ans =1;
		for(int i = 0;i < n-1;i++){
			if(slime[i+1] != slime[i]){
				ans++;
			}
		}
		
		System.out.println(ans);

		
	}


	static long dijkstra(Edge[] edge,int n){

		long[] d = new long[n];		//始点からの最短距離
		Arrays.fill(d, 1l << 60);
		d[0] = 0;
		PriorityQueue<P> q = new PriorityQueue<>(Comparator.comparingLong(p-> p.cost));			//costをソート
		q.add(new P(0,0));

		while(!q.isEmpty()){
			P current = q.remove();
			if(current.to == n-1){
				return current.cost;
			}
			if(current.cost != d[current.to]){
				continue;
			}
			for(P next: edge[current.to]){
				if(d[next.to] > current.cost + next.cost){
					d[next.to] = current.cost + next.cost;
					q.add(new P(next.to, current.cost+next.cost));
				}
			}


		}
		return -1;



	}



	static int upperbond(int k,int currentindex, ArrayList<Pair> a,ArrayList<Pair> b,int[] aa,int[] bb){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = a.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(a.get(mid).from > k){
				max = mid;
			}else{
				min = mid;
			}
		}

		if(max == a.size()){
			max--;
		}
		for(int i = max; i>=0;i--){
			if(a.get(i).from <= bb[currentindex] && aa[currentindex] <= bb[a.get(i).end]){
				int tmp = a.get(i).end;
				a.get(i).end = a.get(currentindex).end;
				a.get(currentindex).end = tmp;

				return tmp;
			}
		}

		return -1;
	}

	static int lowerbond(int k, ArrayList<Integer> data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return data.get(min);
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






Measured memory_bytes: 26404