akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {

    int n;
    long long int t;

    cin >> n >> t;

    long long int a[n];

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

    long long int max_array[n];

    max_array[n-1] = a[n-1];

    for(int i=n-2; i >= 0; i--){
        max_array[i] = max(max_array[i+1],a[i]);
    }

    map<long long int,int> m;

    for(int i=0; i<n; i++){
        m[max_array[i] - a[i]]++;
    }

    priority_queue<pair<long long int,int>> q;

    for(auto p : m){
        q.push(p);
    }

    cout << q.top().second << endl;

    return 0;
}

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

int main()
{
  int n,k,l,c=0;
  cin>>n>>k;
  	for(int i = 0 ; i < n ; i++){
  		    cin>>l;
      	if(l>=k)
          c++;
          
    }
  cout<<c<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, V[1010][3];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        rep(j, 0, 3) cin >> V[i][j];
        sort(V[i], V[i] + 3);
    }

    int ans = 0;
    rep(i, 0, N) {
        int isErase = 0;
        rep(j, 0, i) {
            int same = 1;
            rep(k, 0, 3) if (V[i][k] != V[j][k]) same = 0;
            if (same) isErase = 1;
        }
        if (isErase) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int n, num[300007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int check(int l, int r)
{
	int lst = 0, rst = 0;
	for (int i = l; i <= r; i++)
		if (num[i] < i)
		{
			if (num[i]<l || num[i]>r || lst > num[i])return 0;
			lst = num[i];
		}
		else if (num[i] > i)
		{
			if (num[i]<l || num[i]>r || rst > num[i])return 0;
			rst = num[i];
		}
	return 1;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	for (int i = 2; i < n; i++)
		if (num[i - 1] != i - 1 && num[i] != i && num[i + 1] != i + 1) { cout << "No" << endl; return 0; }
	for (int i = 1; i <= n; i++)
		if (num[i] != i)
		{
			int l = i, now = 1;
			while (((num[i] == i) ^ now) && i <= n)i++, now ^= 1;
			i--;
			if (!check(l, i)) { cout << "No" << endl; return 0; }
		}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+2;
ll a[maxn],c[maxn]={0};
int main()
{
	ll N;
	cin>>N;
	for(ll i=0;i<N;i++)
	{
		cin>>a[i];
		c[a[i]]++;
	}
	ll res=0;
	for(ll i=0;i<=N;i++)
	{
		//cout<<c[i]<<" ";
		res=res+(c[i]*(c[i]-1))/2;
	}
	for(ll i=0;i<N;i++)
	{
		ll ans=res-c[a[i]]+1;
		cout<<ans<<"\n";
	}
	return 0;
}	

Measured memory_bytes: 4736
N, M = map(int, input().split())
Edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    c = -c
    Edges.append([a, b, c])
 
dist = [float('inf')] * N
dist[0] = 0
 
for i in range(N):
    for fr, to, cost in Edges:
        if (dist[fr] != float('inf')) and (dist[to] > dist[fr] + cost):
            dist[to] = dist[fr] + cost
            if (i == N - 1) & (to == N - 1):
                print('inf')
                exit()
 
print(-dist[-1])

Measured memory_bytes: 3416
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(A: int, B: int, C: int):
    if A+B >= C:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)

ret = [0] * (n + 1)
for start in range(n):
    parent = [-1] * n
    q = [start]
    while len(q) > 0:
        i = q.pop(0)
        for j in edges[i]:
            if j == start:
                loop = [i]
                while i != start:
                    i = parent[i]
                    loop.append(i)
                if len(ret) > len(loop):
                    ret = loop
                break
            if parent[j] == -1:
                parent[j] = i
                q.append(j)

if len(ret) > n:
    print(-1)
else:
    print(len(ret))
    for i in reversed(ret):
        print(i + 1)



Measured memory_bytes: 47704
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
int g[202][202];
void solve() {
	ll ans = 0;
	int K; cin >> K;
	FOR(i, 1, 201)FOR(j, 1, 201) {
		g[i][j] = gcd(i, j);
	}
	FOR(a, 1, K + 1)FOR(b, 1, K + 1)FOR(c, 1, K + 1) {
		ans += g[a][g[b][c]];
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




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

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

  if(S[k-1] == 'A')S[k-1] = 'a';
  if(S[k-1] == 'B')S[k-1] = 'b';
  if(S[k-1] == 'C')S[k-1] = 'c';
  
  cout << S << endl;

  
}

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

int main() { 
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n/2; ++i) {
        if(s[i] != s[n-i-1]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    for(int i = 0; i < (n-1)/2; ++i) {
        if(s[i] != s[(n-1)/2 - i - 1]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    for(int i = (n+3)/2; i <= n; ++i) {
        if(s[i - 1] != s[n + (n+3)/2 - i - 1]) {
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';

    return 0;
}


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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

using namespace std;
using ll = long long;
ll mo=1e9+7;
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> x(m);
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<m;++i){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    vector<int> b(m-1);
    for(int i=0;i<m-1;++i){
        b[i] = x[i+1] - x[i];
    }
    ll sum = 0;
    sort(b.begin(),b.end());
    for(int i=0;i<m-n;++i){
        sum += b[i];
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def unite(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

    def get_size(self, x):
        return -self.table[self._root(x)]


n = int(input())
ppp = list(map(int, input().split()))
MOD = 10 ** 9 + 7
uft = UnionFind(n)
base = 0
undefined = []
for i, p in enumerate(ppp):
    if p == -1:
        undefined.append(i)
        continue
    p -= 1
    if not uft.find(i, p):
        base += 1
        uft.unite(i, p)

if len(undefined) == 0:
    print(base % MOD)
    exit()
elif len(undefined) == 1:
    c = uft.get_size(undefined[0])
    others = n - c
    print((base * (n - 1) + others) % MOD)
    exit()

m = len(undefined)
dp = [0] * (m + 1)  # 閉路のパターン数
dp[0] = 1
additional = 0  # 閉路を考慮せずに追加される辺数

for i in undefined:
    c = uft.get_size(i)
    for j in range(m - 1, -1, -1):
        dp[j + 1] += dp[j] * c
    additional += n - c

duplicated = 0
pat = pow(n - 1, m, MOD)
inv = pow(n - 1, MOD - 2, MOD)
loop_permutation = 1
loop_other_pattern = pat * inv * inv % MOD
for loop_size in range(2, m + 1):
    duplicated = (duplicated + dp[loop_size] * loop_permutation * loop_other_pattern) % MOD
    loop_other_pattern = loop_other_pattern * inv % MOD
    loop_permutation = loop_permutation * loop_size % MOD

ans = (base * pat + additional * pat * inv - duplicated) % MOD

print(ans)


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    int dp[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
      //  cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	map<string, int> cnt;
	while(n--) {
		string s;
		cin >> s;
		cnt[s]++;
	}
	V<string> v({"AC", "WA", "TLE", "RE"});
	for(string s:v) cout << s << " x " << cnt[s] << endl;

}





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

int main() {
  ll N, K;
  cin >> N >> K;
  ll p, q=0;
  if (K%2 == 1) p = N/K;
  else {
    ll d = N/(K/2);
    p = d/2; q = d-p;
  }
  cout << p*p*p+q*q*q << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string.h>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int p[n];
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] != i + 1) count++;
	}
	if (count == 0 || count == 2) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    in(N);
    string tmp;
    unordered_set<string> hs;
    rep(i, N) {
        in(tmp);
        hs.insert(tmp);
    }
    cout << hs.size() << endl;



	return 0;
}


Measured memory_bytes: 17676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll K;
    cin >> K;

    queue<ll> q;
    for(ll i = 1; i <= 9; ++i) {
        q.push(i);
    }

    FOR(i, 1, K) {
        ll tmp = q.front();
        q.pop();
        
        if(tmp % 10 != 0) q.push((10*tmp) + (tmp % 10) - 1);
        q.push((10*tmp) + (tmp % 10));
        if(tmp % 10 != 9) q.push((10*tmp) + (tmp % 10) + 1);
    }

    cout << q.front() << endl;

    return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int a, b;
    cin >> a >> b;

    if(a == b) {
        cout  << "Draw" << endl;
        return 0;
    }

    if(a == 1) { 
        cout << "Alice" << endl;
        return 0;
    } 
    if(b == 1) { 
        cout << "Bob" << endl;
        return 0;
    }

    if(a > b) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}   
/** atcoder **/


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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll N,T,M=0,ans=1,cmp=0,tmppp=0;
    cin >> N >> T;
    ll A[N],tmp,tmpp,mi[N],ma[N];
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        if(i != 0) {
            tmp = min(tmp,A[i]);
            mi[i] = tmp;
        }else {
            tmp = A[i];
            mi[i] = tmp;
        }
    }

    reverse(A,A+N);
    tmp = 0;
    for(ll i = 0; i < N; i++) {
        tmp = max(tmp,A[i]);
        ma[i] = tmp;
    }

    for(ll i = 0; i < N-1; i++) {
        cmp = (ma[N-2-i]*(T/2))-(mi[i]*(T/2));
        if (M == cmp) {
            ans++;
            if(mi[i] == tmppp) {
                ans--;
            }else {
                tmppp = mi[i];
            }
        } else if (M < cmp) {
            M = cmp;
            ans = 1;
            tmppp = mi[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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


void ISortMax(int a[], int L){
	int i, j, v, ans;
	for(i = 1; i < L; i++){
		j = i - 1;
		v = a[i];
		while(j >= 0 && a[j] < v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

void ISortMin(int a[], int L){
	int i, j, v, ans;
	for(i = 1; i < L; i++){
		j = i - 1;
		v = a[i];
		while(j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

int hennkann(int a[], int L){
	int ans = 0, i = 0;for(int j = 0; j < L; j++)
	while(L){
		ans += pow(10, L - 1) * (a[i++]);
		L--;
	}
	return ans;
}

void foo(int a[], int b[], int L){
	int temp, temp2,  i = 0;
	temp = hennkann(a, L) - hennkann(b, L);
	
	while(L){
		temp2 = (temp/(int)pow(10, L - 1))%10;
		a[i] = temp2;
		b[i] = temp2;
		i++; L--;
	}
}

int cheak(int A[], int k){
	for(int i = 0; i < k; i++){
		if(A[i] == A[k]) return i;
	}
	return -1;
}

int main(){
	string str;
	int L, f, A[30], temp;
	int i, j, k;
	
	while(1){
		int a[10] = {}, b[10] = {}; j = 0;
		A[0] = 0;
		cin>>str>>L;
		if(str == "0" && L == 0) break;
		for(i = L - (int)str.size(); i < L;i++){
			a[i] = str[j] - '0';
			b[i] = str[j++] - '0';
		}
		
		k = 0;
		while(1){
			
			A[k] = hennkann(a, L);
			temp = cheak(A, k);
			if(temp != -1){
				break;
			}
			ISortMax(a, L);
			ISortMin(b, L);
			foo(a, b, L);
			k++;
			
		}
		
		cout<<temp<<" "<<A[temp]<<" "<<k - temp<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3296
INF = 2000000000
n ,limit_w = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
sum_v = sum(v)
dp = [INF for i in range(sum_v + 1)]
dp[0] = 0
for i in range(n):
    for j in range(sum_v ,-1,-1):
        if j >= v[i]:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])
for i in range(sum_v ,-1,-1):
    if dp[i] <= limit_w:
        print(i)
        break


Measured memory_bytes: 45040
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){

	lli n;
	lli f[110][10];
	lli data[10];
	cin>>n;
	for(lli i=0;i<n;i++){
	for(lli j=0;j<10;j++){
		cin>>f[i][j];
	}}

	lli p[110][10];
	for(lli i=0;i<n;i++){
	for(lli j=0;j<=10;j++){
		cin>>p[i][j];
	}
	}

	lli ans=-100000000000;

	/*0～9にて店を出したときそれぞれどうなる？*/
	for(lli b=1;b<(1<<10);b++){//どこに出す？
		lli now=0;
		for(lli i=0;i<n;i++){
			lli cnt=0;
			for(lli j=0;j<10;j++){
				if(DEBUG)cout<<(b&(1<<j))<<" ";
				if(b&(1<<j) && f[i][j]){
					cnt++;
				}
			}
			if(DEBUG)cout<<endl;
			if(DEBUG)cout<<"p[i] ="<<p[i][cnt]<<" cnt"<<cnt;
			now += p[i][cnt];
		}
		if(DEBUG)cout<<endl;
		if(ans <= now){
			if(DEBUG)cout<<"ans = "<<now<<endl;
			ans=now;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    vector<int> rgb(3, 0);
    REP(i, 3) cin >> rgb[i];
    ll n;
    cin >> n;

    int r, g, b =0;
    int left;
    ll ct = 0;

    r = n/rgb[0];
    // nt left = n - r;

    REP(i, r+1){
        left = n - i*rgb[0];
        g = left/rgb[1];
        // left = left - g;
        int gleft;
        REP(j, g+1){
            gleft = left - j*rgb[1];
            if (gleft %rgb[2] == 0){
                ct++;
                // cout << i << " " << j << " " << left / rgb[2] << endl;
            }
        }
    }

    cout << ct << endl;

}

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

int main(){
	string S;
	cin>>S;
	int count0=0;
	int count1=0;
	for (int i=0;i<S.size();i++){
		if(S.at(i)=='0'){
			count0++;
		}
		else{
			count1++;
		}
	}
	cout << 2* min(count0,count1)<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    int LR[N+1][N+1] = {};
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        LR[a][b]++;
    }
    int sum[N+1][N+1] = {};
    for(int i=1; i<N+1; i++){
        for(int j=1; j<N+1; j++){
            sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + LR[i][j];
        }
    }
    for(int i=0; i<Q; i++){
        int a,b;
        cin >> a >> b;
        a--;
        cout << sum[b][b] - sum[a][b] - sum[b][a] + sum[a][a] << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

signed main (){
    int h,w,hh,ww;
    cin>>h>>w>>hh>>ww;
    cout<<(h-hh)*(w-ww)<<endl;

    

    
}  
/*

*/


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

int main(void){
 	int A, B;
  	cin >> A >> B;
  	if(A==1) A+=13;
    if(B==1) B+=13;
  
    if(A>B) cout << "Alice" << endl;
    else if(A<B) cout << "Bob" << endl;
    else cout << "Draw" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    double x;
    string u;
    double ans = 0;
    for(i = 0;i < n;++i){
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else if(u == "BTC"){
            ans += x*380000.0;
        }
    }
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

   Scanner sc = new Scanner(System.in);

   int N = sc.nextInt();

   N = (N / 1);
   N = N % 10;
   
   if((N == 2) || (N == 4) || (N == 5) || (N == 7) || (N == 9)){
     System.out.println("hon");
   }else if((N == 0) || (N == 1) || (N == 6) || (N == 8)){
    System.out.println("pon");
   }else{
    System.out.println("bon");
   }

  }
}

Measured memory_bytes: 35892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>
#include <regex.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)<0?-(a):(a))
#define alloc(type,size) calloc(sizeof(type),size)

#define N 100001

char s[N];
bool f[256];
int res;


int main(void){
	int i;
	char c1,c2;
	char *h;
	scanf("%s",s);
	c1 = *s;
	c2 = *(s+1);
	for(h=s;*h;h++){
		if((h-s)%2){
			if(*h != c2) break;
		}else{
			if(*h != c1) break;
		}
	}
	if(!*h){
		printf("Second\n");
		return 0;
	}
	for(;*h;h++){
		if(*s == *h) res = h-s-2;
		else res = h-s-1;
	}
	printf("%s\n", res%2 ? "First":"Second");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
  long a,b,k;

  scanf("%ld%ld%ld",&a,&b,&k);

  if(k >= a+b)
    {
      a=0;
      b=0;
    }
  else if(k >= a)
    {
      b = a+b-k;
      a = 0;
    }
  else
    {
      a = a-k;
    }

  printf("%ld %ld",a,b );

return 0;
}


Measured memory_bytes: 1720
#include <iostream>

using namespace std;

int N, Z, W, a[2000], d[2000][2];
void f(int k, int i)
{
	if (d[k][i]) return;
	int w = k ? a[k - 1] : i ? Z : W;
	int m = a[N - 1] < w ? w - a[N - 1] + 1 : a[N - 1] - w + 1;
	for (int j = k + 1; j < N; j++) {
		f(j, !i);
		if (i ? m > d[j][0]:m < d[j][1])
			m = d[j][!i];
	}
	d[k][i] = m;
}

int main()
{
	cin >> N >> Z >> W;
	for (int i = 0; i < N; i++)
		cin >> a[i];
	f(0, 0);
	cout << d[0][0] - 1 << endl;
	return 0;
}


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

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  int ma=a,mi=a;
  ma=max(ma,b);
  ma=max(ma,c);
  mi=min(mi,b);
  mi=min(mi,c);
  cout<<ma-mi<<endl;
}
  

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

using namespace std ;

#define N 320
#define Mod 1000000007
#define int long long

int n , ans , m ;
int f[N][N][N] ;

struct node{
    int l , x ;
};

vector<node> V[N] ;

void Mul(int &x , int y){ ( x += y % Mod ) %= Mod ; }

signed main()
{
    scanf("%lld%lld" , &n , &m ) ;
    for(int i = 1 ; i <= m ; i++ ){
        int l , r , x ;
        scanf("%lld%lld%lld" , &l , &r , &x ) ;
        V[r].push_back( (node){ l , x } ) ;
    }
    f[1][0][0] = 1 ;
    //printf("ok\n") ;
    for(int i = 1 ; i <= n ; i++ ){
        for(int o = 0 ; o < V[i].size() ; o++ ){
            int l = V[i][o].l , x = V[i][o].x ;
            for(int k = 0 ; k < i ; k++ ){
                for(int p = 0 ; p <= max( 0ll , k - 1 ) ; p++ ){
                    //printf("%lld %lld %lld\n" , i , k , p ) ;
                    if( x == 1 ){ if( l <= k ) f[i][k][p] = 0 ; }
                    else if( x == 2 ){ if( k < l || l <= p ) f[i][k][p] = 0 ; }
                    else{ if( p < l ) f[i][k][p] = 0 ; }
                }
            }
        }
        if( i == n ) break ;
        for(int j = 0 ; j < i ; j++ ){
            for(int p = 0 ; p <= max( 1ll * ( j - 1 ) , 0ll ) ; p++ ){
                Mul( f[i + 1][j][p] , f[i][j][p] ) ;
                Mul( f[i + 1][i][j] , f[i][j][p] ) ;
                Mul( f[i + 1][i][p] , f[i][j][p] ) ;
            }
        }
    }
    for(int i = 0 ; i < n ; i++ ){
        for(int j = 0 ; j <= max( 1ll * ( i - 1 ) , 0ll ) ; j++ ){
            Mul( ans , f[n][i][j] ) ;
        }
    }
    ans = 1ll * ans * 3ll % Mod ;
    printf("%lld\n" , ans % Mod ) ;
    return 0 ;
}

Measured memory_bytes: 240000
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    int h,n;
    int a;
    cin >> h >> n;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        a+=temp;
    }
    if(h <= a)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def isAC (I):
  result = False
  tmp = 0
  for i in range(f_num):
    tmp += I[i] * B[i]
  tmp += C
  if tmp > 0:
    result = True
  return result

a = list(map(int, input().split()))

s_num = a[0]
f_num = a[1]
C = a[2]

a = list(map(int, input().split()))
B = []
for i in a:
  B.append(i)

A = []
for i in range(s_num):
  a = list(map(int, input().split()))
  A.append(a)

ans = 0
for I in A:
  if isAC(I):
    ans += 1

print(ans)



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

int main() {
    int N;
    cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
      vec.at(i) = d;
  }
  sort(vec.begin(), vec.end());
  
  int c = 1;
  
    for (int i = 0; i < N-1; i++) {
      if(vec.at(i) < vec.at(i+1)){
        c++;
      }
    }
  cout << c << endl;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,a,b=[parseInt(readline()) for i in 1:3]
    println(x-a-div(x-a,b)*b)
end
main()

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

using namespace std;

int main(){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	h2 = (h2 * 60) + m2;
	h1 = (h1 * 60) + m1;
	h2 -= h1;
	cout << h2 - k << "\n";
	return 0;
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll n,m; cin >> n >> m;
    VVL G(n+1);

    rep(i,m){
        ll a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<ll> q;
    VL roadsign(n+1, -1);
    q.push(1); roadsign[1] = 0;

    while(!q.empty()){
        ll v = q.front();
        q.pop();

        for(auto w : G[v]){
            if(roadsign[w] != -1) continue;
            roadsign[w] = v;
            q.push(w);
        }
    }

    cout << "Yes" << endl;
    rep2(i,2,n+1){
        cout << roadsign[i] << endl; 
    }

    return 0;
}

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

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

    vector<int> cnt_L(n, 0), cnt_R(n, 0), sum_LR(n, 0);
    for (int i = 1; i < n; i++)
    {
        if (s.at(i - 1) == 'W')
        {
            cnt_L.at(i) = cnt_L.at(i - 1) + 1;
        }
        else
        {
            cnt_L.at(i) = cnt_L.at(i - 1);
        }
    }

    for (int i = n - 2; i >= 0; i--)
    {
        if (s.at(i + 1) == 'E')
        {
            cnt_R.at(i) = cnt_R.at(i + 1) + 1;
        }
        else
        {
            cnt_R.at(i) = cnt_R.at(i + 1);
        }
    }

    for (int i = 0; i < n; i++)
    {
        sum_LR.at(i) = cnt_L.at(i) + cnt_R.at(i);
    }

    int answer = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        answer = min(answer, sum_LR.at(i));
    }

    cout << answer << endl;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int main()
{
    fastio;
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
ll MOD = 1000000007;
ll mod(long long val) {
    long long res = val % MOD;
    if (res < 0) res += MOD;
    return res;
}
ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}
const int MAX = 3000005;
ll fac[MAX], finv[MAX], inv[MAX];
void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    com_init();
    int n = (x + y) / 3;
    int k = x - n;
    cout << com(n, k) << endl;
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mod 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;

ll val[100005];
vector<ll>V[100005];
ll vis[100005];

void dfs(ll u)
{
    vis[u]=1;
    if(V[u].size()==0)
    {
        val[u]=0;
        return;
    }
    for(ll i=0;i<V[u].size();i++)
    {
        ll v=V[u][i];
        if(vis[v]==0)
        {
            dfs(v);

        }
        val[u]=max(val[u],val[v]+1);
    }
    return;
}
int main()
{
    ll n,m;
    sc2(n,m);
    for(ll i=1;i<=m;i++)
    {
        ll a,b;
        sc2(a,b);
        V[a].pb(b);
    }
    ll ans=0;
    memset(vis,0,sizeof vis);
    for(ll i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
    }
    for(ll i=1;i<=n;i++)
    {
        ans=max(ans,val[i]);
        //cout<<val[i]<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9344
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[5010][5010],s[5010];
int b[5010][210],l[5010],r[5010],st[5010],tp;
int main(){
	int n,m,i,j;
	ll ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<n;i++){
		scanf("%d",&j);
		s[i+1]=s[i]+j;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)scanf("%d",b[i]+j);
	}
	for(j=1;j<=m;j++){
		tp=0;
		st[0]=0;
		for(i=1;i<=n;i++){
			while(tp&&b[i][j]>b[st[tp]][j])tp--;
			st[++tp]=i;
			l[i]=st[tp-1]+1;
		}
		tp=0;
		st[0]=n+1;
		for(i=n;i>0;i--){
			while(tp&&b[i][j]>b[st[tp]][j])tp--;
			st[++tp]=i;
			r[i]=st[tp-1]-1;
		}
		for(i=1;i<=n;i++){
			a[l[i]][i]+=b[i][j];
			a[l[i]][r[i]+1]-=b[i][j];
			a[i+1][i]-=b[i][j];
			a[i+1][r[i]+1]+=b[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
	}
	ans=0;
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++)ans=max(ans,a[i][j]-(s[j]-s[i]));
	}
	printf("%lld",ans);
}

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

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< long long > a(N);
    vector< pair< long long, long long > > bc(M);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < M; ++i) {
        int b, c;
        cin >> b >> c;
        bc.push_back(make_pair(c, b));
    }
    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    int st = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < bc[i].second; ++j) {
            if (st >= N || a[st] >= bc[i].first) {
                break;
            }
            a[st] = bc[i].first;
            ++st;
        }
    }
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll R(){
	char ch;
	ll ans = 0,f=1;
	ch = getchar();
	while(ch>'9' || ch <'0'){if(ch=='-') f*=-1; ch = getchar();	}	
	while(ch>='0' && ch<='9'){
		ans = ans * 10 + ch - '0';
		ch = getchar();
	}
	return ans * f;
}
int main (){
	ll a,p;
	a = R()	; p = R();
	ll ans  = a*3+p;
	cout<<ans/2<<endl;
	return 0;
	
}

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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
 bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b){
      return a.second>b.second;
}

// vl a(1000000)      ;
vector<bool> mark(2000100,1);
void s(ll n){
  ll p,i;
  for(p=2;p*p<n;p++){
    if(mark[p]==true){
      for(i=2*p;i<n;i+=p){
        mark[i]=false;
      }
    }
  }
  ll sum=0;
  for(i=2;i<n;i++){
    if(mark[i]){
      // cout << i << " ";
      sum+=i;
    }
  }
  cout << sum;
}
vector<bool>visit(10,false);
 vector<ll>g[5];

 void bfs(ll s){
   queue<ll> q;
   q.push(s);
   visit[s]=true;
   ll f;
   while(!q.empty()){
      f=q.front();
     q.pop();
     cout << f << " ";
   
    for(auto& it: g[f]){
      // cout << it << "A";
      if(!visit[it]){
      q.push(it);
      visit[it]=true;
      }
    }
   }  
    // for(auto it=g[f].begin();it!=g[f].end();it++){
    //   cout << *it << "A"; 
       
     
   
}
 
int main(){
 ios_base::sync_with_stdio(0);
 ll n,m;
 cin >> n >> m;
 string s,t;
 cin >> s >> t;
 ll g=__gcd(m,n);
 ll ni=n/g,mi=m/g;
 for(ll k=0;k<g;k++){
   if(s[k*ni]==t[k*mi]){
     continue;
   }
   else{
     cout << "-1";
     return 0;
   }
 }
 cout << n*m/g;
 return 0;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int k=N.size() - 1;
  char l=N.at(k);
  if(l == '2' || l=='4' ||l =='5' || l=='7' || l=='9'){
    cout << "hon" << endl;
  }
  if(l == '0' || l=='1' ||l =='6' || l=='8'){
    cout << "pon" << endl;
  }
  if(l=='3'){
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 10000005

typedef long long ll;
int n;
int a[100000005];

using namespace std;

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

int main()
{   
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = gcd(a[i], a[i - 1]);
    }
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

ll gcd(ll x, ll y){
	if(y==0) return x;
	else return gcd(y, x%y);
}

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

	ll d = A[0]/2;
	for(int i=1; i<N; i++) d = gcd(d, A[i]/2);
	ll g = d;

	for(int i=0; i<N; i++){
		g *= A[i]/2/gcd(g, A[i]/2);
	}
	debug(d, g);

	for(int i=0; i<N; i++){
		if((g / (A[i]/2)) % 2 == 0){
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (M/g + 1)/2 << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    ll sum = 0, sum2 = 0;
    vector<int>a(n),b(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n){
        cin >> b[i];
        sum2 += b[i];
    }
    if(sum > sum2){
        cout << "No" << endl;
        return 0;
    }
    ll num = sum2-sum;
    ll k = 0;
    rep(i,n){
        if(a[i] < b[i]){
            k += (b[i]-a[i]+1)/2;
        }
    }
    if(num < k){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

#define ll long long

typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0)

int k, n, diff = 0, v[200001];

int main(){
	fast;
	
	cin>>k>>n;
	cin>>v[0];
	for(int i = 1; i<n; i++){
		cin>>v[i];
		diff = max(diff, v[i] - v[i-1]);
	}
	diff = max(diff, k - v[n-1] + v[0]);
	cout<<k - diff<<endl;

	return 0;
}


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

namespace ITP1_2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            //3つの整数を読み込み、値が小さい順に並べて出力する

            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //Console.ReadLine().Split()で読み込んだ文字列を
            //Select(int.Parse)でint型に変換し、
            //ToArray()で配列に格納する

            Array.Sort(x);      //Sort()メソッド：配列を昇順に並び替える
            Console.WriteLine(x[0] + " " + x[1] + " " + x[2]);

            Console.ReadKey();
        }
    }
}




Measured memory_bytes: 18404