akhauriyash/Code-Regression huggingface dataset:
import collections

w=input()
a=[]
for i in range(len(w)):
  a.append(w[i])
c = collections.Counter(a)
b=list(c.values())
flag="T"
for i in range(len(b)):
  if b[i]%2!=0:
    print("No")
    flag="F"
    break
if flag=="T":
  print("Yes")

Measured memory_bytes: 3316
n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
m = p_n[0]
for i in range(1, n):
    if m > p_n[i]:
        ans += 1
    m = min(m, p_n[i])
    p_i_1.append(p_n[i])
    if m == 1:
        break
print(ans)


Measured memory_bytes: 26012
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	cols := strings.Split(sc.Text(), " ")

	w, _ := strconv.Atoi(cols[0])
	h, _ := strconv.Atoi(cols[1])
	x, _ := strconv.Atoi(cols[2])
	y, _ := strconv.Atoi(cols[3])
	r, _ := strconv.Atoi(cols[4])

	if x >= r && x <= w-r && y >= r && y <= h-r {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1096
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    divs = filter(lambda x: n // x < x - 1, make_divisors(n))
    ans = sum(x - 1 for x in divs)
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
N,M = map(int,input().split())
mod=10**9+7
A = {int(input()) for i in range(M)}

if 1 in A:
  x=0
else:
  x=1
B=[1,x]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[(B[i-1]+B[i-2])%mod]
print(B[-1]%mod)

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

int main(){
    int l;
    cin >> l;
    int n;
    cin >> n;
    int M = 0;
    for(int i=0; i<n; i++){
        int x, w;
        cin >> x >> w;
        M += x*w;
    }
    int W = abs(M);
    int X = 0;
    if( M > 0 ) X = -1;
    else if( M < 0 ) X = 1;
    cout << abs(X) << endl;
    if( X != 0 ){
        cout << X << " " << W << endl;
    }
}



Measured memory_bytes: 3096
# include <bits/stdc++.h>
# define fi first
# define se second
# define mk make_pair
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 5;
const int MAXM = 5e3 + 5;
const int MOD = 1e9 + 7;
const LL INF = 1e18;
typedef long long LL;
typedef pair<double, int> PDI;



int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    printf("%d\n", n*(n-1)/2 + m*(m-1)/2);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        long n = in.nl();
        long ans = 0, m = 0;
        for (long i = 1; i*i+i < n; i++) {
            if((n-i)%i!=0) continue;
            m = (n-i)/i;
            if(m > i) ans += m;
        }
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   char b;
   cin>>b;
   if(b=='A'){cout<<'T'<<endl;}
   if(b=='T'){cout<<'A'<<endl;}
   if(b=='G'){cout<<'C'<<endl;}
   if(b=='C'){cout<<'G'<<endl;}

return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    // int a[6];
    for(int i=1; i<=5; i++){
        int t; cin>>t;
        if(!t){
            cout<<i;
            return 0;
        }
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    long long s[n];
    s[0]=a[0];
    for(int i=1;i<n;i++){
        s[i]=s[i-1]+a[i];
    }
    long long p,q,r,m;
    long long x,y,z;
    long long ans=100000000000000;
    long long b[4];
    for(int i=2;i<n-1;i++){
        x=0;y=i-1;
        while(y-x>1){
            if(s[i-1]>2*s[(x+y)/2]){
                z=(x+y)/2;
                x=z;
            }else{
                z=(x+y)/2;
                y=z;
            }
        }
            if(s[x]+s[x+1]>s[i-1]){
                p=s[x];
                q=s[i-1]-p;
            }else{
                p=s[x+1];
                q=s[i-1]-p;
            }
        x=i;y=n-1;
        while(y-x>1){
            if(s[n-1]>s[(x+y)/2]*2-s[i-1]){
                z=(x+y)/2;
                x=z;
            }else{
                z=(x+y)/2;
                y=z;
            }
        }
            if(s[x]+s[x+1]-s[i-1]>s[n-1]){
                r=s[x]-s[i-1];
                m=s[n-1]-s[x];
            }else{
                r=s[x+1]-s[i-1];
                m=s[n-1]-s[x+1];
            }
        b[0]=p;
        b[1]=q;
        b[2]=r;
        b[3]=m;
        sort(b,b+4);
        if(ans>b[3]-b[0])ans=b[3]-b[0];
    }
    printf("%lld\n",ans);
}

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

int main(){
  int N;  cin >> N;
  map<int,int>A;
  long long sum = 0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A[a]++;
    sum += a;
  }
  int Q;  cin >> Q;
  for(int i=0;i<Q;i++){
    int B,C;  cin >> B >> C;
    sum += A[B]*(C - B);
    A[C] += A[B];
    A[B] = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 7856
import numpy as np
n,k = map(int,input().split())
sunuke_number = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(len(a)):
        sunuke_number[a[j]-1] = 1
print(sunuke_number.count(0))

Measured memory_bytes: 27212
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Train
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, i;
  scanf("%d%d", &n, &i);

  printf("%d\n", n - i + 1);
  return 0;
}


Measured memory_bytes: 256
use std::collections::BTreeMap;
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut map: BTreeMap<usize, usize> = BTreeMap::new();
    for _ in 0..n {
        map.entry(parse_line::<usize>().unwrap())
            .and_modify(|x| *x += 1)
            .or_insert(1);
    }
    println!("{}", map.values().filter(|&x| x % 2 == 1).count());
}


Measured memory_bytes: 5028
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>

#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk,q;
  multimap<string,int> m;
  int c,x;
  string key;
  //cout << "hoge" << endl;
  map<string,int>::iterator it;
  map<string,int>::iterator lit,rit;
  pair<string,int> p;
  cin >> q;
  
  
  for(ii=0;ii<q;ii++){
    //cout << "ii:" << ii << endl;
    cin >> c ;
    //cout << c << endl;
    if(c == 0){
      cin >> key >> x;
      //m.insert_or_assign(make_pair(key,x));
      //m.erase(key);
      m.insert(make_pair(key,x));
    }
    else if(c==1){
      cin >> key;
      //cout << "<<" << key << ">>" << endl;
      it = m.find(key);
  
      //cout << key << endl;
      if(it != m.end()){


        while(it != m.end()){
          //cout << p.first << " " << p.second << endl;
          p = *it;
          if(key == p.first){
            cout << p.second << endl;
          }
          else{
            break;
          }
          it++;

        }
        //cout << m[key] << endl;
      }
      else{
        //cout << 0 << endl;
      }
  
  
    }
    else if(c==2){
      cin >> key;
      m.erase(key);
    }
    else if(c==3){
      string l,r;

      cin >> l >> r;
  
      it = m.lower_bound(l);
      
      while(it != m.end()){
        p = *it;
        if(p.first >= l && p.first <= r){
          cout << p.first << " " << p.second << endl;
        }
        if(p.first > r){
          break;
        }
        it++;
      }
    }
    //cout << key << endl;
  }

  
  return 0;
  
}



