akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	@SuppressWarnings("unused")
	private static long calculateLCM(long a, long b) throws IOException {
		if ( a  < b ) {
			long t = a;
			a = b;
			b = t;
		}
		while ( b > 0 ) {
			long t = b;
			b = a % b;
			a = t;
		}
		return a;
	}

	
	/* main routine */
	
	public static void main(String args[]) throws IOException {
		int n = getInt();
		String s = getString();
		n /= 2;
		System.out.println( s.substring(0, n).equals(s.substring(n)) ? "Yes" : "No" );
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl v(MAX_N);
    rep(i, n) {
        ll a;
        cin >> a;
        v[a]++;
    }
    
    ll ans = 0;
    exrep(i, 1, 100000) {
        chmax(ans, v[i-1] + v[i] + v[i+1]);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

ll N, W;
ll value[5][105];
ll st[4];
ll min_w = 1ll << 60ll;
ll v, w;
ll ans;

int cmp(const void *x, const void *y);

int main()
{
    scanf("%lld %lld", &N, &W);
    for (int i = 1; i <= N; i++) {
        scanf("%lld %lld", &w, &v);
        min_w = min(w, min_w);
        
        st[w - min_w]++;
        value[w - min_w][st[w - min_w]] = v;
    }

    for (int i = 0; i < 4; i++) {
        qsort(value[i] + 1, N, sizeof(ll), cmp);
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= N; j++) {
            value[i][j] += value[i][j - 1];
        }
    }
    
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= N; k++) {
                for (int l = 0; l <= N; l++) {

                    if (i + j + k + l <= N &&
                        (i * min_w) +
                        (j * (min_w + 1)) +
                        (k * (min_w + 2)) +
                        (l * (min_w + 3)) <= W) {

                        ans = max(ans,
                                  value[0][i] - value[0][0] +
                                  value[1][j] - value[1][0] +
                                  value[2][k] - value[2][0] +
                                  value[3][l] - value[3][0]);
                    }
                }
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}

int cmp(const void *x, const void *y)
{
    if (*(ll *)x > *(ll *)y) {
        return -1;
    }
    else if (*(ll *)x == *(ll *)y) {
        return 0;
    }
    else {
        return 1;
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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 ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
        x /= spf[x];
    }
    sort(ret.begin(), ret.end());
    return ret;
}

ll n;

int main() {
    cin >> n;
    ll ans = 0;
    auto spf = smallest_prime_factors(1000005);
    for(int i = 1; i <= n-1; ++i) {
        int check = n-i;
        auto result = factolization(check, spf);
        map<int, int> mcnt;
        for(auto x : result) mcnt[x]++;
        ll ch = 1;
        for(auto y : mcnt) {
            if(y.second == 0) continue;
            ch *= (y.second+1);
        }
        ans += ch;
    }

    cout << ans << endl;
}

Measured memory_bytes: 7220
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll h, w, K; cin >> h >> w >> K;
  vector<string> m(h); cin >> m;
  vector<vector<ll>> ans(h, vector<ll>(w, 0));
  ll k = 1;
  rep(y, h) {
    bool is_find = false;
    rep(x, w) {
      if (m[y][x] == '#') {
        ans[y][x] = k++;
        is_find = true;
      }
    }
    if (is_find) {
      rep(x, 1, w) if (ans[y][x] == 0) ans[y][x] = ans[y][x-1];
      rrep(x, w-1) if (ans[y][x] == 0) ans[y][x] = ans[y][x+1];
    }
  }
  rep(y, 1, h) rep(x, w) if (ans[y][x] == 0) ans[y][x] = ans[y-1][x];
  rrep(y, h-1) rep(x, w) if (ans[y][x] == 0) ans[y][x] = ans[y+1][x];
  cout << ans << endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> G(h);
    rep(i, h) { cin >> G[i]; }

    int ma = 0;
    for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
            if (G[x][y] == '#') {
                continue;
            } else {
                queue<pair<int, int>> q;
                vector<vector<int>> dist(h, vector<int>(w, -1));
                vector<vector<int>> check(h, vector<int>(w, -1));
                dist[x][y]  = 0;
                check[x][y] = 1;
                q.push(make_pair(x, y));
                while (!q.empty()) {
                    pair<int, int> node = q.front();
                    q.pop();
                    for (int i = 0; i < 4; i++) {
                        pair<int, int> n_node =
                            make_pair(node.first + dx[i], node.second + dy[i]);
                        if (0 <= n_node.first and n_node.first < h and
                            0 <= n_node.second and n_node.second < w and
                            G[n_node.first][n_node.second] == '.' and
                            check[n_node.first][n_node.second] == -1) {
                            q.push(n_node);
                            check[n_node.first][n_node.second] = 1;
                            dist[n_node.first][n_node.second] =
                                dist[node.first][node.second] + 1;
                            d(dist[n_node.first][n_node.second]);
                        }
                    }
                }
                int mma = -1;
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        mma = max(dist[i][j], mma);
                    }
                }
                // cout << mma << endl;
                ma = max(ma, mma);
            }
        }
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
K = min(N, K)
*h, = map(int, input().split())
a = [abs(h[0] - h[k]) for k in range(K)]
for n in range(N - K):
    a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]
