akhauriyash/Code-Regression huggingface dataset:
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    let mut f=0;
    for i in 0..b{
        if i*a%b==c{f+=1}
    }
    println!("{}",if f>0{"YES"}else{"NO"})
}


Measured memory_bytes: 4352
import copy
import heapq
N = int(input())
A = list(map(int, input().split()))

h1 = copy.deepcopy(A[:N])
x = sorted(A[N:])
h2 = x[N:]
x = x[:N]

now_w = sum(h1) - sum(x)
ans = now_w
used = []
heapq.heapify(h1)
heapq.heapify(h2)
heapq.heapify(used)

for i in range(N):
  now = A[N+i]
  heapq.heappush(h1, now)
  left = heapq.heappop(h1)
  while True:
    right_cand = heapq.heappop(h2)
    if len(used) > 0:
      x = heapq.heappop(used)
      if x == right_cand:
        continue
      else:
        heapq.heappush(used, x)
    break
      
  if right_cand >= now:
    right = right_cand
  else:
    right = now
    heapq.heappush(h2, right_cand)
    heapq.heappush(used, now)
  now_w = now_w - left + 2*now - right
  #print(ans, i, now_w, left, now, right)
  ans = max(ans, now_w)
  
print(ans)

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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;

lli w, h, mini = INT_MAX;

lli checker(lli x){
	lli minimum, r1 = x * h, t1, t2, r2, r3, t3;

	t1 = (w-x)/2;
	r2 = t1 * h;
	t2 = (w-x)-t1;
	r3 = t2*h;

	t1 = max(r1, max(r2, r3));
	t2 = min(r1, min(r2, r3));

	if(t2)
		minimum = t1-t2;

	t1 = (w-x);
	t2 = h/2;
	r2 = t1*t2;
	t3 = h-t2;
	r3 = t1*t3;

	t1 = max(r1, max(r2, r3));
	t2 = min(r1, min(r2, r3));
	if(t2)
		minimum = min(minimum, t1-t2);

	return minimum;
}
int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	cin >> w >> h;

	lli i;
	for(i = 1; i < w;++i){
		mini = min(mini, checker(i));
	}

	i = w;
	w = h;
	h = i;

	for(i = 1; i < w;++i){
		mini = min(mini, checker(i));
	}
	cout << mini << "\n";
	return 0;
}


Measured memory_bytes: 256
S=list(input())
T=list(input())
count=0
hako=[]
for i in range(len(S)-len(T)+1):
  for k in range(len(T)):
    if S[i+k]!=T[k]:
      count+=1
  hako.append(count)
  count=0
fin=min(hako)
print(fin)

Measured memory_bytes: 8904
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    ll a,b;
    cin>>a>>b;
    rep(i,1,1001)
    {
        if(floor(0.08*i)==a &&floor(0.1*i)==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
    li N;
    cin >> N;
    li F[N][5][2];
    FOR(i, 0, N) {
        FOR(j, 0, 5) {
            FOR(k, 0, 2) {
                cin >> F[i][j][k];
            }
        }
    }

    li P[N][11];
    FOR(i, 0, N) {
        FOR(j, 0, 11) {
            cin >> P[i][j];
        }
    }

    li value = -(1ll << 60); // 負の大きい数
    FOR(i, 1, 1024) {
        // 2 ^ 10ケースを確認する
        li o[10];
        FOR(j, 0, 10) {
            o[j] = (i & (1 << j)) > 0 ? 1 : 0;
        }

        li count[N];
        FOR(j, 0, N) {
            count[j] = 0; // 初期化
        }
        FOR(j, 0, N) {
            FOR(k, 0, 10) {
            count[j] += o[k] * F[j][k / 2][k % 2]; // 同時に空いている個数を足す
            }
        }

        li tempValue = 0;
        FOR(j, 0, N) {
            tempValue += P[j][count[j]];
        }
        value = max(tempValue, value);
    }
    
    cout << value << endl;
    return 0;
}


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

void solve() {
    int n;
    cin >> n;
    map<int, int> mp;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
        sum += x;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        if(mp.count(b)) {
            sum += (c - b)*mp[b];
            mp[c] += mp[b];
            mp[b] = 0;
       }
       cout << sum;
       cout << "\n";
    }

}

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


