akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100007];
long long mem[100007];
long long res = 0;

//long long swim(int i,int lst=a[0])
//{
//    if(i == n)
//        return a[i];
//    if(i>n)
//        return 1e10 ;
////    long long &r = mem[i];
////    if(~r)
////        return mem[i];
//    res = min(swim(i+1,a[i]) + abs(lst-a[i+1]),swim(i+2,a[i]) + abs(lst-a[i+2]));
////    cout<<i<<" "<<abs(a[i]-swim(i+1,a[i]))<<" "<<abs(a[i]-swim(i+2,a[i]))<<endl;
//    return res;
//}

int main()
{
    cin>>n;
    memset(mem,-1,sizeof(mem));
    for(int i=0;i<n;++i)
        cin>>a[i];
//    cout<<min(swim(1,a[0]),swim(2,a[0]))<<endl;
    mem[0]=0;
    mem[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;++i)
    {
        mem[i] = min(mem[i-1]+ abs(a[i]-a[i-1]) ,mem[i-2]+ abs(a[i]-a[i-2]));
    }
    cout<<mem[n-1]<<endl;
}


Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    for (;;) {
        auto N = readln.chomp.to!int;
        if (N == 0) return;

        auto ws = readln.split.to!(int[]);
        auto DP = new int[][](N, N);
        int max_l;
        foreach (i; 0..N-1) if (abs(ws[i] - ws[i+1]) <= 1) {
            DP[i][i+1] = 2;
        }
        foreach (jj; 1..N) {
            foreach (i; 0..N) {
                auto j = i+jj;
                if (j >= N) break;

                DP[i][j] = max(DP[i][j-1], DP[i+1][j]);
                if (abs(ws[i] - ws[j]) <= 1 && DP[i+1][j-1] == j-i-1) {
                    DP[i][j] = j-i+1;
                }
                foreach (k; i+1..j) {
                    DP[i][j] = max(DP[i][j], DP[i][k] + DP[k+1][j]);
                }
            }
        }
        writeln(DP[0][N-1]);
    }
}


Measured memory_bytes: 10812
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe
import Data.String
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BS
---------------------------------------------------------------------------------
main = do
  s <- getLine'
  putStrLn' $ hakuchumu s

hakuchumu s
  | s=="" = "YES"
  | BS.isSuffixOf "dream" s = hakuchumu $ take' (length' s - 5) s
  | BS.isSuffixOf "dreamer" s = hakuchumu $ take' (length' s - 7) s
  | BS.isSuffixOf "erase" s = hakuchumu $ take' (length' s - 5) s
  | BS.isSuffixOf "eraser" s = hakuchumu $ take' (length' s - 6) s
  | otherwise = "NO"


---------------------------------------------------------------------------------

{-ByteString関連-}
--IO
getLine' = BS.getLine
getContents' = BS.getContents
getInt' = fst . fromJust . BS.readInt <$> getLine'
getIntListw' = map (fst . fromJust. BS.readInt) .words' <$> getContents'
getIntListl' = map (fst . fromJust. BS.readInt) .lines' <$> getContents'
getInteger' = fst . fromJust. BS.readInteger <$> getLine'
putStr' = BS.putStr
putStrLn' = BS.putStrLn
--演算子
bs1 |++| bs2 = BS.append bs1 bs2
chr |:+| bs2 = BS.cons chr bs2
bs1 |+:| chr = BS.snoc bs1 chr
--部分文字列操作
head' bs = BS.head bs
last' bs = BS.last bs
init' bs = BS.init bs
tail' bs = BS.tail bs
take' n bs = BS.take n bs
drop' n bs = BS.drop n bs
takeWhile' f bs = BS.takeWhile f bs
dropWhile' f bs = BS.dropWhile f bs
--リスト操作
length' bs = BS.length bs
reverse' bs = BS.reverse bs
transpose' bs = BS.transpose bs
sort' bs = BS.sort bs
group' bs = BS.group bs
lines' bs = BS.lines bs
words' bs = BS.words bs
unlines' bs = BS.unlines bs
unwords' bs = BS.unwords bs
--要素の有無
elem' chr bs = BS.elem chr bs
notElem' chr bs = BS.notElem chr bs
elemIndex' chr bs = BS.elemIndex chr bs
elemIndices' chr bs = BS.elemIndices chr bs
count' chr bs = BS.count chr bs
--整形
--justifyRight'::Char -> ByteString -> ByteString
--justifyRight' chr bs = convertString $ T.justifyRight chr (convertString bs)

