akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(i) for i in input().split()]
C = [0]*(N+1)
C[0] = 3
ans = 1
MOD = 1000000007
 

for i in range(N):
  ans *= C[A[i]]-C[A[i]+1]
  ans %= MOD
  C[A[i]+1] += 1
print(ans)

Measured memory_bytes: 13932
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
#define shit while(t--)
#define fr for(int i=0;i<n;i++)
int maxo=1e9+7;
using namespace std;
int arr[95];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,s=0;
    cin>>n;
    x=n;
    while(n>0)
    {
        s+=n%10;
        n/=10;
    }
    if(x%s)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3568
#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>;
using T = tuple<int, 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 int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

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

    sort(all(a));

    vector<P> ans;
    if(a[n-1] <= 0){
        for(int i=0; i<n-1; i++){
            ans.emplace_back(a[n-1], a[i]);
            a[n-1] -= a[i];
        }
    }
    else if(0 <= a[0]){
        for(int i=1; i<n-1; i++){
            ans.emplace_back(a[0], a[i]);
            a[0] -= a[i];
        }
        ans.emplace_back(a[n-1], a[0]);
        a[n-1] -= a[0];
    }
    else{
        for(int i=0; i<n-1; i++){
            if(0 < a[i]){
                ans.emplace_back(a[0], a[i]);
                a[0] -= a[i];
            }
        }

        for(int i=0; i<n; i++){
            if(a[i] <= 0){
                ans.emplace_back(a[n-1], a[i]);
                a[n-1] -= a[i];
            }
        }
    }

    cout << ans[n-2].first - ans[n-2].second << endl;
    for(auto i:ans) cout << i.first << " " << i.second << endl;

    return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <limits.h>

int min(int, int);

