akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <vector>

using namespace std;

typedef unsigned int ui;
typedef unsigned long long ull;

int main(void)
{
    ui n, c, k;
    cin >> n >> c >> k;
    std::vector<ui> t;
    for (size_t i = 0; i < n; ++i) {
        ui temp;
        cin >> temp;
        t.push_back(temp);
    }
    if (c == 1) {
        cout << n << endl;
        return 0;
    }
    sort(t.begin(), t.end());
    ull buses = 0UL;

    ui first_t = t[0];
    ui current_load = 1;
    for (size_t i = 1; i < n; ++i) {
        if (current_load == c || first_t + k < t[i]) {
            ++buses;
            first_t = t[i];
            current_load = 1;
        } else {
            ++current_load;
        }
    }

    cout << ++buses << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,j,k,n,s;
  char ca[201],can[201];
 
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
      
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
 
    printf("%s\n", ca);
  }
 
  return 0;
}


Measured memory_bytes: 2048
n, m = [int(i) for i in input().split()]
a = {int(i) for i in input().split()}
b = {int(i) for i in input().split()}

A = a & b
B = a | b

print('{} {}'.format(len(A),len(B)))
for a in sorted(A):
    print(a)
for b in sorted(B):
    print(b)



Measured memory_bytes: 39164
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k = 180;
    vector<int> a(k);
    iota(a.begin(), a.end(), 1);
    for (int i = 1; i < k; ++i) {
        a[i] += a[i - 1];
    }
    for (int i = 1; i < k; ++i) {
        a[i] += a[i - 1];
    }
    vector<int> o;
    for (int i = 0; i < k; ++i) {
        if (a[i] % 2 == 1)
            o.push_back(a[i]);
    }
    int l = o.size();
    vector<int> dp(1000001, 1000000);
    dp[0] = 0;
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < 1000000; ++j) {
            if (j + a[i] <= 1000000)
                chmin(dp[j + a[i]], dp[j] + 1);
            else
                break;
        }
    }
    vector<int> dpo(1000001, 1000000);
    dpo[0] = 0;
    for (int i = 0; i < l; ++i) {
        for (int j = 0; j < 1000000; ++j) {
            if (j + o[i] <= 1000000)
                chmin(dpo[j + o[i]], dpo[j] + 1);
            else
                break;
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0)
            return 0;
        cout << dp[n] << " " << dpo[n] << "\n";
    }
    return 0;
}


Measured memory_bytes: 10648
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

n, a, b = inpl()
l = n // (a + b)
m = n % (a + b)
print(a * l + min(m, a))

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

void solve (int u) {

    int n;
    cin >> n;

    int a [n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }    
    
    vector <int> dp (n, 1e9 + 5);

    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + 2; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    } 

    cout << dp[n - 1] << "\n";
//    cout << "Case #" << k << ": " << count << "\n";

}

int main () {

    ios::sync_with_stdio(0);
    cin.tie(0);

    //int t;
    //cin >> t;
    //int k = 1;
    //while (t--) {
    //    solve(k);
    //    k++;
    //}

    solve(0);
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    long long int n,k,c=0;
    cin>>n;
    k=1000000;
    vector<int>a(1000000);
    for(long long int i=0;i<n;i++){
        cin>>a[i];
        if(k>a[i]){
            k=a[i];
            c++;
        }
    }
    cout<<c<<endl;
   return 0;
}

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

int main()
{
  int a[3];
  int n, x, y, z;

  x = y = z = n = 0;
  while (cin >> a[0] >> a[1] >> a[2]){
    sort(a, a + 3);
    int s = a[0];
    int d = a[1];
    int f = a[2];

    if (s + d <= f){
      cout << n << " " << x << " "<< y << " "<< z << endl;
      return 0;
    }
    n++;

    if (s * s + d * d == f * f){
      x++;
    }
    if (s * s + d * d > f * f){
      y++;
    }
    if (s * s + d * d < f * f){
      z++;
    }
  }

  cout << n << " " << x << " " << y << " " << z << endl;

  return 0;
}

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


