akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 


int main()
{
	fastIO;
	string s,t;
	cin >> s >> t;
	int suc = 1;
	rep(i,0,SZ(s)) {
		if(s[i] != t[i]) suc = 0;
	}	
	if(suc) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.buffer.readline
mod = 10 ** 9 + 7

def main():
	n, m = map(int, input().split())
	*s, = map(int, input().split())
	*t, = map(int, input().split())
	dp = [[1] * (m + 1)] + [[1] + [0] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] * (s[i] != t[j])) % mod
	print(dp[n][m])

if __name__ == '__main__':
	main()

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

using namespace std;

using ll = long long;

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

int main()
{
    int K,X;
    cin >> K >> X;

    for(int i=-K+1;i<K;i++)
    {
        cout << X+i;
        if(i!=K-1)
        {
            cout << ' ';
        }
    }

    cout << endl;

    return 0;
}

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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

int n;
string s;
long long int a[26]={0};

int main() {
    cin>>n;
    cin>>s;
    long long int ans=0;
    for(int i=0;i<n;i++){
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(a[i]!=0){
            if(ans==0){
                ans=a[i]+1;
            }else{
            ans=(ans*(a[i]+1))%1000000007;
            }
        }
    }
    cout<<ans-1;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	int t = 0, x = 0, y = 0;
	for(int i = 0 ; i < N ; i++){
			int t1, x1, y1;  cin >> t1 >> x1 >> y1;
			int dist = abs(x1 - x) + abs(y1 - y);
			if(t1 - t < dist || (dist - (t1 - t)) % 2){
					cout << "No" << endl;
					return 0;
			}
	}

	cout << "Yes" << endl;
	

	return 0;
}


Measured memory_bytes: 256
# ABC074C - Sugar Water
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100

# default values
#x, y = (min(a, b) * 100 + min(c, d)), min(c, d)
x, y = min(a, b) * 100, 0
dens = y / x


# exhaustive search
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
#                if k == 0 and l == 0:
#                    continue
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  # compare to e (the max density)
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;

template <typename T> T gcd(T a, T b){a = abs(a); b = abs(b); if(a<b) swap(a,b); while(b>0){a %= b; swap(a,b);} return a;}
template <typename T> T lcm(T a, T b){return (1LL * a * b) / gcd(a,b);}

int N,K;
vector<int> a;

bool dpL[5001][5001];
bool dpR[5001][5001];

bool judge(int x){
  if(a[x] >= K) return true;

  //cout << "a[" << x << "] = " << a[x] << endl;
  //cout << x-1 << " " << N-x-1 << endl;
  bool r = false;
  FOR(i,K-a[x],K){
    REPE(j,i){
      if(dpL[x][j] && dpR[N-x-1][i-j]){
	//cout << j << " " << i-j << endl;
	r = true; break;
      }
    }
    if(r) break;
  }
  return r;
}

int binary_search(int lower, int upper){
  //cout << lower << "," << upper << endl;
  if(lower == upper) return lower;
  if(lower+1 == upper){
    bool l = judge(lower), u = judge(upper);
    if(l && u) return lower;
    if((!l) && (!u)) return N;
    return upper;
  }
  int mid = (lower+upper)/2;

  if(judge(mid))
    binary_search(lower, mid);
  else
    binary_search(mid, upper);
}

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

  cin >> N >> K;
  a.resize(N);
  REP(i,N) cin >> a[i];
  sort(ALL(a));  

  REPE(i,5000) REPE(j,5000) dpL[i][j] = (j==0);  
  FORE(i,1,N)
    FORE(j,1,K)
      if(j < a[i-1]) dpL[i][j] = dpL[i-1][j];
      else dpL[i][j] = dpL[i-1][j] || dpL[i-1][j-a[i-1]];

  REPE(i,5000) REPE(j,5000) dpR[i][j] = (j==0);  
  FORE(i,1,N)
    FORE(j,1,K)
      if(j < a[N-i]) dpR[i][j] = dpR[i-1][j];
      else dpR[i][j] = dpR[i-1][j] || dpR[i-1][j-a[N-i]];
  /*
  REPE(i,N){
    REPE(j,K) cout << dpL[i][j] << " ";
    cout << endl;
  }
  cout << endl;
  REPE(i,N){
    REPE(j,K) cout << dpR[i][j] << " ";
    cout << endl;
    }*/

  
  //REP(i,N) cout << a[i] << " "; cout << endl;
  //REP(i,N) cout << judge(i) << " "; cout << endl;
  
  cout << binary_search(0, N-1) << endl;
  
  return 0;
}


