akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 1001;
const int INF = INT_MAX/2;
const int mod = 1e9+7;

int n,tar[maxn];
vector <int> adjlist[maxn];
int dp[maxn][2]; //0 is using white, 1 is using black

void dfs(int x) {
	//cout << "NEW: " << x << "\n";
	if (adjlist[x].empty()) {
		dp[x][0] = dp[x][1] = 0;
		return;
	}
	
	for (auto i: adjlist[x]) dfs(i);
	dp[x][0] = dp[x][1] = INF;
	
	int ks[2][5005]; //Given a particular white value, minimum black value;
	for (int j=0;j<=5000;j++) ks[1][j] = ks[0][j] = INF;
	
	ks[0][0] = 0;
	int pos = 0;
	
	for (auto i: adjlist[x]) {	
		int w = tar[i], b = dp[i][0];
		pos = !pos;
		for (int j = 5000; j >= 0; j--) {
			if (ks[!pos][j] == INF or j + w > 5000) continue;
			ks[pos][j + w] = min(ks[pos][j+w],ks[!pos][j] + b);
		}
		
		
		w = dp[i][1], b = tar[i];
		for (int j = 5000; j >= 0; j--) {
			if (ks[!pos][j] == INF or j + w > 5000) continue;
			ks[pos][j + w] = min(ks[pos][j+w],ks[!pos][j] + b);
		}
		
		for (int j=0;j<=5000;j++) ks[!pos][j] = INF;
	}
	//cout << x << " " << tar[x] << ":\n";
	for (int j=0;j<=5000;j++) {
		//cout << j << " " << ks[pos][j] << "\n";
		if (j <= tar[x]) dp[x][0] = min(dp[x][0],ks[pos][j]);
		if (ks[pos][j] <= tar[x]) dp[x][1] = min(dp[x][1], j);
	}
	//cout << x << " " << tar[x] << " " << dp[x][0] << " " << dp[x][1] << "\n";
}

int32_t main() {
	FAST
	cin >> n;
	for (int i =2;i<=n;i++) {
		int p; cin >> p;
		adjlist[p].push_back(i);
	}

	for (int i =1;i<=n;i++) cin >> tar[i];
	dfs(1);
	
	if (dp[1][0] >= INF and dp[1][1] >= INF) cout << "IMPOSSIBLE";
	else cout << "POSSIBLE";

}


Measured memory_bytes: 34048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char[][] strs = new char[2][];
		strs[0] = sc.next().toCharArray();
		strs[1] = sc.next().toCharArray();

loop:		for(int i = 0; i <= 1; i++){
			int[] indexes = {0,0};
			int current = i;
			for(int j = 0; j < strs[0].length; j++){
				while(strs[current][indexes[current]] != strs[0][j]){
					indexes[current]++;
					if(indexes[current] == strs[0].length){
						continue loop;
					}
				}
				indexes[current]++;
				if(indexes[current] == strs[0].length && j != strs[0].length - 1){
					continue loop;
				}
				current = (current + 1) % 2;
			}

			System.out.println("Yes");
			return;
		}

		System.out.println("No");
	}

}



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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<P> ab(m);
  for (int i=0;i<m;++i) cin >> ab[i].second >> ab[i].first;

  sort(ab.begin(), ab.end());
  ll ra = 0;
  ll cnt = 0;
  for (int i=0;i<m;++i){
    if (ra <= ab[i].second){
      ++cnt;
      ra = ab[i].first;
    }
  }
  // rep(i, n) cout << arm[i].first << " " << arm[i].second << endl;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> ans(N+1, 0);
    int64_t fin = 0;
    for (int64_t b = K + 1; b <= N; b++){
        // N = p * b + r
        int64_t p = N / b;
        ans.at(b) += p * (b - K);
        int64_t r = N % b;
        if (K == 0) ans.at(b) += r;
        else if (r - K >= 0) ans.at(b) += (r - K) + 1;
        fin += ans.at(b);
    }
    cout << fin << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9+7;

