akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string o, e; cin >> o >> e;
    int ol = o.size(), el = e.size(), l;
    l = max(ol, el);
    For(i, 0, ol) {
        cout << o[i];
        if(i < el) cout << e[i];
    }
    
    return 0;
}

Measured memory_bytes: 3616
use List::Util qw(max);
$N = glob<>;
@r;
my($a, $b, $c) = glob<>;
$r[0][0] = $a;
$r[0][1] = $b;
$r[0][2] = $c;
for($i=1;$i<$N;$i++){
    my($a, $b, $c) = glob<>;
    $r[$i][0] = max($r[$i-1][1],$r[$i-1][2]) + $a;
    $r[$i][1] = max($r[$i-1][0],$r[$i-1][2]) + $b;
    $r[$i][2] = max($r[$i-1][0],$r[$i-1][1]) + $c;
}
@t = @{ $r[$N-1] };
print max(@t);

Measured memory_bytes: 22144
// https://atcoder.jp/contests/abc169/tasks/abc169_e

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 

const int maxn = 200500;

int a[maxn], b[maxn];
signed main() {
    ios::sync_with_stdio(0);
    cin.sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a+1, a+n+1);
    sort(b+1, b+n+1);

    int x, y;
    if(n&1) {
        x = a[n/2+1];
        y = b[n/2+1];
    } else {
        x = a[n/2] + a[n/2+1];
        y = b[n/2] + b[n/2+1];
    }

    cout << y-x+1 << endl;
}


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

int main(){
    using namespace std;
    unsigned long H, W, K;
    cin >> H >> W >> K;
    vector<vector<unsigned long>> wc(H, vector<unsigned long>(W));
    for(unsigned long i{0}; i < H; ++i){
        string S;
        cin >> S;
        transform(S.begin(), S.end(), wc[i].begin(), [](char c){return c & 1;});
    }
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{0}; i < 1UL << (H - 1); ++i){
        vector<unsigned long> cnt(H);
        unsigned long tmp{__builtin_popcountl(i)};
        [&]{for(unsigned long j{0}; j < W; ++j){
            for(unsigned long k{0}, l{0}; k < H; ++k){
                cnt[l] += wc[k][j];
                if(i >> k & 1)++l;
            }
            if(any_of(cnt.begin(), cnt.end(), [&K](auto i){return i > K;})){
                fill(cnt.begin(), cnt.end(), 0UL);
                ++tmp;
                for(unsigned long k{0}, l{0}; k < H; ++k){
                    cnt[l] += wc[k][j];
                    if(i >> k & 1)++l;
                }
                if(any_of(cnt.begin(), cnt.end(), [&K](auto i){return i > K;}))return;
            }
        }
        ans = min(tmp, ans);}();
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int k,x;
    cin>>k>>x;
    for(int i = x-k+1;i <= k+x-1;i++) cout<<i<<" ";
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int S[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i,K;

    scanf("%d",&K);

    printf("%d\n",S[K-1]);
    return 0;
}

Measured memory_bytes: 128
n = gets.to_i
s = gets.split('')

cnt = 0
(n-1).times do |i|
  j = i + 1
  k = i + 2
  while k < n
    if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
      cnt += 1
    end
    j += 1
    k += 2
  end
end

r = s.count('R')
g = s.count('G')
b = s.count('B')

puts r*g*b - cnt

Measured memory_bytes: 14408
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    string a;
    string b;
    string f;
    string g;
    int c=0,d,e;
    cin>>a;
    d=a.size();
    while(true){
        b="";
        cin>>f;
        e=f.size();
        if(f=="END_OF_TEXT"){
            cout<<c<<endl;
            break;
        }
        for(int i=0;i<e;i++){
            b += tolower(f[i]);
        }
        if(b==a){
            c++;
        }
    }
    return 0;
}

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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    if(A <= K && A + B >= K){
        cout << 0 << " " << B - (K - A) << endl;
        return 0;
    }
    else if(A <= K && A + B < K){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    else if(A > K){
        cout << A - K << " " << B << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

vector<vector<int>> nodes(100000, vector<int>());

bool findPath(int target, int node, vector<int> &path, int from) {
  if (node == target) {
    path.push_back(node);
    return true;
  }
  rep(i, nodes[node].size()) {
    if (nodes[node][i] == from) continue;
    if (findPath(target, nodes[node][i], path, node)) {
      path.push_back(node);
      return true;
    }
  }
  return false;
}

int maxDistance(int from, int node) {
  vector<int> dist;
  rep(i, nodes[node].size()) {
    if (nodes[node][i] != from) {
      dist.push_back(maxDistance(node, nodes[node][i]));
    }
  }
  if (dist.size() == 0) {
    return 0;
  }
  int maxDist = 0;
  rep(i, dist.size()) {
    maxDist = max(maxDist, dist[i]);
  }
  return maxDist + 1;
}

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

  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    nodes[a].push_back(b);
    nodes[b].push_back(a);
  }

  vector<int> utov;
  findPath(u, v, utov, -1);

  int dist = utov.size() - 1;
  if (dist % 2 == 0) {
    out(maxDistance(utov[dist / 2], utov[dist / 2 - 1]) + dist / 2);
  } else {
    out(maxDistance(utov[dist / 2 + 1], utov[dist / 2]) + dist / 2);
  }
}