Measured memory_bytes: 24728
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    vpl dt(N);
    REP(i, N){
        ll t, d; cin >> t >> d; dt[i] = PL(d,t);
    }
    sort(dt.begin(), dt.end(), p_comp_fg);
    set<ll> unq_t; multimap<ll, ll> dup;
    ll deli = 0;
    REP(i, K){
        ll d = dt[i].ff, t = dt[i].ss;
        deli += d;
        if(unq_t.count(t) > 0){
            dup.insert(make_pair(d,t));
        }
        else{
            unq_t.insert(t);
        }
    }
    ll x = unq_t.size();
    ll ans = deli + x*x;
    REP(i, N){
        ll d = dt[i].ff, t = dt[i].ss;
        if(unq_t.count(t) > 0) continue;
        if(dup.size() < 1) break;
        unq_t.insert(t);
        x++;
        deli += d - dup.begin()->ff;
        ans = max(ans, deli + x*x);
        dup.erase(dup.begin());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6784
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int a;

  cin >> a;
  int ans = a + a * a + a * a * a;
  cout << ans << endl;
}


Measured memory_bytes: 3600
N, A, B = map(int, input().split(' '))

count = int(N / (A + B))
blue_balls = count * A

if N % (A + B) != 0:
    if N % (A + B) > A:
        blue_balls += A
    else:
        blue_balls += N % (A + B)

print(blue_balls)

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

