akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
       try{ String line1 = reader.readLine();
        int N = Integer.parseInt(line1);
        String line2 = reader.readLine();
        String[] split = line2.split(" ");
        int[] A = new int[N];
        for(int i = 0; i < N ; i ++){
            A[i] = Integer.parseInt(split[i]);
        }
        int count = 0;
        for(int j = 1; j<N;j++){
        for(int i = j;i >= 1; i-- ){
            if(A[i-1] > A[i]){
                int temp = A[i-1];
                A[i-1] = A[i];
                A[i] = temp;
                count ++;
            }
        }}
        for(int i = 0; i<N; i++){
            if(i != N-1){
                System.out.print(A[i] + " ");
            }else{
                System.out.println(A[i]);
            }
        }
        System.out.println(count);
       }catch(IOException e){

       }
    }
}


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


int main(){
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C)), COL(N, vector<int>(N));
    for(int i = 0; i < C; i++) for(int j = 0; j < C; j++) cin >> D[i][j];
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) {cin >> COL[i][j]; COL[i][j]--;}

    vector<vector<ll>> DP(3, vector<ll>(C));

    ll MIN = 1e18;

    for(int i = 0; i < C; i++){ // color
        ll ans1=0, ans2=0, ans3=0;
        for(int h = 0; h < N; h++){
            
            for(int w = 0; w < N; w++){
                int clr = (h+w+2)%3;
                if(clr == 0) ans1 += D[COL[h][w]][i];
                else if(clr == 1) ans2 += D[COL[h][w]][i];
                else ans3 += D[COL[h][w]][i];
            }
        }
        DP[0][i] = ans1;
        DP[1][i] = ans2;
        DP[2][i] = ans3;

    }

    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            for(int k = 0; k < C; k++){
                if(i == j || j == k || k == i) continue;
                MIN = min(MIN, (ll)(DP[0][i] + DP[1][j] + DP[2][k]));
                //cout << 
            }
        }
    }
    cout << MIN << endl;



}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {

            class sp {
                int index;
                String s;
                int p;
            }
            int n = sc.nextInt();
            List<sp> sps = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                sp tmp = new sp();
                tmp.index = i;
                tmp.s = sc.next();
                tmp.p = sc.nextInt();
                sps.add(tmp);
            }

            sps.sort(new Comparator<sp>() {
                @Override
                public int compare(sp sp1, sp sp2) {
                    if (sp1.s.equals(sp2.s)) return (sp2.p - sp1.p);
                    else return sp1.s.compareTo(sp2.s);
                }
            });
            for (int i = 0; i < n; i++) {
                System.out.println(sps.get(i).index + 1);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
// const int INF  = 1<<30;
const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  vector<P> v(2*n);
  VV pos(2, V(n));
  VVV cum(2, VV(2*n+1, V(n+1)));

  rep(i, 2*n) {
    char c; int a; cin >> c >> a;
    --a;
    int j = (c == 'W' ? 0 : 1);
    pos[j][a] = i;
    ++cum[j][i+1][a];
  }

  rep(i, 2) {
    rep(j, 2*n+1) drep(k, n-1) cum[i][j][k] += cum[i][j][k+1]; 
    rep(j, 2*n) drep(k, n) cum[i][j+1][k] += cum[i][j][k];
  }

  VVll dp(n+1, Vll(n+1, INFll));
  dp[0][0] = 0;

  rep(i, n+1) rep(j, n+1) {
    if (i < n) chmin(dp[i+1][j], dp[i][j] + cum[0][pos[0][i]][i] + cum[1][pos[0][i]][j]);
    if (j < n) chmin(dp[i][j+1], dp[i][j] + cum[0][pos[1][j]][i] + cum[1][pos[1][j]][j]);
  }

  ll ans = dp[n][n];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 97452
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] x = new int[3];
        x[0] = sc.nextInt();
        x[1] = sc.nextInt();
        x[2] = sc.nextInt();

        if(x[0]<x[1] && x[1] < x[2]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}


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