Measured memory_bytes: 12928
n, x = [int(item) for item in input().split()]
if x == 1 or x == 2*n-1:
    print("No")
    exit()

if n == 2:
    print("Yes")
    print("1 2 3")
    exit()

ans = [0] * (2*n - 1)
used = [0] * (2*n - 1)
if x >= n:
    ans[n-1] = 2*n-1
    used[2*n-1-1] = 1
    ans[n] = x
    used[x-1] = 1
    ans[n+1] = x-1
    used[x-2] = 1
    ans[n-2] = x-2
    used[x-3] = 1
else:
    ans[n-1] = 1 
    used[0] = 1
    ans[n] = x
    used[x-1] = 1
    ans[n+1] = x+1
    used[x] = 1
    ans[n-2] = x+2
    used[x+1] = 1
it = 0
for i in range(2*n-1):
    if ans[i] == 0:
        while(used[it] != 0):
            it += 1
        ans[i] = it+1
        it += 1
print("Yes")
print(" ".join([str(item) for item in ans]))

Measured memory_bytes: 26544
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data
 
p_list = get_sieve_of_eratosthenes(10**3)
 
def factorization_counta(n):
    arr = []
    temp = n
    for i in p_list:
        if i * i > n:
            break
        elif temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(cnt)
            
    if temp != 1:
        arr.append(1)
    if arr == []:
        arr.append(1)
    return arr

def main():
    N = int(input())
    ans = 1
    for c in range(2, N):
        p = factorization_counta(c)
        tmp = 1
        for v in p:
            tmp *= (v + 1)
        ans += tmp
    return ans
 
if __name__ == '__main__':
    print(main())

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  out((n + 999) / 1000 * 1000 - n);
}


Measured memory_bytes: 3572
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    LL n,y;
    cin>>n>>y;
    LL ans1=-1,ans2=-1,ans3=-1;
    for(LL i=0;i<=y;i+=10000){
        for(LL j=0;j<=y-i;j+=5000){
            if((y-(i+j))%1000==0&&((i/10000)+(j/5000)+((y-i-j)/1000))==n){
                ans1=i/10000;
                ans2=j/5000;
                ans3=(y-i-j)/1000;
            }
        }
    }
    cout<<ans1<<" "<<ans2<<" "<<ans3<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

