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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// x : 開始の数(初項)
// d : 足す数(公差)
// n : x から何個後まで見るか(第 n 項)
// 例) x = 3, d = 1, n = 4 の場合 3+4+5+6=18
ll AriProSum(ll x, ll d, ll n) {
    return n * (2 * x + (n - 1) * d) / 2;
}

// ある整数区間の両端 [first, second] (閉区間)を表す pair が
// たくさん入った vector を受け取り、
// その区間を整理して和集合したものを返します。
// ※引数 range をソートしちゃうので注意
// 例) { [-2, 5], [6, 9], [12, 19] } の場合
//     -> { [-1, 9], [12, 19] } にする。
//     { [1, 1], [0, 8], [4, 15] } の場合
//     -> { [0, 15] } にする。
// O(NlogN)
vector< pair<ll, ll> > GetSumSet(vector< pair<ll, ll> >& range) {
    vector< pair<ll, ll> > ret;
    if(range.size() == 0) { return ret; }
    sort(range.begin(), range.end());

    pair<ll, ll> cur = range[0];
    for(auto& tmp_r : range) {
        assert(tmp_r.first <= tmp_r.second);
        if(cur.second + 1 < tmp_r.first) {
            // もう cur と一緒にできる区間はない
            ret.push_back(cur);
            cur = tmp_r;
        }
        cur.second = max(cur.second, tmp_r.second);
    }
    ret.push_back(cur);

    return ret;
}

// 値 val を公差 d を好きな回数だけ足して 0 以上にする
ll Adjust(ll val, ll d) {
    if(val >= 0) { return val % d; }
    ll mul = abs(val) / d + 1;
    return (val + d * mul) % d;
}

