akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x, y;
    
    scanf("%d%d", &x, &y);
    
    printf("%d", x+y/2);
    
    return 0;
}



Measured memory_bytes: 1704
<?php

$inputs = explode(" ", trim(fgets(STDIN)));
list($r, $c) = [(int)$inputs[0], (int)$inputs[1]];

$last_line = array_fill(0, $c + 1, 0);

for ($i = 0; $i < $r; $i++) {
    $line = trim(fgets(STDIN));
    $items = explode(" ", $line);
    $items[] = array_sum($items);

    foreach ($items as $key => $item) {
        $last_line[$key] += (int)$item;
    }
    echo implode(" ", $items) . "\n";
}
echo implode(" ", $last_line) . "\n";


Measured memory_bytes: 9328
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	int ans = 0;
	rep(i, k) ans += a[i];
	cout << ans << endl;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int a, b; cin >> a >> b;
  if (a < b){
    for (int i = 0; i < b; i++) cout << a;
  }
  else {
    for (int i = 0; i < a; i++) cout << b;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static long max(long dp[][], int i, int j,int n, int arr[]) {
		if(i==j) {
			dp[i][j] = arr[i];
			return dp[i][j];
		}
		if( dp[i][j]!=-1)
			return dp[i][j];
		dp[i][j]= Math.max(arr[i]-max( dp, i+1,j,n, arr), arr[j]- max(dp, i, j-1,n,arr));
		return dp[i][j];
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in= new Scanner(System.in);
		int n = in.nextInt();
		long dp[][] = new long[n][n];
		int [] arr = new int[n];
		for(int i=0; i<n; i++) {
			arr[i]= in.nextInt();
			Arrays.fill(dp[i], -1);
		}
		max(dp, 0,n-1, n, arr);
		System.out.println(dp[0][n-1]);
	}

}


Measured memory_bytes: 102852
def main():
    from sys import stdin
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    a, b, c = map(int, r.split())
    print(max(a*10+b+c, a+b*10+c, a+b+c*10))

if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
#include<stdio.h>

int main(){
	long long A,B,C,K;
	scanf("%lld%lld%lld%lld",&A,&B,&C,&K);
	if(K%2==0)printf("%lld\n",A-B);
	else printf("%lld\n",B-A);
	return 0;
}

Measured memory_bytes: 128
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     if(n==1){
        cout<<"Hello World"<<endl;
     }
     else{
        cin>>a>>b;
        cout<<a+b<<endl;
     }

     return EXIT_SUCCESS;
}





Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
int main()
{
    int n , cmmdc = 0, nr;
    scanf("%d" , &n);
    for(int i = 1;  i <= n ; i ++){
        scanf("%d" , &nr);
        cmmdc = std :: __gcd(cmmdc , nr);
    }
    printf("%d" , cmmdc);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll ans = INF;
vector<vector<P>> G;
vector<P> e;
V c;

void bfs(ll s) {
	queue<ll> q;

	q.push(s);

	ll now, to;
	while (!q.empty()) {
		now = q.front();
		q.pop();
		V color(G[now].size(), -1);
		ll to, idx;
		rep(i, G[now].size()) {
			to = G[now][i].first;
			idx = G[now][i].second;
			color[i] = c[idx];
		}
		ll cidx = 1;
		rep(i, G[now].size()) {
			to = G[now][i].first;
			idx = G[now][i].second;
			if (c[idx] == -1){
				while(1){
					auto itr = find(ALL(color), cidx);
					if (itr == color.end()){
						c[idx] = color[i] = cidx;
						q.push(to);
						break;
					}
					cidx++;
				}
			}
		}
	}
}

void solve_abc_d() {
    ll n;
    cin >> n;

	G = vector<vector<P>>(n + 1);
	e = vector<P>(n-1);
	c = V(n-1, -1);

	ll a, b;
	rep(i, n - 1) {
		cin >> a >> b;
		G[a].push_back(make_pair(b, i));
		G[b].push_back(make_pair(a, i));
		e[i] = make_pair(a, b);
	}

	bfs(1);

	ll k = 0;
	rep(i, n - 1) {
		k = max(k, c[i]);
	}
	cout << k << "\n";
	rep(i, n - 1){
		cout << c[i] << "\n";
	}
}

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

	solve_abc_d();

	return 0;
}


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

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

