akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0];

    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{
     ll n,i,j,cnt=0,k,w=-100,b,h,m,hcf,prod,t;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
    cin>>n>>m;
   
    while(m--)
    {
        cin>>t;
        cnt+=t;
        
    }
    if(cnt>=n)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
   
    

	    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int x;
    cin >> x;
    if(x <= 599) {
        cout << 8 << endl;
    } else if(x <= 799) { 
        cout << 7 << endl;
    } else if(x <= 999) {
        cout << 6 << endl;
    } else if(x <= 1199) {
        cout << 5 << endl;
    } else if(x <= 1399) {
        cout << 4 << endl;
    } else if (x <= 1599) {
        cout << 3 << endl;
    } else if(x <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = Math.min(a,b);
        boolean check = true;
        while(c<=Math.max(a,b)){
            if(c*a*b%2==1) {
                check = false;
                out.println("Yes");
                break;
            }
            ++c;
        }
        if(check) out.println("No");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32812
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] a = new int[M];
		int[] b = new int[M];
		
		Node[] node = new Node[N];
		for(int i = 0; i < N; i++) {
			node[i] = new Node();
		}
		
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
			
		}
		
		for(int i = 0; i < M; i++) {
			node[a[i]].next.add(b[i]);
			node[b[i]].next.add(a[i]);
		}
		
		boolean ok = false;
		for(int i = 0; i < node[0].next.size(); i++) {
			for(int j = 0; j < node[node[0].next.get(i)].next.size(); j++) {
				if(node[node[0].next.get(i)].next.get(j) == N-1) ok = true;
			}
		}
		System.out.println(ok?"POSSIBLE":"IMPOSSIBLE");
	}
	
	static class Node {
		ArrayList<Integer> next = new ArrayList<>();
		
	}
}

Measured memory_bytes: 125148
import sys
import collections
from collections import Counter
# from collections import deque
# from collections import defaultdict
import itertools
# from itertools import accumulate
# from itertools import permutations
# from itertools import combinations
# from itertools import takewhile
# from itertools import compress
# import functools
# from functools import reduce
import math
# from math import gcd
# from math import inf
# from math import ceil
# from math import floor
# from math import log10
# from math import log2
# from math import log
from math import factorial

# import re

N = int(input())


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


P = prime_decomposition(factorial(N))
C = Counter(P)

n2, n4, n14, n24, n74 = [0] * 5

for k, v in C.items():
    n2 += 1 if v >= 2 else 0
    n4 += 1 if v >= 4 else 0
    n14 += 1 if v >= 14 else 0
    n24 += 1 if v >= 24 else 0
    n74 += 1 if v >= 74 else 0

p1, p2, p3, p4 = [0] * 4
p1 = n4 * (n4 - 1) * (n2 - 2) // 2
p2 = n14 * (n4 - 1)
p3 = n74
p4 = n24 * (n2 - 1)

print(sum([p1, p2, p3, p4]))


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

int main(){
  int a[5],ans=0;
  for(int i=0;i<3;i++)
  {
    cin >>a[i];
  }
  
  sort(a,a+3);
  ans=a[2]*10+a[1]+a[0];
  cout <<ans<<endl;
  
  return 0;
}
  


Measured memory_bytes: 256
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
using namespace std;
int main()
{
    int a,b,c,t;
    cin>>a>>b>>c;
    t=a;
    a=b;
    b=t;
    t=a;
    a=c;
    c=t;
    cout<<a<<" "<<b<<" "<<c<<endl;


    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n:usize = read();
    let mut a:Vec<i32> = (0..n).map(|_| read()).collect();

    let mut min = 0;
    while a.len() != 1 {
        a.sort_by(|x,y|y.cmp(x));
        min = a.pop().unwrap();
        a = a.iter().map(|x| x % min).filter(|x| x.is_positive()).collect();
        a.push(min);
    }

    println!("{}",min);

}