{-elem関連-}
--elemの第一引数をリストにしたもの。
--elemList "abc" "atcoder" -> [True,False,True]
elemList [] _ = []
elemList (x:xs) list  = elem x list : elemList xs list

--elemIndexの第一引数をリストにしたもの。
elemIndexList [] list = []
elemIndexList (x:xs) list  = elemIndex x list : elemIndexList xs list

--elemIndicesの第一引数をリストにしたもの。
elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>i>>j;
    cout<<i*j;

    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

int n, c;
string s[1000];
int d[1000];

int f(int depth) {
	if(isdigit(s[c][0])) {
		int ret = s[c][0] - '0';
		c++;
		return ret;
	}

	if(s[c] == "+") {
		c++;
		int ret = 0;
		while(c < n && d[c] == depth + 1) ret += f(depth + 1);
		return ret;
	}
	else {
		c++;
		int ret = 1;
		while(c < n && d[c] == depth + 1) ret *= f(depth + 1);
		return ret;
	}
	assert(false);
}

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

	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			cin >> s[i];
			d[i] = count(s[i].begin(), s[i].end(), '.');
			int len = s[i].size();
			s[i] = s[i].substr(d[i], len - d[i]);
		}
		c = 0;
		cout << f(0) << endl;
	}
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 998244353;

ll dp[3005];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n, s; cin >> n >> s;
	int a[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	ll ans = 0;
	dp[0] = 1;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] > s) continue;
		if (a[i] < s) ans += 1LL * (n-i) * dp[s-a[i]];
		else ans += 1LL * (n-i) * (i+1);
		ans %= MOD;
		for (int x = s; x > a[i]; --x)
		{
			dp[x] += dp[x-a[i]];
			dp[x] %= MOD;
		}
		dp[a[i]] += i+1; dp[a[i]] %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010],sum[200010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    for(int i=1;i<=n;i++)a[i]=read(),sum[i]=sum[i-1]+a[i];
    int mx=0;
    for(int i=m;i<=n;i++)mx=max(mx,sum[i]-sum[i-m]);
    printf("%lf\n",(mx+m)/2.0);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
#include <cstdint>

using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	ll asub, bsub;
	asub = k - a;
	if (asub < 0) {
		cout <<  k;
		return 0;
	}
	else {
		bsub = asub - b;
	}

	if (bsub <= 0) {
		cout << a;
	}
	else {
		cout << a - bsub;
	}

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  cin >>A>>B>>C;
  
  if(A+B+C>21){
    cout << "bust" << endl;
  }
  else cout << "win" << endl;
  
  return 0;
}


Measured memory_bytes: 256
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    loop{
        let h = iter.next().unwrap().parse().unwrap();
        let w = iter.next().unwrap().parse().unwrap();
        if h==0 {break}
        for _ in 0..h {
            for _ in 0..w {
                out.write(b"#").unwrap();
            }
            out.write(b"\n").unwrap();
        }
        out.write(b"\n").unwrap();
    }
}



Measured memory_bytes: 5020
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  int n;
  cin >> n;
  
  int p[n];
  
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    if( p[i]<p[i+1] && p[i+1]<p[i+2]) ans++;
    if( p[i]>p[i+1] && p[i+1]>p[i+2]) ans++;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define N 1<<20 
const ll mod = 1e9 + 7;

multiset<int> g[N];
int num[N], a[N];

