akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int W;
	cin>>W;
	vector<int>w(n);
	vector<ll>p(n);
	for(int i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		w[i]=a;
		p[i]=b;
	}
cout<<endl;
ll c[n+1][W+1];

for(int i=0;i<=n;i++)
{
	for(int curr_cap=0;curr_cap<=W;curr_cap++)
	{
		if(i==0||curr_cap==0)
		{
			c[i][curr_cap]=0;
		}
		else if(w[i-1]<=curr_cap)
		{
			//max among if we take the value or if we dont take the value
			c[i][curr_cap]=max(p[i-1]+c[i-1][curr_cap-w[i-1]],c[i-1][curr_cap]);
		}
		else
		{
			c[i][curr_cap]=c[i-1][curr_cap];
		}
	}
}
cout<<c[n][W]<<"\n";
	return 0;
}

Measured memory_bytes: 79232
#include <iostream>
using namespace std;
int ans,n;

int dfs(long long x){
    if(x>n) return 0;
    int num=0;
    bool ok3=false,ok5=false,ok7=false;
    for(int i=1;x/i;i*=10){
        int X=(x%(i*10))/i;
        if(X==3)ok3=true;
        if(X==5)ok5=true;
        if(X==7)ok7=true;
    }
    if(ok3&&ok5&&ok7) num++;
    num+=dfs(x*10+3);
    num+=dfs(x*10+5);
    num+=dfs(x*10+7);
    return num;
}

int main(){
    cin>>n;
    cout<<dfs(0);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{int parent, left, right;}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
	if(u == NIL)
		return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
	if(T[u].parent == NIL)
		return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if(T[u].left != NIL)
		deg++;
	if(T[u].right != NIL)
		deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if(T[u].parent == NIL)
		printf("root\n");
	else if(T[u].left == NIL && T[u].right == NIL)
		printf("leaf\n");
	else
		printf("internal node\n");
}

int main(){
	int i, v, l, r, root = 0;
	scanf("%d", &n);

	for(i = 0; i < n; i++)
		T[i].parent = NIL;

	for(i = 0; i < n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL)
			T[l].parent = v;
		if(r != NIL)
			T[r].parent = v;
	}

	for(i = 0; i < n; i++){
		if(T[i].parent == NIL)
			root = i;
	}

	setDepth(root, 0);
	setHeight(root);

	for(i = 0; i < n; i++)
		print(i);

	return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>


#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 998244353;
const ll N = 1e5 + 10;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline void Ckmax(T &x, T y)
{
    x = std::max(x, y);
}
template <typename T>
inline void Ckmin(T &x, T y)
{
    x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll fac(ll x)
{
	ll r = 1;
	for (; x > 1; --x)
		(r *= x) %= MOD;
	return r;
}


int main()
{
	cinspu();
	std::string a;
	std::cin >> a;
	int n = a.size(), ans = 1000;
	for (int i = 0; i < n; ++i)
		a[i] -= '0';
	for (int i = 0; i < n - 2; ++i)
		Ckmin(ans, Abs(a[i] * 100 + a[i + 1] * 10 + a[i + 2] - 753));
	std::cout << ans << std::endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
    string s; cin >> s;
    int q = s.size();
    bool ok = true;
    
    for(int i = 0; i < q; ++i){
		//cout << s[i] << " ";
		if((i+1)%2 == 0 && s[i] == 'R'){
			ok = false;
			break;
		}
		if((i+1)%2 != 0 && s[i] == 'L'){
			ok = false;
			break;
		}
	}
    
    cout << (ok == true ? "Yes\n" : "No\n");
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;
 
int main(void) {
	int n;
	int* a;
	int t;
	int check;
	int count[100002] = {};
	cin >> n;
	a = new int[n + 1];
	FOR(i, 1, n + 1) {
		cin >> a[i];
	}
	
	FOR(i, 1, n + 1) {
		count[a[i]]++;
		count[a[i] + 1]++;
		count[a[i] + 2]++;
	}
	check = count[0];
	FOR(i, 1, 100002) {
		if (count[i] == 0) {
			continue;
		}
		if (check < count[i]) {
			check = count[i];
			t = i;
		}
	}
	cout << count[t] << endl;
	delete[] a;
	return 0;
}

Measured memory_bytes: 1024
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]

s=inp()
if s=='ABC': print("ARC")
else: print("ABC")

Measured memory_bytes: 9144
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<utility>
#include<string>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<array>
#include<algorithm>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    char s[105]={};
    int flag=0;
    scanf("%s",s);
    REP(i,strlen(s)){
        if(i%2==0){
            if(s[i]=='L'){
                flag=1;
            }
        }
        if(i%2==1){
            if(s[i]=='R'){
                flag=1;
            }
        }
    }
    if(flag){
        printf("No\n");
    }
    else printf("Yes\n");
    return 0;
}

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


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


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


