akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

cout<<n*(n+1)/2<<endl;
 return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

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


int main(int argc, char const *argv[]) {
    int k; cin>>k;
    ll ans = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                ans += gcd(gcd(a,b), c);
            }
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3588
N, M = map(int, input().split())
*A, = map(int, input().split())
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda v: -v[1])

ai = 0
for b, c in BC:
    while b > 0 and ai < N and A[ai] < c:
        A[ai] = c
        b -= 1
        ai += 1

print(sum(A))

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x,t; cin >> n>>x>>t;
	if (n % x == 0) {
		cout << t* (n / x);
	}
	else {
		cout << t * ((n / x) + 1);
	}
	
	return 0;
}

Measured memory_bytes: 3648
x,y = map(int, input().split())

a = 2*x-y/2
b = -x + y/2
#print(a)
#print(b)
if y%2 != 0 or (a < 0 or b < 0) or (a==0 and b ==0 ):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9176
#include<stdio.h>

int main(void){

int N;

scanf("%d",&N);

N=N%10;

if(N==2||N==4||N==5||N==7||N==9){printf("hon");}
else if(N==0||N==1||N==6||N==8){printf("pon");}
else if(N==3){printf("bon");}

return 0;
}

Measured memory_bytes: 2120
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
// fscanf(STDIN, "%d %d %d", $n, $x, $t);
fscanf(STDIN, "%s", $s);

# 処理部
// for ($i = 0; $n > $x * $i; $i++) {
// }
if (strpos($s, 'RRR') !== false) {
  $r = 3;
} elseif (strpos($s, 'RR') !== false) {
  $r = 2;
} elseif (strpos($s, 'R') !== false) {
  $r = 1;
} else {
  $r = 0;
}

# 出力部
echo $r . "\n";


Measured memory_bytes: 16156
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}

import Control.Applicative
import Debug.Trace
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.List
import Data.Maybe


bfs :: forall s. [[Char]] -> Int -> Int -> (Int, Int) -> (Int, Int) -> ST s (Maybe Int)
bfs field w h (x0,y0) (x1,y1) = do
  check <- newArray ((1,1),(w,h)) (-1) :: ST s (STArray s (Int,Int) Int)

  let
    bfs' :: [[Char]] -> (Int,Int) -> [(Int,Int)] -> ST s ()
    bfs' _ _ [] = return ()
    bfs' field (x1,y1) ((x0,y0):queue)
      | (x0,y0) == (x1,y1) = return ()
      | otherwise = do
          
          next <- forM [(x0+1,y0), (x0-1,y0), (x0,y0+1), (x0,y0-1)] $ \(x,y) -> do
            if x>=1 && y>=1 && x<=w && y<=h then do
              c <- readArray check (x,y)
              if (field!!(y-1))!!(x-1) == '.' && c<0 then do
                readArray check (x0,y0) >>= \v -> writeArray check (x,y) (v+1)
                return $ Just (x,y)
                else
                return Nothing
              else
              return Nothing
                
          bfs' field (x1,y1) (queue ++ (catMaybes next))

  writeArray check (1,1) 0 
  bfs' field (x1,y1) [(x0,y0)]
  
  readArray check (w,h) >>= return . (\x -> if x == -1 then Nothing else Just x)



main = do
  (h:w:_) <- getLine >>= return . map read . words :: IO [Int]
  s <- getContents >>= return . lines :: IO [[Char]]

  let countWhite = sum $ map (length . filter (=='.')) s
              
  print $ case runST $ bfs s w h (1,1) (w,h) of
            Nothing -> -1
            Just x -> countWhite - x - 1

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin >> N;
    vector<long long> T, A;
    long long t = 1, a = 1;
    for (long long i = 0; i < N; i++) {
        long long x, y;
        cin >> x >> y;
        T.push_back(x);
        A.push_back(y);
    }
    for (long long i = 0; i < N; i++) {
        long long temp = max((t + T[i] - 1) / T[i], (a + A[i] - 1) / A[i]);
        t = temp * T[i];
        a = temp * A[i];
    }
    cout << a + t << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