int main() {
  int n, m;
  cin>>n>>m;
  int a[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
    a[i] %= m;
  }
  long long acc[n];
  acc[0] = a[0];
  for (int i=1; i<n; i++) {
    acc[i] = acc[i-1] + a[i];
  }
  map<long long, int> mods;

  long long ans = 0;
  mods[0] = 1;
  for (int i=0; i<n; i++) {
    long long mod = acc[i] % m;
    long long tmp = (m - mod) % m;
    if (mods.find(mod) != mods.end()) {
      ans += mods[mod];
    }
    ++mods[mod];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int f(int x)
{
    int cnt = 0;
    while (x > 0)
    {
        cnt++;
        x /= 10;
    }
    return cnt;
}

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

    int n;
    cin >> n;
    int ans = INF;
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
            ans = min(ans, max(f(i), f(n / i)));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> N;
    cout << intceil(N, 2) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0010
{
    class Program
    {
        static double _radius = 0;
        static double[] _threePoints = new double[6];
        static double[] _centerPoint = new double[2];
        static double _x_CenterPoint = 0;
        static double _y_CenterPoint = 0;

        static void Main(string[] args)
        {
            int NumOfSumple = int.Parse(Console.ReadLine());
            for (int i = 0; i < NumOfSumple; ++i)
            {
                _threePoints = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                _centerPoint = Calculation.EvaluateCenterOfCircleFrom3Points(_threePoints);
                _x_CenterPoint = _centerPoint[0];
                _y_CenterPoint = _centerPoint[1];
                _radius = Calculation.EvaluateRadiusFrom3Points(_threePoints, _centerPoint);
                Console.WriteLine(_x_CenterPoint.ToString("F3") + " " + _y_CenterPoint.ToString("F3") + " " + _radius.ToString("F3"));
            }
        }

    }
    class Calculation
    {
        internal static double[] EvaluateCenterOfCircleFrom3Points(double[] threePoints)
        {
            double[] centerPoint = new double[2];
            double x_Circle = centerPoint[0];
            double y_Circle = centerPoint[1];
            double x1 = threePoints[0];
            double y1 = threePoints[1];
            double x2 = threePoints[2];
            double y2 = threePoints[3];
            double x3 = threePoints[4];
            double y3 = threePoints[5];

            x_Circle = ((y3 - y2) * (Math.Pow(x1, 2) + Math.Pow(y1, 2)) - ((y3 - y1) * (Math.Pow(x2, 2) + Math.Pow(y2, 2))) - ((y1 - y2) * (Math.Pow(x3, 2) + Math.Pow(y3, 2))))
                           / (2 * ((y3 - y2) * (x1 - x2) - (y1 - y2) * (x3 - x2)));
            y_Circle = (-(x3 - x1) * (Math.Pow(x2, 2) + Math.Pow(y2, 2)) + ((x3 - x2) * (Math.Pow(x1, 2) + Math.Pow(y1, 2))) - ((x1 - x2) * (Math.Pow(x3, 2) + Math.Pow(y3, 2))))
                           / (2 * ((x3 - x2) * (y1 - y2) - (x1 - x2) * (y3 - y2)));
            centerPoint[0] = x_Circle;
            centerPoint[1] = y_Circle;
            return centerPoint;
        }
        internal static double EvaluateRadiusFrom3Points(double[] threePoints, double[] centerPoint)
        {
            double radius = 0;
            double x1 = threePoints[0];
            double y1 = threePoints[1];
            double x_Center = centerPoint[0];
            double y_Center = centerPoint[1];

            radius = Math.Abs(Math.Sqrt(Math.Pow(x1 - x_Center, 2) + Math.Pow(y1 - y_Center, 2)));
            return radius;
        }
    }
}



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int a, p;
	cin >> a >> p;
	p += 3 * a;
	cout << p / 2 << endl;
}


Measured memory_bytes: 3584
n, m = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
a = set(int(i) for i in input().split())
b = set(int(i) for i in input().split())
if len(a) != n or len(b) != m:
    print(0)
    exit()
ans = 1
c = 0
d = 0
for i in reversed(range(1, n * m + 1)):
    if i in a and i in b:
        ans *= 1
        c += 1
        d += 1
    elif i in a:
        ans *= d
        c += 1
    elif i in b:
        ans *= c
        d += 1
    else:
        ans *= (c * d) - (n * m) + i
    ans %= mod
print(ans)


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> h(n);
  for (ll i = 0; i < n; ++i) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<ll>());

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (k > 0) {
      --k;
    } else {
      ans += h[i];
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    ll a = n / k;
    ll x = n - k * a;
    cout << min(x, abs(x - k)) << endl;
    return 0;
}