def main():
    a = list(sorted(list(map(int, input().split()))))
    if a[0] + a[1] == a[2]:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


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

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

    int n;
    cin >> n;
    int a1[n], a2[n];

    for (int i = 0; i < n; ++i) cin >> a1[i];
    for (int i = 0; i < n; ++i) cin >> a2[i];

    int res = -1;
    for (int i = 0; i < n; ++i){
        int candies = 0;
        for (int j = 0; j <= i; ++j) candies += a1[j];
        for (int j = i; j < n; ++j) candies += a2[j];

        res = max(res, candies);
    }
    cout << res << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 mypow(int32 n, int32 r){
    if(r == 0)return 1;
    if(r % 2 == 0){
        int32 x = mypow(n, r / 2);
        return x * x;
    }
    return mypow(n,r-1)*n;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k;
    cin >> n >> k;
    ANS(mypow(k-1,n-1)*k);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);
 
    std::string s;
    std::getline(std::cin, s);
    std::vector<bool> dict(26, false);
    for (char c : s)
        dict[c - 'a'] = true;
    std::string r = "None";
    for (std::size_t i = 0; i < dict.size(); ++i) {
        if (!dict[i]) {
            r = i + 'a';
            break;
        }
    }
    std::cout << r << std::endl;
 
    return 0;
}

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

#define fori(i,n) for (int i = 0; i < (n); i++)
#define repk(i,k,n)  for (int i = k; i < n; ++i)
#define repr(i,k,n) for (int i = k; i >= n; --i)