/**
 * ???????????????
?????????????????????????¨??????????????????§?????????????°????????????????????????????????????´???????????¢?????´???????????§??????

1 selectionSort(A, N) // N??????????´??????????0-?????????????????????A
2   for i ??? 0 ?????? N-1 ?????§
3     minj = i
4     for j ??? i ?????? N-1 ?????§
5       if A[j] < A[minj]
6         minj = j
7     A[i] ??¨ A[minj] ?????????
??°???A??????????????????????????????????????¢?????´???????????§?????????????????????????????????????????°????????????????????????????????????????????????????????????????????¢?????´????????????????£??????????????????????

??????????????? 7 ????????§???i ??¨ minj
?????°?????????????????????????????????????????°??????????????????????????????

??\???
??\??????????????????????????°?????????????????¨?????´??° N ???????????????????????????????????????N
????????´??°????????????????????§?????????????????????

??????
????????? 2 ??????????????????????????????????????´??????????????°?????? 1
???????????????????????????????????°????????£?¶???????????´?????????????????????§????????£??????????????????????????????2
????????????????????°??????????????????????????????

??¶?´?
1 ??? N ??? 100
0 ??? A ???????´? ??? 100
??\?????? 1
6
5 6 4 2 1 3
????????? 1
1 2 3 4 5 6
4

??\?????? 2
6
5 2 4 6 1 3
????????? 2
1 2 3 4 5 6
3
 */

#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <vector>
#include <iterator>

unsigned short selectionSort(std::vector<unsigned short> &Numbers) {
  const size_t n = Numbers.size();
  unsigned short minj;
  unsigned short SwapCount = 0;
  for (size_t i = 0; i < n; i++) {
    minj = i;
    for (size_t j = i; j < n; j++) {
      if (Numbers[j] < Numbers[minj]) {
        minj = j;
      }
    }
    if (i != minj) {
      SwapCount++;
    }
    std::swap(Numbers[i], Numbers[minj]);
  }
  return SwapCount;
}

void printVector(const std::vector<unsigned short> &v) {
  std::ostringstream oss;
  std::copy(v.begin(), v.end() - 1,
            std::ostream_iterator<unsigned short>(oss, " "));
  oss << v.back();
  std::cout << oss.str() << std::endl;
}

int main(int argc, char const *argv[]) {
  unsigned int N;
  std::istringstream iss;
  std::string Param;

  while (true) {
    getline(std::cin, Param);
    iss.str(Param);
    iss >> N;
    iss.clear();
    if (N < 1 || N > 100) {
      std::cout << "Error: 1 <= N <= 100" << std::endl;
    } else {
      break;
    }
  }

  size_t i = 0;
  std::vector<unsigned short> A(N, 0);

  while (true) {
    bool isValid = false;
    unsigned short An;
    getline(std::cin, Param);
    iss.str(Param);
    while (i < N) {
      iss >> An;
      if (An > 100) {
        std::cout << "Error: 0 <= A <= 100" << std::endl;
        isValid = false;
        break;
      } else {
        A[i] = An;
        isValid = true;
        i++;
      }
    }
    iss.clear();
    if (isValid == true) {
      break;
    }
  }
  unsigned short SwapCount = selectionSort(A);
  printVector(A);
  std::cout << SwapCount << std::endl;

  return 0;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    cout << setprecision(15);

    const double th = a * a * b / 2;
    if (x <= th)
    {
        const double alpha = 2 * x / (a * a * b);
        cout << (atan(b / (alpha * a)) / M_PI * 180) << endl;
    }
    else
    {
        const double alpha = 2 * (1 - x / (a * a * b));
        cout << (atan(alpha * b / a) / M_PI * 180) << endl;
    }
}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//int n,m,k;