ll N, X, D;

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

    cin >> N >> X >> D;

    if(D == 0) {
        if(X == 0) {
            printf("1\n");
            return 0;
        }
        // X が N 個ある
        printf("%lld\n", N + 1);
        return 0;
    }

    // D が負の場合を考えるのが面倒なので正にする
    if(D < 0) {
        X = X + (N - 1) * D;
        D = abs(D);
    }

    // N の中から k 個使うとき、
    // k 個使う最小～ k 個使う最大までの間を公差 x で
    // 全て網羅する数列を作成可能
    //
    // k 個使う最小が mod D したときにどのグループになるか分けた後、
    // それぞれでどの区間を網羅するかを保存しておく
    // 最後に区間に含まれる数字の数をカウントすれば OK

    // key: グループ
    // val: そのグループ内で表す区間の両端
    map<ll, vector< pair<ll, ll> > > range;

    for(ll k = 0; k <= N; ++k) {
        // N 個のうち k 個を使った時の最小
        ll val_min = AriProSum(X, D, k);
        // 最大
        ll val_max = AriProSum(X + D * (N - k), D, k);
        // グループ
        ll group = Adjust(val_min, D);
        DBG("k: %lld\n", k);
        DBG("  min: %lld max: %lld group: %lld\n", val_min, val_max, group);
        range[group].push_back(make_pair(val_min, val_max));
    }

    ll ans = 0;
    for(auto& tmp_r : range) {
        // グループごとに区間の和集合をとる
        auto sum_set = GetSumSet(tmp_r.second);
        for(auto& tmp_sum_set_r : sum_set) {
            ans += (tmp_sum_set_r.second - tmp_sum_set_r.first) / D + 1;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 22144
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    string s;
    cin >> s;
    for (auto i : s)
    {
        if (i == ',')
            i = ' ';

        cout << i;
    }
}


Measured memory_bytes: 256
#2
#入力
A,B,C=map(int,input().split())

#デバッグ関連
debug=1#0:本番,1:デバッグ

def pront(*n):
    if debug==1:
        print(n)

#処理
if A%2==1 or B%2==1 or C%2==1:
    
    print(0)
    
elif A==B==C:
    
    print(-1)
    
else:
    x=0
    while not(A%2==1 or B%2==1 or C%2==1):
        a=A
        b=B
        c=C
        
        A=(b+c)//2
        B=(a+c)//2
        C=(a+b)//2
        x+=1
    
    print(x)
    

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int c[10][10];
int cost[10];
bool used[10];

void dfs(int n, int cst){
    //cout << n << ':' << cst << ' ';
    used[n] = true;
    cost[n] = min(cst, cost[n]);
    for(int i = 0; i < 10; i++){
        if(!used[i]) dfs(i, cst+c[i][n]);
    }
    used[n] = false;
}

int main(){
    int H, W;
    long ans = 0;
    cin >> H >> W;
    for(int i = 0; i < 10; i++){
        cost[i] = INT32_MAX;
        used[i] = false;
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }
    dfs(1, 0);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int A;
            cin >> A;
            if(A != -1) ans += cost[A];
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 504
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }
    std::sort(std::begin(A), std::end(A),
              [](const auto& a, const auto& b) {
                  return a > b;
              });

    const double half = A[0] / 2.0;
    double cand = A[0];

    int64_t k = 0;
    for (size_t i = 1; i < N; ++i) {
        if (cand >= abs(half - A[i])) {
            k = i;
            cand = abs(half - A[i]);
        }
    }

    std::cout << A[0] << " " << A[k] << std::endl;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, m;
  cin >> n >> m;
  vll a(n);
  vin(a);
  sort(all(a),greater<ll>());
  ll sum = accumulate(all(a), 0) / (4 * m);
  if(accumulate(all(a), 0) % (4 * m) == 0) cout << (a[m - 1] >=  sum ? "Yes" : "No") << endl;
  else cout << (a[m - 1] >  sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String s[] = new String[N];
		int a_num = 0;
		int b_num = 0;
		boolean flag = true;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			s[i] = sc.next();
			if(s[i].substring(0, 1).equals("B")) {
				b_num++;
			}
			if(s[i].substring(s[i].length() - 1, s[i].length()).equals("A")){
				a_num++;
			}
			if(s[i].substring(0, 1).equals("B") || s[i].substring(s[i].length() - 1, s[i].length()).equals("A")) {
				if(!(s[i].substring(0, 1).equals("B") && s[i].substring(s[i].length() - 1, s[i].length()).equals("A"))) {
					flag = false;
				}
			}
			for(int j = 0; j < s[i].length() - 1; j++) {
				if(s[i].substring(j, j + 2).equals("AB")) ans++;
			}
		}
		ans += Math.min(a_num, b_num);
		if(Math.min(a_num, b_num) != 0 && flag) {
			ans--;
		}
		System.out.println(ans);
	}
}


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


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

    rep(i, (int)s.size()-1){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    rep(i, (int)s.size()-2){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

//vector<int> vt;
//pair<int,int> p;
//map<int,int> m;
int a[2000];
int main() {
	ios::sync_with_stdio(false);
	
	int n,m;
	double sum=0;
	int ok=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double vot=sum/(m*4);
	for(int i=1;i<=n;i++){
		if(a[i]>=vot){
			ok++;
		}
	}
	if(ok>=m){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct part
{
    char name[100];
    int t;
}p;
p Q[LEN];
int head,tail,n;
void enqueue(p x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
}
p dequeue()
{
    p x;
    x=Q[head];
    head=(head+1)%LEN;
    return x;
}
int compare(int a,int b){return a<b?a:b;}
int main()
{
    int elaps=0,c,q,i;
    p u;
    scanf("%d%d",&n,&c);
    for(i=1;i<=n;i++)
    {
        scanf("%s%d",Q[i].name,&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head!=tail)
    {u=dequeue();
    q=compare(c,u.t);
    u.t-=q;
    elaps+=q;
    if(u.t>0)
    {
        enqueue(u);
    }
    else printf("%s %d\n",u.name,elaps);}
return 0;
}


Measured memory_bytes: 11888
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

x, y = rm()
if 4*x - y >= 0 and (4*x - y) % 2 == 0 and y >= 2*x:
  print('Yes')
else:
  print('No')


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

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

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

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll t = numeric_limits<int>::max();
    t = min(t, a * x + b * y);
    t = x < y ? min(t, 2 * c * y) : min(t, 2 * c * x);
    ll s = 0;
    if (a + b > 2 * c) {
        while (min(x, y) > 0) {
            s += 2 * c;
            --x;
            --y;
        }
    }
    s += a * x;
    s += b * y;
    t = min(t, s);
    cout << t << endl;
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, w;
    cin >> n >> w;

    pair<int, int> wv[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> wv[i].ff >> wv[i].ss;
    }

    vector<vector<int>> dp = vector<vector<int>> (2, vector<int>(100010, INT_MAX));
    
    dp[0][wv[0].ss] = wv[0].ff;
    dp[0][0] = dp[1][0] = 0;

    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < 100010; ++j)
        {
            dp[i % 2][j] = min(j >= wv[i].ss ? wv[i].ff + dp[(i - 1) % 2][j - wv[i].ss] : INT_MAX, dp[(i - 1) % 2][j]);
        }
    }

    int ans = 0;
    for (int i = 0; i < 100001; ++i)
        if (dp[(n - 1) % 2][i] <= w)
        {
            // cout << dp[(n - 1) % 2][i] << " : " << i << endl;
            ans = max(ans, i);
        }


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

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

int main(){
    char q, w, e, r; cin >> q >> w >> e >> r;
    int a, b, c, d;
    a = (int)q - 48;
    b = (int)w - 48;
    c = (int)e - 48;
    d = (int)r - 48;
    if(a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(auto &q:p) cin>>q;
    int min=n+1,count=0;
    for(int i=0;i<n;i++){
        if(min>p.at(i)){
            min=p.at(i);
            count++;
        }
    }
    cout<<count;
}

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
	long long x,y,i,j,k,ans,mod=1000000007;
	cin >> x >> y;
	if((x+y)%3!=0 || x>2*y ||y>2*x){
		cout<<0; return 0;
	}
	if(x>y){
		swap(x,y);
	}
	k=(x+y)/3;
	y-=k; x-=k;
	
	vector<long long> p(x+y+1),pinv(x+y+1);
	p[0]=1; pinv[0]=1;
	for(i=1; i<=x+y; i++){
		p[i]=(p[i-1]*i)%mod;
		pinv[i]=modpow(p[i],mod-2,mod);
	}
	/*
	cout << x << y << endl;
	for(i=0; i<4; i++){
		cout << p[i] << ' ' << pinv[i] << endl;
	}
	*/
	ans=(p[x+y]*pinv[x])%mod;
	ans=(ans*pinv[y])%mod;
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int main(void)
{
	int a,b,c,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<a+c;i++){
		if(a<=i&&b>=i){
			printf("%d\n",i);
		}
	}
	for(i=b-c+1;i<b+1;i++){
		if(a<=i&&b>=i){
			if(i>=a&&i<a+c){
			}else{
				printf("%d\n",i);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
# k本の花束の作り方は正直わからない
# 2**n-1通りのはなの選び方があるのは間違いない
# その中からごうけいがa,bになるものは除く
# nCa+nCb何じゃない？
# 組み合わせ数を計算するだけならめんどくさいライブラリを使わなくてもmathのfactorialで階乗を計算すれば良い
from functools import lru_cache
import math
n,a,b = map(int,input().split())


# これはfactorialの計算がやばいことになるので(10**9+7)で割りながらやっていこう
# ホントはここの10^9のループが重いみたいだなぁ
# なんか２分累乗法を使わないといけないらしい．．．実はpythonではmathのpowに標準でついています！
Big = 10**9 + 7
#@lru_cache()
def cal_pow(num,w):
    if num==1:
        return w
    elif num==0:
        return 1
    else:
        half = num // 2
        rest = num % 2
        res = cal_pow(half,w) **2 * cal_pow(rest,w)
        res %= Big
        return res
#all = cal_pow(n,2)-1
all = pow(2,n,Big)-1

a_comb = 1
for i in range(a):
    # 逆元
    # inv_a = cal_pow(Big-2,a-i)
    inv_a = pow(a-i,Big-2,Big)
    a_comb *= (n-i)*inv_a
    a_comb %= Big
b_comb = 1
for i in range(b):
    # 逆元
    #inv_b = cal_pow(Big-2,b-i)
    inv_b = pow(b-i,Big-2,Big)
    b_comb *= (n-i)*inv_b
    b_comb %= Big
res = (all - a_comb - b_comb)
while res<0:
    res += Big
print(res)

# また出たぞ！！逆元だぁ...
# 1/x の mod p(素数) は x^(p-2)になるらしい．(フェルマーの小定理より...)
# mod(1/x) = mod(x^(p-2))






Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i,0,n-1) cin>>b[i];
    
    int ans=0;
    ans+=b[0];
    rep(i,0,n-2) ans+=min(b[i],b[i+1]);
    ans+=b[n-2];
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "math.h"
#include "stdio.h"
#include <iostream>

using namespace std;

int mat[101][101];

int main() {
  int n, m;

  cin>> n >> m;

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

  int col[101];

  for(int j= 0; j<m; j++) {
    cin>> col[j];
  }

  for(int i= 0; i<n; i++) {
    int x= 0;
    for(int j= 0; j<m; j++) {
      x+= col[j] * mat[i][j];
    }

    cout<< x <<endl;
  }
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int N, A[16][16];
ll dp[1 << 16];
ll cost[1 <<16];

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

  cin >> N;

  rep(i, N){
    rep(j, N){
      cin >> A[i][j];
    }
  }

  for(int mask = 0; mask < (1 << N); mask++){
    rep(i, N){
      for(int j = i+1; j < N; j++){
        if((mask & (1 << i)) && (mask & (1 << j))) cost[mask] += A[i][j];
      }
    }
  }

  for(int mask = 0; mask < (1 << N); mask++){
    for(int mask2 = mask; mask2 > 0; mask2 = (mask2 - 1) & mask){
      ll next = dp[mask - mask2] + cost[mask2];
      chmax(dp[mask], next);
    }
  }

  cout << dp[(1<<N) - 1] << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int teste(int n){
    if(n < 10){
        return n;
    }
    else{
        return n%10 + teste(n/10);
    }
}
int main()
{
    int n, menor = 100001, i, aux, resto;
    scanf("%d", &n);
    if(n >= 10){
        for(i = 1; i < n / 2; i++){
            int resto = n - i;
            aux = teste(i) + teste(resto);
            if(aux < menor)
                menor = aux;
        }
        printf("%d\n", menor);
    }
    else
        printf("%d\n", n);
}


Measured memory_bytes: 128
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

*/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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

bool compare(pair<int,int>p1, pair<int,int>p2){

  return p1.second > p2.second;
 }

 // sorting the map when the first is string ans second is the integer
 bool sortbyval(pair<string,int>a, pair<string,int>b){
   return a.second < b.second;
 }

 void prints(string s){

  for(int i=0;i<2;i++){
    cout<<s<<endl;
  }
  //cout<<"animesh"<<endl;
return ;
 }

int main(){

 long long h,w;
 cin>>h>>w;

 for(int i=0;i<h;i++){
    string s;
    cin>>s;
    prints(s);
 }

 return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
   int a,b,k,i;
    
   scanf("%d %d %d",&a,&b,&k);
   if (a>b) i=b;
   else     i=a;
   for (;k>0;k--,i--)
      while (a%i!=0 || b%i!=0) i--;
   printf("%d\n",i+1);
   return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[N];

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        
        long ans = 0;
        if(a[0]>x){
            ans += a[0] - x;
            a[0] = x;
        }
        for(int i=0; i<N-1; i++){
            if(a[i]+a[i+1]>x){
                ans += a[i] + a[i + 1] - x;
                a[i + 1] = x - a[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50876
#include<bits/stdc++.h>
using namespace std;
#define MAXN	1005
#define MAXV	5005
#define INF	1e9
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct DP {
	int now, dest, n;
	int dp[2][MAXV];
	void fill(int now) {
		for (int i = 0; i <= n; i++)
			dp[now][i] = INF;
	}
	void init(int x) {
		n = x;
		now = 0, dest = 1;
		fill(now);
		dp[now][0] = 0;
	}
	void extend(int x, int y, int z) { /*Value, White, Black*/
		fill(dest);
		for (int i = 0; i <= n; i++) {
			if (dp[now][i] == INF) continue;
			if (i + x <= n) dp[dest][i + x] = min(dp[dest][i + x], dp[now][i] + y);
			if (i + z <= n) dp[dest][i + z] = min(dp[dest][i + z], dp[now][i] + x);
		}
		swap(now, dest);
	}
	int getans() {
		int ans = INF;
		for (int i = 0; i <= n; i++)
			ans = min(ans, dp[now][i]);
		return ans;
	}
} Black, White;
//0 : White; 1 : Black
vector <int> a[MAXN];
int n, value[MAXN], mn[MAXN][2];
void work(int pos) {
	if (a[pos].size() == 0) {
		mn[pos][0] = mn[pos][1] = 0;
		return;
	}
	for (unsigned i = 0; i < a[pos].size(); i++)
		work(a[pos][i]);
	Black.init(value[pos]);
	White.init(value[pos]);
	for (unsigned i = 0; i < a[pos].size(); i++) {
		Black.extend(value[a[pos][i]], mn[a[pos][i]][0], mn[a[pos][i]][1]);
		White.extend(value[a[pos][i]], mn[a[pos][i]][1], mn[a[pos][i]][0]);
	}
	mn[pos][0] = White.getans();
	mn[pos][1] = Black.getans();
}
int main() {
	read(n);
	for (int i = 2; i <= n; i++) {
		int x; read(x);
		a[x].push_back(i);
	}
	for (int i = 1; i <= n; i++)
		read(value[i]);
	work(1);
	if (min(mn[1][0], mn[1][1]) >= INF) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>
#include <map>

using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,int> P2;

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

int main() {
	int n,t;
	while(scanf("%d %d",&t,&n),t||n) {
		map<P1,bool> mp1;
		for(int i=0;i<n;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			mp1[P1(x,y)]=true;
		}
		int sx,sy;
		scanf("%d %d",&sx,&sy);
		queue<P2> que;
		que.push(P2(P1(sx,sy),0));
		map<P1,bool> mp2;
		mp2[P1(sx,sy)]=true;
		int ans=1;
		while(!que.empty()) {
			P2 p2=que.front();que.pop();
			if(p2.second==t) break;
			for(int i=0;i<6;i++) {
				int nx=p2.first.first+dx[i],ny=p2.first.second+dy[i];
				if(mp1.find(P1(nx,ny))==mp1.end()&&mp2.find(P1(nx,ny))==mp2.end()) {
					mp2[P1(nx,ny)]=true;ans++;
					que.push(P2(P1(nx,ny),p2.second+1));
				}
			}
		}
		printf("%d\n",ans);
	}
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;cin>>x;
    int val=sqrt(x);
    cout<<val*val<<endl;

    return 0;
}



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

int in(){int x;scanf("%d",&x);return x;}

int main(){
	int N=in(), M=in();
	int V[100000]; for(int l=1; l<=N; ++l) V[l] = N+1;
	while(M--){
		int l=in(), r=in();
		V[l] = min(V[l], r);
	}
	int ans = 0, R = 0;
	for(int l=1; l<N; ++l){
		int r = V[l];
		if(r > N) continue;
		if(l >= R) R=r, ans++;
		R = min(R, r);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
		int a[100][100]={0},w,h,n,i,j,xya[3],ans=0;
		scanf("%d%d%d",&w,&h,&n);
		for(i=h;i<100;i++){
				for(j=w;j<100;j++){
						a[i][j]=1;
				}
		}
		for(i=0;i<n;i++){
				scanf("%d%d%d",&xya[0],&xya[1],&xya[2]);
				int k;
				if(xya[2]==1){
						for(k=0;k<xya[0];k++){
								for(j=0;j<100;j++)a[j][k]=1;
						}
				}if(xya[2]==2){
						for(k=xya[0];k<100;k++){
								for(j=0;j<100;j++)a[j][k]=1;
						}
				}if(xya[2]==3){
						for(k=0;k<xya[1];k++){
								for(j=0;j<100;j++)a[k][j]=1;
						}
				}if(xya[2]==4){
						for(k=xya[1];k<100;k++){
								for(j=0;j<100;j++)a[k][j]=1;
						}
				}
		}
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						if(a[i][j]==0)
								ans++;
				}
		}
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const int N = 1e5+5;
struct Node{
	int x,y;
	int time;
}a[N]; 
int main(){
	int n;
	cin>>n;
	a[0].time=0;
	a[0].x=0;
	a[0].y=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i].time,&a[i].x,&a[i].y);
	}
	int flag = 1;
	for(int i=1;i<=n;i++){
		int nt=abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y);
		if(a[i].time-a[i-1].time<nt){
			flag=0;
			break;
		}
		if((a[i].time-a[i-1].time-nt)%2){
			flag=0;
			break;
		}
	}
	printf("%s",flag?"Yes\n":"No\n");
}

Measured memory_bytes: 1408
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n];
   int mx1=0,mx2=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       if(a[i]>mx1)
       {
           mx2=mx1;
           mx1=a[i];
       }
       else if(a[i]>mx2)
       {
           mx2=a[i];
       }
   }
   for(int i=0;i<n;i++)
   {
       if(a[i]==mx1)
       {
           cout<<mx2<<endl;
       }
       else
        cout<<mx1<<endl;
   }
}


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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if (left == 0 || right == 0) return 0;
  if (left < 0) left *= -1;
  if (right < 0) right *= -1;
  if (left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while (ansgcd == -1) {
    nextnum = left % right;
    if (nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n, k;
vector<long long> a;

bool solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for (auto& p : a) cin >> p;
  sort(a.begin(), a.end());
  if (solve())
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}

bool solve() {
  if (a[n - 1] < k) return 0;
  long long g = a[0];
  for (int i = 0; i < n; ++i) g = GCD(g, a[i]);
  return k % g == 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int arr[105];
int ind;
int minn=0x3f3f3f3f;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=1;i<101;i++)
	{
		int ans=0;
		for(int j=0;j<n;j++)
		{
			ans+=(i-arr[j])*(i-arr[j]);
		}
		if(ans<minn){
			ind=i; minn=ans;
		} 
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	int n;
	float a, b, c;
	ll sum = 0;
	while(cin >> n)
	{
		for(int i = 1; i <= n; i ++)
		{
			a = 1.0 * i / 3;
//			cout << i << endl;
			b = 1.0 * i / 5;
//			cout << i << '\n';
			c = 1.0 * i / 15;
			if(c == int(c))
			{
				continue;
			}
			else if(a == int(a)){
				continue;
			}
			else if(b == int(b)){
				continue;
			}
			else sum += i;
		}
		printf("%lld\n", sum);
		
	}
	return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int E[510][510]={};
int dp[510][510]={};
int main(){
  int N,M,Q,ans;
  cin>>N>>M>>Q;
  
  //入力
  int l,r;
  for(int i=1;i<=M;i++){
    cin>>l>>r;
    E[l][r]++;
  }
  
  //累積和計算
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      dp[i][j]=dp[i-1][j]+dp[i][j-1]+E[i][j]-dp[i-1][j-1];
    }
  }
  
  //キュー処理
  int p,q;
  for(int i=0;i<Q;i++){
    cin>>p>>q;
    ans=dp[q][q]-dp[p-1][q]-dp[q][p-1]+dp[p-1][p-1];
    cout<<ans<<endl;
  }
  return 0;
}



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

int main() {
	string s;

	while (1) {
		cin >> s;
		if (s == "0") {
			break;
		}
		int sum = 0;
		for (int i = 0; i < s.size(); i++) {
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
def include_3(n) :
    ans = False
    if n >= 10 :
        if n % 10 == 3 :
            ans = True
            return ans
        if n // 10 == 3 :
            ans = True
            return ans
        ans = include_3(n // 10)
    return ans

n = int(input())
for i in range(1, n + 1) :
    if i % 3 == 0 or include_3(i) :
        print(" {}".format(i),end='')
print()


Measured memory_bytes: 5872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>

typedef long long ll;
#define fi first
#define se second

using namespace std;

////////////////////////////////
//
//
////////////////////////////////

///////////////////////////////
//////////////////////////////

int N;
ll T;
ll t[212345];
ll ans = 0;

int main(){
  
  cin>>N>>T;
  
  int i;
  
  for( i = 0; i < N; i++ ){
    scanf("%d", t+i);
  }
  
  ans = T;
  
  for( i = 1; i < N; i++ ){
    ans += (ll)min( T, (t[i]-t[i-1]) );
  }
  
  cout<<ans<<endl;
  
  
  return 0;
}

Measured memory_bytes: 1792
def main():
    from math import gcd
    _ = int(input())
    A = [int(i) for i in input().split()]

    def prime_factorize(n):
        for i in range(2, n+1):
            if i*i > n:
                break
            if n % i != 0:
                continue
            while n % i == 0:
                n //= i
            B[i] += 1
        if n != 1:
            B[n] += 1

    # 10**6 以下の素数は78498個しかない
    # よって，1以外の数がこれより多ければpairwiseにはならない
    check = True if sum(a != 1 for a in A) <= 80000 else False
    maxA = max(A)
    B = [0] * (maxA + 1)
    if check:
        for a in A:
            prime_factorize(a)

    g = A[0]
    for a in A:
        g = gcd(g, a)

    if g != 1:
        print("not coprime")
    elif check and max(B) <= 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 181528
<?php
while ($line = fgets(STDIN)) {
  $array[] = trim($line);
}
$no = explode(" ", $array[1]);

$count = -1;
$flag = 0;

while($flag == 0){
    for($i=0; $i<intval($array[0]); $i++){
        $a = $no[$i] % 2;
        if($a == 0){
            $no[$i] = intval($no[$i]) / 2;
        }else{
            $flag = 1;
        }
    }
    
    $count++;
}
echo $count;

?>

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    char c;
    cin >> c;
    c++;
    cout << c << endl; 
    return 0;
}


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

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

    int o_num = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == 'o')
        {
            o_num++;
        }
    }

    if ((15 - S.length() + o_num) >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val x = cin.nextInt()
  val n = cin.nextInt()
  val s = Array<Boolean>(105, {true})

  for (i in 0 until n) {
    val a = cin.nextInt()
    s[a] = false
  }

  for (i in 0..100) {
    if (x - i >= 0) {
      if (s[x - i]) {
        println(x - i)
        cin.close()
        return
      }
    }
    if (x + i <= 104) {
      if (s[x + i]) {
        println(x + i)
        cin.close()
        return
      }
    }
  }

  cin.close()
}

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

int main(void) {
    int A,B,K;
    cin>>A>>B>>K;
    map<int, int> mp;
    for (int i = A; i <= B && i <= A + K - 1; i++) {
        mp[i] = i;
    }
    for (int i = B; i >= A && i >= B - K + 1; i--) {
        mp[i] = i;
    }
    for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
        cout << it->first << endl;
    }
    return 0;
}

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] % 2) cnt++;
    }
    if(cnt > 0) cout << "first" << endl;
    else cout << "second" << endl;
}

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

int main() 
{
    int n;
    cin >> n;
    
    int height[n], minCost[n];
    
    for(int i=0; i<n; ++i)
        cin >> height[i];
    
    minCost[0] = 0;
    
    if (n > 1)
    {
        minCost[1] = abs(height[1] - height[0]);    
    }
    
    for(int i=2; i<n; ++i)
    {
        minCost[i] = min(abs(height[i] - height[i-1]) + minCost[i-1], 
            abs(height[i] - height[i-2]) + minCost[i-2]);
    }
    
    cout << minCost[n-1] << "\n";
	
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS;
    int x;
    cin>>x;  
    for(int i=-1000;i<=1000;i++)
    {
        for(int j=-1000;j<=1000;j++)
        {
            if(i*i*i*i*i-j*j*j*j*j==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int N,D,money;
	scanf("%d %d %d",&N,&D,&money);
	if(D == 1){
		printf("%d\n",money);
		return 0;
	}

	int table[D][N];
	int* dp = new int[100050];

	for(int i = 0; i < D; i++){
		for(int k = 0; k < N; k++)scanf("%d",&table[i][k]);
	}

	int budget = money,ans = money;
	int maximum;

	for(int day = 0; day <= D-2; day++){
		for(int i = 0; i <= budget; i++)dp[i] = 0;

		for(int i = 0; i < N; i++){
			for(int k = table[day][i]; k <= budget;k++){
				dp[k] = max(dp[k],dp[k-table[day][i]]+table[day+1][i]);
			}
		}
		maximum = 0;
		for(int i = 0; i <= budget; i++)maximum = max(maximum,(budget-i)+dp[i]);
		budget = maximum;
		ans = max(ans,budget);
	}

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

	return 0;
}

Measured memory_bytes: 3228
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
    	int t = sc.nextInt();
    	
      
      	if(x-t > 0){
        	System.out.println(x-t);
        }else{
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 35568
#include <iostream>
using namespace std;
   
int F[102][102];
int xg,yg,w,h;
   
   
void DFS(int Y,int X,int c){
  //if(Y < 1 || X < 1)
    //return;
  if(F[Y][X] != c){
    return;
  }
   
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
   
   
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j] = 10;
      }
    }
       
    cin >> xs >> ys >> xg >> yg >> n;
   
   
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(c == 0)
         c = 1919810;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
   
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3764
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  bool[int] kuku_answers;
  foreach(i; 1..10) {
    foreach(o; 1..10) {
      kuku_answers[i*o] = true;
    }
  }
  
  auto N = readln.chomp.to!int;
  writeln(N in kuku_answers ? "Yes" : "No");
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string s;
    cin >> s;
    bool jud = true;
    for(int i=0; i < 3; i++){
        if(s.at(i)==s.at(i+1)) jud = false;
    }
    if(jud) cout << "Good" << endl;
    else cout << "Bad" << endl;
 }

Measured memory_bytes: 256
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    //fastio
    string s;
    cin>>s;
    if(s[s.size()-1] == 's')
    {
        s+="es";
        cout<<s<<endl;
    }
    else
    {
        s+='s';
        cout<<s<<endl;
    }
    
    return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int ans1=0,ans2=0; 
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            if(i==0 && j==0)continue;
            if(100*(a*i+b*j)>f)continue;
            int limit = e*(a*i+b*j);
            for(int k=0;k<=limit;k++){
                for(int l=0;l<=limit;l++){
                    if(c*k+d*l>limit)continue;
                    int tmp1 = 100*(a*i+b*j)+c*k+d*l;
                    int tmp2 = c*k+d*l;
                    if(tmp1>f)continue;
                    if(ans1==0 && ans2==0){
                        ans1=tmp1;
                        ans2=tmp2;
                        continue;
                    }
                    if(tmp2*ans1>ans2*tmp1){
                        ans1=tmp1;
                        ans2=tmp2;
                    }
                }
            }
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
r=proc{gets.split.map(&:to_i)}
n,m=r[]
s=[]
p=0
n.times{s<<r[]}
s.sort_by{|a|a[0]}.each{|x|v,w=x;(w>=m)?(p+=v*m;break):(p+=v*w;m-=w)}
puts p

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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define M 1000000007
#define M2 998244353
#define INF 10000000000000000000
#define MAXN 300005
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int sum = n * (n + 1) / 2;
	// cnl(sum);
	sum -= (n / 3) * (6 + (n / 3 - 1) * 3) / 2;
	sum -= (n / 5) * (10 + (n / 5 - 1) * 5) / 2;
	sum += (n / 15) * (30 + (n / 15 - 1) * 15) / 2;
	cnl(sum);
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int dp[400];

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
			int s, l, p;
			cin >> s >> l >> p;
			for(int j = s; j < 394; j++){
					for(int k = s; k < l; k++){
							if(j - k < 0)continue;
							dp[j] = max(dp[j], dp[j - k] + p);
					}
			}
	}

	int m;
	cin >> m;
	vector<int> vec;
	for(int i = 0; i < m; i++){
			int w;
			cin >> w;
			if(dp[w] != 0){
					vec.push_back(dp[w]);
			}else{
					cout << -1 << endl;
					return 0;
			}
	}
	for(auto itr = vec.begin(); itr != vec.end(); ++itr){
			cout << *itr << endl;
	}
	return 0;
}



Measured memory_bytes: 3120