int main(void){
  
  int n,i,j,a,b,q,gomi;
  int p[111],m[111][111];
  
  scanf("%d",&n);
  
  scanf("%d%d",&p[0],&p[1]);
  for(i = 2;i <= n;i++) scanf("%d%d",&gomi,&p[i]);
  
  for(i = 1;i < n;i++) m[i][i] = 0;
  for(b = 2;b <= n;b++){
    for(i = 1;i <= n-b+1;i++){
      j = i+b-1;
      m[i][j] = INT_MAX;
      for(a = i;a < j;a++){
	q = m[i][a] + m[a+1][j] + p[i-1]*p[a]*p[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
  
}

int min(int a, int b){
  
  if(a <= b) return a;
  return b;
  
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}

bool even(string s) {
    int l = 0;
    int m = s.size() / 2;
    while (l < m) {
        if (s[l] != s[l + m]) {
            return false;
        }
        ++l;
    }
    return true;
}

int main() {
    int task = 1;
//    cin >> task;
    while (task--) {
        string line;
        cin >> line;
        int del = 2;
        while (del <= line.size()) {
            if (even(line.substr(0, line.size() - del))) {
                break;
            }
            del += 2;
        }
        cout << line.size() - del << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;
const long long MOD = 1000000007;

int main(){
    int H,W,K;
    long long dp[110][8] = {0};

    cin >> H >> W >> K;

    dp[0][0] = 1;

    for(int i = 0;i < H;i++){
        long long n[8][8] = {{0}};

        for(int j = 0;j < 1 << (W - 1);j++){
            bool check = false;
            
            for(int k = 0;k < 1 << (W - 2);k++){
                if( (1 & (j >> k)) && (1 & (j >> k + 1)) )check = true;
            }
            if(check)continue;

            for(int k = 0;k < W - 1;k++){
                if(1 & (j >> k)){
                    n[k][k + 1]++;
                    n[k + 1][k]++;
                }
            }

            for(int k = 0;k < W;k++){
                if(k > 0 && (1 & (j >> (k - 1)) ) )continue;
                if(k < W - 1 && (1 & (j >> k) ) )continue;
                n[k][k]++;
            }
        }

        for(int j = 0;j < W;j++){
            for(int k = 0;k < W;k++){
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][k] * n[k][j]) % MOD;
            }
        }
    }

    cout << dp[H][K-1] << endl;

    return 0;
}

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

int main(){
  
    int a,b;
    cin>>a>>b;
    cout<<(a*b%2==0?"Even":"Odd")<<endl;
return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
H = [int(x) for x in input().split()]

path = defaultdict(list)
for i in range(M):
    A, B = map(int, input().split())
    A-=1
    B-=1
    path[A].append(B)
    path[B].append(A)

count = 0
for a in range(N):
    if all(H[a] > H[b] for b in path[a]):
        count += 1
print(count)
        





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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m + 1);
  int k;
  int suki_idx;
  for (int i = 0; i < n; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> suki_idx;
      a[suki_idx]++;
    }
  }

  int ans = 0;
  for (int x : a) if (x == n) ans++;
  cout << ans << endl;
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<string>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  sort(ALL(a));
  for(i=0;i<n;i++)cout<<a[i];
  cout<<endl;
  return 0;
}

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



int main(){
    int n;
    int x[100];
    int s=0, g;
    int res=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x[i];
        s += x[i];
    }

    g = round((double)s/n);
    for(int i=0; i<n; i++){
        res += pow((x[i]-g), 2);
    }

    cout << res << endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

void insertion_sort(int N, int* A) {
    cout << A[0];
    for (int i = 1; i < N; i++) {
      cout << " " << A[i];
    }
    cout << endl;
  
  for (int i = 1; i < N; i++) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    cout << A[0];
    for (int i = 1; i < N; i++) {
      cout << " " << A[i];
    }
    cout << endl;
  }
}

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

  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  insertion_sort(N, A);
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k,s;
    cin>>n>>k>>s;
    if(s==pow(10,9))
    {
        for(int i=0;i<n;i++)
        {
            if(i<k)
            cout<<s<<" ";
            else
            cout<<1<<" ";
        }
    }
    else
    {
        for(int i=0;i<n;i++)
        {
            if(i<k)
            cout<<s<<" ";
            else
            cout<<s+1<<" ";
        }
    }
    
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, M, A[100010];

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

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

  void init() {
    scanf("%lld %lld", &N, &M);
    rep(i, N) {
      scanf("%lld", A+i);
      A[i] /= 2;
    }
  }

  void solve() {
    while(A[0]%2==0) {
      rep(i, N) if (A[i]%2==0) {
        A[i] /= 2;
      } else {
        printf("0\n");
        return;
      }
      M /= 2;
    }
    rep(i, N) if (A[i]%2==0) {
      printf("0\n");
      return;
    }
    ll acc = A[0];
    rep1(i, N) {
      acc = lcm(A[i], acc);
      if (acc > M) {
        printf("0\n");
        return;
      }
    }
    ll ans = 0;
    ll a = M/acc;
    if(a%2) ans = (a+1)/2;
    else ans = a/2;
    printf("%lld\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int K, N;
int A[int(4e5+5)];

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

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

  int ans = A[N-1] - A[0];
  for (int i = 0; i < N - 1; i++){
    ans = min(ans, K - (A[i+1] - A[i]));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s;
string t;

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

    for(int i = 0;i < s.size();i++)
    {
        cout << s[i];
        if(i < t.size())
        {
            cout << t[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long

ll sad(ll b, vector<ll> *B)
{
    ll res = 0;
    for (int i = 0; i < B->size(); i++)
        res += abs((*B)[i] - b);

    return res;
}

int main()
{
    long long int N;
    scanf("%lld", &N);

    ll sum = 0;
    vector<ll> B(N);

    scanf("%lld", &B[0]);
    B[0] -= 1;
    ll maximam = B[0];
    ll minimam = B[0];

    for (ll i = 1; i < N; i++)
    {
        ll A;
        scanf("%lld", &A);
        B[i] = A - (i + 1);
        sum += B[i];
        maximam = max(maximam, B[i]);
        minimam = min(minimam, B[i]);
    }

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

    ll sad1 = sad(B[N / 2 - 1], &B);
    ll sad2 = sad(B[N / 2], &B);
    ll minsad = min(sad1, sad2);

    printf("%lld", minsad);
}


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

using namespace std;

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

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	//ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> n;

	V v(n), c(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}

	rep(i, 1 << n) {
		x = y = 0;
		rep(j, n) {
			if ((i >> j & 1) == 1) {
				x += v[j];
				y += c[j];
			}
		}
		l_ans = max(l_ans, x - y);
	}

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, raw_input().split())
dnum=b-a+1
if b<0:
    odd=0
    if dnum%2==1:
        odd=1
    if odd==0:
        print "Positive"
    else:
        print "Negative"
if a*b==0:
    print "Zero"
if b>0 and a<0:
    print "Zero"
if a>0:
    print "Positive"

Measured memory_bytes: 2568
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 12/29/2018, 9:05:34 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll L;
int N;
ll X[200010];
ll sum[200010];
ll sum_rev[200010];
ll ans = 0;

void solve()
{
  sort(X + 1, X + N + 1);
  sum[0] = 0;
  for (auto i = 1; i <= N; i++)
  {
    sum[i] = sum[i - 1] + X[i];
    // cerr << "sum[" << i << "] = " << sum[i] << endl;
  }
  sum_rev[N + 1] = 0;
  for (auto i = N; i >= 1; i--)
  {
    sum_rev[i] = sum_rev[i + 1] + L - X[i];
    // cerr << "sum_rev[" << i << "] = " << sum_rev[i] << endl;
  }
  for (auto right = 1; right <= N; right++)
  {
    int left = N - right;
    int num = min(right, left);
    // cerr << "left = " << left << ", right = " << right << endl;
    ll tans = sum[right] - sum[right - num] + sum_rev[right + 1] - sum_rev[right + 1 + num];
    tans *= 2;
    tans -= L - X[right + 1];
    // cerr << "tans = " << tans << endl;
    ans = max(tans, ans);
    num = min(right, left + 1);
    tans = sum[right] - sum[right - num] + sum_rev[right + 1] - sum_rev[right + 1 + (num - 1)];
    tans *= 2;
    tans -= X[right];
    // cerr << "tans = " << tans << endl;
    ans = max(tans, ans);
  }
}

int main()
{
  cin >> L >> N;
  X[0] = 0;
  for (auto i = 1; i <= N; i++)
  {
    cin >> X[i];
  }
  X[N + 1] = L;
  solve();
  for (auto i = 1; i <= N; i++)
  {
    X[i] = L - X[i];
  }
  solve();
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <functional>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#define MAX_N 1010

using namespace std;

static int X1[1010], Y1[1010], X2[1010], Y2[1010], fld[MAX_N * 2][MAX_N * 2],dx[4] = { -1, 0, 0, 1 }, dy[4] = { 0, -1, 1, 0 };

static int compress(int *const, int *const, const int, const int);
static int bfs(const int, const int);
void imos(const int, const int, const int);

int main(void)
{
	int W, H, N;

	//freopen("D:\\input.txt", "r", stdin);
	while (1)
	{
		scanf("%d%d", &W, &H);
		if (W == 0 && H == 0)
			break;
		scanf("%d", &N);
		for (int i = 0; i < N; i++)
		{
			scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
		}
		W = compress(X1, X2, W, N);
		H = compress(Y1, Y2, H, N);

		imos(W, H, N);
		cout << bfs(W, H) << endl;
	}
	return EXIT_SUCCESS;
}

static int compress(int *const s1, int *const s2, const int W, const int N)
{
	//???????????£???
	vector<int>xs;

	for (int i = 0; i < N; i++)
	{
		if (0 < s1[i] && s1[i] < W) xs.push_back(s1[i]);
		if (0 < s2[i] && s2[i] < W) xs.push_back(s2[i]);
	}
	xs.push_back(0);
	xs.push_back(W);//?????????????????¶
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (int i = 0; i < N; i++)
	{
		s1[i] = find(xs.begin(), xs.end(), s1[i]) - xs.begin();
		s2[i] = find(xs.begin(), xs.end(), s2[i]) - xs.begin();
	}
	return xs.size() - 1;
}

static int bfs(const int W, const int H)
{
	int ans = 0;
	for (int i = 0; i < W; i++)
		for (int j = 0; j < H; j++)
		{
			if (fld[i][j])continue;//????´¢?????????????????????
			ans++;

			queue<pair<int, int> > que;
			que.push(make_pair(i, j));
			while (!que.empty())
			{
				int tx = que.front().first, ty = que.front().second;
				que.pop();
				for (int i = 0; i < 4; i++)
				{
					int ttx = tx + dx[i], tty = ty + dy[i];
					if (0 <= ttx && ttx <= W
						&& 0 <= tty && tty <= H
						&& !fld[ttx][tty])
					{
						que.push(make_pair(ttx, tty));
						fld[ttx][tty] = 1;
					}
				}
			}
		}
	return ans;
}

void imos(const int W, const int H, const int N)
{
	//imos??????????????´
	memset(fld, 0, sizeof(fld));

	for (int i = 0; i < N; i++)//????????±??????
	{
		fld[X1[i]][Y1[i]]++;
		fld[X1[i]][Y2[i]]--;
		fld[X2[i]][Y1[i]]--;
		fld[X2[i]][Y2[i]]++;
	}
	for (int i = 0; i < W; i++)//?´?????¨????
		for (int j = 1; j < H; j++)
			fld[i][j] += fld[i][j - 1];

	for (int j = 0; j < H; j++)//?´??????????
		for (int i = 1; i < W; i++)
			fld[i][j] += fld[i - 1][j];
	//?????¶??¨????°±????????????????????????
}

Measured memory_bytes: 17200
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] day = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
        String a = sc.next();
        for(int i=0; i<7; i++) {
        		if(a.equals(day[i])) System.out.println(i+1);
        }
        
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> vi;

int n, k;
int dp[2000];
vi v[10], sum[10];

int main() {
	cin >> n >> k;
	REP(i, n) {
		int a, b;
		scanf("%d %d", &a, &b);
		v[b - 1].push_back(a);
	}

	REP(i, 10)
		sort(v[i].begin(), v[i].end(), greater<int>());
	REP(i, 10) {
		sum[i].push_back(0);
		REP(j, v[i].size()) {
			sum[i].push_back(sum[i][j] + v[i][j] + j * 2);
		}
	}

	
	REP(i, 10) {
		for (int j = k; j >= 0; j--) {
			FOR(l, max(0, j - ((int)sum[i].size() - 1)), j) {
				dp[j] = max(dp[j], dp[l] + sum[i][j - l]);
			}
		}
	}
	
	cout << dp[k] << endl;
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    rep(i, N){
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }
    int ans = inf;
    rep(i, 1<<N){
        int sum[M], res = 0;
        fill(sum, sum+M, 0);
        rep(j, N){
            if(i & (1<<j)){
                res += C[j];
                rep(k, M){
                    sum[k] += A[j][k];
                }
            }
        }
        bool able = true;
        rep(j, M){
            if(sum[j] < X) able = false;
        }
        if(able) chmin(ans, res);
    }
    if(ans == inf) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
  int n,i;
  int number[100];
  int check = 0;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    scanf("%d",&number[i]);
  
  for(i = 0;i < n;i++){
    if(number[i] % 2 == 0){
      if(number[i] % 3 != 0 && number[i] % 5 != 0){
        check++;
        break;
      }
    }
  }
  
  if(check == 0)
    printf("APPROVED");
  else
    printf("DENIED");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,B,x,i,l,m,tmp;
	scanf("%d%d",&A,&B);
if(A+B>=24){
	printf("%d",A+B-24);}
	else
	printf("%d",A+B);


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  double ans = 0.0;
  rep(i, n){
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") ans += x;
    else ans += x * 380000.0;
  }
  cout << ans << endl;
  return 0;
}

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

const int N = 500001, M = 2 * 20 * N;
namespace SEG {

int ls[M], rs[M], val[M], nc;
int cp(int q) {
    int p = ++nc;
    ls[p] = ls[q];
    rs[p] = rs[q];
    val[p] = val[q];
    return p;
}

int modify(int x, int v, int p, int lb, int rb) {
    p = cp(p); val[p] += v;
    if (lb + 1 == rb);
    else {
        int mid = (lb + rb) >> 1;
        if (x < mid) ls[p] = modify(x, v, ls[p], lb, mid);
        else rs[p] = modify(x, v, rs[p], mid, rb);
    }
    return p;
}

int query(int l, int r, int p, int lb, int rb) {
    if (l <= lb && rb <= r)
        return val[p];
    else {
        int mid = (lb + rb) >> 1;
        int sum = 0;
        if (l < mid) sum += query(l, r, ls[p], lb, mid);
        if (r > mid) sum += query(l, r, rs[p], mid, rb);
        return sum;
    }
}

}

int a[N], l[N], rt[N];

int main(void) {
    int n, q; scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        rt[i] = SEG::modify(i, 1, rt[i - 1], 1, n + 1);
        if (l[a[i]])
            rt[i] = SEG::modify(l[a[i]], -1, rt[i], 1, n + 1);
        l[a[i]] = i;
    }

    while (q--) {
        int l, r; scanf("%d %d", &l, &r);
        printf("%d\n", SEG::query(l, r + 1, rt[r], 1, n + 1));
    }

    return 0;
}

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

int main() {
    int n;
    float x, sum;
    string u;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else sum += 380000 * x;
    }

    cout << sum << endl;
    
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	if(m == 1) {
		int t;
		cin >> t;
		if(t == 1) {
			cout << 1 << endl;
			cout << 1 << endl;
			cout << 1 << endl;
			return 0;
		}
		cout << t << endl;
		cout << 2 << endl;
		cout << t - 1 << " " << 1 << endl;
		return 0;
	}
	vi even, odd;
	for(int i=0;i<m;i++) {
		int t;
		cin >> t;
		if(t & 1) odd.PB(t);
		else even.PB(t);
	}
	if(odd.size() >= 3) {
		cout << "Impossible" << endl;
		return 0;
	}
	vi v;
	if(odd.size()) {
		v.PB(odd.back());
		odd.pop_back();
	}
	for(int i:even) v.PB(i);
	if(odd.size()) {
		v.PB(odd.back());
		odd.pop_back();
	}
	for(int i:v) cout << i << " ";
	cout << endl;
	v[0]++;
	v.back()--;
	if(v.back() == 0) v.pop_back();
	cout << v.size() << endl;
	for(int i:v) cout << i << " ";
	cout << endl;
}





Measured memory_bytes: 256
str = input()
l = len(str)
p = l-1
index = 0
cnt=0
if l==1:
    print(0)
    exit()
if l==2:
    if str[0]==str[1]:
        print(0)
        exit()
    else:
        print(1)
        exit()
while index < p:

    if str[index] == str[p]:
        index = index + 1
        p = p-1
        if index == p or index + 1 == p:
            if str[index] == str[p]:
                print(cnt)
                exit()
            else:
                cnt+=1
                print(cnt)
                exit()
    else:
        cnt+=1
        index = index + 1
        p = p-1
        if index == p or index + 1 == p:
            if str[index] == str[p]:
                print(cnt)
                exit()
            else:
                cnt+=1
                print(cnt)
                exit()

Measured memory_bytes: 3064
/**********************************************

1.
2.テァツつュテァツ板ーテゥツォツ佚ィツシツ?
3.sumita.takaki@gmail.com

last updated: 2013-07-10@17:04

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


int main(void){


        while(1){
                
                int n=0;
                int k=0;
                int total=0, answer=0;
               

                cin >> n >> k;
                if(n==0 && k==0)break;
                vector <int> data(n);
                
                for(int i=0; i<n; i++){
                        cin >> data[i];
                        //cout << "data[i]="<< data[i]<<endl;
                }

                for(int j=0; j<n-k+1; j++){
                        
                        if( j == 0){
                                for(int i=0; i<k; i++){
                                        total = total + data[j+i];
                                }
                                //cout << "subtotal1="<<total<<endl;
                        }else{
                                
                                total = total - data[j-1] + data[j+k-1];
                                //cout << "subtotal2="<<total<<endl;
                        }
                        //cout << "answer="<<answer<<"subtotal="<<total<<endl;
                        if( total > answer ){
                                answer = total;
                        }
                        //cout << "answer="<<answer<<endl;
                }
                
                cout << answer << endl;
                
        }

        return 0;

}

Measured memory_bytes: 1532
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

string s;

int main(){
  cin>>s;
  sort(s.begin(),s.end());
  if (s[0]!=s[3] && s[0]==s[1] && s[2]==s[3]) cout<<"Yes";
  else cout<<"No";
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int sum = 0;
    int temp = i;
    while(temp) {
      sum += temp % 10;
      temp = temp / 10;
    }
    if(a <= sum && sum <= b) { ans += i; }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int a,v,b,w,t;
int main(){
	scanf("%d%d%d%d%d", &a, &v, &b, &w, &t);
	if(abs(a-b)<=(ll)(v-w)*t) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 1728
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

ans=sum(B)

for i in range(N-1):
    if A[i+1]==A[i]+1:
        ans+=C[A[i]-1]

print(ans)


Measured memory_bytes: 9072
#include<cstdio>
#include<cstring>

const int Maxv = 100005; 
int num[Maxv], n, L, l, r; 

inline int read(){
    int x = 0, f = 1; 
    char ch = getchar(); 
    while (ch < '0' || ch > '9') {
        if (ch == '-') {
            f = -1; 
        }
        ch = getchar(); 
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 3) + (x << 1) + ch - '0'; 
        ch = getchar(); 
    }
    return x * f; 
}

int main(){
    n = read(); 
    L = read(); 
    for (int i = 0; i < n; i++) {
        num[i] = read(); 
    }
    n--; 
    for (int i = 0; i < n; i++) {
        if (num[i] + num[i + 1] < L) {
            continue; 
        }
        l = 0; 
        r = n; 
        printf("Possible\n"); 
        for (int j = 0; j < n; j++) {
            if (l < i) {
                l++; 
                printf("%d\n", l); 
            }
            else {
                printf("%d\n", r); 
                r--; 
            }
        }
        return 0; 
    }
    printf("Impossible\n"); 
    return 0; 
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, D, A = map(int, input().split())
    XH = [None] * N
    X = [None] * N

    for i in range(N):
        XH[i] = tuple(map(int, input().split()))
        X[i] = XH[i][0]

    XH.sort()
    X.sort()
    
    ans = 0
    S = [0] * (N+1)# 与えたダメージ
    for i in range(N):
        if S[i] < XH[i][1]:
            # あと何回攻撃する？
            need = (XH[i][1]-S[i]+A-1)//A
            # 爆弾が届く範囲
            j = bisect_right(X,X[i]+2*D)
            # imos法
            S[i] += need*A
            S[j] -= need*A
            ans += need
        S[i+1] += S[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46284
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, A, B , bnum, num, ans = 0, mod;
    cin >> N >> A >> B;
    for (num = 1; num <= N; num++)
    {
        mod = 0;
        bnum = num;
        while (bnum > 0)
        {
            mod += bnum % 10;
            bnum = bnum / 10;
        }
        if (mod >= A && mod <= B)
        {
            ans += num;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]=='R') cout<<3;
    else if((s[0]==s[1] && s[1]=='R') || (s[1]==s[2] && s[2]=='R')) cout<<2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<1;
    else cout<<0;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

i64 digitsum(i64 b, i64 n) {
    if (n < b) return n;
    return digitsum(b, n / b) + n % b;
}

int main() {
    i64 n, s;
    cin >> n >> s;
    
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    
    if (n < s) {
        cout << -1 << endl;
        return 0;
    }
    
    for (i64 i = 2; i * i <= n; i++) {
        if (digitsum(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    
    i64 mi = 1e18;
    for (i64 i = 1; i * i < n; i++) {
        i64 b  = (n - s) / i + 1;
        if (b >= 2 && digitsum(b, n) == s) {
            mi = min(mi, b);
        }
    }
    
    cout << (mi == 1e18 ? -1 : mi) << endl;
}


Measured memory_bytes: 256
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
        ans+=2
    elif a[i]==b[i] and b[i]==c[i]:
        continue
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(){
  string input;
  cin >> input;
  char past;
  for(int i = 0; i < 3; i++){
	past = input[i];
    if(past == input[i+1]){
		cout << "Bad" << endl;
      	return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

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

#define MAX_N 500000

long long x[MAX_N];
long long y[MAX_N];
long long a[MAX_N], b[MAX_N];
long long n, q;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> x[i]; }
	sort(x, x + n);
	y[0] = 0;
	for (int i = 1; i <= n; i++) {
		y[i] = y[i - 1] + x[i - 1];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < q; i++) {
		long long r = upper_bound(x, x + n, a[i]) - x;
		if (y[r] < b[i]) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int &i: a) { cin >> i; ++b[i]; }
  int ma = *max_element(ALL(a));
  int mi = (ma + 1) / 2;
  bool flag = true;
  if (*max_element(begin(b), begin(b) + mi) > 0) flag = false;
  if (ma % 2) {
    if (b[mi] != 2) flag = false;
  }
  else {
    if (b[mi] != 1) flag = false;
  }
  if (*min_element(begin(b) + mi, begin(b) + ma + 1) == 0) flag = false;
  cout << (flag ? "Possible" : "Impossible") << endl;
  return 0;
}


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

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

const int maxn = 300;

struct Hash{
	ll h[maxn][2], pow[maxn][2], n, 
	   b[2] = {(ll)1e9+9, (ll)1e9+7}, 
	   mod[2] = {(ll)1e9+7, (ll)1e9+9}; 

	Hash(){}
	void init(string &str) {
		n = str.size() - 1; 	
		pow[0][0] = pow[0][1] = 1; 
		h[0][0] = h[0][1] = 0;

		for(int i = 1; i <= n; i++) {
			for(int j = 0; j < 2; j++) {
				pow[i][j] = pow[i-1][j] * b[j] % mod[j]; 
				h[i][j] = (h[i-1][j] * b[j] + str[i] - 'a' + 1) % mod[j];
			} 
		}	
	}

	pair<ll, ll> hash(int l, int r) {
		ll ret[2]; 
		for(int i = 0; i < 2; i++) {
			ret[i] = (h[r][i] - (h[l-1][i]*pow[r-l+1][i] % mod[i]) + mod[i]) % mod[i]; 
		}
		return pair<ll,ll>(ret[0], ret[1]);
	}
} h;

int main(int argc, char const *argv[]) {
	string s; cin >> s; s = "#" + s; 
	h.init(s); 
	for(int i = s.size() - 2; i >= 1; --i) if(~i & 1) {
		if(h.hash(1, i / 2) == h.hash(i / 2 + 1, i)) {
			cout << i << endl; return 0;
		}
	}
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if abs(y) > abs(x):
    if (x >= 0 and y > 0):
        print(abs(y - x))
    elif x * y <= 0:
        print(abs(y) - abs(x) + 1)
    else:
        print(abs(y) - abs(x) + 2)
else:
    if x > 0 and y > 0:
        print(x - y + 2)
    elif x * y < 0 or (y == 0 and x > 0):
        print(abs(x) - abs(y) + 1)
    else:
        print(abs(x - y))

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int N;

int off(int i) {
	return (N/2 - (N-i)/2-1);
}

int get(int i, int j) {
	return (j-off(i));
}

void Main() {
	cin >> N;
	vll A(N); cin >> A;
	vvll dp(N+1, vll(4, -LLINF));
	
	ll maxv = -LLINF;
	for (int i = 1; i <= N; i++) {
		for (int o = 0; o < 4; o++) {
			int j = o + off(i);	
			if (j > N/2) continue;
			if (j <= 0) continue;
			
			if (j == 1) { 
				dp[i][get(i, j)] = A[i-1]; 
				if (j == N/2) chmax(maxv, dp[i][get(i, j)]);
				//cout << i << " " << j << " " << dp[i][get(i, j)] << endl;
				continue;
			}

			if (i-2 >= 1 && get(i-2, j-1) < 4) chmax(dp[i][get(i, j)], dp[i-2][get(i-2, j-1)] + A[i-1]);
			if (i-3 >= 1 && get(i-3, j-1) < 4) chmax(dp[i][get(i, j)], dp[i-3][get(i-3, j-1)] + A[i-1]);
			if (i-4 >= 1 && get(i-4, j-1) < 4) chmax(dp[i][get(i, j)], dp[i-4][get(i-4, j-1)] + A[i-1]);
	
			if (j == N/2) chmax(maxv, dp[i][get(i, j)]);
			//cout << i << " " << j << " " << dp[i][get(i, j)] << endl;
		}
	}

	cout << maxv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 18744
fn solve(edges: Vec<Vec<usize>>, nodes: usize) {
    let mut is_used: Vec<bool> = vec![false; nodes];
    let mut lowlink: Vec<usize> = vec![1000000000; nodes];
    let mut orders: Vec<usize> = vec![0; nodes];
    let mut order = 0;
    let mut is_dfs_edge: Vec<_> = edges.iter().map(|es| vec![false; es.len()]).collect();
    let mut dfs_stack = vec![];
    let mut bridges = vec![];
    fn min(x: usize, y: usize) -> usize {
        if x < y {
            x
        } else {
            y
        }
    }
    fn max(x: usize, y: usize) -> usize {
        if x < y {
            y
        } else {
            x
        }
    }

    for i in 0..nodes {
        if is_used[i] {
            continue;
        }
        dfs_stack.push(i);
        // Root node
        'outer: while !dfs_stack.is_empty() {
            let node = *dfs_stack.last().unwrap();
            if !is_used[node] {
                is_used[node] = true;
                orders[node] = order;
                lowlink[node] = order;
                order += 1;
            }
            for (idx, &to) in edges[node].iter().enumerate() {
                if !is_used[to] {
                    // DFS.
                    dfs_stack.push(to);
                    is_dfs_edge[node][idx] = true;
                    continue 'outer;
                }
            }
            let last = dfs_stack.pop().unwrap();
            let parent = *dfs_stack.last().unwrap_or(&10000000);
            for (&to, &is_dfs) in edges[last].iter().zip(is_dfs_edge[node].iter()) {
                if to == parent {
                    continue;
                } else if is_dfs {
                    let low = lowlink[to];
                    lowlink[last] = min(lowlink[last], low);
                } else {
                    lowlink[last] = min(lowlink[last], orders[to]);
                }
                if orders[last] < lowlink[to] {
                    let from = min(last, to);
                    let to = max(last, to);
                    bridges.push((from, to));
                }
            }
        }
    }
    bridges.sort();
    for (s, t) in bridges {
        println!("{} {}", s, t);
    }
}

fn main() {
    use std::io::{BufRead, BufReader};
    let input = std::io::stdin();
    let input: Vec<_> = BufReader::new(input.lock())
        .lines()
        .filter_map(|e| e.ok())
        .collect();
    let (nodes, _num_edges) = {
        let x: Vec<usize> = input[0]
            .split_whitespace()
            .filter_map(|e| e.parse().ok())
            .collect();
        (x[0], x[1])
    };
    let mut edges: Vec<Vec<_>> = vec![vec![]; nodes];
    for line in input[1..].iter() {
        let edge: Vec<usize> = line
            .split_whitespace()
            .filter_map(|e| e.parse().ok())
            .collect();
        edges[edge[0]].push(edge[1]);
        edges[edge[1]].push(edge[0]);
    }
    solve(edges, nodes);
}



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

int main(){
    int m, n, ans=0, tmp=0; cin >> m >> n;
    vector<vector<int> >a(m,vector<int>(n));
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
            tmp += a[i][j];
        }
        ans = max(ans, tmp);
        tmp =0;
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	Node T[];
	int root;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		T = new Node[n];
		for(int i = 0; i < n; i++) {
			T[i] = new Node(-1);
		}
		for(int i = 0; i < n; i++) {
			int id = sc.nextInt();
			int l = sc.nextInt();
			int r = sc.nextInt();
			T[id].left = l;
			T[id].right = r;
			if(l != -1) T[l].parent = id;
			if(r != -1) T[r].parent = id;
		}
		for(int i = 0; i < n; i++) {
			if(T[i].parent == -1) root = i;
		}
		
		//Preorder巡回
		System.out.println("Preorder");
		preParse(root);
		System.out.println();
		
		//Inorder巡回
		System.out.println("Inorder");
		inParse(root);
		System.out.println();
		
		//Postorder巡回
		System.out.println("Postorder");
		postParse(root);
		System.out.println();
		
		sc.close();
	}
	void preParse(int u) {
		if(u == -1) return;
		System.out.print(" " + u);
		preParse(T[u].left);
		preParse(T[u].right);
	}
	
	void inParse(int u) {
		if(u == -1) return;
		inParse(T[u].left);
		System.out.print(" " + u);
		inParse(T[u].right);
	}
	
	void postParse(int u) {
		if(u == -1) return;
		postParse(T[u].left);
		postParse(T[u].right);
		System.out.print(" " + u);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
class Node {
	int left, right, parent;
	public Node(int parent) {
		this.parent = parent;
	}
}


Measured memory_bytes: 26408
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char alphabet[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	int n_alphabet[26] = { 0 };
	string s;

	while (getline(cin,s)) {
		//getline(cin, s);
		//if (s.empty())break;//???????????????????????°break
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < 26; j++) {
				if (s[i] == alphabet[j] || tolower(s[i]) == alphabet[j]) {
					n_alphabet[alphabet[j] - 'a'] += 1;
					break;
				}
			}
		}
	}

	//output
	for (int i = 0; i < 26; i++) {
		cout << alphabet[i] << " : " << n_alphabet[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int x,y; cin>>x>>y;
    bool xx=false,yy=false;
    vector<int>a={1,3,5,7,8,10,12};
    rep(i,7){
        if(a[i]==x)xx=true;
        if(a[i]==y)yy=true;
    }
    if(xx&&yy){
        cout<<"Yes"<<endl;
        return 0;
    }
    xx=false;yy=false;
    vector<int>b={4,6,9,12};
    rep(i,4){
        if(b[i]==x)xx=true;
        if(b[i]==y)yy=true;
    }
    if(xx&&yy){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(x==2&&y==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}





Measured memory_bytes: 256