signed main()
{
    showoff;
    //cin >> n >> m >> k;
    int n;
    cin >> n;
    int c = 0;
    while(n > 0){
    if(n%10 == 2)++c;
    n /= 10;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
	int main(){
		long long a,b,k,x,y;
		
		 	scanf("%lld" "%lld", &a, &b);
			k=(a+b)/2;
			x= abs(a-k);
			y= abs(b-k);
			if(x==y)
			{printf("%lld", k);
			}
			else if(x!=y)
			{printf("IMPOSSIBLE");
			}
		 	
		 	
		 	
		 	
		 
		
		
		
		
		
		
		
		
			return 0;
		
	}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

inline ll max(ll a,ll b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

const int maxn=1e5+10;

int f[maxn];

int n,m;

inline void init()
{
	for(int i=0;i<=n+1;i++)
		f[i]=i;
}

int getf(int x)
{
	if(x==f[x])
		return x;
	else
	{
		f[x]=getf(f[x]);
		return f[x];
	}
}

void merge(int x,int y)
{
	x=getf(f[x]);
	y=getf(f[y]);
	if(x!=y)
		f[y]=x;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 	
 	cin>>n>>m;
 	
 	init();
 	
 	for(int i=0,x,y;i<m;i++)
 	{
 		cin>>x>>y;
 		
 		merge(x,y);
	}
	
	set<int>s;
	
	for(int i=1;i<=n;i++)
		s.insert(getf(f[i]));
	
	cout<<(int)s.size()-1<<endl;
	
 	return 0;
}

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


def solve(N: int, S: "List[str]"):
    s = set()
    for i in range(N):
        s.add(S[i])
    print(len(s))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35576
/**
*    author:  Dooloper
*    created: 03.09.2020 18:48:15
**/
#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
  vector<int> r;

  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  bool same(int x, int y) {
   return root(x) == root(y);
  }

  int size(int x) {
    return -r[root(x)];
  }
};

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

  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3948
import java.util.*;
public class Main {
  public static void main(String[]args){
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = a%10;
    if(b==2||b==4||b==5||b==7||b==9){
      System.out.println("hon");
    }
    if(b==0||b==1||b==6||b==8){
      System.out.println("pon");
    }
    if(b==3){
      System.out.println("bon");
  }
}
}

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

using namespace std;
#define int long long
int MOD = 1000000007;


signed main(){
    int N;
    cin >> N;
    
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    int ni;
    for(int i=7;i>0;i--){
        ni = pow(2,i);
        if(ni <= N){
            cout << ni << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n,k;
    cin >> n >>k;
    vector<ll>loop(n),value(n);
    for(int i=0;i<n;i++){
        cin >> loop.at(i);
        loop.at(i)--;
    }
    for(int i=0;i<n;i++){
        cin >> value.at(i);
    }
    ll ans = -1e17;
    for(int i=0;i<n;i++){// ここに戻る
    ll kei =0;
    vector<ll>memo;
    memo.push_back(0);
      ll next = loop.at(i);
        for(int j=0;j<k;j++){
        	next = loop.at(next);
          if(j==0)next=loop.at(i);
            kei+=value.at(next);
            memo.push_back(kei);
            if(memo.size()>1){
                memo.at(memo.size()-1)=max(memo.at(memo.size()-1),memo.at(memo.size()-2));// 余りのなかで最
            }
            ans = max(ans,kei);
            if(next==i){
             if(kei<0)break;
             else{
                 ll kai = j+1;
                 ll check = k/kai*kei + memo.at(k%kai);
                 ans = max(check,ans);
                check = ((k/kai)-1)*kei+memo.at(memo.size()-1);
                ans = max(check,ans);
                break;
             }
            }
        }
    }
    cout<<ans<<endl;
}
    



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	int z= (n + 999)/1000;
	int ans = 1000*z - n;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3648
"use strict";
function main(input) {
  let nums = input.split(/\s/).map(s => Number(s));
  let res = 0;
  for (let i = 0; i < 2; i++) {
    if (nums[0] > nums[1]) {
      res += nums[0];
      nums[0]--;
    } else {
      res += nums[1];
      nums[1]--;
    }
  }

  console.log(res);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
 int n , m;
  cin >> n >> m;
  pair<int,int> c[100010];
  
  int a[100010],b[100010];
  
  for(int i=0;i<n;i++){
    
    cin >> a[i] >> b[i];
    
    c[i] = make_pair(a[i],b[i]);
    
  }
  
  sort(c,c+n);
  
  
  priority_queue<int> p;
  
  int res=0,ans=0;
  
  for(int i=1;i<=m;i++){
    while(c[res].first<=i){
      p.push(c[res].second);
      res++;
    }
    if(!p.empty()){
      ans+=p.top();
      p.pop();
    }
  }
  cout << ans << endl;
}
  
  
  
    


Measured memory_bytes: 2428
from random import sample
n=int(input())
if n==3:a=[2,5,63]
else:
  l=[i for i in range(6,30001)if i%2==0 or i%3==0]
  while True:
    a=[2,3,4];a+=sample(l,n-3)
    if sum(a)%6==0:break
print(*a)

Measured memory_bytes: 5192
I = [int(i) for i in input().split()]
A, B, AB, X, Y = I

ans = 1e+15
for i in range(max(X,Y)+1):
  price = A*max(X-i, 0) + B*max(Y-i, 0) + AB*2*i
  ans = min(ans, price)
print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        string[] inputs = Console.ReadLine().Split(' ');
        Stack<int> stk = new Stack<int>();
        int num, calculated = 0;
        for (int i = 0; i < inputs.Length; i++)
        {
            if(Int32.TryParse(inputs[i], out num)) stk.Push(num);
            else{
                int val2 = stk.Pop();
                int val1 = stk.Pop();
                switch (inputs[i])
                {
                    case "+":
                        calculated = val1 + val2;
                        break;
                    case "-":
                        calculated = val1 - val2;
                        break;
                    case "*":
                        calculated = val1 * val2;
                        break;
                }
                stk.Push(calculated);
            }
        }
        Console.WriteLine(stk.Pop());
    }
}

Measured memory_bytes: 10228
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int jewels = sc.nextInt();
        int v[] = new int[jewels];
        int c[] = new int[jewels];
        for (int i = 0; i < jewels; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < jewels; i++) {
            c[i] = sc.nextInt();
        }

        int res = 0;
        for (int i = 0; i < jewels; i++) {
            if (v[i] - c[i] > 0) {
                res += v[i] - c[i] ;
            }
        }

		System.out.println(res);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur == nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if (t == nil) {
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst () {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey (int key) {
  deleteNode(listSearch(key));
}

//insert???????°????????????\???????????§???????????????????????\??????
void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main () {
  int key, n, i;
  int size = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d\n", com, &key);
    if (com[0] == 'i') {
      insert(key);
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') {
          deleteFirst();
        } else if (com[6] == 'L') {
          deleteLast();
        }
      } else {
        deleteKey(key);
      }
      size--;
    }
  }

  printList();

}

Measured memory_bytes: 33944
<?php
$m = int();
$sum = 0;
$C = 0;
for($i = 0; $i < $m; $i++){
  list($d, $c) = ints();
  $sum+=$d*$c;
  $C += $c;
}
echo $C-1 + intdiv($sum-1,9);
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int[][][] array = new int [4][3][10];
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		for(int i = 0; i<num; i++){
			int building = sc.nextInt();
			int floor = sc.nextInt();
			int room_num = sc.nextInt();
			int change = sc.nextInt();
			array[building-1][floor-1][room_num-1] += change;
		}

		for(int j = 0; j<4; j++){
			for(int k = 0; k<3; k++){
				for(int l = 0; l<10; l++){
					System.out.print(" "+array[j][k][l]);
				}
				System.out.println();
			}
			if(j!=3){
				System.out.println("####################");
			}
		}
	}
}


Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int h,w;
  cin>>h>>w;
  vector<string>s(110);
  vector<bool>x(110,false),y(110,false);
  rep(i,h) cin>>s[i];
  rep(i,h)rep(j,w){
    if(s[i][j]=='#'){
      x[i]=true;
      y[j]=true;
    }
  }
  rep(i,h){
    if(x[i]){
      rep(j,w){
        if(y[j])
          cout<<s[i][j];
      }
      cout<<endl;
    }
  }
}
  