int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int count = 0;
  while(A >= B){
    B *= 2;
    count++;
  }
  while(B >= C){
    C *= 2;
    count++;
  }
  if(count <= K){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 3e3;

int n, x[N], m, y[N], dp[N][N];

void solve(){
   for (int i = 0; i <= n; ++i)
   {
      for (int j = 0; j <= m; ++j)
      {
         dp[i][j]= ( ((i<1) | (j<1)) ? 1 : (dp[i-1][j]+dp[i][j-1]) % mod - (x[i]==y[j]?0:dp[i-1][j-1]))%mod;
         dp[i][j] %= mod;
         if(dp[i][j] < 0)dp[i][j] += mod;
      }
   }

   cout<<dp[n][m];
   exit(0);
}

int32_t main(){_

   #ifdef LOCAL
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
   #endif

   cin>>n>>m; 

   for (int i = 1; i <= n; ++i)
   {
      cin>>x[i];
   }

   for (int i = 1; i <= m; ++i)
   {
      cin>>y[i];
   }
   
   solve();

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works


Measured memory_bytes: 47104
N=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))



plusdiff=[]
minusdiff=[]
diffcount=0
Asum=0
Bsum=0

for i in range(N):
  Asum+=A[i]
  Bsum+=B[i]
  if A[i]-B[i]>0:
    plusdiff.append(A[i]-B[i])
  elif A[i]-B[i]<0:
  	minusdiff.append(abs(A[i]-B[i]))


if len(minusdiff)==0:
  print(0)
  exit()

if Asum<Bsum:
  print(-1)
  exit()

plusdiff.sort(reverse=True)
minusdiff.sort(reverse=True)
  
#print(plusdiff,minusdiff)

answer=0
flag=2
while(len(minusdiff)!=0):
  answer+=flag
  if plusdiff[0]>minusdiff[0]:
    plusdiff[0]=plusdiff[0]-minusdiff[0]
    flag=1
    minusdiff.pop(0)
  elif plusdiff[0]==minusdiff[0]:
    plusdiff.pop(0)
    minusdiff.pop(0)
    flag=2
  else:
    minusdiff[0]=minusdiff[0]-plusdiff[0]
    plusdiff.pop(0)
  
    
print(answer)

Measured memory_bytes: 18360
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

int main(void)
{
    long long N, K;
    cin >> N >> K;
    N %= K;
    while (abs(N - K) < N)
    {
        N = abs(N - K);
    }
    cout << N << "\n";
}

Measured memory_bytes: 3632
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
const int maxn = 200111*2;
const ll inf = 1e18;
int n;
ll K;
int a[maxn];
int len[maxn];
int lst[maxn];
ll go[60][maxn], glen[60][maxn];
vector<int> ans;
map<int,int> mp;
void add(int x)
{
	if (mp[x]==0)
	{
		ans.PB(x);
		mp[x]++;
	}
	else
	{
		while (mp[x]>0)
		{
			mp[ans.back()]--;
			ans.pop_back();
		}
	}
}
int main()
{
	cin>>n>>K;
	for (int i=0; i<n; i++) scanf("%d", &a[i]), a[n+i] = a[i];
	int r = n+n;
	for (int i=n+n-1; i>=0; i--)
	{
		if (lst[a[i]])
		{
			len[i] = lst[a[i]]-i+1;
		}
		lst[a[i]] = i;
	}
	for (int i=0; i<n; i++) cerr<<len[i]<<" "; cerr<<endl;
	for (int i=0; i<n; i++)
	{
		go[0][i] = (i+len[i])%n;
		glen[0][i] = len[i];
	}
	for (int i=1; i<60; i++)
	{
		for (int j=0; j<n; j++)
		{
			go[i][j] = go[i-1][go[i-1][j]];
			glen[i][j] = min(inf, glen[i-1][j]+glen[i-1][go[i-1][j]]);
		}
	}
	K = 1ll*K*n;
	int cur = 0;
	for (int i=59; i>=0; i--)
	{
		if (glen[i][cur]<=K)
		{
			K -= glen[i][cur];
			cur = go[i][cur];
		}
	}
	for (int i=0; i<K; i++)
	{
		add(a[(cur+i)%n]);
	}
	for (auto x : ans) printf("%d ", x);
	return 0;
}

