akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5 + 7;
const int mod = 1e9+7;
ll jc[N];
void init()
{
    jc[0]=1;
    jc[1]=1;
    for(int i=2;i<=N-2;i++){
        jc[i]=jc[i-1]*i%mod;
    }
}
ll qp(ll a,ll b)
{
    ll ret=1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a %mod;
        b>>=1;
    }return ret;
}
ll c(ll n,ll m)
{
    return jc[n]* qp(jc[m]*jc[n-m]%mod,mod-2) %mod;
}
int main()
{
    init();
    ll n,m,a,b,ans=0;
    cin>>n>>m>>a>>b;
    ll d=b+n-1-a;
    ll d2=n+m-2-d;
    if(n-a<=m-b){
        for(int i=0;i<n-a;i++){
            ans = ans + c(d,i)*c(d2,n-1-i)%mod;
            ans%=mod;
        }
    }
    else{
        for(int i=0;i<m-b;i++){
            ans = ans + c(d,m-1-i)*c(d2,i)%mod;
            ans%=mod;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll N; cin >> N;
  vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i];}
  vector<ll> X(N,0);
  for(ll i = 0; i < N; i++){
    if( i % 2 == 0){ X[0] += A[i];}
    else{ X[0] -= A[i];}}
  X[0] /= 2; 
  //X[0]決定
  for(ll i = 0; i < N - 1; i++){
    X[i+1] = A[i] - X[i];}
  
 for(ll i = 0; i < N; i++){ cout << 2 * X[i] << " " ;}
  return 0;}
      
  

Measured memory_bytes: 2944
#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 < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool ftb = true;
    rep(i, q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            ftb = !ftb;
            continue;
        }
        int f;
        char c;
        cin >> f >> c;
        int pos = ftb ? 0 : s.size();
        if (f == 2)
        {
            pos = ftb ? s.size() : 0;
        }

        s.insert(pos, 1, c);
    }

    if (!ftb)
    {
        reverse(s.begin(), s.end());
    }

    cout << s << endl;

    return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a>b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
    cout<<endl;
  }
  else{
    for(int i=0;i<b;i++){
      cout<<a;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]
    x = list(map(int, input().split()))

    l = bisect.bisect_left(x, 0)

    r = 3 * (10 ** 8)

    for i in range(min(l, K), -1, -1):
        if N < l + K - i:
            break
        if i == K:
            r = min(r, abs(x[l - K]))
        elif i == 0:
            r = min(r, abs(x[l + K - 1]))
        else:
            r = min(r, abs(x[l - i]) * 2 + x[l + K - i - 1], abs(x[l - i]) + x[l + K - i - 1] * 2)


    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    bool flag=false;
    int ans;
    for (int i=1;i<50000;i++) {
        double m=i*1.08;
        if (int(m)==n) {
            flag=true; 
            ans=i;
        }
    }
    if (flag) cout << ans << endl;
    else cout << ":(" << endl;
}

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

using namespace std;