int main(){
   int n; cin >> n;
   ll ans = 0;
   for(int i = 1; i <= n; i++){
      if((i%3 != 0) && (i%5 != 0)){
         ans += i;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3620
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Lazy as IntMap
import qualified Data.IntSet as IntSet
import Data.Foldable
import Control.Monad.ST

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [u,v] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1,v-1)
  [s,t] <- map (subtract 1) . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let graph :: IntMap.IntMap IntSet.IntSet
      graph = U.foldl' (\m (u,v) -> IntMap.insertWith IntSet.union (3 * u) (IntSet.singleton (3 * v + 1))
                                    $ IntMap.insertWith IntSet.union (3 * u + 1) (IntSet.singleton (3 * v + 2))
                                    $ IntMap.insertWith IntSet.union (3 * u + 2) (IntSet.singleton (3 * v))
                                    $ m) IntMap.empty edges
      result = runST $ do
        visited <- UM.replicate (3 * n) False
        let !target = 3 * t
        -- bfs :: IntSet -> ST s (Maybe Int)
        let bfs !depth ss = do
              forM_IntSet ss $ \u ->
                UM.write visited u True
              let ts = foldMap_IntSet (\u -> IntMap.findWithDefault IntSet.empty u graph) ss
              ts' <- foldMapM_IntSet (\v -> do
                                         d <- UM.read visited v
                                         pure $ if d then IntSet.empty else IntSet.singleton v
                                     ) ts
              if target `IntSet.member` ts'
                then return $ Just (depth `quot` 3)
                else if IntSet.null ts'
                     then return Nothing
                     else bfs (depth+1) ts'
        bfs 1 (IntSet.singleton (3 * s))
  case result of
    Nothing -> putStrLn "-1"
    Just d -> print d

foldMap_IntSet :: (Monoid n) => (Int -> n) -> IntSet.IntSet -> n
foldMap_IntSet f set = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> mempty
               [x] -> foldMap f (IntSet.toList x)
               xs -> foldMap go xs

forM_IntSet :: Monad m => IntSet.IntSet -> (Int -> m ()) -> m ()
forM_IntSet set f = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> return ()
               [x] -> forM_ (IntSet.toList x) f
               xs -> forM_ xs go

foldMapM_IntSet :: (Monoid n, Monad m) => (Int -> m n) -> IntSet.IntSet -> m n
foldMapM_IntSet f set = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> return mempty
               [x] -> foldlM (\x v -> mappend x <$> f v) mempty (IntSet.toList x)
               xs -> foldlM (\x set' -> mappend x <$> go set') mempty xs


Measured memory_bytes: 74108
import sys

while True:
    blk_wh = "#." * 150
    h, w = map(int, input().split())
    if h == 0 and w ==0:
        break
    
    for row in range (h):
        if row % 2 == 0:
            print(blk_wh[:w])
        else:
            print(blk_wh[1:w+1])
    print()




Measured memory_bytes: 5612
n=gets.to_i
d,x=gets.chomp.split.map(&:to_i)
sumChocolate = x
n.times.map{
  day = gets.to_i
  count = 0
  loop do
    tempDay = 1 + count * day
    break if(tempDay > d)
    sumChocolate += 1
    count += 1
  end
}
puts sumChocolate

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];


    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 21732
#include <cstdio>

void sort(int a, int b);

int hill[10];
int main() {
    int i;
    for (i = 0; i < 10; i++) {
        scanf("%d", &hill[i]);
    }
    sort(0, 9);
    for (i = 0; i < 3; i++) {
        printf("%d\n", hill[i]);
    }
}

void sort(int a, int b) {
     int left, right, temp, pivot;
     if ( a < b ) {
          left = a; right = b;
          pivot = hill[ (a + b) / 2];
          while (left <= right) {
                while ( hill[left] > pivot ) left++;
                while ( hill[right] < pivot ) right--;
                if ( left <= right) {
                     temp = hill[left];
                     hill[left] = hill[right];
                     hill[right] = temp;
                     left++;
                     right--;
                }
          }
          sort(a, right);
          sort(left, b);
     }
}

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

int main(){
  int N,K; cin >> N >> K;
  string S; cin >> S;
  if(S[K-1]=='A') S[K-1]='a';
  else if(S[K-1]=='B') S[K-1]='b';
  else S[K-1]='c';
  cout << S << endl;
}