bool used[216000];
Int M;
int n;
Int a;
vector<P> ans;
int main(){
    cin >> n;
    vector<Int> plus, minus;
    Int zero = 0;
    for(int i = 0;i < n;i++){
        cin >> a;
        if(a == 0)zero++;
        if(a > 0)plus.push_back(a);
        if(a < 0)minus.push_back(a);
    }
    sort(plus.rbegin(), plus.rend());
    sort(minus.begin(), minus.end());
    if(plus.empty()){
        if(zero > 0){zero--;plus.push_back(0);}
        else {
            plus.push_back(minus.back());
            minus.pop_back();
        }
    }
    if(minus.empty()){
        if(zero > 0){while(zero--)minus.push_back(0);}
        else{
            minus.push_back(plus.back());
            plus.pop_back();
        }
    }
    if(zero>0)    while(zero--)plus.push_back(0);

    for(int i = 1;i < plus.size();i++){
        ans.push_back(P(minus[0], plus[i]));
        minus[0] -= plus[i];
    }
    for(int i = 0;i < minus.size();i++){
        ans.push_back(P(plus[0], minus[i]));
        plus[0] -= minus[i];
    }
    cout << plus[0] << endl;
    for(int i = 0;i < n-1;i++)cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    cout << std::fixed << std::setprecision(10);
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
    mod = (i64)mod;
    i64 res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

void main_sub(void) {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> t_mod(n + 1, 0);
    int i = n - 1;
    while (i >= 0) {
        t_mod[i] =
            (t_mod[i + 1] + (s[i] - '0') * mod_pow(10, n - i, 2019)) % 2019;
        --i;
    }
    unordered_map<int, int> cnt;
    for (auto t : t_mod) {
        cnt[t]++;
    }
    int ans = 0;
    for (auto it = cnt.begin(); it != cnt.end(); it++) {
        ans += it->second * (it->second - 1) / 2;
    }
    cout << ans << endl;
    return;
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int main() {
	int r,g,b;
	cin>>r>>g>>b;
	int num=100*r+10*g+b;
	if(num%4==0){
		p("YES");
	}
	else p("NO");;
	return 0;
}


Measured memory_bytes: 256
int a[200010];
int ans[200010];
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }

Measured memory_bytes: 3216
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf[100];

int main(void) {
  REP(i, 3) {
    scanf("%s", buf);
    putchar(buf[0]-'a'+'A');
  }
  puts("");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int a,b,c,d;cin>>a>>b>>c>>d;
	int hoge = c*d/GCD(c,d);
	int dim = b/c-(a-1)/c+b/d-(a-1)/d-b/hoge+(a-1)/hoge;
	cout << b - a + 1 - dim << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
S = input()

result = 0
count = 0

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        count += 1
    else:
        count = 0
    if result < count:
        result = count

print(result)

Measured memory_bytes: 3060
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] line = sc.nextLine().toCharArray();
            if(line.length==1 && line[0]=='.') break;

            boolean boo = true;
            LinkedList<Character> moji = new LinkedList<Character>();
            for(int i=0; i<line.length; i++){
                if(line[i]=='(' || line[i]=='[' || line[i]=='{'){
                    moji.add(line[i]);
                    continue;
                }
                if((line[i]==')'  || line[i]==']' || line[i]=='}')){
                    if(moji.size()==0) {boo = false; break;}
                    char c = moji.pollLast();
                    if((c=='(' && line[i]==')') || (c=='[' && line[i]==']') || (c=='{' && line[i]=='}')) continue;
                    else {boo = false; break;}
                }
            }

            if(boo && moji.size()==0) System.out.println("yes");
            else System.out.println("no");
        }

    }

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

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

bool isEven( int a ) {
	return a % 2 == 0 && a != 0;
}

signed main() {
	string S;
	cin >> S;

	cout << ( regex_match( S, regex( R"((dream(er)?|eraser?)*)" ) ) ? "YES" : "NO" ) << endl;
}

Measured memory_bytes: 40960
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long a=0;
    long b=0; //500
    long c=0;
    cin >>a;
    
    while(a>=500){
        a=a-500;
        b++;
    }
    while(a>=5){
        a=a-5;
        c++;
    }
    
    cout <<b*1000+c*5;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> PAIR;