int n, m;
int main() {
	ios::sync_with_stdio(0);
	while(cin >> n) {
		int k = 1<<n;
		for(int i = 0; i < k; i++) cin >> a[i], g[i].insert(a[i]);
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < k; j++) {
				if((j >> i) & 1) {
					for(int it: g[j^(1<<i)]) g[j].insert(it);
				}
				while(g[j].size() > 2) g[j].erase(g[j].begin());
			}
		}
		int ans = 0;
		for(int i = 1; i < k; i++) {
			int res = *g[i].begin() + *g[i].rbegin();
			ans = max(ans, res);
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 77824
from collections import deque
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cnt=[0 for i in range(n)]
visited=[-1 for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for i in range(q):
  p,x=map(int,input().split())
  cnt[p-1]+=x
def dfs(edge,cnt,visited):
  stack=deque([0])
  visited[0]=0
  while stack:
    x=stack.pop()
    for i in edge[x]:
      newx=i
      if visited[newx]==-1:
        visited[newx]=0
        cnt[newx]+=cnt[x]
        stack.append(newx)
  return cnt
print(*dfs(edge,cnt,visited))


Measured memory_bytes: 106124
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
    int n,i,j;
    long long s=0,a[88];
    a[0]=2;a[1]=1;
    for(i=2;i<=86;i++){
        a[i]=a[i-1]+a[i-2];
    }
    scanf("%d",&n);
    printf("%lld\n",a[n]);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	ll x;
	cin >> x;
	ll ans=100 ,b=100,cnt=0;
	while (ans < x) {
		ll a = ans;
		ans += a * 0.01;
		a = ans;
		cnt += 1;
	}
	cout << cnt;
	return 0;
}













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

int main(){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll ans;
    if (K%2 == 0) ans = X;
    else ans = X+D;
    ll need = X/D;
    if (need <= K) {
        if (need%2 == K%2) ans = min(ans, X%D);
        else ans = min(ans, abs(X%D-D));
    }else {
        ans = min(ans, abs(X-K*D));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

class Main{
    static int[][] path=new int[50][50];



    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int H=scan.nextInt();
        int W=scan.nextInt();
        int cnt =0;
        for(int[] i : path)Arrays.fill(i,-1);
        for(int i=0;i<H;++i){
            String s = scan.next();
            for(int j=0;j<W;++j){
                path[i][j]=(s.charAt(j)=='.' ? 10000:-1);
                if(s.charAt(j)=='.')++cnt;
            }
        }
        int[] dx ={0,-1,0,1};
        int[] dy={1,0,-1,0};

        path[0][0]=1;
        Deque<Integer> que = new ArrayDeque<>();
        que.add(0);
        while(!que.isEmpty()){
            int h = que.peek()/W;
            int w = que.poll()%W;
            for(int i=0;i<4;++i){
                if(h+dy[i]<0 || h+dy[i] >=H || w+dx[i]<0 || w+dx[i]>=W || path[h+dy[i]][w+dx[i]]==-1 || path[h+dy[i]][w+dx[i]]<=path[h][w]+1)continue;
                path[h+dy[i]][w+dx[i]]=path[h][w]+1;
                que.add((h+dy[i])*W + w+dx[i]);
            }
        }
        if(path[H-1][W-1]==-1 || path[H-1][W-1]==10000)System.out.println(-1);
        else System.out.println(cnt - path[H-1][W-1]);
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


//////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long step = 0,ans = 0;
    for (int i = 0;i<n;i++){
        cin >> a[i];
        if (i == 0){
            continue;
        }

        if(a[i] < a[i-1]){
            step = a[i-1] - a[i];
            ans += step;
            a[i] += step; 
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 4844
#dfs(再帰)
import sys
sys.setrecursionlimit(1000000000)

N, M = map(int, input().split())
a, b = [0]*M, [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())

c = [[0]*N for _ in range(N)]
for x, y in zip(a, b):
    c[x-1][y-1] = 1
    c[y-1][x-1] = 1
visited = [-1]*N
visited[0] = 1
ans = 0

def dfs(n):
    global ans
    if sum(visited) == N:
        ans += 1
        return
    else:
        for i, x in enumerate(c[n]):
            if x == 1 and visited[i] == -1:
                visited[i] = 1
                dfs(i)
                visited[i] = -1
    return

dfs(0)
print(ans)

Measured memory_bytes: 3064
n=int(input())
dic={}
for _ in range(0,n):
  s="".join(sorted(input()))
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
    
ans=0    
for a in dic.values():
  ans+=(a*(a-1))/2
  
print(int(ans))


Measured memory_bytes: 17852
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;

inline void solve()
{
	ll a, b, k;
	cin >> a >> b >> k;
	cout << max(0ll, a - k) << ' ' << max(0ll, min(a + b - k, b));
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

string IMP = "Impossible";
int n, m;
int a[110];

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    int rc = 0;
    for (int i = 0; i < m; i++) {
        rc += (a[i]+1)/2;
    }
    if (rc-1 > n/2) {
        cout << IMP << endl;
        return 0;
    }
    vector<int> od, ev;
    for (int i = 0; i < m; i++) {
        if (a[i] % 2) {
            od.push_back(a[i]);
        } else {
            ev.push_back(a[i]);
        }
    }
    assert(od.size() <= 2);
    vector<int> v;
    if (od.size()) {
        v.push_back(od.back());
        od.pop_back();
    }
    for (int d: ev) {
        v.push_back(d);
    }
    if (od.size()) {
        v.push_back(od.back());
        od.pop_back();
    }
    vector<int> b;
    if (v.size() >= 2) {
        int i = 0;
        if (v[i] % 2 == 1) {
            if (v[i]-1) {
                b.push_back(v[i]-1);
            }
            i++;
        } else {
            b.push_back(v[i]-1);
            i++;
        }
        while (i < v.size()-1) {
            b.push_back(v[i]);
            i++;
        }
        if (v[i] % 2 == 1) {
            b.push_back(2);
            if (v[i]-1) {
                b.push_back(v[i]-1);
            }
            i++;
        } else {
            b.push_back(v[i]);
            b.push_back(1);
        }
    } else {
        if (v[0]-1) {
            b.push_back(v[0]-1);
        }
        b.push_back(1);
    }

    for (int d: v) {
        printf("%d ", d);
    }
    printf("\n");
    printf("%d\n", (int)b.size());
    for (int d: b) {
        printf("%d ", d);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void) {
	long long int n, i, min=0, max=0, sum=0, a;
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a;
		if (a < min||i==1) {
			min = a;
		}
		if (a > max|i==1) {
			max = a;
		}
		sum = sum + a;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
#define int long long
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
typedef pair<int, int> P;
signed main()
{
    int h, w;
    cin >> h >> w;
    char table[110][110];
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> table[i][j];
        }
    }
    rep(i, h)
    {
        bool flag = false;
        rep(j, w)
        {
            if (table[i][j] == '#')
                flag = true;
        }
        if (flag == false)
        {
            rep(j, w) table[i][j] = '1';
        }
    }
    rep(j, w)
    {
        bool flag = false;
        rep(i, h)
        {
            if (table[i][j] == '#')
                flag = true;
        }
        if (flag == false)
        {
            rep(i, h) table[i][j] = '1';
        }
    }
    rep(i, h)
    {
        bool flag = false;
        rep(j, w)
        {
            if (table[i][j] != '1')
            {
                cout << table[i][j];
                flag = true;
            }
        }
        if (flag == true)
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

#define MAX_N 100

// int N = 432;
int N;

int main() {
    cin >> N;
    int ans = 0;
    int mod = 100 * N % 108;
    if (mod == 0) {
        ans = N / 1.08;
    } else {
        int tmp = (N / 1.08) + 1;
        int tmp2 = tmp * 1.08;
        if (tmp2 == N) {
            ans = tmp;
        } else {
            printf(":(\n");
            return 0;
        }
    }

    printf("%d\n", ans);
}

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

// int max: 2 x 10^9, long long max: 9 x 10^18

using namespace std;

int main()
{

  int x;
  cin >> x;

  if(x == 0){
    cout << 1;
  }else{
    cout << 0;
  }

  return 0;
}

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

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

  vector<int> moti(N);

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

  vector<int>::iterator maxIter = max_element(moti.begin(), moti.end());
  size_t maxIndex = distance(moti.begin(), maxIter);
  int maxCho = moti.at(maxIndex);
  moti.at(maxIndex) = 0;
  int dan = 1;

  for(int i=0; i<N; i++){
    vector<int>::iterator iter = max_element(moti.begin(), moti.end());
    size_t index = distance(moti.begin(), iter);
    if(moti.at(index)==0){
      break;
    } 
    if(moti.at(index)<maxCho){
      dan++;
      maxCho = moti.at(index);
      moti.at(index) = 0;
    }else if(moti.at(index)==maxCho){
      moti.at(index) = 0;
    }else{
      break;
    }
  }

  cout << dan << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a7=1000000007;
ll inf=100000000000000000;
ll max(ll x,ll y){if(x>y)return x;return y;}
ll min(ll x,ll y){if(x<y)return x;return y;}
/////////////////////////////////////////////////////////////////////////////////////////

int main()
{
  string s;cin>>s;
  ll n=s.length();
  ll k=0;
  for(ll i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i])k++;
  }
  cout<<k<<endl;
  return 0;
}

//cout<<setprecision(20)<<2*sum/n<<endl;


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int maxn = 100 + 10;
const int maxnn = 1e5 + 10;

int n , W , now = 1 , pre;
long long dp[2][maxnn];
int v[maxn] , w[maxnn];

int main() {
    cin >> n >> W;
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    
    for (int i = 1; i <= n; i++){
        pre ^= 1;
        now ^= 1;
        for (int j = 0; j <= W; j++){
            if (j - w[i] < 0){
                dp[now][j] = dp[pre][j];
                continue;
            }
            dp[now][j] = max(dp[pre][j] , dp[pre][j-w[i]] + v[i]);
        }
    }
    cout << dp[now][W] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, d;
struct Point
{
	int x[20];
};

Point pts[20];

std::set<int> squares;

void init()
{
	int base;
	int n = 0;
	while (base <= 40000)
	{
		base = n * n;
		squares.insert(base);
		n++;
	}
}

int getDist(const Point &a, const Point &b)
{
	int dist = 0;
	for (int i = 0 ; i < d ; i++)
		dist = dist + (a.x[i] - b.x[i]) * (a.x[i] - b.x[i]);
	
	return dist;
}


int main()
{
	init();
	
	scanf("%d%d", &n, &d);
	
	for (int i = 0 ; i < n ; i++)
	{
		for (int j = 0 ; j < d ; j++)
			scanf("%d", &(pts[i].x[j]));
	}
	
	int count = 0;
	for (int i = 0 ; i < n ; i++)
	{
		for (int j = i + 1 ; j < n ; j++)
		{
			int dist = getDist(pts[i], pts[j]);
			
			if (squares.find(dist) != squares.end())
			{
//				printf("%d %d %d\n", i, j, dist);
				count++;
			}
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}


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

int main() {
	int N;	// 組数.
	cin >> N;

	int total_num = 0;
	for (int i = 0; i < N; i++) {
		int l;
		int r;
		cin >> l >> r;
		total_num += r - l + 1;
	}
	cout << total_num << endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> L(N);
  int ans = 0;
  
  for (int i = 0; i < N; i++)
  {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  for (int i = 2; i < N; i++) {
    for (int j = 1; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (L.at(k) + L.at(j) > L.at(i)) {
          ans += j - k;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int arr[100007];

int main ()
{
    int i, j, n, k, x, y;
    cin >> n;
    int cnt1=0, cnt2=0, cnt4=0;
    for (i=0; i<n; i++)
    {
        cin >> x;
        if (x%2) cnt1++;
        else
        {
            if (x%4==0) cnt4++;
            else cnt2++;
        }
    }

    if (2*cnt1-1>n) cout << "No" << endl;
    else if (2*cnt1-1==n)
    {
        if (cnt4<cnt1-1) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else
    {
        if (cnt4<cnt1) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005];
int main(){
    memset(dp, -1, sizeof(dp));
    int n, w, a, b;
    scanf("%d%d", &n, &w);
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        scanf("%d%d", &a, &b);
        for(int j=100000;j>=0;j--){
            if(dp[j] == -1) continue;
            if(dp[j+b] == -1 || dp[j+b] > dp[j] + a){
                dp[j+b] = dp[j] + a;
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<=100000;i++){
        if(dp[i] != -1 && dp[i] <= w) ans = max(ans, (ll)i);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include "stdio.h"
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <queue>
#include <algorithm>
#include <math.h>

#define MAX 4000
#define WMAX 10000
#define NMAX 50
#define AMAX 1000
#define BMAX 100
#define inf 1000000

using namespace std;

int main(){
    int n;
    cin >> n;
    string ans = "";
    if(n == 0){
        cout << "0";
        return 0;
    }
    while(n != 0){
        if(n % -2 != 0){
            ans = "1" + ans;
            n--;
        }
        else{
            ans = "0" + ans;
        }
        n /= -2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
/**
 * Computing Geometry Library
 * @author Sshwy
 */
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)

namespace cg{
    typedef long double vtyp;
    const vtyp eps = 1e-9;
    bool isZero(vtyp x){
        return -eps < x && x < eps;
    }
    struct vec {
        vtyp x,y;
        vec(){ x = y = 0; }
        vec(vtyp _x, vtyp _y){ x = _x, y = _y; }
        vec operator+(const vec V) const { return vec(x+V.x, y+V.y); }
        vec operator-() const { return vec(-x, -y); }
        vec operator-(const vec V) const { return *this + (-V); }
        vec operator*(const vtyp a) const { return vec(x*a, y*a); }
        friend vec operator*(const vtyp a, const vec v){ return v*a; }
        operator bool() const { return !(isZero(x) && isZero(y)); }
        bool operator==(const vec V) const { return bool(*this-V) == 0; }
        vtyp length(){ return sqrt(x*x + y*y); }
        /**
         * 方向角，单位 rad
         */
        vtyp ang() const { return atan2(y,x); }
        /**
         * 方向向量
         * @return 0向量或者一个单位向量
         */
        vec dir() const {
            if(*this){
                vtyp ang = atan2(y,x);
                return vec(cos(ang), sin(ang));
            } else return vec(0,0);
        }
        void read(){ scanf("%Lf%Lf",&x,&y); }
    };
    istream & operator>>(istream & in, vec & v){ 
        return in >> v.x >> v.y, in; 
    }
    ostream & operator<<(ostream & out, const vec & v){ 
        return out << v.x << " " << v.y, out;
    }
    ifstream & operator>>(ifstream & in, vec & v){ 
        return in >> v.x >> v.y, in; 
    }
    ofstream & operator<<(ofstream & out, const vec & v){ 
        return out << v.x << " " << v.y, out;
    }
    /**
     * 点积
     * a dot b == |a||b|cos theta
     */
    vtyp dot(const vec a, const vec b){ return a.x*b.x + a.y*b.y; }
    /**
     * 叉积
     * 两个向量围成的有向面积
     */
    vtyp det(const vec a, const vec b){ return a.x*b.y - a.y*b.x; }
    typedef vec point;
    struct line {
        point p1, p2;
        line(point _p1, point _p2){ p1 = _p1, p2 = _p2; }
    };

    /**
     * 投影
     * @param L 直线
     * @param p 要求投影的点
     * @return p 在 L 上的投影坐标（即垂足）
     */
    point projection(line L, point p){
        vec d = L.p2 - L.p1;
        return L.p1 + (dot(d, p-L.p1)/d.length()) * d.dir();
    }
    /**
     * 对称点
     * @param L 直线
     * @param p 点
     * @return p 关于直线 L 的对称点
     */
    point reflection(line L, point p){
        point o = projection(L,p);
        return vtyp(2)*(o-p)+p;
    }
}


int main(){
    cg::point p1,p2,p;
    int q;
    cin>>p1>>p2>>q;
    cg::line l(p1,p2);
    FOR(i,1,q){
        cin>>p;
        cout<<setiosflags(ios::fixed)
            <<setprecision(10)
            <<cg::reflection(l,p)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;



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

	vector<int> t(100010, 0); vector<int> x(100010, 0); vector<int> y(100010, 0);

	for (int i = 0; i < N; i++) {
		cin >> t.at(i + 1);
		cin >> x.at(i + 1);
		cin >> y.at(i + 1);
	}

	bool flag = true;

	for (int i = 0; i < N; i++) {
		int a = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - (y.at(i)));
		int b = t.at(i + 1) - t.at(i);

		if (a > b) flag = false;
		if (a % 2 != b % 2) flag = false;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 4576
// 解説を見なかった

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int to_a(char x) {
    return 'z' - x + 1;
}

int main() {
    string s;
    ll K;
    cin >> s >> K;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != 'a' && K >= to_a(s[i])) {
            K -= to_a(s[i]);
            s[i] = 'a';
        }
    }
    if (K > 0) {
        K %= 'z' - 'a' + 1;
        s[s.size()-1] += K;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
bool cmp(long long a, long long b) {
	return a > b;
}
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	int q1, q2;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n, cmp);
	long long ans = 0;
	for (i = m; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;


int main(){
  int a,b;
  cin >> a >>b;
  if(a+b>=10){cout << "error" << endl;}else{cout << a+b << endl;}
}

Measured memory_bytes: 3532
function Main(input) {
  var input = input.split("\n");
  var N = input[0];
  var aryH = input[1].split(" ").slice(0, N).map(val => parseInt(val, 10));
  var result = 0;
  aryH.forEach(function(e, i) {
    if(i === 0) {
      result++;
      return;
    }

    var checkary = aryH.slice(0, i).filter(function(elm){
      return elm > e;
    });
    if(checkary.length === 0) {
      result++;
    }
  });

  console.log(result);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

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

  int n; cin >> n;
  int m[n];
  for(int i = 0; i < n; i++){
    cin >> m[i];
    if(m[i] % 2 == 0){
      if(m[i] % 3 == 0 || m[i] % 5 == 0){
        continue;
      }else{
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout << "APPROVED";

  return 0;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	while (cin>>a>>b) {
		if (a == 0 && b==0) break;
		if (a > b) swap(a, b);
		cout << a << " " << b << endl;
	}
}


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

char str[303]; int dp[303][303][303] , N , K;

int solve(int x , int y , int z){
	if(x > y) return 0;
	if(x == y) return 1;
	if(dp[x][y][z]) return dp[x][y][z];
	if(str[x] == str[y]) return dp[x][y][z] = solve(x + 1 , y - 1 , z) + 2;
	return dp[x][y][z] = max(solve(x + 1 , y , z) , max(solve(x , y - 1 , z) , z == 0 ? 0 : 2 + solve(x + 1 , y - 1 , z - 1)));
}

int main(){
	scanf("%s %d" , str + 1 , &K); N = strlen(str + 1);
	cout << solve(1 , N , K) << endl; return 0;
}

Measured memory_bytes: 106368
#include<iostream>
#include<string>

using namespace std;

int main(){
	int a = -1,z = 0;
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A' && a == -1)
			a = i;
		else if(s[i] == 'Z')
			z = i;
	}
	
	cout << z - a + 1 << endl;
	
	return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
/*ll f[200001];
ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }*/


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int n, m;
	cin >> n >> m;
	int ans = 0;
	while (m--) {
		int x;
		cin >> x;
		ans += x;
	}
	if (n < ans)
		cout << "-1";
	else {
		cout << n - ans;
	}
	return 0;
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> v(n);
    vector<int> acess;
    vector<bool> flag(n, false);
    rep(i, m){
        int s, c; cin >> s >> c;
        s--;
        if(!flag.at(s) || c == v.at(s)) {
            v.at(s) = c;
            acess.push_back(s);
            flag.at(s) = true;
        }
        else{
            cout << "-1" << endl;
            return 0;
        }
        if(n > 1 && v.at(0) == 0 && flag.at(0)){
            cout << "-1" << endl;
            return 0;
        }
    }
    int x = pow(10, n);
    int i = pow(10, n-1);
    if(n == 1) i = 0;
    while(i < x){
        bool f = true;
        string s = to_string(i);
        for(auto j : acess){
            if(v.at(j) != s[j] - '0'){
                f = false;
            }
        }
        if(f) {
            cout << i << endl;
            return 0;
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<vector<int>> num_ways(n + 1, vector<int> (k + 1, 0));
	for (int i = 0; i <= n; i++) {
		num_ways[i][0] = 1;
	}
	num_ways[0][0] = 1;
	for (int j = 1; j <= k; j++) {
		num_ways[0][j] = 0;
	}
	vector<int> prev_prefix(k + 1, 0);
	prev_prefix[0] = num_ways[0][0];
	for (int i = 1; i <= k; i++) {
		prev_prefix[i] = prev_prefix[i - 1] + num_ways[0][i];
		prev_prefix[i] %= MOD;
	}
	// cout << "Prefix : " ;
	// for (int i = 0 ; i <= k; i++) {
	// 	cout << prev_prefix[i] << " ";
	// }
	// cout << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			num_ways[i][j] += prev_prefix[j];
			num_ways[i][j] %= MOD;
			if (max(j - a[i - 1], 0ll) - 1 >= 0) {
				num_ways[i][j] -= prev_prefix[max(j - a[i - 1], 0ll) - 1];
				//cout << "Curr_pref : " << prev_prefix[max(j - a[i - 1], 0ll) - 1] << endl;
				if (num_ways[i][j] < 0) {
					num_ways[i][j] += MOD;
				}
			}
			// for (int candies = 0; candies <= a[i - 1]; candies++) {
			// 	if (j - candies >= 0) {
			// 		num_ways[i][j] += num_ways[i - 1][j - candies];
			// 		num_ways[i][j] %= MOD;
			// 	}
			// 	if (j - candies < 0) break;
			// }
		}
		prev_prefix[0] = num_ways[i][0];
		for (int pos = 1; pos <= k; pos++) {
			prev_prefix[pos] = prev_prefix[pos - 1] + num_ways[i][pos];
			prev_prefix[pos] %= MOD;
		}
		// cout << "Prefix : " ;
		// for (int i = 0 ; i <= k; i++) {
		// 	cout << prev_prefix[i] << " ";
		// }
		// cout << endl;
	}
	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j <= k; j++) {
	// 		cout << num_ways[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << num_ways[n][k] << endl;

	return 0;
}

Measured memory_bytes: 83032
Q = gets.to_i
ABs = readlines.map{|l| l.split.map(&:to_i)}

def solve(a, b)
  s = a*b
  a, b = [a, b].minmax
  c = (Math.sqrt(s) - 1).ceil
  case 
  when b == a, b == a + 1
    2*a - 2
  when c*(c + 1) >= s
    2*c - 2
  else
    2*c - 1
  end
end

ABs.each{|a, b| puts solve(a, b)}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
    int W,H,N;
    cin>>W>>H>>N;
    int S[W][H];
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            S[i][j]=0;
        }
    }
    int x,y,a;
    for(int i=0;i<N;i++){
        cin>>x>>y>>a;
        switch(a){
            case 1:
                for(int j=0;j<x;j++){
                    for(int k=0;k<H;k++){
                        S[j][k]=1;
                    }
                }
                break;
            case 2:
                for(int j=x;j<W;j++){
                    for(int k=0;k<H;k++){
                        S[j][k]=1;
                    }
                }
                break;
            case 3:
                for(int j=0;j<W;j++){
                    for(int k=0;k<y;k++){
                        S[j][k]=1;
                    }
                }
                break;
            case 4:
                for(int j=0;j<W;j++){
                    for(int k=y;k<H;k++){
                        S[j][k]=1;
                    }
                }
                break;
        }
    }
    int sum = 0;
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if (S[i][j]==0){sum++;}
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

class Str
{
public:

	string str;

	Str(){}
	Str(string c)
	{
		str = c;
	}

	bool operator=(const Str & a)const
	{
		return str == a.str;
	}

	bool operator<(const Str & a)const
	{
		if(str.length() == a.str.length())
		{
			return str < a.str;
		}
		return str.length() < a.str.length();
	}
};

int main()
{
	set<Str> st;

	int N;
	string C;

	cin >> N;
	cin >> C;

	for (auto c : C)
	{
		Str s;
		s.str = c;

		vector<Str> V;

		for (auto itr : st)
		{
			if (itr.str.length() >= 3) { break; }
			Str s2; s2.str = itr.str + c;
			V.emplace_back(s2);
		}

		for (auto itr : V)
		{
			st.insert(itr);
		}

		st.insert(s);
	}


	int cnt=0;
	st.insert(Str("1"));
	for (auto itr : st)
	{
		
		if (itr.str.size() >= 3) { break; }
		cnt++;
	}

	cout << st.size() - cnt << endl;


	return 0;
}

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

void solve() 
{
    double a,b;cin>>a>>b;a--;b--;
    cout<<ceil(b/a)<<endl;
}

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

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

int main() {
  int64_t N, K, count=0;
  cin >> N >> K;
  vector<int> H(N);
  for(int i=0; i<N; i++)
    cin >> H.at(i);
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  if(K >= H.size())
    cout << 0 << endl;
  else{
    for (int i=K; i<H.size(); i++){
      count += H.at(i);
    }
    cout << count << endl;
  }   
}

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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = max<int>({
    10*a+b+c,
    a+b*10+c,
    a+b+10*c,
  } );
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
X = list(map(int, readline().split()))

lower = min(X)
upper = max(X)

ans = float("inf")
for P in range(lower, upper+1):
    dis = 0
    for x in X:
        dis += abs(P - x) ** 2
    ans = min(ans, dis)
print(ans)

Measured memory_bytes: 3064
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function root(uf::Array{Int,1},x)
	s=x
	while uf[s]>0
		s=uf[s]
	end
	s
end
function same(uf::Array{Int,1},x,y)
	root(uf,x)==root(uf,y)?true:false
end
function unite(uf::Array{Int,1},x,y)
	l = root(uf,x)
	r = root(uf,y)
	if l!=r
		if uf[l] < uf[r]
			uf[l] += uf[r]
			uf[r] = l
		else
			uf[r] += uf[l]
			uf[l] = r
		end
	end
end

function main()
	n,m = readline() |> split |> parseMap
	e = Tuple{Int,Int}[(0,0) for i in 1:m]
	for i in 1:m
		a,b = readline() |> split |> parseMap
		e[i] = (a,b)
	end
	k = 0
	for j in 1:m
		uf = -ones(Int,n)
		for i in 1:m
			if i!=j
				unite(uf,e[i][1],e[i][2])
			end
		end
		if uf[root(uf,1)]!=-n
			k += 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 169704
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, p[102] = {1, 1}, c[102] = {}, z = 0;
    cin >> n;
    for (int i = 2; i <= 100; i++) for (int j = 2; j < i; j++) if (i % j == 0) p[i] = 1;
    for (int i = 1; i <= n; i++) {
        int m = i;
        while (m > 1) {
            for (int j = 2; ; j++) if (m % j == 0) {
                m /= j;
                c[j]++;
                break;
            }
        }
    }
    for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) for (int k = 1; k < j; k++) if (i != j && i != k && c[i] >= 2 && c[j] >= 4 && c[k] >= 4) z++;
    for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) if (i != j && c[i] >= 4 && c[j] >= 14) z++;
    for (int i = 1; i <= 100; i++) for (int j = 1; j <= 100; j++) if (i != j && c[i] >= 2 && c[j] >= 24) z++;
    for (int i = 1; i <= 100; i++) if (c[i] >= 74) z++;
    cout << z;
    //3 5 5 -> 2 4 4
    //5 15 -> 4 14
    //3 25 -> 2 24
    //75 -> 74
}


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


int main()
{
    string S, T;
    cin >> S >> T;
    int a = 0;
    for(int i=0;i<S.size();++i)
    {
        if(S[i] != T[i]) ++a;
    }
    cout << a << endl;
}

Measured memory_bytes: 3852