Measured memory_bytes: 256
while True:
  try:
    plst = list(map(int, input().split()))
    
    horse = [4, 1, 4, 1, 2, 1, 2, 1]
    max_num = -1
    max_horse = horse[:]
    
    for _ in range(8):
      #乗車可能人数
      num = sum([min(plst[j], horse[j]) for j in range(8)])
      
      #人数が最大値と等しく、並びの数値が小さければ更新
      if num == max_num and max_horse > horse:
        max_horse = horse[:]
      
      #人数が最大値より大きければ更新
      elif num > max_num:
        max_num = num
        max_horse = horse[:]
      
      #馬を回転
      horse.append(horse.pop(0))

    print(" ".join(map(str, max_horse)))

  except EOFError:
    break


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

// ABC157D
// (1)直接の友達ではなく、(2)ブロック関係でもなく、(3)友達の友達の友達の…友達であれば友達候補
// 入力時に友達数をカウントしておく。Union-Findで友達＋友達候補の全体数を把握し、そこから、友達数と自身の数を引く。
// 最後にブロックしている人が同じ連結グラフ内にいればその数も引く。

// UnionFind tree(N);でUnion-Find木を生成
// tree.root(X);で親ノード番号を返す
// tree.unite(X, Y);でノードを結合する
// tree.same(X, Y);でXノード、Yノードが結合しているかどうか返す
// tree.size(X);でXノードが結合しているノード数を返す
struct UnionFind{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int N) : par(N), sizes(N, 1){
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x){
  if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    if(sizes[rx] < sizes[ry]) swap(rx, ry);
    par[ry] = rx;
    sizes[rx] += sizes[ry];
  }

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K; cin >> N >> M >> K;
  UnionFind Tree(N);
  // 0:保留又は本人、1:友人関係、-1:ブロック関係
  vector<int> ans(N, 0);
  REP(i, M){
    int a, b; cin >> a >> b; a--; b--;
    Tree.unite(a, b);
    ans[a]--; ans[b]--;
  }
  REP(i, N){
    ans[i] = ans[i] + Tree.size(i) - 1;
  }
  REP(i, K){
    int c, d; cin >> c >> d; c--; d--;
    if(Tree.same(c, d)){
      ans[c]--; ans[d]--;
    }
  }
  REP(i, N){
    cout << ans[i];
    if(i == N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll px(ll t){
    ll p=t;
    ll cnt=0;
    while(p){
      p%=__builtin_popcount(p);
      cnt++;
    }
    return cnt;
}
int main(){
    ll n;cin >> n;
    string s;cin >> s;
    ll p=0;rep(i,n)if(s[i]=='1')p++;
    ll a=0,b=0;
    if(p!=1)rep(i,n){
        if(s[i]=='1'){
            a+=modpow(2,n-i-1,p-1);
        }
        a%=p-1;
    }
    rep(i,n){
        if(s[i]=='1'){
            b+=modpow(2,n-i-1,p+1);
        }
        b%=p+1;
    }
    //cout << p <<" " << a <<" " << b <<endl;
    rep(i,n){
        if(p==1&&s[i]=='1'){
            cout << 0 <<endl;
            continue;
        }
        if(s[i]=='0'){
            ll c=b;
            c+=modpow(2,n-i-1,p+1);
            c%=p+1;
            cout << 1+px(c) <<endl;
        }
        else {
            ll c=a;
            c-=modpow(2,n-i-1,p-1);
            c=(c+p-1)%(p-1);
            cout << 1+px(c)<<endl;
        }
    }
}

Measured memory_bytes: 3728
#include <iostream>
#include <climits>
#include <memory.h>
#include <random>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <bitset>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/

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

bool solve(LL r, LL b, LL c, LL d) {
    if (r != 0 && r < b - c) return false;
    if (d == 0) return true;
    if (d <= b-c-1) return false;
    LL tmp = gcd(b, d);
    if (tmp <= b-c-1) return false;
    r = r % tmp;
    LL x = 1 - r;
    if (x < 0) x += b;
    LL y = b-c-1 - r;
    if (y < 0) y += b;
    x = x / tmp;
    y = y / tmp;
    if (x != y) return false;
    return true;
}




/*-------------------------------------coding area end------------------------------------------*/
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
    #ifdef LOCAL
        freopen("../test.txt", "r", stdin);
//        freopen("../output.txt", "w", stdout);
    #endif
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
    LL a, b, c, d;
    int T; cin >> T;
    while(T--) {
        cin >> a >> b >> c >> d;
        if (b > min(a, d)) {
            cout << "No\n";
            continue;
        }
        if (c+1 >= b) {
            cout << "Yes\n";
            continue;
        }
        a = (a-c) % b + c;
        if (a != c) a -= b;
        a = a - c;
        if (a < 0) a += b;
        if (solve(a, b, c, d % b)) cout << "Yes\n";
        else cout << "No\n";
    }



/*-------------------------------------coding area end------------------------------------------*/

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
    #endif
    return 0;
}
/* author:  txingml */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll x, y;

void solve() {
	if (abs(x-y) <= 1) {
		cout << "Brown" << endl;
	} else {
		cout << "Alice" << endl;
	}
}

int main() {
	cin >> x >> y;
	solve();
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  char a[3];
  cin>>a[0]>>a[1]>>a[2];
  char b[3];
  cin>>b[0]>>b[1]>>b[2];
  char c[3];
  cin>>c[0]>>c[1]>>c[2];
  cout<<a[0]<<b[1]<<c[2];
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N,M,K = map(int,input().split())

friend = [[] for i in range(N)]
ans = [0] * N ###友達関係にある人は必ず同グループにいるので, あらかじめマイナスにしておく

for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    friend[A].append(B)
    friend[B].append(A)
    ans[A] -= 1
    ans[B] -= 1
    

block = []

for i in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    block.append([C,D])

group = [0] * N
count = 1

for i in range(N):
    if group[i] == 0:
        group[i] = count
        stack = deque()
        stack.append([i,i])
        while stack:
            x = stack.pop()
            for y in friend[x[1]]:
                if y == x[0] or group[y] == count:
                    continue
                group[y] = count
                stack.append([x[1],y])
            #print(stack)
        count += 1

###ブロック関係かつ同グループに入っている二人にマイナスポイントをつける
for x in block:
    if group[x[0]] == group[x[1]]:
        ans[x[0]] -= 1
        ans[x[1]] -= 1

num = [0] * count###各グループの人数

for i in range(N):
    num[group[i]] += 1

for i in range(N):
    ans[i] += num[group[i]] - 1###-1は自分

print(" ".join(map(str,ans)))


Measured memory_bytes: 109600
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        double n = Double.parseDouble(scanner.next());

        int page = (int)Math.ceil(n / 2);


        System.out.println(page);
    }
}

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

