akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x_2000 = sc.nextInt();
		long crt = x_2000;
		for(int i = 0; i < 10; i ++) {
			crt = crt *r - D;
			System.out.println(crt);
		}
	}
}

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

int main() {
  string S;
  cin >> S;
  
  bool h_MM_flag = true;
  bool l_MM_flag = true;
  int high_num = (S[0] - '0') * 10 + S[1] - '0';
  int low_num = (S[2] - '0') * 10 + S[3] - '0';
  
  if (high_num == 0  || high_num >= 13) {
    h_MM_flag = false;
  }
  
  if (low_num == 0  || low_num >= 13) {
    l_MM_flag = false;
  }

  string str = "";
  if (h_MM_flag == false && l_MM_flag == true) {
    str = "YYMM";
  }
  else if (h_MM_flag == true && l_MM_flag == false) {
    str = "MMYY";
  }
  else if (h_MM_flag == false && l_MM_flag == false) {
    str = "NA";
  } else {
    str = "AMBIGUOUS";
  }
  
  cout << str << endl;
  
  return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  cout<<"ABC"<<N<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#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;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    cout<<setprecision(16);
    ll n;
    cin>>n;
    for(ll h=1;h<=3500;h++){
        for(ll w=1;w<=3500;w++){
            ll b=4*h*w-n*(w+h);
            ll a = n*h*w;

            if(b<=0){continue;}
            else{

                if(a%b==0){
                 cout<<h<<" "<<w<<" "<<a/b<<endl;
//                 cout<<"debag"<<endl;
//                 cout<<4/double(n)<<endl;
//                 cout<<1/double(h)+1/double(w)+1/double(a/b)<<endl;

                 return 0;
                }
            }


        }
    }


    return 0;
}


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

int main() {
  int N; std::cin >> N;
  std::string s; std::cin >> s;
  std::vector<int> p(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    p[i] = 'E' == s[i];
    sum += p[i];
  }
  
  int ans = sum - p[0];
  int r = sum - p[0];
  int l = 0;
  for (int i = 1; i < N; ++i) {
    r -= p[i];
    l += p[i-1];
    ans = std::min(r+(i-l), ans);
  }
  std::cout << ans << std::endl;
  
}


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

int main(){
  int n; cin>>n;
  string s,t,u; cin>>s >>t;
  for(int i=0;i<=n;i++){
    u=s.substr(0,i)+t;
    if(u.substr(0,n)==s){
      break;
    }
  }
  cout<<(int)u.size()<<endl;
  return 0;
}

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

using namespace std;

int x;

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