Measured memory_bytes: 49152
#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>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


int main(){
  int n; ll K; cin >> n >> K; ll p[n]; ll c[n];
  rep(i, n){
    cin >> p[i]; p[i]--;
  }
  rep(i, n) cin >> c[i];
  ll tmp[n];
  rep(i, n) tmp[i] = -longinf;
  rep(i, n){
    ll syuki = 0; int now = i; int cnt = 0; 
    while(now!=i || cnt==0){
      syuki+=c[p[now]]; now = p[now]; cnt++;
    }
    if(syuki<=0 || K<cnt){
      ll po = 0; now = i;
      rep(j, min(K, (ll)cnt)){
        po+=c[p[now]]; now = p[now]; tmp[i] = max(tmp[i], po); 
      }
    }
    else{
      ll begin = K-cnt; ll po = syuki*((K-cnt)/cnt); int kazu = cnt + K%cnt; now = i;
      rep(j, kazu){
        po+=c[p[now]]; now = p[now]; tmp[i] = max(tmp[i], po);
      }
    }
  }
  ll ans = -longinf;
  rep(i, n){
    ans = max(ans, tmp[i]);
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 3776
import numpy as np
input_line = map(int,raw_input().split(" "))
H = input_line[0]
W = input_line[1]
N = int(raw_input())
input_line = raw_input()
a = map(int,input_line.split(" "))
square = np.zeros((H,W))
k = 0
for j in range(H):
	for i in range(W):
		if j % 2 == 0:
			square[j][i] = k+1
			a[k] -= 1
		else :
			square[j][W-i-1] = k+1
			a[k] -= 1
		if a[k] == 0:
			k += 1

txt = ""
for s in square:
	for number,ss in enumerate(s):
		if number != len(s) - 1:
			txt += str(int(ss)) + " "
		else:
			txt += str(int(ss))
	print txt
	txt = ""


Measured memory_bytes: 19176
n = int(input())
x = [list(map(int, input().split())) for i in range(n)]
y = []
y = sorted(x, key = lambda x:x[1])
a = 0
for i in y:
    a += i[0]
    if a > i[1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 48660
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
    int W , H , x , y;
    cin >> W >> H >> x >> y;
    cout << double(W) * double(H) / 2 << " " << (x + x == W && y + y == H) << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b; cin >> a >> b;
    cout << (a+b) % 24 << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

slen = len(s)
tlen = len(t)
arr = []
upto = slen - tlen + 1 

for i in range(upto):
    c = (s[i:i+tlen])
    d = 0
    for j in range(tlen):
        if t[j] != c[j]:
            d += 1
    arr.append(d)
    
print(min(arr))

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

using namespace std;

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

  string s, t;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (i & 1) t += 'p';
    else t += 'g';
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'g' && t[i] == 'p') ans++;
    if (s[i] == 'p' && t[i] == 'g') ans--;
  }
  
  cout << ans << '\n';

  return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;

const int maxn = 1e5 + 10;
vector<int> adj[maxn];
int par[maxn], vis[maxn], ans[maxn];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; ++ i)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	queue<int> q;
	par[1] = -1;
	q.push(1);
	vis[1] = 1;
	while(!q.empty())
	{
		int v = q.front(); q.pop();
		for(int u : adj[v])
		{
			if(vis[u]) continue;
			q.push(u);
			par[u] = v;
			vis[u] = 1;
		}
	}
	
	bool ok = true;
	for(int i = 1; i <= n; ++ i)
		ok &= (par[i] != 0);
	
	if(!ok)
	{
		cout << "No\n";
	}
	else
	{
		cout << "Yes\n";
		for(int i = 2; i <= n; ++ i)
			cout << par[i] << "\n";
		cout << '\n';
	}
	return 0;
}






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