using namespace std;

int matrix_rank(vector<unsigned long long> A){
	int n=A.size(),r=0;
	rep(i,64){
		int piv=-1;
		for(int j=r;j<n;j++) if(A[j]>>i&1) {
			piv=j;
			break;
		}
		if(piv==-1) continue;

		for(int j=r;j<n;j++) if(j!=piv && A[j]>>i&1) {
			A[j]^=A[piv];
		}
		swap(A[r],A[piv]);
		r++;
	}
	return r;
}

void solve(){
	int n; cin>>n;
	vector<unsigned long long> a(n);
	rep(i,n) cin>>a[i];
	string s; cin>>s;

	vector<unsigned long long> A;
	int r=0;
	for(int i=n-1;i>=0;i--){
		A.emplace_back(a[i]);
		int r2=matrix_rank(A);
		if(r<r2 && s[i]=='1'){
			puts("1");
			return;
		}
		r=r2;
	}
	puts("0");
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}


Measured memory_bytes: 3700
import sys
import math

ALPHABET = ["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"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

print(alphabet_decimal(int(input())))

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

int main(){
	int L, N, M;
	cin >> N;
	M = 0;
	
	for(int i=N;i>0;i=i/10){
		M = M + i%10;
	}
	
	L = N%M;
	
	if(L==0)
		cout << "Yes" <<endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

vll dp;

lli fib(lli x){
    if(dp[x]) return dp[x];
    if(x == 0) return dp[x] = 1;
    if(x == 1) return dp[x] = 1;
    return dp[x] = fib(x-1) + fib(x-2);
}

lli n;

int main(){
    cin >> n;
    dp = vll(n+1);
    cout << fib(n) << endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<vector<pair<int, int>>> g;
int ans[100000];

void dfs(int now, int to, int from) {
    ans[to] = now;
    for(auto next : g[to]){
        if(next.fi == from) continue;
        if(next.se%2 == 1){
            dfs(1-now, next.fi, to);
        }else{
            dfs(now, next.fi, to);
        }
    }
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    g.resize(n);
    inc(i, 0, n-1){
        int a, b;cin >> a >> b;
        a--;b--;
        int w;cin >> w;
        g[a].pb({b, w});
        g[b].pb({a, w});
    }
    dfs(0, 0, -1);
    inc(i, 0, n){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main()
{
    int x, y;
    while( cin >> x >> y && ( x || y ) ){
        if( x > y ){
            int t = x;
            x = y;
            y = t;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}

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

using namespace std;
#define REPI(x) for(int i=0;i<x;i++)

bool paircomp (const pair<int,int> &a, const pair<int,int> &b)
{
  if (a.second != b.second)
    return a.second < b.second;
  
  return a.first < b.first;
}

int main ()
{
  vector<pair<int, int> > vp;
  pair<int,int> p;
  int N,a,b,t=0;

  cin >> N;

  REPI (N)
  {
    scanf("%d %d",&a,&b);
    vp.push_back (make_pair(a,b));
  }
  sort (vp.begin (), vp.end (), paircomp);

  REPI (N)
  {
    t += vp[i].first;
    if ( t > vp[i].second)
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0; 
}

Measured memory_bytes: 2420
from math import log2, ceil


class SegmentTree:
    def __init__(self, n):
        self.n = n
        tn = 2 ** ceil(log2(n))
        self.a = [2 ** 31 - 1] * (tn * 2)
        self.tn = tn

    def find(self, s, t):
        return self.__find(1, 0, self.tn - 1, s, t)

    def __find(self, c, l, r, s, t):
        if self.a[c] == -1:
            return self.a[c // 2]
        if s <= l and r <= t:
            return self.a[c]
        mid = (l + r) // 2
        if t <= mid:
            return self.__find(c * 2, l, mid, s, t)
        elif s > mid:
            return self.__find(c * 2 + 1, mid + 1, r, s, t)
        else:
            return min(
                self.__find(c * 2, l, mid, s, mid),
                self.__find(c * 2 + 1, mid + 1, r, mid + 1, t))

    def update(self, s, t, x):
        self.__update(1, 0, self.tn - 1, s, t, x)

    def __update(self, c, l, r, s, t, x, f=None):

        if f is None and self.a[c] == -1:
            f = self.a[c // 2]

        if l == s and r == t:
            return self.__set(c, x)

        mid = (l + r) // 2
        if t <= mid:
            rv, f = self.__get_child(c, c * 2 + 1, f)
            u = min(self.__update(c * 2, l, mid, s, t, x, f), rv)
        elif s > mid:
            lv, f = self.__get_child(c, c * 2, f)
            u = min(lv, self.__update(c * 2 + 1, mid + 1, r, s, t, x, f))
        else:
            u = min(
                self.__update(c * 2, l, mid, s, mid, x, f),
                self.__update(c * 2 + 1, mid + 1, r, mid + 1, t, x, f))
            if f is not None:
                u = min(f, u)
        self.a[c] = u

        return u

    def __set(self, c, x):
        self.a[c] = x
        if c < self.tn:
            self.a[c * 2] = self.a[c * 2 + 1] = -1
        return x

    def __get_child(self, c, child, f):
        if f is not None:
            return self.__set(child, f), f
        v = self.a[child]
        if v == -1:
            f = self.a[c]
            v = self.__set(child, f)
        return v, f


n, q = map(int, input().split())
st = SegmentTree(n)
buf = []
for _ in range(q):
    q_type, *query = map(int, input().split())
    if q_type == 0:
        st.update(*query)
    else:
        buf.append(st.find(*query))
        # print(_, query, st.a)
print('\n'.join(map(str, buf)))

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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<int>a(m);
  
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  
  int ansl=0;
  int ansr=0;
  
  for(int i=0;i<m;i++){
    if(a[i]>0 && a[i]<x){
      ansl++;
    }
    if(a[i]>x && a[i]<n){
      ansr++;
    }
  }
  cout<<min(ansl,ansr)<<endl;
  
}


Measured memory_bytes: 256
s=int(input())
A=[s]

# 繰り返してゆく
for n in range(2,1000001):
    if A[-1]%2==0: # 偶数のとき
        f=A[-1]//2
    else: # 奇数のとき
        f=3*A[-1]+1

    if f in A: # 重複したら出力して終了
        print(n)
        break

    A.append(f) # 追加

Measured memory_bytes: 3060
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    vector<ll> FR;
    
public:
    comb(ll mod=1000000007,ll mx=100000):mod(mod),mx(mx),F(mx+1,1),FR(mx+1,1){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        while(x>0){
            if(x&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
            x>>=1;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        for(ll i=1;i<=mx;i++){F[i]=F[i-1]*i%mod; FR[i]=R(F[i]);}
    }
    
    ll c(ll n,ll k){
        if(n<k || n<0 || k<0){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*FR[n-k]%mod*FR[k]%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};

comb C;



int main(){
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=k;i++){
        ll ans=C.c(k-i+(i-1),i-1);
        //cout<<ans<<endl;
        ans*=C.c(n-k-(i-1)+i,i);
        ans%=MOD;
        if(ans<0){ans+=MOD;}
        cout<<ans<<endl;
    }
    
    
    return 0;
}


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

using namespace std;
constexpr long long int mod = 1000000007;
int main() {
    long long u=100;
	long long t;
	cin >> t;
	for (size_t i = 0; ; i++)
	{
		if (u < t)u *= 1.01;
		else { cout << i; return 0; }
	}
}

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

//for "to" table
#define INF -1
#define LOOP -2

int n;
int t[100010];
int to[100010];
int dp[100010];

int dfs(int idx){
  if(to[idx] != INF){
    return to[idx];
  }
  if(to[idx] == LOOP){
    return LOOP;
  }
  to[idx] = LOOP;

  int next = idx + t[idx];
  return to[idx] = dfs(next);
}

int main(){
  while(cin>>n){
    for(int i = 0; i < n; i++){
      cin >> t[i];

      if(t[i] == 0){
        to[i] = i;
      }
      else{
        to[i] = INF;
      }

      dp[i] = INT_MAX;
    }

    for(int i = 0; i < n; i++){
      if(to[i] == INF){
        to[i] = dfs(i + t[i]);
      }
    }

    dp[0] = 0;

    for(int i = 0; i < 10; i++){
      for(int idx = 0; idx < n; idx++){
        if(dp[idx] == INT_MAX){
          continue;
        }

        for(int plus = 1; plus <= 6; plus++){
          if(idx + plus >= n){
            continue;
          }

          int next = to[idx + plus];

          if(next == LOOP){
            continue;
          }

          dp[next] = min(dp[next], dp[idx] + 1);
        }
      }
    }

    cout << dp[n - 1] << endl;
  }
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  vi c(n-1),s(n-1),f(n-1);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

  rep(i,n){//start
    int time = 0;
    FOR(j,i,n-1){
      if(time < s[j]) time = s[j];
      else if(time % f[j] == 0);
      else time = time + f[j] - (time%f[j]);
      time += c[j];
    }
    cout << time << endl;
  }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SimpleKnapsack solver = new SimpleKnapsack();
        solver.solve(1, in, out);
        out.close();
    }

    static class SimpleKnapsack {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long w = in.nextLong();

            long[] weights = new long[n];
            long[] values = new long[n];

            // i番目 | 選んだ個数 | weightの和
            long[][][] dp = new long[n + 1][n + 1][3 * n + 1];
            for (int i = 0; i < n; i++) {
                weights[i] = Long.parseLong(in.next());
                values[i] = Long.parseLong(in.next());
            }

            long sum = 0;
            for (int i = 0; i < n; i++) {
                int diff = (int) (weights[i] - weights[0]);
                for (int j = 0; j <= i; j++) {
                    for (int k = 0; k <= 3 * n; k++) {
                        dp[i + 1][j][k] = Math.max(dp[i + 1][j][k], dp[i][j][k]);
                        if (diff <= k) {
                            dp[i + 1][j + 1][k] = Math.max(dp[i][j + 1][k], dp[i][j][k - diff] + values[i]);
                        }
                    }
                }
                sum += diff;
            }
            long result = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= 3 * n; j++) {
                    if (i * weights[0] + j <= w) {
                        result = Math.max(result, dp[n][i][j]);
                    }
                }
            }

            out.println(result);

//        long[] weights = new long[n];
//        long[] values = new long[n];
//
//        //  選んだ個数 | weightの和
//        long[][] dp = new long[n + 1][3 * n + 1];
//        for (int i = 0; i < n; i++) {
//            weights[i] = Long.parseLong(in.next());
//            values[i] = Long.parseLong(in.next());
//        }
//
//        int sum = 0;
//        for (int i = 0; i < n; i++) {
//            int diff = (int) (weights[i] - weights[0]);
//            for (int j = i; 0 <= j; j--) {
//                for (int k = sum; 0 <= k; k--) {
//                    dp[j + 1][k + diff] = Math.max(dp[j + 1][k + diff], dp[j][k] + values[i]);
//                }
//            }
//            sum += diff;
//        }
//        long result = 0;
//        for (int i = 0; i <= n; i++) {
//            for (int j = 0; j <= sum; j++) {
//                if (w < i * weights[0] + j) {
//                    continue;
//                }
//                result = Math.max(result, dp[i][j]);
//            }
//        }
//
//        out.println(result);

        }

    }
}



Measured memory_bytes: 67744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Space-Time Sugoroku Road
 */
public class Main {

	static final int INF = 1 << 29;
	static int min = INF;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Main main = new Main();

		int N = parseInt(br.readLine());
		Map<Integer, List<Integer>> G = new HashMap<>();

		for (int i = 1; i <= N; i++) {

			int p = parseInt(br.readLine());

			G.put(i, new ArrayList<>());

			if (p == 0) {
				for (int j = 1; j <= 6; j++) {
					G.get(i).add(i + j < N ? i + j : N);
				}
			} else {
				G.get(i).add(i + p);
			}
		}

		//solve
		Queue<int[]> pq = new PriorityQueue<>(1, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[1], o2[1]);
			}
		});
		Log loop = main.new Log();

		pq.offer(new int[]{1, 0});

		while (!pq.isEmpty()) {

			int[] s = pq.poll();

			if (s[0] == N) {
				min = Math.min(min, s[1]);
				continue;
			}

			if (s[1] >= min) {
				continue;
			}

			if (G.get(s[0]).size() != 1) {
				for (int t : G.get(s[0])) {
					if (!loop.detect(s[0], t, s[1] + 1)) {
						pq.add(new int[]{t, s[1] + 1});
					}
				}
			} else {
				int t = G.get(s[0]).get(0);
				if (!loop.detect(s[0], t, s[1])) {
					pq.add(new int[]{t, s[1]});
				}
			}
		}
		System.out.println(min);
	}

	class Log {

		Map<Integer, Map<Integer, Integer>> data;

		Log() {
			data = new HashMap<>();
		}

		boolean detect(int s, int t, int c) {

			data.putIfAbsent(s, new HashMap<>());
			data.get(s).putIfAbsent(t, INF);

			if (c < data.get(s).get(t)) {
				data.get(s).put(t, c);
				return false;
			} else {
				return true;
			}
		}
	}
}

Measured memory_bytes: 154804
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string a;
	cin>>a;
	if(a=="SUN")
 	cout<<"7";
	if(a=="MON")
	cout<<"6";
	if(a=="TUE")
	cout<<"5";
	if(a=="WED")
	cout<<"4";
	if(a=="THU")
	cout<<"3";
	if(a=="FRI")
	cout<<"2";
	if(a=="SAT")
	cout<<"1";
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
odd = [i for i in range(N + 1) if i % 2 == 1]
ans = 0

for i in range(len(odd)):
    count = 0
    for x in range(1, odd[i] + 1):
        if odd[i] % x == 0:
            count += 1
    if count == 8:
        ans += 1
    count = 0

print(ans)


Measured memory_bytes: 3060
N = int(input())

flag = 0

for i in range((N // 4) + 1):
  for j in range((N // 7) + 1):
    if 4*i + 7*j == N:
      print("Yes")
      flag = 1
      break
  if flag == 1:
    break
      
if flag == 0:
  print("No")


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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


int main() {
    ll x,y;
    cin>>x>>y;

    ll ans=0;

    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

s = input().strip()
t = input().strip()
n = len(s)
m = len(t)
ans = float('inf')
for i in range(n-m+1):
    ct = 0
    for j in range(m):
        if s[i+j] != t[j]:
            ct += 1
    ans = min(ans,ct)
print(ans)

Measured memory_bytes: 67512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()

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

  int longuest = 0;
  int current = 0;

  REP(i, s.size()) {
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
      current++;
      longuest = max(longuest, current);
    }
    else {
      current = 0;
    }
  }

  cout << longuest << endl;

  return 0;
}


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

using namespace std;


string o = "keyence";
int main () {
  string s;
  cin >> s;
  bool ok = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size(); j++ ) {
      if (s.substr(0, i)+s.substr(j) == o) {
        ok = 1;
      }
    }
  }
  cout << ((ok) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
n=int(input())
dic={"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(n):
  s=input()
  dic[s]+=1
print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))

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

int main()
{
  int n, x;
  cin >> n >> x;
  vector<int> L(n);
  rep(i, n) cin >> L.at(i);

  vector<int> D(n+1);
  D.at(0) = 0;
  rep(i, n)
  {
    D.at(i + 1) = D.at(i) + L.at(i);
  }

  int count = 0;
  rep(i, n+1)
  {
    if (D.at(i) <= x)
    {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 19;
int n;
int b[N] , f[(1 << N)];
int a[N][N];
int dp[(1 << N)];

main()
{
    //freopen("U.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        FOR(j , 1 , n)
            cin >> a[i][j];
    REP(j , (1 << n))
    {
        int cnt = 0 , r = 0;
        REP(k , n)
            if((j >> k) & 1)
                b[++r] = k + 1;
        FOR(x , 1 , r - 1)
            FOR(y , x + 1 , r)
                cnt += a[b[x]][b[y]];
        f[j] = cnt;
    }
    dp[0] = 0;
    FOR(j , 1 , (1 << n) - 1)
    {
        dp[j] = f[j];
        for(int k = ((j - 1) & j) ; k ; k = ((k - 1) & j))
            dp[j] = max(dp[j] , dp[j ^ k] + f[k]);
    }
    cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 2944
n = int(input())
la1 = [int(w) for w in input().split()]
la2 = [int(w) for w in input().split()]


ans = 0
for i in range(n):
    s1 = sum(la1[:i + 1])
    s2 = sum(la2[i:])
    ans = max(ans, s1 + s2)
print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    int n; cin >> n;
    for(int i = 0; i < s.size(); i += n) cout << s[i];
    cout << "\n";
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
n, k = map(int,input().split())

ans = 0.0
for i in range(1,n+1):
    if i >= k:
        ans += (1/n)
    else:
        get = (1/n)
        val = i
        while val < k:
            val *= 2
            get *= (1/2)
        ans += get
print(ans)        


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    int diff = INT_MAX;
    for (int i = 0; i <= len - 3; i++)
    {
        istringstream ss = istringstream(s.substr(i, 3));
        int num;
        ss >> num;
        int d = 753 - num;
        if (d < 0) d = -d;
        if (diff > d)
        {
            diff = d;
        }
    }
    cout << diff << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;
  char prev=S[0];
  int ans=1;
  for(char c:S) {
    if(c != prev) {
      prev = c;
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
typedef struct node{
	int key;
	int pri;
	struct node *right , *left;
}Node;

Node * Delete(Node **,int);
Node * del(Node **,int);

int find(Node *p,int x)
{
	while(p!=NIL)
	{
		if(p->key==x)return 1;
		else if(p->key > x)p = p->left;
		else p = p->right;
	}
	return 0;
}

void inorder(Node *a)
{
	if(a->left!=NIL) inorder(a->left);
	printf(" %d",a->key);
	if(a->right!=NIL) inorder(a->right);
	return;
}

void preorder(Node *p)
{
	printf(" %d",p->key);
	if(p->left!=NIL) preorder(p->left);
	if(p->right!=NIL) preorder(p->right);
	return;
}

void print(Node *p)
{
	inorder(p);
	printf("\n");
	preorder(p);
	printf("\n");
	return;
}

Node * makenode(int x , int y)
{
	Node *new = malloc(sizeof(Node));
	new->key = x;
	new->pri = y;
	new->left = NIL;
	new->right = NIL;
	return new;
}

Node *rightRotate(Node *p)
{
	Node *q = p->left;
	p->left = q->right;
	q->right = p;
	return q;
}

Node *leftRotate(Node *p)
{
	Node *q = p->right;
	p->right = q->left;
	q->left = p;
	return q;
}

Node* insert(Node **t , int key, int pri)
{
	Node *new;
	if((*t)==NIL)
	return new = makenode(key,pri);
	if((*t)->key == key)
	return *t;
	
	if(key < (*t)->key)
	{
		(*t)->left = insert(&(*t)->left,key,pri);
		if((*t)->pri < (*t)->left->pri)
		(*t) = rightRotate(*t);
	}
	else{
		(*t)->right = insert(&(*t)->right,key,pri);
		if((*t)->pri < (*t)->right->pri)
		(*t) = leftRotate((*t));
	}
	return *t;
}

Node * Delete(Node **t , int key)
{
	if((*t)==NIL)
	return NIL;
	
	if(key < (*t)->key)
	(*t)->left = Delete(&((*t)->left),key);
	
	else if(key > (*t)->key)
	(*t)->right = Delete(&((*t)->right),key);

	else return del(t,key);
	return *t;
}

Node * del(Node **t , int key)
{
	if((*t)->left == NIL && (*t)->right == NIL)
	{
		return NIL;
	}
	else if((*t)->left == NIL)
	{
		(*t) = leftRotate(*t);
	}
	else if((*t)->right ==NIL)
	{
		(*t) = rightRotate(*t);
	}
	else{
		if((*t)->left->pri > (*t)->right->pri)
		(*t) = rightRotate(*t);
		else
		(*t) = leftRotate(*t);
	}
	return Delete(t,key);
}

int main(void)
{
	int num ,  x, y;
	char com[8];
	Node *root = NIL;
	scanf("%d",&num);
	
	for(int i = 0; i < num; i++)
	{
		scanf("%s",com);
		switch(com[0])
		{
			case 'i':scanf("%d %d",&x,&y);
			root = insert(&root,x,y);
			break;
			case 'd':scanf("%d",&x);
			root = Delete(&root,x);
			break;
			case 'f':scanf("%d",&x);
			if(find(root,x))printf("yes\n");
			else printf("no\n");
			break;
			case 'p':print(root);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 7996
#include <stdio.h>

int main(void){
   long int a,b,n,ans;
   
   scanf("%ld%ld%ld",&n,&a,&b);
   
   ans=n/(a+b)*a;
   if(a<=n%(a+b)){ans+=a;}
   else ans+=n%(a+b);
   
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        P[i]--;
    }

    vector<ll> C(N);
    for (int i = 0; i < N; ++i)
        cin >> C[i];

    ll ans = LLONG_MIN;
    for (int i = 0; i < N; ++i) {
        ll stmp = 0, smax = LLONG_MIN;
        vector<ll> score(N, -1), dist(N, -1);
        ll pos = i;
        score[i] = 0, dist[i] = 0;
        bool check = true;

        for (ll j = K; j > 0;) {
            if (~score[P[pos]] && check) {
                ll siz = dist[pos] + 1 - dist[P[pos]];
                ll inc = score[pos] + C[P[pos]] - score[P[pos]];

                if (j / siz >= 1) {
                    stmp += (ll)(j / siz - 1) * inc;
                    j -= (j / siz - 1) * siz;
                    smax = max(stmp, smax);
                }

                check = false;
                continue;
            }

            stmp = stmp + C[P[pos]];
            smax = max(stmp, smax);

            score[P[pos]] = score[pos] + C[P[pos]];
            dist[P[pos]] = dist[pos] + 1;

            pos = P[pos];
            --j;
        }
        ans = max(ans, smax);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double a, b, x;
    scanf("%lf %lf %lf", &a, &b, &x);
  	if (x/a/a > b/2){
	    double r = atan2(b-x/a/a, a/2);
    	printf("%.12lf",  r * 180.0 / (atan(1.0) * 4.0));
    }else{
      	double r = atan(b/(2*x/a/b));
    	printf("%.12lf",  r * 180.0 / (atan(1.0) * 4.0));
    }
    return 0;
}   


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int>a(3);
    for(int i = 0; i < 3; i++) cin >> a[i];
   // for(int i = 0; i < 3; i++) cout << a[i];
    std::sort(a.begin(), a.end());
    a.erase(std::unique(a.begin(), a.end()), a.end());
    //for(int i = 0; i < 3; i++) cout << a[i];
    if(a.size() == 2) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  long long int n;
  scanf("%lld",&n);
  long long int a[n];
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  
  long long int sum=0;
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
      sum+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  printf("%lld",sum);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct com {
  int a, b, c;
  bool operator<(const com &that) const {
    if (a != that.a) return a < that.a;
    if (b != that.b) return b < that.b;
    if (c != that.c) return c < that.c;
    return false;
  }
};

void solve() {
  int N, Q;
  cin >> N >> Q;
  vector<com> v;
  rep(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    v.push_back({ s - x, 1, x });
    v.push_back({ t - x, -1, x });
  }
  sort(all(v));
  multiset<int> se;
  int j = 0;
  rep(i, Q) {
    int d; cin >> d;
    while (j < (int) v.size() && v[j].a <= d) {
      if (v[j].b == 1) {
        se.insert(v[j].c);
      } else {
        se.erase(v[j].c);
      }
      j++;
    }
    if (se.size()) {
      cout << *se.begin() << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}


Measured memory_bytes: 15340
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int count = 0;
        for (int i = 0; i <= A; i++) {
            for (int j = 0; j <= B; j++) {
                for (int k = 0; k <= C; k++) {
                    if (i*500 + j*100 + k*50 == X) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 22100
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m,sum1[110][110],sum2[110][110],a,b;
short ans,f[101][101][101][101];
char s[110];

void update(short &x,short y)
{
    if (y>x)
        x=y;
}

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,1,n)
    {
        scanf("%s",s+1);
        repu(j,1,m)
        {
            if (s[j]=='E')
                a=i,b=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    repu(i,0,n-a)
        repu(j,0,a-1)
            repu(k,0,m-b)
                repu(l,0,b-1)
                {
                    update(ans,f[i][j][k][l]);
                    int x=max(b-l,k+1),y=min(b+k,m-l);
                    if (a+i+1+j<=n)
                        update(f[i+1][j][k][l],f[i][j][k][l]+sum1[a+i+1][y]-sum1[a+i+1][x-1]);
                    if (a-j-1-i>0)
                        update(f[i][j+1][k][l],f[i][j][k][l]+sum1[a-j-1][y]-sum1[a-j-1][x-1]);
                    x=max(a-j,i+1),y=min(a+i,n-j);
                    if (b+k+1+l<=m)
                        update(f[i][j][k+1][l],f[i][j][k][l]+sum2[y][b+k+1]-sum2[x-1][b+k+1]);
                    if (b-l-1-k>0)
                        update(f[i][j][k][l+1],f[i][j][k][l]+sum2[y][b-l-1]-sum2[x-1][b-l-1]);
                }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 198912
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;

signed main() {
double R,ans;
cin >> R;
ans = 2* PI *R;
answer(ans);

}

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

using namespace std;

class DisjointSet {
public:
	vector<int>rank, p;

	DisjointSet(){}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++) makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

int main() {
	int n, a, b, q;
	int t;

	cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	for (int i = 0; i < q; i++) {
		cin >> t >> a >> b;
		if (t == 0)ds.unite(a, b);
		else if (t == 1) {
			if (ds.same(a, b))cout << 1 << endl;
			else cout << 0 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = 1 << 30;
const int maxn = 100010;


int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k;
    cin >> k;
    
    cout << a[k - 1] << "\n";


}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String S = in.next();
			int price = 700;
			for(int i = 0; i < S.length(); i++) {
				if(S.charAt(i) == 'o') {
					price += 100;
				}
			}
			out.println(price);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main() {
	//N:品物の個数, W:バッグの容量
	int N, W;
	cin >> N >> W;

	//荷物のweightとvalueを保存する配列
	int weight[110], value[110];
	rep(i, N) cin >> value[i] >> weight[i];

	//DPのためのテーブル
	//dp[i][w]:i番目までの荷物を使ってwを超えない最大の価値
	int dp[110][10010];

	//0番目の荷物すなわち荷物なしなら最大の価値は0
	for (int w = 0; w <= W; ++w) dp[0][w] = 0;

	// DPループ
	for (int i = 0; i < N; ++i) {
		for (int w = 0; w <= W; ++w) {
			if (w >= weight[i]) {//i番目の荷物の重さが重さの上限以下なら
				dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
			}
			else {
				dp[i + 1][w] = dp[i][w];
			}
		}
	}

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


Measured memory_bytes: 7064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int l,r;
    cin >> l >> r;
    int ans = INF;
    if(r - l > 2019){
        ans = 0;
    }else{
        for(int i = l; i < r; i++){
            for(int j = i + 1; j < r + 1; j++){
                ans = min(ans,i * j % 2019);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256