Measured memory_bytes: 391028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1000;
long long shuzi[maxn],mi2[20]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096},ans; 
long long mi10[20]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000};
int main()
{
	char a[maxn];
	cin>>a;
	int len=strlen(a);
	for(int i=0;i<len;i++)
		shuzi[i+1]=a[i]-'0';
	ans=shuzi[len]*mi2[len-1];
	for(int i=len-1;i>=1;i--)
	{
		 for(int j=len-2;j>=i-1;j--)
		{
			int ai=shuzi[i];
			int mi2lenj=mi2[len-j];
			int mi10j2=mi10[j-2];
			ans+=shuzi[i]*mi2[j]*mi10[len-j-2];
		}
		ans+=shuzi[i]*mi2[i-1]*mi10[len-i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):
    uf = UnionFind(N)
    for xx, yy in zip(x, y):
        uf.union(xx-1, yy-1)
    ans = 0
    for members in uf.all_group_members().values():
        s = {p[m]-1 for m in members}
        ans += sum(m in s for m in members)
    return ans

# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        res = {}
        for i in range(self.n):
            r = self.find(i)
            if r not in res:
                res[r] = []
            res[r].append(i)
        return res
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(solve(N, M, p, x, y))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 41172
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    -- スペース区切り整数の入力
    l1 <- map strToInt . words <$> getLine
    l2 <- map strToInt . words <$> getLine
    -- 出力
    putStrLn $ show $ solve l1 l2 n
solve :: [Int] -> [Int] -> Int -> Int
solve l1 l2 n = last (ans!!1)
    where
        ans = [[dp k m | m <- [0..(n-1)]] | k <- [0,1]]
        dp 0 0 = l1!!0
        dp 1 0 = l1!!0 + l2!!0
        dp 0 m = dp 0 (m-1) + l1!!m
        dp 1 m = max (dp 0 m) (dp 1 (m-1)) + l2!!m


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	bool S[200000];

	void Solve() {
		UL N; cin >> N;
		UL A, B, C, D; cin >> A >> B >> C >> D;
		A--; B--; C--; D--;
		rep(i, N) { char c; cin >> c; S[i] = c == '#'; }
		if (D < C) {
			UL ok = false;
			for (UL i = B; i <= D; i++) {
				if (i == N - 1) continue;
				if (!(S[i - 1] || S[i] || S[i + 1])) ok = true;
			}
			if(!ok) { cout << "No" << endl; return; }
		}
		for (UL i = A; i < C; i++) {
			if (S[i] && S[i + 1]) { cout << "No" << endl; return; }
		}
		for (UL i = B; i < D; i++) {
			if (S[i] && S[i + 1]) { cout << "No" << endl; return; }
		}
		cout << "Yes" << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 384
n = int(input())
p = list(map(int, input().split()))

c=0
for i in range(1,n-1):
	if p[i-1]<p[i] and p[i]<p[i+1]:	c+=1
	if p[i+1]<p[i] and p[i]<p[i-1]:	c+=1

print(c)


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

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }
};

struct seg_node {
	using M = RMQ;
	using T = typename M::type;
	using U = int;

	T val;

private:
	U lazy;

public:
	seg_node() : val(0), lazy(0) {}
	void update(U v) {
		val += v;
		lazy += v;
	}
	void push(seg_node& l, seg_node& r) {
		if (!lazy) return;
		l.update(lazy);
		r.update(lazy);
		lazy = 0;
	}
	bool is_updated() const {
		return lazy;
	}

};

class segment_tree {
	using M = typename seg_node::M;
	using T = typename seg_node::T;
	using U = typename seg_node::U;
	const int h, n;
	vector<seg_node> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].val = M::op(data[node << 1].val, data[(node << 1) | 1].val);
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {}
	void update(int l, int r, U val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].val);
			if (r & 1) res2 = M::op(data[--r].val, res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	segment_tree sst(n);
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			sst.update(s, t, x);
		}
		else {
			int s, t;
			cin >> s >> t;
			printf("%d\n", sst.find(s, t));
		}
	}
	return 0;
}