using namespace std;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int num = a * 100 + b * 10 + c;
    if(num % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;
    if (S[1] == 'R') {
        out << 1 + (S[0] == 'R' ? 1 : 0) + (S[2] == 'R' ? 1 : 0) << endl;
    }
    else {
        out << std::max(S[0] == 'R' ? 1 : 0, S[2] == 'R' ? 1 : 0) << endl;
    }


    return 0;
}
#endif


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int p[10];
    int s[10][10];
    int k[10];
    bool use[10];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < 1 << n; i++) {
        memset(use, 0, sizeof(use));
        for (int j = 0; j < n; j++) {
            if (i >> j & 1)
                use[j] = true;
        }
        bool flag = true;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int l = 0; l < k[j]; l++) {
                if (use[s[j][l]] == true) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<vector<int>>A(2,vector<int>(N));
    int sum=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            int a;
            cin >> a;
            A[i][j]=a;
            if(i==1)sum+=a;
        }
    }
    sum+=A[0][0];
    int ans=sum;
    for(int i=0;i<N-1;i++){
        sum+=A[0][i+1]-A[1][i];
        ans=max(ans,sum);
    }
    cout  << ans << endl;


    return 0;
}

Measured memory_bytes: 256
using System;

public class Program {
  public static void Main(string[] args) {
    var str = Console.ReadLine();
    int n = int.Parse(str);
    int[] a = new int[n];
    var str2 = Console.ReadLine().Split();
    
    for (int i = 0; i < n; i++) {
      a[i] = int.Parse(str2[i]);
    }
    
    Array.Sort(a);
    
    for (int i = 0; i < n-1; i++) {
      if (a[i] == a[i+1]) {
        Console.WriteLine("NO");
        return ;
      }
    }
    
    Console.WriteLine("YES");
    
    
  }
}

Measured memory_bytes: 30940
#include <iostream>
#include <deque>