Measured memory_bytes: 3536
from math import tan, atan2, pi, degrees


def f(theta):
    if theta < thres:
        return V - a ** 3 * tan(theta) / 2
    else:
        return a * b * b / tan(theta) / 2


eps = 1e-9
a, b, x = map(int, input().split())
V = a * a * b
thres = atan2(b, a)

bad, good = pi / 2, 0
while bad - good > eps:
    mid = (bad + good) / 2
    if f(mid) >= x:
        good = mid
    else:
        bad = mid
print(degrees(good))


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 083 A / Link: http://abc083.contest.atcoder.jp/tasks/abc083_a  ----- */


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

	LL A, B, C, D; cin >> A >> B >> C >> D;


	LL a = A + B;
	LL b = C + D;
	
	string ans;
	if (a == b)ans = "Balanced";
	else if (a > b)ans = "Left";
	else ans = "Right";
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[109];

int main() {
  int n;
  scanf("%d", &n);
  int suff = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    suff += a[i];
  }
  int ans = 1'000'000'000;
  int pref = 0;
  for (int i = 0; i < n - 1; ++i) {
    pref += a[i];
    suff -= a[i];
    ans = min(ans, abs(pref - suff));
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll dp[200100];

int main(){
	ll n;
	cin>>n;
	clr(dp,0);
	vector<ll> v;
	ll c = -1;
	rep(i,0,n){
		ll a;
		cin>>a;
		if(a!=c){
			v.pb(a);
			c = a;
		}
	}
	map<ll,ll> ma;
	dp[0] = 1;
	rep(i,0,v.sz){
		dp[i+1] += dp[i];
		dp[i+1] += ma[v[i]];
		dp[i+1] %= MOD;
		ma[v[i]]+=dp[i];
		ma[v[i]]%=MOD;
	}
	cout << dp[v.sz]%MOD << endl;
	return 0;	
}

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

using namespace std;

int a[5][110];
int dp[5][110];

int main()
{
    int n;
    scanf("%d",&n);
    for (int i=1;i<=2;i++)
        for (int j=1;j<=n;j++) scanf("%d",&a[i][j]);
    memset(dp,0,sizeof(dp));
    for (int i=1;i<=2;i++)
        for (int j=1;j<=n;j++)
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
    printf("%d\n",dp[2][n]);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
		int snuke[101];
		int n,k,d,i,j,tmp,ans=0;
		
		for(i=0;i<=100;i++) snuke[i]=0;
		scanf("%d %d",&n,&k);
		for(i=0;i<k;i++){
			scanf("%d",&d);
			for(j=0;j<d;j++){
				scanf("%d", &tmp);
				if(snuke[tmp]==0) snuke[tmp]=1;
			}
		}
		for(i=1;i<=n;i++){
			if(snuke[i]==0) ans++;
		}
		printf("%d\n",ans);
		return 0;
	}
	


Measured memory_bytes: 1728
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from decimal import Decimal
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

'''
N = ii()
A = li()
ans = 1
inf = Decimal('1000000000000000000')
for num in A:
    if ans <= inf / Decimal(str(num)):
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()
print(ans)
'''

N = ii()
A = li()
if 0 in A:
    print(0)
    exit()
ans = 1
for num in A:
    if ans < (10**18+1) / num or ans == 10**18//num:
        ans *= num
    else:
        print(-1)
        exit()
 
print(ans)

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
//    ifstream myfile("C:\\Users\\riku\\Downloads\\even0.txt");
//
//    ofstream outfile("log.txt");

    ll n;
    cin >> n;
//    myfile >> n;
    vector<ll> as(n);
    rep(i, n) {
//        myfile >> as[i];
        cin >> as[i];
    }

    sort(as.begin(), as.end());
    ll mx = as[n - 1];


    ll diff_min = INF;
    ll comb_min;
    for (ll i = 0; i < n - 1; i++) {
        ll u = as[i];
        ll v = u;
        if ((u * 2) >= mx) {
            v = mx - u;
        }

        ll d = abs((v * 2) - mx);


        if (diff_min > d) {
            comb_min = u;
            diff_min = d;
        }
    }
    cout << mx << ' ' <<  comb_min << endl;

}

