akhauriyash/Code-Regression huggingface dataset:
#![allow(clippy::needless_range_loop)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        i: usize,
        o: usize,
        _t: usize,
        j: usize,
        l: usize,
    }
    let ans = std::cmp::max(
        (i & (!1)) + o + (j & (!1)) + (l & (!1)),
        if i > 0 && j > 0 && l > 0 {
            ((i - 1) & (!1)) + o + ((j - 1) & (!1)) + ((l - 1) & (!1)) + 3
        } else {
            0
        }
    );
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include <iostream>
#include "cstdio"
#include <string>
#include <vector>

#define NMAX 100
using namespace std;

int main(){
	int N,K,ans,D[10] = {};
	cin >> N >> K;
	for (int i = 0; i < K; ++i)
	{
		int a;
		cin >> a;
		D[a]++;//嫌いな数字なら1違うなら0
	}
	ans = N;//品物の金額（買う時の最低額）
	while(1){
		int s = true,num = ans;
		while(num){//0になるまでやる
			if(D[num%10] == 1){//一の位を取り出してリストに存在したら
				s = false;
				break;
			}
			num /= 10;//桁を一つ減らす
		}
		if(s){//リストにかからない
			cout << ans <<"\n";
			break;
		}
		ans++;
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n) cin >> s[i];
  map<string, int> ans;
  REP(i, n){
    ans[s[i]]++;
  }
  for (string i : {"AC", "WA", "TLE", "RE"}){
    cout << i << " x " << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 6444
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <complex>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// define x, y as real(), imag()


template<class T>
istream& operator>> (istream& is, complex<T>& p) {
  T value;
  is >> value;
  p.real(value);
  is >> value;
  p.imag(value);
  return is;
}
#define M_PI 3.14159265358979323846
typedef long long int lli;
lli mod=1e9+9ll;
#define OS //single input use oeis
lli INF=9223372036854775807;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,s,t;
const double pi=3.14159265358979323846;
lli me(lli a,lli b)
{
    // cout<<mod<<"\n";
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
lli a[15][15];
lli c[15];
lli anss=1e15;
lli tot=0;
lli aa[15];
void slv(lli i)
{
	if(i>n+1)
	return;
	// cout<<tot<<" "<<x<<"\n";
	
	if(i==0)
	slv(i+1);
	else
	{
		lli flag=0;
		for(int j=1;j<=m;j++)
		{
			if(aa[j]<x)
			flag=1;
		}
		if(flag)
		{
		slv(i+1);
		tot+=c[i];
		for(int j=1;j<=m;j++)
		aa[j]+=a[i][j];
		slv(i+1);
		tot-=c[i];
		for(int j=1;j<=m;j++)
		aa[j]-=a[i][j];
		}
		else
		{
			// cout<<tot<<"\n";
			anss=min(anss,tot);
			return;
		}
	}
}
int main()
{
cin>>n>>k;
lli a[n+1];
for(int i=1;i<=n;i++)
cin>>a[i];
map<lli,lli> vis;
lli cc=0;
lli idx=1;
lli tim=k;
for(int i=1;cc<k;i=a[i])
{
	if(!vis[i])
	{
		vis[i]=cc;
		cc++;
		idx=a[i];
	}
	else
	{
		tim=cc-vis[i];
		idx=i;
		break;
	}
}
if(tim==k)
{
	cout<<idx<<"\n";
}
else
{
	k-=vis[idx];
	k=k%tim;
	lli ans=idx;
	for(int j=1;j<=k;j++)
	{
		ans=a[ans];
	}
	cout<<ans;
}
}

Measured memory_bytes: 15224
import sys
import itertools
input = sys.stdin.readline

N = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)

bob_filter = [i % 2 for i in range(len(a))]
alice_filter = [not i for i in bob_filter]
result = sum(list(itertools.compress(a, alice_filter))) \
         - sum(list(itertools.compress(a, bob_filter)))
print(result)

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

using namespace std;

int main()
{
  int n, a[101], t;

  while(cin>>n && n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    t = 0;
    for(int i = 1; i < n-1; i++){
      t += a[i];
    }

    cout << (t/(n-2)) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define INF 100000
#define MAX 101
#define NIL -6
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int G[MAX][MAX];
int n;
 
void prim(){
  int i,j;
  int d[MAX];
  int pi[MAX];
  int color[MAX];
  int min,u,v,sum=0;
 
  for(i=0;i<n;i++){
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    min = INF;
    u = NIL;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
        min = d[i];
        u = i;
      }
    }
    if(u == NIL){
      break;
    }
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] != INF){
        if(d[v] > G[u][v]){
          d[v] = G[u][v];
          pi[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i] != NIL)sum += G[i][pi[i]];
  }
  printf("%d\n",sum);
}
 
int main(){
  int e;
  int i,j;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e == -1){
        G[i][j] = INF;
      }else{
        G[i][j] = e;
      }
    }
  }
 
  prim();
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