int main()
{
    int n;
    std::cin >> n;
    std::deque<int> dq;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        if (i & 1)
            dq.push_back(a);
        else
            dq.push_front(a);
    }

    bool rev = !(n & 1);
    while (!dq.empty()) {
        int top;
        if (rev) {
            top = dq.back();
            dq.pop_back();
        }
        else {
            top = dq.front();
            dq.pop_front();
        }
        std::cout << top << " ";
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 4416
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr long long inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll S; cin>>S;

    ll x3 = 0;
    ll y3 = 0;
    ll x1, x2, y1, y2;
    if(S == INF){
        x1 = y2 = inf;
        x2 = y1 = 0;
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
        return 0;
    }

    x1 = (S + inf) / inf;
    y2 = inf;
    x2 = abs((S % inf) - inf);
    y1 = 1;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string ans = "No";
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        ans = "Yes";
    }
    if (s[0] == s[2] && s[1] != s[2] && s[1] == s[3]){
        ans = "Yes";
    }
    if (s[0] == s[3] && s[2] != s[0] && s[1] == s[2]){
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;
//use itertools::Itertools;

fn main() {
    input!{n :u128};
    let filt : i128 = 1000000007;
    let mut res = 1;
    let mut temp = 1;
    let mut temp2 = 1;
    for _i in 0..n {
        res = (res * 10) % filt;
        temp = (temp * 9) % filt;
        temp2 = (temp2 * 8) % filt;
    }
    let temp3 = ((temp + temp % filt) - temp2) % filt;
    let mut ans = (res - temp3) % filt;
    if ans < 0 {
        ans = ans + filt;
    }
    println!("{}", ans);
}

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

vector<ll>w[4];
ll sum[5][110];

int main(void){
    ll n,W;
    cin>>n>>W;
    ll w1=0;
    for(int i=0;i<4;i++)w[i].push_back(0);
    for(ll i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(i==0)w[0].push_back(y),w1=x;
        else w[x-w1].push_back(y);
    }
    for(int i=0;i<4;i++)sort(w[i].begin(),w[i].end(),greater<ll>());
    for(int i=0;i<4;i++){
        sum[i][0]=0;
        for(int j=0;j<w[i].size();j++){
            sum[i][j+1]=sum[i][j]+w[i][j];
        }
    }
    ll ans = 0;
    for(ll i=0;i<w[0].size();i++){
        for(ll j=0;j<w[1].size();j++){
            for(ll k=0;k<w[2].size();k++){
                for(ll l=0;l<w[3].size();l++){
                    ll weight = w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
                    if(weight>W)continue;
                    //cout<<weight<<endl;
                    ll x1=0,x2=0,x3=0,x4=0;
                    if(i!=0)x1=sum[0][i];
                    if(j!=0)x2=sum[1][j];
                    if(k!=0)x3=sum[2][k];
                    if(l!=0)x4=sum[3][l];
                    //cout<<x1+x2+x3+x4<<endl;
                    ans = max(ans,x1+x2+x3+x4);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int freq[200005],dp[200005],i,j;
unordered_map<int,int> best;
#define get(k) (best.find(k)!=best.end()?best[k]:dp[i-1])
int main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	for(int i=0;i<s.size();++i)
		freq[i+1]=freq[i]^(1<<(s[i]-'a'));
	for(best[0]=0,i=1;i<=s.size();++i){
		for(dp[i]=1+get(freq[i]),j=26;j--;dp[i]=min(dp[i],1+get(freq[i]^(1<<j))));
		if(best.find(freq[i])==best.end() || best[freq[i]]>dp[i]) best[freq[i]]=dp[i];
	}
	cout<<dp[s.size()];
}

Measured memory_bytes: 10332
#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
#define int long long
using namespace std;
signed main() {
	int X;
	cin >> X;

	cout << (X / 500) * 1000 + ((X % 500) / 5) * 5 << endl;
}

Measured memory_bytes: 3632
def main():
    S = input()
    K = int(input())

    tmp = ''
    count = 0
    for s in S:
        if s == '1':
            count += 1
        else:
            tmp = s
            break

    if count >= K:
        print('1')
    else:
        print(tmp)


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
	string d = "AIDUNYAN", z = "AIZUNYAN", s;
	sort(d.begin(), d.end());
	cin >> s;
	for(int i=0;i+d.size()<=s.size();i++){
		string a = s.substr(i, d.size());
		sort(a.begin(), a.end());
		if(d == a){
			for(int j=0;j<z.size();j++){
				s[i + j] = z[j];
			}
			i += z.size() - 1;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

int main()
{
  char str[3];
  scanf("%s", str);
  
  char o[] = "o";
  int counter=0;
  if(str[0]==o[0]) counter++;
  if(str[1]==o[0]) counter++;
  if(str[2]==o[0]) counter++;
  printf("%d\n",700+counter*100);  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
  int i,n=0;
  for( i=1;i<10;i++){
   
    printf("1x%d=%d\n", i,1*i);
  }
 for( i=1;i<10;i++){
    
    printf("2x%d=%d\n", i,2*i);
  }
  for( i=1;i<10;i++){
   
    printf("3x%d=%d\n", i,3*i);
  }
for( i=1;i<10;i++){
   
    printf("4x%d=%d\n", i,4*i);
  }
  for( i=1;i<10;i++){
   
    printf("5x%d=%d\n", i,5*i);
  }
  for( i=1;i<10;i++){
    
    printf("6x%d=%d\n", i,6*i);
  }
for( i=1;i<10;i++){
    
    printf("7x%d=%d\n", i,7*i);
  }
for( i=1;i<10;i++){
    
    printf("8x%d=%d\n", i,8*i);
  }
for( i=1;i<10;i++){
   
    printf("9x%d=%d\n", i,9*i);
  }
    return 0;
  }
      
  

Measured memory_bytes: 524
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        string s = Console.ReadLine();
        string ans = "None";
        if (-1 == s.IndexOf("a")) { ans = "a"; }
        else if (-1 == s.IndexOf("b")) { ans = "b"; }
        else if (-1 == s.IndexOf("c")) { ans = "c"; }
        else if (-1 == s.IndexOf("d")) { ans = "d"; }
        else if (-1 == s.IndexOf("e")) { ans = "e"; }
        else if (-1 == s.IndexOf("f")) { ans = "f"; }
        else if (-1 == s.IndexOf("g")) { ans = "g"; }
        else if (-1 == s.IndexOf("h")) { ans = "h"; }
        else if (-1 == s.IndexOf("i")) { ans = "i"; }
        else if (-1 == s.IndexOf("j")) { ans = "j"; }
        else if (-1 == s.IndexOf("k")) { ans = "k"; }
        else if (-1 == s.IndexOf("l")) { ans = "l"; }
        else if (-1 == s.IndexOf("m")) { ans = "m"; }
        else if (-1 == s.IndexOf("n")) { ans = "n"; }
        else if (-1 == s.IndexOf("o")) { ans = "o"; }
        else if (-1 == s.IndexOf("p")) { ans = "p"; }
        else if (-1 == s.IndexOf("q")) { ans = "q"; }
        else if (-1 == s.IndexOf("r")) { ans = "r"; }
        else if (-1 == s.IndexOf("s")) { ans = "s"; }
        else if (-1 == s.IndexOf("t")) { ans = "t"; }
        else if (-1 == s.IndexOf("u")) { ans = "u"; }
        else if (-1 == s.IndexOf("v")) { ans = "v"; }
        else if (-1 == s.IndexOf("w")) { ans = "w"; }
        else if (-1 == s.IndexOf("x")) { ans = "x"; }
        else if (-1 == s.IndexOf("y")) { ans = "y"; }
        else if (-1 == s.IndexOf("z")) { ans = "z"; }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13792
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
vector<char> v;
string s;
cin>>s;
for(int i=0;i<s.length();i++)
{
	if(s[i]!='B')
	v.pb(s[i]);
	else if(v.size()>0)
	v.pop_back();
}
for(int i=0;i<v.size();i++)
cout<<v[i];

}return 0;}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

int komb[10][10];

int broj(int x)
{
    int cif = 0;
    while(x > 0)
    {
        cif = x % 10;
        x /= 10;
    }
    return cif;
}

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

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int a = broj(i);
        int b = i % 10;
        komb[a][b]++;
    }
    ll sum = 0;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
            sum += komb[i][j] * komb[j][i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	i := 1
	for {
		x := nextInt()
		if x == 0 {
			break
		} else {
			fmt.Printf("Case %v: %v\n", i, x)
		}
		i++
	}
}



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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

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

  init();
  string command;
  int key;
  rep(i, n) {
    cin >> command;
    if (command.length() == 6) cin >> key;
    if (command == "insert") {
      insert(key);
    } else if (command.length() == 6) {
      deleteKey(key);
    } else if (command == "deleteFirst") {
      deleteFirst();
    } else if (command == "deleteLast") {
      deleteLast();
    } else {
      cout << "Command Not Found" << endl;
    }
  }

  Node *cur = nil->next;
  while (cur != nil) {
    printf("%d%c", cur->key, cur->next == nil ? '\n':' ');
    cur = cur->next;
  }
  return 0;
}



Measured memory_bytes: 34480
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int oddCnt = 0;
    int evenCnt = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] % 2 != 0) oddCnt++;
        else evenCnt++;
    }

    if(oddCnt % 2 == 0) {
        cout << "YES" << endl;
        return 0;
    }

    if(evenCnt == n) {
        cout << "YES" << endl;
        return 0;
    }

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
vector<int> v[101010];
int depth[101010],sz[101010];