Measured memory_bytes: 3616
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());
    
    let t = rvn::<usize>(&mut br);
    let (n, d) = (t[0], t[1]);
    let x = 2 * d + 1;
    writeln!(&mut bw, "{}", (n+x-1)/x);
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
using lld =long long int;
int main(){
    lld X;
    cin >> X;
    lld ans;
    ans=X/500;
    X=X-ans*500;
    ans=ans*1000;
    lld r=X/5;
    ans+=r*5;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int, int> tp;
vector<tp> ans;
int a[505][505];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		if(i%2 == 1){
			for(int j=1;j<=m;j++){
				if(a[i][j]%2 == 0) continue;
				if(j == m){
					if(i != n){
						a[i+1][j]++;
						ans.push_back(tp(i, j, i+1, j));
					}
				}
				else{
					a[i][j+1]++;
					ans.push_back(tp(i, j, i, j+1));
				}
			}
		}
		else{
			for(int j=m;j>=1;j--){
				if(a[i][j]%2 == 0) continue;
				if(j == 1){
					if(i != n){
						a[i+1][j]++;
						ans.push_back(tp(i, j, i+1, j));
					}
				}
				else{
					a[i][j-1]++;
					ans.push_back(tp(i, j, i, j-1));
				}
			}	
		}
	}
	printf("%d\n", ans.size());
	for(int i=0;i<ans.size();i++){
		int a, b, c, d;
		tie(a, b, c, d) = ans[i];
		printf("%d %d %d %d\n", a, b, c, d);
	}
}

