akhauriyash/Code-Regression huggingface dataset:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str (gensym "STR")))
    (labels ((expand (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str :start ,pos1 :test #'char=))
			    (,(car arg-lst) (parse-integer ,str :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr arg-lst) nil))))))
      `(let ((,str ,string))
         (declare (string ,str))
	 ,@(expand arg-lst)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defstruct city
  (year 0 :type uint31)
  (prefecture 0 :type uint31)
  (version 0 :type uint31))

(defun main ()
  (let* ((n (read))
         (m (read))
         (p-table (make-array (list (1+ n)) :element-type 'list :initial-element nil))
         (city-table (make-array (list m) :element-type 'list :initial-element nil)))
    ;; node := (prefecture year version)
    (dotimes (city-idx m)
      (split-and-bind (prefecture year) (read-line)
        (let ((node (make-city :prefecture prefecture :year year)))
          (push node (aref p-table prefecture))
          (setf (aref city-table city-idx) node))))
    (loop for p-idx from 1 to n
          do (setf (aref p-table p-idx)
                   (sort (aref p-table p-idx) #'< :key #'city-year))
             (loop for node in (aref p-table p-idx)
                   for version from 1
                   do (setf (city-version node) version)))
    (dotimes (city-idx m)
      (format t "~6,'0D~6,'0D~%"
              (city-prefecture (aref city-table city-idx))
              (city-version (aref city-table city-idx))))))

#-swank(main)


Measured memory_bytes: 69476
n, y = map(int, input().split())

none = True

for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if (i*10000 + j*5000 + k*1000) == y and k >= 0:
            none = False
            break
    if none == False:
        break
if none:
    print('-1 -1 -1')
else:
    print("{} {} {}".format(i, j, k))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }

vector<ll> Eratosthenes(const ll N)
{
    vector<bool> is_prime(N+1);
    for (ll i=0; i<=N; i++) is_prime[ i ] = true;
    vector<ll> P;
    for (ll i=2; i<=N; i++){
        if (is_prime[i]){
            for (ll j=2*i; j<=N; j+=i){
                is_prime[j] = false;
            }
            P.push_back(i);
        }
    }
    return P;
}

int main() {
    vector<ll> a = Eratosthenes(1e5);
    ll n = a.size();
    map<ll, ll> m;
    rep1(i, n) m[a[i]]++;
    vector<ll> ans(1e5+10);
    for (ll i=1; i<1e5; i+=2){
        if (m[i]>0 && m[(i+1)/2]>0){
            ans[i] = ans[i-1] + 1;
            ans[i+1] = ans[i];
        }
        else{
            ans[i] = ans[i-1];
            ans[i+1] = ans[i];
        }
    }
    ll q;
    cin >> q;
    rep1(i, q){
        ll l, r;
        cin >> l >> r;
        cout << ans[r]-ans[l-1] << endl;
    }
    //printf("%.12f", ans);
}

Measured memory_bytes: 7316
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,q,appe[100010][20],coap[100010],len=0;//appe:appearance
int list_top[100010],val[200010],nxt[200010];

void add(int x,int y)
{
	val[++len]=y;
	nxt[len]=list_top[x];
	list_top[x]=len;
}

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	cin>>q;
	repn(i,q)
	{
		int x,y;
		scanf("%d%d%d",&x,&y,&coap[i]);
		appe[x][y]=i;
	}
	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 
	{
		repn(p,n)
		{
			for(int k=list_top[p];k!=0;k=nxt[k])//i在这里代表可以控制的范围
			{
				int j=val[k];
				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，
				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/
			}	
		}	
	} 
	repn(i,n)
	{
		int lst=0;
		rep(j,11) lst=max(lst,appe[i][j]);
		cout<<coap[lst]<<endl;
	}
	rt0;
}

Measured memory_bytes: 10752
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = []
for i in range(3):
  n = IL()
  for j in n:
    a.append(j)

N = I()
used = [False]*9
for _ in range(N):
  n = I()
  for i in range(9):
    if a[i] == n:
      used[i] = True

f = 0
if all(used[0:3]) or all(used[3:6]) or all(used[6:9]):
  f = 1
if (used[0] and used[3] and used[6]) or (used[1] and used[4] and used[7]) or (used[2] and used[5] and used[8]):
  f = 1
if (used[0] and used[4] and used[8]):
  f = 1
if (used[2] and used[4] and used[6]):
  f = 1
if f == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
#include<iostream>
main(){for(int n,s,t,M,m,i;std::cin>>n,n;printf("%d %d\n",M,m))for(M=0,m=500;n-->0;M<t&&(M=t),t<m&&(m=t))for(t=i=0;i++<5;t+=s)std::cin>>s;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    v a(n);in(a,n);
    int ans=0;
    f(i,n)
    {
        if(i&1)continue;
        if(a[i]&1)
            ans++;

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

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

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

	vector<int> W(N);
	for(int i = 0; i < N; i++){
		cin >> W[i];
	}

	int ans = 	2147483647;
	for(int i = 0; i < N; i++){
		int S1, S2; S1 = S2 = 0;
		for(int j = 0; j < N; j++){
			if(j <= i) S1 += W[j];
			else S2 += W[j];
		}

		if(ans > abs(S1 - S2)) ans = abs(S1 - S2);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main() {
  ll n, pri_h;
  cin >> n >> pri_h;
  string ans = "Yes";
  for (ll i = 1; i < n; i++) {
    ll h;
    cin >> h;
    if (pri_h < h) {
      h--;
    }
    else if (pri_h > h) {
      ans = "No";
      break;
    }
    pri_h = h;
  }
  
  cout << ans << endl;
}

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

#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPe(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define REPI(i, a, b) for (int(i) = int(a); (i) < int(b); ++(i))
#define REPIe(i, a, b) for (int(i) = int(a); (i) <= int(b); ++(i))

using namespace std;

int main()
{
    int Z;           //入力待ち
    int j, k;        //for文用
    string to = ","; //デバッグ用
    int e_count = 0; //演算回数を数える
    int count = 0;   //よくあるカウント
    //----------

    int a;
    cin >> a; //500の枚数
    int b;
    cin >> b;
    int c;
    cin >> c;

    int x;
    cin >> x;

    //Xは50の倍数
    REPe(i, a) //500を使う枚数を定める
    {

        REPe(ii, b) //100を使う回数を定める
        {

            REPe(iii, c) //50を使う枚数によって，xをつくれたらカウント
            {
                //cout << i << to << ii << to << iii << endl;

                if (i * 500 + ii * 100 + iii * 50 == x)
                {
                    //cout << "O" << endl;
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    //-----------
    cin >> Z;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define nl n<<1
#define nr (n<<1) |1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=1e9+7;
int main()
{
    ll k;
    scanf("%lld",&k);
        printf("50\n");
        ll num=k%50;
        for(ll i=1;i<=num;i++)
        {
            printf("%lld ",k/50+100-k%50);
        }
        for(ll i=num+1;i<=50;i++)
            printf("%lld ",k/50+50-k%50-1);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    string s;
    int K;
    cin >> s >> K;

    char alpha[26];
    for(int i = 0; i < 26; ++i){
        alpha[i] = 'a' + i;
        //cerr << alpha[i] << endl;
    }

    set<string> sub;
    for(int start = 0; start < s.length(); ++start){
        for(int i = 1; i <= 5; ++i){
            if(start + i <= s.length()) sub.insert(s.substr(start, i));
        }
    }
    string ans;
    int cnt = 0;
    for(set<string>::iterator itr = sub.begin(); itr != sub.end(); ++itr){
        cnt++;
        ans = *itr;
        if(cnt == K) break;
    }
    cout << ans << endl;
    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    long long arr[n + 1];
    ll count = 1;
    for(ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    ll mini = arr[0];
    for(ll i = 1; i < n; i++)
    {
        if(arr[i] < mini)
        {
            count++;
            mini = arr[i];
        }
    }
    cout << count << endl;


    return 0;
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int x, y, z, k;
ll a[1005], b[1005], c[1005];
ll sum[10000005];
int num;
int main()
{
	std::cin >> x >> y >> z >> k;
	for (int i = 0; i < x; ++i)
		std::cin >> a[i];
	for (int i = 0; i < y; ++i)
		std::cin >> b[i];
	for (int i = 0; i < z; ++i)
		std::cin >> c[i];

	std::sort(a, a + x, std::greater<ll>());
	std::sort(b, b + y, std::greater<ll>());
	std::sort(c, c + z, std::greater<ll>());

	for (int i = 0; i < x; ++i)
		for (int j = 0; j < y; ++j)
			for (int l = 0; l < z; ++l)
				if ((i + 1)*(j + 1)*(l + 1) <= k)
					sum[num++] = a[i] + b[j] + c[l];
				else
					break;

	std::sort(sum, sum + num, std::greater<ll>());
	for (int i = 0; i < k; ++i)
		std::cout << sum[i] << std::endl;
	return 0;
}


Measured memory_bytes: 1152
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
mod=998244353

inv=[0]*(3*M//2+N+2)
inv[1]=1
for i in range(2,3*M//2+N+2):
    inv[i]=-(mod//i)*inv[mod%i]%mod

#階乗テーブル
g1=[1,1]
g2=[1,1]
for i in range(2,3*M//2+N+2):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(g2[-1]*inv[i]%mod)
    
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod

#奇数の和で場合分け
#iは奇数の数

ans=0
for i in range(min(N+1,M+1)):
    if M%2!=i%2:
        continue
    m=(3*M-i)//2
    num=(cmb(m+N-1,N-1)-i*cmb(m-M+N-1,N-1))%mod
    if m>=M+1:
        num=(num-(N-i)*cmb(m-M+N-2,N-1))%mod
    ans=(ans+cmb(N,i)*num)%mod

print(ans)    

Measured memory_bytes: 131504
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n, k;
string s;

vector<pair<int,int> > d;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	 
	cin >> n >> k;
	cin >> s;

	int i = 0;
	while (i < n) {
		if (s[i] == '1')
			++i;
		else {
			int j = i+1;
			while (j < n && s[j] == '0')
				++j;

			d.push_back(make_pair(i, j));
			i = j;
		}
	}

	int ans = 0;
	if (d.size() <= k)
		ans = n;
	else {
		ans = d[k].first;

		for (int i = k; i < d.size(); ++i) {
			int en = i == d.size()-1 ? n : d[i+1].first;
			ans = max(ans, en - d[i-k].second);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1020
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7

    N = int(input())
    ans = [0]*(N+1)
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                if x*x + y*y + z*z + x*y + y*z + z*x > N:
                    break
                else:
                    ans[x*x + y*y + z*z + x*y + y*z + z*x] += 1

    for a in ans[1:]:
        print(a)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 74408
import sys

coins = [1,5,10,50,100,500]

for i in sys.stdin:
    if int(i) == 0:
        break

    n =1000-int(i)
    c = [ i for i in range(n+1) ]
    for i in range(len(coins)):
        coin = coins[i]
        if coin <= n:
            c[coin] = 1
            coins.append(coin)

    for coin in coins:
        for p in range(coin+1, n+1):
            minc = c[p]
            if minc == 1:
                continue
            c[p] = c[p-coin]+1 if minc > c[p-coin] + 1 else minc

    print(c[n])

Measured memory_bytes: 7608
import math
a , b = map(int,input().split())
al = math.ceil(a / 0.08)
ar = math.floor((a + 1)/0.08)
bl = math.ceil(b/0.1)
br = math.floor((b+1)/0.1)
ans = 0
if al <= bl and ar > bl:
    ans = bl
elif al >= bl and br > al:
    ans = al
else:
    ans = -1
print(ans)

Measured memory_bytes: 3064
<?php
$num_data = trim(fgets(STDIN));

// arr[4][3][10]
$rooms = array_fill(0, 4,
           array_fill(0, 3,
             array_fill(0, 10, 0)));

while ($num_data-- > 0) {
  $input = trim(fgets(STDIN));
  $data  = explode(" ", $input);
  $rooms[$data[0]-1][$data[1]-1][$data[2]-1] += $data[3];
}

$num_bldg = 0;
foreach ($rooms as $bldg) {
  if ($num_bldg > 0) {
    echo "####################" . PHP_EOL;
  }
  $num_bldg++;

  foreach ($bldg as $floor) {
    echo " " . implode(" ", $floor) . PHP_EOL;
  }
}

Measured memory_bytes: 15492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) #x " = " << x
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#define YesNo(c) ((c) ? "Yes" : "No")
#define quit(x) { cout << (x) << endl; return 0; }
#define DEBUG 1
#define debug if (DEBUG)
typedef long long ll;
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;

template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }

template <class T> typename conditional<true, ostream&, decltype(declval<T>().begin())>::type operator<<(ostream& os, T const& v) { for (auto const& x : v) os << x << " "; return os; }
template <class T> typename conditional<true, istream&, decltype(declval<T>().begin())>::type operator>>(istream& is, T& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.fst << ", " << p.snd << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.fst >> p.snd; }

#define double long double
const double eps = 1e-5;

int main() {
    cout << fixed << setprecision(20);
    
    int n; cin >> n;
    vector<double> x(n), y(n);
    rep (i,n) cin >> x[i] >> y[i];

    double m = 0;
    rep (i,n) {
            // //
            // cout << show(i) << endl;
        double xx = -y[i], yy = x[i];
        for (double k1 : { +1, -1 }) for (double k2 : { +1, -1 }) {
            double sx = 0, sy = 0;
            double xxx = xx - eps*yy*k1;
            double yyy = eps*xx*k1 + yy;
            rep (j,n) if (k2*(x[j]*xxx+y[j]*yyy)>0) {
                // //
                // cout << show(j) << endl;
                sx += x[j];
                sy += y[j];
            }
            //
//            if (chmax(m,hypot(sx,sy))) cout << i << " ";
            chmax(m,hypot(sx,sy));
        }
    }
    cout << m << endl;

    
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
big = max(a)
small = min(a)
if small >= 0:
    print(n-1)
    for i in range(1,n):
        print(i,i+1)
elif big <= 0:
    print(n-1)
    for i in range(n-1):
        print(n-i,n-i-1)
else:
    if big + small > 0:
        print(2*n-1)
        p = a.index(big)
        for i in range(1,n+1):
            print(p+1,i)
        for i in range(1,n):
            print(i,i+1)
    else:
        print(2*n-1)
        q = a.index(small)
        for i in range(1,n+1):
            print(q+1,i)
        for i in range(n - 1):
            print(n - i, n - i - 1)

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	cout << a * b / g;

	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++

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll C[51][51];
void comb_table(int N){
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0 || j == i)
                C[i][j] = 1LL;
            else
                C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

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

    int odd = 0;
    int even = 0;
    REP(i,N){
        int a;
        cin >> a;
        if(a % 2) odd++;
        else even++;
    }

    ll ans = 0;

    ll neven = (1LL << even);

    comb_table(odd);


    ll nodd = 0;
    for(int i = P; i <= odd; i+=2){
        nodd += C[odd][i];
    }

    ans += nodd * neven;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (a <= k) {
		sum += a;
		k -= a;
	}
	else {
		cout << k << endl;
		return 0;
	}
	k = k - b;
	if (k <= 0) {
		cout << sum << endl;
		return 0;
	}
	else {
		cout << sum - k << endl;
	}
	return 0;
}


Measured memory_bytes: 3676
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.buffer.readline()[:-1]
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
up = int(N**(1/2))+1
ans = [0]*(N+1)
for x in range(1, up):
    for y in range(1, up):
        for z in range(1, up):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if tmp <= N:
                ans[tmp] += 1
print(*ans[1:], sep="\n")


Measured memory_bytes: 10392
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll pred = 0;
    ll v = a[0];
    repi(i, n) {
        ll gcd = GCD(v, a[i]);
        v = v * (a[i]) / gcd;
    }
    v /= 2;
    rep(i, n) {
        if (v % a[i] != a[i] / 2) {
            put(0);
            return;
        }
    }

    put((m / v + 1) / 2);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4016
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int calc(int x){
    int res=0;
    while(x>0){
        res+=x%10;
        x/=10;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    int A=1, B=N-1, mn=INF;
    while(A<=B){
        mn=min(mn,calc(A++)+calc(B--));
    }
    cout1(mn);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
S = list(str(input()))

if N % 2 == 1:
    print("No")
else:
    a = 0
    for i in range(int(N/2)):
        if S[i] == S[int(N/2) + i]:
            a += 1
    if a == int(N/2):
        print("Yes")
    else:
        print("No")


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("input.in", "r")) {
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
  }

  string s, t;
  cin >> s >> t;

  // dp[i][j] = lcs for s[0...i] and t[0...j]

  vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
  dp[0][0] = 0;

  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      // if characters are the same, then do i-1, j-1
      if (s[i-1] == t[j-1]) dp[i][j] = 1+dp[i-1][j-1];

      // if characters not the same, move either i back or j back
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }

  //cout << dp[s.size()][t.size()] << endl;

  int i = s.size(), j = t.size();
  string lcs = "";
  while (i > 0 && j > 0) {
    if (s[i-1] == t[j-1]) {
      lcs += s[i-1]; i--; j--;
    } else if (dp[i-1][j] > dp[i][j-1]) {
      i--;
    } else {
      j--;
    }
  }

  string reversed(lcs.rbegin(), lcs.rend());
  cout << reversed << endl;

  return 0;
}

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

int main()
{
	int n, x, m = 0;
	int l[100];

	cin >> n >> x;

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

	for (int i = 0; i < n; i++){

		m += l[i];

		if (m > x) {
			cout << i + 1 << endl;
			break;
		}
		else if (i == n - 1)
			cout << n + 1 << endl;
	}
	
	return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    string s;
    cin >> s;
    int n = s.length();
    bool ok = true;
    REP(i, n - 1)
    {
        if (s[i] == s[i + 1])
        {
            ok = false;
        }
    }

    printf("%s", ok ? "Good" : "Bad");

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    S=[SI() for i in range(n)]
    ans=0
    if n==1:
        print(1)
        sys.exit()
    st=n*(n-1)//2
    for b in range(n):
        count=0
        for i in range(n-1):
            for j in range(i+1,n):
                #print(b,i,j)
                #print(i,(j+b)%n,j,(i+b)%n)
                if S[i][(j+b)%n]==S[j][(i+b)%n]:
                    count+=1
            if count==st:
                ans+=n
    print(ans)
        
        
                





if __name__=="__main__":
    main()


Measured memory_bytes: 73884
#include <stdio.h>

int main(void)
{
	int n, m, l, i, j, k;
	int a[101][101], b[101][101];
	long c[101][101] = {0};

	scanf("%d %d %d", &n, &m, &l);

	for (i = 0;i < n;i++)
	{
		for (j = 0;j < m;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0;i < m;i++)
	{
		for (j = 0;j < l;j++)
		{
			scanf("%d", &b[i][j]);
		}
	}

	

	for (i = 0;i < n;i++)
	{
		for (j = 0;j < l;j++)
		{
			for (k = 0;k < m;k++)
			{
				c[i][j] =c[i][j]+ a[i][k] * b[k][j];
			}
			printf("%ld", c[i][j]);
			if (j<l-1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
	Point operator * (double a) {return Point(x*a,y*a);}
	Point operator / (double a) {return Point(x/a,y/a);}
	double absv() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x != p.x ? x<p.x: y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};


double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

//----------------kokomade temple------------
int zz(double a){
if(a>EPS) return 1;
else if(a<-EPS) return -1;
else return 0;
}


int main(){
int n,k=0;
double x,y;
cin>>n;
Point a[110];
Vector v[110];
for(int i=0;i<n;i++){
cin>>x>>y;
a[i].x=x;
a[i].y=y;
}
a[n]=a[0];
for(int i=0;i<n;i++){
v[i]=a[i]-a[i+1];
}
v[n]=v[0];
int ans=0;
for(int i=0;i<n;i++){
ans=ans+zz(cross(v[i],v[i+1]));
if(zz(cross(v[i],v[i+1]))==0) k++;
}
if(ans==n-k || ans==-n+k) cout<<"1"<<endl;
else cout<<"0"<<endl;


}

Measured memory_bytes: 1228
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
bool prime[50500];
int ans[50500];
int main()
{
  for(int i = 0;i <=50000;i++){
    prime[i] = true;
  }
  prime[0] =false;
  prime[1] = false;
  for(int i = 2;i*i<=50000;i++){
    if(prime[i]){
      for(int j =i*2;j <=50000;j+=i){
	prime[j] =false;
      }
    }
  }
  vector<int> P;
  for(int i = 2;i <=50000;i++){
    if(prime[i]){
      P.push_back(i);
    }
  }
  for(int i =0;P[i] <=25000;i++){
      for(int j = i;P[j]+P[i] <=50000;j++){
	ans[P[i]+P[j]]++;
	}
  }

  int n;
  while(cin>>n,n){
    cout <<ans[n]<<endl;
  }
  return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int m;
    cin >> m;
    cout << 24 + 24 - m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
 
int main() {
	int A, B;
	cin >> A >> B;

  	
	if(  A >= 0 && B >= 0){
    	std::cout << "Positive";
        return 0;
    };
	if(A <= 0 && B<= 0){
      if((B-A + 1)%2 == 0){
        std::cout << "Positive";
      }
      else std::cout << "Negative";
      return 0;
    }
  if(A <= 0 && B >= 0){
    std::cout << "Zero";
  }
	return 0;
}

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

int main(){
    char a, b;
    scanf("%c %c",&a,&b);
    
    if((a=='H'&&b=='H')||(a=='D'&&b=='D')){
        printf("H\n");
    }else{
        printf("D\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13) cout << b;
    else if (a <= 5) cout << 0;
    else cout << b/2;

    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res ++;
    n /= 10;
  }
  return res;
}

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

  vector<int> ans(N);
  vector<int> ans2(N,-1);
  vector<int> s(M);
  vector<int> c(M);
  vector<pair<int,int>> sc(M);
  for(int i = 0; i < M; i++){
    cin >> s[i] >> c[i];
  }
  for(int i = 0; i < M; i++){
    sc[i] = make_pair(s[i], c[i]);
  }
  sort(sc.begin(), sc.end());

  // cout << "--" << endl;
  // for(int i = 0; i < M; i++){
  //   cout << sc[i].first << ", " << sc[i].second << endl;
  // }

  for(int i = 1; i < M; i++){
    if(sc[i-1].first == sc[i].first 
      && sc[i-1].second != sc[i].second){
        cout << -1 << endl;
        return 0;
      } 
  }
  if(N > 1){
    for(int i = 0; i < M; i++){
      if(sc[i].first == 1 
        && sc[i].second == 0){
          cout << -1 << endl;
          return 0;
        }
    }
  }

  // if(N == 1 && M == 0){
  //   cout << 0 << endl;
  //   return 1;
  // }
  if(M == 0){
    if(N == 3){
      cout << 100 << endl;
      return 0;
    }else if(N == 2){
      cout << 10 << endl;
      return 0;
    }else if(N ==1){
      cout << 0 << endl;
       return 0;
    }
  }


  for(int i = 0; i < M; i++){
    ans[sc[i].first-1] = sc[i].second;
    ans2[sc[i].first-1] += 2;
  }
  //     cout << "---" << endl;
  // for(int i = 0; i < M; i++){
  //     cout << ans2[i] << endl;
  //     cout << ",";
  // }
  //     cout << endl;
  //     cout << "---" << endl;
  for(int i = 0; i < N; i++){
    if(ans2[i] > 0){
      cout << ans[i];
      // cout << "a" << endl;
    }else if(i == 0 && N != 1){
      cout << 1;
      // cout << "b" << endl;
    }else{
      cout << 0;
      // cout << "c" << endl;
    }
  }
  cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	lint y; cin>>y;
	int d=0;
	lint x = 100;
	while(x < y){
		x += x/100;
		d++;
	}
	cout<<d<<"\n";
	return 0;	
}



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

int main(){
  int n, y, one = -1, five = -1, ten = -1;

  cin >> n >> y;

  for(int i = 0; i < n + 1; i++){
    for(int j = 0; j < n - i + 1; j++){
      if(10000 * i + 5000 * j + 1000 * (n - i - j) == y){
        one = i;
        five = j;
        ten = n - i - j;
      }
    }
  }

  cout << one << ' ' << five << ' ' << ten << endl;
}


Measured memory_bytes: 256
import math


def agg_gcd(i, j, k):
    gcd = math.gcd(i, j)
    gcd = math.gcd(gcd, k)
    return gcd


K = int(input())

count = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j and j == k:
                count += agg_gcd(i, j, k)
            elif i == j or j == k:
                count += 3 * agg_gcd(i, j, k)
            else:
                count += 6 * agg_gcd(i, j, k)

print(count)


Measured memory_bytes: 9224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main( void ){
    int nCount = 0;
    int n[50];
    int m = 0;
    char str[3];
    while( scanf( "%d",&n[m] ) != EOF ) m++;

    for( int a = 0;a < m;a++ ){
    for( int i = 0;i < 10;i++ ){
        for( int j = 0;j < 10;j++ ){
            for( int k = 0;k < 10;k++ ){
                for( int l = 0;l < 10;l++ ){
                    if( i+j+k+l == n[a] ) nCount++;
                }
            }
       }
    }
    printf( "%d\n",nCount );
    nCount = 0;
    }
    return 0;
} 

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<long long, long long>> xh(n);
  for (int i = 0; i < n; i++) {
    cin >> xh[i].first >> xh[i].second;
  }
  sort(xh.begin(), xh.end());
  int cur = 1;
  vector<long long> cnt(n);
  for (int i = 0; i < n; i++) {
    cnt[i] = (long long) ceil((double) xh[i].second / a);
  }
  vector<long long> cnt2(n, 0);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    while (cur < n && xh[cur].first <= xh[i].first + 2 * d) {
      cur++;
    }
    long long t = max(0LL, cnt[i] - cnt2[i]);
    ans += t;
    cnt2[i] += t;
    if (i == n - 1) break;
    cnt2[cur] -= t;
    cnt2[i + 1] += cnt2[i];
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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(){
    int n;cin >> n;
    vector<int> to[n+1];
    rep(i,n-1){
        int a,b;cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int cntF=0,cntS=0;
    vector<int> used(n+1,-1);
    queue<P> q;
    q.push({1,0});
    q.push({n,1});
    used[1]=0;
    used[n]=1;
    while(!q.empty()){
        int nowp=q.front().first;
        int nowc=q.front().second;
        q.pop();
        for(auto next: to[nowp]){
            if(used[next]!=-1) continue;
            used[next]=nowc;
            if(nowc==0) cntF++;
            if(nowc==1) cntS++;
            q.push({next,nowc});
        }
    }
    if(cntF<=cntS) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;

int op(int a, int b){
  return max(a, b);
}

int e(){
  return 0;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  segtree<int, op, e> seg(300'005);
  for(auto now : a){
    int mx = seg.prod(max(0, now-k), min(300'005, now+k+1));
    seg.set(now, mx+1);
  }
  cout << seg.all_prod() << endl;
  return 0;
}

Measured memory_bytes: 9568
/*

Crux :- Multidimensional DP and DP optimizations, Prefix sums

created by sanyam singhal
*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;
ll dp[101][100001];

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

void solve(){
  ll n,k; 
  cin>>n>>k;

  vector<ll>candies(n+1);
  loop(i, 1, 1+n)
    cin>>candies[i];
  memset(dp, 0, sizeof(dp));

  for(int j=0; j<=k; j++){
    dp[1][j] = (candies[1] >= j) ? 1 : 0;
  }

  for(int i=0; i<=n; i++){
    dp[i][0]=1;
  }

  for(int i=2; i<=n; i++){
    for(int j=1; j<=k; j++){
      dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - ((j-candies[i]-1)<0 ? 0 : dp[i-1][j-candies[i]-1]))%mod;
    }
  }

  // for(int i=0; i<=n; i++) {
  //   for(int j=0; j<=k; j++) {
  //     cout<<dp[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }

  cout<<dp[n][k]<<endl;
  return;
}

int main(){

  fastIO;
  // take_fileIO();

  solve();

  return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  long long n,k;
  cin >> n >> k;

  if(n < k) cout << min(n,k-n) << endl;
  else {
    long long ans = n;
    long long dis = max(0LL,n-k);
    long long num = dis%k;
    n = k+num;
    ans = min(n,ans);
    while(n >= k) {
      n = abs(n-k);
      ans = min(n,ans);
    }

    ans = min({ans,n,k-n});
    cout << ans << endl;

  }



  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{

    while(1)
    {
        int i,n=0;
    char x[1000];
        scanf("%s",&x);
        if(x[0]=='0')
            break;
        else
        {
            for(i=0;i<strlen(x);i++)
            {
                n+=x[i]-'0';
            }
            printf("%d\n",n);
        }
    }
    return 0;
}




Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;
  
#if 1
  vector<char> data;
  for (int i = 0; i < s.size(); i++) {
    data.push_back(s[i]);
  }

  sort(data.begin(), data.end());
#endif

#if 0
  for (int i = 0; i < s.size(); i++) {
    cout << data[i];
  }
  cout << endl;
#endif

#if 1
  if (data[0] != 'a') {
    cout << 'a' << endl;
    return 0;
  }

  for (int i = 0; i < s.size() - 1; i++) {
    if (data[i + 1] != data[i]) {
      if (data[i + 1] != char(data[i] + 1)) {
	cout << char(data[i] + 1) << endl;
	return 0;
      }
    }
  }
#endif

  if (data[s.size() - 1] == 'y') {
    cout << 'z' << endl;
    return 0;
  }

  cout << "None" << endl;

  return 0;
}

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

const int maxn=2e5+10;
const int inf=0x3f3f3f3f;

int n,p,ans;
string s;
int arr[maxn],pre[maxn],cnt[maxn];

inline int qpow(int a,int x){
	if(x==0) return 1ll;
	if(x==1) return a%p;
	int tmp=qpow(a,x/2)%p;
	if(x%2==0) return (tmp*tmp%p);
	else return ((tmp*tmp%p)*a%p);
}

signed main(){
	cin>>n>>p>>s;
	for(int i=1;i<=n;++i) arr[i]=s[i-1]-'0';
	if(p==2){
		for(int i=1;i<=n;++i) if(arr[i]%2==0){
			ans+=i;
		}
		cout<<ans<<endl;
	}else if(p==5){
		for(int i=1;i<=n;++i) if(arr[i]%5==0) ans+=i;
		cout<<ans<<endl;
	}else{
		for(int i=n;i>=1;--i) pre[i]=(pre[i+1]%p+arr[i]*qpow(10,n-i)%p)%p;
		for(int i=1;i<=n;++i) ++cnt[pre[i]];
		ans+=cnt[0]*(cnt[0]+1)/2;
		for(int i=1;i<p;++i) ans+=cnt[i]*(cnt[i]-1)/2; 
//		for(int i=n;i>=1;--i) cout<<pre[i]<<" ";
//		cout<<endl;
//		for(int i=0;i<p;++i) cout<<cnt[i]<<" ";
//		cout<<endl;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3716