Measured memory_bytes: 1024
a,b,c=map(int,input().split())
x=[a,b,c]
for  j in range(2,0,-1):
    for i in range(j):
        if x[i]>x[i+1]:
            x[i],x[i+1]=x[i+1],x[i]
print(x[0],x[1],x[2])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<vector<char>> grid(h+1, vector<char>(w+1, '#'));
    rep(i, h) rep(j, w) cin >> grid[i+1][j+1];
    
    vector<vector<int>> dp(h+1, vector<int>(w+1));
    dp[1][1] = 1;
    rep(i, 1, h+1) rep(j, 1, w+1) {
        if(i == 1 && j == 1) continue;
        if(grid[i][j] == '.') dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        else dp[i][j] = 0;
    }
    cout << dp[h][w] << endl;
}

Measured memory_bytes: 8224
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
static const int VMAX = 10000;

void solve()
{
	int n;
	cin >> n;
	vector<int> A(n + 1);
	vector<int> B(n + 1);
	vector<int> C(VMAX + 1, 0);
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i + 1];
		C[A[i + 1]]++;
	}
	for (int i = 1; i <= VMAX; ++i)
	{
		C[i] += C[i - 1];
	}
	for (int i = 1; i <= n; ++i)
	{
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	for (int i = 1; i < n; ++i)
	{
		cout << B[i] << " ";
	}
	cout << B[n] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 16856
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

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

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main(){
  ll N;
  cin >> N;
  ll m = INFL;
  ll ans = 0;
  ll cnt = 0;
  vector<ll> A(N), B(N);
  rep(i, N){
    cin >> A[i] >> B[i];
    if(A[i] > B[i]) cnt++;
  }
  if(cnt == 0){
    ans = 0;
  }else if(cnt){
    rep(i, N){
      if(A[i] <= B[i]){
        ans += A[i];
      }else{
        ans += A[i];
        m = min(m, B[i]);
      }
    }
    ans -= m;
  }
  cout << ans << endl;
}


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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	vector<string> s(n);
	map<string,int> m;
	for(int i=0;i<n;i++){
		cin >> s[i];
		m[s[i]]++;
	}
	// keisan
	int mx = 0;
	for(auto x:m){
		mx = max(mx,x.second);
	}
	for(auto x:m){
		if(x.second == mx){
			cout << x.first << endl;
		}
	}
	// syutsuryoku
}

Measured memory_bytes: 26752
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    cout << "";
    if (a<b && b<c){ 
        cout << "Yes";
    }
    else cout << "No";
     
    cout << endl;
    
}


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

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