int abs(int a, int b){
    if(a < b ){
        return b - a; 
    } else {
        return a - b;
    }
}

int main(){
    int n, l;
    cin >> n >> l;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        sum += l + i - 1;
    }
    if(l > 0 && l + n -1 > 0){
        cout << sum - l << endl;
    } else if((l <= 0 && l + n -1 >= 0) ||
    (l >= 0 && l + n -1 <= 0)){
        cout << sum << endl;
    } else {
        cout << sum - (l + n -1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int H,W,M;
  cin>>H>>W>>M;
  vector<pair<int,int>> A(M);
  set<pair<int,int>> F;
  map<int,int> B,C;
  for(pair<int,int> &p:A){
    cin>>p.first>>p.second;
    B[p.first]++,C[p.second]++;
    F.insert(p);
  }
  int mxh=0,mxw=0;
  for(pair<int,int> p:B)mxh=max(mxh,p.second);
  for(pair<int,int> p:C)mxw=max(mxw,p.second);
  vector<int> D,E;
  for(pair<int,int> p:B)
    if(p.second==mxh)D.push_back(p.first);
  for(pair<int,int> p:C)
    if(p.second==mxw)E.push_back(p.first);
  if(((int)D.size())*((int)(E.size()))>M){
    cout<<mxh+mxw<<endl;
    return 0;
  }
  for(int i:D)
    for(int j:E)
      if(!(F.count({i,j}))){
        cout<<mxh+mxw<<endl;
        return 0;
      }
  cout<<mxh+mxw-1<<endl;
}

Measured memory_bytes: 72596
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0 0 3 0 0 2 3 2
0 0 3 0 1 1 1 4
0 0 3 0 1 1 2 2

output:
2
1
0
"""

import sys


def get_line(line_info):
    for line_pair in line_info:
        line_axis = tuple(map(int, line_pair))
        p0, p1, p2, p3 = (x + y * 1j for x, y in zip(line_axis[::2], line_axis[1::2]))
        # print(p0, p1, p2, p3)
        if dot(p1 - p0, p3 - p2) == 0:
            print('1')
        elif cross(p1 - p0, p3 - p2) == 0:
            print('2')
        else:
            print('0')
    return line_info


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    questions = int(_input[0])
    lines = map(lambda x: x.split(), _input[1:])
    ans = get_line(lines)

Measured memory_bytes: 8008
/*input
4
3 6 28 9


*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
// #define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int n;
  cin >> n;
  ld v;
  vector <ld> vec;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
  }
  sort(all(vec));
  ld ans = vec[0] + vec[1];
  ans /= 2.0;
  for (int i = 2; i < n; i++) {
    ans = (ans + vec[i]) / 2.0;
  }
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def add_mod(a,b): return (a+b) % MOD

N, W = imn()
wv = [iln() for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        if sum_w - wv[i][0] >= 0: dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-wv[i][0]] + wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[N][W])

Measured memory_bytes: 181576
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

H, W, K = ri_()
c = [list(rs()) for _ in range(H)]
ans = 0
for bit in range(1<<H):
    for bitr in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if not (bit & (1 << i)):
                    if not (bitr & (1 << j)):
                        if c[i][j] == '#':
                            cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; i++) {
        h = (h1(key) + i * h2(key)) %M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0) {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(void) {
    int i, n;
    char str[L], com[9];
    for(i=0;i<M;i++) H[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%s %s",com,str);
        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)){
            printf("yes\n");
        } else {
            printf("no\n");
        }
        }
    }
  return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, sum = 0;
    cin >> n;
    rep(i, n)
    {
        int l, r;
        cin >> l >> r;
        sum += (r - l) + 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A2271
Title KUPC
*/
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))

char buf[302];
//
int strcnt(char * s,char c)
{
        int ret;

        ret=0;
        for(;*s;s++)
                if(*s==c)
                        ret++;
        return(ret);
}
int solve(char *s)
{
        int a1,a2,a3,a4;

        a1=strcnt(s,'K');
        a2=strcnt(s,'U');
        a3=strcnt(s,'P');
        a4=strcnt(s,'C');
        return(min(a1,min(a2,min(a3,a4))));
}
main()
{
        scanf("%s",buf);
        printf("%d\n",solve(buf));
return(0);
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define R register
typedef std::pair<int, int> pii;

int n, a[1 << 18], mx, sx, sss, f[1 << 18], g[1 << 18], frm[1 << 18];

int main() {
	std::ios::sync_with_stdio(false);

	std::cin >> n;
	for (R int i = 0, x; i < (1 << n); ++i) {
		std::cin >> x;
		if (x >= f[i]) g[i] = f[i], f[i] = x, frm[i] = i;
		else g[i] = std::max(g[i], x);
		for (R int j = 0; j < n; ++j)
			if ((~i >> j) & 1)
				if (f[i] > f[i | (1 << j)]) {
					g[i | (1 << j)] = std::max(f[i | (1 << j)], g[i]);
					f[i | (1 << j)] = f[i];
					frm[i | (1 << j)] = frm[i];
				}
				else {
					if (frm[i] == frm[i | (1 << j)]) continue;
					g[i | (1 << j)] = std::max(g[i | (1 << j)], f[i]);
				}
		sss = std::max(sss, f[i] + g[i]);
		if (i) std::cout << sss << std::endl;
	}
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

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


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string str;cin>>str;
	int dp[5][13]={0};
	dp[0][0]=1;
	int i,j,k;
	for(i=1;i<=4;i++){
		for(j=1;j<=str.size();j++){
			int suu=0,kak=1;
			for(k=j-1;k>=0;k--){
				suu+=(str[k]-'0')*kak;
				if(suu>255){break;}
				kak*=10;
				if(str[k]=='0'&&kak>10){continue;}
				dp[i][j]+=dp[i-1][k];
			}
		}
	}
	cout<<dp[4][str.size()]<<endl;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 3 ==0 || i % 5 == 0);
else sum += i;
}
cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val (n, a, b) = readInputLine().split(" ").map { it.toInt() }
    
    var ans = 0
    
    for (i in 1..n) {
        var tmp = i
        var sums = 0
        while (tmp != 0) {
            sums += tmp % 10
            tmp /= 10
        }
        if (a <= sums && sums <= b) {
            ans += i
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define mod (1e9 + 7)
#define pi 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

void solve1() {
    int n, m; cin >> n >> m;
    vector<int> s(m), c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> s[i] >> c[i];
    }

    string num = "";
    vector<bool> nums(n);
    for(int i = 0; i < n; i++) {
        num += '0';
        nums[i] = true;
    }

    for(int i = 0; i < m; i++) {
        if(n > 1 && s[i] == 1 && c[i] == 0) {
            num = "-1";
            break;
        }

        if(nums[s[i]-1] || num[s[i]-1] ==  c[i] + '0') {
            num[s[i]-1] = c[i] + '0';
            nums[s[i]-1] = false;
        } else {
            num = "-1";
            break;
        }
    }

    if(n > 1 && num[0] == '0') {
        num[0] = '1';
    }

    cout << num << endl;

}
int main()
{
    solve1();
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
 
 
ll n, m, i, j, k, t,r, a, b, c, d, l, w, tmp, g, ans, sum, cnt, neg1, flag, mn, mx, neg2;
ll arr[MAX], brr[MAX], crr[MAX], drr[MAX];
vector<ll> v[MAX];
vector<ll> centroid;

int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);
   
        cin>>n;
        mx = INT_MIN;
        mn = INT_MAX;
        ll mxi, mni;
        for(i=0;i<n;i++){
            cin>>arr[i]>>brr[i];
            crr[i]=arr[i]+brr[i];
            drr[i]=arr[i]-brr[i];
        }
        sort(crr,crr+n);
        sort(drr,drr+n);


        cout<<max(crr[n-1]-crr[0], drr[n-1]-drr[0]);


    return 0;   
}

Measured memory_bytes: 56772
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi v(n),c(n);
  REP(i,n)cin >> v[i];
  REP(i,n) cin >> c[i];
  REP(i,n) v[i] -= c[i];
  sort(rALL(v));
  int sum = 0;
  REP(i,n){
    if(v[i]<0) break;
    sum += v[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, roop, area = 1;

  while (scanf("%d", &n) != EOF) {

    for (roop = 1; roop <= n; roop++) {
      area += roop;
    }

    printf("%d\n", area);
    area = 1;
  }

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main () {
	int a,b,c,d,e,f=0,g;
	char moji[201],mae[201],ato[201];
	char ka,ki,ku;
	while(1){
		scanf("%s",moji);
		e=strlen(moji);
		if(moji[0]=='-'&&e==1)break;
		scanf("%d",&a);
		for(b=0;b<a;b++){
			scanf("%d",&c);
			for(d=0;d<c;d++){
				ato[d]=moji[d];
			}
			ato[c]='\0';
			f=0;
			for(d=c;d<e;d++){
				mae[f]=moji[d];
				f++;
			}
			mae[f]='\0';
			strcat(mae,ato);
			for(g=0;g<e;g++){
				moji[g]=mae[g];
			}
		}printf("%s\n",moji);
	}
			








	//scanf("%d",&a);
	return 0;}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    double L;
    cin >> L;
    cout << fixed << setprecision(10) << L * L * L / 27.0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    int add;
    bool can=true;
    rep(i,n){
        cin >> add;
        if(add%2!=0) continue;
        if(add%3!=0 && add%5!=0) can=false;
    }
    if(can) COUT("APPROVED");
    else COUT("DENIED");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<vector<int>> adjlist;
vector<vector<int>> vec;
int dep = 0;

void dfs (int cur, int prev = 0)
{
	dep++;
	for (int i: adjlist[cur])
	{   
		
		if (i != prev)
		{
			vec[dep].push_back(i);
			dfs(i, cur);	
		}

	}
	dep--;
}
int main() {

int n, a, b;
cin >> n;
adjlist.resize(n+1);
vec.resize(n+1);
int c[n+1];

for(int i=1;i<n;i++)
	{
		cin>>a>>b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
for(int i = 1; i < n+1; i++)
	cin >> c[i] ;

sort(c+1, c+n+1);

long long ans = 0;

for(int i = 1; i <n; i++)
ans+=c[i];

cout << ans << endl;
int i = 1, j = n-1;
int p[n+1];
p[1] = c[n];

dfs(1);

while(vec[i].size() != 0)
{
	for(int k = 0; k < vec[i].size(); k++)
	{
	p[vec[i][k]] = c[j];
	j--;
	}
	i++;
}
for (int i = 1; i < n+1; i++)
cout << p[i]<< " ";
	// your code goes here
	return 0;
}

Measured memory_bytes: 2048
use strict;
use warnings;

sub main {
    my ($A,$B,$C,$D) = split(/ /,<STDIN>);
    chomp($D);
    print solve($A,$B,$C,$D);
}
main() unless caller;

sub solve {
    my ($A,$B,$C,$D) = @_;
    my $AB = $A * $B;
    my $CD = $C * $D;
    return $AB > $CD ? $AB : $CD;
}

Measured memory_bytes: 640
# coding: utf-8
n,m=map(int,input().split())
if n==m==1:
    print(1)
    exit()
ans=0
ans+=max((n-2),0)*max((m-2),0)
if n==1 and n!=m or m==1 and m!=n:
    ans+=max(n,m)-2
print(ans)

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

using namespace std;

int main(){

string sign;
int number = 0;
cin >> sign ;

for ( int n = 0 ; n < 4 ; n++){
    if ( sign [n] == '+')
        number ++;
    if ( sign [n] == '-')
        number--;
}
cout << number;

return 0;
}

Measured memory_bytes: 256
s = input()
while s:
    if s.startswith("eraser"):
        s = s[6:]
    elif s.startswith("erase"):
        s = s[5:]
    elif s.startswith("dreamera"):
        s = s[5:]
    elif s.startswith("dreamer"):
        s = s[7:]
    elif s.startswith("dream"):
        s = s[5:]
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int K=110;
int d;
int t;
int ans[K];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        cin>>d;
        for(int j=1;j<=d;j++){
            cin>>t;
            ans[t]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(ans[i]==0) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <cctype>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

map<string,int> table;
bool flag;

int expression(State &begin);
int factor(State &begin);
int atom(State &begin);
int number(State &begin);

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

int atom(State &begin){
	string name="";
	name+=*begin;
	begin++;
	if(*begin>='a' && *begin<='z'){
		name+=*begin;
		begin++;
	}
	if(table.find(name)==table.end()){
		flag=false;
		return -1;
	}
	int ret=table[name];
	if(isdigit(*begin))ret*=number(begin);
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		int ret=expression(begin);
		begin++;
		if(isdigit(*begin)){
			ret*=number(begin);
		}
		return ret;
	}else return atom(begin);
}

int expression(State &begin){
	if(!flag)return -1;
	//int ret=factor(begin);
	int ret=0;
	while(1){
		if(*begin>='A' && *begin<='Z'){
			ret+=factor(begin);
		}else if(*begin>='a' && *begin<='z'){
			flag=false;
			return -1;
		}else if(isdigit(*begin)){
			ret*=factor(begin);
		}else if(*begin=='('){
			ret+=factor(begin);
		}else break;
	}
	return ret;
}


int main(void){
	while(1){
		string str;
		cin >> str;
		if(str=="END_OF_FIRST_PART")break;
		int x;
		scanf("%d",&x);
		table[str]=x;
	}
	while(1){
		string str;
		cin >> str;
		if(str=="0")break;
		State begin=str.begin();
		flag=true;
		int res=expression(begin);
		if(!flag)printf("UNKNOWN\n");
		else printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
#define pb push_back
#define LL long long
using namespace std;

vector<int> v;
int k;

bool check(LL c) {
    LL sum = 0, x =0;
    x = 1;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] > c) return false;
        if (sum + v[i] > c) x++, sum = v[i];
        else sum += v[i];
    }

    return k >= x;
}

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

    for (int i = 0; i < n; i++) {
        int x;
        cin >>x;
        v.pb(x);
    }

    LL low = 1, high = 2000000000, mid;
    int ans = -1;
    while (1) {
        mid = (low + high) / 2;
        //cout << low << " " << high << endl;
        if (!check(mid)) low = mid + 1;
        else if (low == mid) {
            ans = mid;
            break;
        }
        else high = mid;
    }

    cout<<ans<< endl;

    return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e3+1;
const int md=1e9+7;

int n,k;
int c[maxn][maxn];

int main(){
	cin>>n>>k;
	for (int i=0;i<=n;++i){
		c[i][0]=1;
		for (int j=1;j<=i;++j)
		c[i][j]=(c[i-1][j-1]+c[i-1][j])%md;
	}
	for (int i=1;i<=k;++i){
		int res=1ll*c[n-k+1][i]*c[k-1][i-1]%md;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ull A, B;
    cin >> A >> B;
    cout << (A * B) / __gcd(A, B);
    return 0;
}

Measured memory_bytes: 256