akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

using namespace std;

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

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    vector<vector<int>> graph(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    vector<int> dist_from_u(n, -1), dist_from_v(n, -1);
    function<void(int, int, vector<int>&)> dfs = [&](int now, int d, vector<int> &ds){
        if (0 <= ds.at(now)) return;

        ds.at(now) = d;
        for (int to: graph.at(now)) dfs(to, d + 1, ds);
    };

    dfs(u, 0, dist_from_u);
    dfs(v, 0, dist_from_v);

    int ans = 0;
    rep(i, n) if (dist_from_u.at(i) < dist_from_v.at(i)) chmax(ans, dist_from_v.at(i) - 1);
    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String str1 = scan.nextLine();
		int count = Integer.parseInt(str1);

		String str2 = scan.nextLine();
		int[] heightArray = parseIntArrayFromString(str2);

		int[] minCostArray = new int[count];
		minCostArray[0] = 0;
		minCostArray[1] = Math.abs(heightArray[0] - heightArray[1]);

		for (int i = 2; i < count; i++) {

			int a = minCostArray[i - 2] + Math.abs(heightArray[i] - heightArray[i - 2]);
			int b = minCostArray[i - 1] + Math.abs(heightArray[i] - heightArray[i - 1]);

			minCostArray[i] = Math.min(a, b);
		}

		System.out.println(minCostArray[count - 1]);
	}

	private static int[] parseIntArrayFromString(String stringBeforeSplit) {

		String[] stringArray = stringBeforeSplit.split(" ");

		return Arrays.stream(stringArray)
				.mapToInt(Integer::parseInt)
				.toArray();
	}
}


Measured memory_bytes: 45604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class AHitachiString {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
	    in >> s;

	    if(s.length()%2 != 0){
            ans(false, out);
            return;
	    }

	    bool flg = true;
	    for(int i=0; i<s.length()-1; i+=2){
            if(s[i] != 'h' || s[i+1] != 'i'){
                flg = false;
                break;
            }
	    }

	    ans(flg, out);
	}
};


int main() {
	AHitachiString solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define INF (1<<29)
#define MAX (500)
typedef long long ll;

int dp[50][MAX][MAX];

int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int> a(N), b(N), c(N);
	for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];

	for(int i=0; i<N; i++) for(int j=0; j<MAX; j++) for(int k=0; k<MAX; k++) dp[i][j][k] = INF;
	dp[0][0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < MAX; j++) {
			for (int k = 0; k < MAX; k++) {
				dp[i+1][j][k] = dp[i][j][k];
				if (j >= a[i] && k >= b[i]) {
					dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
				}
			}
		}
	}

	int ans=INF;
	for (int i = 1; i < MAX; i++) {
		if(Ma*i >= MAX || Mb*i >= MAX) continue;
		ans = min(ans, dp[N][Ma*i][Mb*i]);
	}

	cout << (ans==INF ? -1 : ans) << endl;
}


Measured memory_bytes: 41216
#include <stdio.h>

#define A_N (2)

int a_max(int a[])
{
	int max;
	int i;
	
	max = a[0];
	for (i = 1; i < A_N; i++){
		if (max < a[i]){
			max = a[i];
		}
	}
	
	return (max);
}

int main(void)
{
	int x;
	int s[2];
	int i, j;
	
	for (i = 0; i < A_N; i++){
		s[i] = 0;
		for (j = 0; j < 4; j++){
			scanf("%d", &x);
			s[i] += x;
		}
	}
	
	printf("%d\n", a_max(s));
	
	return (0);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  bool ans = true;
  for (int i = 0; i < n; ++i) {
    if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) {
      ans = false;
    }
  }
  if (ans) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;

long [] a;
long [] b;
long [] c;

struct Summand
{
	int u;
	int v;
	int w;

	@property auto value () const
	{
		return a[u] + b[v] + c[w];
	}

	@property auto id () const
	{
		return (u << 20) | (v << 10) | w;
	}