int szdfs(int x,int d=0,int p=-1){
    int ret=1;
    depth[x]=d;
    for(auto to:v[x]){
        if(to==p)continue;
        ret+=szdfs(to,d+1,x);
    }
    return sz[x]=ret;
}
int main(){
   int n;
   cin>>n;
   int a[n-1],b[n-1];
   rep(i,n-1){
       cin>>a[i]>>b[i];
       --a[i];--b[i];
       v[a[i]].push_back(b[i]);
       v[b[i]].push_back(a[i]);
   }
   szdfs(0);
   rep(i,n-1)if(depth[a[i]]>depth[b[i]])swap(a[i],b[i]);
   ll d[n];
   rep(i,n)cin>>d[i];
   int yabai=-1;
   ll ans[n-1];
   rep(i,n-1){
       if(2*sz[b[i]]==n)yabai=i;
       else ans[i]=(d[b[i]]-d[a[i]])/(n-2*sz[b[i]]);
   }
   if(yabai>=0){
       rep(i,n-1){
           if(i==yabai)continue;
           d[0]-=ans[i]*sz[b[i]];
       }
       ans[yabai]=2*d[0]/n;
   }
   rep(i,n-1)cout<<ans[i]<<endl;
   return 0;
}

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

int max(int j,int i){
        if (j > i) {
                return j;
        }else{
                return i;
        }
}