namespace QiFeng233{
	map<string,int> vote;
	map<string,bool> vis;
	int n;
	string str;
	bool cmp(const PAIR& x, const PAIR& y){  
		return x.second>y.second;
	
	}
	bool cmp2(string a,string b){
    	return a<b;
	} 
	void solve(){
		cin>>n;
		for(int i=1;i<=n;++i){
			cin>>str;
			++vote[str];
		}
		vector<PAIR> res(vote.begin(),vote.end());
		sort(res.begin(),res.end(),cmp);
		vector<string> output;
		int max=res[0].second;
		output.push_back(res[0].first);
		vis[res[0].first]=true;
		for(int i=1;i<(int)res.size();++i){
			if(res[i].second<max)break;
			if(!vis[res[i].first])output.push_back(res[i].first);
		}
		sort(output.begin(),output.end(),cmp2);
		for(int i=0;i<(int)output.size();++i)cout<<output[i]<<endl;
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 42352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

struct button{
	int left, top, right, bottom;
	string link;
	button(int l, int t, int r, int b, string li){
		left = l, top = t, right = r, bottom = b, link = li;
	}
};

int main(){
	//fin();
	int n;
	while(cin >> n, n){
		int w, h;
		cin >> w >> h;
		map<string, vector<button> > pages;
		string current;
		rep(i, n){
			string s;
			int bn;
			cin >> s >> bn;
			if(!i) current = s;
			rep(i, bn){
				int left, top, right, bottom;
				string link;
				cin >> left >> top >> right >> bottom >> link;
				pages[s].push_back(button(left, top, right, bottom, link));
			}
		}
		stack<string> back;
		stack<string> forward;
		int m;
		cin >> m;
		rep(i, m){
			string com;
			cin >> com;
			if(com == "click"){
				int x, y;
				cin >> x >> y;
				rep(i, pages[current].size()){
					button b = pages[current][i];
					if(x < b.left || x > b.right || y < b.top || y > b.bottom) continue;
					back.push(current);
					forward = stack<string>();
					current = b.link;
					break;
				}
			}
			else if(com == "back"){
				if(back.empty())continue;
				forward.push(current);
				current = back.top();
				back.pop();
			}
			else if(com == "forward"){
				if(forward.empty())continue;
				back.push(current);
				current = forward.top();
				forward.pop();
			}
			else if(com == "show"){
				cout << current << endl;
			}
		}
	}

	return 0;
}

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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define base 402653189
#define mod 998244353
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 200005

int main(){
	optimize();
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	ll ans=0;
	if(K) {
        ans+=min(A,K);
        K-=min(A,K);
	}
	if(K){
        K-=min(B,K);
	}
	if(K){
        ans-=min(C,K);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};



int main() {
    int h, w;
    cin >> h >> w;
    char grid[h + 2][w + 2];
    rep(i, h + 2) rep(j, w + 2) grid[i][j] = '/';
    REP(i, h) REP(j, w) cin >> grid[i][j];

    bool ok = true;
    REP(i, h) REP(j, w) {
            if (grid[i][j] == '#') {
                bool flag = false;
                rep(k, 4) {
                    if (grid[i + my4[k]][j + mx4[k]] == '#') {
                        flag = true;
                    }
                }
                if (!flag) ok = false;
            }
        }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
	string s;
    cin >> s;
  	string r = "";
  	for(int i=0;i<s.size();i++){
    	if(s[i] == '0')r += '0';
    	else if(s[i] == '1')r += '1';
    	else if(s[i] == 'B'){
    		if(r != "") r = r.substr(0,r.size()-1);
    	}
    }
	cout << r << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args)
	{
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			int[] A = new int[n];
			for(int i = 0; i<n ; i++)
			{
				A[i] = Integer.parseInt(br.readLine());
			}
			shellSort(A,n);
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shellSort(int[] arr , int l)
	{
		
		int m = 1 ,cnt =0;
		int G[] = new int[15];
		G[0] = 1;
		while((G[m] = G[m-1] * 3 +1) <= l){
			m++;
		}
		sb.append(m).append('\n');
		m--;
		for(; m >= 0 ; m--){
			sb.append(G[m]).append(' ');
			cnt += insertionSort(arr,l,G[m]);
		}
		sb.deleteCharAt(sb.length()-1).append('\n').append(cnt).append('\n');
		
		for(m = 0 ; m < l ; m++){
			sb.append(arr[m]).append('\n');
		}
			System.out.print(sb.toString());
	}
	public static int insertionSort(int[] a,int n , int g)
	{
		int cnt = 0;
		int v;
		for(int i = g ; i < n ; i++)
		{
			v = a[i];
			int j = i-g;
			while(j >= 0 && a[j] > v)
			{
				a[j+g] = a[j];
				a[j] = v;
				j -= g;
				cnt++;
			}
		}
		return cnt;
	}
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

// .#迷路
// .(通路),#(壁),S(スタート),G(ゴール)でできた迷路をコンストラクタで受け取る
class Maze {
public:
	int h, w;
	pii start, goal;
	vii a;
	Maze(vector<vector<char> > s) {
		h = s.size(); w = s[0].size();
		a.resize(h + 2);
		for (int i = 0; i < h + 2; i++) {
			a[i].resize(w + 2, -1);
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] != '#') a[i + 1][j + 1] = inf;
				if (s[i][j] == 'S') start = pii(i + 1, j + 1);
				if (s[i][j] == 'G') goal = pii(i + 1, j + 1);
			}
		}
	}

	void solve() {
		a[start.first][start.second] = 0;
		queue<pii> que;
		que.push(start);
		while (!que.empty()) {
			pii now = que.front();
			int i = now.first, j = now.second;
			int d = a[i][j];
			que.pop();
			for (int k = 0; k < 4; k++) {
				if (d + 1 < a[i + dy[k]][j + dx[k]]) {
					a[i + dy[k]][j + dx[k]] = d + 1;
					que.push(pii(i + dy[k], j + dx[k]));
				}
			}
		}
		return;
	}
};


int main() {
	int i, j, h, w;
	cin >> h >> w;
	int cnt = 0;
	vector<vector<char> > s(h, vector<char>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
			if (i == 0 && j == 0) {
				s[i][j] = 'S';
			}
			else if (i == h - 1 && j == w - 1) {
				s[i][j] = 'G';
			}
			else if (s[i][j] == '.') {
				cnt++;
			}
		}
	}
	Maze M(s);
	M.solve();
	if (M.a[h][w] == inf) {
		cout << -1 << endl;
	}
	else {
		cout << cnt - (M.a[h][w] - 1) << endl;
	}
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	string S; cin >> S;
	