	int opCmp () (const auto ref Summand that) const
	{
		if (this.value != that.value)
		{
			return (this.value < that.value) -
			    (this.value > that.value);
		}
		return (this.id > that.id) - (this.id < that.id);
	}
}

void main ()
{
	int x, y, z, k;
	while (readf (" %s %s %s %s", &x, &y, &z, &k) > 0)
	{
		readln;
		a = readln.splitter.map !(to !(long)).array;
		b = readln.splitter.map !(to !(long)).array;
		c = readln.splitter.map !(to !(long)).array;
		sort !(q{a > b}) (a);
		sort !(q{a > b}) (b);
		sort !(q{a > b}) (c);

		auto t = redBlackTree !(Summand) ();
		t.insert (Summand (0, 0, 0));
		foreach (p; 0..k)
		{
			auto cur = t.front;
			writeln (cur.value);
			t.removeFront ();
			if (cur.u + 1 < x)
			{
				t.insert (Summand (cur.u + 1, cur.v, cur.w));
			}
			if (cur.v + 1 < y)
			{
				t.insert (Summand (cur.u, cur.v + 1, cur.w));
			}
			if (cur.w + 1 < z)
			{
				t.insert (Summand (cur.u, cur.v, cur.w + 1));
			}
		}
	}
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
	long long int n, mem[10]; 
	cin >> n;
	for(int i = 0; i < 5; i++) cin >> mem[i];
	sort(mem, mem+5);
	if(mem[0] >= n) { cout << 5 << endl; return 0; }
	long long int d = n - mem[0];
	long long int ans = d / mem[0];
	long long int e = d % mem[0];
	if(e!=0) ans++; 
	cout << (5+ans) << endl; 
	return 0;
}

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

int A,B,C,X,Y;

int main(){
	scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
	if(2*C<=A+B){
		if(X<=Y)
			printf("%d\n",2*C*X+(Y-X)*min(2*C,B));
		else printf("%d\n",2*C*Y+(X-Y)*min(2*C,A));
	}
	else printf("%d\n",X*A+Y*B);
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInts >>= print . maximum . flip map ( map uncurry [ (+), (-), (*) ] ) . flip ($) . mp

Measured memory_bytes: 380
// cf.) https://qiita.com/drken/items/dc53c683d6de8aeacf5a

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

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> h(N), dp(N+K, 1e9);
    for (int i = 0; i < N; i++) cin >> h[i];

    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {
	int i, j, k;
	int N, M, K;

	string S, T;
	cin >> S >> T;
	rep(i, 0, S.size()) {
		if (S[i] != T[i]) {
			cout << "No";
			return 0;
		}
}
	cout << "Yes";


	return 0;

}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
  int i, j, n, m;
  cin >> n;
  vi a(2*n);
  fo(i,2*n) cin >> a[i];
  sortall(a);
  ll ing = 0;
  while(!a.empty()){
    auto f = a.back();
    a.pop_back();
    auto s = a.back();
    a.pop_back();
    ing += min(f,s);
  }
  cout << ing;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}


Measured memory_bytes: 3664
function main()
  
  N = parse(Int,readline())
  S = collect(chomp(readline()))
  
  for i in 1:length(S)
    
    if S[i] + N > 'Z'
      S[i] += N
      S[i] -= 26
    else
      S[i] += N
    end

  end
  
  println(join(S))
  
end

main()

Measured memory_bytes: 142404
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<int> a(x);
    REP(i,x) cin >> a[i];
    vector<int> b(y);
    REP(i,y) cin >> b[i];
    vector<int> c(z);
    REP(i,z) cin >> c[i];
    sort(rall(c));
    vec ab;
    rep(i,x){
        rep(j,y){
            ab.pb(a[i]+b[j]);
        }
    }
    sort(rall(ab));
    vec abc;
    rep(i,min(k,(ll)ab.size())){
        rep(j,min(k,(ll)c.size())){
            abc.pb(ab[i]+c[j]);
        }
    }
    sort(rall(abc));
    rep(i,k){
        cout<<abc[i]<<endl;
    }

    
    
}