Measured memory_bytes: 5144
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    double n, m, d;
    cin >> n >> m >> d;
    double t;
    if(d != 0.0)t = (n-2.0*d)*2.0 + 2.0*d;
    else t = n;
    double ans = (t/n)*(m-1.0)/n;
    // cout << "t "  << t << endl;
    printf("%.12f\n", ans);
}

Measured memory_bytes: 256
from collections import defaultdict

CHARS = '0123456789'

def binarySearch(a, val):
    left, right = -1, len(a)
    while left + 1 < right:
        mid = (left + right) >> 1
        if a[mid] <= val:
            left = mid
        else:
            right = mid
    return a[right] if right != len(a) else -1

def canForm(ch1, ch2, ch3):
    if not indices[ch1] or not indices[ch2] or not indices[ch3]:
        return False
    idx1 = indices[ch1][0]
    idx2 = binarySearch(indices[ch2], idx1)
    if idx2 == -1:
        return False
    idx3 = binarySearch(indices[ch3], idx2)
    return idx3 != -1

n = int(input())
s = input()
indices = defaultdict(list)
for i, ch in enumerate(s):
    indices[ch].append(i)
ret = 0
for ch1 in CHARS:
    for ch2 in CHARS:
        for ch3 in CHARS:
            if canForm(ch1, ch2, ch3):
                ret += 1
print(ret)

Measured memory_bytes: 4724
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[10][10],dp[123][10];

int main(void){
	int h,w,k,i,j,m;
	bool flag,b[10];
	fill(a[0],a[10],0ll);
	fill(dp[0],dp[123],0ll);
	++dp[0][0];
	cin >> h >> w >> k;
	--k; --w;
	for(i=0; i<(1<<w); ++i){
		if(!w){
			a[w][w] = 1ll;
			break;
		}
		flag = true;
		for(j=0; j<w; ++j){
			if(i&(1<<j)){
				b[j] = true;
			}else{
				b[j] = false;
			}
		}
		for(j=1; j<w; ++j){
			if(b[j-1] && b[j]){
				flag = false;
				break;
			}
		}
		if(!flag){
			continue;
		}
		for(j=0; j<w; ++j){
			if(b[j]){
				++a[j][j+1];
				++a[j+1][j];
			}
		}
		for(j=1; j<w; ++j){
			if(!(b[j-1] || b[j])){
				++a[j][j];
			}
		}
		if(!b[0]){
			++a[0][0];
		}
		if(!b[w-1]){
			++a[w][w];
		}
	}
	++w;
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			add_mod(dp[i+1][j],(dp[i][j]*a[j][j])%MOD);
		}
		for(j=1; j<w; ++j){
			add_mod(dp[i+1][j],(dp[i][j-1]*a[j-1][j])%MOD);
			add_mod(dp[i+1][j-1],(dp[i][j]*a[j][j-1])%MOD);
		}
	}
	cout << (dp[i][k]) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