	bool ans = true;
	if(S.front() != 'A') ans = false;
 	else if(!count(S.begin()+2, S.end()-1, 'C')) ans = false;
	else{
		int cnt = 0;
		REP(i,S.length()) if(islower(S[i])) cnt++;
		if(!(cnt == S.length()-2))  ans = false;
	}

	if(ans == true) cout << "AC" << endl;
	else cout << "WA" << endl;

	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  h2 -= h1;
  m2 -= m1;

  int tot = h2 * 60 + m2 - k;
  cout << max(tot, 0) << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, m, q, mux;
struct qua
{
    ll an, bn, cn, dn;
};
qua a[55];
void pereb(vector<ll> tec)
{
    if ((ll)tec.size() == n)
    {
        ll score = 0;
        for (ll i = 1; i <= q; i ++)
            if (tec[a[i].bn - 1] - tec[a[i].an - 1] == a[i].cn)
                score += a[i].dn;
        mux = max(mux, score);
        return;
    }
    ll p = tec[(ll)tec.size() - 1];
    for (ll i = p; i <= m; i ++)
    {
        tec.push_back(i);
        pereb(tec);
        tec.pop_back();
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> q;
    for (ll i = 1; i <= q; i ++)
        cin >> a[i].an >> a[i].bn >> a[i].cn >> a[i].dn;
    mux = 0;
    for (ll i = 1; i <= m; i ++)
        pereb({i});
    cout << mux;
    return 0;
}


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

int main() {
  
  int k;
  cin >> k;
  
  string s;
  cin >> s;
  
  int a = s.size();
  
  if ( a <= k ){
    cout << s << endl;
  }else{
    for ( int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }   
  
}

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

int main(){
	
	int p, q, r;
	
	cin >> p >> q >> r;
	
	vector <int> v;
	
	v.push_back(p);
	v.push_back(q);
	v.push_back(r);
	
	sort(v.begin(), v.end());
	
	cout << v[0] + v[1];
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<bool> vb;
void isUtilLongestPath(ll i, vll &dp, vll adj[], vb &visit) {
	visit[i] = true;
	for (int j = 0; j < adj[i].size(); ++j) {
		if (!visit[adj[i][j]]) {
			isUtilLongestPath(adj[i][j], dp, adj, visit);
		}
		dp[i] = max (dp[i], 1+dp[adj[i][j]]);
	}
}
int main() {
	ll v, e;
	cin >> v >> e;
	vll adj[v];
	ll x, y;
	for (ll i = 0; i < e; ++i) {
		cin >> x >> y;
		adj[x-1].push_back(y-1);
	}
	vll dp(v, 0);
	vb visit(v, false);
 	for (ll i = 0; i < v; ++i) {
 		if (!visit[i]) 
 			isUtilLongestPath(i, dp, adj, visit);
 	}
 	cout << *max_element(dp.begin(), dp.end());
}

Measured memory_bytes: 12848
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,k,a[100010],s[100010],m[100010],t=0;
  cin>>n>>k;
  fr(i,n) cin>>a[i];
  fr(i,n){
    s[i+1]=s[i]+a[i];
    m[i+1]=m[i]+max(a[i],(ll)0);
  }
  fr(i,n-k+1){
    t=max(t,m[i]+m[n]-m[i+k]+max((ll)0,s[i+k]-s[i]));
  }
  cout<<t<<endl;
}

Measured memory_bytes: 2560
import itertools

n = int(input())
exist = [input() for _ in range(n)]

suit_list = ['S', 'H', 'C', 'D']
rank_list = range(1, 14)

card_list = [suit + ' ' + str(rank) for suit, rank in itertools.product(suit_list, rank_list)]

answer_list = [card for card in card_list if card not in exist]

for ans in answer_list:
    print(ans)


Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
int main()
{
    fast;
    int n;
    cin>>n;
    int a[3];
    vector<int> dp(3,0);
    for(int i=0;i<n;i++)
    {
        cin>>a[0]>>a[1]>>a[2];
        vector<int> ndp(3,0);
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++)
            {
                if(j!=k){
                    ndp[k]=max(ndp[k],dp[j]+a[k]);
                }
            }
        }
        dp=ndp;
    }    
    cout<<max(dp[0],max(dp[1],dp[2]));
return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
#define gc() getchar_unlocked()
//#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char tr['T'+1];
char f[268435460];

int trans()
{
	int c, k, w;

	w = k = 0; while ((c = gc()) >= ' ') {
		k = (k<<2) | tr[c], w++;
	}
	return w | (k<<4);
}

int main()
{
	int n, k;

	tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
	n = in();
	while (n--) {
		if (gc() == 'i') {
			k = 6; while (k--) gc();
			f[trans()] = 1;
		} else {
			k = 4; while (k--) gc();
			puts(f[trans()]? "yes": "no");
		}
	}
	return 0;
}



Measured memory_bytes: 17944
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
const int N=1e5+5;
int n;
struct student{
	int num,val;
}e[N];
bool cmp(student a,student b){
	return a.val<b.val;
} 
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(e[i].val);
		e[i].num=i;
	}
	sort(e+1,e+n+1,cmp);
	for(int i=1;i<=n;i++)
	    printf("%d ",e[i].num);
	puts("");
	return 0;
} 