Measured memory_bytes: 7452
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector

int main(void)
{
    string s;
    cin >> s;
    string k = "keyence";

    rep(i, 8) {
        int flag = 1;
        rep(j, 7) {
            if (j < i && s[j] != k[j]) flag = 0;
            if (j >= i && s[s.length() - (7 - i) + (j - i)] != k[j]) flag = 0;
            if (!flag) break;
        }
        if (flag) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(x) (x * x * x * x * x)
using LL = long long;
using namespace std;
map<LL, LL> mp;
set<LL> st;
int main() {
	for (LL i = -1000; i <= 1000; i++) {
		LL x = f(i);
		st.insert(x);
		mp[x] = i;
	}
	LL x; cin >> x;
	for (auto b : st) {
		if (st.find(x + b) != st.end()) {
			cout << mp[x + b] << ' ' << mp[b];
			return 0;
		}
	}
}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a, b, c, d;
    string s;

    cin >> n >> a >> b >> c >> d;
    cin >> s;

    if (c < d)
    {
        bool pa[212345];
        fill(pa, pa + n + 1, false);

        pa[a] = true;
        for (int i = a; i < n; i++)
        {
            if (!pa[i])
                continue;
            if (s[i + 1 - 1] == '.')
                pa[i + 1] = true;
            if (i < n - 1 && s[i + 2 - 1] == '.')
                pa[i + 2] = true;
        }

        if (!pa[c])
        {
            cout << "No" << endl;
            return 0;
        }

        fill(pa, pa + n + 1, false);

        pa[b] = true;
        for (int i = b; i < n; i++)
        {
            if (!pa[i])
                continue;
            if (s[i + 1 - 1] == '.')
                pa[i + 1] = true;
            if (i < n - 1 && s[i + 2 - 1] == '.')
                pa[i + 2] = true;
        }

        if (!pa[d])
        {
            cout << "No" << endl;
            return 0;
        }

        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        bool pa[212345];
        fill(pa, pa + n + 1, false);

        pa[a] = true;
        for (int i = a; i < n; i++)
        {
            if (!pa[i])
                continue;
            if (s[i + 1 - 1] == '.')
                pa[i + 1] = true;
            if (i < n - 1 && s[i + 2 - 1] == '.')
                pa[i + 2] = true;
        }

        if (!pa[c])
        {
            cout << "No" << endl;
            return 0;
        }

        bool pb[212345];

        fill(pb, pb + n + 1, false);

        pb[b] = true;
        for (int i = b; i < n; i++)
        {
            if (!pb[i])
                continue;
            if (s[i + 1 - 1] == '.')
                pb[i + 1] = true;
            if (i < n - 1 && s[i + 2 - 1] == '.')
                pb[i + 2] = true;
        }

        if (!pb[d])
        {
            cout << "No" << endl;
            return 0;
        }

        for (int i = a; i <= d - 1; i++)
        {
            if ((i + 2 - 1) < s.size() && pa[i] && pb[i + 1] && (s[i + 2 - 1] == '.'))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }

        cout << "No" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 976
/*
** 左子右兄弟表示法
*/

# include <cstdio>
# include <vector>
using namespace std;

const int maxn = 100000 + 10;
const int NIL = -1;

struct Node {
    int p, l, r;
} t[maxn];

int n;

int getDepth(int u) {
    int d = 0;
    while (t[u].p != NIL) {
        ++d;
        u = t[u].p;
    }
    return d;
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);

    scanf("%d", &n);

        /*
        ** 此段为根据输入存储有根树
        */
    for (int i = 0; i < n; i++) { // 初始化有根树
        t[i].p = NIL;
        t[i].l = NIL;
        t[i].r = NIL;
    }
    int id, k;
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &id, &k);
        if (k == 0)
        {
            // t[id].l = NIL; // 此为叶节点
            continue;
        }
        int cid;
        vector<int> vc;
        vc.resize(0); // 初始化子节点vector
        for (int j = 0; j < k; j++)
        {
            scanf("%d", &cid);
            vc.push_back(cid);
        }
        t[id].l = vc[0]; // 左子节点
        for (int j = 0; j < vc.size(); j++)
        {
            t[vc[j]].p = id; // 父节点
            if (j < vc.size() - 1)
            {
                t[vc[j]].r = vc[j + 1]; // 兄弟节点
            }
        }
        t[vc[vc.size() - 1]].r = NIL; // 没有兄弟节点
    }

        /*
        ** 以下为依照顺序输出节点信息。
        */
        for (int i = 0; i < n; i++) {
            printf("node %d: parent = %d, depth = %d, ", i, t[i].p, getDepth(i));
            if (t[i].p == NIL) {
                printf("root, ");
            }
            else if (t[i].l == NIL) {
                printf("leaf, ");
            }
            else {
                printf("internal node, ");
            }
            printf("[");
            if (t[i].l != NIL) {
                int u = t[i].l;
                int flag = 0;
                while (true) {
                    if (flag++ != 0)
                        printf(", ");
                    printf("%d", u);
                    if (t[u].r == NIL)
                        break;
                    u = t[u].r; 
                }
            }
            printf("]\n");
        }
            
    return 0;
}