Measured memory_bytes: 4352
#include <stdio.h>
int X, Y, T, R;
int gcd(int x, int y) {
	if(x == 0) return y;
	if(y == 0) return x; T++;
	if(x > y) return gcd(y, x % y);
	return gcd(x, y % x);
}
int main() {
	while(true) {
		scanf("%d%d", &X, &Y); T = 0;
		if(X == 0 && Y == 0) break;
		R = gcd(X, Y);
		printf("%d %d\n", R, T);
	}
	return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

ll v[100001]={0};
ll v2[100001]={0};

ll gcd(ll x, ll y);  // 最大公約数を求める関数

ll gcd(ll x, ll y)
{
    ll r;

    if(x == 0 || y == 0)  // 引数チェック
    {
//        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}

int main(){
    ll n,x;cin>>n>>x;
    rep(i,n){ cin>>v[i]; }
    for(int i=1;i<n;i++){
        v2[i-1]=abs(v[i]-v[i-1]);
    }
    if(n==1){
        v2[0]=abs(v[0]-x);
    }
    //cout<<v2[0]<<endl;
    ll ans = abs(v[0]-x);
    rep(i,n-1) {
        ans = gcd(ans, v2[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

ll N;
vector<ll> a(3), b(3);
ll dp[30000000];

ll calc(vector<ll> sei, vector<ll> obj, ll M) {
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < 3; ++i) {
        for (int v = 0; v + sei[i] <= M; ++v) {
            dp[v+sei[i]] = max(dp[v+sei[i]], dp[v] + obj[i]);
        }
    }

    ll res = M;
    for (int v = 0; v <= M; ++v){
        res = max(res, dp[v] + M-v);
    }
    return res;
}

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    for (int i = 0; i < 3; ++i) cin >> a[i];
    for (int i = 0; i < 3; ++i) cin >> b[i];

    N = calc(a, b, N);
    N = calc(b, a, N);
    cout << N << endl;
}


Measured memory_bytes: 234624
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
 
    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
 
 
s = input()
n = len(s)
 
print(dfs(0, s[0]))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

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

const ll INF=1LL << 60;
ll dp[100005];
ll h[100005];

int main() {
  int n,k;cin >> n >> k;
  rep(i,n)dp[i]=INF;
  rep(i,n)cin >> h[i];
  dp[0]=0;

  rep(i,n){
    reps(j,k){
      if(i+j<n)chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout << dp[n-1];
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
 
#define ll long long
ll MAX = 1000000000+7;
 
using namespace std;
 
ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}
 
int main() {
    ll t = 1;
    // cin >> t;
    while (t--) {
        ll n, k, i, a, po=0, ni=0, ans=1;
        vector<ll> vcp, vcn;
        cin >> n >> k;
        for (i=0;i<n;i++) {
            cin >> a;
            if (a<0) {
                a=-a;
                ni++; vcn.push_back(a);
            }
            else {
                po++; vcp.push_back(a);
            }
        }
        if (po>0) sort(vcp.begin(),vcp.end());
        if (ni>0) sort(vcn.begin(),vcn.end());
 
        if (po==0) {
            if (k%2==0) {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[ni-1]);
                    ans = modF(ans);
                    ni--;
                }
            }
            else {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[i]);
                    ans = modF(ans);
                }
            }
        }
        else if (ni==0) {
            for (i=0;i<k;i++) {
                ans = ans * vcp[po-1];
                ans = modF(ans);
                po--;
            }
        }
        else {
            if (k%2==1) {
                ans = vcp[po-1];
                po--; k--;
            }
            while (k>1 && (po>=2 || ni>=2)) {
                ll propo = 0;
                if (po>=2) propo = vcp[po-1]*vcp[po-2];
                ll proni = 0;
                if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];
 
                if (propo>proni) {
                    propo = modF(propo);
                    ans = ans*propo;
                    ans = modF(ans);
                    po = po-2;
                }
                else {
                    proni = modF(proni);
                    ans = ans*proni;
                    ans = modF(ans);
                    ni = ni-2;
                }
                k=k-2;
            }
            while (k>0) {
                if (po>0) {
                    ans = ans*vcp[po-1];
                    ans = modF(ans);
                    po--; k--;
                }
                else if (ni>0) {
                    ans = ans*(-vcn[ni-1]);
                    ans = modF(ans);
                    ni--; k--;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  vector<int> num(110);
  for(int i = 0; i < N; i++){
    num.at(data.at(i))++;
  }
  int count = 0;
  for(int i = 0; i <= 100;i++){
    if(num.at(i) > 0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod(int n)
{

    if(n>=0)
    {
        return n;
    }
    else
    {
        return -n;
    }

}
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(mod(x-a)<mod(x-b))
    {
        cout<<"A";
    }
    else
    {
        cout<<"B";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll x = n / 500;
  ll y = (n - 500 * x) / 5;
  cout << 1000 * x + 5 * y << endl;
}

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

#define ll long long
#define pb push_back

int main(){

	int N, K;
	cin >> N >> K;
	if(N + 1 >= K * 2)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
import math
import itertools
n, d = map(int, input().split())
ary = []
for i in range(n):
	x = list(map(int, input().split()))
	ary.append(x)
c = 0
for j,k in itertools.combinations(ary,2):
	s = 0
	for l in range(d):
		s += (j[l]-k[l])**2
	ss = math.sqrt(s)
	if ss.is_integer():
		c += 1
print (c)


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

int H,W;
char s[101][101];
int dp[101][101];

int main(){
    cin>>H>>W;
    repn(i,H) repn(j,W) cin>>s[i][j];
    repn(i,H) fill(dp[i]+1,dp[i]+W+1,INF);

    dp[1][1]=0;
    repn(i,H){
        repn(j,W){
            if(i<H){
                int cnt=dp[i][j];
                if(s[i][j]!=s[i+1][j]) cnt++;
                dp[i+1][j]=min(dp[i+1][j],cnt);
            }
            if(j<W){
                int cnt=dp[i][j];
                if(s[i][j]!=s[i][j+1]) cnt++;
                dp[i][j+1]=min(dp[i][j+1],cnt);
            }
        }
    }
    int ans=dp[H][W]/2;
    if(s[1][1]=='#' || s[H][W]=='#') ans++;

    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int N, M, P;
  while (cin >> N >> M >> P, N || M || P){
    int tot = 0;
    vector<int> v;
    inpt(v, N, in);
    for (auto& x : v) tot += x * 100;
    M--;
    tot -= P * (tot / 100);
    if (v[M]) printf("%d\n", tot / v[M]);
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1216
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	total := 0.0
	for i := 0; i < n; i++ {
		total += 1.0 / list[i]
	}
	fmt.Println(1.0 / total)

}


Measured memory_bytes: 512
let words = Str.split (Str.regexp " ")
let chars s = List.init (String.length s) (String.get s)
let (>>) f g x = g (f x)

let [a; b; c; d] = read_line () |> chars |> List.map (Char.escaped >> int_of_string)

let ans =
  let rec solve bits =
    let sign = List.init 3 (fun i -> if bits land (1 lsl i) <> 0 then 1 else -1) in
    let x =
      List.combine sign [b; c; d]
      |> List.fold_left (fun acc pair -> acc + fst pair * snd pair) a
    in
    if x = 7 then bits else solve (bits + 1)
  in solve 0

let () =
  print_int a;
  print_string (if ans land 1 <> 0 then "+" else "-");
  print_int b;
  print_string (if ans land 2 <> 0 then "+" else "-");
  print_int c;
  print_string (if ans land 4 <> 0 then "+" else "-");
  print_int d;
  print_string "=7";
  print_newline ()


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

#define MARK 4
#define RANK 13

#define SPADE 0
#define HEART 1
#define CLUB 2
#define DIAMOND 3

int main(int argc, char const *argv[])
{
    int card[MARK][RANK] = {0};
    int n;
    char M;
    int R;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> M >> R;
        if (M == 'S')
        {
            card[SPADE][R - 1] = 1;
        }
        else if (M == 'H')
        {
            card[HEART][R - 1] = 1;
        }
        else if (M == 'C')
        {
            card[CLUB][R - 1] = 1;
        }
        else if (M == 'D')
        {
            card[DIAMOND][R - 1] = 1;
        }
    }

    for (int i = 0; i < MARK; i++)
    {
        for (int j = 0; j < RANK; j++)
        {
            if (card[i][j] == 0)
            {
                if (i == SPADE)
                {
                    cout << "S " << j + 1 << endl;
                }
                else if (i == HEART)
                {
                    cout << "H " << j + 1 << endl;
                }
                else if (i == CLUB)
                {
                    cout << "C " << j + 1 << endl;
                }
                else if (i == DIAMOND)
                {
                    cout << "D " << j + 1 << endl;
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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 before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    vector<pii> range;
    REP(i,N) {
        int l=A-(N-i-1)*D+i*C;
        int r=A-(N-i-1)*C+i*D;
        range.push_back({l,r});
    }
    REP(i,SZ(range)) {
        if(range[i].first<=B && B<=range[i].second) {
            dump(range[i]);
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 10604
def c_sentou(N, T, Times):
    times = Times + [Times[-1] + T]  # 番兵を追加(最後の人が押したT秒後に止まる)
    return sum([min(T, times[i + 1] - times[i]) for i in range(N)])

N, T = [int(i) for i in input().split()]
Time = [int(i) for i in input().split()]
print(c_sentou(N, T, Time))

Measured memory_bytes: 25200
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        s: chars,
    }
    let mut ans = 0;
    for i in 0..s.len() {
        if i & 1 == 0 {
            if s[i] == 'p' {
                ans -= 1;
            }
        } else if i & 1 > 0 {
            if s[i] == 'g' {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if ((c-a-b)<0) {
    cout << "No" << endl;
    return 0;
  }
  ll l = 4*a*b;
  ll r = (c-a-b)*(c-a-b);
  if(l<r) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
   string s;
   cin >> s;
   bool solve = 0;
   bool c = 1;
   while(c)
   {
       if(s.size() == 0)
       {
           solve = 1;
           break;
       }
       c = 0;
       if(s.size() >= 11 && s.substr(0, 11) == "dreameraser")
       {
           s.erase(0, 11);
           c = 1;
       }
       else if(s.size() >= 10 && s.substr(0, 10) == "dreamerase")
       {
           s.erase(0, 10);
           c = 1;
       }
       else if(s.size() >= 7 && s.substr(0, 7) == "dreamer")
       {
           s.erase(0, 7);
           c = 1;
       }
       else if(s.size() >= 5 && s.substr(0, 5) == "dream")
       {
           s.erase(0, 5);
           c = 1;
       }
       else if(s.size() >= 6 && s.substr(0, 6) == "eraser")
       {
           s.erase(0, 6);
           c = 1;
       }
       else if(s.size() >= 5 && s.substr(0, 5) == "erase")
       {
           s.erase(0, 5);
           c = 1;
       }
   }

   if(solve)
   {
       cout << "YES" << endl;
   }
   else
   {
       cout << "NO" << endl;
   }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll n,k; cin >> n >> k;

    /**
     * a+b = b+c = c+a = 0 (mod k)
     * =>2*(a+b+c) = 0 (mod k)
     * =>2a = 2b = 2c = 0 (mod k)
     *   -> 同値ではない...
     *
     * if k%2==0 then:
     *   a = b = c = k/2 or 0 (mod k) -> a = b = c = 0 (mod k/2)
     *   "2つを足し合わせた時" 0 (mod k)を満たせばいいので、
     *   a = b = k/2(mod k) なる a,b に対しても a+b = k = 0(mod k)が成立する
     * else then:
     *   a = b = c = 0 (mod k)
     */

    if(k%2==1) cout << (n/k)*(n/k)*(n/k) << '\n';
    else {
        ll p = n/k, q = n/(k/2)-n/k;
        cout << p*p*p + q*q*q << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N, A[Nmax];

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

	int ans = 0;
	for(int i=0; i<N-1; i++){
		if(A[i]==i){
			ans++;
			swap(A[i], A[i+1]);
		}
	}
	if(A[N-1]==N-1){
		ans++;
		swap(A[N-2], A[N-1]);
	}

	//for(int i=0; i<N; i++){
	//	cout << A[i] << (i==N-1?'\n':' ');
	//}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

// Java8
public class Main
{
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		int n = nint();
		int[] ds = new int[n];
		for(int i=0; i<n; i++) ds[i] = nint();

		System.out.println(judge(n, ds) ? "yes" : "no");
	}

	boolean judge(int n, int[] ds)
	{
		PriorityQueue<Integer> minHeap = new PriorityQueue<>(n, Comparator.naturalOrder());
		minHeap.offer(ds[0]);
		for(int i=1; i<n; i++)
		{
			while(!minHeap.isEmpty())
			{
				int x = minHeap.peek();
				if(x<i*10) minHeap.poll();
				else break;
			}
			if(minHeap.isEmpty()) return false;
			minHeap.offer(i*10+ds[i]);
		}
		PriorityQueue<Integer> maxHeap = new PriorityQueue<>(n, Comparator.reverseOrder());
		maxHeap.offer((n-1)*10-ds[n-1]);
		for(int i=n-2; i>=0; i--)
		{
			while(!maxHeap.isEmpty())
			{
				int x = maxHeap.peek();
				if(x>i*10) maxHeap.poll();
				else break;
			}
			if(maxHeap.isEmpty()) return false;
			maxHeap.offer(i*10-ds[i]);
		}
		return true;
	}

	int nint()
	{
		return Integer.parseInt(sc.next());
	}
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	vector<char> ans;
	for(int unsigned i=0;i<s.size();i++){
		if(s[i] == 'B'){
			if(ans.size()) ans.pop_back();
			continue;
		}
		ans.emplace_back(s[i]);
	}
	for(int unsigned i=0;i<ans.size();i++){
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
c = [[int(x) for x in input().split()] for _ in range(3)]

for i in range(2):
    for j in range(2):
        if c[j][i + 1] - c[j][i] != c[j + 1][i + 1] - c[j + 1][i]:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 9112
def main() -> None:
    S = input()
    N = len(S)
    pos = []
    ss = []
    for i, s in enumerate(S):
        if s != 'x':
            ss.append(s)
            pos.append(i)
    if ss != ss[::-1]:
        print(-1)
        return

    L = len(ss)
    if len(ss) == 0:
        print(0)
        return
    if L % 2 == 0:
        left, right = (L-1) // 2, L // 2
    else:
        left = right = L // 2
    left, right = left - 1, right + 1
    ans = 0
    while left >= 0 and right < L:
        ans += abs((pos[left + 1] - pos[left] - 1) -
                   (pos[right] - pos[right-1] - 1))
        left, right = left - 1, right + 1
    ans += abs((pos[0] - 0) - (N - 1 - pos[-1]))
    print(ans)


if __name__ == '__main__':
    main()


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

int main(void) 
{
   int n;
   cin >>n;
   vector<ll>a(n);
   rep(i,n) cin >> a[i];
   sort(a.rbegin(), a.rend());
    ll ans = a[0];
   rep(i,n-2)
   {
       int target = i/2;
       ans += a[target+1];
       //cout <<a[target+1] << endl;
   }
   cout << ans << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int s[10][1005];
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  rep(i,h)rep(j,w){
    s[i][j+1] = s[i][j];
    if(c[i][j]=='1') s[i][j+1]++;
  }
  int ans = (h-1)*(w-1);
  rep(b,1<<(h-1)){
    int res = [&]{
      int res = 0;
      int p = 0;
      bool ok = true;
      rep(j,w){
        int x = 0; bool add = false;
        rep(i,h){
          x += s[i][j+1]-s[i][p];
          if(x>k) {
            add = true;
            if(j==p) ok = false;
          }
          if(b>>i&1) x = 0;
        }
        if(!ok) return -1;
        if(add){
          p = j;
          ++res;
        }
      }
      return res;
    }();
    if(res<0) continue;
    ans = min(ans,res+__builtin_popcount(b));
  }
  cout << ans << endl;
}


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

using LL = long long;

LL f(LL x, LL y) {
  if (x == 0) return -y;
  if (y == 0) return -x;
  if (x == y) return x;
  if (x < y) return 2 * x * (y / x) + f(x, y % x);
  if (x > y) return 2 * y * (x / y) + f(x % y, y);
  return -1;
}

void run() {
  LL n, x;
  std::cin >> n >> x;
  std::cout << f(x, n - x) + n << std::endl;
}

int main() {
  run();
  return 0;
}


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

const int MAX = 2e5 + 1;
int N;
P h[MAX];
int a[MAX];
ll dp[MAX];

ll t[2 * MAX];
void modify(int p, ll value) {
	for (t[p += N] = value; p > 1; p >>= 1)
		t[p >> 1] = max(t[p],  t[p ^ 1]);
}
ll query(int l, int r) {
	ll ret = 0;
	for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ret = max(ret, t[l++]);
		if (r & 1) ret = max(ret, t[--r]);
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		int hh; cin >> hh;
		h[i] = { hh, i };
	}
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(h, h + N);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		int j = h[i].second;
		dp[j] = query(0, j) + a[j];
		modify(j, dp[j]);
		ans = max(ans, dp[j]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8832
//最短経路長が短い経路に流せるだけ流す。
//ただし、順辺のコストをcとしたときに逆辺のコストは-cにする (フローを押し戻すとき、コストも押し戻すため）。
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const int VMAX = 200;
struct Edge {
	int from, to, flow, cost, rev;
	Edge(int from, int to, int flow, int cost, int rev) {
		this->from = from;
		this->to   = to;
		this->flow = flow;
		this->cost = cost;
		this->rev  = rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, int from, int to, int flow, int cost) {
	g[from].push_back(Edge(from, to, flow, cost, g[to].size()));
	g[to].push_back(Edge(to, from, 0, -cost, g[from].size() - 1));
}

int dfs(Graph &g, int s, int t, int flow, bool yet[], int level[]) {
	yet[s] = false;
	if (s == t) return flow;
	for (int i = 0; i < g[s].size(); i++) {
		int v = g[s][i].to;
		if (g[s][i].flow > 0 && yet[v] && level[v] == level[s] + g[s][i].cost) {
			int res = dfs(g, v, t, min(flow, g[s][i].flow), yet, level);
			if (res > 0) {
				int r = g[s][i].rev;
				g[s][i].flow -= res;
				g[v][r].flow += res;
				return res;
			}
		}
	}
	return 0;
}

//gを破壊します
int minCostflow(Graph g, int s, int t, int flow) {
	const int INF_DIST = 11451419;
	const int INF_FLOW = 11451419;
	const int ERROR_RETURN = -1;
	int level[VMAX];
	bool yet[VMAX];
	queue<int> que;
	int i;
	int ret = 0;
	
	while (true) {
		for (i = 0; i < g.size(); i++) level[i] = INF_DIST;
		que.push(s); level[s] = 0;
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (i = 0; i < g[v].size(); i++) {
				int nv = g[v][i].to;
				if (g[v][i].flow > 0 && level[nv] > level[v] + g[v][i].cost) {
					level[nv] = level[v] + g[v][i].cost;
					que.push(nv);
				}
			}
		}
		if (level[t] >= INF_DIST) break;

		while (true) {
			for (i = 0; i < g.size(); i++) yet[i] = true;
			int f = dfs(g, s, t, INF_FLOW, yet, level);
			if (f == 0) break;
			flow -= f;
			ret += f * level[t];
			if (flow <= 0) {
				ret += flow * level[t];
				return ret;
			}
		}
	}
	return -1;
}

int n, m, s, t;
int u, v, d, c;
Graph g;

int main() {
	int i;
	
	cin >> n >> m >> s >> t; s--; t--;
	g.resize(n);
	for (i = 0; i < m; i++) {
		cin >> u >> v >> d >> c; u--; v--;
		add_edge(g, u, v, c, d);
	}
	
	int dist = minCostflow(g, s, t, 1);
	int st = 0, ed = 25000, mid; //oooxxx, [st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		int cst = minCostflow(g, s, t, mid);
		if (cst == -1 || cst > dist * mid) ed = mid;
		else st = mid;
	}
	cout << st << endl;
	return 0;
}


Measured memory_bytes: 3288
function main(input) {
    input = parseInt(input);
    switch(input) {
      case 25:
        console.log("Christmas");
        break;
      case 24:
        console.log("Christmas Eve");
        break;
      case 23:
        console.log("Christmas Eve Eve");
        break;
      case 22:
        console.log("Christmas Eve Eve Eve");
        break;
    }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import sys
def input(): return sys.stdin.readline().rstrip()


class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def orr(x, y):
    return x | y


def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 53768
n = int(input())
dp = [0]*(n+1)
a = list(map(int, input().split()))
  
dp[1] = abs(a[1]-a[0])
for i in range(2,n):
  dp[i] =  min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]))
print(dp[n-1])

Measured memory_bytes: 14696
#include <iostream>
#include <string>
#include <utility>

int ctoi(char c)
{
	switch (c)
	{
	case '1':
		return 1;
	case '2':
		return 2;
	case '3':
		return 3;
	case '4':
		return 4;
	case '5':
		return 5;
	case '6':
		return 6;
	case '7':
		return 7;
	case '8':
		return 8;
	case'9':
		return 9;
	default:
		return 0;
	}
}

std::string GetResidueString(const std::string& str)
{
	// 上から2桁目以降で最初に0以外が現れるpositionを探す
	const size_t nonZeroPos = str.find_first_not_of("0", 1);

	if (nonZeroPos == std::string::npos)
	{
		// すべて0だった
		return "";
	}

	return str.substr(nonZeroPos);
}

long long GetOneDigitNum(const std::string& str)
{
	if (str.empty())
	{
		return 0;
	}

	return (static_cast<int>(str.size()) - 1) * 9 + ctoi(str.front());
}

long long GetTwoDigitNum(const std::string& str)
{
	if (str.empty())
	{
		return 0;
	}

	const int size = static_cast<int>(str.size());
	if (size == 1)
	{
		return 0;
	}

	long long sum = (size - 1) * (size - 2) * 81 / 2;
	for (int i = 1; i < ctoi(str.front()); ++i)
	{
		sum += (size - 1) * 9;
	}

	sum += GetOneDigitNum(GetResidueString(str));

	return sum;
}

long long GetThreeDigitNum(const std::string& str)
{
	const int size = static_cast<int>(str.size());
	if (size < 3)
	{
		return 0;
	}
	
	long long sum = (size - 1) * (size - 2) * (size - 3) * 243 / 2;
	for (int i = 1; i < ctoi(str.front()); ++i)
	{
		sum += (size - 1) * (size - 2) * 81 / 2;
	}
	sum += GetTwoDigitNum(GetResidueString(str));

	return sum;
}

int main()
{
	std::string n;
	int k = 0;
	std::cin >> n >> k;

	if (k == 1)
	{
		std::cout << GetOneDigitNum(n) << std::endl;
	}
	else if (k == 2)
	{
		std::cout << GetTwoDigitNum(n) << std::endl;
	}
	else
	{
		std::cout << GetThreeDigitNum(n) << std::endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define Pair pair<int, string>

using namespace std;

int convert_minutes(const string& s){
  int h = (s[0]-'0')*10 + (s[1]-'0');
  int m = (s[3]-'0')*10 + (s[4]-'0');
  return 60*h + m;
}

int main(){
  int N, T, t, t_;
  string t1, t2, s1, s2;
  vector<Pair> ans;
  cin >> N >> T;
  for(int i=0; i<N; ++i){
    cin >> t1 >> s1 >> t2 >> s2;
    if(i != 0){
      t_ = convert_minutes(t1);
      if(t_-t >= T) ans.push_back(make_pair(t_-t, s1));
    }
    t = convert_minutes(t2);
  }
  cout << ans.size() << endl;
  for(vector<Pair>::iterator it=ans.begin(); it!=ans.end(); ++it)
    cout << it->second << " " << it->first << endl;
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define ll long long
using namespace std;
//int main()
//{
//    int a;
//    int aa[9]={0,1,2,1,3,1,2,1,0};
//    while(cin>>a)
//    {
//        if(a%8==0)
//    {
//        printf("%d\n",3+a/8);
//    }
//    else
//        printf("%d\n",aa[a%8]);
//    }
//
//    return 0;
//}
//int main()
//{
//    int a[100005];
//    int n;
//    scanf("%d",&n);
//    for(int i=0;i<n;i++)
//        scanf("%d",&a[i]);
//    int num=1;
//    int sum=0;
//    for(int i=0;i<n;i++)
//    {
//        num=1;
//        int ii=i+1;
//        while(a[ii]>a[i])
//        {
//            num++;
//            i=ii;
//            ii++;
//        }
//        if(num%2==1)
//            sum+=num/2*num;
//        else
//            sum+=(num-1)/2*num+num/2;
//
//    }
//    printf("%d\n",sum+n);
//    return 0;
//}
int main()
{

    int n;
    ll sum=0;
    int a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n-1;i++)
        for(int k=i+1;k<n;k++)
        sum+=a[i]*a[k];
    printf("%lld\n",sum);
    return 0;
}


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

int main() {

  string w;
  cin >> w;

  map<char, int> map;//key,個数
  for (int i = 0; i < w.length(); i++) {
    map[w[i]]++;
  }

  for (auto i : map) {
    if ((i.second) % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	for(int i=0;i<4;i++){
		cin >> a >> b;
		if(a==1){
			cout << b*6000 << endl;
		}else if(a==2){
			cout << b*4000 << endl;
		}else if(a==3){
			cout << b*3000 << endl;
		}else{
			cout << b*2000 << endl;
		}
	}
}	
			


Measured memory_bytes: 3104
def dfs(i, Str, res):
    if i==3:
        if res==7:
            print(Str+"=7")
            exit()
        return
    
    dfs(i+1,Str+"+"+s[i+1],res+int(s[i+1]))
    dfs(i+1,Str+"-"+s[i+1],res-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll A[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 ll k;
 cin>>k;
 cout<<A[k-1]<<endl;
return 0;
}



Measured memory_bytes: 256