// int cnt[26];
// int cc[26];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t = s;
    reverse(all(t));
    int l = 0,r = 0;
    int ad = 0;
    while(1){
        if(l+r>=len(s)){
            break;
        }
        if(s[l] != t[r]){
            if(s[l] == 'x'){
                l++;
                ad++;
            }else if(t[r] == 'x'){
                r++;
                ad++;
            }else{
                cout << "-1\n";
                return 0;
            }
        }else{
            l++,r++;
        }
    }
    cout << ad << "\n";
    // rep(i,len(s)){
    //     cnt[s[i]-'a']++;
    // }
    // int od = 0;
    // int id;
    // rep(i,26){
    //     if(i != 23){
    //         if(cnt[i] % 2 == 1){
    //             od++;
    //             id = i;
    //         }
    //     }
    // }
    // if(od >= 2){
    //     cout << "-1\n";
    // }else if(od == 1){
    //     rep(i,id){
    //         cc[s[i]-'a']++;
    //     }
    //     rep(i,id){
    //         cc[]
    //     }
    // }else{
    //
    // }
    return 0;
}


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

int main() {
	
	int N;
	std::cin >> N;
	
	int A[N];
	for (int i = 1; i <= N; i++) 
	{
	    std::cin >> A[i];
	}
	A[N+1] = 0;
	A[0] = 0;
	
	// i番目をやめたときの金額の総和
	//int cost[110000] = {0};
	int proA = 0, d;
	int B[N];
	int sum;
	
	for (int i = 1; i <= N; i++) 
	{
	    
	    B[i] = abs(A[i] - proA) + abs(A[i+1] - A[i]) - abs(proA - A[i+1]);
	    
	    sum += abs(A[i] - proA);
	    
	    proA = A[i];
	}
	
	sum += abs(A[N]);
	
	for (int i = 1; i <= N; i++) 
	{
	    std::cout << sum - B[i]  << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 2048
// 2020/08/23
// Walking Takahashi

#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  long long x, k, d;
  cin >> x >> k >> d;

  long long quo; // quotient
  quo = abs(x) / d;
  //cout << "quo=" << quo << endl;

  long long ans, tmp1, tmp2;
  if(k<=quo){
    ans = abs(x) - k*d;
  } else {
    if((k-quo)%2==0){
      ans = abs(abs(x) - quo*d);
      //cout << "0" << endl;
    } else{
      ans = abs(abs(x) - (quo+1)*d);
      //cout << "1" << endl;
    }
  }

  cout << ans;
}



Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val input1: String? = readLine()
    val tmp = input1!!.split(" ")
    val n = Integer.parseInt(tmp[0])
    val h = Integer.parseInt(tmp[1])
    val w = Integer.parseInt(tmp[2])
    var count = 0

    for(i in 0..(n-1)){
        val input2: String? = readLine()
        val tmp2 = input2!!.split(" ")
        val a = Integer.parseInt(tmp2[0])
        val b = Integer.parseInt(tmp2[1])
        if(h <= a && w <= b) count++
    }

    println(count)
}