Measured memory_bytes: 4176
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
  for(int i = 1; i <= N; ++i) {
    int c = 0;
    int s = i;
    while(s < K) {
      s = s*2;
      c += 1;
    }
    ans += pow(0.5, c);
  }
  cout << setprecision(20) << ans/N << endl;
}

Measured memory_bytes: 512
#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>;
const int inf{int(1e9)};
int main(void){
  int x;
  cin >> x;
  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3584
h, w = map(int, input().split())
mapping = [input().strip() for i in range(h)]
dp = [[123012302103120310]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            dp[i][j] = int('#' == mapping[i][j])
 
        if j != 0:
            if mapping[i][j] == '#' and mapping[i][j-1] != '#':
                dp[i][j] = min(dp[i][j-1] + 1, dp[i][j])
            else:
                dp[i][j] = min(dp[i][j-1], dp[i][j])
        if i != 0:
            if mapping[i][j] == '#' and mapping[i-1][j] != '#':
                dp[i][j] = min(dp[i-1][j] + 1, dp[i][j])
            else:
                dp[i][j] = min(dp[i-1][j], dp[i][j])
print(dp[-1][-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
//-----------------------------------------------------
int main()
{
    string str;
    cin>>str;
    int a=str.length();
    int i=0;
    int count=0;
    for(int i=0;i<a/2;i++)
    {
        if(str[i]!=str[a-i-1])
        {
            count++;
        }
        
    }
    cout<<count;
return 0;
}

Measured memory_bytes: 256
MOD=10**9+7

N=int(input())
if N==1:
  C=int(input())
  print(2*C%MOD)
  exit()
C=list(map(int, input().split()))
C.sort(reverse=True)
out=0
tmp1=pow(2, N-1, MOD)
tmp2=pow(2, N-2, MOD)
for i in range(N):
  out+=(tmp1+tmp2*i)*C[i]
  out%=MOD
  
out=out*pow(2, N, MOD)
print(int(out%MOD))

Measured memory_bytes: 87500
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	double a, b;

	cin >> a >> b;

	if (a - b > 0)
	{
		cout << "GREATER" << endl;
	}
	else if (a - b == 0)
	{
		cout << "EQUAL" << endl;
	}
	else
	{
		cout << "LESS" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn dfs(edges: &Vec<Vec<usize>>, cur: usize, par: usize, nums: &mut Vec<i64>, k :i64, d: i64) {
    let mut pt = k;
    if d == 0 {
        pt = k-1;
    } else {
        pt = k-2;
    }

    for &nd in edges[cur].iter() {
        if nd != par {
            nums[nd] = max(0, pt);
            pt -= 1;
        }
    }

    for &nd in edges[cur].iter() {
        if nd != par {
            dfs(edges, nd, cur, nums, k, d+1);
        }
    }
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (writeln!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: i64,
      abs: [(usize1,usize1); n-1],
    }

    let mut edges = vec![vec![]; n];
    for (a, b) in abs {
        edges[a].push(b);
        edges[b].push(a);
    }

    let mut nums = vec![-1i64; n];
    nums[0] = k;
    dfs(&edges, 0, n, &mut nums, k, 0);

    const MOD: i64 = 1e9 as i64 + 7;
    let mut ans = 1;
    for i in 0..n {
        ans *= nums[i];
        ans %= MOD;
    }
    puts!("{}", ans);
}


Measured memory_bytes: 18300
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        auto m = s.split(",").map!(to!long).array().idup;
        immutable v1=m[$-2],v2=m[$-1];
        auto a = m[0..$-2];
        auto p = (a.reduce!"a+b"()*v1+(v1+v2)-1)/(v1+v2);
        foreach(i,v;a)
            if((p-=v)<=0)
                { writeln(i+1);break; }
    }
}

Measured memory_bytes: 1068
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int h;
    int w;
    
    cin >> n;
    cin >> h;
    cin >> w;
    
    int ans = (n-h+1)*(n-w+1);
    
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

#define ll long long
#define PI acos(-1.0)

ll dp[105][105005];
ll n, w, weight[105], cost[105];

ll func(ll indx, ll rest)
{
	if(indx > n) 
	{
		if(rest == 0) return 0;
		else return 10000000000;
	}
	if(rest == 0) return 0;
	if(dp[indx][rest] != -1) return dp[indx][rest];
	
	ll ans1 = 10000000000, ans2 = 10000000000;
	if(rest-cost[indx] >= 0)
	{
	    ans1 = weight[indx] + func(indx+1,rest-cost[indx]);
	}
	ans2 = func(indx+1,rest);
	return dp[indx][rest] = min(ans1,ans2); 
}


int main()
{
	
	scanf("%lld %lld", &n, &w);
	for(ll i = 1;i <= n; i++) scanf("%lld %lld", &weight[i],&cost[i]);
	memset(dp,-1,sizeof(dp));
	for(ll i = 100000; i >= 0; i--)
	{
		ll ans = func(1,i);
		if(ans <= w)
		{
			printf("%lld\n",i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 86528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll one=b*d;
	ll two=a*c;
	ll three=b*c;
	ll four=a*d;
	ll m1=max(one,two);
	ll m2=max(three,four);
	ll ans=max(m1,m2);
	cout<<ans<<endl;

}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;

#define EPS (1e-7)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define tasu(x, y) (x+y)%MOD
#define kake(x, y) (x*y)%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n);
}


std::vector<int> v = {3,5,7};
long long N; int digit; long long ans = 0;
set<long long> visited;


void dfs(int num, int d){

	string num_str = to_string(num);
	bool three = false, five =false, seven = false;
	for(int i=0; i<num_str.length(); i++){
		if(num_str[i] == '3'){
			three = true;
		} else if (num_str[i] == '5'){
			five = true;
		} else if (num_str[i] == '7'){
			seven = true;
		} else {
			seven = false;
			break;
		}
	}
	if(three && five && seven){
		ans++;
	}

	visited.insert(num);

	for(int i=0; i<3; i++){
		if(num + v[i]*pow(10, d) > N) continue;
		if(s_exists(num + v[i]*pow(10, d), visited) == true) continue;
		dfs(num + v[i]*pow(10, d), d-1);
	}
}


int main(){
	cin >> N;
	digit = to_string(N).length();

	if(digit <= 2){
		cout << 0 << endl;
		return 0;
	}

	while(digit >= 3){
		for(int i=0; i<3; i++){
			if(v[i]*digit < N){
				//cout << v[i]*pow(10,digit-1) << endl; -> 300
				dfs(v[i]*pow(10,digit-1), digit-2);
			}
		}
		digit--;
	}	

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

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

int main(){
    vector<int> x(5);
    for (int i = 0; i < 5; i++){
        cin >> x[i];
    }
    int p = 1;
    for (int i = 0; i<5; i++){
        if(x[i]!=0) p += 1;
        else break;
    }
    cout << p;
}

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

const int maxSize = 10000000;
long long numFactors[maxSize + 5];

int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i * i <= N; i++)
	{
		for(int j = i * i; j <= N; j += i)
		{
			numFactors[j]++;
			if(j != i * i)
				numFactors[j]++;
		}
	}
	
	long long ans = 0;
	for(int i = 1; i <= N; i++)
		ans += numFactors[i] * i;
		
	printf("%lld", ans);
}


Measured memory_bytes: 81924
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void)
{
    int n;
    char w[100][11];
    int i, j;
    bool ans = true;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        scanf("%s", w[i]);
    }

    for (i=0; i<n-1; i++)
    {
        if (w[i][strlen(w[i])-1] != w[i+1][0]){
            ans = false;
        }
    }

    for (i=0; i<n; i++)
    {
        for (j=i+1; j<n; j++)
        {
            if (strcmp(w[i], w[j]) == 0) {
                ans = false;
            }
        }
    }

    if (ans == true) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

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

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

	int s1 = a * b;
	int s2 = c * d;
	int answer = s1 <= s2 ? s2 : s1;

	cout << answer << endl;	
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
const int N=200005;
int t[N],n,con[129];
bool used[N];
char str[N];
vector<int>g[129];
int lb(int x)
{
    return x&(-x);
}
int ques(int x)
{
    int r=0;
    for(int i=x;i>0;i-=lb(i))
        r+=t[i];
    return r;
}
void update(int x,int v)
{
    for(int i=x;i<=n;i+=lb(i))
        t[i]+=v;
}
int main()
{
    scanf("%s",str+1);
    n=strlen(str+1);
    for(int i=1;i<129;i++)
        g[i].clear();
    for(int i=1;i<=n;i++)
    {
        con[str[i]]++;
        g[str[i]].push_back(i);
    }
    int flag=0;
    for(int i=0;i<26;i++)
    {
        if(con['a'+i]%2) 
			flag++;
        if(con['A'+i]%2) 
			flag++;
    }
    if(flag>1)
        puts("-1");
    else
    {
		for(int i=1;i<=n+1;i++)
			update(i,1);
		long long ans=0ll;
		int v,u,size;
		char s;
		for(int i=1;i<=n;i++)
			if(!used[i])
			{
				s=str[i];
				size=g[s].size();
				u=g[s][size-1];
				if(i==u)
					ans+=(ques(n)-ques(i))/2;
				else
					ans+=ques(n)-ques(u);
				update(u,-1);
				update(i,-1);
				used[i]=used[u]=1;
				g[s].erase(g[s].end()-1);
			}
		printf("%lld\n", ans);
    }
    return 0;
}

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

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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	rep(i, 100) {
		rep(j, n) {
			if (h[j] == 0) continue;
			while (h[j] > 0) {
				h[j]--;
				j++;
			}
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3552
import java.util.*

fun main(args: Array<String>) {

    val (N, Q) = readLine()!!.split(" ").map(String::toInt)

    val nodes = Array(N) { ArrayDeque<Int>() }
    val counter = IntArray(N)
    val ans = IntArray(N)
    val check = BooleanArray(N)

    repeat(N - 1) {
        val (l, r) = readLine()!!.split(" ").map(String::toInt)
        nodes[l - 1].add(r - 1)
        nodes[r - 1].add(l - 1)
    }

    repeat(Q) {
        val (node, count) = readLine()!!.split(" ").map(String::toInt)
        counter[node - 1] += count
    }

//    nodes.forEachIndexed { i, n ->
//        println("$i:${n.joinToString(",")}")
//    }
//    counter.forEach(::println)

    val stack = ArrayDeque<Pair<Int, Int>>()
    ans[0] = counter[0]
    stack.addAll(nodes[0].map { Pair(0, it) })
    check[0] = true
    while (stack.isNotEmpty()) {
        val (parent, node) = stack.pollLast()!!
        if (check[node]) {
            continue
        }
        counter[node] += counter[parent]
        ans[node] = counter[node]
        check[node] = true
        stack.addAll(nodes[node].map { Pair(node, it) })
    }

    ans.joinToString(" ").let(::println)
}

Measured memory_bytes: 144164
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        int[] a = new int[n];
        for(int i=0 ; i<n ; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }

        int min = Integer.MAX_VALUE;
        int count = 0;
        for(int i=0 ; i<n ; i++) {
            if(a[i] <= min) {
                min = a[i];
                count++;
            }
        }

        pw.print(count);

        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 46428
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int gcd(int x, int y) {
    if (y == 0)return x;
    else return gcd(y, x % y);
}
int main(){
    int n,X;
    cin >> n >> X;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    x.push_back(X);
    sort(All(x));
    vector<int> d;
    rep1(i,1,x.size()){
        d.push_back(x[i] - x[i - 1]);
    }
    int g = d[0];
    rep(i, d.size()) g = gcd(g, d[i]);
    cout << g << endl;
}

Measured memory_bytes: 1528
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end


nn = inputs[0][0]
lst = inputs[1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag

end

sum = 0
for i in 0..nn-2
  for j in i+1..nn-1
    sum += lst[i]*lst[j]
  end
end

puts sum

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

const int z = 1e9+7;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}

int inv(int a) {
    return fp(a, z - 2);
}

int main() {
    int b, w;
    cin >> b >> w;

    int pw[b+w+1], pb[b+w+1];
    for (int i = 0; i < w; i++) {
        pw[i] = 0;
    }
    int c = 1, inv2 = inv(2);
    int i2k = fp(inv2, w);
    for (int i = w; i <= b + w; i++) {
        pw[i] = (pw[i-1] + 1ll * i2k * c) % z;
        c = 1ll * c * i % z * inv(i - w + 1) % z;
        i2k = 1ll * i2k * inv2 % z;
    }

    for (int i = 0; i < b; i++) {
        pb[i] = 0;
    }
    c = 1, i2k = fp(inv2, b);
    for (int i = b; i <= b + w; i++) {
        pb[i] = (pb[i-1] + 1ll * i2k * c) % z;
        c = 1ll * c * i % z * inv(i - b + 1) % z;
        i2k = 1ll * i2k * inv2 % z;
    }

    for (int i = 0; i < b + w; i++) {
        int ans = (pw[i] + 1ll * (1 + z + z - pb[i] - pw[i]) * inv2) % z;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int main(){
    cin>>n>>s;
    int ans=n;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1])ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val X = in.nextInt

  val primes: Stream[Int] = 2 #:: (Stream.from(3, 2) filter {n =>
    primes.takeWhile(_ <= Math.sqrt(n).toInt).forall(n % _ != 0)
  })

  println(primes.dropWhile(_ < X).head)
}

Measured memory_bytes: 43092
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, top;
    String s;
    char az;

    s = sc.next();
    az = 'A'; top = 0;
    for(i = 0;i < s.length();i++){
      if(s.charAt(i) == az){
        top++;
        if(az == 'A')az = 'Z';
        else if(az == 'Z')az = 'A';
      }
    }
    if(top < 2)out.println("-1");
    else{
      for(i = 0;i < top / 2;i++)out.print("AZ");
      out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26248
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;

}

int main(){
    ll n; cin >> n;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll k = 1;
    rep(i,n-1)k = (k * (i+1)) % MOD;
    vector<ll> dp(n-1), sum(n,0);
    rep(i,n-1)dp[i] = (k * modinv((i+1),MOD)) % MOD;
    rep(i,n-1)sum[i+1] = (sum[i] + dp[i]) % MOD;
    ll ans = 0;
    rep(i,n-1){
        ll dis = x[i+1] - x[i];
        ll temp = sum[i+1] - sum[0];
        ans = (ans + (dis * temp) % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

set<string> w;
int n;

void add_str(int len, int level, string s) {
    if (len >= n) {
        w.insert(s);
        return;
    }
    REP(i,level+2) {
        string tmp(s);
        tmp += (char)('a' + i);
        //debug(tmp);
        add_str(len+1, max((int)i,level), tmp);
    }
}

int main()
{
    cin>>n;
    add_str(1,0,"a");

    int cnt = 0;
    REPITR(itr,w) {
        cout<<*itr<<endl;
        cnt++;
    }
    //debug(cnt);

    return 0;
}


Measured memory_bytes: 12416
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    vector <int> lcp = lcp_array(s, suffix_array(s));
    ll ans = 0;
    ll n = s.length();
    for (int i = 0; i < n - 1; i++) ans -= lcp[i];
    ans += n * (n + 1) / 2;
    cout << ans;
}


Measured memory_bytes: 15652
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(void) {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    vector<string> a;
    for (int i = 0; i < n; i++) {
        string tmp = "";
        for (int j = i; j < min(n, i + 5); j++) {
            tmp += s[j];
            a.push_back(tmp);
        }
    }
 
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt();
      long debt = 100000;
      for (int i = 0; i < n; i++) {
        debt *= 105;
        if (debt % 100000 != 0) {    
          debt = debt / 100000;
          debt = debt * 1000 + 1000;
        } else {
          debt /= 100;
        }
      }
      
      out.println(debt);
      
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int p,q,r; cin>>p>>q>>r;
    cout<<min({p+q,q+r,r+p})<<endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
using namespace std;
int main()
{
  ll k,i;
  cin>>k;
  string s;
  cin>>s;
  if(k>=s.size())
    cout<<s<<endl;
  else
  {
    for0(i,k)
      cout<<s[i];
    cout<<"..."<<endl;
  }

}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[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)*}
    };

    ($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 {
    ($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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N:usize,
        M:usize,
    }
    let mut ans = 0;
    if N > 0 {
        ans += N * (N - 1) / 2;
    }
    if M > 0 {
        ans += M * (M - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    ll h;cin >> h;
    ll ans = 0;
    int i = 0;
    while(h!=0) {
        h/=2;
        ans+=pow(2,i);
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

x,a,b = rli()
if(a-b >= 0):
    print("delicious")
elif(b-a <= x):
    print("safe")
else:
    print("dangerous")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
using namespace std;
static const long long int INF=1e9+7;
int main()
{
	int n;
	int a[10004];
	while(scanf("%d",&n)!=EOF)
	{
		memset(a,0,sizeof(a));
		
		for(int i=2;i<=n;i++)
		{
		    int m=i;
			for(int j=2;j<=m;j++)
			{
				while(m%j==0)
				{
					a[j]++;
					m/=j;
				}
			}
			if(m!=1)
			a[m]++;
			
		}
		long long int ans=1;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=0)
			ans=(ans*(a[i]+1))%INF;
		}
		printf("%lld\n",ans);
	}
return 0;
}

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

struct Graph
{
    vector<int> f;
};

int main()
{
    int n, m, a, b;
    bool judgeFriend[501];
    Graph s[501];

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;

        for( int i = 0; i < 501; i++ )
        {
            judgeFriend[i] = 0;
            s[i].f.clear();
        }

        for( int i = 0; i < m; i++ )
        {
            cin >> a >> b;
            s[a].f.push_back(b);
            s[b].f.push_back(a);
        }

        for( int i = 0; i < s[1].f.size(); i++ )
        {
            judgeFriend[s[1].f[i]] = 1;
            for( int j = 0; j < s[s[1].f[i]].f.size(); j++ )
                if( s[s[1].f[i]].f[j] != 1 )
                    judgeFriend[s[s[1].f[i]].f[j]] = 1;
        }

        int cnt = 0;
        for( int i = 2; i <= n; i++ )
            if( judgeFriend[i] )
                cnt++;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3260
#include<stdio.h>

int main(void)
{
  int n,c,i;
  char s[11000];
  scanf("%d%s",&n,s);
  for(i=0;s[i]!='\0';i++){
    c = s[i]-'A'+n;
    printf("%c",c%26+'A');
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

LL n, a, b;
VL h;

LL aa(LL x, LL y) { return (x + y - 1) / y; }

bool check(LL x) {
	LL cnt = 0;
	rep(i, n) {
		if (h[i] > b * x) {
			cnt += aa(h[i] - b * x, a - b);
		}
	}
	return cnt <= x;
}

int main() {
	cin >> n >> a >> b;
	h = VL(n); rep(i, n)cin >> h[i];

	LL ma = (accumulate(all(h), 0LL) / b) + 1;

	LL l = -1, r = ma + 10;
	while (r - l > 1) {
		LL mid = l + (r - l) / 2;
		if (check(mid))r = mid;
		else l = mid;
	}

	Cout(r);
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
    int i,lenS,lenP;
    char P[100],S[100],X[200];
    char *pp;

    scanf("%s %s",S,P);
    lenS=strlen(S);
    lenP=strlen(P);
    strcpy(X,S);
    strcpy(X+lenS,S);

    for(i=0,pp=X;;i++,pp++){
        if(i>=lenS){
            printf("No\n");
            break;
        }
        if(!strncmp(pp,P,lenP)){
            printf("Yes\n");
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 2104
N, M = map(int, input().split())
b = [1] * (N + 1)
for i in range(M):
    a = int(input())
    b[a] = 0
c = [0] * (N + 1)
c[0] = 1
c[1] = b[1]
for i in range(2, N + 1):
    c[i] = (b[i] * (c[i - 1] + c[i - 2])) % 1000000007
print(c[N])

Measured memory_bytes: 46680
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    string S;
    cin >> S;

    string prev;
    string current;
    ll ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        current += S[i];

        if (current != prev) {
            ++ans;
            prev = current;
            current = "";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 832
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
#define N 100005
using namespace std;

struct node{
	int v,w,next;
}e[N<<3];
int head[N],tot,k,dis[N];
bool vis[N];
void init()
{
	memset(head,-1,sizeof head);
	tot=0;
}
void addedge(int u,int v,int w)
{
	e[tot].v=v;
	e[tot].w=w;
	e[tot].next=head[u];
	head[u]=tot++;
}

int Dijkstra(int st)
{
	memset(dis,INF,sizeof dis);
	memset(vis,0,sizeof vis);
	queue<int> que;
	que.push(st);
	vis[st]=1;
	dis[st]=0;
	while(que.size())
	{
		int u=que.front();que.pop();
		vis[u]=0;
		for(int i=head[u];i!=-1;i=e[i].next)
		{
			int v=e[i].v;
			if(dis[v]>dis[u]+e[i].w)
			{
				dis[v]=dis[u]+e[i].w;
				if(!vis[v])
				{
					vis[v]=1;
					que.push(v);
				}
			}
		}
	}
	return dis[0];
}

int main()
{
	scanf("%d",&k);
	init();
	for(int i=0;i<k;i++)
	{
		addedge(i,(i+1)%k,1);
		addedge(i,i*10%k,0);
	}
	Dijkstra(1);
	printf("%d\n",dis[0]+1);
	return 0;
}

Measured memory_bytes: 4480