int main()
{
//    freopen("1 21.in","r",stdin);
//    freopen("1 21.out","w",stdout);
    
    char a[20],b[20];
    scanf("%s%s",a,b);
    int lena=strlen(a),lenb=strlen(b);
    
    int step=0;
    for(int i=lena;i<=lena+lenb-1;i++)
        a[i]=b[step],step++;
    
    int c=0; int p=1;
    for(int i=lena+lenb-1;i>=0;i--)
        c+=(a[i]-'0')*p,p*=10;
    
    int d=(int)floor((double)sqrt(c));
    if(c==d*d) printf("Yes");
    else printf("No");
    return 0;
}
        
    
    


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n, k;
int a[200002];

int main () {

	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	ll sol = 0;
	for (int i = 0; i < n-k; i++) {
		sol += a[i];
	}
	
	cout << sol;

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = N % 10
if S ==3:
    print("bon")
elif S == 0:
    print("pon")
elif S == 1:
    print("pon")
elif S == 6:
    print("pon")
elif S == 8:
    print("pon")    
else:
    print("hon")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    string s;
    cin>> s;
    int val = 0;
    rep(i, 0, s.size()){
        int cur = s[i] - '0';
        val += cur;
        val %= 9;
    }
    if(val)
        cout<< "No\n";
    else
        cout<< "Yes\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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


int main() {
    int x, n;
    cin >> x >> n;
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    vector<int> a(n);
    rep(i, n){
        cin >> p[i];
        a[i] = abs(p[i] - x);
    }

    sort(a.begin(), a.end());
    int diff = 0;
    for(int i = 0; i < n;i ++){
        if(i <= 2*diff && a[i] == diff){
            if(i == 2*diff){
                diff++;
            }
        }
        else{
            break;
        }
    }


    if(diff == 0){
        cout << x << endl;
        return 0;
    }

    rep(i, n){
        if(p[i] == x - diff || p[i] == x + diff){
            diff = p[i] - x;
            cout << x - diff << endl;
            return 0;
        }
    }

    cout << x - diff << endl;

    return 0;
}

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

int main()
{
    int a,b,c;cin>>a>>b>>c;
    char e =(max(a,b)-min(a,b))<(max(a,c)-min(a,c))?'A':'B';
    cout<<e;
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
s = input()

def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') - n) % 26 + ord('A')))
        # a - z
        elif ('a' <= ch and ch <= 'z'):
            ns.append(chr((ord(ch) - ord('a') - n) % 26 + ord('a')))
        # 0 - 9
        elif ('0' <= ch and ch <= '9'):
            ns.append(chr((ord(ch) - ord('0') - n) % 10 + ord('0')))
        # no change for other characters
        else:
            ns.append(ch)
    return "".join(ns)

print(caesar(s,26-n))


Measured memory_bytes: 3192
H, W = map(int, input().split())
s = [[] for i in range(H)]
num = 0
judge = 0
start = []
for i in range(H):
    s[i] = input()
    if '#' in s[i]:
        num += s[i].count('#')

if num == 0:
    print('Yes')
else:
    for y in range(H):
        for x in range(W):
            flag = False
            if s[y][x] == '#':
                for dy, dx in [1, 0], [-1, 0], [0, 1], [0, -1]:
                    if 0 <= y + dy <= H-1 and 0 <= x+dx <= W-1:
                        if s[y+dy][x+dx] != '#':
                            continue
                        else:
                            flag = True
                if flag == True:
                    judge += 1
                    
    if num == judge:
        print('Yes')
    else:
        print('No')      

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void input(){return;}
template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

template<typename First,typename Second> void inputTwoVector(std::vector<First> &first,std::vector<Second>& second){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i] >> second[i];
    }
}

bool isRound(std::string s){
    for(int i = 0;i < (int)s.size() / 2;++i){
        if(s[i] != s[s.size() - i - 1]){
            return false;
        }
    }
    return true;
}