Measured memory_bytes: 36536
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
int main() {
    // your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,q;
    cin >> n >> q;
    int a[n];
    for(int i = 0;i<n;i++)cin >> a[i];
    Query queries[q]; 
    for(int i = 0;i<q;i++){
    	int l,r;
    	cin >> l >> r;
    	queries[i].l = l-1; 
    	queries[i].r = r-1; 
    	queries[i].idx = i; 
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0;
}


Measured memory_bytes: 19328
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

const int eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

int main()
{

  double x1, y1, x2, y2;

  cin >> x1 >> y1 >> x2 >> y2;

  Vector p1( x1, y1 );
  Vector p2( x2, y2 );

  int q;
  cin >> q;

  for ( auto i = 0; i < q; ++i )
    {
      double x, y;
      cin >> x >> y;
      Vector p( x , y );
      
      Vector a = p2 - p1;
      Vector b = p - p1;

      Vector pr = p1 + a * Vector::dot( a, b ) / a.norm();

      cout << fixed << setprecision(10) << pr.x << " " << pr.y << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> a(3 * N);
    cin >> a;
    heap<int> hp(begin(a), begin(a)+N);
    priority_queue<int> pq(rbegin(a), rbegin(a)+N);
    int sum_l = accumulate(begin(a), begin(a)+N, 0LL);
    int sum_r = accumulate(rbegin(a), rbegin(a)+N, 0LL);
    vector<int> b(3 * N, 0), c(3 * N, 0);
    b[N-1] = sum_l;
    c[N-1] = sum_r;
    REPF(i, N, 2 * N) {
        if (hp.top() < a[i]) {
            sum_l -= hp.top(); hp.pop();
            hp.push(a[i]);
            sum_l += a[i];
        }
        if (pq.top() > a[3 * N - i - 1]) {
            sum_r -= pq.top(); pq.pop();
            pq.push(a[3 * N - i - 1]);
            sum_r += a[3 * N - i - 1];
        }
        b[i] = sum_l;
        c[i] = sum_r;
    }
    dump(b, c);
    int ans = -INF;
    REPF(i, N, 2 * N + 1) {
        chmax(ans, b[i-1] - c[3*N-i-1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8832
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, L);
  int sum = 0;
  FOR(i, N) { sum += L + i; }
  int ans, minabs = 1e8;
  FOR(i, N) {
    int ths = L + i;
    if (minabs > abs(ths)) {
      ans = ths;
      minabs = abs(ths);
    }
  }
  print(sum - ans);
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

const int MAX = 1e6 + 5;
vi isPrime(MAX);
void sieve() {
    rep(i, MAX) isPrime[i] = i;
    isPrime[0] = isPrime[1] = -1;
    for (int x = 2; x*x <= MAX; x++) {
        if (isPrime[x] != x) continue;
        for (int y = x; y < MAX; y += x) {
            isPrime[y] = x;
        }
    }
}

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

    int n; std::cin >> n;
    vi a(n); rep(i, n) std::cin >> a[i];

    sieve();
    vi cnt(MAX);
    rep(i, n) {
        set<int> s;
        int x = a[i];
        while (x != 1) {
            s.insert(isPrime[x]);
            x /= isPrime[x];
        }
        for (int v : s) {
            cnt[v]++;
        }
    }
    bool ispare = true;
    rep(i, MAX) if (cnt[i] > 1) ispare = false;

    int gcdv = a[0];
    rep(i, n-1) {
        gcdv = gcd(gcdv, a[i+1]);
    }

    if (ispare) {
        std::cout << "pairwise coprime" << "\n";
    } else if (gcdv == 1) {
        std::cout << "setwise coprime" << "\n";
    } else {
        std::cout << "not coprime" << "\n";
    }
}


Measured memory_bytes: 15084
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    while (t-->0) {
        int n; cin >> n;
        ll ans = 0;
        V< P<int, int> > lcam, rcam;
        for (int i = 0; i < n; i++) {
            int k, l, r; cin >> k >> l >> r;
            ans += (ll)min(l, r);
            if (l > r) lcam.emplace_back(k - 1, l - r);
            else {
                if (n == k) continue;
                rcam.emplace_back(n - k - 1, r - l);
            }
        }
        V< V<int> > lll(lcam.size()), rrr(rcam.size());
        int lsz = lcam.size(), rsz = rcam.size();
        for (int i = 0; i < lsz; i++) lll[min(lsz - 1, lcam[i].first)].emplace_back(lcam[i].second);
        for (int i = 0; i < rsz; i++) rrr[min(rsz - 1, rcam[i].first)].emplace_back(rcam[i].second);
        {
            multiset<int> muls;
            for (int i = lsz - 1; i >= 0; i--) {
                for (int j = 0; j < lll[i].size(); j++) muls.insert(-lll[i][j]);
                if (!muls.empty()) {
                    auto it = muls.begin();
                    ans += ll(-(*it));
                    muls.erase(it);
                }
            }
        }
        {
            multiset<int> muls;
            for (int i = rsz - 1; i >= 0; i--) {
                for (int j = 0; j < rrr[i].size(); j++) muls.insert(-rrr[i][j]);
                if (!muls.empty()) {
                    auto it = muls.begin();
                    ans += ll(-(*it));
                    muls.erase(it);
                }
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e7;
ll spf[N + 1];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		spf[i] = i;
	}
	for (ll i = 2; i <= n; i += 2) {
		spf[i] = 2;
	}
	for (ll i = 3; i * i <= n; i++) {
		if (spf[i] == i) {
			for (ll j = i * i; j <= n; j += i) {
				if (spf[j] == j)
					spf[j] = i;
			}
		}
	}
	for (ll i = 1; i <= n; i++) {
		ll x = i, mul = 1;
		while (x != 1) {
			ll cnt = 0;
			ll y = spf[x], z = 1;
			while (x % y == 0) {
				x /= y;
				cnt++;
				z *= y;
			}
			mul *= (cnt + 1) * z;
		}
		ans += mul;
	}	
	cout << ans << "\n";
 	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

using ll = long long;
using P = pair<int, int>;
using PLL = pair<ll, ll>;

const ll INF=1e8;
const ll MOD=1e9+7;

vector<PLL> prime_factorize(ll N) {
    vector<PLL> res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(int, char**)
{
    ll n;
    cin >> n;

    vector<PLL> plist = prime_factorize(n);

    ll ans = 0;
    for (auto p : plist) {
        ll t = 1;
        ll ps = p.second;
        while (ps >= t) {
            ps -= t;
            t++;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,m,X,Y;
  cin >>n >>m >>X >>Y;
  int maxx = X;
  int miny = Y;
  rep(i,n) {
    int x;
    cin >>x;
    maxx = max(maxx, x);
  }
  rep(i,m) {
    int y;
    cin >>y;
    miny = min(miny, y);
  }
  if(maxx>=miny) cout << "War" << endl;
  else cout << "No War" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, W =  list(map(int, input().split()))

    dp = [-1] * (W + 1)
    dp[0] = 0

    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] != -1 and dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v

    print(max(dp))

main()


Measured memory_bytes: 9720
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;
const int zero=200;

deque<int> q;
int n;
int a[200048];

int main ()
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	bool f=true;
	for (i=1;i<=n;i++)
	{
		if (f) q.push_back(a[i]); else q.push_front(a[i]);
		if (f) f=false; else f=true;
	}
	if (f)
		while (!q.empty())
		{
			printf("%d ",q.front());
			q.pop_front();
		}
	else
		while (!q.empty())
		{
			printf("%d ",q.back());
			q.pop_back();
		}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int ans = 0;
		int[] B = new int[N-1];
		for(int i = 0;i < N-1;i++) {
			B[i] = scn.nextInt();
		}
		ans += B[0] + B[N-2];
		for(int i = 0;i < N-2;i++) {
			ans += Math.min(B[i], B[i+1]);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22228
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn=1e6+5;
const int MAXN=1e7+5;


char a[maxn];
int main()
{
    scanf("%s",a+1);
    if(a[3]==a[4]&&a[5]==a[6])puts("Yes");
    else puts("No");
}

Measured memory_bytes: 760
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/



#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;


void mymain(){
    int n,k,s;
    cin >> n >> k >> s;
    int a = s+1;
    if( s == (int)1e9 )
        a = s-1;
    int i=0;

    for(;i<k;i++){
        cout << s<<" ";
    }
    for(;i<n;i++){
        cout << a <<" ";
    }
    cout << endl;




}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t;
t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
//head
const char s[] = "ATGC";
const int maxsta = 64;
int n, dp[maxn][maxsta];
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    //Dfs(0, );
    for(int sta = 0; sta < maxsta; ++sta) {
        dp[3][sta] = 1;
        int i = sta % 4, j = (sta/4) % 4, k = (sta/16) % 4;
        if(i == 0 && j == 2 && k == 3) dp[3][sta] = 0;
        if(i == 2 && j == 0 && k == 3) dp[3][sta] = 0;
        if(i == 0 && j == 3 && k == 2) dp[3][sta] = 0;
    }
    for(int len = 4; len <= n; ++len) {
        for(int sta = 0; sta < maxsta; ++sta) {
            int i = sta % 4, j = (sta/4) % 4, k = sta/16;
            for(int ch = 0; ch < 4; ++ch) {
                int newsta = j + k*4 + ch*16;
                dp[len][newsta] = (dp[len][newsta] + dp[len-1][sta]) % mod;
                if(j == 0 && k == 2 && ch == 3) dp[len][newsta] = 0;
                if(j == 2 && k == 0 && ch == 3) dp[len][newsta] = 0;
                if(j == 0 && k == 3 && ch == 2) dp[len][newsta] = 0;
                if(ch == 3) {
                    if(i == 0 && k == 2) dp[len][newsta] = 0;
                    if(i == 0 && j == 2) dp[len][newsta] = 0;
                }
            }
        }
    }
    int ans = 0;
    for(int sta = 0; sta < maxsta; ++sta) {
        ans = (ans + dp[n][sta]) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX_N = 100005; /* to be set */

ll m;

struct dataset {
    ll dp;
    dataset(ll dp = 1) : dp(dp) {}
    dataset operator+ (const dataset& a) const { /* merge nodes */
        return dataset((dp % m)*((a.dp) % m) % m);
    }
    dataset addRoot() const { /* include parent */
        return dataset((dp + 1) % m);
    }
};

vector<int> g[MAX_N];
vector<dataset> dp[MAX_N];
dataset ans[MAX_N];

dataset dfs1(int v, int p = -1) {
    dataset dpsum;
    dp[v] = vector<dataset> (g[v].size());

    rep(i, g[v].size()) {
        int u = g[v][i];
        if(u == p) continue;
        dp[v][i] = dfs1(u, v);
        dpsum = dpsum + dp[v][i];
    }
    return dpsum.addRoot();
}

void dfs2(int v, const dataset& dpParent = dataset(), int p = -1) {
    int deg = g[v].size();
    rep(i, deg) if(g[v][i] == p) dp[v][i] = dpParent;

    vector<dataset> dpSum_Left(deg+1), dpSum_Right(deg+1);
    rep(i,deg) dpSum_Left[i+1] = dpSum_Left[i] + dp[v][i];
    rrep(i, deg) dpSum_Right[i] = dpSum_Right[i+1] + dp[v][i];

    ans[v] = dpSum_Left[deg].addRoot();

    rep(i,deg) {
        int u = g[v][i];
        if(u == p) continue;
        dataset d = dpSum_Left[i] + dpSum_Right[i+1];
        dfs2(u, d.addRoot(), v);
    }
}

int main() {
    int n; cin >> n >> m;
    rep(i,n-1) {
        int a,b; cin >> a >> b; a--; b--;
        g[a].pb(b); g[b].pb(a);
    }
    dfs1(0);
    dfs2(0);

    rep(i,n) cout << (ans[i].dp - 1 + m) % m << endl;
}


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

int main(int argc, const char * argv[]) {
    string sa,sb,sc;
    
    cin >> sa >> sb >> sc;
    int ai,bi,ci = 0;
    
    char selector = sa[ai++];
    bool flag = true;
    while(flag){
        char temp = selector;
        if(temp=='a') {
            selector = sa[ai++];
            if(ai>sa.size()) {
                cout << "A";
                flag = false;
            }
        }
        else if(temp=='b') {
            
            selector = sb[bi++];
            if(bi > sb.size()){
                cout << "B" ;
                flag = false;
            }
        }
        else if(temp=='c') {
            selector = sc[ci++];
            if(ci > sc.size()){
                cout << "C";
                flag = false;
            }
        }
        
//        if(ai==sa.length()+1) {cout << "A" << endl;break;}
//        if(bi==sb.length()+1) { cout << "B" << endl; break;}
//        if(ci==sc.length()+1){cout << "C" << endl;break;}
    }
//    bool flag = true;
//    while(flag){
//        if(ai==sa.length()+1) {cout << "A" << endl; flag = false;}
//        if(bi==sb.length()+1) { cout << "B" << endl; flag = false;}
//        if(ci==sc.length()+1){cout << "C" << endl; flag = false;}
//        char temp = selector;
//        if(temp=='a') selector = sa[ai++];
//        if(temp=='b') selector = sb[bi++];
//        if(temp=='c') selector = sc[ci++];
//        
//    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
int dx,dy;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<(b-a)*(b-a+1)/2-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<modint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    modint operator()(int n, int k) {
        if (n < k || k < 0) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    modint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);
modint calc(int y, int x) {
    y--;
    x--;
    return comb(y + x, y);
}
int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    modint ans = 0;
    for (int i = 1; i <= h - a; i++) {
        ans += calc(i, b) * calc(h + 1 - i, w - b);
    }
    cout << ans.value() << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    lint ans = 0;
    for_(a,1,K+1) for_(b,1,K+1) for_(c,1,K+1) {
        int x = __gcd(a, b);
        x = __gcd(x, c);
        ans += x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

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

    int n, x;
    cin >> n >> x;
    int d = 0;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        int y;
        cin >> y;
        d += y;
        if (d <= x) {
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int x;
    cin >> x;
    if(1200>x) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)

    divisors.sort(reverse=True)
    return divisors

N = int(input())
A = make_divisors(N)[0]
B = N // A
F = max(len(str(A)), len(str(B)))

print(F)

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

#define int long long
#define pii pair<int, int>
#define pb push_back
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    if(s.size() < 6){
        cout << "No\n";

    }
    else if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    } 
    else{
        cout <<"No\n";
    }
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*⁽⁽(ી₍₍⁽⁽(ી( ˆεˆ )ʃ)₎₎⁾⁾ʃ)₎₎*/
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost

	//for dijkstra
	bool done; //conform or not
	ll cost; // now cost
	int par;

	bool operator<(const Vertex& another) const { // priority --> min
		return another.cost < cost; // order(cost)
	}

	bool operator==(const Vertex& another) const {
		return another.cost == cost; // order(cost)
	}
};
struct Vertex V[100002];

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> edgenum;


	FORq(i,1,N-1){
		int a,b;
		cin >> a >> b;
		V[a].edges_to.PB(b);
		V[b].edges_to.PB(a);
	}

	queue<int> Q;
	Q.push(1);
	V[1].done = true;
	edgenum.PB(1);

	while(!Q.empty()){
		int now = Q.front(); Q.pop();
		REP(i,V[now].edges_to.size()){
		    int next = V[now].edges_to[i];
		    if (V[next].done) continue;
		    V[next].cost = V[now].cost + 1;
		    V[next].done = true;
		    Q.push(next);
			edgenum.PB(next);
		}
	}

	ll ans = K;

	REP(i,N){
		//cout << "edgenum = " << edgenum[i] << endl;
	    int num = edgenum[i];
		ll nans = 1;
	    if (V[num].cost == 0){

	    	REP(j,V[num].edges_to.size()){
	    		if (K-1-j <= 0) nans = 0;
	    	    nans = (nans * (K-1-j)) % MOD;
	    	}

	    }else{
			REP(j,V[num].edges_to.size()-1){
				if (K-2-j <= 0) nans = 0;
				nans = (nans * (K-2-j)) % MOD;
			}
	    }

	    //cout << ans << endl;
	    ans = (nans * ans) % MOD;
	}

	cout << ans << "\n";
	/*FORq(i,1,N){
		cout << V[i].cost << "\n";
	}*/

	return 0;
}


Measured memory_bytes: 11768
#include<bits/stdc++.h>
/* imp functions
	sorting arrays - sort(array,array+n);
	sorting vectors - v.sort(v.begin(),v.end());
	erasing element of vector - v.erase(v.begin()+i);
	inserting element in vector - v.insert(v.begin()+i,element);
	reversing vector - v.reverse(v.begin(),v.end());
	finding size of string - str.length();
	finding size of vector - v.size();
*/
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define ll long long 
#define pb push_back
#define gcd __gcd
// checking whether a number is prime or not
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_less(ll n){
    ll array[n];
    vector<ll> factor;
    for(ll i=1;i<=n;i++) array[i]=i;
    ll prime[n];
    for(ll i=0;i<n;i++) prime[i]=1;
    for(ll i=2;i<=sqrt(n);i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returning vector containing index refering to elements of normal array after sorting it
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
//calculating power in order logn returns x^y
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
int main(){
    ll x,y;
    cin>>x>>y;
    ll a = x*y;
    if(x==1 || y==1) cout<<"1";
    else if(a%2==0) cout<<a/2;
    else cout<<a/2 + 1;
}


Measured memory_bytes: 256