int main(){
  int n, x;
  int a,b = 0;
  cin >> n >> x;
  for(int i = 0; i < n && b != 1 ; i++){
    cin >> a;
    a -= x;
    a = abs(a);
    if(i == 0){
      b = a;
      continue;
    }
    b = gcd(a, b);
  }
  cout << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=2e5+5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,k,ans;
	cin>>n>>k;
	if(n>=10)ans=k;
	else ans=k+(10-n)*100;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 2e5 + 10;
long long a[maxn];
vector<long long>son[maxn];
int main()
{
	long long n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	son[1].push_back(1);
	int t, cur = 1;
	int now = 1;
	while (k > 0)
	{
		if (son[now].size() >= 2)
		{
			t = abs(son[now][0] - son[now][1]);
			k %= (t * 1LL);
			if (k == 0)
				break;
		}
		now = a[now];
		cur++;
		son[now].push_back(cur);
		k--;
	}
	cout << now << endl;
}

Measured memory_bytes: 14780
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let mut n = read!(i64);

    if n == 0 {
        println!("0");
        return;
    }

    let mut v = vec![];
    let mut i = 1;

    while n != 0 {
        if n % (1 << i) != 0 {
            v.push(1);
            n -= (1 << (i - 1)) * (if i % 2 == 1 { 1 } else { -1 });
        } else {
            v.push(0)
        }

        debug!(n);
        i += 1;
    }

    {
        let mut m = 0;
        let mut p = 1;
        for b in v.iter().cloned() {
            m += b * p;
            p *= -2;
        }
        debug!(m);
    }

    println!(
        "{}",
        v.into_iter().rev().map(|b| b.to_string()).vec().join("")
    );
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for (int i = 0; i < 3; i++) {
			if(s.charAt(i) == 'o') count++;
		}
		System.out.println(700+100*count);
		sc.close();
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
int main()
{
	ll a;
	double b;
	scanf("%lld%lf",&a,&b);
	ll res=(ll)(b*100+0.5);//防止转化浮点误差 
	printf("%lld\n",res*a/100);
	return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int m, ni, na,p;
	while (cin >> m >> ni >> na) {
		if (m == 0)break;
		int ma = 0; int check; int memo = 0;
		for (int i = 1; i <= m; i++) {
			if (i == 1) {
				cin >> p; memo = p; continue;
			}
			cin >> p;
			if (ni < i && i <= na+1) {
				if (ma <= memo - p) {
					ma = memo - p; check = i - 1;
				}
			}
			memo = p;
		}
		cout << check << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>

using namespace std;

void scan_list (int X[][100], int a, int b) {
    
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            cin >> X[i][j];
        }
    }

}

int main () {

    int n, m ,l;

    int A[100][100];
    int B[100][100];

    long long int C[100][100] = {0};

    int cnt = 0;

    cin >> n >> m >> l;

    scan_list(A, n, m);
    scan_list(B, m, l);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < l; k++) {
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            if (j > 0) {
                cout << " ";
            }
            cout << C[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;




ll table[100009];


int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);


    int n,m;
    cin >> n >> m;
    vector<pair<int,ll> >v(n);


    for(int i = 0;i < n;i++){
        cin >> v[i].f >> v[i].s;
    }

    for(int i = 0;i < n;i++){
        for(int cap = m;cap >= v[i].f;cap--){
            table[cap] = max(table[cap],table[cap-v[i].f]+v[i].s);
        }
    }

    cout<<table[m];



    return 0;
}
/*
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000



*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n + 1); REP (i, n + 1) cin >> a[i];
  vector<int> b(n + 1); REP (i, n) cin >> b[i];
  int ans = 0;
  REP (i, n) {
    int mi = min(a[i], b[i]);
    ans += mi;
    b[i] -= mi;

    int mi2 = min(a[i + 1], b[i]);
    ans += mi2;
    a[i + 1] -= mi2;
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  int t[N+5],x[N+5],y[N+5];
  t[0] =0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 1;i<N+1;++i){
	cin >> t[i] >> x[i] >> y[i];
  }
  
  bool can = true;
  for(int i = 0;i<N;++i){
    if((x[i+1]-x[i] + y[i+1] - y[i]) > (t[i+1]-t[i])) can = false;
    if(((abs(x[i+1]-x[i] + y[i+1] - y[i]))%2) != (t[i+1]-t[i])%2) can = false;  
  }
  if(can) printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 1408
// ABC049

// inputに入力データ全体が入る
function Main(input) {
  var S = reverse(input.split("\n")[0].toString());
  const a = reverse("dream");
  const b = reverse("dreamer");
  const c = reverse("erase");
  const d = reverse("eraser");
  var flag = 0;
  var result = "YES";

  while(S.length > 0 && flag != 1) {
    if(!S.indexOf(a)){
      S = S.slice( a.length ) ;
    } else if(!S.indexOf(b)){
      S = S.slice( b.length ) ;
    } else if(!S.indexOf(c)){
      S = S.slice( c.length ) ;
    } else if(!S.indexOf(d)){
      S = S.slice( d.length ) ;
    } else {
      flag = 1;
      result = "NO";
    }
  }
  console.log(result);
}

// 文字逆さ
function reverse(s) {
  var tmp = s.split("");
  var str = "";
  for(var i=tmp.length-1;i>=0;i--) {
    str += tmp[i].toString();
  }
  return str;
}

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


Measured memory_bytes: 16312