void calculate(){
    int A,B;
    input(A,B);
    int res = 0;
    for(int i = A;i <= B;++i){
        std::string s = std::to_string(i);
        if(isRound(s)) res++;
    }
    std::cout << res << '\n';
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 50

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

int main()
{
    int n;
    
    scanf("%d", &n);
    
    printf("%d", n*n*n);
    
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int calc(int a, int n) {
  vector<int> v(n);
  REP(i, n) {
    v[i] = a % 10;
    a /= 10;
  }
  sort(begin(v), end(v));
  int mn = 0;
  int mx = 0;
  REP(i, n) {
    int j = n - i - 1;
    mn = 10 * mn + v[i];
    mx = 10 * mx + v[j];
  }
  return mx - mn;
}

int main() {
  for (int a, l; cin >> a >> l, l;) {
    map<int, int> mp;
    REP(i, 21) {
      if (mp.find(a) != end(mp)) {
        cout << mp[a] << ' ' << a << ' ' << i - mp[a] << endl;
        break;
      }
      mp[a] = i;
      a = calc(a, l);
    }
  }
}



Measured memory_bytes: 3040
#include<stdio.h>

int main(){
	int A;
	int B;
	scanf("%d %d",&A,&B);

	if(A>=13){
		printf("%d",B);
	}else if(A<13&&A>=6){
		printf("%d",B/2);
	}else{
		printf("0");
	}

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n;
	cin >> n;
	while(n)
	{
		if(n % 10 == 7)
			ret("Yes");		
		n /= 10;
	}
	ret("No");
}


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

signed main(){
  int N;
  cin>>N;
  rep(i,N+1){
    int X=i*1.08;
    if(X==N){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

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

int main() { 
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
 for(int i = 0;i <= A;i++){
   for(int j = 0;j <= B;j++){
     for(int k = 0;k <= C;k++){
       if(((500*i)+(100*j)+(50*k)) ==X){
         count++;
       }
     }
   }
 }
 cout << count << endl;
}

Measured memory_bytes: 256
#coding utf-8
import math
N,K=map(int,input().split())
ans=0
A=[]

while(K>0):
  A.append(K)
  if K==1:
    K-=1
  K=math.ceil(K/2)

x=1/N

for i in range(len(A)):
  if N>=A[i] and ans==0:
    ans +=(N-A[i]+1)*x*((1/2)**i)
  elif N>=A[i] and ans>0:
    ans +=(A[i-1]-A[i])*x*((1/2)**i)
  

print(ans)

Measured memory_bytes: 3064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    let mut x = 1;
    loop {
        if x*x>n {
            x -= 1;
            break;
        }
        x += 1;
    }

    println!("{}", x*x);

}


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

int main()
{
  long int N;

  cin >> N;

  long int count = 0;

  for (int i = 1; i <= N; i++)
  {
    if (i % 3 != 0 && i % 5 != 0)
    {
      count += i;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<pair<int,int> >a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i).first>>a.at(i).second;
    }
    int ans=n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int cnt=0;
            if(i==j){
                continue;
            }
            //n*(n-1)点の組み合わせについてベクトルを定める。
            int dx=a.at(i).first-a.at(j).first;
            int dy=a.at(i).second-a.at(j).second;

            //それぞれのdx.dyについて、その方向のベクトルが存在するかを確認する。
            for(int k=0;k<n;k++){
                for(int l=0;l<n;l++){
                    if((a.at(k).first-a.at(l).first)==dx){
                        if((a.at(k).second-a.at(l).second)==dy){
                            cnt++;
                        }
                    }
                }
            }
            ans=min(ans,n-cnt);
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
fun main() {
    val mod = 998244353L

    val n = readLine()!!.toInt()
    val d = readLine()!!.split(' ').map(String::toInt)

    if (d[0] != 0 || d.count { it == 0 } != 1) {
        println(0)
        return
    }

    val dNum = IntArray(n)
    d.forEach { dNum[it]++ }

    val max = d.max()!!

    var ans = 1L
    for (i in 1..max) {
        repeat(dNum[i]) {
            ans = (ans * dNum[i - 1]) % mod
        }
    }
    println(ans)
}

Measured memory_bytes: 49888
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin>>n>>k;
    int ans = 0;
    REP(i,n){
        int h; cin>>h;
        if(h>=k) ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())

if N >= 10:
	ans = 9
	if N >= 1000:
		ans += 900
		if N == 100000:
			ans += 90000
		else:
			ans += max(0, N - 9999)
	else:
		ans += max(0, N - 99)
else:
	ans = N

print(ans)

Measured memory_bytes: 3060
#include <iostream>
typedef long long ll;
#include <cmath>
#include <string>

int main() {
  int n,i,k,j,ans=0;
  std::string s;
  std::cin >> n >>k;
  std::cin >> s;
  j=0;
  for (i = 1; i < n; ++i) {
    if (s[i-1]==s[i]) {
      ++ans;
    }else{
      ++j;
    }
  }
  ++j;
  if (j>2*k+1){
    ans+=2*k;
  }else{
    ans+=j-1;
  }
  std::cout <<ans<< '\n';
}


Measured memory_bytes: 888
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double r = Double.parseDouble(scan.nextLine());
		double dbCir = (Math.PI * r * 2.0);
		double dbArea = (Math.PI * r * r);
		BigDecimal x = new BigDecimal(dbCir);
		BigDecimal y = new BigDecimal(dbArea);
		x = x.setScale(6, BigDecimal.ROUND_HALF_UP);
		y = y.setScale(6, BigDecimal.ROUND_HALF_UP);

		System.out.println(y + " " + x);
		scan.close();
	}
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

i64 n;
vector<i64> a;
vector<i64> d;
vector<vector<i64>> g;
vector<i64> p;

void dfs(i64 x) {
    i64 idx = lower_bound(begin(p), end(p), a[x]) - begin(p);
    i64 s = p.size();
    if (idx != s) {
        swap(p[idx], a[x]);
    } else {
        p.push_back(a[x]);
    }

    d[x] = p.size();
    for (auto& e : g[x]) {
        if (d[e] == -1) dfs(e);
    }

    if (idx != s) {
        swap(p[idx], a[x]);
    } else {
        p.pop_back();
    }
}

void solve() {
    cin >> n;
    a.assign(n, 0);
    for (auto& e : a) cin >> e;
    g.assign(n, {});
    for (i64 i = 0; i < n - 1; i++) {
        i64 u, v;
        cin >> u >> v, u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    d.assign(n, -1);
    dfs(0);
    for (auto& e : d) cout << e << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 28740
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int MW, MH;
vector<string> a;
vector<vector<bool>> used;
bool inside(int nh, int nw) {
    return 0 <= nw && nw < MW && 0 <= nh && nh < MH;
}
int dh[] = {-1, 0, 0, 1};
int dw[] = {0, -1, 1, 0};
bool white, black;
int dfs(PII now, PII back) {
    int w, h; tie(h, w) = now;
    if (a[h][w] == 'W') {
        white = true;
        return 0;
    }
    if (a[h][w] == 'B') {
        black = true;
        return 0;
    }
    int res = 0;
    REP(i, 4) {
        int nh = h + dh[i], nw = w + dw[i];
        if (!inside(nh, nw) || used[nh][nw]) continue;
        if (back == MP(nh, nw)) continue;
        if (a[nh][nw] == '.') used[nh][nw] = true;
        res += dfs(MP(nh, nw), now);
    }
    return res + 1;
}

void solve(int W, int H) {
    MW = W;MH = H;
    a.resize(H);used.resize(H, vector<bool>(W, false));
    for_each(ALL(a), [](string &e){cin >> e;});
    PII ans = MP(0, 0);
    REP(i, H)REP(j, W) if (!used[i][j] && a[i][j] == '.') {
        used[i][j] = true;
        white = false;
        black = false;
        int buf = dfs(MP(i, j), MP(-1, -1));
        //DEBUG(buf)
        if (white == black) {
            buf = 0;
        }
        if (black && !white) ans.first += buf;
        else if (!black && white) ans.second += buf;
    }
    cout << ans.first << " " << ans.second << endl;
    a.clear();used.clear();
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

Measured memory_bytes: 3448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef long long ll;

char i2c(int i) { return '0'+i; }

const char* d2o(ll a) {
  string s;
  while (a) {
    s += i2c(a % 8);
    a /= 8;
  }
  reverse(s.begin(), s.end());
  rep(i,s.size()) {
    if(s[i] == '4') s[i] = '5';
    else if(s[i] == '5') s[i] = '7';
    else if(s[i] == '6') s[i] = '8';
    else if(s[i] == '7') s[i] = '9';
  }
  return s.c_str();
}

int main() {
  //int in;
  ll in;
  while (cin>>in,in) {
    //printf("%d\n",in);
    //printf("%d\n",d2o(in));
    cout<<d2o(in)<<endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,re=0;
    string s;
    cin>>n>>k>>d;
    if(n<0)
    {
        re=1;
        n=abs(n);
    }
    m=n/d;
    if(k>=m)
    {
        k-=m;
        n%=d;
        k%=2;
    }
    else
    {
        n-=d*k;
        k=0;
    }
    if(k==0) cout<<abs(n);
    else
    {
        if(re==1) n=-n;
        cout<<min(abs(n+d),abs(n-d));
    }
    return 0;
}





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


int main(){
    int x;
    rep(i, 5){
        cin >> x;
        if(x == 0){
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3588
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
x = list(set(s))
def counter(x,N,s,M,t):
    ans = [0]
    for i in range(len(x)):
        tmp = 0
        for j in range(N):
            if x[i] == s[j]:
                tmp += 1
        for k in range(M):
            if x[i] == t[k]:
                tmp += (-1)
        ans.append(tmp)
    return(ans)
print(max(counter(x,N,s,M,t)))

Measured memory_bytes: 3064
n, l = map(int, input().split())
min_taste = l
max_taste = l + n - 1
if min_taste * max_taste <= 0:
    eat = 0
else:
    if abs(min_taste) < abs(max_taste):
        eat = min_taste
    else:
        eat = max_taste
print((min_taste + max_taste) * n // 2 - eat)

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(n, vector<ll>(n, inf));
    function<ll(int, int, int)> rec = [&] (int l, int r, int turn) {
        if(l > r) return 0LL;
        if(dp[l][r] != inf) return dp[l][r];
        ll res = (turn == 0 ? -inf : inf);
        if(turn == 0) {
            res = max({res, rec(l + 1, r, !turn) + a[l], rec(l, r - 1, !turn) + a[r]});
        } else {
            res = min({res, rec(l + 1, r, !turn) - a[l], rec(l, r - 1, !turn) - a[r]});
        }

        return dp[l][r] = res;
    };

    cout << rec(0, n - 1, 0) << endl;
}


Measured memory_bytes: 71296
inputl = gets.chomp.split(" ")
input = inputl[0].to_i
list = ["a", "b", "c", "d", "e", "f", "g",
        "h", "i", "j", "k", "l", "m", "n",
        "o", "p", "q", "r", "s", "t", "u",
        "v", "w", "x", "y", "z"]

shou = 1
ans = []

while input != 0
  input -= 1
  amari = input % 26
  input /= 26
  ans.unshift list[amari]
end

puts ans.join("")


Measured memory_bytes: 14360
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BEasyLinearProgramming {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    cout << min(K, A) - max((K - A - B), 0LL) << endl;
  }
};


signed main() {
  BEasyLinearProgramming solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
    int n, i, a, b, c;

    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf("%d %d %d", &a, &b, &c);
        if ((a * a == b * b + c * c)
                || (b * b == c * c + a * a)
                || (c * c == a * a + b * b))
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}

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

int main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;   
}

Measured memory_bytes: 3572