Measured memory_bytes: 1536
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;

int a[maxn],dp[maxn];

int main(){
	int n,k;
	scanf("%d %d",&n, &k);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	for(int i = 2; i <= n; i++){
		for(int j = k; j >= 1; j--){
			if(i - j > 0){
				if(i > k){
					if(j == k) dp[i] = dp[i-j] + abs(a[i] - a[i-j]);
					else dp[i] = min(dp[i] , dp[i-j] + abs(a[i] - a[i-j]));
				}
				else{
					if(i - j == 1) dp[i] = dp[i-j] + abs(a[i] - a[i-j]);
					else dp[i] = min(dp[i] , dp[i-j] + abs(a[i] - a[i-j]));
				}
			}
		}
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 1024
s = int(input())
existed = set()
cur_s = s
i = 1

while cur_s not in existed:
    existed.add(cur_s)
    if cur_s % 2 == 0:
        cur_s //= 2
    else:
        cur_s = 3 * cur_s + 1
    i += 1
print(i)


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

#define ll long long
#define N 200005
#define mod 1000000007

ll bit[N], n, h[N], a[N];
void insert(ll val, int idx) {
	for (int i = idx; i < N; i += (i & -i)) {
		bit[i] = max(val, bit[i]);
	}
}

ll query(int idx) {
	ll ans = 0;
	for (int i = idx; i > 0; i -= (i & -i)) {
		ans = max(bit[i], ans);
	}
	return ans;
}

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

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

	memset(bit, 0, sizeof bit);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll q = query(h[i]);
		if (q + a[i] > ans) {
			ans = q + a[i];
		}
		insert(q + a[i], h[i]);
		//ll tmp = query(h[i]);
		//cout << tmp << "\n";
		//ans = max(ans, query(h[i]));
	}

	cout << ans;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,s[202020],sa;
long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){cin>>sa;s[i]=sa-i;}
	sort(s+1,s+n+1);
	if(n&1)sa=s[(n+1)>>1];
	else sa=s[n>>1];
	ans=0;
	for(int i=1;i<=n;i++)ans+=abs(s[i]-sa);
	cout<<ans;
} 

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