int main(void) {
    int N,L;
    cin >> N >> L;
    vector<string> vec(N);
    fori(i,N) cin >> vec[i];
    sort(vec.begin(), vec.end());
    fori(i,N) {
        cout << vec[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[200010];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long sum=0;
    for(int i=1;i<n;i++){
        int sa=a[i-1]-a[i];
        if(sa>0){
            sum+=sa;
            a[i]+=sa;
        }
    }
    cout<<sum<<"\n";
    return(0);
}

Measured memory_bytes: 4336
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map(String::toInt)
    var inc = 0
    var ans = 1
    for (i in 1..n - 1) {
        if (a[i] > a[i - 1] && inc == -1 || a[i] < a[i - 1] && inc == 1) {
            ans++
            inc = 0
        } else {
            if (a[i] > a[i - 1]) inc = 1
            if (a[i] < a[i - 1]) inc = -1
        }
    }
    println(ans)
}


Measured memory_bytes: 44304
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	int X0;
	scanf("%d", &X0);
	long long ans = 0;
	for (int i = 1; i < N; ++i)
	{
		int X;
		scanf("%d", &X);
		ans += min(1ll * (X - X0) * A, 1ll * B);
		X0 = X;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long val = scanner.nextLong();
        HashMap<Long, Integer> factors = new HashMap<>();
        for (long i = 2; i <= Math.sqrt(val); i++) {
            while (val % i == 0) {
                factors.compute(i, (k, v) -> v == null ? 1 : v + 1);
                val = val / i;
            }
        }
        if (val != 1) {
            factors.compute(val, (k, v) -> v == null ? 1 : v + 1);
        }

        int result = 0;
        for (Map.Entry<Long, Integer> entry : factors.entrySet()) {
            int current = entry.getValue();
            for (int i = 1; i <= current; i++) {
                current -= i;
                result++;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35812
#include <iostream>

using namespace std;

int main(){
        int n,m,l;
        unsigned long sum = 0;

        cin >> n >> m >> l;

        int det_1[100][100];
        int det_2[100][100];

        for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++)
                        cin >> det_1[i][j];
        }       

        for(int i = 0; i < m; i++){
                for(int j = 0; j < l; j++)
                        cin >> det_2[i][j];
        }

        for(int k = 0; k < n; k++){
                for(int p = 0; p < l; p++){
                        for(int q = 0; q < m; q++){
                                sum += (det_1[k][q] * det_2[q][p]);
                        }

                        cout << sum;
                        if(p != (l-1)) cout << " ";                             
                        sum = 0;
                }
                cout << "\n";
        }
        return 0;
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstdint>
#include <vector>
#include <map>
#include <algorithm>
#include <tuple>

constexpr size_t dd[] = {size_t(-1), 0, 1};

int main() {
  size_t H, W, N;
  scanf("%zu %zu %zu", &H, &W, &N);

  std::map<std::pair<size_t, size_t>, int> g;
  for (size_t i = 0; i < N; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a;
    --b;

    for (size_t da: dd)
      for (size_t db: dd) {
        size_t na = a + da;
        size_t nb = b + db;
        if (!(na < H && nb < W)) continue;
        ++g[{na, nb}];
      }
  }

  std::vector<uintmax_t> res(10);
  res[0] = (H-2)*(W-2);
  for (const auto& p: g) {
    size_t a, b;
    std::tie(a, b) = p.first;
    if (a == 0 || a+1 == H || b == 0 || b+1 == W) continue;
    ++res[p.second];
    --res[0];
  }

  for (auto ri: res) printf("%ju\n", ri);
}


Measured memory_bytes: 56448
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VVI a(2, VI(n));
    REP(i, n) cin >> a[0][i];
    REP(i, n) cin >> a[1][i];

    int ans = 0;
    REP(i, n) {
        int tmp = 0;
        REP(j, i+1) tmp += a[0][j];
        FOR(j, i, n) tmp += a[1][j];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	string s, e = "erase", d = "dream", ans = "YES";
	cin >> s;
	for (int i = 0; i < s.size();) {
		if (s[i] == e[0]) {
			for (int j = 0; j < 5; j++) {
				if (i == s.size() || s[i] != e[j]) {
					ans = "NO";
					break;
				}
				i++;
			}
			if (i < s.size() && s[i] == 'r')i++;
		}
		else if (s[i] == d[0]) {
			for (int j = 0; j < 5; j++) {
				if (i == s.size() || s[i] != d[j]) {
					ans = "NO";
					break;
				}
				i++;
			}
			if (i + 2 < s.size() && s[i] == 'e' && s[i + 1] == 'r') {
				if (s[i + 2] == 'a')continue;
				i += 2;
			}
			else if (i + 1 < s.size() && s[i] == 'e' && s[i + 1] == 'r')i += 2;
		}
		else {
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#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() {
	string s;
	cin >> s;
	int ans = 0;
	while (true){
		if (s.find("0") == string::npos || s.find("1") == string::npos) break;
		for (int i = 0; i < s.size() - 1; i++){
			if (s[i] != s[i + 1]){
				ans += 2;
				string a = s.substr(0, i);
				string b;
				if (i == s.size() - 1) b = "";
				else b = s.substr(i+2);
				s = a + b;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,h,m;cin>>a>>b>>h>>m;
    long double hr = 0.5 * (h * 60 + m);
    long double PI = 3.14159265358979323846264338327950L;
    long double mr = 6.0 * m;
    long double arg = abs(hr-mr);
    arg = min(360.0L-arg,arg);
    // arg = min(180.0L-arg,arg);
    long double res = sqrtl(a*a+b*b-2*a*b*cosl(arg/180.0L*PI));
    printf("%.20Lf\n",res);
    return 0;
}


Measured memory_bytes: 4068
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

# 負、ゼロ、正の個数
np = 0
nA = []
zp = 0
pp = 0
pA = []

# Aの正負の判定
for i in A:
    if i < 0:
        np += 1
        nA.append(-i)
    elif i >0:
        pp += 1
        pA.append(i)
    else:
        zp += 1
nA=nA[::-1]
# この時点で、両方絶対値の昇順になっている

# K番目の積の正負の判定ように数を作成
ncc = np*pp
zcc = zp*(np+pp)+(zp*(zp-1))//2
pcc = (np*(np-1))//2+(pp*(pp-1))//2

# 負の場合
if K <= ncc:
    K = ncc-K
    # nAから一つとpAから一つをかける
    # 積がxより大きい個数を求めて、それを二分探査で狭めていく
    minK = 0
    maxK = 10**18+1
    while maxK-minK != 1:
        x = (maxK+minK)//2
        # 積がxより大きい個数をしゃくとり法で求める
        count = 0
        pos = pp-1
        for i in range(np):
            while pos != -1:
                if pA[pos] > x//nA[i]:
                    pos -= 1
                else:
                    break
            count += pos+1
        if count > K:
            maxK = x
        else:
            minK = x
    print(-maxK)
elif K <= (ncc+zcc):
    print(0)
# 正の場合
else:
    K-=(ncc+zcc)
    # nAとnAをかけるかpAとpAをかける
    minK = 0
    maxK = 10 ** 18
    x = 0
    while maxK-minK != 1:
        x = (maxK + minK) // 2
        # 積がxより大きい個数をしゃくとり法で求める
        count = 0
        pos = np-1
        for i in range(np):
            while pos !=-1:
                if nA[pos] > x//nA[i]:
                    pos -=1
                else:
                    break
            count += pos+1
            if nA[i]**2<x:
                count -= 1
        pos = pp-1
        for i in range(pp):
            while pos != -1:
                if pA[pos] > x // pA[i]:
                    pos -= 1
                else:
                    break
            count += pos + 1
            if pA[i] ** 2 < x:
                count -= 1
        count = count//2
        if count >= K:
            maxK = x
        else:
            minK = x
    print(maxK)


Measured memory_bytes: 97028
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int[] a = nextIntArray(sc, n);

		sc.close();

		int ans1 = max(a);

		int x = ans1/2;
		int minD = Integer.MAX_VALUE;
		int ans2=0;

		for(int i=0;i<n;i++) {
			if(a[i] == ans1) {
				continue;
			}
			if(minD > Math.abs(x-a[i])) {
				minD = Math.abs(x-a[i]);
				ans2 = a[i];
			}
		}

		out.println(ans1 + " " + ans2);

	}

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

	@SuppressWarnings("unused")
	private int max(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 50508
#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

template <typename T> string to_string(const T& n)
{
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

int main()
{
	int a, b;
	for (; cin >> a >> b;)
	{
		cout << ::to_string(a + b).length() << endl;
	}
}


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

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

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

    // output
    for (int i=0; i<N-1; i++) {
        cout << A.at(i) << " ";
    }
    cout << A.at(N-1) << endl;

    for (int i=1; i <= N-1; i++) {
        int v = A.at(i);
        int j = i - 1;
        while (j >= 0 && A.at(j) > v) {
            A.at(j+1) = A.at(j);
            j--;
        }
        A.at(j+1) = v;

        // output
        for (int i=0; i<N-1; i++) {
            cout << A.at(i) << " ";
        }
        cout << A.at(N-1) << endl;
    }

    return(0);
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, L;
    string ans;
    cin >> N >> L;
    vector<string> S(N);
    for(int i = 0; i < N; i++)
        cin >> S[i];
    
    sort(S.begin(), S.end());
    
    for(int i = 0; i < N; i++)
        ans += S[i];
    
    cout << ans << endl;
    
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	}
	else {
		puts("IMPOSSIBLE");
	}
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, x, d; cin >> n >> x >> d;


  if(d == 0 && x == 0) {
    cout << 1 << endl;
    return 0;
  } else if(d == 0) {
    cout << n+1 << endl;
    return 0;
  }

  if(d < 0) {
    x = -x;
    d = -d;
  }

  

  map<ll, set<pair<ll, ll>>> mp;

  mp[0].insert({0, 0});

  ll nowl = 0, nowr = n-1;
  ll sul = 0, sur = 0;
  for(ll i=1;i<=n;++i) {
    ll tmp = i * x;
    ll add = tmp / d;
    ll mod = tmp % d;
    sul += nowl;
    sur += nowr;
    nowl++;
    nowr--;
    if(sul > sur) break;
    mp[mod].insert({add + sul, add + sur});
  }

  ll ans = 0;
  for(auto &e1: mp) {
    ll r = -LINF;
    //cout << "i:" << i << endl;
    for(auto &e: e1.second) {
      //cout << e.first << ":" << e.second << endl;
      if(r < e.first) {
        ans += e.second - e.first + 1;
        r = e.second;
      } else if(r < e.second) {
        ans += e.second - r;
        r = e.second;
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 31488
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i64 n;
  scanf ("%" SCNi64, &n);
  i64 ans = 0;
  for (i64 i = 1;i <= n && (n - i) / i > i;++i) {
    if ((n - i) % i == 0) {
      ans += (n - i) / i;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

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

Measured memory_bytes: 128
use std::cmp::min;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, m: usize, x: usize);
    let mut c = vec![];
    let mut a = vec![];
    for i in 0..n {
        parse!(it, ci: usize, line: [usize; m]);
        c.push(ci);
        a.push(line);
    }

    let mut ret = std::usize::MAX;
    for i in 0..(1 << n) {
        let mut done = vec![0; m];
        let mut s = 0;
        for j in 0..n {
            if (i >> j) & 1 == 1 {
                s += c[j];
                for k in 0..m {
                    done[k] += a[j][k];
                }
            }
        }

        if done.iter().all(|&y| y >= x) {
            ret = min(ret, s);
        }
    }
    if ret == std::usize::MAX {
        println!("{}", -1);
    } else {
        println!("{}", ret);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2176
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=300005;



void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;int i=1;
    while(a>0&&c>0)
    {
        if(i%2)
        {
            c-=b;
            
        }
        else
        {
            a-=d;
        }
        i++;
        
    }
    if(c<=0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    cout<<endl;
}

int32_t main()
{
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
import scala.io.Source

object Main {
  def main(args:Array[String]) {
    
    for(line <- Source.stdin.getLines()) {
      val items = line.split(" ").toList.map(_.toInt)
      if (items(0) == 0 && items(1) == 0) {
        return      
      }
      
      for (hIndex <- (1 to items(0))) {
        val w = (1 to items(1)).toList.map{ wIndex => 
          if ((hIndex % 2 == 0 && wIndex % 2 != 0) || (hIndex % 2 != 0 && wIndex % 2 == 0)) "." 
          else "#"
        }
        println(w.mkString)
      }
      println("")
    }
  }
}

Measured memory_bytes: 49056
use proconio::input;

fn err() -> ! {
    println!("{}", -1);
    std::process::exit(0);
}

fn main() {
    input!(n: usize, d: [u64; n]);
    let mut ord: Vec<_> = (0..n).collect();
    ord.sort_by_key(|&i| std::cmp::Reverse(d[i]));
    let mut vid = vec![0; n];
    (0..n).for_each(|i| vid[ord[i]] = i);
    let mut d_sorted_reverse = d.clone();
    d_sorted_reverse.sort_by_key(|&x| std::cmp::Reverse(x));

    let mut g = vec![vec![]; n];
    let mut ans = vec![];
    let mut size = vec![1; n];
    for (si, &i) in ord.iter().enumerate().take(n - 1) {
        if n as u64 <= size[i] * 2 {
            err();
        }
        let di = d[i];
        let dj = di - n as u64 + 2 * size[i];
        let sj = d_sorted_reverse
            .binary_search_by_key(&std::cmp::Reverse(dj), |&x| std::cmp::Reverse(x))
            .unwrap_or_else(|_| err());
        assert!(si < sj);
        let j = ord[sj];
        size[j] += size[i];
        ans.push((i, j));
        g[j].push(i);
    }

    let root = ord[n - 1];
    fn dfs(x: usize, g: &Vec<Vec<usize>>, size: &Vec<u64>) -> u64 {
        dbg!(x);
        let mut ans = 0;
        for &y in &g[x] {
            ans += dfs(y, &g, &size) + size[y];
        }
        ans
    }
    if dbg!(dfs(root, &g, &size)) != dbg!(d[root]) {
        err();
    }
    for (u, v) in ans {
        println!("{} {}", u + 1, v + 1);
    }
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N);
    int best = 0, next = 0;
    for (size_t i = 0; i < N; i++)
    {
        int t;
        cin >> t;
        if (next<=t)
        {
            next=t;
            if (best<=t)
            {
                swap(best,next);
            }
            
        }
        
        A[i] = t;
    }
    for (size_t i = 0; i < N; i++)
    {
        if (A[i]!=best)
        {
            cout << best << endl;
        }else
        {
            cout << next << endl;
        }
        
        
    }
    
    return 0;
}


Measured memory_bytes: 2432
h, w = map(int, input().split())
s = [input() for i in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      top = max(0, i-1)
      bottom = min(h-1, i+1)
      right = min(w-1, j+1)
      left = max(0, j-1)
      if s[i][right] == s[i][left] == s[top][j] == s[bottom][j] == ".":
        print("No")
        exit()

print("Yes")

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

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


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

int main(void){
	char s[100];
	int len;
	int flag = 0;
	int k;

	scanf("%s", s);
	len = strlen(s);
	
	for (k = 0; k < len; k++) {
		if (k%2 == 0) {
			if(s[k] != 'h'){ flag = 1; break; }
		}
		if (k%2 == 1) {
			if(s[k] != 'i'){ flag = 1; break; }
		}
	}

	if (((len % 2) == 0)&&(flag == 0)) { puts("Yes"); } else { puts("No"); }

	return 0;
}


Measured memory_bytes: 128
//div game
#include <stdio.h>
#include <math.h>

int main(void){
    unsigned long int n;
    unsigned long int sq_n;
    unsigned int i=2;
    unsigned long int cnt = 0;
    unsigned long int div;
    
    scanf("%lu",&n);
    sq_n = sqrt(n);

    if(n%i==0) {//i=2
        div = i;
        while(n%div==0){
            n/= div;
            div *= i;
            cnt ++;
        }
        while(n%i == 0) n/=i;
    }

    for(i = 3;i<=sq_n;i+=2){
        if(n%i==0) {
            div = i;
            while(n%div==0){
                n/= div;
                div *= i;
                cnt ++;
            }
            while(n%i == 0) n/=i;
        }
    }
    if(n != 1) cnt ++;
    printf("%lu",cnt);

    return 0;
}


Measured memory_bytes: 2148
def main():
    n, *a = open(0).read().split()
    if int(n) % 2:
        print(" ".join(reversed(a[0::2])), end=" ")
        print(" ".join(a[1::2]))
    else:
        print(" ".join(reversed(a[1::2])), end=" ")
        print(" ".join(a[0::2]))
    return


main()


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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
int a[N], n;

bool check(int k)
{
	for (int i = 0; i < n - 1; ++i)
	{
		if (a[n + i] > k && a[n + i + 1] > k) return 0;
		if (a[n - i] > k && a[n - i - 1] > k) return 0;
		if (a[n + i] <= k && a[n + i + 1] <= k) return 1;
		if (a[n - i] <= k && a[n - i - 1] <= k) return 1;
		
	}
	return a[1] <= k && a[2 * n - 1] <= k;
}

int main()
{
	n = read();
	for (int i = 1; i <= 2 * n - 1; ++i) a[i] = read();
	
	int l = 1, r = 2 * n - 1;
	while (l < r)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
			else l = mid + 1;
	}
	printf("%d\n", l);
	
	return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b/a<c) cout << b/a << endl;
	else cout << c << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

a = input().split()
x = abs(int(a[0]))
count = int(a[1])
d = int(a[2])

num = x // d
if abs(x - d * num) <= abs(x - d * (num + 1)):
  num += 1
else:
  num = num
  
if count == num:
  mini = abs(x - d * num)
elif count > num:
  count -= num
  if count % 2 == 0:
    mini = abs(x - d * num)
  else:
    a = abs(abs(x - d * num) - d)
    b = abs(abs(x - d * num) + d)
    if a >= b:
      mini = b
    else:
      mini = a
else:
  mini = abs(x - d * count)
print(mini)

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;

#define int long long
#define double long double
#define pii pair<int, int>
#define mp make_pair

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int N = 2e5 + 10;
int a[N];
int vis[N];
int cnt[N];
int r[N];

signed main() {
    fast();
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    memset(cnt, -1, sizeof(cnt));
    memset(vis, -1, sizeof(vis));
    for (int i = n - 1; i >= 0; i--) {
        r[i] = cnt[a[i]];
        cnt[a[i]] = i;
    }
    int cur = 0, pos = 0;
    int cyc = -1;
    while (cur + 1 < k) {
        if (vis[pos] != -1) {
            cyc = cur - vis[pos];
            break;
        }
        vis[pos] = cur;
        if (r[pos] != -1) {
            pos = r[pos];
        } else {
            pos = cnt[a[pos]];
            cur++;
        }
        if (pos == n - 1) {
            pos = 0; cur++;
        } else pos++;
    }
    if (cyc != -1) {
        cur = (k - 1 - cur) / cyc * cyc;
    }
    while (cur < k - 1) {
        if (r[pos] != -1) {
            pos = r[pos];
        } else {
            pos = cnt[a[pos]];
            cur++;
        }
        if (pos == n - 1) {
            pos = 0; cur++;
        } else pos++;
    }
    if (cur == k - 1) {
        for (int i = pos; i < n; ) {
            if (r[i] == -1) {
                cout << a[i] << ' ';
                i++;
            } else {
                i = r[i] + 1;
            }
        }
    }
    return 0;
}

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

#define int long long int

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

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x;
    cin >> x;
    while (!IsPrime(x)) x++;
    cout << x << "\n";

    return 0;
}


Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	n, k := nextInt(), nextInt()

	n = n % k

	ans := 0
	if n < k-n {
		ans = n
	} else {
		ans = k - n
	}
	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll N = 100;
    ll y = 0;
    while (N < X) {
        N += N / 100;
        y++;
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
bool result = true;
int main(){
    LCIN(N);
    V<LL> vec;
    LCIN(X);
    REP(a,N){
        LCIN(b);
        vec.pb(b);
    }
    int ans = 0;
    sort(ALL(vec));
    for(int a = 0;a < N;a++){
        if(X - vec.at(a) >= 0){
            ans++;
            X-= vec.at(a);
        }else{
            result = false;
            break;
        }
    }
    if(X > 0 && result){
        ans--;
    }
    COUT(ans);
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  int64_t ans=1;
  rep(i,n){
    int64_t x;
    cin >> x;
    if(x!=0)if(ans<=1000000000000000000/x&&ans!=-1)ans*=x;
    else ans=-1;
    if(x==0) ans=0;
  }
  cout << ans << endl;

}

Measured memory_bytes: 3648
#include<stdio.h>
int uru(int year){
  if(year%4)
    return 0;
  else if(year%100)
    return 1;
  else if(year%400)
    return 0;
  else
    return 1;
}
int main(){
  int g=0,h,i;
  int yb,ye;
  for(;;){
    scanf("%d%d",&yb,&ye);
    if(yb==0&&ye==0)
      break;
    if(g)
      puts("");
    g=1;
    h=1;
    for(i=yb;i<ye+1;i++){
      if(uru(i)){
	printf("%d\n",i);
	h=0;
      }
    }
    if(h)
      puts("NA");
  }
  return 0;
}

Measured memory_bytes: 0
MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
DP = [[0] * (1 + S) for _ in range(1 + N)]  # DP[i][j] はi番目までみた時に総和がjと成る組み合わせの総和
# 初期化
DP[0][0] = 1
# 漸化式　DP[i][j] = DP[i-1][j]*2 + DP[i-1][j-A[i]]
for i in range(1, N + 1):
    for j in range(S + 1):
        if j >= A[i - 1]:
            DP[i][j] = DP[i - 1][j] * 2 + DP[i - 1][j - A[i - 1]]
        else:
            DP[i][j] = DP[i - 1][j] * 2
        DP[i][j] %= MOD
print(DP[N][S])


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

constexpr long long mod{1000000007};

std::string k;
int d;
using vll = std::vector<long long>;
using vvll = std::vector<vll>;
std::vector<vvll> digit_dp;

long long rc(const unsigned int, const int, const int);

int main()
{
	std::cin >> k >> d;
	digit_dp.resize(k.size() + 1, vvll(d, vll(2, -1)));
	digit_dp[k.size()][0][0] = digit_dp[k.size()][0][1] = 1;
	for (int i{1}; i < d; i++)
		digit_dp[k.size()][i][0] = digit_dp[k.size()][i][1] = 0;
	printf("%lld\n", (rc(0, 0, 1) + mod - 1) % mod);

	return 0;
}

long long rc(const unsigned int digit, const int rest, const int tight)
{
	long long& sum{digit_dp[digit][rest][tight]};
	if (sum >= 0) return sum;
	sum = 0;

	int limit{10};
	if (tight) limit = k[digit] - '0';

	for (int i{}; i < limit; i++)
	{
		sum += rc(digit + 1, (rest + i) % d, false);
		sum %= mod;
	}
	if (tight)
	{
		sum += rc(digit + 1, (rest + limit) % d, true);
		sum %= mod;
	}
	return sum;
}

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

using namespace std;
const int INF = 1 << 28;

template <typename T> void floyd_warshall(vector<vector<T>> &graph) {
  for (int k = 0; k < (int)graph.size(); k++) {
    for (int i = 0; i < (int)graph.size(); i++) {
      for (int j = 0; j < (int)graph.size(); j++) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  vector<vector<int>> graph(N, vector<int>(N, INF));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  floyd_warshall(graph);
  int res = INF;
  vector<int> c(R);
  for (int i = 0; i < R; i++) {
    c[i] = i;
  }
  do {
    int d = 0;
    for (int i = 0; i < R - 1; i++) {
      d += graph[r[c[i]]][r[c[i + 1]]];
    }
    res = min(res, d);
  } while (next_permutation(c.begin(), c.end()));
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
string S;
// main solution goes here:
void execute(int test_number)
{
    cin>>S;
    if (S == "AAA" || S == "BBB") cout<<"No";
    else cout<<"Yes";
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 3452