int main() {
	string A, B, C;
	cin >> A >> B >> C;

	int a, b, c;
	a = A.size() - 1;
	b = B.size() - 1;
	c = C.size() - 1;

	if (A.at(a) == B.at(0) && B.at(b) == C.at(0))
		cout << "YES" << endl;

	else
		cout << "NO" << endl;

}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

  string s;
  cin >> s;

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
using namespace std;

// map<ll,ll> dp[N*100];

ll n,ar[N],val[N],w[N],q,dp[105][100005];

ll f(ll ind,ll k)
{
	if(k>q)
		return dp[ind][k]=-999999999;
	if(ind>n)
		return dp[ind][k]=0;
	if(dp[ind][k])
		return dp[ind][k];
	ll t1=0;
	if(k+w[ind]<=q)
		t1=f(ind+1,w[ind]+k)+val[ind];
	ll t2=f(ind+1,k);

	return dp[ind][k]=max(t1,t2);
}

int main()
{
	fast;
	cin>>n>>q;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>val[i];
	ll a=f(1,0);
	cout<<a;
}


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

int main() {

  int r, c;
  cin >> r >> c;

  vector<vector<int>> rc(r + 1, vector<int>(c + 1));

  for (int i = 0; i < r; i++) {
    int c_ = 0;
    for (int j = 0; j < c; j++) {
      cin >> rc[i][j];
      c_ += rc[i][j];
    }
    rc[i][c] = c_;
  }

  for (int i = 0; i < c + 1; i++) {
    int r_ = 0;
    for (int j = 0; j < r; j++) {
      r_ += rc[j][i];
    }
    rc[r][i] = r_;
  }

  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      cout << rc[i][j];
      if (j != c) {
        cout << " ";
      }
    }
    cout << endl;
  }

  return 0;

}


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