int main(void){
        int N;
        int L[11];
        scanf("%d", &N);
        int m = 0;
        int sum = 0;
        for (int i = 0; i < N; i++) {
                scanf("%d", &L[i]);
                sum += L[i];
                m = max(m,L[i]);
        }
        printf("%d\n",sum-(m/2));
        return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int n;
bool isOk;
int actualColor = 0;
vector <int> adj[100005];
int color[100004];
bool visited[100005];
void DFS(int vertex){
        visited[vertex] = 1;
        if(actualColor != color[vertex])
                isOk = false;
        for(int i = 0; i < adj[vertex].size(); i++){
                if(!visited[adj[vertex][i]])
                        DFS(adj[vertex][i]);
        }

}
int main(){
        int n;
        cin >> n;
        int ev = 0, od = 0;
        for(int i = 0; i < n; i++){
                int x;
                cin >> x;
                if(x % 2 == 0)
                        ev++;
                else od++;
        }
        if(n == 1)
            return cout << "YES", 0;
        if(od % 2 == 0)
                return cout << "YES", 0;
        return cout << "NO", 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int cnt=0,len,k;
long long ans;
void dfs(int x,long long i){
    if(len==x){
	    cnt++;
    	if(cnt==k)
	    	ans=i;
		i/=10;
		return;
	}
    long long u=i%10;
    for(long long j=u-1;j<=u+1;j++){
        if(j<0 || j>9) continue;
        else{
            len++;
            dfs(x,i*10+j);
            len--;
        }
    }
}
int main(){
    cin>>k;
    for(int j=1;j<=10;j++){
        for(long long i=1;i<=9;i++){
            len=1;
            dfs(j,i);
        }
    }
    cout<<ans;
    return 0;
}

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


int main(void)
{
    int N;
    cin >> N;
    int d[N];

    for(int i = 0; i < N; i++)
	cin >> d[i];

    int store_points = 0;
    for(int i = 0; i < N - 1; i++)
    {
	for(int j = i + 1; j < N; j++)
	    store_points += d[i] * d[j];
    }
    cout << store_points << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] str = new char[S.length()];
        for (int i = 0; i < S.length();i++){
            str[i] = S.charAt(i);
        }
        for (int i = 0; i < S.length();i++){
            if (i%2 ==0){
                if (str[i] =='L'){
                    System.out.println("No");
                    return;
                }
            }
            if (i%2 ==1){
                if (str[i] == 'R'){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(),d.end(),greater<int>());
    set<int> dset(d.begin(),d.end());
    cout << dset.size() << endl;
}

Measured memory_bytes: 256
module Main where

abcd :: String -> (Float, Float, Float, Float)
abcd str =  ( read (head strs)
			, read (head (tail strs))
			, read (head (tail (tail strs)))
			, read (head (tail (tail (tail (strs))))))
	where strs = words str

ans a b c d
	| rsTakahashi < rsAoki = "No"
	| otherwise = "Yes"
	where (rsTakahashi, rsAoki) = (ceiling (a / d) , ceiling (c / b))


main :: IO ()
main = do
	input <- getLine
	let (a, b, c, d) = abcd input
	putStrLn $ ans a b c d


Measured memory_bytes: 3920
def run():
  num_list = [int(i) for i in list(input())]
  ans_list = [(str(num_list[0]), num_list[0])]
  for num in num_list[1:]:
    new_list = []
    for ans in ans_list:
      ans_str = ans[0]
      ans_num = ans[1]
      new_list.append((ans_str+'+'+str(num), ans_num+num))
      new_list.append((ans_str+'-'+str(num), ans_num-num))
    ans_list = new_list
  for ans in ans_list:
    if ans[1] == 7:
      print(ans[0]+'=7')
      break
                       
if __name__ == '__main__':  
  run()

Measured memory_bytes: 3064
#include<stdio.h>
#include <stdlib.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
    int N, A[200001],B[200001];
    scanf("%d", &N);
    for (int a = 0;a<N;a++){
        scanf("%d", &A[a]);
    }
    for (int b = 0; b < N;b++){
        B[b] = A[b];
    }
    qsort(B, N, sizeof(int), compare_int);

    for (int c = 0; c < N;c++){
        if(A[c]==B[N-1]){
            printf("%d\n", B[N - 2]);
    }else{
        printf("%d\n", B[N-1]);
    }
    }
    return 0;
}

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

using namespace std;

const int MOD = 1000000007;
const int MAX = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  int a;
  cin >> a;
  a %= 1000;
  if (a == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - a << endl;
}


Measured memory_bytes: 3620
L, R = map(int, input().split())
if L % 2019 == 0:
    low = L // 2019
else:
    low = L // 2019 + 1
high = R // 2019

if low <= high:
    # 2019の倍数が範囲内に存在する
    print(0)
else:
    minmod = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            temp = (i * j) % 2019
            if temp < minmod:
                minmod = temp
    print(minmod)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

ll n;
vl a;
vector<vector<pair<bool, ll>>> dp;

ll compute(ll start, ll count, ll turn) {
  if(dp[start][count].xx)
    return dp[start][count].yy;

  if(count == 0) {
    dp[start][0] = mp(true, a[start]*(turn%2?-1:1));
    return dp[start][0].yy;
  }


  ll val1 = compute(start+1, count-1, turn + 1) + (turn%2?-1:1)*a[start];
  ll val2 = compute(start, count-1, turn + 1) + (turn%2?-1:1)*a[start + count];


  dp[start][count] = mp(true, (turn%2?min(val1, val2): max(val1, val2)));
  return dp[start][count].yy;
}

int main() {
  cout << fixed << setprecision(8);
  cin >> n;
  FOR(i,0,n) {
    ll x;
    cin >> x;
    a.pb(x);
  }

  dp.assign(n, vector<pair<bool, ll>>(n, mp(false, -1)));

  cout << compute(0, n-1, 0) << endl;
}


Measured memory_bytes: 141312
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,g,h,i;
int main()
{
    cin>>a>>b>>e; 
    c=3*e-a-b;  
    h=2*e-b;
    f=2*a-h;
    i=3*e-c-f;
    d=2*e-f;
    g=3*e-h-i;
    printf("%d %d %d\n%d %d %d\n%d %d %d",a,b,c,d,e,f,g,h,i); 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define ll long long

using namespace std;

int n, m, x, y, mx = 0;
vector<int> graph[100005];
int dp[100005];
bool vis[100005];

int dfs(int node)
{
	if (vis[node])return dp[node];
	vis[node] = 1;
	for (int i = 0; i < graph[node].size(); i++)
	{
		int child = graph[node][i];
		dp[node] = max(dp[node], dfs(child) + 1);
	}
	return dp[node];
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> x >> y;
		graph[x].push_back(y);
	}
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i])
		{
			int l = dfs(i);
		}
		mx = max(mx, dp[i]);
	}
	cout << mx << '\n';
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;