signed main()
{
	x = read();
	for(int i=0;i<=1000;i++)for(int j=i;j<=1000;j++)
	{
		int i5=i*i*i*i*i,j5=j*j*j*j*j;
		if(i5+j5==x)
		{
			printf("%lld %lld",i,-j);
			return 0;
		}
		if(i5-j5==x)
		{
			printf("%lld %lld",i,j);
			return 0;
		}
		if(-i5+j5==x)
		{
			printf("%lld %lld",j,i);
			return 0;
		}
		if(-i5-j5==x)
		{
			printf("%lld %lld",-i,j);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<Mint> dp(n, V<Mint>(n + 1));
  dp[n - 1][1] = 1;
  for (int i = 0; i < m; ++i) {
    VV<Mint> ndp(n, V<Mint>(n + 1));
    for (int x = 0; x < n; ++x) for (int y = 1; y <= n; ++y) {
      ndp[x][n - x] += dp[x][y] * y;
      ndp[x][y] += dp[x][y] * (n - x - y);
      if (x) ndp[x - 1][y] += dp[x][y] * x;
    }
    swap(dp, ndp);
  }
  cout << dp[0][n] << '\n';
}

Measured memory_bytes: 1048
using System;
using System.Collections.Generic;
class Solve{
    int H,W;
    int[,] color;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        long count = 0;
        for(int i=0;i<W-1;i++){
            int[,] d = new int[H+1,H+1];
            int[,] dp = new int[H+1,H+1];
            for(int j=0;j<H+1;j++){
                for(int k=0;k<H+1;k++){
                    if(j == 0 || k == 0){
                        d[j,k] = 0;
                    }
                    else{
                        if(color[i,H-j] == color[i+1,H-k]){
                            d[j,k] = d[j-1,k-1] + 1;
                        }
                        else{
                            d[j,k] = d[j-1,k-1];
                        }
                    }
                }
            }
            for(int j=H;j>=0;j--){
                for(int k=H;k>=0;k--){
                    if(j == H && k == H){
                        dp[j,k] = 0;
                    }
                    else if(j == H){
                        dp[j,k] = dp[j,k+1]+d[j,k+1];
                    }
                    else if(k == H){
                        dp[j,k] = dp[j+1,k]+d[j+1,k];
                    }
                    else{
                        dp[j,k] = dp[j,k+1]+d[j,k+1] < dp[j+1,k]+d[j+1,k] ? dp[j,k+1]+d[j,k+1] : dp[j+1,k]+d[j+1,k];
                    }
                }
            }
            count += dp[0,0];
        }
        Console.WriteLine(count);
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        H = int.Parse(str[0]);
        W = int.Parse(str[1]);
        color = new int[W,H];
        for(int i=H-1;i>=0;i--){
            string s = Console.ReadLine();
            for(int j=0;j<W;j++){
                color[j,i] = s[j] - 'a';
            }
        }
    }    
}

Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> L(k), R(k);
  for (int i = 0; i < k; ++i) cin >> L[i] >> R[i];
  vector<int64> f(3 * n);
  f[1] = 1;
  f[2] = -1;
  const int64 mod = 998244353;
  for (int i = 1; i <= n; ++i) {
    (f[i] += f[i - 1]) %= mod;
    for (int j = 0; j < k; ++j) {
      (f[i + L[j]] += f[i]) %= mod;
      (f[i + R[j] + 1] -= f[i]) %= mod;
    }
  }
  cout << (f[n] % mod + mod) % mod;

  return 0;
}
//2020.09.19 20:10:44


Measured memory_bytes: 7948
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 dp[1000010][2];

int main() {
    string s; cin >> s;
    reverse(all(s));
    s += '0';
    int n = s.length();

    rep(i, n+1) rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n) rep(j, 2) {
        int x = s[i] - '0';
        x += j;
        rep(a, 10) {
            int ni = i+1, nj = 0;
            int b = a - x;
            if (b < 0) {
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
        }
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 9220
a, b, c = map(int, input().split())
ans = 0
if a == b == c:
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        pass
    else:
        ans = -1
else:
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        ans += 1
        a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		int arr[n],ans=0;
		F(i,0,n) getI(arr[i]);
		F(i,0,n){
			while(arr[i]%2==0&&arr[i]!=1){
				arr[i]/=2;
				ans++;
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
using System;

// 計算機

public class ITP1_4_C
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        while (true)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            string op = input[1];
            int b = int.Parse(input[2]);

            if (op == "?")
            {
                break;
            }

            switch (op)
            {
                case "+":
                    Console.WriteLine($"{a + b}");
                    break;
                case "-":
                    Console.WriteLine($"{a - b}");
                    break;
                case "/":
                    Console.WriteLine($"{a / b}");
                    break;
                case "*":
                    Console.WriteLine($"{a * b}");
                    break;
            }
        }
    }
}



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

using namespace std;

int main()
{
    int n,q,count=0;
    int S[100000],T[50000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>S[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>T[i];
        if(*lower_bound(S,S+n,T[i])==T[i])
            count++;
    }
    cout<<count<<endl; 
    return 0;
}


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

int main() {
  ll N, K;
  cin >> N >> K;
  ll count = 0;
  for (ll i = K; i <= N+1; i++) {
    ll M = (2*N +1 -i) * i / 2;
    ll m = i * (i-1) / 2;
    count += M-m+1;
    count = count % 1000000007;
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){

  int a , b;
  scanf("%d%d",&a,&b);
  if( a < b ) {
    printf("a < b\n");
  } else if ( a > b ){
    printf("a > b\n");
  }else {
    printf("a == b\n");
  }


 
  return 0;
 }




Measured memory_bytes: 2116
S = gets

subs = []
result = 0

for i in 0..(S.length - 1)
  for j in 0..(S.length - 1)
	subs << S[i..j] 
  end
end
subs.each do |sub|
  acgt = true
  sub.split('').each do |s|
    if s == 'A' || s == 'C' || s == 'G' || s == 'T'
      acgt = true
    else
      acgt = false
      break
    end
  end
  result = sub.length if acgt == true && result < sub.length
end

puts result


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    sort(H.begin(), H.end());
    int ans = 0;
    for (int i = 0; i < max(N - K, 0LL); i++) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 1792
S = input()

if S[0] == "A":
    if S.count("C") == 1:
        if S[2:-1].count("C") == 1:
            S = S.replace("A", "")
            S = S.replace("C", "")
            if S.islower():
                print("AC")
                exit()

print("WA")


Measured memory_bytes: 61812
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
 
  int a, b;
  in, a, b;
  if (a == 1)a = 100;
  if (b == 1)b = 100;
  if (a == b) {
    cout << ("Draw") << endl;
  } else if (a < b) {
    cout << ("Bob") << endl;
  } else {
    cout << ("Alice") << endl;
  }


}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(n-i-j>=0){        
        if(y==1000*i+5000*j+10000*(n-i-j)){
          cout<<n-i-j<<" "<<j<<" "<<i<<"\n";
          return 0;
        }
      }
    }
  }
  cout<<"-1 -1 -1\n";
  return 0;
}