Measured memory_bytes: 43240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int h = sc.nextInt();
		int w = sc.nextInt();
		for (; h != 0 || w != 0;) {
			StringBuffer oddline = new StringBuffer();
			StringBuffer evenline = new StringBuffer();
			for (int i = 0; i < w; i++) {
				if (i % 2 == 1) {
					oddline.append('.');
					evenline.append('#');
				} else {
					oddline.append('#');
					evenline.append('.');
				}
			}
			for (int i = 0; i < h; i++) {
				if (i % 2 == 1) {
					System.out.println(evenline);
				} else {
					System.out.println(oddline);
				}
			}
			System.out.println("");
			
			h = sc.nextInt();
			w = sc.nextInt();
		}
		
		sc.close();
	}
}

Measured memory_bytes: 21028
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    int N, L;
    readf("%d %d\n", &N, &L);
    N.rep!(() => readln.chomp).sort().join.writeln;
}


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

int main(void) {
    int N;
    cin >> N;

    vector<int> A(N);
    vector<int> X(N);
    int S = 0, s = 0;

    for(int i=0;i<N;i++) {
        cin >> A.at(i);
        S += A.at(i);
        if(i%2==1) s += A.at(i);
    }
    
    X.at(0) = S-2*s;
    for(int i=1;i<N;i++) {
        X.at(i) = 2*A.at(i-1)-X.at(i-1);
    }

    for(int i=0;i<N;i++) {
        cout << X.at(i) << " ";
    }
    

    return (0);
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int k;
  while (cin >> k) {
    vector<int> a(1 << k);
    each (i, a) cin >> i;

    // http://d.hatena.ne.jp/todo314/20120614/1339695202

    pair<int, int> mx[a.size()];
    for (int i = 0; i < a.size(); ++i) {
      mx[i] = make_pair(a[i], 0);
    }
    auto merge = [&] (int i, int j) {
      vector<int> v({mx[i].first, mx[i].second, mx[j].first, mx[j].second});
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      mx[i] = make_pair(v[0], v[1]);
    };
    for (int i = 0; i < k; ++i) {
      for (int bit = 0; bit < (1 << k); ++bit) {
        if (bit & (1 << i)) {
          merge(bit, bit ^ (1 << i));
        }
      }
    }

    int x = mx[0].first + mx[1].second;
    for (int i = 1; i < a.size(); ++i) {
      x = max(x, mx[i].first + mx[i].second);
      cout << x << endl;
    }
    // cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6144
def main():
    input()
    sequence = list(map(int, input().split()))
    inserted = False
    for i in range(len(sequence)):
        n = sequence.pop(i)
        for j in sequence[:i]:
            if n <= j:
                sequence.insert(sequence.index(j), n)
                inserted = True
                break
        if inserted is False:
            sequence.insert(i, n)
        else:
            inserted = False
        print(' '.join(map(str,sequence)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5604
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

lli mod = 1e9 + 7;

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a, k;
    vector<lli> v;
    cin >> n >> k;
    vector<vector<lli>> dp(n + 2, vector<lli>(100005, 0));
    input(n, v);
    fr(i, 0, v[0] + 1) {
        dp[0][i] = 1;
    }

    for (lli i = 1; i < n; i++) {
        for (lli j = 0; j <= k; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
            if (j + v[i] + 1 <= k) {
                dp[i][j + v[i] + 1] -= dp[i - 1][j];
				dp[i][j + v[i] + 1] += mod;  
              	dp[i][j + v[i] + 1] %= mod;
            }
        }
        for (lli j = 1; j <= k; j++) {
            dp[i][j] += dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }

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

Measured memory_bytes: 81024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    //最小値を保存する。入力値との差の最大値で比較する
    int min;cin>>min;
    int max;max=-1*min;
    for(int i=0;i<n-1;i++){
        int num;cin>>num;
        if(max<num-min)max=num-min;
        if(min>num)min=num;
    }
    cout<<max<<endl;
    return 0;
}



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

int binary_search(vector<long long> &n, long long x){
    int ok = (int)n.size();
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (n[mid] >= x) ok = mid;
        else ng = mid;
    }
    if (ok == (int)n.size()) ok--;
    return ok;
}

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> shrine(a);
    for (int i = 0; i < a; i++) cin >> shrine[i];
    vector<long long> temple(b);
    for (int i = 0; i < b; i++) cin >> temple[i];

    for (int i = 0; i < q; i++){
        long long x;
        cin >> x;
        vector<long long> sh(2);
        vector<long long> tem(2);
        int v, w;
        v = binary_search(shrine, x);
        w = binary_search(temple, x);
        sh[0] = shrine[v];
        sh[1] = shrine[max(0, v-1)];
        tem[0] = temple[w];
        tem[1] = temple[max(0, w-1)];
        long long ans = 1000000000000;
        for (int j = 0; j < 2; j++){
            for (int k = 0; k < 2; k++){
                long long s = sh[j];
                long long t = tem[k];
                if (t > s) swap(s, t);
                if (x <= t || x >= s) ans = min(ans, max(abs(t-x), abs(s-x)));
                else if (abs(t-x) >= abs(s-x)) ans = min(ans, abs(t-x) + abs(s-x)*2);
                else ans = min(ans, abs(t-x)*2 + abs(s-x));
            }
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 2944
package main
 
import(
  "fmt"
)
 
func main() {
  var a, b int
  fmt.Scan(&a, &b)
  r := 0
  if a + b > a - b {
    r = a + b
  } else {
    r = a -b 
  }
  if r > a * b {
    fmt.Println(r)
  } else {
    fmt.Println(a*b)
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, x, k, res;
int main() {
    DAU
    cin >> n >> k;
    while (n--) {
        cin >> x;
        res += (x >= k);
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int val, res;
    for (int i = 0; i < 5; i++){
        cin >> val;
        if (val == 0) res = i + 1;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    int count5 = 0;
    int count7 = 0;
    
    cin >> a >> b >> c;
    if(a==5) count5++;
    if(a==7) count7++;
    if(b==5) count5++;
    if(b==7) count7++;
    if(c==5) count5++;
    if(c==7) count7++;
    
    if(count5==2&&count7==1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;
ll dp[2005][2005];
ll sum[2005][2005];

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<ll> s(n+5), t(m+5);
    rep(i, 1, n+1) cin >> s[i];
    rep(i, 1, m+1) cin >> t[i];

    dp[0][0] = 1;
    rep(i, 1, n+1) rep(j, 1, m+1) {
        if (s[i]==t[j]) dp[i][j] = (sum[i-1][j-1] + 1)%MOD;
        sum[i][j] = (((sum[i-1][j] + sum[i][j-1])%MOD - sum[i-1][j-1])%MOD + dp[i][j])%MOD;
        if (sum[i][j]<0) sum[i][j] += MOD;
    }

    rep(i, 0, n+1) rep(j, 0, m+1) ans += dp[i][j] %MOD;
  
    cout << ans%MOD << "\n";
    return 0;
}



Measured memory_bytes: 65800
#include <stdio.h>
#define MAX 100001
int main(void) {
    int n, i, absx, absy, dis, tim;
    int t[MAX]={0}, x[MAX]={0}, y[MAX]={0};
    
    scanf("%d", &n);
    for(i=1; i<=n; i++) {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
    for(i=0; i<n; i++) {
        absx = x[i+1]>=x[i] ? x[i+1]-x[i] : x[i]-x[i+1];
        absy = y[i+1]>=y[i] ? y[i+1]-y[i] : y[i]-y[i+1];
        tim = t[i+1]-t[i];
        dis = absx + absy;
        if(dis<=tim && dis%2==tim%2);
        else {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,W;
int w[101],v[101];
ll dp[101][100010];
int main(){
    cin >> N >> W;
    for(int i = 1; i <= N; i++){
        cin >> w[i] >> v[i];
        dp[i][0] = 0;
    }
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= W; j++){
            dp[i+1][j] = dp[i][j];
            if(j >= w[i+1]){
                dp[i+1][j] = max(dp[i][j-w[i+1]]+v[i+1],dp[i+1][j]);
            }
        }
    }
    ll mx = 0;
    for(int i = 0; i <= W; i++){
        mx = max(mx, dp[N][i]);
    }
    cout << mx << endl;
}



Measured memory_bytes: 78336
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int w, h, c;
	cin >> w >> h >> c;

	for (int i = min(w,h); i >= 1; i--) {
		if (w % i == 0 && h % i == 0) {
			cout << (w / i) * (h / i) * c << endl;
			return 0;
		}
	}
	return	0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#define N 8

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
int X[N][N];

void Inn();
void print();
void Queen(int );

int main() {
  int i, k, r, c;

  Inn();

  scanf("%d",&k);
  for(i = 0; i < k; i++) {
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }

  Queen(0);

  return 0;
}
void Inn(){
  int i, j;
  for(i=0; i<N; i++) row[i] = col[i] = 0;
  for(i=0; i<2*N-1; i++) dpos[i] = dneg[i] = 0;
  for(i=0; i<N; i++) {
    for(j=0; j<N; j++) {
      X[i][j] = 0;
    }
  }
}

void Board(){
  int i, j;
  for(i=0; i<N; i++) {
    for(j=0; j<N; j++) {
      if(X[i][j] == 1) {
    if(row[i] != j) return;
      }
    }
  }
  for(i=0; i<N; i++) {
    for(j=0; j<N; j++) {
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void Queen(int i) {
  int j;
  if(i == N) {
    Board();
    return;
  }

  for(j=0; j<N; j++) {
    if(col[j] == 1 || dpos[i+j] == 1 || dneg[i-j+N-1] == 1) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = 1;
    Queen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = 0;
  }
}



Measured memory_bytes: 2108
//:Ditttoo
#include<bits/stdc++.h>
using namespace std;
double  p[3000];
double  dp[3000][3001];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	}
    double ans=0.0;
    dp[1][0]=1-p[1];
    dp[1][1]=p[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=i ;j++)
		{dp[i][j]=(j!=0)?dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]):dp[i-1][j]*(1-p[i]);
	    //cout<<"i= "<<i<<" j="<<j<<"p="<<dp[i][j]<<"\n ";
	    }

	}
    for(int j=n/2+1;j<=n;j++)
    	ans+=dp[n][j];
    
   cout<<setprecision(9)<<ans;
	return 0;
}        

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

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef set<int> si;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
template<typename T> T gcd(T a, T b) {return a==0 ? b : gcd(b%a,a);}
template<typename T> void sout(T &w) { for(auto x : w) cout << x << ", "; cout << endl;}


int main() {
   ios::sync_with_stdio(0);
   int n, k; cin >> n >> k;
   vi a(n); REP(i,n) cin >> a[i];

   if (n<=k) {cout << 1 << endl; return 0;}

   int x = 1;
   n -= k;
   x += (n + k-2) / (k-1);

   cout << x << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  REP(i,3)REP(j,3){
    char c;
    cin >> c;
    if(i==j)cout << c;
  }
  cout << endl;
}



Measured memory_bytes: 256
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
As = Is()
d = collections.defaultdict(int)
for a in As:
    d[a] += 1 
lis = list(d.items())
ans = 0
for e in lis:
    if e[0] - e[1] > 0:
        ans += e[1]
    else:
        ans += e[1] - e[0]
print(ans)

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

long long n, k, ans=1e12;

int main(){
	cin >> k >> n;
	vector<long long>a(n);
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=0;i<n;i++){
		if (i==n-1) ans=min(ans,k-abs(a[n-1]-(a[0]+k)));
		else ans=min(ans,k-abs(a[i]-a[(i+1)%n]));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		
		int p[] = new int[n];
		
		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			p[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Pair[] pairs = new Pair[m];

		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			int x = Integer.parseInt(tmpArray[0]);
			int y = Integer.parseInt(tmpArray[1]);
			
			pairs[i] = new Pair(x, y);
		}
		
		DisjointSet set = new DisjointSet(n);
		
		for(int i = 0; i < m; i++){
			set.union(pairs[i].x, pairs[i].y);
		}
		
		int result = 0;
		for(int i = 1; i <= n; i++){
			if(p[i - 1] == i){
				result++;
			}
			
			else if(set.isSameSet(p[i - 1], i)){
				result++;
//				System.out.println(p[i - 1] + " and "+i+" is same set");
			}
		}
		
		System.out.println(result);
	}

}

class DisjointSet {
    private int n;
    private int[] p;
    private int[] rank;
 
    public DisjointSet(int n){
        this.n = n;
 
        p = new int[n + 1];
        rank = new int[n + 1];
 
        for(int i = 1; i <= n; i++){
            makeSet(i);
        }
    }
 
    private void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
 
    public void union(int x, int y){
        link (findSet(x), findSet(y));
    }
 
    private int findSet(int x){
        if(x != p[x]){
            p[x] = findSet( p[x]);
        }
        return p[x];
    }
 
    public boolean isSameSet(int x, int y){
        return findSet(x) == findSet(y);
    }
 
    private 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]++;
            }
        }
    }
}

class Pair {
	int x;
	int y;
	
	public Pair(int x, int y){
		this.x = x;
		this.y = y;
	}
}


Measured memory_bytes: 47652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<complex>//real().imag().
#include<cctype>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<string>
#include<utility>
#include<iterator>
#define pii pair<int,int>
#define make_pair mp
using namespace std;
typedef long long ll;
int main()
{
    // freopen("D:\\in.txt","r",stdin);
    // freopen("D:\\out.txt","w",stdout);
    //ios::sync_with_stdio(false);
    //system("pause");
    priority_queue<int> one,three;
    priority_queue<int,vector<int>,greater<int>> two,four;
    int w,h,n,x,y,a;
    cin>>w>>h>>n;
  while(n--)
  {
      cin>>x>>y>>a;
      if(a==1)
      {
          one.push(x);
      }
      if(a==2)
      {
          two.push(x);
      }
      if(a==3)
      {
          three.push(y);
      }
      if(a==4)
      {
          four.push(y);
      }
  }
  int x1=0,x2=w,y1=0,y2=h;
  if(!one.empty())
  {
      x1=one.top();
  }
  if(!two.empty())
  {
       x2=two.top();
  }
  if(!three.empty())
  {
       y1=three.top();
  }
  if(!four.empty())
  {
       y2=four.top();
  }

  if(x1>=x2||y1>=y2)
  {
      cout<<0<<endl;
  }else
  {
      cout<<(x2-x1)*(y2-y1)<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll bj=1,pp=0;
ll n;
cin>>n;
ll a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
for (int i = 1; i <= n; i++)
	{
		if (a[i] == bj) 
		{
			++bj;
			++pp;
		}
	}
	if (pp == 0) puts("-1");
	else printf("%d\n", n - pp);
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000000001
using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

typedef complex<double> pt;

int main(){
	pt p[310];
	int i,j,ii;
	int n;
	
	while(1){
		cin >> n;
		if(n==0) break;
		for(i=0;i<n;i++){
			double x,y;
			scanf("%lf %lf",&x,&y);
			p[i] = pt(x,y);
		}
		
		int mx=1;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				if(norm(p[i]-p[j]) > 4.0) continue;
				double l = abs(p[i]-p[j]);
				double k = sqrt(1.0-(l*l/4.0));
				pt m = (p[i]+p[j])/2.0;
				pt v(-imag(p[i]-p[j]),real(p[i]-p[j]));
				double r = abs(v);
				v= v*k/r;
				int cnt;
				
				p[n] = m+v;
				cnt=0;
				for(ii=0;ii<n;ii++){
					if(norm(p[ii]-p[n])<1.00001) cnt++;
				}
				mx = max(mx,cnt);
				
				p[n]=m-v;
				cnt=0;
				for(ii=0;ii<n;ii++){
					if(norm(p[ii]-p[n])<1.00001) cnt++;
				}
				mx = max(mx,cnt);
			}
		}
		cout << mx << endl;
	}
}

Measured memory_bytes: 968
#include <stdio.h>
#define MAX 101

int main(void){
  int N,count[MAX]={0},i,max=1;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    if(i % 64 == 0){
      count[i] = 6;
    }
    else if(i % 32 == 0){
      count[i] = 5;
    }
    else if(i % 16 == 0){
      count[i] = 4;
    }
    else if(i % 8 == 0){
      count[i] = 3;
    }
    else if(i % 4 == 0){
      count[i] = 2;
    }
    else if(i % 2 == 0){
      count[i] = 1;
    }
  }
  for(i=2;i<=N;i++){
    if(count[max] < count[i]){
      max = i;
    }
  }
  printf("%d",max);
  return 0;
}

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

int main()
{
  ll N, P;
  scanf("%lld %lld", &N, &P);
  if (N == 1)
  {
    cout << P << endl;
    return 0;
  }
  if (N * N > P)
  {
    cout << 1 << endl;
    return 0;
  }
 
  ll O = P;
  for (ll i = 2; i * i <= P + 2; i++)
  {
    ll j = i;
    while (P % j == 0)
    {
      P /= j;
      prime[j]++;
    }
  }
  if (O == P)
  {
    cout << 1 << endl;
    return 0;
  }
  if (P != 1 && P <= 100000)
    prime[P]++;

  ll ans = 1;
  for (ll i = 2; i * i <= O + 2; i++)
  {
    if (prime[i] >= N)
    {
      int num = prime[i] / N;
      ll nnum = 1;
      rep(j, num) nnum *= i;
      ans *= nnum;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n = int(input())
counter = 0
def dfs(num):
    global counter
  
    if num != "" and int(num)>n:return
    if "3"in num and "5" in num and "7" in num :counter+=1
    dfs(num+"7")
    dfs(num+"5")
    dfs(num+"3")
    
    

    


    
    
  

dfs("")  
print(counter)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 1e5 + 5;
int n, k;
int a[MXN], b[MXN], c[MXN];
int dp[MXN][4];

int Dp(int d, int lst) {
    if(d == n) return 0;
    if(dp[d][lst] != -1) return dp[d][lst];
    int ans = 0;
    if(lst != 0) ans = Dp(d + 1, 0) + a[d];
    if(lst != 1) ans = max(ans, Dp(d + 1, 1) + b[d]);
    if(lst != 2) ans = max(ans, Dp(d + 1, 2) + c[d]);
    return dp[d][lst] = ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp, -1, sizeof dp);
    cout << Dp(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 11044
#include <bits/stdc++.h>
using namespace std;
#define N 55555
bool prime[N + 5] = {0};

void sprime() {
  prime[0] = 1;
  prime[1] = 1;
  for(int i = 2; i * i <= N; ++i)
    if(!prime[i])
      for(int j = 2; i * j <= N; ++j) prime[i * j] = 1;
}

int n;
vector<int> v;

int main() {
  sprime();
  for(int i = 1; i <= N; i += 5)
    if(!prime[i]) v.push_back(i);
  cin >> n;
  for(int i = 0; i < n; ++i) {
    if(i != 0) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int N=IN(),A,B,C,Q;static int count[100000]={0};static long long sum=0;
  while(N--){A=IN();count[A-1]++;sum+=A;}
  Q=IN();
  while(Q--)
  {
    B=IN(),C=IN();
    sum+=1ll*count[B-1]*(C-B);
    count[C-1]+=count[B-1];
    count[B-1]=0;
    printf("%lld\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1964
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    ld x;std::cin>>x;
    std::cout<<x*6.28318530717958623200<<'\n';
}


Measured memory_bytes: 3796
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<unordered_map>
#include<stack>
#include<chrono>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define val         1000000007
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define PI          acos(-1.0)
#define f(i,n)		for(ll i=0;i<n;i++)
#define m(a)		memset(a,0,sizeof(a))
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld ",a)
using namespace std;
int d[201][201][201];
int gcd(ll a, ll b, ll c)
{
	if (a > b)
		swap(a, b);
	if (b > c)
		swap(b, c);
	if (d[a][b][c] != 0)
		return d[a][b][c];
	int x = 0;
	x = a;
	if(x==1)
		return d[a][b][c] = x;
	if (a % x == 0 && b % x == 0 && c % x == 0)
	{
		d[a][b][c] = x;
		return x;
	}
	if (b % x != 0)
		b = b % x;
	if (c % x != 0)
		c = c % x;
	return d[a][b][c]=gcd(a, b, c);
}
int main()
{
	FastIO;

	int  b[3], r, j,i,s, k, l, m, n, t;
	cin >> k;
	s = 0;
	for (i = 1; i <= k; i++)
	{
		for (j = i; j <= k; j++)
		{
			for (l = j; l <= k; l++)
			{
			   // cout<<i<<" "<<j<<" "<<l<<endl;
				if(i==j && j== l)
				s = s + gcd(i, j, l);
				else if(i==j || j==l || l==i)
                    s=s+3*gcd(i,j,l);
                else
                    s=s+6*gcd(i,j,l);

			}
		}
	}
	cout << s << endl;
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int max = 0;
		for(int i =0 ; i < n ;i++){
			a[i] = sc.nextInt();
			max = Math.max(a[i], max);
		}
		
		int gcd = gcd(a);
//		System.out.println(gcd+" "+Arrays.toString(a));
		
		System.out.println(k<=max && k%gcd==0?"POSSIBLE":"IMPOSSIBLE");
	}
	
	int gcd(int[] arr){
		int min = arr[0];
		for(int i = 1 ; i < arr.length ; i++){
			if(arr[i]==0){
				continue;
			}
			min = Math.min(min, arr[i]);
			if(arr[0] > arr[i]){
				if(arr[0] % arr[i] != 0){
					for(int j =0 ;j < arr.length ;j++){
						if(j != i){
							arr[j] = arr[j]%arr[i];
						}
					}
					return gcd(arr);
				}
			}else{
				if(arr[i] % arr[0] != 0){
					for(int j =1 ;j < arr.length ;j++){
						if(j != 0){
							arr[j] = arr[j]%arr[0];
						}
					}
					return gcd(arr);
				}
			}
		}
		return min;
	}
}


Measured memory_bytes: 50576
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
  string a, b ;
  cin >> a >> b ;
  b.pop_back( ) ;
  cout << (a==b?"Yes":"No") << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
    sol( );
  }
}

Measured memory_bytes: 3620
n=int(input())
t=list(map(int,input().split()))
m=int(input())
juice=[]
for i in range(m):
	juice.append(list(map(int,input().split())))

for i in range(m):
	ans=0
	for j in range(n):
		if j==juice[i][0]-1:
			ans+=juice[i][1]
		else:
			ans+=t[j]
	print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
# include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli a, b;
    cin>>a>>b;
    b *= 2;
    a -= b;
    a = max(a, 0ll);
    cout<<a<<endl;
    return ;
}
/*
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

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

    int max_count = 0;
    int count = 0;
    for (auto s : S) {
        if (s == 'R') {
            count++;
        } else {
            max_count = std::max(count, max_count);
            count = 0;
        }
    }
    max_count = std::max(count, max_count);
    std::cout << max_count << std::endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int n;
    bool g[101][101] = {};
    cin >> n;
    rep(i,n) {
        int u,k;
        cin  >> u >> k;
        rep(j,k) {
            int tmp;
            cin >> tmp;
            g[u][tmp] = 1;
        }
    }
    FOR(i,1,n+1) {
        FOR(j,1,n+1) {
            cout << g[i][j];
            if(j != n) cout << " "; 
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 3096