int main() {
    int n;
    scanf("%d", &n);
    vector< int> v(n);
    for (int &a : v) cin >> a;
    long long res = 0;

    int sum = 0;
    for(int l = 0, r = 0; l < n; ++l) {
        while(r < n and (sum & v[r]) == 0) {
            sum ^= v[r];
            r++;
        }
        res += r - l;
        //if(l == r) r++;
       // else 
        sum ^= v[l];
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) cin>>x>>y; f0(i,0,k){int x,y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int mon[501][501];
int cnt[501][501];

signed main()
{
    fast

    int a;
    cin>>a;

    cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	vi h(N);
	rep(i, N) {
		cin >> h[i];
	}
	A -= B;
	int ng = 0, ok = INF;
	while (ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		ll num = 0;
		rep(i, N) {
			if (h[i] > B*mid) {
				num += (h[i] - B*mid + A - 1) / A;
			}
		}
		//cout << num << endl;
		if (num <= mid) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 640
a=[]
5.times do
  a.push gets.chomp.to_i
end

min = a.first
minp = 0
a.each_with_index do |e, i|
  if min%10 > e%10 && e%10 != 0
    min = e
    minp = i
  end
end

ans = min
a.delete_at(minp)
a.each do |e|
  if e % 10 == 0
    ans += e
  else
    num = e.to_s
    num[-1] = '0'
    ans += num.to_i + 10
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
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;
using P=pair<ll,ll>;
template <class T> using vec=vector<T>;
template <class T> using vvec=vec<vec<T>>;



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

    while(true){
        ll n,m;
        cin>>n>>m;
        if(n==0 && m==0) break;
        vvec<int> g(n);
        REP(i,m){
            int u,v;
            cin>>u>>v;
            u--;v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }

        vec<ll> con(n,-1);

        auto dfs=[&](auto &&self, int v)->bool{
            for(auto to:g[v]){
                if(con[to]==-1){
                    con[to]=!con[v];
                    if(!self(self,to)){
                        return false;
                    }
                }else{
                    if(con[to]==con[v]) return false;
                }
            }
            return true;
        };

        con[0]=0;
        set<ll> st;
        if(dfs(dfs, 0)){
            ll num1=0;
            REP(i,n) if(con[i]) num1++;
            ll num0=n-num1;
            if(num0%2==0) st.insert(num0/2);
            if(num1%2==0) st.insert(num1/2);
        }
        cout<<st.size()<<"\n";
        for(auto i:st){
            cout<<i<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3216
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random

# sys.stdin = open('input')

def inp():
    re = map(int, raw_input().split())
    if len(re) == 1:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def my_main():
        n, s = inp()
        da = inp()
        dp = [[0 for i in range(s+1)] for i in range(n+1)]
        sm = [0 for i in range(s+1)]
        dp[0][0] = sm[0] = 1
        mod = 998244353
        for i in range(1, n+1):
            now = da[i-1]
            dp[i][0] = 1
            for j in range(s+1):
                if j>=now:
                    dp[i][j] += sm[j-now]
                dp[i][j] %= mod
            for j in range(s+1):
                sm[j] += dp[i][j]
                sm[j] %= mod
        ans = 0
        for i in range(n+1):
            ans += dp[i][s]*(n-i+1)
            ans %= mod
        print ans



my_main()


Measured memory_bytes: 103196
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk, mem;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    now = ans = nn;
    rep(i, m) {
        while('0' <= *pos) {
            mem <<= 1;
            mem += mem << 2;
            mem += *pos++ - '0';
        }
        pos++;
        k -= mem;
        mem = 0;
        if(k < 0) break;
        while(a[now] > k) --now;
        ans = max(ans, i + 1 + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7752
import * as fs from "fs";

function calcCombination(n: number) {
	return n * (n - 1) / 2;
}

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const a = input[1].split(" ").map((x: string): number => +x);

const dict: Array<number> = [];
for (const ball of a) {
	if (dict[ball] === undefined) dict[ball] = 0;
	dict[ball] += 1;
}

// pre-calc
const combinations = new Array(n + 1);
for (const value of dict) {
	if (value === undefined) continue;
	if (combinations[value] === undefined) {
		combinations[value] = calcCombination(value);
	}
	if (combinations[value - 1] === undefined) {
		combinations[value - 1] = calcCombination(value - 1);
	}
}

let all_sum = 0;
for (const value of dict) {
	if(value === undefined) continue;
	all_sum += combinations[value];
}

for (let i = 0; i < n; i++) {
	const count: number = dict[a[i]];
	const ans = all_sum - combinations[count] + combinations[count - 1];
	console.log(ans);
}


Measured memory_bytes: 49208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB")
		puts("No");
	else
		puts("Yes");
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String U = sc.next();
    if (U.equals(S)){
      A--;
    }else{
      B--;
    }
    System.out.println(A + " " + B);
  }
}

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

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	int len = s.length();
	if (len<=k) cout << s << endl;
	else {
		rep(i,k) cout << s[i];
		cout << "..." << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
    double pi = 3.141592653589793;
    double a,b,h,m; 
    cin>>a>>b>>h>>m;
    double angle = abs(h/12.0 + m/720 - m/60.0) * 360;
    angle = min(double(360-angle), double(angle));
    // cout<<angle<<endl;
    double ans = a*a + b*b - 2.0 * a *b* cos(angle*pi/180);

    // cout<<cos(90)<<endl;
    cout<<fixed<<setprecision(10)<<sqrt(ans)<<endl;
    return 0;

}

Measured memory_bytes: 4240
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

vector<int> curr;
vector<vector<int>> all;

void backtrack(int rem) {
	if(rem == 0) {
		all.emplace_back(curr);
		return;
	}

	if(size(curr) == 0)
		FOR(i, 1, 9) {
			curr.emplace_back(i);
			backtrack(rem - 1);
			curr.pop_back();
		}
	else
		REP(i, 10)
			if(abs(i - curr.back()) <= 1) {
				curr.emplace_back(i);
				backtrack(rem - 1);
				curr.pop_back();
			}
}

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

	int k;
	cin >> k;

	for(int len = 1; size(all) < k; ++len)
		backtrack(len);
	sort(all.begin(), all.end(), [&](vector<int> &a, vector<int> &b) {
		if(size(a) != size(b))
			return size(a) < size(b);
		return a < b;
	});
	debug(all);
	auto out = all[k - 1];
	for(int digit : out)
		cout << digit;
	cout << '\n';
}


Measured memory_bytes: 15532
#include<bits/stdc++.h>
#define pb push_back
#define ins(a,b) top++,px[top]=a,py[top]=b
using namespace std;
int rd()
{
	int rx=0,fx=1;char c=getchar();
	while(c<48||c>57)
	{
		if(c=='-') fx=-1;
		c=getchar();
	}
	while(c>=48&&c<=57)
	{
		rx=rx*10+c-48;
		c=getchar();
	}
	return rx*fx;
}
const int N=2050;
int n,m,ans=0,cur,top=0;
int L[N],R[N],px[N],py[N];
vector<int> e[N];
namespace NS
{
	vector<int> e[N];
	void insert(int x,int y);
	struct Tree
	{
		int id;
		int tag[N],fa[N]; 
		void dfs(int x)
		{
			int i,vsi,v;
			vsi=e[x].size();
			for(i=0;i<vsi;i++)
			{
				v=e[x][i];
				if(v==fa[x]) continue;
				fa[v]=x;dfs(v);
			}
		}
		void mcol(int x,int w)
		{
			if(tag[x])
			{
				if(x!=w) ins(w,x);
				return ;
			}
			int i,vsi,v;
			tag[x]=w;
			vsi=e[x].size();
			for(i=0;i<vsi;i++)
			{
				v=e[x][i];
				if(v==fa[x]) continue;
				mcol(v,w);
			}
		}
		void gedge(int x)
		{
			if(tag[x])
			{
				//printf("edge%d %d\n",id,x);
				::e[id].pb(x);
				return ;
			}
			int vsi,i,v;
			vsi=e[x].size();
			for(i=0;i<vsi;i++)
			{
				v=e[x][i];
				if(v==fa[x]) continue;
				gedge(v);
			}
		}
	}tr[N];
	void insert(int x,int y)
	{
		//printf("I %d %d\n",x,y);
		if(tr[x].tag[y]) 
		{
			//printf("root%d pos%d %d\n",x,y,tr[5].tag[2]);
			if(tr[x].tag[y]!=y) ins(tr[x].tag[y],y);
		}
		else if(tr[y].tag[x]) 
		{
			//printf("root%d pos%d %d\n",y,x,tr[5].tag[2]);
			if(tr[y].tag[x]!=x) ins(tr[y].tag[x],x);
		}
		else 
		{
			//printf("col%d %d start\n",x,y);
			tr[x].mcol(y,y);
			//printf("col%d %d end\n",x,y);
			//printf("col%d %d start\n",y,x);
			tr[y].mcol(x,x);
			//printf("col%d %d end\n",y,x);
		}
	}
	void Init()
	{
		int i,x,y;
		for(i=1;i<n;i++)
		{
			x=rd();y=rd();
			e[x].pb(y);e[y].pb(x);
		}
		for(i=1;i<=n;i++) 
		{
			tr[i].id=i;tr[i].dfs(i);
		}
	}
	void dfs(int x,int nf)
	{
		int vsi,i,v;
		L[x]=++cur;
		vsi=e[x].size();
		for(i=0;i<vsi;i++)
		{
			v=e[x][i];
			if(v==nf) continue;
			dfs(v,x);
		}
		R[x]=cur;
	}
}
void dfs(int x)
{
	int vsi,i,v;
	vsi=e[x].size();
	for(i=0;i<vsi;i++)
	{
		v=e[x][i];
		if(L[v]>=L[x]&&R[v]<=R[x]) 
		{
			//printf("S%d %d\n",x,v);
			ans++;dfs(v);
		}
	}
}
int main()
{
	int i,a,b;
	n=rd();m=rd();
	NS::Init();
	for(i=1;i<=m;i++)
	{
		a=rd();b=rd();
		ins(a,b);
		while(top>0) top--,NS::insert(px[top+1],py[top+1]);
		//puts("OK");
	}
	for(i=1;i<=n;i++) NS::tr[i].gedge(i);
	for(i=1;i<=n;i++) 
	{
		cur=0;NS::dfs(i,0);
		dfs(i);
	}
	ans>>=1;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 33408
s = input()
res = [0] * (len(s)+1)
 
for i in range(len(s)):
  if s[i] == "<":
    res[i +1] = res[i] +1
 
for i in range(len(s)-1,-1,-1):
  if s[i] == ">":
    res[i] = max(res[i], res[i+1]+1)
 
print(sum(res))

Measured memory_bytes: 23336
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=0;i<(s.size()+1)/2;i++){
        cout << s[2*i];
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   ll x,y;
           cin>>x>>y;
           if(x%y==0){
            cout<<-1<<endl; 
           }
           else{
            cout<<x*(y+1)<<endl; 
           }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  double x[3], y[3];
  for(i=0; i<3; i++) cin >> x[i] >> y[i];
  
  double d[3];
  for(i=0; i<3; i++) {
    double tx=abs(x[i]-x[(i+1)%3]);
    double ty=abs(y[i]-y[(i+1)%3]);
    d[i]=sqrt(tx*tx+ty*ty);
  }
  
  double tanhfA[i];
  for(i=0; i<3; i++) {
    double a=d[i];
    double b=d[(i+1)%3];
    double c=d[(i+2)%3];
    double cosA=(b*b+c*c-a*a)/(2*b*c);
    tanhfA[i]=sqrt((1-cosA)/(1+cosA));
  }
  
  double ans=0;
  for(i=0; i<3; i++)
    chmax(ans, d[i]/(1/tanhfA[(i+1)%3]+2+1/tanhfA[(i+2)%3]));
  printf("%.12f\n", ans);
  
}





Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
   x = int(input())
   if x == 0:
      break
   
   y = 1000 - x;
   a = y % 500
   b = a % 100
   c = b % 50
   d = c % 10
   e = d % 5
   z = y // 500 + a // 100 + b // 50 + c // 10 + d // 5 + e
   
   print(z)
   



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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int main(){
 
  int a, b; cin >> a>> b;
  if(a == b){
    pr(a + b);
  }
  else{
    cout << max(a, b) + max(a,b) - 1 << endl;
  }
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>hoge(3*n);
  priority_queue<ll>kouhan;
  priority_queue<ll,vector<ll>,greater<ll> >zenhan;
  vector<ll>aha,ihi;
  ll summae=0;
  ll sumushiro=0;
  for(int i=0;i<3*n;i++){
    cin>>hoge[i];
    if(i<n){zenhan.push(hoge[i]);summae+=hoge[i];}
    if(i>=2*n){kouhan.push(hoge[i]);sumushiro+=hoge[i];}
  }
  // cout<<zenhan.size()<<" "<<kouhan.size()<<endl;
  aha.pb(summae);
  ihi.pb(sumushiro);
  ll ans=-llINF;
  for(int i=n;i<2*n;i++){
    if(zenhan.top()<hoge[i]){
      summae+=hoge[i]-zenhan.top();
      zenhan.pop();
      zenhan.push(hoge[i]);
    }
    if(kouhan.top()>hoge[3*n-i-1]){
      sumushiro-=kouhan.top()-hoge[3*n-i-1];
      kouhan.pop();
      kouhan.push(hoge[3*n-i-1]);
    }
    aha.pb(summae);
    ihi.pb(sumushiro);
  }
  for(int i=0;i<n+1;i++){
    //cout<<aha[i]<<" "<<ihi[n-i]<<endl;
    ans=max(ans,aha[i]-ihi[n-i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6516
using System;
using System.Collections.Generic;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split(' ');
            HashSet<int> vs = new HashSet<int>();
            vs.Add(int.Parse(abc[0]));
            vs.Add(int.Parse(abc[1]));
            vs.Add(int.Parse(abc[2]));
            Console.WriteLine(vs.Count == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
N=int(input())
val=[]
cnt=0
for i in range(1,6,1):
    val.append(pow(9,i))
for i in range(1,7,1):
    val.append(pow(6,i))
val.append(1)
val.sort(reverse=True)
#print(val)
dp=[float("inf")]*(N+1)
dp[0]=0
for i in range(N+1):
    for j in range(len(val)):
        if val[j]<=i:
            dp[i]=min(dp[i],dp[i-val[j]]+1)
    #print(dp)
    #input()
print(dp[N])

Measured memory_bytes: 44492
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    VI l(n);
    REP(i,0,n) cin >> l[i];
    int ans = 1<<30;
    REP(i,0,1<<(n*2)) {
        int p = i;
        int suma = 0, sumb = 0, sumc = 0;
        int cost = -30;
        REP(j,0,n) {
            switch(p%4) {
                case 1:
                    suma += l[j];
                    cost += 10;
                    break;
                case 2:
                    sumb += l[j];
                    cost += 10;
                    break;
                case 3:
                    sumc += l[j];
                    cost += 10;
                    break;
            }
            p /= 4;
        }
        if (suma == 0 || sumb == 0 || sumc == 0) continue;
        cost += abs(suma - a);
        cost += abs(sumb - b);
        cost += abs(sumc - c);
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	ll n,k;
	cin >> n >> k;

	n %= k;
	n = min(n, k - n);

	cout << n << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int A , B ;
    cin >> A >> B ;
    if(A+B >=10){
        cout <<"error"<< endl;
    }else{
        cout << A+B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		Stack<Integer> data = new Stack<Integer>();
		while(s.hasNext()){
			int in = s.nextInt();
			if(in != 0)
				data.push(new Integer(in));
			else
				System.out.println(data.pop());
		}
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll g[500005],mx[500005],ne[500005];
int main()
{
    ll n,m,i,j,x,y,k;
    cin >> n >> m;


    for(i=1;i<=n;i++)
    	cin >> g[i];
    for(i=1;i<=m;i++)
    {
    	cin >> x >> y;
    	ne[x]++,ne[y]++;
    	mx[x]=max(mx[x],g[y]);
    	mx[y]=max(mx[y],g[x]);
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
    	if(!ne[i])ans++;
    	else
    	{
    		if(mx[i]<g[i])
    			ans++;
    	}
    }
    cout<<ans<<endl;
}

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

void insertionSort(vector<int> &a, int n, int g, int &cnt)
{
  for (int i = g; i < n; ++i)
  {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v)
    {
      a[j + g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
}

void shellSort(vector<int> &a, int n)
{
  int cnt = 0;

  vector<int> g;
  int val = 1;
  for (int i = 1; val <= n; ++i)
  {
    g.push_back(val);
    val = 3 * val + 1;
  }
  int m = g.size();
  reverse(g.begin(), g.end());

  for (int i = 0; i < m; ++i)
  {
    insertionSort(a, n, g[i], cnt);
  }
  cout << m << endl;

  for (int i = 0; i < m; ++i)
    cout << g[i] << " \n"[i == m - 1];

  cout << cnt << endl;

  for (int i = 0; i < n; ++i)
    cout << a[i] << endl;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  shellSort(a, n);

  return 0;
}



Measured memory_bytes: 6688
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main(void) {
    LL a,b,x;
    cin >> a >> b >> x;
    if(x>=a&&(a+b)>=x)
        cout << "YES";
        else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ll, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// #define multicase
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll N = 2e3 + 5;

ll n;
ll dp[N];

void computeDP() {
    dp[0] = 1;
    for(ll i = 1; i <= n; i++) {
        ll &sol = dp[i];
        for(ll j = 3; j <= i; j++) {
            (sol += dp[i - j]) %= MOD;
        }
    }
}

void solve() {
    ll T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> n;
        computeDP();
        cout << dp[n] << "\n";
    }
}

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


Measured memory_bytes: 3644
import java.util.*;
public class Main {
	static int n;
	static long[] a=new long[3005];
	static boolean[][] vis=new boolean[3005][3005];
	static long[][] dp=new long[3005][3005];
	static long DP(int x,int y) {
		if (x+y>=n) return 0;
		if (vis[x][y]) return dp[x][y];
		vis[x][y]=true;
		if ((x+y)%2==0) dp[x][y]=Math.max(DP(x+1,y)+a[x],DP(x,y+1)+a[n-1-y]);
		else dp[x][y]=Math.min(DP(x+1,y)-a[x],DP(x,y+1)-a[n-1-y]);
		return dp[x][y];
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		for (int i=0;i<n;++i) a[i]=in.nextLong();
		System.out.println(DP(0,0));
	}
}

Measured memory_bytes: 133412
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define MST(vv,x) memset(vv,x,sizeof(vv))
#define ll long long
#define maxn 30
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if((n+m)%3==0||n%3==0||m%3==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;
    }
    return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

ll score[1<<16];
ll DP[1 << 16];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vector<vll> a(n, vll (n));
	M00(i, n) M00(j, n) cin >> a[i][j];
	//2^n * n^2
	M00(i, 1 << n) {
		score[i] = 0;
		M00(j, n) M00(k, n) {
			int temp = (1 << k) + (1 << j);
			if(k < j && ((i & temp) == temp)) score[i] += a[j][k];
		}
		//dbg(i _ score[i]);
	}
	//DP
	M00(i, 1 << n) {
		//iterate through submasks
		int j = i;
		DP[i] = 0;
		while(j > 0) {
			DP[i] = max(DP[i], score[j] + DP[i ^ j]);
			j--;
			j &= i;
		}
	}
	cout << DP[(1 << n) - 1] << endl;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d = map(int, readline().split())
if a >= 0 and c >= 0:
    print(b*d)
elif b <= 0 and d <= 0:
    print(a*c)
else: 
    print(max(a*d,b*d,a*c,b*c))

Measured memory_bytes: 61752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = a+b;
    if(ans % 2 == 0) cout << ans/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
P = set(map(int, input().split()))
U = set(range(-200, 201))
diff = sorted(list(U - P))

ans = 0
tmp = float('inf')
for i in diff:
    if tmp > abs(X - i):
        tmp = abs(X - i)
        ans = i
print(ans)


Measured memory_bytes: 9224
#include <stdio.h>
#include <math.h>
#include <ctype.h>

#define PI (3.14159265359)

int main(int argc, char *argv[])
{
    int a, b, c;
    double S, L, h;

    scanf("%d%d%d", &a, &b, &c);
    S = sin(c * PI / 180) * a * b / 2;
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * PI / 180));
    h = S * 2 / a;
    
    printf("%.8f\n", S);
    printf("%.8f\n", L);
    printf("%.8f\n", h);
    return 0;
}



Measured memory_bytes: 2100
require 'prime'
n = gets.to_i
pd = n.prime_division
ans = 0
pd.each do |v|
  k = 1
  while true do
    if v[1] >= k
      v[1] -= k
      ans += 1
      k += 1
    else
      break
    end
  end
end
puts ans


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

//ABC110C
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int i, len, alps[27];
  char s[200001], t[200001];
  scanf("%s %s", &s, &t);

  for(len=0; s[len]!='\0'; ++len)
    ; //文字数
  for(i=0; i<27; i++)
    alps[i]=-1;

  for(i=0; i<len; i++){
    if(alps[s[i]-97]==-1||alps[s[i]-97]==t[i]-97) alps[s[i]-97]=t[i]-97;
    else{
      printf("No");
      return 0;
    }
  }
  qsort(alps, 26, sizeof(int), compare_int); //sort
  for(i=0; i<26; i++){
    if(alps[i]==alps[i+1]&&alps[i]!=-1){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 2e6;

string s;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
	
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";


	
	
	return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
const int mod = (119<<23)+1;
const int M = 1e9+7;
const int N = 1e5+5;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << fixed << setprecision(15);
	
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n) cout << s[i] << t[i];
}


Measured memory_bytes: 256