akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  string ans = "AC";
  if(S[0] != 'A') ans = "WA";
  if(S[1] != tolower(S[1])) ans = "WA";
  if(S[S.size() - 1] != tolower(S[S.size() - 1])) ans = "WA";
  int cnt = 0;
  for(int i = 2; i < S.size() - 1; ++i) {
    if(S[i] == 'C') cnt++;
    if(cnt > 1) ans = "WA";
    if(i == S.size() - 2 && cnt == 0) ans = "WA";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import math
from itertools import combinations
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for x0,x1 in combinations(X, 2):
    if x0 == x1:
      continue
    if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
            counter+=1
print(counter)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  
  cout<<max(A+B,max(A-B,A*B))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    k=0;
    for(i=0; i<n; i++)
    {
        cin>>o;
        k+=o;
        v.PSB(k);
    }
    s=v[n-1];
    k=999999999999999999999999;
     for(i=0; i<n-1; i++)
    {
        l=s-v[i];
        k=min(k,abs(v[i]-l));
    }
    cout<<k<<endl;



    return 0;

}


Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t res = a * (n/(a+b));
    if(a<n%(a+b)){
        res+=a;
    }else{
        res+=n%(a+b);
    }
    cout << res << endl;
}


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

using namespace std;
int main(){
    int a,b,c;cin >> a >> b >> c;
    int g;g = 0;
    if(a==b&&a!=c){
        g = 1;
    }
    if(a==c&&a!=b){
        g = 1;
    }
    if(c==b&&a!=c){
        g = 1;
    }
    if(g==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


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

const int INF = 1000000000;

void WarshallFloyd(int d[10][10],int x){
	for(int k=0;k<x;k++){
		for(int i=0;i<x;i++){
			for(int j=0;j<x;j++){
				if(d[i][j]>d[i][k]+d[k][j]){
					d[i][j]=d[i][k]+d[k][j];
				}
			}
		}
	}
	return;
}

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;
		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		int A=INF,c;
		WarshallFloyd(T,10);
		for(int i=0;i<m;i++){
			int B=0;
			for(int j=0;j<m;j++){
				if(T[i][j]!=INF) B+=T[i][j];
			}
			if(A>B&&B!=0){
				A=B;
				c=i;
			}
		}
		
		cout<<c<<' '<<A<<endl;

	}

	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>

int main(void)
{
	char s[10];
	int cnt = 0;
	
	scanf("%s",s);
	if(s[0] == '1')cnt++;
	if(s[1] == '1')cnt++;
	if(s[2] == '1')cnt++;
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

class Combination_Mod{
    public:
        Combination_Mod(long long MAX, long long MOD) : fact(MAX + 1), inv(MAX + 1), finv(MAX + 1), MAX(MAX + 1), MOD(MOD){
            init();
        }

        void init(){
            fact[0] = fact[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for(long long i = 2; i < MAX; ++i){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] *  (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long bin(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

        long long perm(long long n, long long r){
            return (bin(n, r) * fact[r]) % MOD;
        }

        long long factorial(long long n){
            return fact[n];
        }

        long long modinv(long long n){
            return inv[n];
        }

        long long modfinv(long long n){
            return finv[n];
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long MAX;
        const long long MOD;
};

ll N, K;
Combination_Mod c(400010, MOD);

signed main(){
    cin >> N >> K;
    ll ans = 0;
    REP(k, min(N + 1, K + 1)){
        ans = (ans + c.bin(N, k) * c.bin(N - 1, k) % MOD) % MOD;
    }
    PRINT(ans % MOD);
    return 0;
}

Measured memory_bytes: 12492
while true
  h, m, s = gets.chomp.split(" ").map{|s| s.to_i}
  break if h == -1 && m == -1 && s == -1

  ts = (h * 60 + m) * 60 + s
  rs = 120 * 60 - ts
  rs3 = rs * 3

  printf("%02d:%02d:%02d\n", rs / 3600, (rs / 60) % 60, rs % 60)
  printf("%02d:%02d:%02d\n", rs3 / 3600, (rs3 / 60) % 60, rs3 % 60)
end

Measured memory_bytes: 6116
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main(){
    double x1, y1, x2, y2, distance;
    cin >> x1 >> y1 >> x2 >> y2;
    distance=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    cout << fixed << setprecision(6);
    cout << distance << endl;

    return 0;  
}


Measured memory_bytes: 3264
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

H,W,K = inputIL()

if W == 1:
  print(1)
  exit()

possible = []
for i in range(1<<(W-1)):
  b = bin(i)[2:]
  flag = 1
  for j in range(len(b)-1):
    if b[j] == b[j+1] == "1":
      flag = 0
  if flag:
    possible.append(int(b,2))

def amida(b):
  ret = [i for i in range(W)]
  for i in range(W-1):
    if b>>i & 1:
      ret[i],ret[i+1] = ret[i+1],ret[i]
  return ret

ans = [0 for i in range(W)]
ans[0] = 1


for _ in range(H):
  new_ans = [0 for i in range(W)]
  for b in possible:
    for i in range(W):
      new_ans[i] = (new_ans[i] + ans[amida(b)[i]])%MOD
  ans = new_ans
  
print(ans[K-1])

Measured memory_bytes: 73904
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		sc.close();
		System.out.printf("%.6f\n", r * r * Math.PI);
		System.out.printf("%.6f\n", r * 2  * Math.PI);
	}
}

Measured memory_bytes: 28324
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;

 
int main(){
    ofstream out("output.txt");

    string cad;
    cin>>cad;
    int cont = 0;
    for(int i = 0; i<cad.size()-1; i++){
        if(cad[i] == cad[i+1]) cont++;
    }
    if(cont>0) cout<<"Bad\n";
    else        cout<<"Good\n";

    return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 69 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 23:06:50
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    int sizes = s.size();
    cout << s[0] << sizes - 2 << s[sizes - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
rectangles = 0
lozenges = 0

$<.each_line do |line|
	a, b, d = line.split(',').map(&:to_i)
	rectangles += 1 if a ** 2 + b ** 2 == d ** 2
	lozenges += 1 if a == b
end

p rectangles
p lozenges

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = c / __gcd(c, d) * d;
    ll ans = b - a + 1;
    ans -= (b / c - (a + c - 1) / c + 1);
    ans -= (b / d - (a + d - 1) / d + 1);
    ans += (b / e - (a + e - 1) / e + 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];

    vector<ll> dp(W+1);
    for(int i=0; i<N; i++){
        for(int j=W; j>=0; j--){
            if(j-w[i]>=0) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }

    cout << dp[W] << endl;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  bool can=false;
  if(abs(A-C)<=D || (abs(A-B)<=D && abs(B-C)<=D )) can=true;
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    h, w = list(map(int, readline().split()))
    a = [[True] * w for _ in range(h)]
    ql = []
    ql = collections.deque(ql)
    for i in range(h):
        s = str(readline().rstrip().decode('utf-8'))
        for j in range(w):
            if s[j] == "#":
                a[i][j] = False
                ql.append([0, i, j])

    mt = 0
    while True:
        if len(ql) != 0:
            cost, x, y = ql.popleft()
            mt = max(mt, cost)
            for xv, yv in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]:
                if 0 <= xv < h and 0 <= yv < w:
                    if a[xv][yv]:
                        ql.append([cost + 1, xv, yv])
                        a[xv][yv] = False
        else:
            break
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 144604
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	VL arr(n);
	fr(i,0,n)
		rl(arr[i]);
	ll ct=0,nb=1;
	fr(i,0,n)
	{
		if(arr[i]==nb)
		{
			nb++;
			ct++;
		}
	}
	ll ans=n-ct;
	if(ct==0)
		ans=-1;
	wl(ans);
	NL;

	return 0;
}

Measured memory_bytes: 1792
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

static size_t A[100000];

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t K;

	scanf("%zu", &K);

	printf("%zu\n", (K/2)*((K+1)/2));

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#define R register
#define LL long long
#define max(_i_,_j_) ((_i_)>(_j_)?(_i_):(_j_))
#define min(_i_,_j_) ((_i_)<(_j_)?(_i_):(_j_))
char Is[1<<22],*Ss=Is;
inline int read()
{
	R char ch;
	while((ch=*Ss++)<48||ch>57);R int in=ch^48;
	while((ch=*Ss++)>47&&ch<58)in=(in<<1)+(in<<3)+(ch^48);
	return in;
}
inline LL readll()
{
	R char ch;
	while((ch=*Ss++)<48||ch>57);R LL in=ch^48;
	while((ch=*Ss++)>47&&ch<58)in=(in<<1)+(in<<3)+(ch^48);
	return in;
}
inline char gettype()
{
	R char ch;
	while((ch=*Ss++)!='U'&&ch!='D'&&ch!='L'&&ch!='R');
	return ch;
}
int n,m;
struct point
{
	int x,y;
	LL v;
}p[111];
int lm[111],rm[111],um[111],dm[111];
int first[333],next[66666],to[66666],f[66666],deg[333];
LL w[66666];
int S,T,ecnt;
LL fee;
int gu;
inline void connect(int u,int v,int mnf,int mxf,LL cost)
{
	deg[u]+=mnf,deg[v]-=mnf;
	++ecnt,
	next[ecnt<<1]=first[u],first[u]=ecnt<<1,to[ecnt<<1]=v,f[ecnt<<1]=mxf-mnf,w[ecnt<<1]=cost,
	next[ecnt<<1|1]=first[v],first[v]=ecnt<<1|1,to[ecnt<<1|1]=u,f[ecnt<<1|1]=0,w[ecnt<<1|1]=-cost;
}
int que[65540];
unsigned head,tail;
LL dis[333],ans;
bool vis[333];
bool SPFA()
{
	head=tail=0;
	memset(dis,63,(T+1)<<3);
	que[++tail]=S;
	dis[S]=0;
	for(R int now;head!=tail;)
	{
		now=que[++head];
		vis[now]=0;
		for(R int i=first[now];i;i=next[i])
			if(f[i]&&dis[to[i]]>dis[now]+w[i])
				dis[to[i]]=dis[now]+w[i],
				!vis[to[i]]?que[++tail]=to[i],vis[to[i]]=1:0;
	}
	return dis[T]<(1ll<<60ll);
}
int cur[333];
int DFS(int now,int flow)
{
	if(now==T)return flow;
	vis[now]=1;
	int re=0;
	for(R int &i=cur[now];i;i=next[i])
		if(f[i]&&!vis[to[i]]&&dis[to[i]]==dis[now]+w[i])
		{
			int tmp=DFS(to[i],min(flow-re,f[i]));
			re+=tmp,
			f[i]-=tmp,
			f[i^1]+=tmp,
			fee+=w[i]*tmp;
			if(re==flow)
			{
				vis[now]=0;
				return re;
			}
		}
	if(!re)dis[now]=(1ll<<60ll);
	vis[now]=0;
	return re;
}
int Dinic()
{
	int maxflow=0;
	while(SPFA())
		memcpy(cur,first,T<<2),
		maxflow+=DFS(S,233);
	return maxflow;
}
int main()
{
	fread(Is,1,1<<22,stdin);
	n=read();
	for(R int i=1;i<=n;++i)
		p[i].x=read(),p[i].y=read(),p[i].v=readll();
	for(R int i=0;i<=101;++i)
		lm[i]=rm[i]=um[i]=dm[i]=n;
	m=read();
	for(R int i=1;i<=m;++i)
	{
		R char type=gettype();
		R int a=read(),b=read();
		if(type=='U')um[a]=b;
		else if(type=='D')dm[a]=b;
		else if(type=='L')lm[a]=b;
		else if(type=='R')rm[a]=b;
	}
	for(R int tot=1;tot<=n;++tot)
	{
		memset(first,0,233<<2),
		memset(deg,0,233<<2),
		ecnt=0,gu=0;
		for(R int i=1;i<=101;++i)
		{
			if(tot-lm[i-1]>rm[i])break;
			connect(i-1,i,tot-lm[i-1],rm[i],0);
		}
		for(R int i=1;i<=101;++i)
		{
			if(tot-um[i]>dm[i-1])break;
			connect(101+i,101+i+1,tot-um[i],dm[i-1],0);
		}
		for(R int i=1;i<=n;++i)
			connect(p[i].x,101+p[i].y+1,0,1,-p[i].v);
		deg[0]-=tot,deg[203]+=tot;
		S=204,T=205;
		fee=0;
		for(R int i=0;i<=203;++i)
		{
			if(deg[i]>0)
				connect(i,T,0,deg[i],0),
				gu+=deg[i];
			else if(deg[i]<0)
				connect(S,i,0,-deg[i],0);
		}
		if(Dinic()!=gu)break;
		-fee>ans?ans=-fee:0;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main()
{
	int n = in();
	cout << (n < 105 ? 0 : n < 135 ? 1 : n < 165 ? 2 : n < 189 ? 3: n < 195 ? 4 : 5) << endl;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int visited[5001][5001];
int memo[5001][5001];
string s;
int calc(int i, int j){ 
    if(visited[i][j]){ return memo[i][j]; }
    visited[i][j] = true;
    if(s[i] != s[j]){
        return 0;
    }
    int ret = 1;
    if(i + 1 < j && j + 1 < (int)s.size()){
        ret += calc(i + 1, j + 1);
    }
    return memo[i][j] = ret;
}
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans = max(ans, min(j - i, calc(i, j)));
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 195200
#include <iostream>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)


int main(){
	int n;
	cin>>n;
	vector<int> v(2*n);
	rep(i,2*n){
		v[i]=i+1;
	}
	int m;
	cin>>m;
	rep(i,m){
		int k;
		cin>>k;
		if(k==0){
			vector<int> t=v;
			rep(j,n){
				v[j*2]=t[j];
				v[j*2+1]=t[j+n];
			}
		}
		else{
			vector<int> t=v;
			rep(j,k){
				v[2*n-k+j]=t[j];
			}
			rep(j,2*n-k){
				v[j]=t[j+k];
			}
		}
	}
	rep(i,2*n){
		cout<<v[i]<<endl;
	}
	return 0;
}

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

int main(void){
  int N;
  cin >> N;
  
  vector<int> a(201); //変数を最大２００個入れるための箱
  
  //配列変数への入力
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int count = 0; //２で割れる操作の回数を記録する変数
  
  while (1) {
   bool odd = false; //residueがoddとなる場合を検出するためのフラグ
    
    //N個の整数の中に奇数が存在するかどうかを判定する操作
    for (int i = 0; i < N; i++) {
      if (a.at(i) % 2 == 1){
        odd = true;
      }
    }
    
    if (odd) break; //２で割り切れないものが存在するならループを終わらせる
    
    for (int i = 0; i < N; i++){
      a.at(i) /= 2;
    }
    
    count++; //２で割り切れる操作１回実施を記録していく
  }
  
  cout << count << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int mod  = 100003;
const int maxn = 1e5+10;

int a[maxn];
int dp[maxn];
int f(int a)
{
	if (a<0)
		a=-a;
	return a;
}
int k;
int solve(int n)
{
	if (dp[n]!=-1)
		return dp[n];
	int ans=1e9;
	for (int i=1;n-i>=1&&i<=k;i++)
	{
		int tem=solve(n-i)+f(a[n]-a[n-i]);
		ans=min(tem,ans);
	}
	dp[n]=ans;
	return dp[n];
}
int main()
{
	int n;
	cin>>n>>k;
	for (int i=0;i<=n;i++)
		dp[i]=-1;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	dp[1]=0;
	dp[2]=f(a[1]-a[2]);
	cout<<solve(n);
	return 0;
}


Measured memory_bytes: 9044
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示

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

	int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  var ans=0;
  for(var i=1; i<=n; i++){
    if(i%2==1){
      var temp=0
      for(var j=1; j<=i; j++){
        if(i%j==0){
          temp++
        }
      }
      if(temp==8){
        ans++
      }
    }
  }
  console.log(ans);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 9420
until (n = gets.to_i) == 0
  sum = 0
  n.times do
    x, y, h, w = gets.split.map(&:to_i)
    s = x + y + h
    if s <= 60 and w <= 2
      sum += 600
    elsif s <= 80 and w <= 5
      sum += 800
    elsif s <= 100 and w <= 10
      sum += 1000
    elsif s <= 120 and w <= 15
      sum += 1200
    elsif s <= 140 and w <= 20
      sum += 1400
    elsif s <= 160 and w <= 25
      sum += 1600
    end
  end
  puts sum
end

Measured memory_bytes: 9104
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 2e5 + 5;

namespace ancient {
  bool seq [MAX_N];
 
  int smooth_subseq (int a, int b) {
    bool cmade = false;
    // cout << a << " " << b << ";\n";
    if (a == b) return 0;
    if (seq[a] == seq[b]) {
      for (int i = a; i <= b; i++) {
        if (seq[i] != seq[a]) {
          seq[i] = seq[a];
          cmade = true;
        }
      }
    } else {
      for (int i = a; i <= ((a+b-1)/2); i++) {
        if (seq[i] != seq[a]) {
          seq[i] = seq[a];
          cmade = true;
        }
      }
      for (int i = ((a+b+1)/2); i <= b; i++) {
        if (seq[i] != seq[b]) {
          seq[i] = seq[b];
        }
      }
    }
    return (cmade ? (b-a)/2 : 0);
  }
 
  int check (vector<int> bits) {
    int length, maxt = 0, cstart = 0, cend, ct;
    bool inseq = true;
 
    length = bits.size();
    seq[0] = bits[0];
    for (int i = 1; i < length-1; i++) {
      seq[i] = bits[i];
      if (seq[i] == seq[i-1]) {
        if (inseq) {
          cend = i-1;
          ct = smooth_subseq(cstart, cend);
          if (maxt < ct) maxt = ct;
          inseq = false;
        }
      } else {
        if (!inseq) {
          cstart = i-1;
          inseq = true;
        }
      }
    }
    seq[length-1] = bits[length - 1];
    if (inseq) {
      cend = length-1;
      ct = smooth_subseq(cstart, cend);
      if (maxt < ct) maxt = ct;
      inseq = false;
    }

    return seq[length / 2];
  }
}

int arr [MAX_N];

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

  int n;
  cin >> n;

  n = 2 * n - 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  int ans = 0;
  for (int k = 1 << 20; k != 0; k /= 2) {
    vector<int> test;
    for (int i = 0; i < n; i++) {
      test.push_back(arr[i] >= ans + k);
    }

    if (ancient::check(test)) {
      ans += k;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6092
using System;
namespace Sample{
class Sample
  {
    static void Main(string[] args)
    {
    int N =int.Parse(Console.ReadLine());
      long output=0;
      for(int i=1;i<=N;i++){
    if((i%3!=0)&& (i%5!=0)){
      output =output+i;
    }
 
    }
      Console.WriteLine(output);
    
  }
 
}
}


Measured memory_bytes: 27536
import std.stdio;
import std.string;
import std.conv;

void main()
{
    int N = readln.chomp.to!(int);
    int[][2] arr;
    for (int i = 0; i < 2; i++) {
        arr[i] = readln.chomp.split.to!(int[]);
    }

    int ans;
    for (int i = 0; i < N; i++) {
        int sum;
        for (int j = 0; j <= i; j++) {
            sum += arr[0][j];
        }
        for (int j = i; j < N; j++) {
            sum += arr[1][j];
        }
        ans = ans > sum ? ans : sum;
    }

    ans.writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
typedef long long ll;
typedef long double ld;
#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;



int main(){
    string S;
    cin >>S;
    int ans=0;
    if(S.size()%2==0){
        for(int i=0;i<(S.size())/2;++i){
            if(S[i]!=S[(S.size())-1-i]){
                ans++;
            }
        }
    }
    else{
        for(int i=0;i<S.size()/2;++i){
            if(S[i]!=S[(S.size())-1-i]){
                ans++;
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[200004], f[200004];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < n; i++) cin >> f[i];
    if(sum <= k){
        cout << 0 << endl;
        return 0;
    }
    sort(a, a + n);
    sort(f, f + n, greater<ll>());
    ll now = 1;
    for(int i = 0; i < 50; i++) now *= 2;
    ll mid = now / 2;
    while(mid > 0){
        ll l = k;
        for(int i = 0; i < n; i++){
            l -= max((ll)0, a[i] - now / f[i]);
        }
        if(l >= 0) now -= mid;
        else now += mid;
        mid /= 2;
    }
    ll l = k;
    for(int i = 0; i < n; i++){
        l -= max((ll)0, a[i] - now / f[i]);
    }
    if(l < 0) now++;
    cout << now << endl;
}

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

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long m = a*c;
    m = max(m, a*d);
    m = max(m, b*c);
    m = max(m, b*d);
    cout << m << endl;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        string[] inputs = Console.ReadLine().Split();
        int k = int.Parse(inputs[1]);
        int[] a = Console.ReadLine().Split()
            .Select(int.Parse)
            .OrderBy(x => x)
            .Distinct()
            .ToArray();
        sbyte[] winner = new sbyte[k + 1];
        foreach(var i in Enumerable.Range(0, a.Min()))
            winner[i] = -1;
        foreach(var i in Enumerable.Range(0, k))
        {
            foreach(var pull in a.TakeWhile(x => x + i <= k))
            {
                if(winner[i + pull] == 0)
                    winner[i + pull] = (sbyte)-winner[i];
                else
                    winner[i + pull] = (sbyte)Math.Max(winner[i + pull], -winner[i]);
            }
        }
        //Console.WriteLine(string.Join(",", winner));
        Console.WriteLine(winner[k] == 1 ? "First" : "Second");
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 17632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int x; cin >> x;
    vector<bool> exp(x+1, false);
    
    exp[1] = true;
    for(int i = 2; i < x; i++){
        int j = i*i;
        while(j <= x){
            exp[j] = true;
            j *= i;
        }
    }
    for(int i = x; i > 0; i--){
        if(exp[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

using ll=long long int;


int main() {

	int n, x;
	cin >> n >> x;

	int l[101];

	int cnt = 1;
	int sum = 0;

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

		if (sum <= x) {
			cnt++;
		}

		

	}

	cout << cnt << endl;


	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


int main(){
    int n,x;
    cin >> n >>x;
    int A[105];
    REP(i,n) cin >> A[i];
    sort(A,A+n);
    int tmp=0,ans=0;
    int i=0;
    while(1){
        tmp += A[i];
        if(tmp>x) break;
        if(tmp==x){
            ans+=1;
            break;
        }
        i+=1;
        if(i >=n) break;
        ans+=1;
    }
    cout << ans  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t mod = 1'000'000'007;
template <uint32_t mod>
class modint{
    uint64_t value;
public:
    constexpr modint(const int64_t x=0) noexcept: value(x % mod + (x < 0 ? mod : 0)){ }
    constexpr explicit operator uint64_t() const noexcept{ return value; }
    constexpr modint inverse() const noexcept{ return pow(*this, mod-2); }
    constexpr bool operator==(const modint &rhs) const noexcept{ return value == rhs.value; }
    constexpr bool operator!=(const modint &rhs) const noexcept{ return value != rhs.value; }
    constexpr modint operator+() const noexcept{ return modint(*this); }
    constexpr modint operator-() const noexcept{ return modint(mod - value); }
    constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) noexcept{
        if((value += rhs.value) >= mod) value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{ return *this += mod - rhs.value; }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        if((value *= rhs.value) >= mod) value %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{ return *this *= rhs.inverse(); }
    constexpr modint operator++(int) noexcept{
        modint ret(*this);
        if((++value) >= mod) value -= mod;
        return ret;
    }
    constexpr modint operator--(int) noexcept{
        modint ret(*this);
        if((value += mod - 1) >= mod) value -= mod;
        return ret;
    }
    constexpr modint &operator++() noexcept{ return *this += 1; }
    constexpr modint &operator--() noexcept{ return *this -= 1; }
    friend std::ostream &operator<<(std::ostream &os, const modint<mod> &x){ return os << x.value; }
    friend std::istream &operator>>(std::istream &is, modint<mod> &x){
        int64_t i;
        is >> i;
        x = modint<mod>(i);
        return is;
    }
    friend constexpr modint<mod> pow(const modint<mod> &x, uint64_t y){
        modint<mod> ret{1}, m{x};
        while(y > 0){
            if(y & 1) ret *= m;
            m *= m;
            y >>= 1;
        }
        return ret;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    static int64_t x[100000], y[100000];
    for(int i=0;i<n;++i) cin >> x[i];
    for(int i=0;i<m;++i) cin >> y[i];
    
    modint<mod> xx = 0, yy = 0;
    for(int i=0;i<n;++i) xx += x[i] * (2*i+1-n);
    for(int i=0;i<m;++i) yy += y[i] * (2*i+1-m);
    cout << xx*yy << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := nextInt(), nextInt()
	dp := make([]int, N)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = nextInt()
	}
	if N <= K {
		fmt.Println(abs(h[0] - h[N-1]))
		return
	}
	for i := 1; i <= K; i++ {
		dp[i] = abs(h[0] - h[i])
	}

	for i := K + 1; i < N; i++ {
		min := 2147483647
		for j := 1; j <= K; j++ {
			if min > dp[i-j]+abs(h[i]-h[i-j]) {
				min = dp[i-j] + abs(h[i]-h[i-j])
			}
		}
		dp[i] = min
	}
	fmt.Println(dp[N-1])
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/*N個の宝石があり、
i番目の宝石の価値は 
Vi
 です。

あなたはこれらの宝石の中からいくつかを選んで手に入れます。
このとき、
1つも選ばなくとも、全て選んでも構いません。

ただし、
i番目の宝石を手に入れる場合コスト 
Ci
 を支払わなければいけません。

手に入れた宝石の価値の合計を 
X
、支払ったコストの合計を 
Y
 とします。

X
−
Y
 の最大値を求めてください。*/
int main(){
	int N,xy;
	cin >> N;
	vector<int> v(N),c(N);
	xy = 0;
	for(int i=0;i<N;i++){
		cin >> v.at(i);
		
	}
	for(int i=0;i<N;i++){
		cin >> c.at(i);
		
	}
	for(int i=0;i<N;i++){
		if(v.at(i)>=c.at(i)) 
		xy += v.at(i)-c.at(i);
		
	}

	cout <<xy << endl;

}

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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  int arr[H+2][W+2];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      arr[i][j]=0;
    }
  }
  for(int i=0;i<H;i++)
  {
    string s;
    cin >> s;
    for(int j=0;j<W;j++)
    {
      if(s.at(j)=='#'){
        arr[i][j] -= 9;
        arr[i][j+1] ++;
        arr[i][j-1] ++;
        arr[i+1][j+1] ++;
        arr[i+1][j] ++;
        arr[i+1][j-1] ++;
        arr[i-1][j+1] ++;
        arr[i-1][j] ++;
        arr[i-1][j-1] ++;
      }
    }
    cout << endl;
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(arr[i][j]<0){
        cout << "#";
      }
      else{
        cout << arr[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t ;
  int a=s.size();
  int b=t.size();
  int x=0;
  for (int i=0; i<a-b+1 ; i++)
  {
    int y=0;
    for (int j=0; j<b ; j++)
    {
    if(t[j]==s[i+j])
     {
      y++;
     }
    }
    x=max(x,y);
    
  }
  cout << b-x <<endl;
}


Measured memory_bytes: 3620
subabs = lambda x, y: [abs(i - j) for i, j in zip(x, y)]
minkowski = lambda arr, p: sum(a ** p for a in arr) ** (1 / p)

_ = input()
x = map(float, input().split())
y = map(float, input().split())
subs = subabs(x, y)

print("{:.8f}".format(minkowski(subs, 1)))
print("{:.8f}".format(minkowski(subs, 2)))
print("{:.8f}".format(minkowski(subs, 3)))
print("{:.8f}".format(max(subs)))


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

using namespace std;

char s[10];

void solve()
{
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}

int main()
{
    for(int i = 0; i < 6; i++) cin >> s[i];
    solve();


    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> r(n);
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        a--;

        r[a]++;
    }

    for (int i = 0; i < n; i++) {
        cout << r[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<vector>
#include<string>
#include<list>
#include<algorithm>

using namespace std;

int main() {
	long a, b;
	long N, M;
	vector<long>  money;
	long sum = 0;
	double ans = 0.0;

	cin >> N ;

	if (N % 2 == 0) {
		ans = (double)(N / 2) / (N);
	}
	else {
		ans = (double)((N / 2) +1 ) / (N);
	}

	

	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

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

  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0){

      }else{
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;

  return 0;
}




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

int n;

int main() 
{
	ios_base::sync_with_stdio(false);
	//freopen(".inp","r",stdin);
	cin>>n;
	double x,sum=0;
	while(n--)
	{
		cin>>x;
		sum+=1.0/x;
	}
	cout<<setprecision(6)<<fixed<<1.0/sum;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N>>M;
	long long int num[51] = {};
	for (int i = 1; i <= N; i++) {
		cin >> num[i];
		num[i] %= 2;
	}
	long long int dp[51][2] = {};
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		dp[i][0] = dp[i - 1][0];
		dp[i][0] += dp[i - 1][num[i] ^ 0];
		dp[i][1] = dp[i - 1][1];
		dp[i][1] += dp[i - 1][num[i] ^ 1];
	}
	cout << dp[N][M] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()) mp[s.at(i)]++;
  int mx = min({mp['a'], mp['b'], mp['c']});
  mp['a'] -= mx;
  mp['b'] -= mx;
  mp['c'] -= mx;
  bool ans = false;
  for(auto p : mp){
    if(p.second > 1) ans = true;
  }
  if(ans == false) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3756
N, Y = gets.split(' ').map(&:to_i)

count = [-1, -1, -1]
is_break = false

(0..N).each do |i|
  next if 10000*i + 5000*(N-i) < Y
  (0..(N-i)).each do |j|
    if 10000*i + 5000*j + 1000*(N-i-j) == Y
      count = [i, j, N-i-j]
      is_break = true
    end
    break if is_break
  end
  break if is_break
end

ans = count[0].to_s + ' ' + count[1].to_s + ' ' + count[2].to_s
print ans


Measured memory_bytes: 1788
def ope(i, ans, ans_str):
    if i == 3:
        if ans == 7:
            return ans_str+"=7"
        else:
            return None
    else:
        result = ope(i+1, ans+int(S[i+1]), ans_str + "+" + S[i+1])
        if result:
            return result
        result = ope(i+1, ans-int(S[i+1]), ans_str + "-" + S[i+1])
        if result:
            return result
S = list(input())
result = ope(0, int(S[0]), S[0])
print(result)


Measured memory_bytes: 3060
s=input()
if s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)
else:
  print(7)

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

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

    long long int ans = 0, a = 0, b = 0, c = 0;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
        for(int j=0; j+1<s[i].length(); j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans += 1;
        }

        if(s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') c += 1;
        else if(s[i][0] == 'B') b += 1;
        else if(s[i][s[i].length()-1] == 'A') a += 1;
    }
    
    if(c == 0) ans += min(a,b);
    else{
        if(a == 0 && b == 0) ans += c - 1;
        else ans += min(a,b) + c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692