akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int x; cin >> x;
    int ans = 0;
    ans += (x/500)*1000;
    x = x - (x/500)*500;
    ans += (x / 5) * 5;
    cout << ans << endl;
}

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

/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
void solve(ll a[],ll n){
    vector<ll>dp(n,0);
    dp[1]=dp[0]+abs(a[0]-a[1]);
    for(ll i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
       // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}


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

    }
     solve(a,n);
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  string n;
  cin >> n;
  string ans = "No";
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2)) ans = "Yes";
  else if (n.at(1) == n.at(2) && n.at(2) == n.at(3)) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	ll h; cin >> h;
	vector<ll> A(n), B(n);
	rep(i,n){cin >> A[i] >> B[i];}
	ll a = max(A);
	sort(all(B), greater<int>());
	ll ans = 0;
	for(ll b:B){
		if(h <= 0){
			cout << ans << endl;
			return 0;
		}
		if(b < a){
			break;
		}
		ans++;
		h-=b;
	}
	if(h<=0) cout << ans << endl;
	else cout << ans + (h+a-1)/a << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
typedef long long ll;
using namespace std;

int main()
{
	int a,b,c = 0,d = 0,e=0;
	cin >> a >> b;
	if( b > 1 ){
		while( b > c )
		{
			if( b - c <= a)
			{
				c = c + a;
				e++;
			}else{
				c = c + ( a - 1 );
				e++;
			}
		}
	}else if( b == 1 )
	{
		e = 0;
	}
	cout << e << endl;

	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

template<int M>
class Combination
{
public:
  int n;
  vector<int> fac, finv;

  Combination(int n_) : n(n_), fac(n_), finv(n_)
  {
    fac[0] = 1;
    for(int i = 1; i < n; i++) fac[i] = fac[i-1]*i%M;
    finv[n-1] = pow(fac[n-1], M-2);
    for(int i = n-1; i > 0; i--) finv[i-1] = finv[i]*i%M;
  }

  int pow(int a, int b)
  {
    if(b == 0) return 1; 
    return pow(a*a%M, b/2)*(b%2?a:1)%M;
  }

  int C(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M*finv[b]%M;
  }

  int P(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M; 
  }

  int H(int a, int b){
    if(a == 0 and b == 0) return 1;
    return C(a+b-1, b);
  }
};

signed main(){
	Combination<mod> comb(100000);

	int n, k;
	cin >> n >> k;

	int b = k;
	int r = n-k;	

	rep(i, 1, k+1){
		int ans;
		if(r-(i-1) < 0) ans = 0;
		else{
			ans = comb.fac[b-1];
			ans = ans*comb.pow(comb.fac[b-i], mod-2)%mod;
			ans = ans*comb.pow(comb.fac[i-1], mod-2)%mod;
			ans = ans*comb.fac[r+1]%mod;
			ans = ans*comb.pow(comb.fac[r-i+1], mod-2)%mod;
			ans = ans*comb.pow(comb.fac[i], mod-2)%mod;
		}
		cout << ans << endl;
	}

	return 0;
}


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

int main () {
  int A, B;
  cin >> A >> B;
  
  int ans1 = A+B;
  int ans2 = A-B;
  int ans3 = A*B;
  if ((ans1 > ans2) && (ans1 > ans3))  cout << ans1 << endl;
  else if (ans2 > ans3) cout << ans2 << endl;
  else cout << ans3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

const int MAX_N = 101, MAX_K = 1e5 + 1;

ll dp[MAX_N][MAX_K];

int main() {
    int N, K; cin >> N >> K;
    ll a[N];
    rep(i, N) cin >> a[i];
    dp[0][0] = 1;
    rep(i, N) {
        for(int j = 0; j <= K; ++j) {
            if(a[i] >= j){
                if(j - 1 >= 0)dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) %MOD;
                else dp[i + 1][j] = dp[i][j];
            }else if(a[i] < j){
                dp[i + 1][j] = (MOD + dp[i + 1][j - 1] + dp[i][j] - dp[i][j - a[i] - 1])%MOD;
            }
        }
    }

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


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

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

    int N;
    cin >> N;
    int A[N], B[N], C[N - 1];
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> B[i];
    for (int i = 0; i < N - 1; i++)
        cin >> C[i];

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += B[A[i] - 1];
        if (i > 0 && A[i] - A[i - 1] == 1)
            sum += C[A[i - 1] - 1];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
m = Array.new(n) # adjacency matrix
for i in 0..n-1
  m[i] = Array.new(n,0)
end
for i in 0..n-1
  temp = gets.chomp.split(" ").map(&:to_i)
  if temp[1] != 0
    for j in 0..temp[1]-1
      m[i][temp[j+2]-1] = 1
    end
  end
end

q = [0] # queue
d = Array.new(n,-1)
d[0] = 0
while q.length > 0
  #p ["debug", q]
  cur = q.shift
  (0..n-1).each do |dst|
    if m[cur][dst] == 1 && d[dst] == -1
      d[dst] = d[cur] + 1
      q << dst
    end
  end
end

for i in 0..n-1
  print i+1, " ", d[i], "\n"
end

Measured memory_bytes: 8764
#include<iostream>
#include<vector>
#include <cmath>
#include <map>

using namespace std;


int main() {
	int n;
	cin >> n;
	map<int, long long> appear;
	map<long long, long long> ansers;
	vector<int> a(n);

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

		if (ansers.count(appear[a[i]]) == 0) {
			appear[a[i]] -= 1;

			for (auto itr = appear.begin(); itr != appear.end(); itr++) {
				long long tmp = itr->second;
				count += tmp * (tmp - 1) / 2;
			}
			appear[a[i]] += 1;
			ansers[appear[a[i]]] = count;

		}
		else {
			count = ansers[appear[a[i]]];
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 12288
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース
xxxxxxxxxx  0000000000 最初のsearchで
xoooooooxx  0111111100
xxoooooxxx  0011111000
xxxoooxxxx  0001110000
xxxxoxxxxx  0000100000
xxxxxxxxxx  0000000000
xxxxoxxxxx  0000200000
xxxoooxxxx  0002220000
xxoooooxxx  0022222000
xxxxxxxxxx  0000000000
*/
//main.cpp----------------------------
#define max_n 100

void solve();

ll n;
ll l[max_n*2+1];

int main() {
  cin >> n;
  rep(i, n*2) cin >> l[i];

  solve();

  return 0;
}

void solve() {

  sort(l, l+n*2);

  ll max = 0;
  for(int i=0; i<n*2; i+=2) {
    max += l[i];
  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = __int128_t;
// using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

istream& operator >>(istream &is, ll &a) {
    int64_t i;
    is >> i;
    a = i;
    return is;
}

ostream& operator <<(ostream &os, ll a) {
    auto i = (int64_t)a;
    os << i;
    return os;
}

string to_string(ll a) {
    string ret;
    while(a) {
        ll t = a % 10;
        a /= 10;
        ret += '0' + t;
    }
    reverse(ALL(ret));
    return move(ret);
}

// #define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

V<ll> pow_10(30, 1);
ll dummy0[20] = {};
ll dummy1[20] = {};
ll *cnt_perm = dummy0 + 10;
ll *cnt_perm_ms = dummy1 + 10;

ll calc(ll val, ll dl, ll ds) {
    ll *arr = (ds == 0 ? cnt_perm_ms : cnt_perm);
    if(dl == ds) return arr[0] * (val == 0);
    if(dl < ds) return val == 0;
    if(to_string(abs(val)).size() > dl + 1) return 0;
    ll mul = pow_10[dl] - pow_10[ds];
    ll ret = 0;
    for(ll j = -9; j <= 9; j++) {
        ll nd = val - mul * j;
        ll rec = calc(nd, dl - 1, ds + 1);
        ret += rec * arr[j];
    }
    return ret;
}

int main() {
    init_io();
    for(ll i = 0; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm[i - j]++;
    for(ll i = 1; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm_ms[i - j]++;
    ll D;
    cin >> D;
    for(ll i = 1; i < pow_10.size(); i++) pow_10[i] = pow_10[i - 1] * 10;
    ll ans = 0;
    for(ll d = 1; d <= 18; d++) ans += calc(-D, d, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		Set<String> insert = new HashSet<>();
		for (int i = 0; i < m; i++) {
			String in = sc.next();
			String input = sc.next();
			if (in.equals("insert")) {
				insert.add(input);
			}
			if (in.equals("find")) {
				if (insert.contains(input)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}

		}
	}
}



Measured memory_bytes: 209108
#include <bits/stdc++.h>
using namespace std;
#define INF 1000005
#define maxx 1000000000000

int n,w;
long long weight[INF];
long long value[INF];
long long mem[105][INF];

long long rec(int pos,int cost)
{
    if(pos==n) return 0;
    if(mem[pos][cost]!=-1) return mem[pos][cost];
    long long now=0;
    if(cost+weight[pos]<=w)
    {
        now=value[pos]+rec(pos+1,cost+weight[pos]);
    }
    return mem[pos][cost]=max(now,rec(pos+1,cost));
}

int main()
{
    memset(mem,-1,sizeof(mem));
    scanf("%d%d",&n,&w);
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",&weight[i],&value[i]);
    }
    long long ans=rec(0,0);
    printf("%lld\n",ans);
}


Measured memory_bytes: 823552
#!/usr/bin/env python3
import sys

def gcd(A,B):
    while B:
        A, B = B, A % B

    return A

def solve(A: int, B: int):
    print( (A*B) // gcd(A, B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

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

using namespace std;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;

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

    vector<int> H(N);
    rep(i, N) cin >> H.at(i);

    int max_combo = 0;
    int combo = 0;

    rep(i, N) {
        if (i == 0) {
            continue;
        }

        if (H.at(i) <= H.at(i - 1)) {
            combo++;
            max_combo = max(combo, max_combo);

        } else {
            max_combo = max(combo, max_combo);
            combo = 0;
        }
    }

    cout << max_combo << endl;
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(lint i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(Range(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LLONG_MAX)
# define LINT_MIN (LLONG_MIN)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class T> void Print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void Print(vector<vector<T>> &df) { for (auto& vec : df) { Print(vec); } }

template <class Type> inline constexpr Type Pow5(Type x)
{ 
    return x * x * x * x * x;
}

int main()
{
    lint X; cin >> X;
    range_for (A, -118, 119) range_for (B, -119, 118)
    {
        if (Pow5(A) - Pow5(B) == X)
        {
            Print(A, B);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
typedef long long ll;
int a[200000], b[200000];
ll bsum[200010] = {0};
int binarySearch(int key, int num) {
	int ok = -1, ng = num, mid;
	while (ng - ok > 1) {
		mid = (ng + ok) / 2;
		if (bsum[mid] <= key)
			ok = mid;
		else
			ng = mid;
	}
	return ng;
}
int main() {
	int n, m, k;
	int ans = 0;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
		// b[i]まで読んだ時の所要時間
		if (i != 0)
			bsum[i] = bsum[i - 1] + b[i];
		else {
			bsum[i] = b[i];
		}
	}
	// for (int i = 0; i < m; i++) {
	// 	printf("%lld ", bsum[i]);
	// }
	// printf("\n");
	ll sum = 0;
	for (int i = -1; i < n; i++) {
		if (i != -1)
			sum += a[i];
		if (sum > k) {
			break;
		}
		int r = binarySearch(k - sum, m);
		if (i + 1 + r > ans) {
			ans = i + 1 + r;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4852
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					ans++;
			}
		}
	}
}
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

#define int long long

signed main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    static int dp[4000][4000];  // (全体の量, 水の量)
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 0; i <= F; i++) {
        for (int j = 0; j <= F; j++) {
            if (dp[i][j] < 0) continue;
            if (i + 100 * A <= F) dp[i + 100 * A][j + 100 * A] = max(dp[i + 100 * A][j + 100 * A], dp[i][j]);
            if (i + 100 * B <= F) dp[i + 100 * B][j + 100 * B] = max(dp[i + 100 * B][j + 100 * B], dp[i][j]);
            if (i + C <= F and j * E >= 100 * (dp[i][j] + C)) dp[i + C][j] = max(dp[i + C][j], dp[i][j] + C);
            if (i + D <= F and j * E >= 100 * (dp[i][j] + D)) dp[i + D][j] = max(dp[i + D][j], dp[i][j] + D);
        }
    }
    int all = 100, sugar = -1;
    for (int i = 0; i <= F; i++) {
        for (int j = 0; j <= F; j++) {
            if (dp[i][j] < 0) continue;
            if (sugar * i < dp[i][j] * all) {
                all = i;
                sugar = dp[i][j];
            }
        }
    }
    cout << all << " " << sugar << endl;

    /*
    int a, b;
    while (cin >> a >> b, a | b) {
        cout << dp[a][b] << endl;
    }
    */

    return 0;
}


Measured memory_bytes: 125184
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll s, c;
    cin >> s >> c;

    if (s * 2 >= c) {
        cout << c / 2 << endl;
    } else {
        ll ans = s;
        c -= (2 * s);
        s -= s;
        assert(c >= 0);
        ll add = c / 4;
        ans += add;
        cout << ans << endl;
    }

}


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

int main() {

	int N, K;

	cin >> N >> K;

	if (N >= 2 * K - 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	

	return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class BinaryIndexedTree
{
private:
    typedef int T;
    int n;
    vector<T> data;
public:
    // コンストラクタ
    BinaryIndexedTree(int n){
        this->n = n;
        data.assign(n+1, 0);
    }
    // k番目の要素にxを加算する
    void add(int k, T x){
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    // 区間[0,k)の総和を返す
    T sum(int k){
        T ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    // 区間[a,b)の総和を返す
    T sum(int a, int b){
        return sum(b) - sum(a);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int i=0; i<n; ++i){
        cin >> c[i];
        -- c[i];
    }

    vector<tuple<int, int, int> > v(q);
    for(int i=0; i<q; ++i){
        int l, r;
        cin >> l >> r;
        -- l;
        v[i] = make_tuple(l, r, i);
    }
    sort(v.begin(), v.end());

    int k = q - 1;
    vector<int> ans(q);
    vector<int> next(n, -1);
    BinaryIndexedTree bit(n);
    for(int i=n-1; i>=0; --i){
        bit.add(i, 1);
        if(next[c[i]] != -1)
            bit.add(next[c[i]], -1);
        next[c[i]] = i;

        while(k >= 0 && get<0>(v[k]) == i){
            auto [l, r, index] = v[k];
            ans[index] = bit.sum(l, r);
            -- k;
        }
    }

    for(int i=0; i<q; ++i)
        cout << ans[i] << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < S.size() / 2; i++) {
    if (S[i] != S[S.size() - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for (int i = 0; i < (S.size()-1)/4; i++) {
    if (S[i] != S[(S.size()-1)/2-1-i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for (int i = (S.size()+3)/2-1; i < S.size(); i++) {
    if (S[i] != S[(S.size()-1)-(i-((S.size()+3)/2-1))]) {
      cout << "No" << endl;
      return 0;
    }
  }
    
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

x = [[-1] for _ in range(h*w+d+1)]
m = []
for i in range(h):
    for j in range(w):
        x[a[i][j]] = [i, j]
        m.append([a[i][j], i, j])
m.sort()
visit = [[-1 for _i in range(w)] for _j in range(h)]

for pos, xx, yy in m:
    if visit[xx][yy] < 0:
        visit[xx][yy] = 0
        while x[pos+d][0] >= 0:
            g, h = x[pos+d]
            visit[g][h] = visit[xx][yy] + abs(g-xx)+abs(h-yy)
            xx = g
            yy = h
            pos = a[xx][yy]
for l, r in lr:
    print(visit[x[r][0]][x[r][1]]-visit[x[l][0]][x[l][1]])

Measured memory_bytes: 103892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](long a, long b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll k;
  string s;
  cin >> k >> s;
  if(s.size()>k){
    rep(i,k){
      cout <<s[i];
    }
    co("...");
  }else{
    co(s);
  }

  return 0;
}


Measured memory_bytes: 3604
module kkk
  sub main()
    
    dim AB
    dim i as long
    dim j as long
    dim k as long
    
    dim a as long
    
    AB = console.readline()
    AB = split(AB, " ")
    
    j = AB(0)
    i = AB(1)
    
    do
      k = j mod i
      if k = 0 then exit do
      j = i
      i = k
    loop
        
        a = AB(0)*AB(1)/i
        
        console.writeline(a)
        
      end sub
    end module

Measured memory_bytes: 20560
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  double a,b,c,d;
  cin >> c >> d >> a >> b;
  cout << setprecision(15);
  a+=b/60;
  a/=-6;b/=-30;
  a *= acos(-1);
  b *= acos(-1);
  a += (0.5*acos(-1));
  b += (0.5 * acos(-1));
  double ax= cos(a)*c;
  double ay = sin(a) * c;
  double bx = cos(b) * d;
  double by = sin(b) * d;

  double dist = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay-by));
  cout << dist;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


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

n, x =  [int(i) for i in raw_input().split()]
xx = [int(i) for i in raw_input().split()]

s = []
for i in xx:
    a = x - i
    if a < 0:
        s.append(-a)
    else:
        s.append(a)

import fractions
v = s[0]
for b in s[1:]:
    v = fractions.gcd(b, v)
print v


Measured memory_bytes: 11808
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n, h, w;
	cin >> n >> h >> w;
	int result = 0;
	for (int x = 0; x < n; x++)
		for (int y = 0; y < n; y++)
			if (x + w - 1 < n && y + h - 1 < n)
				result++;
	cout << result << endl;
}

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

int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        mp[p[i]]++;
    }

    if (mp[x] == 0) {
        cout << x << endl;
        return 0;
    }

    sort(p.begin(), p.end());

    int sa = 102, memo = 0, ans = 102, sa_memo = 0;
    for (int i = 0; i <= p[n - 1] + 1; i++)
    {
        if (mp[i] == 1) continue;
        memo = sa;
        
        sa = min(sa, abs(x - i));
        if (memo != sa) {
            sa_memo = abs(x - (i - 1));
            if (ans < i && sa == sa_memo) break;
            ans = i;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, T: int):
    print(math.floor(T/A)*B)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, B, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
cnt = [1] * 110
for num in range(1, N + 1):
    for i in range(2, 100):
        while num % i == 0:
            cnt[i] += 1
            num /= i

ans = 0
for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            if i == j or j == k or k == i:
                continue
            if cnt[i] >= 3 and cnt[j] >= 5 and cnt[k] >= 5:
                ans += 1

ans /= 2

for i in range(N + 1):
    for j in range(N + 1):
        if i == j:
            continue
        if cnt[i] >= 5 and cnt[j] >= 15:
            ans += 1
        if cnt[i] >= 3 and cnt[j] >= 25:
            ans += 1
    if cnt[i] >= 75:
        ans += 1

print ans

Measured memory_bytes: 3320
// Created by abhay
#include <bits/stdc++.h>
#define ll long long
#define mq 1000000007
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl; 
}


Measured memory_bytes: 256
M,D=map(int,input().split())
# print(M,D)
 
count = 0
for ii in range(1,M+1):
    
    for i in range (22, D + 1):
        #print(i)
        d1 = i % 10
        d2 = i // 10
        
        if d1 < 2 or d2 < 2:
            continue
        
        if ii == d1 * d2:
            count = count + 1
        
        
 
print(count)

Measured memory_bytes: 2940
N, D = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(N)]

count = 0
for item in P:
  dis_2 = item[0] ** 2 + item[1] ** 2
  if dis_2 <= D**2:
    count += 1

print(count)

Measured memory_bytes: 45372
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"1234567876
" => r"34",

r"35753
" => r"0",

r"1111111111
" => r"642"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: String
    }

    let mut minimum = std::i32::MAX;
    for i in 0..s.len() - 2 {
        let mut str1 = "".to_string();
        for (j, c) in s.chars().enumerate() {
            if j >= i && j < i + 3 {
                str1.push(c);
            }
        }
        let stri: String = String::from(str1);
        let num: i32 = stri.parse().unwrap();

        minimum = cmp::min(minimum, (753 - num).abs());
    }

    minimum.to_string()
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<double, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


ll solve1(ll i, ll j, ll l) {

    ll ans = 0;

    ll ilj = min({i, l, j});

    ll iljc = ilj * 3;
    ans += iljc;

    i -= ilj;
    l -= ilj;
    j -= ilj;

    ll l2 = (l / 2) * 2;
    ll j2 = (j / 2) * 2;
    ll i2 = (i / 2) * 2;

    ans += l2 + j2 + i2;
    return ans;

}


ll solve2(ll i, ll j, ll l) {

    ll ans = 0;

    ll ilj = min({i, l, j});
    if (ilj == 0) return 0;
    ilj--;

    ll iljc = ilj * 3;
    ans += iljc;

    i -= ilj;
    l -= ilj;
    j -= ilj;

    ll l2 = (l / 2) * 2;
    ll j2 = (j / 2) * 2;
    ll i2 = (i / 2) * 2;

    ans += l2 + j2 + i2;
    return ans;

}

int main() {

    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;

    ll ans = 0;
    ans += o;

    ll k = max(solve1(i, j, l), solve2(i, j, l));

    ans += k;

    cout << ans << endl;


}

Measured memory_bytes: 3632
# ABC144c


def main():
    import sys
    import math
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    # map(int,input().split())
    n = int(input())
    ans = 10**12
    for i in range(math.ceil(math.sqrt(n))+1, 0, -1):
        if n % i == 0:
            ans = min(ans, i+n//i)
    print(ans-2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n,a,*l=map(int,open(0).read().split())
R=2500
dp=[[0]*R*2 for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
  for s in range(-R,R):
    dp[i+1][s]=dp[i][s]+dp[i][s-l[i]+a]
print(dp[n][0]-1)

Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
const long long inf=0x3f3f3f3f;
const double eps=1e-6;
const long long mod=1000000007;
typedef long long ll;
struct matrix{
	int n=50,a[55][55]={};ll k;
	void input(){
		scanf("%d%lld",&n,&k);
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				scanf("%d",&a[i][j]);
	}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=0;i<n;i++){
			for(int k=0;k<n;k++){
				for(int j=0;j<n;j++){
					ret.a[i][j]+=(1ll*a[i][k]*b.a[k][j]%mod);
					ret.a[i][j]%=mod;
				}
			}
		}
		return ret;
	}
	matrix fastpow(matrix x,ll y){
		if(y==1)return x;
		matrix ret=fastpow(x,y>>1);
		ret=ret*ret;
		if(y&1)ret=ret*x;
		return ret;
	}
	int answer(){
		if(k==0)return n;
		matrix mat=fastpow(*this,k);
		ll ans=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				ans=(ll)(ans+mat.a[i][j])%mod;
		return ans%mod;
	}
}graph;
int main(){
	ios::sync_with_stdio(false);
	graph.input();
	printf("%d\n",graph.answer());
	return 0;
}

Measured memory_bytes: 3968
N = int(input())
h = list(map(int,input().split()))

memo = [-1]*N

memo[0] = 0
memo[1] = abs(h[1]-h[0])
for i in range(2,N):
    a = memo[i-1] + abs(h[i]-h[i-1])
    b = memo[i-2] + abs(h[i]-h[i-2])
    memo[i] = min(a,b)
print(memo[N-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

vector<bool> eratos(int n){
    vector<bool> primes(n + 1, true);
    primes[0] = primes[1] = false;
    for(int i = 2; i * i <= n; i++){
        if(!primes[i]) continue;
        for(int j = i * i; j <= n; j += i){
            primes[j] = false;
        }
    }
    return primes;
}

signed main(){
    int n;
    cin >> n;
    vector<int> ans;
    vector<bool> vec = eratos(55555);
    for(int i = 1; i <= 55555; i += 5){
        if(vec[i]) ans.emplace_back(i);
    }
    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int main(){
	int k,m=0,n;
	n=read();
	for(register int i=1;i<=n;i++){
		if(i<=9)m++;
		if(i>=100 && i<=999)m++;
		if(i>=10000 && i<=99999)m++;
		if(i>=1000000 && i<=9999999)m++;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import itertools

N = int(stdin.readline().rstrip())
F = []

for i in range(N):
    f = [int(x) for x in stdin.readline().rstrip().split()]
    F.append(f)
    
P = []
for i in range(N):
    p = [int(x) for x in stdin.readline().rstrip().split()]
    P.append(p)

ans = -10**9
for i in itertools.product([0,1],repeat=10):
    if sum(i) == 0:
        continue
    score = 0
    for ind,f in enumerate(F):
        num = sum([j*k for j,k in zip(i,f)])
        score += P[ind][num]
    ans = max(ans,score)
    
print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {
	public void exec() throws IOException {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		for(int i=1; true; i++){
			int x = input.nextInt();
			if(x == 0){
				break;
			}else{
				out.println(new StringBuilder("Case ").append(i).append(": ").append(x));
			}
		}
		out.flush();
		input.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
}

Measured memory_bytes: 41480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll H,W;
    cin >> H >> W;
    if(H==1||W==1){
        cout << 1 << endl;
        return 0;
    }
    if(H*W%2==0) cout << H*W/2 << endl;
    else cout << H*W/2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int ans = 1;
  vector<int> d(110);
  
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort (d.begin(), d.end());
  reverse (d.begin(), d.end());
  
  int temp = d.at(0);
  
  for (int j = 1; j < N; j++) {
    if (d.at(j) < temp) {
      ans++;
      temp = d.at(j);
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn split_whitespace(line: String) -> Vec<u32> {
    line.split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

fn main() {
    read_line();
    let sizes = split_whitespace(read_line());

    let max = sizes
        .windows(2)
        .map(|w| w[0] >= w[1])
        .scan(0, |st, x| {
            *st = if x { *st + 1 } else { 0 };
            Some(*st)
        })
        .max()
        .unwrap_or(0);
    println!("{}", max);
}


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

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int compress(vector<ll>& unzip, map<ll, int>& zip) {
    sort(unzip.begin(), unzip.end());
    unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
    for (int i = 0; i < unzip.size(); i++) {
        zip[unzip[i]] = i;
    }
    return unzip.size();
}

template<typename T>
struct BIT{
    private:
        vector<T> array;
        const int n;
    public:
        BIT(int _n) : array(_n + 1, 0), n(_n) {}
        T sum(int i){
            T s = 0;
            while(i > 0){
                s += array[i];
                i -= i & -i;
            }
            return s;
        }
        T sum(int i, int j){
            T ret_i = sum(i-1);
            T ret_j = sum(j);
            return ret_j - ret_i;
        }
        void add(int i, T x){
            while(i <= n){
                array[i] += x;
                i += i & -i;
            }
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<int> com(q);
    vector<ll> a, b;
    rep(i,q){
        cin >> com[i];
        if(com[i] == 1){
            ll x, y;
            cin >> x >> y;
            a.push_back(x);
            b.push_back(y);
        }
    }
    vector<ll> unzip = a;
    map<ll, int> zip;
    int sz = compress(unzip, zip);
    int cnt = 0, idx = 0;
    ll bsum = 0;
    BIT<int> bit1(sz);
    BIT<ll> bit2(sz);
    rep(i,q){
        if(com[i] == 1){
            int ai = zip[a[idx]];
            bit1.add(ai + 1, 1);
            bit2.add(ai + 1, a[idx]);
            bsum += b[idx];
            idx++;
            cnt++;
        }
        else{
            int ng = 0, ok = sz;
            while(ok - ng > 1){
                int mid = (ok + ng) / 2;
                int cmp = bit1.sum(mid);
                if(cmp >= (cnt + 1) / 2) ok = mid;
                else ng = mid;
            }
            ll x = unzip[ok - 1];
            int foo = bit1.sum(ok);
            int bar = cnt - foo;
            ll uku = bit2.sum(ok);
            ll ans = (bit2.sum(sz) - uku) - x * bar + x * foo - uku + bsum;
            cout << x << " " << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 13164
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int a, b;
    char op;
    while(1)
    {
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    else if(op=='-')cout<<a-b<<endl;
    else if(op=='*')cout<<a*b<<endl;
    else if(op=='/')cout<<a/b<<endl;
    else if(op=='?')break;
    }
    return 0;

}


Measured memory_bytes: 3080