int main(){
  int N;
  cin >> N;
  char c;
  int W=0;
  int R=0;
  vector<int> d(N);
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> c;
    if(c == 'R'){
      d.at(i)=1;
      R++;
    }
    else{
      d.at(i)=0;
      W++;
    }
  }
  for(int i=0;i<R;i++){
    m.at(i)=1;
  }
  for(int i=R;i<N;i++){
    m.at(i)=0;
  }
  int counter =0;
  for(int i=0;i<N;i++){
    if(m.at(i)<d.at(i)){
      counter++;
    }
  } 
  cout << counter << endl;

}

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

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

	string s;

	cin >> s;

	for(int i=0;i<s.length()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout << "Bad" << '\n';
			return 0;
		}
	}

	cout << "Good" << '\n';
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int tmp;
    if (a > b) {
        tmp = b;
        b = a;
        a = tmp;
    }
    if (b > c) {
        tmp = c;
        c = b;
        b = tmp;
    }
    if (a > b) {
        tmp = b;
        b = a;
        a = tmp;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> cards;
  for (int i = 0; i < n; ++i) {
    int input;
    std::cin >> input;
    cards.push_back(input);
  }
  std::sort(cards.begin(), cards.end(), std::greater<>());
  int alice = 0, bob = 0;
  for (int i = 0; i < cards.size(); i++) {
    alice += (i % 2 == 0) ? cards[i] : 0;
    bob += (i % 2) ? cards[i] : 0;
  }
  std::cout << alice - bob << std::endl;
}


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