print(a[K - 1])


Measured memory_bytes: 55264
// https://atcoder.jp/contests/abc160/tasks/abc160_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

int d[2001][2001];
void warshall_floyd(int n, int x, int y) {
    int v[] = {x, y};
    for (auto k : v) {         // 経由する頂点
        REP(i, n) {            // 始点
            FOR(j, i + 1, n) { // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, X, Y;
    cin >> N >> X >> Y;
    REP(i, N) REP(j, N) { d[i][j] = abs(i - j); }
    X--, Y--;
    d[X][Y] = 1;
    d[Y][X] = 1;
    warshall_floyd(N, X, Y);
    vector<int> ans(N);
    REP(i, N) FOR(j, i + 1, N) {
        int t = d[i][j];
        if (t < N)
            ans[t]++;
    }
    FOR(i, 1, N) { cout << ans[i] << "\n"; }

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} //最大公約数
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;} //最小公倍数
inline vector<ll> divisor(ll M){ //約数の全列挙
    vector<ll> dd;
    for(ll i = 1; i*i <= M; i++){
        if(M % i == 0){
            dd.push_back(i);
            if(i * i != M){
                dd.push_back(M/i);
            }
        }
    }
    sort(dd.begin(), dd.end());
    return dd;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    vector<ll> v;
    vector<ll> d1 = divisor(A[0]);
    vector<ll> d2 = divisor(A[1]);
    rep(i,0,d1.size()) v.push_back(d1[i]);
    rep(i,0,d2.size()) v.push_back(d2[i]);
    sort(v.begin(), v.end(), greater<ll>());
    v.erase(unique(v.begin(), v.end()), v.end());
    // printa(v,v.size());
    rep(i,0,v.size()){
        ll cnt = 0;
        rep(j,0,N){
            if(A[j] % v[i] != 0) cnt++;
        }
        if(cnt <= 1){
            print(v[i]);
            return 0;
        }
    }




    
    
}

Measured memory_bytes: 1024
a, b, k = gets.split.map(&:to_i)

len = b - a + 1
if k * 2 >= len
  (a..b).each { |n| puts n }
else
  nums = (a..a+k-1).to_a + (b-k+1..b).to_a
  nums.each { |n| puts n }
end


Measured memory_bytes: 1788
import math
N = int( input())
As  = [int(input())for _ in  range(N)]
ans = 0
for i in range(N):
    if As[i] > i or As[i] - As[i - 1] > 1:
        ans = -1
        break

    else:
        if As[i] == As[i -1] + 1:
            ans += 1
        else:
            ans += As[i]

print(ans)


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

int main() {
  string x;
  cin >> x;

  // ここにプログラムを追記
  if ( x == "a" || x == "e" || x == "i" || x == "o" || x == "u")
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
static const int inf = 1 << 30;
static const int MAX = 100;
int main(void) {
  int A, B;
  char Mat[MAX][MAX];
  cin >> A >> B;
  REP(i, MAX) {
    REP(j, MAX) { Mat[i][j] = (i < 50 ? '#' : '.'); }
  }
  int nrowA = A / 50;
  int nrowB = B / 50;
  cout << MAX << ' ' << MAX << endl;
  for (int i = 0; i < A - 1; i++) {
    Mat[i / 50 * 2][i % 50 * 2] = '.';
  }
  for (int i = 0; i < B - 1; i++) {
    Mat[99 - i / 50 * 2][i % 50 * 2] = '#';
  }
  REP(i, MAX) {
    REP(j, MAX) { cout << Mat[i][j]; }
    cout << endl;
  }
}

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

int main(int argc, char const *argv[])
{
    long n, m;
    cin >> n >> m;
    vector<long> vec_h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec_h.at(i);
    }
    vector<unordered_set<long>> vec_r(n, unordered_set<long>());
    long a, b;
    for (int i = 0; i < m; i++)
    {

        cin >> a >> b;
        vec_r.at(a - 1).insert(b - 1);
        vec_r.at(b - 1).insert(a - 1);
    }
    long counter = 0;
    bool flag = true;
    unordered_set<long> tmp_vec;
    for (int i = 0; i < n; i++)
    {
        flag = true;
        tmp_vec = vec_r.at(i);
        if (tmp_vec.size() == 0)
        {
            counter++;
            continue;
        }
        for (long j : tmp_vec)
        {
            if (vec_h.at(i) <= vec_h.at(j))
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 19260
N = int(input())
T = [1 for k in range(101)]

for M in range(2,N+1):
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            T[k] += 1
        else:
            k += 1
    if M > 1:
        T[M] += 1

C = [0 for k in range(101)]
for k in range(101):
    if T[k] >= 3:
        C[3] += 1
    if T[k] >= 5:
        C[5] += 1
    if T[k] >= 15:
        C[15] += 1
    if T[k] >= 25:
        C[25] += 1
    if T[k] >= 75:
        C[75] += 1

print(C[75] + C[25]*(C[3]-1) + C[15]*(C[5]-1) + (C[5]*(C[5]-1)*(C[3]-2))//2)


Measured memory_bytes: 38376
n,k=[int(i) for i in input().split()]
arr=[0 for i in range(n+1)]
ans=n
for i in range(k):
  d=int(input())
  s=[int(i) for i in input().split()]
  for i in s:
    if arr[i]==0:
      arr[i]=1
      ans-=1
print(ans)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,co=0,n;
    char a[4];
    scanf("%s",a);

    for(i=0;i<2;i++){
        if(a[i]==a[i+1] && a[i]==a[i+2]){
           co++;
           break;
        }
    }
    if(co!=0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

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

    if (S == "SUN") {
        n = 7;
    } else if (S == "MON") {
        n = 6;
    } else if (S == "TUE") {
        n = 5;
    } else if (S == "WED") {
        n = 4;
    } else if (S == "THU") {
        n = 3;
    } else if (S == "FRI") {
        n = 2;
    } else if (S == "SAT") {
        n = 1;
    } else {
        n = -1;
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int a,b;
    string s;
    cin>>a>>b>>s;
    if(s[a]=='-'){
        rep(i,a) if(s[i]=='-') {
            cout<<"No"<<endl;
            return 0;
        }
        for(int i=a+1;i<=b+a;i++) if(s[i]=='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }else{
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[309][309];
int f[309];
int h[309];
int w[309];
main(){
    int n, m;
    cin>> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++)
            w[j] = 1;
        for(int j = 1; j <= m; j++)
            f[j] = 1;
        int k = m;
        int fl = 0;
        while(k --){
            for(int j = 1; j <= m; j++)
                h[j] = 0;
            for(int j = 1; j <= n; j++)
                while(f[a[j][w[j]]] == 0)
                    w[j] ++;
            for(int j = 1; j <= n; j++)
                h[a[j][w[j]]] ++;
            int x = -1;
            for(int j = 1; j <= m; j++){
                if(h[j] > i) x = j;
            }
            if(x == -1) {
                fl = 1;
                break;
            }
            f[x] = 0;
        }
        if(fl){
            cout << i << endl;
            return 0;
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int a[100005] = {};
	int N; cin >> N;

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

	int ans = 0;
	for (int i = 1;i <= 100000;i++){
		int sum = a[i-1]+a[i]+a[i+1];
		ans = max(ans,sum);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    //まず0番目をリーダーにしたときを数える
    int turn = 0;
    for (int i=1; i<n; i++) {
        if (s[i] == 'E') {
            turn++;
        }
    }
    int minTurn = turn;
    //1,2,3,...番目をリーダーにした時、向き変えの必要数の変化を考える
    for (int i=1; i<n; i++) {
        if (s[i-1] == 'W') {
            turn++;
        }
        if (s[i] == 'E') {
            turn--;
        }
        minTurn = min(minTurn, turn);
    }
    cout << minTurn << endl;
}

Measured memory_bytes: 3852
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

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


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int arr[2020][2020];
int chaeng[2020];
int main()
{
    int n,i,j,k,x,y,ans,temp,curr,m;
    int tc;
    cin >> n >> x >> y;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            arr[i][j] = 1e9;
    for(i=1;i<=n;i++) arr[i][i] = 0;
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            arr[i][j] = arr[j][i] = j - i;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            arr[i][j] = min(arr[i][j], arr[i][x] + arr[y][j] + 1);
            arr[i][j] = min(arr[i][j], arr[i][y] + arr[x][j] + 1);
            arr[j][i] = arr[i][j];
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            chaeng[arr[i][j]]++;
        }
    }
    for(i=1;i<n;i++) cout << chaeng[i] << endl;
    return 0;
}


Measured memory_bytes: 16000
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
void solve();
 
class Solver {
public:
  int M;

  void solve() {
    cin >> M;
    cout << 48 - M << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int t,h,m,s;
  scanf("%d",&t);
  h = t/3600;
  t -= h*3600;
  m = t/60;
  s = t -m*60;
  printf("%d:%d:%d\n",h,m,s);
  return(0);
}

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

using namespace std;

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

    long long res = 0;
    for(int i = 1; i < N; i++) {
        if(A[i - 1] > A[i]) {
            int diff = abs(A[i - 1] - A[i]);
            res += diff;
            A[i] += diff;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x; cin >> n >> x;
    vector<int> D(n+1);
    D[0] = 0;
    for(int i = 0;i < n;i++) {
        int x; cin >> x;
        D[i+1] = D[i] + x;
    }
    int ans = 0;
    for(int i = 0;i <= n;i++) {
        if(D[i] <= x) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	double f;
	int a, b, d, r;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / b;
	printf("%d %d %lf\n", d, r, f);
	return 0;

}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;

// ¼ïPNPPú©çÌú
ll days(int y, int m, int d) {
  y--;
  ll res = y*365;
  res += (y/4)-(y/100)+(y/400); // [N
  for (int i=1; i<m; i++) {
    res += 31;
    if (i==4||i==6||i==9||i==11) res--;
    if (i==2) {
      res-=3;
      y++;
      if (y%400==0||(y%4==0&&y%100!=0))
        res++;
    }
  }
  return res+d-1;
}

int main() {
  // int y,m,d;
  // while(cin>>y>>m>>d) {
  //   cout << days(y,m,d) << endl;
  // }
  int y1,m1,d1,y2,m2,d2;
  while(cin>>y1>>m1>>d1>>y2>>m2>>d2) {
    if (y1<0||y2<0||m1<0||m2<0||d1<0||d2<0) break;
    cout << days(y2,m2,d2)-days(y1,m1,d1) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    ll N,K;
    cin>>N>>K;
    ll ans = 0;
    if(K ==0){
        cout<<N*N<<endl;
        return 0;
    }
    for(ll b = K+1; b <= N; b++){
        /*
        aの候補を考える
        bの倍数 + Kであれば良い
        */
        /*
        if(N % b == 0){
            ans += (N/b) * (b-K);
        }
        else{*/
            ans += (N/b) * (b-K);
            if(K > N % b)continue;
            ans += (N%b) - K +1;
        //}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
wx=[]
wy=[]
i=1
A="0"
wx=[A]
wy=[A]
for s in sys.stdin:
    s=s[:-1]
    if i: wx.append(A+s+A)
    else: wy.append(A+s)
    i=1-i
wx[0]=A*len(wx[1])
z=A*len(wy[1])
wy[0]=z
wy.append(z)

y = 1
x = 1
d = 1
msg = ""
while 1:
    A=[3,0,1,2,3,0,1][d:d+4]
    wall=[wy[y-1][x],wx[y][x],wy[y][x],wx[y][x-1]]
    for e in A:
        if wall[e]=="1": break
    d = e
    y += [-1,0,1,0][d]
    x += [0,1,0,-1][d]
    msg += "URDL"[d]
    if [x,y]==[1,1]: break
print msg

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  if(a*b%2==0) cout<<"Even"<<endl;
  else cout<<"Odd"<<endl;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c - (a-b),0) << endl;
  return 0;
    

}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

    ans = [0] * (N - K)
    for i in range(N - K):
        if A[i + K] > A[i]:
            ans[i] = 'Yes'
        else:
            ans[i] = 'No'

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 99532
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &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; }

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> h(n), a(n);
	rep(i, n) cin >> h[i];
	rep(i, n) cin >> a[i];
	segtree<int> seg(n + 1, 0, [](int a, int b) {return max(a, b); }, [](int a, int b) {return b; });
	rep(i, n) {
		int c = seg.query(0, h[i]);
		seg.change(h[i], c + a[i]);
	}
	int ans = 0;
	rep(i, n + 1) chmax(ans, seg[i]);
	cout << ans << endl;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
 
bitset<2000007> dp; 
int main()
{
	int n;
  cin >> n;
  dp[0] = 1;
  int x = 0;
  int sum = 0;
  for(int i = 0 ; i  < n ;i++)
  {
    cin >> x;
    sum = sum + x;
    dp = (dp | dp << x);
  }
  int target = ( sum + 1 )/2;
  
  for(int i = target; i<= sum ;i++)
  {
  	if(dp[i])
    {
    	cout << i;
      break;
    }
  }
  
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
long long x,a[100005],f[100005],ans[100005];
int cnt,n,q;
void xyy(long long d,long long w){
	int cat=upper_bound(a+1,a+cnt+1,d)-a-1;
	if(!cat) ans[1]+=w,ans[d+1]-=w;
	else f[cat]+=d/a[cat]*w,xyy(d%a[cat],w);
}
int main(){
	scanf("%d%d",&n,&q);
	a[++cnt]=n;
	while(q--){
		scanf("%lld",&x);
		while(cnt&&a[cnt]>=x) cnt--;
		a[++cnt]=x;
	}
	f[cnt]=1;
	for(int i=cnt;i>=2;i--) f[i-1]+=a[i]/a[i-1]*f[i],xyy(a[i]%a[i-1],f[i]);
	ans[1]+=f[1];ans[a[1]+1]-=f[1];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]+=ans[i-1]);
}


Measured memory_bytes: 6136
N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for _ in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])
num = {}
for py in sort_PY:
  if(py[0] not in num):
    num[py[0]] = 1
  else:
    num[py[0]] += 1
  py[2] = num[py[0]]
for py in PY:
  print(str(py[0]).zfill(6) + str(py[2]).zfill(6))

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


void solve(long long N, long long M){
    cout << pow(2, M) * (1900 * M + 100 * (N - M)) << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 4264
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] a = new double[n];
        double[] b = new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextDouble();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextDouble();
        }
        System.out.println(distance(a, b, 1));
        System.out.println(distance(a, b, 2));
        System.out.println(distance(a, b, 3));
        System.out.println(distance2(a, b, 1));
    }

    /**
     * [Assume a.length == b.length]
     * [pow >= 1] (?)
     *
     * Manhattan Distance : pow == 1
     * Euclidean Distance : pow == 2
     */
    private static double distance(double[] a, double[] b, double pow) {
        double sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += Math.pow(Math.abs(a[i] - b[i]), pow);
        }
        return Math.pow(sum, 1 / pow);
    }

    /**
     * [Assume a.length == b.length]
     *
     * Chebyshev distance : pow == 1
     * Hamming Distance : pow == 2
     */
    private static double distance2(double[] a, double[] b, int type) {
        double distance = 0;
        for (int i = 0; i < a.length; i++) {
            if (type == 1) {
                distance = Math.max(distance, Math.abs(a[i] - b[i]));
            } else if (type == 2) {
                distance += a[i] == b[i] ? 1 : 0;
            }
        }
        return distance;
    }
}

Measured memory_bytes: 28880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=2e5+10;
typedef long long LL;
const LL MOD=2019;
LL s[MR],a[MR];
LL cnt[MOD]={};

int main() {
	string num;
	cin>>num;
	int n=num.size();
	LL pow10=1;
	for(int i=n-1;i>=0;i--){
		a[n-i]=(num[i]-'0')*pow10;
		pow10=(pow10*10)%MOD;
	}
	s[0]=0;
	cnt[0]=1;
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
		cnt[s[i]%MOD]++;
	}
	LL ans=0;
	for(int i=0;i<MOD;i++){
		if(cnt[i]>=2){
			ans+=cnt[i]*(cnt[i]-1)/2;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6896
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	ull x, y;
	cin >> x >> y;
	ull a = x;
	int cnt = 0;
	while (a <= y) {
		a *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}





Measured memory_bytes: 256
/*
  Esteban Arango Medina
*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;
#define int ll

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <string,string> mss;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<", "; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
  #ifdef LOCAL_PROJECT
    freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
  #endif

  int T = 1; //cin>>T;
  while(T--) {
    int N, W; cin>>N>>W;
    vii items(N);
    int w, v;
    rep(i, 0, N) {
      cin>>w>>v;
      items[i] = {w,v};
    }
    vector<vi> DP(N, vi(W,0));
    rep(j, 0, W) {
      DP[0][j] = (items[0].first <= j+1) ? items[0].second : 0;
    }
    rep(i, 1, N) {
      DP[i][0] = (items[i].first <= 1) ? items[i].second : DP[i-1][0];
    }
    rep(i, 1, N) {
      rep(j, 1, W) {
        if(items[i].first <= j+1){
          int extraWeight = j - items[i].first >= 0 ? DP[i-1][j - items[i].first] : 0;
          DP[i][j] = max(DP[i-1][j], items[i].second + extraWeight);
        } else {
          DP[i][j] = DP[i-1][j];
        }
      }
    }
    // printMatrix(DP);
    cout<<DP[N-1][W-1];
  }
  return 0;
}

Measured memory_bytes: 79488
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(std::vector<long long> H, std::vector<long long> M, long long K) {
  ll s = H[0] * 60 + M[0];
  ll e = H[1] * 60 + M[1];
  ANS(e - s - K);
}

// clang-format off
int main() {
  std::vector<long long> H(2);
  std::vector<long long> M(2);
  for(int i = 0 ; i < 2 ; i++){
    scanf("%lld",&H[i]);
    scanf("%lld",&M[i]);
  }
  long long K;
  scanf("%lld",&K);
  solve(std::move(H), std::move(M), K);
  return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        if (w >= x+r && h >= y+r && 0 <= x-r && 0 <= y-r)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[5];
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    for(int i=4; i>=0; i--) {
        for(int j=0; j<i; j++) {
            if(a[j]<a[j+1]) swap(a[j], a[j+1]);
        }
    }
    cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<' '<<a[3]<<' '<<a[4]<<'\n';
    return 0;
}

Measured memory_bytes: 3168
#include<stdio.h>
int main()
{
 int r, g, b, ama;
 scanf("%d %d %d", &r, &g, &b);
 ama = (10*g+b)%4;
  
 if (ama == 0)
 {
 printf("YES");
 }
 
 else
 {
 printf("NO");
 }

 return 0;
 }

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

int n, k;

int gcd(int a, int b){
	return b?gcd(b, a%b):a;
}
int a[100010];

void dame(){ puts("IMPOSSIBLE"); exit(0); }

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	int g=0;
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		g=gcd(g, a[i]);
	}
	if(k%g) dame();
	k/=g;
	int m=0;
	for(int i=1; i<=n; ++i) m=max(m, a[i]/g);
	cout << ("IMPOSSIBLE" + 2*(k<=m)) << endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
        int[] x = new int[8];
        string str = Console.ReadLine();
        for (int i = 0; i < 6; i++)
        {
            x[i + 1] = int.Parse(str.Split()[i]);
        }
        int a = int.Parse(Console.ReadLine());
        int[] y = new int[a];
        for (int i = 0; i < a; i++)
        {
            string str2 = Console.ReadLine();
            int b = int.Parse(str2.Split()[0]);
            int c = int.Parse(str2.Split()[1]);

            if (b == x[1])
            {
                if (c == x[2]) y[i] = x[3];
                if (c == x[3]) y[i] = x[5];
                if (c == x[5]) y[i] = x[4];
                if (c == x[4]) y[i] = x[2];
            }
            if (b == x[2])
            {
                if (c == x[3]) y[i] = x[1];
                if (c == x[1]) y[i] = x[4];
                if (c == x[4]) y[i] = x[6];
                if (c == x[6]) y[i] = x[3];
            }
            if (b == x[3])
            {
                if (c == x[2]) y[i] = x[6];
                if (c == x[6]) y[i] = x[5];
                if (c == x[5]) y[i] = x[1];
                if (c == x[1]) y[i] = x[2];
            }
            if (b == x[4])
            {
                if (c == x[2]) y[i] = x[1];
                if (c == x[1]) y[i] = x[5];
                if (c == x[5]) y[i] = x[6];
                if (c == x[6]) y[i] = x[2];
            }
            if (b == x[5])
            {
                if (c == x[1]) y[i] = x[3];
                if (c == x[3]) y[i] = x[6];
                if (c == x[6]) y[i] = x[4];
                if (c == x[4]) y[i] = x[1];
            }
            if (b == x[6])
            {
                if (c == x[5]) y[i] = x[3];
                if (c == x[3]) y[i] = x[2];
                if (c == x[2]) y[i] = x[4];
                if (c == x[4]) y[i] = x[5];
            }
        }
        for (int i = 0; i < a; i++)
        {
            Console.WriteLine(y[i]);
        }
    }
}

Measured memory_bytes: 5604
import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import numpy as np

A_abs = np.abs(A_li)
A_neg_count = sum([1 if i<0 else 0 for i in A_li])

if 0 in A_li or A_neg_count%2 == 0: print(sum(A_abs))
else: print(sum(A_abs) - 2 * min(A_abs))


Measured memory_bytes: 18748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a;
  int ans = 0;
  cin >> n >> m;
  for(int i=0; i<m; i++){
      cin >> a;
      ans += a;
  }
  
  if(n<ans){
      ans = -1;
  }else{
      ans = n - ans;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3632