struct Edge {
	int to, cost;
};
struct Node {
	int v, used, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

const int inf = 1e9;

int main() {
	int N, M, C; \
	while (cin >> N >> M >> C, N || M || C) {
		vector< vector<Edge> > G(N);
		for (int i = 0; i < M; ++i) {
			int from, to, c; cin >> from >> to >> c; --from, --to;
			G[from].push_back((Edge){to, c});
		}
		int dist[200][100]; fill(dist[0], dist[200], inf);
		priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push((Node){0, 0, 0});
		while ( !Q.empty() ) {
			Node node = Q.top(); Q.pop();
			int v = node.v, used = node.used, cost = node.cost;
			if (cost >= dist[used][v]) continue;
			dist[used][v] = cost;
			for (int i = 0; i < G[v].size(); ++i) {
				Edge& e = G[v][i];
				if (cost+e.cost < dist[used][e.to]) {
					Q.push((Node){e.to, used, cost+e.cost});
				}
				if (used < N && cost < dist[used+1][e.to]) {
					Q.push((Node){e.to, used+1, cost});
				}
			}
		}
		int ans = -1;
		for (int i = 0; i < N; ++i) {
//			cout << ":" << dist[i][N-1] << endl;
			if (dist[i][N-1] <= C) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2756
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

int N;
long long W, weight[110], value[110];
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int max=MAX(a,MAX(b,c));
  int min=MIN(a,MIN(b,c));
  int mid=a+b+c-max-min;
  int ans=max-mid;
  min+=ans;
  ans+=(max-min+1)/2;
  if((max-min)%2!=0) ans++;
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
n,k,*a=map(int,open(0).read().split())
b=[[]for _ in range(max(a)+1)]
l=[]
for i,v in enumerate(a):
  b[v]+=i,
  l+=len(b[v]),
s=a[0]
i=c=0
while i<n:
  m=len(b[s])
  j=l[i]
  c+=j==m
  i=b[s][j%m]+1
  s=a[i%n]
k%=c+1
i=c=0
r=[]
while i<n:
  m=len(b[s])
  j=l[i]
  if c>k-2and j==m:
    r+=s,
    i+=1
  else:i=b[s][j%m]+1
  c+=j==m
  s=a[i%n]
print(*r)

Measured memory_bytes: 48636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class ACircle {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int r;cin >> r;
        cout <<r*r << endl;
    }
};

int main() {
	ACircle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N;
ll h[100010];
ll dp[100010];

int main() {
    cin >> N;
    rep(i, N) cin >> h[i];

    // DP配列初期化
    rep(i, N) dp[i] = INF;
    dp[0] = 0;

    // DP更新
    for (int i = 1; i < N; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    println!("{}", min(a * n, b));
}


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

int main()
{
	double n,m,d;
	cin >> n >> m >> d;
	double ans;
	if (d == 0)
	{
		ans = 1/n;
	}
	else
	{
		ans = 2*(n-d)/n/n;
	}
	ans *= m-1;
	cout << setprecision(10) << ans << endl;
	return 0;
}

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

using namespace std;

const int N = (int)1e3 + 5;
int n, m, prv[N], disc[N], curDisc;
bool inSt[N];
stack<int> st;
vector<int> gr[N], loop;

void dfs(int u) {
    disc[u] = ++curDisc;
    st.emplace(u); inSt[u] = 1;
    for (int v : gr[u]) {
        if (!disc[v]) {
            prv[v] = u;
            dfs(v);
        }
        else if (inSt[v]) {
            for (int ver = u; ; ver = prv[ver]) {
                loop.emplace_back(ver);
                if (ver == v) break ;
            }
            reverse(loop.begin(), loop.end() );
        }
        if (loop.size() ) return ;
    }
    inSt[u] = 0; st.pop();
}

int main() {
    scanf(" %d %d", &n, &m);
    while (m--) {
        int u, v; scanf(" %d %d", &u, &v);
        gr[u].push_back(v);
    }

    for (int u = 1; u <= n; ++u) if (!disc[u] && !loop.size() ) dfs(u);

    if (!loop.size() ) {
        printf("-1");
        return 0;
    }

    while (1) {
        vector<bool> inLoop(n + 5, 0);
        for (int u : loop) inLoop[u] = 1;
        bool ok = 1;
        for (int iU = 0; iU < (int)loop.size(); ++iU) {
            int u = loop[iU];
            for (int v : gr[u]) if (v != loop[ (iU + 1) % (int)loop.size() ] && inLoop[v]) {
                ok = 0;
                vector<int> newLoop;

                int iV = iU;
                while (loop[iV] != v) iV = (iV + 1) % (int)loop.size();
                for (int i = iV; ; i = (i + 1) % (int)loop.size() ) {
                    newLoop.emplace_back(loop[i]);
                    if (i == iU) break ;
                }

                loop = newLoop;
                break ;
            }
            if (!ok) break ;
        }
        if (ok) break ;
    }

    printf("%d\n", (int)loop.size() );
    for (int u : loop) printf("%d\n", u);

    return 0;
}


Measured memory_bytes: 384
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

 n = inp[0]
 p (r_up(n,2))/n.to_f

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
      num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main(){
    long long n;
    cin >> n;
    vector<pair<ll, int>> res = factrized(n);
    long long ans = 0;

    map<int, int> mp;
    int sum = 0;
    int cnt = 0;
    for (int i=1; i<200; i++){
        sum += i;
        cnt++;
        for (int j=sum; j<sum + i + 1; j++){
            mp[j] = cnt;
        }
    }
    // for (auto it=mp.begin(); it!=mp.end(); it++){
    //     cout << it->first << " " << it->second << endl;
    //     if (it->first == 100) break;
    // }
    for (int i=0; i<(int)res.size(); i++){
        long long x = res[i].second; 
        ans += mp[x];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4576
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    ll sum=0;
    for(int i=1;i<=k;i++){
    	for(int j=1;j<=k;j++){
    		for(int x=1;x<=k;x++){
    			sum+=__gcd(i,__gcd(j,x));
    		}
    	}
    }
    cout << sum <<endl;
    return 0;
}


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

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

  int n = s.size();
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x = s[i] - '0';
    sum += x;
  }

  if(sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3748
#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;

int main(){
    ll x,y;
    cin >> x >> y;
    int ans = 0;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s; cin>>s;
    vector<int> ngo(s.length()+1,0);
    vector<int> zeroList;
    if(s[0]=='<') zeroList.push_back(0);
    if(s[s.length()-1]=='>') zeroList.push_back(s.length());
    for(int i=1;i<s.length();++i){
        if(s[i-1]=='>' && '<'==s[i]){
            zeroList.push_back(i);
        }
    }
    for(int i=0;i<zeroList.size();++i){
        int p = zeroList[i];
        int count = 0;
        while(p<s.size() && s[p]==s[zeroList[i]]){
            count++;
            if(ngo[p+1]<=count) ngo[p+1]=count;
            p++;
        }
        p = zeroList[i]-1;
        count = 0;
        while(p>=0 && s[p]==s[zeroList[i]-1]){
            count++;
            if(ngo[p]<=count) ngo[p]=count;
            p--;
        }
    }

    long long ans = 0;
    for(int i=0;i<ngo.size();++i) ans += ngo[i];
    cout<<ans<<endl;
    //for(int i=0;i<s.length();++i) cout<<ngo[i]<<s[i];
    //cout<<ngo[ngo.size()-1]<<endl;
}


Measured memory_bytes: 3460
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,p[N],q[N];ll a[N],b[N];bool vis[N];
int main() {
	read(n);rep(i,1,n)read(a[i]);
	per(i,n,1)a[i]-=a[i-1];
	ll m,k;read(m);read(k);
	rep(i,1,n)q[i]=i;
	while(m--){int x;read(x);swap(q[x],q[x+1]);}
	rep(i,1,n)p[q[i]]=i;
	//a(k)-->b
	rep(i,1,n)if(!vis[i]){
		static int s[N];int len=0;
		for(int u=i;!vis[u];u=p[u])s[++len]=u,vis[u]=1;
		rep(j,1,len)b[s[(j+k)%len==0?len:(j+k)%len]]=a[s[j]];
	}
	
	rep(i,1,n)b[i]+=b[i-1],printf("%lld\n",b[i]);
	return 0;
}


Measured memory_bytes: 4096
import math
from functools import reduce

def gcd_list(a,b,c):
    return reduce(math.gcd, [a,b,c])

n = int(input())
cnt = 0
for i in range(1,n + 1):
    for j in range(1,n + 1):
        for k in range(1,n + 1):
            
            cnt += gcd_list(i,j,k)
print(cnt)

Measured memory_bytes: 69724
N = gets.to_i
R = []
L = []
U = []
D = []
N.times{
  sx, sy, d = gets.chomp.split(" ")
  x = sx.to_i
  y = sy.to_i
  case d
  when 'R' then
    R << [x, y]
  when 'L' then
    L << [x, y]
  when 'U' then
    U << [x, y]
  else
    D << [x, y]
  end
}

XMIN = []
XMAX = []
YMIN = []
YMAX = []
if !((U + D).empty?) then
  w1 = (U + D).min_by{|e| e[0]}[0]
  XMIN << Proc.new{|t| w1}
  w2 = (U + D).max_by{|e| e[0]}[0]
  XMAX << Proc.new{|t| w2}
end
if !((R + L).empty?) then
  w3 = (R + L).min_by{|e| e[1]}[1]
  YMIN << Proc.new{|t| w3}
  w4 = (R + L).max_by{|e| e[1]}[1]
  YMAX << Proc.new{|t| w4}
end

if !(R.empty?) then
  w5 = R.min_by{|e| e[0]}[0]
  XMIN << Proc.new{|t| w5 + t}
  w6 = R.max_by{|e| e[0]}[0]
  XMAX << Proc.new{|t| w6 + t}
end
if !(L.empty?) then
  w7 = L.min_by{|e| e[0]}[0]
  XMIN << Proc.new{|t| w7 - t}
  w8 = L.max_by{|e| e[0]}[0]
  XMAX << Proc.new{|t| w8 - t}
end
if !(U.empty?) then
  w9 = U.min_by{|e| e[1]}[1]
  YMIN << Proc.new{|t| w9 + t}
  wa = U.max_by{|e| e[1]}[1]
  YMAX << Proc.new{|t| wa + t}
end
if !(D.empty?) then
  wb = D.min_by{|e| e[1]}[1]
  YMIN << Proc.new{|t| wb - t}
  wc = D.max_by{|e| e[1]}[1]
  YMAX << Proc.new{|t| wc - t}
end

def calc(t)
  xmin = XMIN.map{|e| e.call(t)}.min
  xmax = XMAX.map{|e| e.call(t)}.max
  ymin = YMIN.map{|e| e.call(t)}.min
  ymax = YMAX.map{|e| e.call(t)}.max
  (xmax - xmin) * (ymax - ymin)
end

t_can = []
t_can << (w1 - w5).abs if !w1.nil? && !w5.nil?
t_can << (w1 - w7).abs if !w1.nil? && !w7.nil?
t_can << (w2 - w6).abs if !w2.nil? && !w6.nil?
t_can << (w2 - w8).abs if !w2.nil? && !w8.nil?
t_can << (w3 - w9).abs if !w3.nil? && !w9.nil?
t_can << (w3 - wb).abs if !w3.nil? && !wb.nil?
t_can << (w4 - wa).abs if !w4.nil? && !wa.nil?
t_can << (w4 - wc).abs if !w4.nil? && !wc.nil?
t_can << (w5 - w7).abs / 2.0 if !w5.nil? && !w7.nil?
t_can << (w6 - w8).abs / 2.0 if !w6.nil? && !w8.nil?
t_can << (w9 - wb).abs / 2.0 if !w9.nil? && !wb.nil?
t_can << (wa - wc).abs / 2.0 if !wa.nil? && !wc.nil?

ans = calc(0)
t_can.each{|t|
  n = calc(t)
  ans = n if n < ans
}

puts ans


Measured memory_bytes: 11644
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque([])
flag = False
if n % 2 == 1:
    flag = True
for i in range(n):
    if flag:
        b.appendleft(a[i])
        flag = False
    else:
        b.append(a[i])
        flag = True
print(*b)

Measured memory_bytes: 25412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n;
ll niz[200005];
ll poj[30][30];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ll konst = 1000000000;
    ll res = 0;
    ff(i,1,n){
        string x;
        cin >> x;
        int m = x.length();
        int poz = -1;
        ll broj = 0;
        ff(j,0,m - 1){
            if(x[j] == '.')poz = j;
            else{
                broj *= 10;
                broj += (x[j] - '0');
            }
        }
        if(poz == -1){
            broj = broj * konst;
        }
        else{
            int kol = 9 - (m - poz - 1);
            ff(i,1,kol)broj *= 10;
        }

        niz[i] = broj;
        int st2 = 0;
        while(niz[i]%2 == 0){
            niz[i] /= 2;
            st2++;
        }
        int st5 = 0;
        while(niz[i]%5 == 0){
            niz[i] /= 5;
            st5++;
        }
        st2 = min(st2, 18);
        st5 = min(st5, 18);
        ff(i,18-st2,18){
            ff(j,18-st5,18){
                res += poj[i][j];
            }
        }
        poj[st2][st5]++;
    }
    cout << res << "\n";
    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin  >> n;
	
	int x = n/2;
	cout << x*(n-x);
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
char a[100][100]= {0};
int h1[]= {1,0};
int l1[]= {0,1};
int dp[100][100]= {0};
struct node
{
    int x;
    int y;
};
int main()
{
    int h,l;
    cin>>h>>l;
    for(int i=0; i<h; i++)
    {
        cin>>a[i];
    }
    queue<node>q;
    node a1;
    a1.x=0;
    a1.y=0;
    q.push(a1);
    dp[0][0]=1;
    while(!q.empty())
    {
        node p=q.front();
        q.pop();
        for(int i=0; i<=1; i++)
        {
            int x=p.x+h1[i];
            int y=p.y+l1[i];
            if(a[x][y]=='.')
                continue;
            if(x>=h||y>=l)
                continue;
            if(dp[x][y])
            {
                cout<<"Impossible"<<endl;
                return 0;
            }
            else
            {
                node o;
                o.x=x;
                o.y=y;
                dp[x][y]=1;
                q.push(o);
                break;
            }
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<l; j++)
        {
            if(a[i][j]=='#'&&dp[i][j]==0)
            {
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int sqrt(int n)
{
    int lb = 1;
    int ub = n + 1;
    long long m = 0;
    while (ub - lb > 1) {
	m = (lb + ub) / 2;
	if (m * m <= n) lb = m;
	else ub = m;
    }
    return lb;
}


void factorize(int n, int p[], int *m) 
{
    int i;
    int j = 0;
    while (n > 1) {
	for (i = 2; i <= sqrt(n); i++) {
	    if (n % i == 0) {
		if (p[j-1] == i) break;
		p[j++] = i;
		break;
	    }
	}
	if (i > sqrt(n)) break;
	n /= i;
    }
    if (n != 1 && p[j-1] != n) p[j++] = n;
    *m = j;
}

int next_combination(int c[], int n, int r)
{
    for (int i = r-1; i >= 0; i--) {
	if (c[i] != n-r+i) {
	    c[i]++;
	    int ci = c[i];
	    for (int j = i+1; j < r; j++) c[j] = ci+j-i;
	    return 0;
	}
    }
    return 1;
}

int main()
{
    int n;
    int p[1<<5], c[1<<5];
    int cnt = 0;
    int j, sign;
    int not_prime;
    scanf("%d", &n);
    factorize(n, p, &j); // n = 12 => p = [2, 3], j = 2
    not_prime = 0;
    sign = -1;
    for (int i = 1; i <= j; i++) { // choose i of prime factors
	sign *= -1;
	for (int k = 0; k < i; k++) c[k] = k;
	do {
	    int prod = 1;
	    for (int k = 0; k < i; k++) prod *= p[c[k]];
	    not_prime += sign * n / prod;
	} while(!next_combination(c, j, i));
    }
    printf("%d\n", n - not_prime);
    return 0;
}



Measured memory_bytes: 2748
#include<iostream>

using namespace std;

int eulerPhi(int n) {
  if (n == 0) return 0;
  int ans = n;
  for (int i = 2; i*i <= n; i++) {
    if (n % i == 0) {
      ans -= ans / i;
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) ans -= ans / n;
  return ans;
}

int main(void){
    int n;

    cin>>n;
    cout<<eulerPhi(n)<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int compare_char1(const void *a, const void *b){
    return *(char*)a > *(char*)b;
}
 
int compare_char2(const void *a, const void *b){
    return *(char*)a < *(char*)b;
}
 
int main(int argc, char *argv[]){
    char s[101] = {};
    char t[101] = {};
    scanf("%s", s);
    scanf("%s", t);
    qsort(s, strlen(s), sizeof(char), compare_char1);
    qsort(t, strlen(t), sizeof(char), compare_char2);
    printf("%s\n", strcmp(s, t) < 0 ? "Yes" : "No");
    return 0;
}

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

// 隣接リストで使う辺を表す型
struct Edge {
  int to, cost; // 辺の接続先頂点、辺の重み
  Edge(int to, int cost) : to(to), cost(cost) {}  // コンストラクタ
};
typedef long long ll;
const ll INF = 1e18;
typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph; // グラフの辺を格納した構造体
               // graph[v][i]は頂点vから出るi番目の辺Edge
vector<ll> dist; // 最短距離
vector<bool> negative; // 負の閉路があるかどうか

void bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<ll>(n, INF);
  negative = vector<bool>(n, false);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        if (dist[v] == INF) continue;
        Edge e = graph[v][k];
        if (dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        if (dist[v] == INF) continue;
        Edge e = graph[v][k];
        if (dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          negative[e.to] = true;
        }
        if (negative[v]) negative[e.to] = true;
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  graph = AdjList(n);
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    from--; to--;
    graph[from].push_back(Edge(to, -cost));
  }
  bellman_ford(n, 0);
  // 解答
  if (negative[n-1]) cout << "inf" << endl;
  else cout << -dist[n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<vector>
using namespace std;

#define INF 1<<21
#define MAX 100005
#define MOD 10e9+7
bool c[200005],d[200005];

int main(){
    int N,M;
    int a,b;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        if(a==1)c[b]=1;
        else if(b==N)d[a]=1;
    }
    for(int i=0;i<N;i++){
        if(c[i]&&d[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int gcd(int a, int b)
{
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}


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

	int n, g, i, j, k, x;
	cin >> n >> g;
	for (i = 1; i < n; i++) {
		cin >> x;
		g = gcd(g, x);
	}
	cout << g << "\n";

	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> q(m);
  vector<string> r(m);
  for(int i=0;i<m;i++){
    cin >> q.at(i) >> r.at(i);
  }
  vector<int> ac(n);
  vector<int> wa(n);
  vector<int> wakari(n);
  for(int i=0;i<m;i++){
    if(ac.at(q.at(i)-1)==0&&r.at(i)=="AC"){
      ac.at(q.at(i)-1) = 1;
      wa.at(q.at(i)-1) = wa.at(q.at(i)-1) + wakari.at(q.at(i)-1);
    }else if(ac.at(q.at(i)-1)==0&&r.at(i)=="WA"){
      wakari.at(q.at(i)-1) = wakari.at(q.at(i)-1) + 1;
    }
  }
  int acsum=0;
  int wasum=0;
  for(int i=0;i<n;i++){
    acsum = acsum + ac.at(i);
    wasum = wasum + wa.at(i);
  }
  cout << acsum << " " << wasum << endl;
}

Measured memory_bytes: 7296
N=int(input())
ls=[int(s) for s in input().split()]
_abs=[0 for _ in range(N)]
zero=0
minus=0
for i in range(N):
  if ls[i]<0:
    minus+=1
    _abs[i]=-ls[i]
  elif ls[i]==0:
    zero+=1
  else:
    _abs[i]=ls[i]
if zero>0:
  print(sum(_abs))
elif minus%2==0:
  print(sum(_abs))
else:
  print(sum(_abs)-2*min(_abs))

Measured memory_bytes: 14412
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    score=c
    for j in range(m):
        score+=a[j]*b[j]
    if score>0:
        ans+=1
print(ans)

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

int main() {
  int N,K;
  int a[100];
  cin >> N >> K;
  for(int i; i < N; i++) cin >> a[i];
  
  sort(a, a + N, greater<int>());
  int sum = 0;
  for(int i = 0; i < K; i++) sum += a[i];
  
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=3e5+10;
const int maxm=1.5e7+10;
const int mod=1e9+7;
using namespace std;

ll n,m;

int main()
{
    scanf("%lld%lld",&n,&m);
    if(n==1||m==1)
        printf("1");
    else 
        printf("%lld\n",n*m/2+(n*m%2!=0));
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	ll i,j;

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

	ll A,B,N;
	cin >> A >> B >> N;

	ll ans=1e18;
	for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){
			if((B*i)%j==0){
				ans=min(ans,llabs((B*i)/j-A));
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

signed main()
{
  int N; cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }

  multiset<int> st;
  st.insert(a[0]);

  for(int i=1;i<N;i++){
    auto itr=st.lower_bound(a[i]);
    if(itr==st.begin()){
      st.insert(a[i]);
    }else{
      itr--;
      st.erase(itr);
      st.insert(a[i]);
    }
  }
  
/*
  for(int x:st){
    cout<<x<<' ';
  }
  cout<<endl;
*/
  cout<<st.size()<<endl;
  
  return 0;
}


Measured memory_bytes: 5760
s = input()
i = len(s)
while i > 0:
    if s[i-5:i] == 'dream':
        i -= 5
    elif s[i-7:i] == 'dreamer':
        i -= 7
    elif s[i-5:i] == 'erase':
        i -= 5
    elif s[i-6:i] == 'eraser':
        i -= 6
    else:
        break
if i == 0:
    print('YES')
else:
    print('NO')

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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>0 ?(a):-(a))
#define llong long long

int main(){
	int N,M,K;
	scanf("%d %d %d",&N,&M,&K);
	int A[N],B[M];
	rep(i,0,N) scanf("%d",A+i);
	rep(i,0,M) scanf("%d",B+i);
	
	int n=0,m=0;
	int sum=0;
	for(;n<N;n++){
		if( sum+A[n]<=K ){
			sum+=A[n];
		}else{
			break;
		}
	}
	n--;
	int max = n;
	
	while( m<M ){
		if( sum+B[m]<=K ){
			sum+=B[m];
			m++;
			max = max(max,n+m);
		}else{
			if( n<0 ) break;
			else{
				sum-=A[n];
				n--;
			}
		}
	}
	printf("%d",max+1);
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; }

    int ans = 0;
    while (true) {
        bool flag = false;
        rep(i, n) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            } else {
                flag = true;
            }
        }
        if (flag) {
            break;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "algorithm"

using namespace std;

const int maxm=1e5+10;

int N;
string S[maxm];

int main(){
	register int i;
	register long long Now,Ans;
	scanf("%d",&N);
	for(i=1;i<=N;i++) cin>>S[i],sort(S[i].begin(),S[i].end());
	sort(S+1,S+1+N);
	Now=1,Ans=0;
	for(i=2;i<=N+1;i++){
		if(S[i]==S[i-1]) Now++;
		else Ans+=((Now-1)*Now)>>1ll,Now=1;
	}
	printf("%lld",Ans);
	return 0;
}

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

ll Mod=pow(10,9)+7;


int main(){
  int N,M;
  cin >> N >> M;
  queue<int> a;
  rep(i,M){
    int s;
    cin >> s;
    a.push(s);
  }
  ll ans[N+5];
  rep(i,N+5) ans[i]=0;
  ans[0]=1;
  rep(i,N+3){
    if(!a.empty() and i==a.front()){
      a.pop();
      ans[i]=0;
    }
    ans[i+1]+=ans[i];
    ans[i+1]=ans[i+1]%Mod;
    ans[i+2]+=ans[i];
    ans[i+2]=ans[i+2]%Mod;
  }
  cout << ans[N] << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N;
    
    cin >>N;
    
    map<int,bool> m;
    rep2(i,9){
        rep2(j,9){
            m[i*j] = 1;
        }
    }
    if(m[N] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No"<< endl;
    }
    //cout << N << endl;
    
    
    return 0;
    

}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	int p[200000];
	rep(i,n) cin >> p[i];

	int ans=0;

	int tmp = 1000000;
	rep(i,n){
		if(tmp > p[i]) ans++;
		tmp = min(tmp,p[i]);
	}

	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt64()
	m := n - 1
	rn := math.Sqrt(float64(n))
	rm := math.Sqrt(float64(m))
	var ans int64
	for i := int64(1); float64(i) < rm; i++ {
		if m%i == 0 {
			ans++
		}
	}
	ans *= 2
	ans--
	if m == int64(rm)*int64(rm) {
		ans++
	}
	a := make([]int64, 0, int(rn))
	for i := int64(2); float64(i) < rm; i++ {
		if n%i == 0 {
			a = append(a, i)
			a = append(a, n/i)
		}
	}
	if n == int64(rn)*int64(rn) {
		a = append(a, int64(rn))
	}
	a = append(a, n)
	for _, x := range a {
		nn := n
		for nn%x == 0 && nn > 0 {
			nn /= x
		}
		if nn%x == 0 || nn%x == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
s = [gets.chomp]
n = gets.to_i
q = Array.new(n){gets.chomp.split}
f = true
n.times do |i|
  if q[i][0] == '1'
    f = !f
  else
    if q[i][1] == '1'
      if f
        s.unshift(q[i][2])
      else
        s << q[i][2]
      end
    else
      if f
        s << q[i][2]
      else
        s.unshift(q[i][2])
      end
    end
  end
end
if f
  puts s.join
else
  puts s.join.reverse
end

Measured memory_bytes: 53884
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int Alice = 0, Bob = 0;
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++){
        if(N % 2 == 0){
            if(i % 2 == 1){
                Alice += A.at(i);
            }
            else{
                Bob += A.at(i);
            }
        }
        else{
            if(i % 2 == 1){
                Bob += A.at(i);
            }
            else{
                Alice += A.at(i);
            }
        }
    }
    cout << Alice - Bob << endl;
    return 0;
}

Measured memory_bytes: 3628
n = list(input())

count = 0

word = 0
flag = 0

for j in range(len(n)):
  if(flag == 0):
    if(n[j] == 'A' or n[j] == 'C' or n[j] == 'T' or n[j] == 'G'):
      word += 1
      flag = 1
  else:
    if(n[j] != 'A' and n[j] != 'C' and n[j] != 'T' and n[j] != 'G'):
      if(count < word):
        count = word
      word = 0
      flag = 0
    else:
      word += 1

if(count < word):
  count = word

print(count)


Measured memory_bytes: 9144
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	string a;
	cin >> n >> a;
	for(auto &c: a){
		-- c;
	}
	int mark = 1;
	if(none_of(a.begin(), a.end(), [&](char x){ return x == '1'; })){
		mark = 2;
		for(auto &x: a){
			if(x == '2'){
				x = '1';
			}
		}
	}
	int res = 0;
	auto choose = [&](int n, int r){
		for(int bit = 0; bit < 31; ++ bit){
			int mask = 1 << bit;
			if(mask & r && !(mask & n)){
				return 0;
			}
		}
		return 1;
	};
	for(int i = 0; i < n; ++ i){
		res += choose(n - 1, i) * (a[i] - '0');
	}
	cout << res % 2 * mark;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 1948
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

 

  
int main() {
  int n, co = 0,co2 = 0;
  cin >> n;
  vector<ll> a(n),b(n);
  FOR(i, 0, n){
    cin >> a.at(i);
  }
  bool ans = false;
  FOR(i, 0, n){
    if(a.at(i) % 2 == 0){
      co++;
      if(a.at(i) % 3 == 0 || a.at(i) % 5 == 0 ){
        co2++;
      }
    }
  }
 
  if (co == co2){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
    
  }

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
     
    int main(void){
      char s[103];
      int i,n;
      
      scanf("%s",&s);
      //printf("%s",s);
      
      for(i=0;i<103;i++){
        if(s[i] == '\0'){
          n = i;
          break;
        }
      }
      for(i=0;i<n;i++){
        s[i] = 'x';
      }
      
      printf("%s",s);
      return 0;
    }

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  vector<bool> primes(100010, true);
  primes[0] = false;
  primes[1] = false;
  for (long i = 2; i < 100010; i++) {
    if (not primes[i]) continue;
    for (long j = i * 2; j < 100010; j += i) primes[j] = false;
  }

  vector<long> accum(100010, 0);
  long count = 0;
  for (long i = 1; i <= 100000; i+= 2) {
    if (primes[i] and primes[(i + 1) / 2]) count++;
    accum[i] = count;
  }

  long Q;
  cin >> Q;

  rep (i, Q) {
    long l, r;
    cin >> l >> r;
    if (l == 1) cout << accum[r] << endl;
    else cout << accum[r] - accum[l-2] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ m1, _ ] <- readInts
	[ m2, _ ] <- readInts
	print $ which 1 0 ( m1 /= m2 )

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long

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

    int n;
    set <string> s;
    string input;
    cin>>n;
    while(n--){
        cin>>input;
        s.insert(input);
    }
    cout<< s.size() << "\n";
    
    return 0;
}

Measured memory_bytes: 19216
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    map<string, ll> polls;
    REP(i, n){
        string s; cin >> s;
        polls[s]+= 1;
    }
    vector <pair <ll, string>> cands;
    for(auto p=polls.begin(); p!=polls.end(); ++p){
        auto pp = *p;
        cands.push_back({pp.second*-1, pp.first});
    }
    sort(cands.begin(), cands.end());
    ll maximum = cands[0].first;
    REP(i, cands.size()){
        if (cands[i].first == maximum){
            cout << cands[i].second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 29172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool comp(pair<string,ll>p1,pair<string,ll>p2)
{
    return p1.second<p2.second;
}
int main(){
    // Your code here!
    ll n;
    cin>>n;
    vector<pair<string,ll>>v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        ll t;
        cin>>t;
        v.push_back(make_pair(s,t));
    }
    //sort(v.begin(),v.end(),comp);
    string x;
    cin>>x;
    ll i;
    for(i=0;i<n;i++)
    {
        if(v[i].first==x)
        {
            break;
        }
    }
    ll ans=0;
    for(int j=i+1;j<n;j++)
    {
        ans+=v[j].second;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;

ll t,n,m;
map<string,int> mp;
string s;
int maxn=0;
int main(){
	cin>>n;
	while(n--){
		cin>>s;
		mp[s]++;
	}
	cin>>m;
	while(m--){
		cin>>s;
		mp[s]--;
	}
	for(map<string,int>::iterator it = mp.begin();it!=mp.end();++it){
        int temp = (*it).second;
        maxn=max(maxn,temp);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256