Measured memory_bytes: 5232
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let xs = read_vec_i64();
    let (v,e,r) = (xs[0] as usize, xs[1] as usize, xs[2] as usize);
    let mut edges = vec![];
    for _ in 0..e {
        let ys = read_vec_i64();
        let (s,t,d) = (ys[0] as usize, ys[1] as usize, ys[2]);
        edges.push((s,t,d));
    }
    let mut dists = vec![None; v];
    dists[r] = Some(0);
    for _ in 0..v {
        for k in 0..e {
            let (s,t,d) = edges[k];
            if let Some(sd) = dists[s] {
                let nd = sd + d;
                if dists[t].is_none() || nd < dists[t].unwrap() {
                    dists[t] = Some(nd);
                }
            }
        }
    }
    for &(s,t,d) in &edges {
        if let Some(sd) = dists[s] {
            if let Some(td) = dists[t] {
                if sd + d < td {
                    println!("NEGATIVE CYCLE");
                    return;
                }
            }
        }
    }
    for &d in &dists {
        match d {
            Some(x) => println!("{}", x),
            None => println!("INF"),
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}



Measured memory_bytes: 5036
#include <stdio.h>
int main(void){
    int A,B,max;
    scanf("%d %d",&A,&B);
    max=0;
    max=A+B;
    if(max<A-B){
        max=A-B;
    }
    if(max<A*B){
        max=A*B;
    }
    printf("%d",max);
    
    return 0;
}

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

using namespace std;



int main(){

	int n1,n2,n3,n4,n5,n6,n7,n8,n9;

	cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6 >> n7 >> n8 >> n9;

	for(int a1 =0;a1<=n1 and a1<=n2 and a1<=n3;a1++){
		for(int a2 =0;a2<=n4 and a2<=n5 and a2<=n6;a2++){
			for(int a3 =0;a3<=n7 and a3<=n8 and a3<=n9;a3++){
				for(int b1 =0;b1<=n1 and b1<=n4 and b1<=n7;b1++){
					for(int b2 =0;b2<=n2 and b2<=n5 and b2<=n8;b2++){
						for(int b3 =0;b3<=n3 and b3<=n6 and b3<=n9;b3++){
							if(n1!=a1+b1) continue;
							if(n2!=a1+b2) continue;
							if(n3!=a1+b3) continue;
							if(n4!=a2+b1) continue;
							if(n5!=a2+b2) continue;
							if(n6!=a2+b3) continue;
							if(n7!=a3+b1) continue;
							if(n8!=a3+b2) continue;
							if(n9!=a3+b3) continue;
							cout << "Yes" << endl;
							return 0;
						}
					}
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <stdio.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
int a[100000];
int main(void){
    int n,i;
    int ans=0;
    scanf("%d",&n);
    FOR(i,0,n) scanf("%d",&a[i]);
    FOR(i,0,n){
        ans++;
        while(a[i]==a[i+1]&&i+1<n) i++;
        if(a[i+1]-a[i]>0){
            while(a[i+1]-a[i]>=0&&i+1<n) i++;
        }
        else{
            while(a[i+1]-a[i]<=0&&i+1<n) i++;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 512
a, b = input().split()
if a == "A":
    a1 = 10
if a == "B":
    a1 = 11
if a == "C":
    a1 = 12
if a == "D":
    a1 = 13
if a == "E":
    a1 = 14
if a == "F":
    a1 = 15
if b == "A":
    b1 =10
if b == "B":
    b1 = 11
if b == "C":
    b1 = 12
if b == "D":
    b1 = 13
if b == "E":
    b1 = 14
if b == "F":
    b1 = 15
if a1 > b1:
    print(">")
elif a1 == b1:
    print("=")
else :
    print("<")

Measured memory_bytes: 3064
import heapq
n, m  = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)
for i in range(m):
    a = heapq.heappop(A)
    heapq.heappush(A, a/2)
print(sum([-int(a) for a in A]))

Measured memory_bytes: 20452
#include <stdio.h>
int main(void)
{
	int i, j, hill[10], temp;

	for(i = 0; i < 10; i++)
		scanf("%d", &hill[i]);

	for (i = 0; i < 9; i++) {
		for (j = i; j < 10; j++) {
			if (hill[i] < hill[j]) {
				temp = hill[i];
				hill[i] = hill[j];
				hill[j] = temp;
			}
		}
	}

	for (i = 0; i < 3; i++)
		printf("%d\n", hill[i]);

	return 0;
}

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

int main() {
  // your code here...
  float l;
  scanf("%f", &l);

  if (l/3 < 1) {
    if (l > 2) {
      printf("%f\n", l-2.0);
      return 0;
    }
    if (l > 1) {
      printf("%f\n", ((l-2.0)/2.0)*((l-2.0)/2.0));
      return 0;
    }
  }

  printf("%f\n", (l/3.0)*(l/3.0)*(l/3.0));
  return 0;
}


Measured memory_bytes: 128
import sys

N = int(input())
mylist = list(map(int, input().split()))

for m in mylist:
    if m%2 == 0:
      if m%3 == 0:
          continue
      elif m%5 == 0:
          continue
      else:
          print('DENIED')
          sys.exit()
print('APPROVED')

Measured memory_bytes: 3060
mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)

Measured memory_bytes: 39708
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100+20
int a[MAXN][MAXN]={0};
bool cmp(string s1,string s2){
  return s1.length()<s2.length() ? true : false;
}
int main(){
  int x,y,rst;
  cin>>x>>y;
  cout<<x+y/2<<endl;
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K, S = getlist()
	if K == N:
		ans = [S] * N
		ans = list(map(str, ans))
		print(" ".join(ans))

	elif S == 1:
		ans = [0] * N
		for i in range(K):
			ans[i] = 1
		for i in range(K, N):
			ans[i] = 2
		ans = list(map(str, ans))
		print(" ".join(ans))

	elif S != 10 ** 9:
		ans = [0] * N
		for i in range(K + 1):
			if i % 2 == 0:
				ans[i] = 1
			else:
				ans[i] = S - 1
		for i in range(K + 1, N):
			ans[i] = S + 1
		ans = list(map(str, ans))
		print(" ".join(ans))

	else:
		ans = [0] * N
		for i in range(K):
			ans[i] = S
		for i in range(K, N):
			ans[i] = 1
		ans = list(map(str, ans))
		print(" ".join(ans))

if __name__ == '__main__':
	main()

Measured memory_bytes: 56812
#include<iostream>
#include<string>
#include<algorithm>

int res,t;

std::string s;

int main(){

    std::cin>>s;

    for(auto&& x:s){
    if(x=='A'||x=='G'||x=='C'||x=='T'){
        t++;
    }
    else{
    if(t>0){
    res=t;
    t=0;
    }
    }
    }

    std::cout<<std::max(res,t)<<std::endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   
    unsigned long long h,w;
    cin >> h >> w;
    if(min(h,w) != 1) {
        cout << (h * w % 2 == 0 ? h * w / 2 : (h * w + 1) / 2) << endl;
    }else{
        cout << 1 << endl;
    }

}

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

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

bool str_greater(string &s, string &t) {
	int n=s.size(), m=t.size();
	if(n<m) return false;
	if(n>m) return true;
	for (int i=0; i<n; i++)
		if(s[i]<t[i]) return false;
		else if(s[i]>t[i]) return true;
	return false;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	if(s==t) cout << "EQUAL";
	else cout << (str_greater(s,t) ? "GREATER" : "LESS");
	cout << endl;
	return 0;
}


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, R;
	
	cin>>N>>R;
	
	if(N >= 10) cout<<R<<endl;
	else {
		cout<<R + 100 * (10 - N)<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
s = input()
w = int(input())

if len(s) % w == 0:
    M = len(s) // w
else:
    M = len(s) // w + 1

if w == 1:
    print(s)
else:
    ans = ""
    for i in range(0, M):
        ans += s[i*w]

    print(ans)


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

const ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a = 1;
    ll b = 1;
    ll c = 1;
    rep(i, n){
        a *= 10;
        a %= mod;
        b *= 9;
        b %= mod;
        c *= 8;
        c %= mod;
    }
    ll ans = a-b-b+c;
    ans %= mod;
    ans = (ans + mod) % mod; 
    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
	int X = 0, Y = 0;
	cin >> X >> Y;
	if (Y%2==1||4*X<Y||2*X>Y)
	{
		cout << "No";
	}
	else 
	{
		cout << "Yes";
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll mod = 1000000007;
ll N;
vector<ll> pathes[105000];
ll parent[105000];
vector<ll> children[105000];
ll dp[105000];
ll dp2[105000];

void dfs(int now) {
    dp[now] = 1;
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == parent[now]) continue;
        parent[to] = now;
        children[now].push_back(to);
        dfs(to);
        dp[now] *= (1 + dp[to]);
        dp[now] %= mod;
    }
}

void dfs2(int now, ll factor) {
    dp2[now] = dp[now] * factor % mod;
    vector<ll> R(children[now].size() + 1, 1);
    vector<ll> L(children[now].size() + 1, 1);
    for(int i = 1; i < R.size(); i++) {
        int to = children[now][i-1];
        L[i] = L[i-1] * (dp[to] + 1) % mod;
    }
    for(int i = (int)children[now].size() - 1; i >= 0; i--) {
        int to = children[now][i];
        R[i] = R[i+1] * (dp[to] + 1) % mod;
    }
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        ll nowfactor = factor;
        nowfactor *= L[i];
        nowfactor %= mod;
        nowfactor *= R[i+1];
        nowfactor %= mod;
        nowfactor++;
        nowfactor %= mod;
        dfs2(to, nowfactor);
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> mod;
    for(int i = 1; i <= N - 1; i++) {
        ll x, y;
        cin >> x >> y;
        pathes[x].push_back(y);
        pathes[y].push_back(x);
    }
    parent[1] = -1;
    dfs(1);
    dfs2(1, 1);
    for(int i = 1; i <= N; i++) {
        cout << dp2[i] << endl;
    }
    return 0;
}


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

int main() {
    int N, L, sum = 0, maxv = -200000000;
    cin >> N >> L;
    vector<int> a(N + 1);
    a[0] = 0;
    //リンゴの味
    for (int i = 1; i <= N; i++)
    {
        a[i] = L + i - 1;
        //cout << a[i] << endl;
        sum += a[i];
    }
    //cout << "sum = " << sum << endl;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if (a[i] == 0)
        {
            cout << sum << endl;
            return 0;
        }
        
        if (a[i] < 0)
        {
            ans = abs(sum - a[i]);
        }
        else
        {
            ans = sum - a[i];
        }
        
        maxv = max(ans, maxv);
    }
    if (sum < 0)
    {
        maxv *= -1;
    }
    
    cout << maxv << endl;
}

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

int main() {
  float N; cin>>N;
  int ans = 0;
  for(float i=1; i<=ceil(sqrt(N)-1); ++i) {
    ans += (ceil(N/i-1)-(i-1))*2 - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3776
x = gets.to_i

ns = [1]

(2..31).each do |b|
  p = 2
  while b**p <= 1024
    ns << b**p
    p += 1
  end
end

ns = ns.uniq.sort

(0..ns.length-1).each do |i|
  if x < ns[i]
    p ns[i-1]
    exit 0
  end
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] pasta = new int[N+1];
		int[][][] dp = new int[N+1][3][2];
		for(int i=0;i<K;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			pasta[a] = b;
		}
		if (pasta[1] != 0) {
			dp[1][pasta[1]-1][0] = 1;
		}else{
			for(int i=0;i<3;i++) {
				dp[1][i][0] = 1;
			}
		}
		for(int i=2;i<=N;i++) {
			for(int j=0;j<3;j++) {
				if (pasta[i] != 0 && pasta[i] != j+1) {
					continue;
				}
				for(int k=0;k<2;k++) {
					if (k==0) {
						int sum = 0;
						for(int j2=0;j2<3;j2++) {
							if (j==j2) {
								continue;
							}
							for(int k2=0;k2<2;k2++) {
								sum += dp[i-1][j2][k2];
							}
						}
						dp[i][j][k] = sum % 10000;
					}else{
						dp[i][j][k] = dp[i-1][j][k-1];
					}
				}
			}
		}
		int ans = 0;
		for(int j=0;j<3;j++) {
			for(int k=0;k<2;k++) {
				ans = (ans + dp[N][j][k]) % 10000;
			}
		}
		//System.out.println(Arrays.deepToString(dp));
		System.out.println(ans);
	}

}

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

int main(){
    long long a,b,c,k;
    long long max = 0;
    cin >> a >> b >> c >> k;
    if(a <= k){
        max += a;
        k -= a;
        
    }else{
        max += k;
        k = 0;
        
    }

    if(b <= k){
        k -= b;
        
    }else{
        k = 0;
        
    }

    max -= k;

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int x = Integer.parseInt(sc.next());
                int n = Integer.parseInt(sc.next());
                boolean[] q = new boolean[102];
                Arrays.fill(q , true);
                for(int i = 0 ; i < n ; i++){
                        q[Integer.parseInt(sc.next())] = false;
                }
                int s = 0;
                boolean ebishu = true;
                while(ebishu){
                        if(q[Math.max(0 , x - s)] == true){
                                ou.print(x - s + "\n");
                                ebishu = false;
                        }else if(q[Math.min(101 , x + s)] == true){
                                ou.print(x + s + "\n");
                                ebishu = false;
                        }
                        s++;
                }
                sc.close();
                ou.flush();
        }
}

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

int main() {
  
  ll N,result=0;
  cin >> N;

  result = N%10;
  result = N-result;
  result = N-result;
  
  if(result==3){
    cout << "bon" << endl;
  }else if(result == 0 || result == 1 || result == 6 || result == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }

  
}


Measured memory_bytes: 3636
def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b

def calc_lcm(a, b):
	gcm = calc_gcm(a, b)
	return a * b // gcm

N, M = map(int, input().split())
a_list = list(map(int, input().split()))

lcm = 1
for a in a_list:
	lcm = calc_lcm(lcm, a)
	if lcm > 2 * M:
		lcm = 0
		break

def check():
	for a in a_list:
		if (lcm // a) % 2 == 0:
			return False
	return True

if lcm == 0:
	print(0)
elif check():
	lcm //= 2
	count = M // lcm + 1
	print(count // 2)
else:
	print(0)


Measured memory_bytes: 15060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

ll f(ll pA, ll pB, ll pC, ll N) {
  ll res = 0;
  for (int M = N; M < 2 * N; M++) {
    ll e1 = 1;
    e1 = e1 * power(pA, N) % MOD;
    e1 = e1 * power(pB, M - N) % MOD;
    ll e2 = 1;
    e2 = e2 * power(pA, M - N) % MOD;
    e2 = e2 * power(pB, N) % MOD;
    ll e = (e1 + e2) % MOD;
    e = e * choose(M - 1, N - 1) % MOD;
    e = e * M % MOD;
    //e = e * inverse((1 - pC + MOD) % MOD) % MOD;
    e = e * inverse(power((1 - pC + MOD) % MOD, M + 1)) % MOD;
    res = (res + e) %  MOD;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  initFact(300000);
  ll N, A, B, C;
  while (cin >> N >> A >> B >> C) {
    ll pA = A * inverse(100) % MOD;
    ll pB = B * inverse(100) % MOD;
    ll pC = C * inverse(100) % MOD;
    ll res = f(pA, pB, pC, N);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
string S;
bool visit[3];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> S;

	for (int i = 0; i < 3; i++) {
		visit[S[i] - 'A'] = true;
	}
	bool fg = true;
	for (int i = 0; i < 2; i++) {
		if (!visit[i]) {
			fg = false;
			break;
		}
	}
	if (fg) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

signed main(){

    string s; cin >> s;
    int n = (int)s.size();
    
    int c0 = 0, c1 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '0') c0++;
        else c1++;
    }

    cout << 2 * min(c0, c1) << endl;
    return 0;
}

Measured memory_bytes: 512