using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  set<string> words;
  string prev = "";
  bool bad = false;
  for(int i = 0; i < n; i++){
     string s;
     cin >> s;
     if(words.count(s)){
       bad = true;
       break;
     }
     words.insert(s);
     if(i > 0){
       if(prev[prev.size() - 1] != s[0]){
          bad = true;
          break;
       }
     }
     prev = s;
  }
  printf("%s", bad ? "No" : "Yes");
  return 0;
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int ans=0;
  for(int i=0;i<=100;i++){
    if(A<=i&&i<B&&C<=i&&i<D)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int c,a,n;
		cin>>c>>a>>n;
		int ans=0;
		for(;n>0 && a>0 && c>0;n--,a--,c--)ans++;
		for(;a>0 && c>1;a--,c-=2)ans++;
		for(;c>2;c-=3)ans++;
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 1164
k=int(input())
l=k-1
raw=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(raw[l])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) a[i] -= b[i];
	sort(a.begin(), a.end());
	int cnt = 0;
	ll tarinai = 0;
	rep(i, n) {
		if (a[i] < 0) {
			tarinai += a[i];
			cnt++;
		}
		else {
			break;
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (tarinai >= 0) break;
		else {
			if (a[i] <= 0) break;
			else {
				tarinai += a[i];
				cnt++;
			}
		}
	}
		
	if (tarinai < 0) cout << -1 << endl;
	else cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
L,R=map(int, input().split())
from itertools import permutations, combinations,combinations_with_replacement,product
if (R+1-L)<2019:
  LR = range(L,R+1)
  LRA = []
  for i in LR:
    LRA.append(i%2019)
  LRAA = set(LRA)
  C = combinations(LRAA, 2)
  Ret = 2019
  for i in list(C):
    Ret = min(Ret,(i[0]*i[1])%2019)
else:
  Ret = 0
print(Ret)


Measured memory_bytes: 148408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll K;
  vector<ll> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << a.at(K-1) << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dist[2][100000];
VVI edge(100000-1);

void dfs(int node, int d, int player){
    if(dist[player][node] != -1) return;
    dist[player][node] = d;
    for(int n : edge[node]){
        dfs(n, d+1, player);
    }
}
int main(void){

    int N, u, v; cin >> N >> u >> v;
    REP(i,N-1){
        int a,b; cin >> a >> b;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }
    REP(i,2)REP(j,N) dist[i][j] = -1;
    
    dfs(u-1, 0, 0); dfs(v-1, 0, 1);

    int ans = 0;
    REP(i,N){
        if(dist[0][i] < dist[1][i]) chmax(ans, dist[1][i]);
    }
    cout << ans-1 << endl;
    return 0;
}

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

ll f(ll n){
    return n * (n+1) / 2;
}

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n;i++){
        ll r = n / i;
        ans += i * f(r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;


namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                if(n==0){break;}
                int[,] heights = new int[n, n];
                for (int i = 0; i < n; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    for (int j = 0; j < n; j++) {
                        heights[i, j] = ints[j];
                    }
                }

                bool[,] smallest = new bool[n, n];
                for (int i = 0; i < n; i++) {
                    int small = int.MaxValue;
                    int smallInd = -1;
                    for (int j = 0; j < n; j++) {
                        if (small > heights[i, j]) {
                            small = heights[i, j];
                            smallInd = j;
                        }
                    }
                    smallest[i,smallInd] = true;
                    for (int j = 0; j < n; j++) {
                        if (heights[i, j] == small) { smallest[i, j] = true; }
                    }
                }
                
                bool[,] biggest = new bool[n, n];
                for (int j = 0; j < n; j++) {
                    int max = int.MinValue;
                    int maxInd = -1;
                    for (int i = 0; i < n; i++) {
                        if (max < heights[i, j]) {
                            max = heights[i, j];
                            maxInd = i;
                        }
                    }
                    biggest[maxInd, j] = true;
                    for (int i = 0; i < n; i++) {
                        if (heights[i, j] == max) { biggest[i, j] = true; }
                    }
                }

                int theHeight = 0;
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        if (smallest[i, j] && biggest[i, j]) {
                            theHeight = heights[i, j];
                            break;
                        }
                    }
                    if (theHeight != 0) { break; }
                }
                Console.WriteLine(theHeight);
            }   
        }   
    }
}

Measured memory_bytes: 5976
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 100005
using namespace std;

int main()
{
    int n, k;
    cin>>n>>k;
    int arr[n+1];
    int i1=0;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
        if(arr[i] == 1)
            i1 = i;
    }
    int ans = INT_MAX;
    for(int i=0; i<=k-1; i++)
    {
        int in = i1 - i;
        if(in <= 0) in = 1;
        int aage = (n-in+k-2)/(k-1);
        int piche = (in-1+k-2)/(k-1);
        ans = min(ans, aage + piche);
        in = i1 + i;
        if(in > n) in = n;
        aage = (n-in+k-2)/(k-1);
        piche = (in-1+k-2)/(k-1);
        ans = min(ans, aage+piche);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int h, w;
char c[100][100];
bool ta[100], mu[100], a, b;

signed main() {
	cin >> h >> w;
	rep(i, h) {
		a = true;
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '#')a = false;
		}
		if (a)ta[i] = true;
	}
	rep(i, w) {
		b = true;
		rep(j, h) {
			if (c[j][i] == '#')b = false;
		}
		if (b)mu[i] = true;
	}
	rep(i, h) {
		if (ta[i] == false) {
			rep(j, w) {
				if (mu[j] == false)cout << c[i][j];
			}
			cout << endl;
		}
	}
	ggr
}

Measured memory_bytes: 256