akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int w, a, b;
	cin >> w >> a >> b;

	if(b > a){
		cout << max(0, (b - (a + w))) << endl;
	}else{
		cout << max(0, (a - (b + w))) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
#template
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
s = 7
for i in range(K):
    if s % K == 0:
        print(i+1)
        exit()
    if s % K != s:
        s = 10*(s%K) + 7
        continue
    s = 10*s + 7
print(-1)

Measured memory_bytes: 63888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll r,g,b,k,p,q;
    cin>>r>>g>>b>>k;
    while(r>=g && k){
        g*=2;
        k--;
    }
    while(g>=b && k){
        b*=2;
        k--;
    }
    if(b>g && g>r) cout<<"Yes";
    else cout<<"No";
}

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

int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int len=s.length();

    for (int i=0;i<len;i++){
        int temp=s[i]-'A';
        temp=(temp+n)%26;
        s[i]='A'+temp;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  vector<vector<int>> gcd(K, vector<int>(K));
  int sum = 0;
  for (int a = 1; a <= K; a++){
    for (int b = 1; b <= K; b++){
      for (int g = 1; g <= min(a,b); g++){
        if (a % g == 0 && b % g == 0){
          gcd.at(a - 1).at(b - 1) = g;
        }
      }
    }
  }
  for (int a = 1; a <= K; a++){
    for (int b = 1; b <= K; b++){
      for (int c = 1; c <= K; c++){
        sum += gcd.at(gcd.at(a - 1).at(b - 1) - 1).at(c - 1);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n;
	long long ans = 1;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		ans = ans * i % 1000000007;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

typedef unsigned long long ull;
const int MAXN=1e5+10;
const ull LIMIT=1000000000000000000llu;

ull input[MAXN];

int main(){
    int N;
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        ull temp;
        scanf("%llu",&temp);
        if (temp==0){
            puts("0");
            return 0;
        }
        input[i]=temp;
    }

    ull ans=1ull;
    for(int i=0;i<N;i++){
        ull newval=(ans*input[i])%(LIMIT+1);
        if (newval/input[i]!=ans){
            puts("-1");
            return 0;
        }
        ans=newval;
    }

    printf("%llu\n",ans);

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
 
#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007


int main() {
	ll n; scanf("%lld", &n);
	ll x = 1;
	while(n >= x)
		x <<= 1LL;
	printf("%lld", x-1);
}

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

int main(){
    
    std::string a, b;
    std::cin >> a >> b;

    if(a.size() > b.size()){
        std::cout << "GREATER" << std::endl;
    }else if(a.size() < b.size()){
        std::cout << "LESS" << std::endl;
    }else{
        if(a > b){
            std::cout << "GREATER" << std::endl;
        }else if(a < b){
            std::cout << "LESS" << std::endl;
        }else{
            std::cout << "EQUAL" << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
program main

  implicit none
  integer :: n 
  integer,allocatable ::a(:)
  integer :: i
  
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  
  do i = 1, n  
    if( mod(a(i),2) /= 0 ) cycle
    if( mod(a(i),3) == 0 .or. mod(a(i),5) == 0 ) then
    else
      print*,"DENIED"
      stop
    end if
  end do
  print*,"APPROVED"
  
end program main


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

template <int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return is;
    }

    static int get_mod() { return mod; }
};

// TにはModIntを渡す
template <typename T>
struct Combination {
    vector<T> _fact, _rfact, _inv;

    Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
        _fact[0] = _rfact[sz] = _inv[0] = 1;
        for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
        _rfact[sz] /= _fact[sz];
        for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
        for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
    }
    inline T fact(int k) const { return _fact[k]; }

    inline T rfact(int k) const { return _rfact[k]; }

    inline T inv(int k) const { return _inv[k]; }

    T P(int n, int r) const {
        if (r < 0 || n < r) return 0;
        return fact(n) * rfact(n - r);
    }

    T C(int p, int q) const {
        if (q < 0 || p < q) return 0;
        return fact(p) * rfact(q) * rfact(p - q);
    }

    T H(int n, int r) const {
        if (n < 0 || r < 0) return 0;
        return r == 0 ? 1 : C(n + r - 1, n);
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    const int mod = 1000000007;
    Combination<ModInt<mod>> comb(n + k);
    cout << comb.H(n, k) << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
#define x real()
#define y imag()

string ccw(P a,P b,P c){
  P ab=b-a,ac=c-a;
  P k=ac*conj(ab);
  if(k.y>0)return "COUNTER_CLOCKWISE";
  if(k.y<0)return "CLOCKWISE";
  if(k.x<0)return "ONLINE_BACK";
  if(abs(ab)<abs(ac))return "ONLINE_FRONT";
  return "ON_SEGMENT";
}

int main(){
  double x0,y0,x1,y1,x2,y2;
  cin>>x0>>y0>>x1>>y1;
  P a(x0,y0);
  P b(x1,y1);
  int n;
  cin>>n;
  while(n--){
    cin>>x2>>y2;
    P c(x2,y2);
    cout<< ccw(a,b,c) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M) cin >> A[i];
    int s = N;
    REP(i, M){
        s -= A[i];
    }

    if(s < 0) cout << -1 << endl;
    else cout << s << endl;
    return 0;
}

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

int main(){
	string s;	cin>>s;
	int k;	cin>>k;
	set<string> st;

	for(int i=0; i<s.length(); i++){
		for(int j=i; j<s.length(); j++){
			if(j-i<k){
				string tmp="";
				for(int x=i; x<=j; x++){
					tmp=tmp+s[x];
				}
				st.insert(tmp);
			}
		}
	}

	auto itr = st.begin();
	for(int i=1;i<k;i++){
		itr++;
	}

	cout<<*itr<<endl;



	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf                        scanf    
 
const ll M=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % M;
        a = a * a % M;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

long long binpower(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpower(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

///////////// TEMPLATE END /////////////////////////////////



void solve()
{
	ll n;
	cin>>n;
	vpll a;
	
	vll t1,t2;
	
	fr(i,n)
	{
		ll u,v;
		cin>>u>>v;
		a.pb({u,v});	
		t1.pb(u+v);
		t2.pb(u-v);
	}	
	sort(all(t1));
	sort(all(t2));
	ll ans=-1;
	
	ans=max(t1[t1.size()-1]-t1[0],t2[t2.size()-1]-t2[0]);
	cout<<ans<<endl;
	
}



int main()
{
    fastio

//    int t;
//    cin>>t;
//    fr1(i,t)
    {
//        cout<<"Case #"<<i<<": ";
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 11484
n, m = gets.chomp.split.map(&:to_i)
a = []
b = []

n.times { a.push gets.chomp.split.map(&:to_i) }
m.times { b.push gets.chomp.to_i }

(0..(n-1)).each do |i|
  n = 0
  (0..(m-1)).each do |j|
    n += a[i][j] * b[j]
  end
  puts n
end



Measured memory_bytes: 7024
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a,b,c;
int sleep() {
	int j=0;
	for(int i=1; i<2000001; i++) j++;
	return j;
}
int main() 
{
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a%2==0||b%2==0||c%2==0) {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c);
    sleep();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;


    vector<bool> seen;
    void dfs(const Graph &G,int v){
        int cnt = 0;
        seen[v] = true;
        for(auto nv:G[v]){
            if(seen[nv])continue;
            cnt++;
            dfs(G,nv);
        }
    }
    int main(){
      int n;cin>>n;
      set<int>s;
      rep(i,n){
          int a;cin>>a;
          s.insert(a);
      }
      cout<<s.size();
    }


Measured memory_bytes: 256
let j,u,k,e,r="overflow",read_line,int_of_string,print_endline,String.length;;let g s=let n=r s in let rec($)i a=if i=n then a else(i+1)$(s.[i]::a)in 0$[]and h c=int_of_char c-48;;let(&)v w=let f x=if x<=9then(x,0)else(x mod 10,1)in let rec(^)o=function|([],[],1)->1::o|([],[],_)->o|(a::b,[],z)->let s,t=f(h a+z)in(s::o)^(b,[],t)|([],c::d,z)->let s,t=f(h c+z)in(s::o)^([],d,t)|(a::b,c::d,z)->let s,t=f(h a+h c+z)in(s::o)^(b,d,t)in[]^(g v,g w,0);;let n=read_int();;let rec f i=if i<n then(let x=u()and y=u()in let s=r x and t=r y in if s>80||t>80then e j else if s<10&&t<10then Printf.printf"%d
"(k x+k y)else(let z=x&y in if List.length z>80then e j else(List.iter(fun e->print_int e)z;print_newline()));f(i+1));;f 0

Measured memory_bytes: 2244
import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  n <- getInt
  xs <- getInts
  let ys = zipWith (-) xs [1..]
  let m = median ys
  print . sum . map (abs . subtract m) $ ys

getInt :: IO Int
getInt = readLn

getInts :: IO [Int]
-- getInts = map read . words <$> getLine
getInts = unfoldr (BC.readInt . BC.dropWhile (== ' ')) <$> BC.getLine

median :: Ord a => [a] -> a -- O(n log n)
median xs = sort xs !! (length xs `div` 2)


Measured memory_bytes: 50556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long X = sc.nextLong();
        long Y = sc.nextLong();

        System.out.println(solve(X, Y));

        sc.close();
    }

    static int solve(long X, long Y) {
        int result = 0;
        for (long i = X; i <= Y; i *= 2) {
            ++result;
        }

        return result;
    }
}

Measured memory_bytes: 23764
int main()
{
  int n,i,j,x;
  scanf("%d",&n);
  for(;n--;)
    {
      scanf("%d%d",&i,&j);
      if(i<6)
	{
	  for(;i-j;i+=i<j?1:-1)printf("%d ",i);	    
	}
      else
	{
	  for(x=-1;i-j;)
	    {      
	      printf("%d ",i);
	      if(i<6)
		i+=x;
	      else
		i++;
	      if(i==0)
		x=1;
	      if(i>9) i=5;
	    }
	}
      printf("%d\n",j);
    }
}

Measured memory_bytes: 0
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

   insert(key) {
     if (this.root === null) {
       this.root = new BinaryTree.Node(key);
       return;
     }
     let x = this.root, y;
     let newNode = new BinaryTree.Node(key);
     while (x !== null) {
       y = x;
       x = x[key < x.key ? 'left' : 'right'];
     }
     newNode.parent = y;
     y[key < y.key ? 'left' : 'right'] = newNode;
   }


  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    if (n === null) return;
    let leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      let skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



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

typedef pair<int, int> pii;

int N;
vector<pii> B;
vector<int> X;

struct BIT {
    vector<pii> tree;
    void init() {
        tree = vector<pii>(4*N, pii(1e9, 0));
    }
    void upd(int idx, pii val, int l, int r, int n) {
        if(idx < l || r < idx) return;
        if(l == r) {
            tree[n] = val;
            return;
        }
        int m = (l + r)>>1;
        upd(idx, val, l, m, 2*n);
        upd(idx, val, m + 1, r, 2*n + 1);
        tree[n] = min(tree[2*n], tree[2*n + 1]);
    }
    pii quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return pii(1e9, 0);
        if(a <= l && r <= b) return tree[n];
        int m = (l + r)>>1;
        pii L = quer(a, b, l, m, 2*n);
        pii R = quer(a, b, m + 1, r, 2*n + 1);
        return min(L, R);
    }
} mn, mx, tmp;

int main() {
    scanf("%d", &N);
    B.resize(N);
    mn.init();
    mx.init();
    tmp.init();
    int mnmx = 1e18;
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &B[i].first, &B[i].second);
        X.push_back(B[i].first);
        X.push_back(B[i].second);
        if(B[i].first >= B[i].second) swap(B[i].first, B[i].second);
        mn.upd(i, pii(-B[i].first, i), 0, N - 1, 1);
        mx.upd(i, pii(B[i].second, i), 0, N - 1, 1);
        tmp.upd(i, pii(B[i].first, i), 0, N - 1, 1);
        mnmx = min(mnmx, B[i].second);
    }
    sort(X.begin(), X.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    long long ans = 1e18;
    int remx = 0, remn = 1e9;
    for(int i = 0; i < X.size(); i++) {
        if(X[i] > mnmx) break;
        int rmn = X[i], rmx;
        int bmn, bmx = X.back();

        while(tmp.tree[1].first < rmn) {
            pii t = tmp.tree[1];
            tmp.upd(t.second, pii(1e9, 0), 0, N - 1, 1);
            mn.upd(t.second, pii(1e9, 0), 0, N - 1, 1);
            mx.upd(t.second, pii(1e9, 0), 0, N - 1, 1);
            remn = min(remn, B[t.second].first);
            remx = max(remx, B[t.second].second);
        }

        rmx = max(-mn.tree[1].first, remx);
        bmn = min(mx.tree[1].first, remn);
        ans = min(ans, (long long)(rmx - rmn)*(bmx - bmn));
    }
    printf("%lld", ans);
}


Measured memory_bytes: 22772
#include <cstdio>
#include <vector>
#include <algorithm>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;

int main() {
    int n; scanf("%d", &n);
    vector<int> a(3*n); repeat (i, 3*n) scanf("%d", &a[i]);
    whole(sort, a);
    ll result = 0;
    repeat (i, n) {
        result += a[3*n-1 - (2*i+1)];
    }
    printf("%lld\n", result);
    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c; gi(a), gi(b), gi(c);
	swap(a, b);
	swap(a, c);
	print(a); pc(' '); print(b); pc(' '); print(c);
}


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

using namespace std;

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

int main() {
    int n; cin >> n;
    vector<pair<int, int>> v;
    rep(i, n) {
        int a, b; cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(all(v));
    rep(i, n) {
        cout << v[i].first << " " << v[i].second << endl;
    }
}



Measured memory_bytes: 3856
N, M = map(int, input().split())
X = [int(x) for x in input().split()]

if N >= M:
    print(0)
else:
    X.sort()
    dX = [X[i + 1] - X[i] for i in range(M - 1)]
    dX.sort(reverse=True)
    print(sum(dX[N - 1:]))

Measured memory_bytes: 13840
bottons=[]
for x in input().split():
    bottons.append(int(x))
if bottons[0]>bottons[1]:
    max=bottons[0]+(bottons[0]-1)
elif bottons[1]>bottons[0]:
    max=bottons[1]+(bottons[1]-1)
else:
    max=sum(bottons)

print(max)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main()
{
	long long int h,sum=0;
	scanf("%lld",&h);
	int n=1;
	while(h!=0){
		sum+=pow(2,n-1);
		h/=2;
		n++;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int sx = scanner.nextInt();
        int sy = scanner.nextInt();
        int tx = scanner.nextInt();
        int ty = scanner.nextInt();

        int xGap = tx - sx;
        int yGap = ty - sy;

        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < yGap; i++) {
         stringBuffer.append("U");
        }
        for (int i = 0; i < xGap; i++) {
            stringBuffer.append("R");
        }
        for (int i = 0; i < yGap; i++) {
            stringBuffer.append("D");
        }
        for (int i = 0; i < xGap; i++) {
            stringBuffer.append("L");
        }
        stringBuffer.append("L");
        for (int i = 0; i < yGap; i++) {
            stringBuffer.append("U");
        }
        stringBuffer.append("U");
        for (int i = 0; i < xGap; i++) {
            stringBuffer.append("R");
        }
        stringBuffer.append("R");
        stringBuffer.append("D");
        stringBuffer.append("R");
        for (int i = 0; i < yGap; i++) {
            stringBuffer.append("D");
        }
        stringBuffer.append("D");
        for (int i = 0; i < xGap; i++) {
            stringBuffer.append("L");
        }
        stringBuffer.append("L");
        stringBuffer.append("U");

        System.out.println(stringBuffer.toString());
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

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

    int ans = 0;
    int cnt = 0;
    for(int i=0; i<N-1; i++){
        if(H[i] >= H[i+1]) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#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);
  }
  sort(a.begin(),a.end());
  a.erase( unique( a.begin(), a.end() ), a.end() );
  
  cout << a.size() << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

const MOD: i64 = 1_000_000_007;

#[derive(Copy, Clone, Hash, Debug)]
struct ModInt {
  x: i64
}
impl ModInt {
  fn new(x: i64) -> Self {
    let x = x % MOD;
    ModInt {
      x: if x < 0 {
        x + MOD
      } else {
        x
      }
    }
  }
  fn pow(self, e: i64) -> Self {
    if e == 0 {
      Self::new(1)
    } else if e % 2 == 1 {
      self.pow(e - 1) * self
    } else {
      let y = self.pow(e / 2);
      y * y
    }
  }
  #[allow(dead_code)]
  fn inv(self) -> Self {
    self.pow(MOD - 2)
  }
  #[allow(dead_code)]
  fn fact(n: usize) -> Vec<Self> {
    let mut ret = vec![0.into(); n+1];
    ret[0] = 1.into();
    for i in 1 .. n + 1 {
      ret[i] = ret[i-1] * i as i64;
    }
    ret
  }
  #[allow(dead_code)]
  fn inv_fact(fact: &Vec<Self>) -> Vec<Self> {
    let n = fact.len() - 1;
    let mut ret = vec![0.into(); n+1];
    ret[n] = fact[n].inv();
    for i in (0 .. n).rev() {
      ret[i] = ret[i+1] * (i + 1) as i64;
    }
    ret
  }
}
impl<T: Into<ModInt>> std::ops::Add<T> for ModInt {
  type Output = Self;
  fn add(self, other: T) -> Self {
    let other = other.into();
    let sum = self.x + other.x;
    ModInt {
      x: if sum >= MOD { sum - MOD } else { sum }
    }
  }
}
impl<T: Into<ModInt>> std::ops::Sub<T> for ModInt {
  type Output = Self;
  fn sub(self, other: T) -> Self {
    let other = other.into();
    let sum = self.x - other.x;
    ModInt {
      x: if sum < 0 { sum + MOD } else { sum }
    }
  }
}
impl<T: Into<ModInt>> std::ops::Mul<T> for ModInt {
  type Output = Self;
  fn mul(self, other: T) -> Self {
    let other = other.into();
    ModInt {
      x: self.x * other.x % MOD
    }
  }
}
impl<T: Into<ModInt>> std::ops::Div<T> for ModInt {
  type Output = Self;
  fn div(self, other: T) -> Self {
    let other = other.into();
    self * other.inv()
  }
}
impl From<i64> for ModInt {
  fn from(x: i64) -> Self {
    ModInt::new(x)
  }
}
impl std::fmt::Display for ModInt {
  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    self.x.fmt(f)
  }
}
impl<T: Into<ModInt>> std::ops::AddAssign<T> for ModInt {
  fn add_assign(&mut self, other: T) {
    *self = *self + other;
  }
}
impl<T: Into<ModInt>> std::ops::SubAssign<T> for ModInt {
  fn sub_assign(&mut self, other: T) {
    *self = *self - other;
  }
}
impl<T: Into<ModInt>> std::ops::MulAssign<T> for ModInt {
  fn mul_assign(&mut self, other: T) {
    *self = *self * other;
  }
}
impl<T: Into<ModInt>> std::ops::DivAssign<T> for ModInt {
  fn div_assign(&mut self, other: T) {
    *self = *self / other;
  }
}

#[fastout]
fn main() {
  input! {
    n: i64,
    k: i64,
  }
  let mut sum = ModInt::new(0);
  for c in k ..= n+1 {
    let l = c * (c - 1) / 2;
    let r = c * (2 * n - c + 1) / 2;
    sum += r - l + 1;
  }

  println!("{}", sum);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll temp1,temp2;
    ll h[n];
    ll ans = 0;
    //set<ll> hoge;
    bool huga[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
        huga[i] = true;
    }

    for(int i = 0; i < m ; i++){
        cin >> temp1 >> temp2;
       // hoge.emplace(max(temp1,temp2));
       if(h[temp1-1] > h[temp2-1]){
           huga[temp2-1] = false;
       }
       else if(h[temp1-1] < h[temp2-1]){
           huga[temp1-1] = false;
       }
      else if(h[temp1-1] == h[temp2-1]){
        huga[temp2-1] = false;
        huga[temp1-1] = false;
        
      }
    }
    for(int i = 0; i < n; i++){
        if(huga[i]) ans += 1;

    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 4524
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
ll a[2010];
int s[2010];
ll dp[2010][2010];

void solve(){
    cin >> n;
    vector<LP> v;
    rep(i,n){
        cin >> a[i];
        v.emplace_back(a[i],i);
    }
    sort(v.begin(),v.end());
    rep(i,n){
        s[i]=v[n-i-1].second;
    }
    rep(i,n+1){
        rep(j,i+1){
            dp[i][j]=-INF;
        }
    }
    dp[0][0]=0;
    rep(i,n){
        rep(j,i+1){
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+(ll)abs(j-s[i])*a[s[i]]);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+(ll)abs(n-i+j-1-s[i])*a[s[i]]);
        }
    }
    ll ans=0;
    rep(i,n+1){
        ans=max(ans,dp[n][i]);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 26352
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
ans = 1
for k in range(N):
    ans = lcm(ans, int(input()))

print(ans)


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

// nCk の和について
// 引用資料：https://mathtrain.jp/nikoubekijo

////// a^n mod を計算する、a^(2^k) mod の積で求める、 O(n) から O(log(n)) の短縮が見込まれる
long modpow(long base, long exponent, long mod) {
    long power = 1;
    while (exponent > 0) {
        if (exponent & 1){
            power = power * base % mod;
        }
        base = base * base % mod;
        exponent >>= 1;
    }
    return power;
}

////// 二項係数の求め方
// 引用資料：https://drken1215.hatenablog.com/entry/2018/06/08/210000
// COMinit() : O(n), COM(n, k) : O(1)
const int MOD = 1000000007;
const int MAX = 200002;

long factorial[MAX], finv[MAX], inv[MAX]; 

// テーブルを作る前処理
void COMinit() {
    factorial[0] = factorial[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        factorial[i] = factorial[i - 1] * i % MOD;      // factorial[] : a! (mod MOD)
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;    // inv[] : a^-1     (mod MOD) 
        finv[i] = finv[i - 1] * inv[i] % MOD;           // finv[] : (a!)^-1 (mod MOD) 
    }
}

// 二項係数計算
long COM(int n, int k){
    long ans = 1;
    for (int i = 0; i < k; i++){
        ans = (ans * (n - i) % MOD) * inv[i+1] % MOD;
    }
    return ans;
}

int main(void){
    // 入力
    int n, a, b;
    cin >> n >> a >> b;

    COMinit();
    long combiSum = modpow(2, n, MOD) - 1;
    cout <<  ( combiSum - COM(n, a) - COM(n, b) + 2*MOD) % MOD << endl;

    return 0;
}


Measured memory_bytes: 8328
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<pair<int,int>> v(n);
  rep(i,n) cin>>v[i].first>>v[i].second;

  sort(all(v));

  int ub = 1;
  int ch = 1;
  rep(i,n){
    if(v[i].first == ch) continue;
    else {
      int nub = ub + (v[i].first - ch);
      ch = v[i].first;
      if(v[i].second < nub){
        cout << ch-1 << endl;
        return 0;
      } else if(v[i].second == nub){
        ub = nub - 1;
      } else {
        ub = nub;
      }
    }
  }

  cout << h << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPR(i, N) for (int i = (N)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

int main() {
  ll N, W;
  std::cin >> N >> W;
  ll w[N];
  ll v[N];
  REP(i, N) { std::cin >> w[i] >> v[i]; }
  ll dp[W + 1] = {-1};
  dp[0] = 0;
  ll M = 0;
  REP(i, N) {
    REPR(j, M + 1) {
      if (dp[j] == -1)
        continue;
      if (j + w[i] <= W) {
        dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
        M = max(M, j + w[i]);
      }
    }
  }
  sort(dp, dp + W + 1, greater<ll>());
  std::cout << dp[0] << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 1024
//I made a very very stupid mistake and stucked on this task for a long time

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

int x,y,z,ar['Z'][10001];
string s1;
long long sum;

int main() {
	cin >> x;
	cin >> s1;
	for (int a = 0; a <= x; a++) {
		ar[s1[a]][a]++;
	}
	for (int a = 0; a <= 10000; a++) {
		ar['R'][a]+=ar['R'][a-1];
		ar['G'][a]+=ar['G'][a-1];
		ar['B'][a]+=ar['B'][a-1];
	}
	for (int a = 0; a < x; a++) {
		for (int b = a+1; b < x; b++) {
			int tmp = b-a;
			if ((s1[a] == 'R' && s1[b] == 'G') || (s1[a] == 'G' && s1[b] == 'R')) {
				sum += ar['B'][10000] - ar['B'][b];
				if (s1[b+tmp] == 'B') sum--;
			} else if ((s1[a] == 'B' && s1[b] == 'G') || (s1[a] == 'G' && s1[b] == 'B')) {
				sum += ar['R'][10000] - ar['R'][b];
				if (s1[b+tmp] == 'R') sum--;				
			} else if ((s1[a] == 'B' && s1[b] == 'R') || (s1[a] == 'R' && s1[b] == 'B')) {
				sum += ar['G'][10000] - ar['G'][b];	
				if (s1[b+tmp] == 'G') sum--;			
			}
		}		
	}
	cout << sum  << "\n";
}

Measured memory_bytes: 3752
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int debt = 100000;

        for(int i=0;i<n;i++){
            debt += debt*0.05;
            if(debt%1000!=0){ debt = debt/1000*1000+1000; }
        }
        System.out.println(debt);
    }
}


Measured memory_bytes: 25712
n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

score_cnt = [None] * (n + 1)
for i in range(1, n + 1):
    now = i
    cnt = 0
    score = 0
    for _ in range(n):
        now = p[now]
        score += c[now]
        cnt += 1
        if now == i:
            score_cnt[i] = [score, cnt]
            break

ans = - 10 ** 20
for i in range(1, n + 1):
    now = i
    score = 0
    left = k
    for j in range(n):
        now = p[now]
        score += c[now]
        left -= 1
        if left >= 0:
            times = left // score_cnt[now][1]
            score_loop = score + times * score_cnt[now][0]
            ans = max(ans, score, score_loop)

print(ans)


Measured memory_bytes: 74840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    map<string,int> mp;
    int n; cin >> n;
    rep(i, n) {
        string s; cin >> s;
        mp[s]++;
    }
    int m; cin >> m;
    rep(i, m) {
        string s; cin >> s;
        mp[s]--;
    }
    int ans = 0;
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ans = max(ans, it->second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    for(i in 0..100){
        for(j in 0..100){

            if(j > n) break

            if(i*4 + j*7 == n){
                println("Yes")
                return
            }
        }
    }

    println("No")

}

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

const int N=160005,M=480005,oo=1e9;
struct edge{
	int di,nextt,ed;
}e[M];
int son[N],nedge,cur[N],deep[N],n,m;
inline void aedge(int a,int b,int c){
	e[++nedge].nextt=son[a];
	son[a]=nedge;
	e[nedge].ed=b;
	e[nedge].di=c;
}
inline void insert(int a,int b,int c){
	aedge(a,b,c); aedge(b,a,0); //cout<<a<<" "<<b<<endl;
}
inline bool bfs(int s,int t){
	for(int i=1;i<N;i++)deep[i]=oo;
    for(int i=1;i<N;i++)cur[i]=son[i];
    deep[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int now=q.front();q.pop();
        for(int tmp=son[now];tmp;tmp=e[tmp].nextt)
            if(deep[e[tmp].ed]>=oo&&e[tmp].di){deep[e[tmp].ed]=deep[now]+1,q.push(e[tmp].ed);}
    }
    return deep[t]<oo;
}
int dfs(int now,int t,int limit){
    if(!limit||now==t) return limit;
    int flow=0,f;
    for(int tmp=cur[now];tmp;tmp=e[tmp].nextt){
        cur[now]=tmp;
        if(deep[e[tmp].ed]==deep[now]+1&&(f=dfs(e[tmp].ed,t,min(limit,e[tmp].di)))){
            flow+=f; limit-=f; e[tmp].di-=f; e[((tmp-1)^1)+1].di+=f; if(!limit)break;
        }
    }
    return flow;
}
inline int dinic(int s,int t){
    int ans=0;
    while(bfs(s,t))ans+=dfs(s,t,oo);
    return ans;
}
inline int read(){
	int x=0;char ch=getchar();bool positive=1;
	for(;!isdigit(ch);ch=getchar())	if(ch == '-')	positive=0;
	for(;isdigit(ch);ch=getchar())	x=x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a;putchar('-');
	}
	write(a);puts("");
}
const int P=10000005;
int tot,q[P/10];
bool heshu[P],a[P];
int b[205];
int main(){
    n=read();
	for(int i=2;i<P;i++){
		if(!heshu[i])q[++tot]=i;
		for(int j=1;j<=tot&&i*q[j]<P;j++){
			heshu[i*q[j]]=1; if(i%q[j]==0)break;
		}
	}
	tot=0;
	for(int i=1;i<=n;i++){
		int t=read(); a[t]^=1; a[t+1]^=1;
	}
	heshu[1]=1;
	int jb=0;
	for(int i=1;i<P;i++)if(a[i])b[++jb]=i;
	for(int i=1;i<=jb;i++)if(b[i]&1){
		for(int j=1;j<=jb;j++)if(b[j]%2==0){
			if(!heshu[abs(b[i]-b[j])]){insert(i,j,1);}
		}
	}
	int s=jb+1,t=jb+2;
	for(int i=1;i<=jb;i++)if(b[i]&1){insert(s,i,1); tot++; }else insert(i,t,1);
	int jj=dinic(s,t); 
	cout<<jj+(jb-jj*2)+((tot-jj)&1)<<endl;
}


Measured memory_bytes: 24960
#include <stdio.h>

static const int MAX = 100;

void swap(unsigned short *a, unsigned short *b ) {
	unsigned short temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

short selectionSort( unsigned short *p_dt, unsigned short n ) {
	short i, j, idx, sw = 0;

	for ( i = 0; i < n; i++ ) {
		idx = i;
		for ( j = i; j < n; j++ ) {
			if (p_dt[j] < p_dt[idx]) idx = j;
		}
		if ( idx != i ) {
			swap( &p_dt[i], &p_dt[idx] );
			sw++;
		}
	}
	return sw;
}

int main( void ) {
	short i, sw;
	unsigned short n, dt[MAX];

	scanf( "%d", &n );
	for ( i = 0; i < n; i++ ) scanf( "%d", &dt[i] );

	sw = selectionSort( dt, n );

	for ( i = 0; i < (n - 1); i++ ) printf( "%d ", dt[i] );
	printf( "%d\n%d\n", dt[i], sw );

	return 0;
}



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

using namespace std;

string dp[128][128];

int main()
{
    int w, h;
    while (scanf("%d %d", &w, &h) && w){
        char mp[128][128];
        
        for (int i = 0; i < h; i++){
            scanf("%s", mp[i]);
        }
        
        string res = "";
        
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                dp[i][j] = "";
                if (i - 1 >= 0 && dp[i - 1][j] != ""){
                    dp[i][j] = dp[i - 1][j];
                }
                if (j - 1 >= 0 && dp[i][j - 1] != ""){
                    if (dp[i][j - 1].size() > dp[i][j].size() ||
                        (dp[i][j - 1].size() == dp[i][j].size() && dp[i][j - 1] > dp[i][j]))
                            dp[i][j] = dp[i][j - 1];
                }
                
                if (isdigit(mp[i][j])){
                    if (dp[i][j] != "" || mp[i][j] != '0') dp[i][j] += mp[i][j];
                }
                else dp[i][j] = "";
                
                if (res.size() < dp[i][j].size() || (res.size() == dp[i][j].size() && dp[i][j] > res))
                    res = dp[i][j];
            }
        }
        
        printf("%s\n", res.c_str());
    }
    
    return (0);
}

Measured memory_bytes: 1524
fun main(args:Array<String>){
  var a = readLine()!!.split(" ")
  var num1 = a[0].toInt()
  var num2 = a[2].toInt()
  when(a[1]){
    "+" -> println(num1+num2)
    "-" -> println(num1-num2)
  }
}

Measured memory_bytes: 36080
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 出力
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                System.out.print(s.charAt(i));
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 29104
H, W = map(int, input().split())

temp = ['.'] * (W + 2)
S = [temp]

for _ in range(H):
    S.append(list('.' + input() + '.'))

S.append(temp)

output = []

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '.':
            continue
        if (S[i-1][j] + S[i+1][j] + S[i][j-1] + S[i][j+1]).count('#') == 0:
            print('No')
            exit()

print('Yes')


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, p;
  cin >> a >> p;
  int ans = (a * 3 + p) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    for(int d = 1; d <= D; d++) {
        cout << (d % 26) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
/*input
100000 1000000000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
bool isp[maxn];
vector<int> p;

ll inv(ll n){
	if(n==1) return 1;
	return (MOD-MOD/n)*inv(MOD%n)%MOD;
}

vector<ll> C;

int main()
{
	IOS;
	ll n,m;
	cin>>n>>m;

	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}

	C.pb(1);
	for(int i=1;i<50;i++){
		ll tmp=C.back()*(i+n-1)%MOD;
		tmp=tmp*inv(i)%MOD;
		C.pb(tmp);
	}
	ll ans=1;

	for(int i:p){
		int cnt=0;
		while(m%i==0){
			m/=i;
			cnt++;
		}
		ans=ans*C[cnt]%MOD;
	}
	if(m!=1){
		ans=ans*C[1]%MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 768