Measured memory_bytes: 256
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a >= 100:
    a1 = a % 10
else:
    a2 = a - 100
    a1 = a2 % 10
if b >= 100:
    b1 = b % 10
else:
    b2 = b - 100
    b1 = b2 % 10
if c >= 100:
    c1 = c % 10
else:
    c2 = c - 100
    c1 = c2 % 10
if d >= 100:
    d1 = d % 10
else:
    d2 = d - 100
    d1 = d2 % 10
if e >= 100:
    e1 = e % 10
else:
    e2 = e - 100
    e1 = e2 % 10
if a1 == 0:
    a1 = 9
if b1 == 0:
    b1 = 9
if c1 == 0:
    c1 = 9
if d1 == 0:
    a1 = 9
if e1 == 0:
    e1 = 9
lis = [a1,b1,c1,d1,e1]
if a1 == min(lis) :
    answer = math.ceil(b / 10) * 10 + math.ceil(c/ 10) * 10 + math.ceil(e/ 10)* 10+ math.ceil(d/ 10) * 10 + a
if b1 == min(lis):
    answer = math.ceil(a/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + b
if c1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(a/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + c
if d1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(a/ 10)* 10 + d
if e1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(a/ 10)* 10 + math.ceil(d/ 10)* 10 + e
print(answer)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  rep(i,(n+1)/2) cout << a[n-1-2*i] << " ";
  rep(i,n/2) cout << a[2*i+n%2] << " ";
  cout << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
    int n,K;
    cin >> n >> K;
    vector<ll>x(n),y(n);
    vector<pair<ll,ll>>p(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        p[i] = make_pair(x[i], y[i]);
    }
    sort(p.begin(),p.end());
    rep(i,n){
        x[i] = p[i].first;
        y[i] = p[i].second;
    }
    ll ans = LONG_LONG_MAX;
    if(K == 2){
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                ans = min(ans, (x[j]-x[i])*abs(y[j]-y[i]));
            }
        }
        cout << ans << endl;
        return 0;
    }
    else if(K == 3){
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                for(int k = j+1; k < n; k++){
                    int l = i;
                    ll ma = max(y[i],max(y[j],max(y[k],y[l])));
                    ll mi = min(y[i],min(y[j],min(y[k],y[l])));
                    ans = min(ans,(x[k]-x[i])*(ma-mi));
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                for(int l = k+1; l < n; l++){
                    int cnt = 0;
                    ll ma = max(y[i],max(y[j],max(y[k],y[l])));
                    ll mi = min(y[i],min(y[j],min(y[k],y[l])));
                    for(int m = i; m <= l; m++){
                        if(mi <= y[m] and y[m] <= ma)cnt++;
                    }
                    if(cnt >= K){
                        ans = min(ans, (ma-mi)*(x[l]-x[i]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

const MOD = 1000000007

func main() {
	N := int64(nextInt())
	M := int64(nextInt())

	MNokori := int(M)
	var ans int64 = 1
	for i := 2; i*i <= MNokori; i++ {
		if MNokori%i == 0 {
			var cnt int64
			for MNokori%i == 0 {
				cnt++
				MNokori /= i
			}
			//cntが2^Xとか3^XのXの部分
			ans *= calcComb(cnt+N-1, N-1) //N-1はcntと同じ
			ans %= MOD
		}
	}
	if MNokori != 1 {
		//最後に素数が残ってる分を処理する
		ans *= calcComb(N+1-1, N-1) //N-1はcntと同じ
		ans %= MOD
	}

	fmt.Printf("%#v\n", ans)
}

func modpow(a, p int64) int64 {
	if p == 0 {
		return 1
	}

	if p%2 == 0 {
		//pが偶数の時
		halfP := p / 2
		half := modpow(a, halfP)
		//a^(p/2) をhalfとして、half*halfを計算
		return half * half % MOD
	} else {
		//pが奇数の時は、
		//pを偶数にするために1減らす
		return a * modpow(a, p-1) % MOD
	}
}

//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv
func calcComb(a, b int64) int64 {
	if b > a-b {
		return calcComb(a, a-b)
	}

	var ansMul int64 = 1
	var ansDiv int64 = 1
	var i int64
	for i = 0; i < b; i++ {
		ansMul *= (a - i)
		ansDiv *= (i + 1)
		ansMul %= MOD
		ansDiv %= MOD
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！

	ans := ansMul * modpow(ansDiv, MOD-2) % MOD
	return ans
}


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

void solve(long long K, long long N, std::vector<long long> A)
{
    long long max_dis = 0;
    for (int i = 0; i < N; i++)
    {
        long long dis = 0;
        if (i != N - 1)
        {
            dis = A[i + 1] - A[i];
            max_dis = max(dis, max_dis);
        }
        else
        {
            dis = K - A[N - 1] + A[0];
            max_dis = max(dis, max_dis);
        }
    }
    cout << K - max_dis << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  rep(i, n-1) {
    ans = (ans + a[i+1]) / 2;
  }
  cout << fixed << setprecision(15) << ans << endl;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if(c <= (a+b+1)){
		cout << b+c << endl;
	}
	else{
		cout << 2*b+a+1 << endl;
	}
}


Measured memory_bytes: 256
def extgcd(a,b):
  r=[1,0,a]
  w=[0,1,b]
  while w[2]!=1:
    q=r[2]//w[2]
    r2=w
    w2=[r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
    r=r2
    w=w2
  return [w[0],w[1]]
def mod_inv(a,m):
  x=extgcd(a,m)[0]
  return (m+x%m)%m

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

prime=primes(int(10**3)+1)

def fact2(n):
  l=prime
  L=[]
  for i in range(len(l)):
    ct=0
    while n%l[i]==0:
      n=n//l[i]
      ct+=1
    if ct!=0:
      L.append((l[i],ct))
    if n==1:
      break
  if n!=1:
    L.append((n,1))
  return L

n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(10**6)]
mod=10**9+7
for i in range(n):
  x=fact2(a[i])
  for j in range(len(x)):
    l[x[j][0]]=max(l[x[j][0]],x[j][1])
lcm=1
for i in range(2,10**6):
  lcm*=(i**l[i])
  lcm%=mod
ans=0
for i in range(n):
  ans+=lcm*mod_inv(a[i],mod)
  ans%=mod
print(ans)

Measured memory_bytes: 115056
A,B,C=map(int,input().split())
D,E,F=map(int,input().split())
G,H,I=map(int,input().split())
N=int(input())
for i in range(N):
    b=int(input())
    if b==A:
        A=0
    if b==B:
        B=0
    if b==C:
        C=0
    if b==D:
        D=0
    if b==E:
        E=0
    if b==F:
        F=0
    if b==G:
        G=0
    if b==H:
        H=0
    if b==I:
        I=0



if A==0 and B==0 and C==0 or D==0 and E==0 and F==0 or G==0 and H==0 and I==0 or A==0 and D==0 and G==0 or B==0 and E==0 and H==0 or C==0 and F==0 and I==0 or A==0 and E==0 and I==0 or C==0 and E==0 and G==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	ll n,x;
	std::cin >> n>>x;
	std::vector<ll> a(n);
	rep(i,n)std::cin >> a[i];
	ll counter=0;
	if(a[0]>x){counter+=a[0]-x;a[0]-=a[0]-x;}
	rep(i,n-1){
		
		if(a[i]+a[i+1]>x){
			counter+=min(a[i]+a[i+1]-x,a[i+1]);
			a[i+1]-=min(a[i]+a[i+1]-x,a[i+1]);
			
			if(a[i]+a[i+1]>x){
				counter+=min(a[i]+a[i+1]-x,a[i+1]);
				a[i]-=min(a[i]+a[i+1]-x,a[i]);
			
			}
		}
	}
	std::cout << counter << std::endl;
}



Measured memory_bytes: 1024
s=input()
p=input()

pf=p[0]
l=len(pf)
flag=0
if pf in s:
  for i in range(len(s)):
    if s[i]==pf:
      word=''
      for j in range(i,i+len(p)):
        j=j%(len(s))
        word+=s[j]
      if word==p:
        flag=1
        break
if flag:
  print('Yes')
else:
  print('No')



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

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

const ll INF = 1LL << 60;

vector<E> G[50];
ll dist[50][2501];
int C[50], D[50];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, S;
    cin >> N >> M >> S;
    for (int i = 0; i < M; i++) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        U--;
        V--;
        G[U].emplace_back(V, P(A, B));
        G[V].emplace_back(U, P(A, B));
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i] >> D[i];
    }
    S = min(S, 2500);
    fill((ll *)dist, (ll *)(dist + 50), INF);
    dist[0][S] = 0;
    priority_queue<State, vector<State>, greater<State>> que;
    que.emplace(0, P(0, S));
    while (!que.empty()) {
        State now = que.top();
        que.pop();
        ll d = now.first;
        int v = now.second.first;
        int coin = now.second.second;
        if (d > dist[v][coin])
            continue;
        for (E e : G[v]) {
            int to = e.first;
            int A = e.second.first;
            int B = e.second.second;
            if (A <= coin && d + B < dist[to][coin - A]) {
                dist[to][coin - A] = d + B;
                que.emplace(dist[to][coin - A], P(to, coin - A));
            }
        }
        int x = min(coin + C[v], 2500);
        if (d + D[v] < dist[v][x]) {
            dist[v][x] = d + D[v];
            que.emplace(dist[v][x], P(v, x));
        }
    }
    for (int i = 1; i < N; i++) {
        ll ans = INF;
        for (int j = 0; j <= 2500; j++) {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6200
import sys

while 1:
  n = input() + 1
  if n==1: break
  N = range(n)
  M = [[0] * n for i in N]
  y = M[0]
  for i in N[1:]:
    x = [0] * n
    A = ' ' + raw_input()
    for j in N[1:]:
      if A[j] == '.': x[j] = min(y[j-1],y[j],x[j-1]) + 1
    M[i] = x
    y = x
  print max(map(max,M))

Measured memory_bytes: 31924
n = int(input())
hh = tuple(map(int, input().split()))
h = [0] * n

prev = 0
ans = 0
while True:
    x = 0
    y = 0
    while x < n:
        if h[x] == hh[x]:
            x += 1
            continue

        ansadd = hh[x] - h[x]
        y = x + 1
        while y < n and h[y] < hh[y]:
            ansadd = min(ansadd, hh[y] - h[y])
            y += 1
        for i in range(x, y):
            h[i] += ansadd
        ans += ansadd

    if ans == prev:
        break
    prev = ans
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    ans+=a[n-1]-a[0];
    for(ll i=1;i<n/2;i++){
        //cout<<"i="<<i<<" ";
        ans+=a[n-i]-a[i];
        ans+=a[n-1-i]-a[i-1];
        //cout<<ans<<endl;
    }
    if(n%2==1){
        ans+=max(a[n/2+1]-a[n/2],a[n/2]-a[n/2-1]);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1024
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rep2(i,a,b) for(int i = a; i >= b; i--)
#define die return 0;

using namespace std;

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

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

int testcases;
testcases=1;
//cin>>testcases;

while(testcases--)
{
	int n;
	cin>>n;
	string res;
	while(n)
	{
		n--;
		int t=n%26;
		n=n/26;
//		t--;
		res.push_back(t+'a');		
	}
	reverse(res.begin(),res.end());
	cout<<res<<'\n';
}

return 0;
}


Measured memory_bytes: 3652
N = int(input())
# N < 10 ** 5
A = sorted([int(x) for x in input().split()])
# - 10 ** 9 < A < 10 ** 9

B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if D and -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;

#define sushi pair<ll, ll>

#define d first
#define t second

ll N, K;
vector<sushi> S;

void abc116d() {
  vector<ll> kind(N, 0), kind_rest(N, 0);
  ll kind_cnt = 0, eat_cnt = 0;
  priority_queue<sushi, vector<sushi>, greater<sushi>> eat, eat_duplicated;
  priority_queue<sushi> rest;

  sort(S.rbegin(), S.rend());

  for (int i = 0; i < N; i++) {
    if (i < K) {
      eat.push(S[i]);
      eat_cnt += S[i].d;
      if (kind[S[i].t] == 0) {
        kind_cnt++;
        kind[S[i].t]++;
      } else {
        eat_duplicated.push(S[i]);
      }
    } else {
      if (kind[S[i].t] == 0 && kind_rest[S[i].t] == 0) {
        rest.push(S[i]);
        kind_rest[S[i].t]++;
      }
    }
  }

  vector<sushi> f;
  f.push_back(sushi(eat_cnt, kind_cnt));

  while (!eat_duplicated.empty()) {
    sushi e = eat_duplicated.top();
    eat_duplicated.pop();
    if (rest.empty()) {
      break;
    }
    sushi r = rest.top();
    rest.pop();
    eat_cnt = eat_cnt + r.d - e.d;
    kind_cnt++;
    f.push_back(sushi(eat_cnt, kind_cnt));
  }

  ll res = f[0].d + f[0].t * f[0].t;
  for (auto s : f) {
    res = max(res, s.d + s.t * s.t);
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> K;
  S.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i].t >> S[i].d;
    S[i].t--;
  }
  abc116d();
  return 0;
}

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

double num[1000000],h[1000000],w[1000000];
int n;

int main(){
	while(true){
		int ans = 0;
		cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			cin >> num[i] >> h[i] >> w[i];
			h[i] /= 100;
			h[i] *= h[i];
			w[i] /= h[i];
			w[i] -= 22;
			if(w[i] < 0)
				w[i] *= -1;
			if(w[ans] > w[i]){
				ans = i;
			}else if(w[ans] == w[i] && num[ans] > num[i])
				ans = i;
		}
		cout << num[ans] << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		char a[][] = new char[h][w];
		for (int i = 0 ; i < h ; i++) {
			String s = sc.next();
			for (int j = 0; j < w ; j++)
				a[i][j] = s.charAt(j);
		}
		int num = 0;
		for (int i = 0; i < 1 << h; i++) {
			for (int j = 0; j < 1 << w; j++) {
				int count = 0;
				for (int p = 0; p < h ; p++) {
					for (int q = 0; q < w ; q++) {
                      int p2 = 1 << p;
                      int q2 = 1 << q;
						if((i & p2) > 0 && (j & q2) > 0 && a[p][q] == '#') {
								count++;
							}
					}
					}
				if (count == k)
					num++;
				}
		}
		sc.close();
		System.out.println(num);
	}
}



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

#define LL long long

vector<pair<int,pair<LL,LL> > > G[100009];

LL dists[100009];
LL distt[100009];
LL ans[100009];
LL tot = (LL)(1000000000000000);
bool mark[100009];
int n;
LL inf = (LL)(100000000000000000);

void shortest_path(int s,int type){
	multiset<pair<LL,int> > mul;
	mul.insert(make_pair(0,s));
	memset(mark,0,sizeof(mark));
	for(int i=1;i<=n;i++){
		if(type==1){dists[i] = inf;}
		else{distt[i] = inf;}
	}
	if(type==1){dists[s]=0;}
	else{distt[s]=0;}

	while(!mul.empty()){
		pair<LL,int> p = *mul.begin();mul.erase(mul.begin());
		int u = p.second;

		if(mark[u]){continue;}
		mark[u] = true;

		for(int i=0;i<(int)G[u].size();i++){
			int v = G[u][i].first;
			LL w;
			if(type==1){w = G[u][i].second.first;}
			else{w = G[u][i].second.second;}
			if(type==1){
				if(!mark[v] && (dists[v] > dists[u]+w)){
					dists[v] = dists[u] + w;
					mul.insert(make_pair(dists[v],v));
				}
			}else{
				if(!mark[v] && (distt[v] > distt[u]+w)){
					distt[v] = distt[u] + w;
					mul.insert(make_pair(distt[v],v));
				}
			}
		}
	}
}

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int m,s,t;
	cin>>n>>m>>s>>t;

	for(int i=0;i<m;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;

		G[a].push_back(make_pair(b,make_pair(c,d)));
		G[b].push_back(make_pair(a,make_pair(c,d)));
	}

	shortest_path(s,1);
	shortest_path(t,2);

	vector<pair<LL,int> > v;
	for(int i=1;i<=n;i++){
		v.push_back(make_pair(dists[i]+distt[i],i));
	}

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

	set<int> st;
	for(int i=0;i<n;i++){st.insert(i);}

	int i=0;
	while(!st.empty()){
		LL x = v[i].first;
		int idx = v[i].second;
		while(!st.empty() && *st.begin()<idx){
			ans[*st.begin()] = tot - x;
			st.erase(st.begin());
		}
		i++;
	}

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

Measured memory_bytes: 19440
N, A, B, C = map(int, input().split())
L = []
for _ in range(N):
  L.append(int(input()))

def rec(i, a, b, c):
  if i == N:
    if not a or not b or not c: return float('inf')
    return abs(a-A) + abs(b-B) + abs(c-C)
  
  ret = rec(i+1, a, b, c)
  
  ret = min(ret, rec(i+1, a+L[i], b, c) + (10 if a else 0))
  ret = min(ret, rec(i+1, a, b+L[i], c) + (10 if b else 0))
  ret = min(ret, rec(i+1, a, b, c+L[i]) + (10 if c else 0))
  
  return ret

print(rec(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	int N, K, i, tmp;
	scanf("%d %d", &N, &K);
	int p[N];
	for (i = 0; i<N; i++){
		scanf("%d", &p[i]);
	}
	for (i = 0; i<N; ++i){
		for (int j = i + 1; j < N; ++j){
			if (p [i] > p[j]){
			tmp = p[i];
			p[i] = p[j];
			p[j] = tmp;
		}
	}
	}

	int sum = 0;
	for (i = 0; i < K; i++){
		sum += p[i];
	}
	printf("%d", sum);
}

Measured memory_bytes: 1720
import heapq

n = int(input())
a = list(map(int, input().split()))
first = a[:n]
second = a[n:2*n]
third = [ -1*i for i in a[2*n:3*n]]
sum_first = sum(first)
sum_third = sum(third)
results = [0]*(n+1)
results[0] = sum_first
results[n] = sum_third
heapq.heapify(first)
heapq.heapify(third)

for i in range(n):
    x = second[i]
    p = heapq.heappushpop(first, x)
    sum_first = sum_first + x - p
    results[i+1] += sum_first

for i in reversed(range(n)):
    x = -1*second[i]
    p = heapq.heappushpop(third,x)
    sum_third = sum_third + x - p
    results[i] += sum_third

print(max(results))

Measured memory_bytes: 38288
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep2(i,a,b)for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
const ll M=1000000007;

int n;
int a[100];
int b[100];
int w[51][51];
int w2[51][51];
vector<int>du;
ll ans;
const int INF=10000000;


int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];

	

	for(int i=50;i>=1;i--){
		rep2(j,0,51)rep2(k,0,51){w[j][k]=(j==k)?0:INF;w2[j][k]=w[j][k];}

		for(int j=50;j>=0;j--){
			for(int k=50;k>=1;k--){
				//if(j%k==j)continue;
				bool ok=1;
				rep(z,du.size())if(du[z]==k)ok=0;
				if(!ok)continue;

				w[j][j%k]=1;
				if(k!=i)w2[j][j%k]=1;
			}
		}

		rep2(j,0,51){
			rep2(k,0,51){
				rep2(z,0,51){
					w[k][z]=min(w[k][z],w[k][j]+w[j][z]);
					w2[k][z]=min(w2[k][z],w2[k][j]+w2[j][z]);
				}
			}
		}
		
		bool o1=1,o2=2;
		rep(j,n)if(w[a[j]][b[j]]==INF)o1=0;
		rep(j,n)if(w2[a[j]][b[j]]==INF)o2=0;
		//cout<<i<<" "<<o1<<" "<<o2<<endl;
		if(o1&&!o2){
			ll one=1;
			ans+=(one<<i);
		}
		else if(o1&&o2)du.push_back(i);
	}
	if(du.size()==0)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        float result = 0;
        for  (int i =0; i<N; i++) {
            float x = sc.nextFloat();
            String u = sc.next();

            if (u.equals("JPY")) {
                result += x;
            }
            else {
                result += (x*380000);
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
	string yn[2] = { "YES","NO" };
	int a[3], go = 0, nana = 0,x=1;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		if (a[i] == 5) go++;
		else if (a[i] == 7) nana++;
	}
	if (go == 2 && nana == 1) x = 0;
	cout << yn[x] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MOD = 924844033;
const int N = 2002;
int n,k;
LL f[N+2][N+2][2];
LL g[(N+2)*2][N+2];
LL fac[N];
void init() {
    fac[0]=1;
    for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%MOD;
    f[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            (f[i+1][j][0] += f[i][j][0]+f[i][j][1]) %= MOD;
            (f[i+1][j+1][1] += f[i][j][0]) %= MOD;
        }
    }
    // k, n/k
    g[0][0]=1;
    for(int i=0;i<2*k;i++){
        int len=(n/k-1) + ((i/2 < n%k)?1:0); 
        for(int j=0;j<=n;j++){
            for(int x=0;x<=len;x++){
                g[i+1][j+x] += g[i][j] * (f[len][x][0] + f[len][x][1]);
                g[i+1][j+x] %= MOD;
            }
        }
    }
    /*
    for(int i=1;i<=n;i++) {
        printf("%d: %d\n", i, g[2*k][i]);
    }
    */
}
int main() {
    cin>>n>>k;
    init();
    LL ans = 0;
    for(int x=0;x<=n;x++) {
        LL tmp = g[2*k][x] * fac[n-x] % MOD;
        ans += x % 2 == 0 ? tmp : -tmp;
        ans = (ans % MOD + MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 125696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];

		for (int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}


		int min = c[0];
		int index = -1;

		for (int i = 0; i < N; i++) {
			if (t[i] > T)
				continue;
			if (c[i] <= min) {
				min = c[i];
				index = i;
			}
		}

		if (index == -1)
			System.out.println("TLE");
		else
			System.out.println(min);

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
double shurui, ninki;
  cin >> shurui >> ninki;
  vector<int> touhyousu(shurui);
 
  for (int i = 0; i < shurui; i++) {
    cin >> touhyousu.at(i);
}
  
   sort(touhyousu.begin(), touhyousu.end()); 
  
 double allcount;
  allcount = 0;
    for (int i = 0; i < shurui; i++) {
    allcount = allcount + touhyousu.at(i);
}
  
  int a;
  a = shurui - ninki;
  double jouken;
  jouken = 1 / (4 * ninki);
if ( touhyousu.at(a) >= allcount*jouken){
  cout << "Yes" << endl;
}
  else{
   cout << "No" << endl;
  }
}

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

long long dp[(1<<16) + 7];
int v[17][17];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> v[i][j];
    for (int i = 0; i < (1<<n); ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i&(1<<j)) == 0)
                continue;
            for (int k = j + 1; k < n; ++k) {
                if ((i&(1<<k)) == 0)
                    continue;
                dp[i] += v[k][j];
            }
        }
        for (int sm = ((i - 1)&i); sm > 0; sm = ((sm - 1)&i))
            dp[i] = max(dp[i], dp[sm] + dp[i^sm]);
    }
    cout << dp[(1<<n) - 1];
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int n;
	cin >> n;
	vector<pair<ll,ll>> x(n);
	ll xt,lt;
	rep(i,n) {
		cin >> xt >> lt;
		x[i] = pair<ll,ll>(xt,lt);
	}
	vector<pair<ll,ll>> p(n);
	rep(i,n) {
		p[i] = pair<ll,ll>(x[i].fi+x[i].se, x[i].fi - x[i].se);
	}
	int count = 0;
	sort(p.begin(),p.end());
	ll cur = -1e9;
	rep(i,n) {
		if(cur <= p[i].se) {
			cur = p[i].fi;
			count++;
		}
	}
	cout << count << endl;
  return 0;
}


Measured memory_bytes: 3328
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(lst):  # fix inputs here
    console("----- solving ------")

    curmax = 0
    res = 0
    for x in lst:
        res += max(curmax - x, 0)
        curmax = max(curmax, x)

    # return a string (i.e. not a list or matrix)
    return res


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    _ = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(lst)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


Measured memory_bytes: 34040