int main(){
    long long n;
    cin >> n;
    string s;
    while (n){
        n--;
        int next = n % 26;
        n/=26;
        s += 'a' + next;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}




Measured memory_bytes: 3576
n = int(input())
a1 = list(input().split())
a2 = a1[:]
for i in range(0, n):
    for j in range(1, n-i):
        if int(a2[j][1])<int(a2[j-1][1]):
            a2[j], a2[j-1] = a2[j-1], a2[j]
print (*a2)
print ("Stable")

a3 = a1[:]
for i in range(0, n):
    minj = i
    for j in range(i, n):
        if int(a3[j][1])<int(a3[minj][1]):
            minj = j
    a3[i], a3[minj] = a3[minj], a3[i]
print(*a3)
if a2 == a3:
    print("Stable")
else:
    print("Not stable")
       




Measured memory_bytes: 5604
#include <stdio.h>

#define MAX 100000

struct data {
    char name[10];
    int time;
};

int head = 0, tail = 0;
struct data Q[100000];

int isEmpty()
{
    return head != tail;
}

void enqueue(struct data p)
{
    Q[tail] = p;
    if (tail == MAX - 1) {
        tail = 0;
    } else {
        tail++;
    }
}

struct data dequeue()
{
    struct data x;
    
    x = Q[head];
    if (head == MAX - 1) {
        head = 0;
    } else {
        head++;
    }
    return x;
}

int main(void)
{
    int n, q, i, t = 0;
    struct data p;
    
    scanf("%d %d", &n, &q);
    for (i = 0; i < n; i++) {
        scanf("%s %d", p.name, &p.time);
        enqueue(p);
    }
    while (isEmpty()) {
        p = dequeue();
        if (p.time <= q) {
            t += p.time;
            printf("%s %d\n", p.name ,t);
        } else {
            t += q;
            p.time -= q;
            enqueue(p);
        }
    }
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp1,temp2,y,sum=0,o,n,m,k;
    cin >> n;
    string a;
    set <string> aa;
    for(i=0;i<n;i++){
        cin >> a;
        aa.insert(a);
    }
    cout << aa.size();

}

Measured memory_bytes: 19180
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    ll a,b;cin>>a>>b;
    cout<<GCD(a,b)<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------














































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

int main() {
  
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2])
    cout << "Yes"<< endl;
  else if (N[1] == N[2] && N[2] == N[3]) 
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int dp[100010][3]; int n;
int niz[100010][3];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
		dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

Measured memory_bytes: 1408