akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, a[100005], b[100050], c[100005];
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read(), b[i] = read(), c[i] = read();
}
void solve(){
    int aa = a[1], bb = b[1], cc = c[1];
    for (int i = 2; i <= n; ++i){
        int aaa = max(bb, cc) + a[i];
        int bbb = max(aa, cc) + b[i];
        int ccc = max(bb, aa) + c[i];
        aa = aaa, bb = bbb, cc = ccc;
    }
    printf("%d\n", max(aa, max(bb, cc)));
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1408
//هوالحق
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;

template<typename T>
T In() {
   T x;
   cin >> x;
   return x;
}

int main() {
   ios::sync_with_stdio(false), cin.tie(nullptr);
   string S = In<string>();
   bool easy = true;
   for(int i = 0; i < S.size(); i++)
      easy = easy && !(((i & 1) && S[i] == 'R') || (!(i & 1) && S[i] == 'L'));
   cout << (easy ? "Yes" : "No");
   return cout << endl, 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    c*=2;
    int ans=1000000000;
    for(int i=0;i<=100000;i++){
        ans=min(ans,c*i+a*max(0,x-i)+b*max(0,y-i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

const INF: i64 = 1e16 as i64;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();
    let k = iter.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();

    let mut dp_f: Vec<Vec<bool>> = vec![vec![false; k]; n];
    let mut dp_b: Vec<Vec<bool>> = vec![vec![false; k]; n];

    dp_f[0][0] = true;

    for i in 0..(n - 1) {
        for j in 0..k {
            if !dp_f[i][j] {
                continue;
            }

            dp_f[i + 1][j] = true;
            if j + a[i] < k {
                dp_f[i + 1][j + a[i]] = true;
            }
        }
    }

    dp_b[n - 1][0] = true;
    for _i in 0..(n - 1) {
        let i = n - 1 - _i;
        for j in 0..k {
            if !dp_b[i][j] {
                continue;
            }

            dp_b[i - 1][j] = true;
            if j + a[i] < k {
                dp_b[i - 1][j + a[i]] = true;
            }
        }
    }

    let mut res = 0;
    let mut dp_b_sum = vec![0; k + 1];
    for i in 0..n {
        if a[i] > k {
            continue;
        }

        let mut ok = false;
        for j in 0..k {
            dp_b_sum[j + 1] = dp_b[i][j] as i32 + dp_b_sum[j];
        }

        for j in 0..k {
            let min = if k - a[i] < j { 0 } else { k - a[i] - j };
            let max = k - j;

            if dp_f[i][j] && dp_b_sum[max] - dp_b_sum[min] > 0 {
                ok = true;
            }
        }
        if !ok {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 55548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vi u(n-1), v(n-1);
    rep(i,0,n-1) {
        cin >> u[i] >> v[i];
        --u[i], --v[i];
    }
    vi deg(n);
    rep(i,0,n-1) ++deg[u[i]], ++deg[v[i]];
    vector<bool> leaf(n);
    rep(i,0,n) if(deg[i]==1) leaf[i]=true;
    if(n==2) {
        cout<<"1 2\n";
    }
    else {
        vi a(n,-1), b(n,-1);
        rep(i,0,n-1) if(!leaf[u[i]] && !leaf[v[i]]) {
            if(a[u[i]]==-1) a[u[i]]=v[i];
            else b[u[i]]=v[i];
            if(a[v[i]]==-1) a[v[i]]=u[i];
            else b[v[i]]=u[i];
        }
        int start=-1;
        rep(i,0,n) if(!leaf[i] && b[i]==-1) {
            start=i;
            break;
        }
        assert(start!=-1);
        int j=start, last=-1;
        vi vs;
        while(j!=-1) {
            vs.push_back(j);
            int next=a[j];
            if(next==last) next=b[j];
            last = j;
            j = next;
        }
        vi option1;
        int nn=sz(vs);
        vector<bool> visited(n);
        rep(i,0,nn) visited[vs[i]]=true;
        bool problem=false;
        rep(i,0,n) if(!leaf[i] && !visited[i]) problem=true;
        if(problem) cout<<"-1\n";
        else {
            rep(i,0,nn) {
                int d=deg[vs[i]]-2;
                //if(i==0 || i==nn-1) --d;
                option1.push_back(d);
            }
            vi option2 = option1;
            reverse(all(option2));
            vi choice = min(option1,option2);
            vi ans;
            ans.push_back(0);
            int k=1;
            rep(i,0,nn) {
                rep(j,0,choice[i]) ans.push_back(k+j+1);
                ans.push_back(k);
                k+=1+choice[i];
            }
            ans.push_back(n-1);
            rep(i,0,n) cout<<ans[i]+1<<" ";
            cout<<"\n";
        }
    }
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll l,r; cin >> l >> r;
    if(r-l>=2019)cout << 0 << endl;
    else{
        ll res = L_INF;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                res = min(i*j % 2019,res);
            }
        }
        cout << res << endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  cout << '?';
  for (int i = 0; i < n; ++i) {
    cout << ' ' << i + 1;
  }
  cout << endl;
  string s0;
  cin >> s0;
  int l = 0, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    cout << '?';
    for (int i = m; i < m + n; ++i) {
      cout << ' ' << i + 1;
    }
    cout << endl;
    string s;
    cin >> s;
    if (s == s0) {
      l = m;
    } else {
      r = m;
    }
  }
  auto fn = [&](int i) -> char {
    cout << '?';
    for (int j = r; j < l + n; ++j) {
      cout << ' ' << j + 1;
    }
    cout << ' ' << i + 1;
    cout << endl;
    string s;
    cin >> s;
    return s[0];
  };
  string res(2 * n, '?');
  for (int i = 0; i < r; ++i) {
    res[i] = fn(i);
  }
  for (int i = l + n; i < 2 * n; ++i) {
    res[i] = fn(i);
  }
  vector<int> idx;
  int red = 0, blue = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (res[i] == 'R' and red < (n - 1) / 2) {
      idx.push_back(i);
      ++red;
    }
    if (res[i] == 'B' and blue < (n - 1) / 2) {
      idx.push_back(i);
      ++blue;
    }
  }
  for (int i = r; i < l + n; ++i) {
    cout << '?';
    for (int e : idx) {
      cout << ' ' << e + 1;
    }
    cout << ' ' << i + 1;
    cout << endl;
    string s;
    cin >> s;
    res[i] = s[0];
  }
  cout << "! " << res << endl;
}


Measured memory_bytes: 724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		long x = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		long cnt = 0;
		for (int i = 1; i < n; i++) {
			if (a[i - 1] + a[i] <= x) {
			} else {
				if (a[i - 1] <= x) {
					cnt += a[i] - (x - a[i - 1]);
					a[i] = x - a[i - 1];
				} else {
					cnt += a[i] + (a[i - 1] - x);
					a[i] = 0;
					a[i - 1] = a[i - 1] - (x - a[i]);
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 56788
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, a, ans = 1<<30;
    cin >> n;
    vector<int> A;
    for (int i = 0; i < n; i++) {
        cin >> a;
        A.push_back(a);
    }
    for (int i = -100; i <= 100; i++) {
        int cost = 0, object = i;
        for (int j = 0; j < n; j++) cost += pow(object - A[j], 2);
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ans = false;
		for(int i = 1; i < 10; i++) {
			if(n % i == 0 && n / i < 10) {
				ans = true;
				break;
			}
		}
		if(ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

using namespace std;

int const NMAX = 100;
int freq[1 + NMAX];

int main() {

  int n, m, ans = 0, isB = 0;
  string p;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> m;
    freq[m]++;
    if(freq[m] == 1){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
  	cin >> data[i];
  }
  map<int, bool> numbers;
  bool flag = false;
  for (int i = 0; i < N; i++) {
	if (numbers[data[i]] == true) {
      flag = true;
      break;
    } else {
    	numbers[data[i]] = true;
    }
  }
  string result = flag ? "NO" : "YES";
  cout << result << endl;
}


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

typedef long long ll;
const int MOD=1e9+7;

struct modint {
    int val;
    modint inv() const{
        int tmp,a=val,b=MOD,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return modint(x);
    }
public:
    modint():val(0){}
    modint(ll x){if((val=x%MOD)<0)val+=MOD;}
    modint pow(ll t){modint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    modint& operator+=(const modint& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
    modint& operator-=(const modint& x){if((val+=MOD-x.val)>=MOD)val-=MOD; return *this;}
    modint& operator*=(const modint& x){val=(ll)val*x.val%MOD; return *this;}
    modint& operator/=(const modint& x){return *this*=x.inv();}
    bool operator==(const modint& x) const{return val==x.val;}
    bool operator!=(const modint& x) const{return val!=x.val;}
    bool operator<(const modint& x) const{return val<x.val;}
    bool operator<=(const modint& x) const{return val<=x.val;}
    bool operator>(const modint& x) const{return val>x.val;}
    bool operator>=(const modint& x) const{return val>=x.val;}
    modint operator+(const modint& x) const{return modint(*this)+=x;}
    modint operator-(const modint& x) const{return modint(*this)-=x;}
    modint operator*(const modint& x) const{return modint(*this)*=x;}
    modint operator/(const modint& x) const{return modint(*this)/=x;}
};

struct factorial {
    vector<modint> Fact, Finv;
public:
    factorial(int _n): Fact(_n+1), Finv(_n+1) {
        Fact[0]=modint(1); for (int i = 0; i < _n; ++i) Fact[i+1]=Fact[i]*(i+1);
        Finv[_n]=modint(1)/Fact[_n]; for (int i = _n; i > 0; --i) Finv[i-1]=Finv[i]*i;
    }
    modint fact(int n,bool inv=0) { if (inv) return Finv[n]; else return Fact[n]; }
    modint nPr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[n-r]; }
    modint nCr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int pos[100010];
int main() {
  int n;
  cin >> n;
  int l, r;
  for (int i = 0; i < n+1; ++i) { 
    int a;
    cin >> a;
    if (pos[a] > 0) {
      l = pos[a]-1;
      r = i;
    }
    pos[a] = i+1;
  }
  // cout << l << " " << r << endl;
  factorial fact(1000010);
  int out = l+n-r;
  for (int i = 1; i <= n+1; ++i) {
    modint ans = fact.nCr(n+1,i);
    ans -= fact.nCr(out, i-1);
    cout << ans.val << endl;
  }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a  >> b >> c;
  if(a==b) cout << c << endl;
  if(b==c) cout << a << endl;
  if(c==a) cout << b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(
            a==b && a==5 && c == 7 ||
            a==c && a==5 && b == 7 ||
            c==b && c==5 && a == 7
        )
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
char a[5];
int main(){
	int i;
	for(i=1;i<=4;i++)
		cin>>a[i];
	if(a[1]=='Y'&&a[2]=='A'&&a[3]=='K'&&a[4]=='I')
		cout<<"Yes";
	else cout<<"No";
	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 ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n)cin >> a[i];
	ll sn= a[0],ar=0;
	for(int i=1;i<n;i++)
	{
		ar += a[i];
	}
	ll mi = abs(sn-ar);
	for(int i=1;i<n-1;i++)
	{
		mi = min(mi,abs(ar-sn)); 
		sn+=a[i];
		ar-=a[i];
	}
	cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 1792
var n,ans:int64;
    s,i:longint;
begin
  readln(n);
  for i:=trunc(sqrt(n)) downto 1 do
    if n mod i=0 then
    begin
      ans:=n div i;
      break;
    end;
  while ans>0 do
  begin
    inc(s);
    ans:=ans div 10;
  end;
  writeln(s);
end.

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD=1e9+7;

int main(void){
	ll n,m,x,y,sum[100010],ansx=0,ansy=0;
	scanf("%lld%lld",&n,&m);
	sum[0]=0;
	reg(i,1,n){
		scanf("%lld",&x);
		sum[i] = x+sum[i-1];
		sum[i] %= MOD;
		ansx += i*x-sum[i];
		ansx %= MOD;
	}
	sum[0]=0;
	reg(i,1,m){
		scanf("%lld",&y);
		sum[i] = y+sum[i-1];
		sum[i] %= MOD;
		ansy += i*y-sum[i];
		ansy %= MOD;
	}
	ansx*=ansy;
	ansx%=MOD;
	printf("%lld\n", ansx);
	return 0;
}

Measured memory_bytes: 1024
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()


s=input()

if(s.isupper()): print('A')
else: print('a')




Measured memory_bytes: 72880
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int>::iterator p = unique(v.begin(), v.end());
  v.resize(p - v.begin());
  for (int i = 0; i < v.size(); i++) {
    if (i)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  map<int,int>mp;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    mp[a]=i+1;
  }
  for(auto x:mp){
    cout<< x.second<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 5504
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
while 1:
    N, W, D = mapint()
    if N==0 and W==0 and D==0:
        break
    cakes = [(W, D)]
    for i in range(N):
        p, s = mapint()
        w, h = cakes.pop(p-1)
        s = s%(w+h)
        if s<w:
            piece1, piece2 = (s, h), (w-s, h)
            if s>=w-s: piece1, piece2 = piece2, piece1
            cakes.append(piece1)
            cakes.append(piece2)
        else:
            s -= w
            piece1, piece2 = (w, s), (w, h-s)
            if s>=h-s: piece1, piece2 = piece2, piece1
            cakes.append(piece1)
            cakes.append(piece2)
    cakes = sorted(list(map(lambda x: x[0]*x[1], cakes)))
    cakes = list(map(str, cakes))
    print(' '.join(cakes))


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  vector<int64> ys(n);

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

  auto solve_1_fn = [&]() -> int64 {
    vector<int64> rs;
    vector<int64> bs;
    for (int i = 0; i < n; i++) {
      if (xs[i] >= ys[i]) {
        rs.push_back(xs[i]);
        bs.push_back(ys[i]);
      } else {
        rs.push_back(ys[i]);
        bs.push_back(xs[i]);
      }
    }
    sort(rs.begin(), rs.end());
    sort(bs.begin(), bs.end());
    return (rs[n - 1] - rs[0]) * (bs[n - 1] - bs[0]);
  };

  auto solve_2_fn = [&]() -> int64 {
    vector<int64> zs;
    for (int64 x : xs) zs.push_back(x);
    for (int64 y : ys) zs.push_back(y);
    sort(zs.begin(), zs.end());
    int64 c1 = zs.back() - zs.front();

    vector<pair<int64, int64>> ps;
    for (int i = 0; i < n; i++) {
      ps.push_back(make_pair(min(xs[i], ys[i]), max(xs[i], ys[i])));
    }
    sort(ps.begin(), ps.end());
    
    set<pair<int64, int>> s;
    for (int i = 0; i < n; i++) {
      s.insert(make_pair(ps[i].first, i));
    }
    int64 c2 = s.rbegin()->first - s.begin()->first;
    for (int i = 0; i < n; i++) {
      s.erase(make_pair(ps[i].first, i));
      s.insert(make_pair(ps[i].second, i));
      UpdateMin(c2, s.rbegin()->first - s.begin()->first);
    }

    return c1 * c2;
  };

  int64 ans1 = solve_1_fn();
  int64 ans2 = solve_2_fn();
  if (DEBUG) cout << "ans1: " << ans1 << endl;
  if (DEBUG) cout << "ans2: " << ans2 << endl;
  int64 ans = min(ans1, ans2);
  cout << ans << endl;
}


Measured memory_bytes: 23980
n = int(input())
nums = list(map(int, input().split()))

for i in range(len(nums)):
    key = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > key:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = key
    print(' '.join(map(str, nums)))

Measured memory_bytes: 6724
n=int(input())
AC="AC"
WA="WA"
TLE="TLE"
RE="RE"
lst = [str(input()) for _ in range(n)]
print(f"{AC} x {lst.count(AC)}")
print(f"{WA} x {lst.count(WA)}")
print(f"{TLE} x {lst.count(TLE)}")
print(f"{RE} x {lst.count(RE)}")

Measured memory_bytes: 16100
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int N, Q;
    scan(N, Q);
    auto adj = new int[][](N, 0);
    foreach (i ; 0 .. N - 1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    int idx;
    auto lm = new int[](N);
    auto rm = new int[](N);

    void dfs(int v, int p) {
        lm[v] = idx++;
        foreach (u ; adj[v]) if (u != p) {
            dfs(u, v);
            idx++;
        }
        rm[v] = idx;
    }

    dfs(0, -1);

    auto wa = new long[](2*N);

    foreach (i ; 0 .. Q) {
        int pi, xi;
        scan(pi, xi);
        pi--;
        wa[lm[pi]] += xi;
        wa[rm[pi]] -= xi;
    }

    foreach (i ; 0 .. 2*N - 1) {
        wa[i + 1] += wa[i];
    }

    auto ans = iota(N).map!(i => wa[lm[i]]).array;

    writefln("%(%s %)", ans);
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 38396
#include <bits/stdc++.h>
#define in(n, arr) for (int i = 0; i < n; ++i) cin >> arr[i]
#define out(n, arr) for (int i = 0; i < n; ++i) cout << arr[i] << " "
 
using namespace std;
long long int solve(long long int** dp, long long int* arr, long long int l, long long int r)
{
	if(l > r)
		return  0;
	if(l == r)
		return arr[l];
	if(dp[l][r]!=-1)
		return dp[l][r];
	long long int ans = arr[l] - solve(dp,arr,l+1,r);
	ans = max(ans,arr[r]-solve(dp,arr,l,r-1));
	dp[l][r] = ans;
	return ans;

}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
	#endif
	int t;
	cin >> t;
	long long int* arr = new long long int[t]();
	for(int  i =0; i<t; i++)
		cin >> arr[i];
	long long int** dp = new long long int*[t];
	for(int  i = 0; i<t; i++)
		dp[i] = new long long int[t];
	for(int i =0; i<t; i++)
	{
		for(int  j = 0; j<t; j++)
			dp[i][j] = -1;
	}
	cout << solve(dp, arr, 0, t-1);


return 0;
}

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

template <class T, class U>
inline bool chmax(T& t, const U& f) { return t < f ? t = f, true : false; }

int main() {
    double d; cin >> d;
    double maxi = d * sqrt(2.0);
    for (int x = 1; x <= d; ++x) {
        double y = sqrt(d * d - x * x);
        if (y <= 1.0) chmax(maxi, x + 1.0);
    }
    cout << fixed << setprecision(12) << maxi << endl;
}

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

const int MAX_N = 110000;

// 入力
int N, W;

// DPテーブル
int dp[MAX_N] = {0};

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

    for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF の気持ち

    dp[0] = 0;

    // 貰う DP --- dp[n] に遷移を集める
    for (int n = 1; n <= N; n++) {
        for(int i = 0; i < W; i++){

            if(n - value[i] >= 0) dp[n] = min(dp[n], dp[n - value[i]] + 1);

        }
    }


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


Measured memory_bytes: 3536
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int main()
{
	int n; cin >> n;
	vector<ll> sum(n + 1, 0);
	rep(i, n)
	{
		ll a; cin >> a;
		sum[i + 1] = sum[i] + a;
	}
	ll res = 1e18;
	for (int i = 2; i < n - 1; ++i)
	{
		ll p, q, r, s;
		auto it = upper_bound(all(sum), sum[i] / 2);
		p = *it;
		--it;
		if (it != sum.begin() && sum[i] / 2 - *it < p - sum[i] / 2)
		{
			p = *it;
			q = sum[i] - *it;
		}
		else
		{
			++it;
			q = sum[i] - *it;
		}
		it = upper_bound(all(sum), (sum[n] - sum[i]) / 2 + sum[i]);
		if (it == sum.end())
		{
			--it;
			r = *it - sum[i];
			s = sum[n] - r - sum[i];
		}
		else
		{
			r = *it - sum[i];
			--it;
			if ((sum[n] - sum[i]) / 2 - (*it - sum[i]) < r - (sum[n] - sum[i]) / 2)
			{
				r = *it - sum[i];
				s = sum[n] - r - sum[i];
			}
			else
			{
				s = sum[n] - r - sum[i];
			}
			/*cout << "p:" << p << endl;
			cout << "q:" << q << endl;
			cout << "r:" << r << endl;
			cout << "s:" << s << endl;*/
		}
		ll tmp = max({ p,q,r,s }) - min({ p,q,r,s });
		res = min(res, tmp);
	}
	cout << res << endl;
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 73
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];

ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

int n, m, k;

ll a[e];

int main()
{
   cin >> n >> m >> k;
   vector<vector<ll>>adj(n+1, vector<ll>(n+1, 1e18));
   for(int i=1; i<=k; i++)
   {
       cin >> a[i];
   }
   for(int i=1; i<=m; i++)
   {
       ll u, v, w;
       cin >> u >> v >> w;
       adj[u][v] = min(adj[u][v], w);
       adj[v][u] = min(adj[v][u], w);
   }
   for(int z=1; z<=n; z++)
   {
       for(int i=1; i<=n; i++)
       {
           for(int j=1; j<=n; j++)
           {
               if(adj[i][j] > adj[i][z] + adj[z][j])
               {
                   adj[i][j] = adj[i][z] + adj[z][j];
               }
           }
       }
   }
   ll ans = 1e18;
   ll curr = 0;
   sort(a+1, a+k+1);
   for(int i=1; i<k; i++)
   {
       curr += adj[a[i]][a[i+1]];
   }
   ans = min(ans, curr);
   while(next_permutation(a+1, a+k+1))
   {
       ll cur = 0;
       for(int i=1; i<k; i++)
       {
           //cout << a[i] << " ";
           cur += adj[a[i]][a[i+1]];
       }
       //cout << endl;
       ans = min(ans, cur);
   }
   cout << ans;
}
/*

*/


Measured memory_bytes: 512
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  if(a == b) printf("%d\n", c);
  else if(a == c) printf("%d\n", b);
  else printf("%d\n", a);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
lis = list(map(int,input().split()))
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    global ans
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1
            ans += (len(left) - l_i)

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

ans = 0
merge_sort(lis)
print(ans)



Measured memory_bytes: 27480
/*input
1
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll x; cin >> x;
	cout << (x * 360 / __gcd(x, (ll)360)) / x << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

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


int main() {
	int n, m;
	cin >> n >> m;
	if (n == 0 & m == 0) {
		cout << 0;
	}
	else if (n == 0) {
		cout << m * (m - 1) / 2;
	}
	else if (m == 0) {
		cout << n * (n - 1) / 2;
	}
	else {
		cout << n * (n - 1) / 2 + m * (m - 1) / 2;
	}


	return 0;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<int> a;
    vector<int> b;
    vector<int> c;

    rep(i,n){
        int tmpa,tmpb,tmpc;
        cin >> tmpa >> tmpb >> tmpc;

        a.pback(tmpa);
        b.pback(tmpb);
        c.pback(tmpc);
    }

    vector<vector<pair<int,int>>> dp(n + 1, vector<pair<int,int>>(8001, mpair(0,INT_MAX / 2)));

    dp[0][4000] = mpair(0,0);

    rep(i,n){
        rep(j, 8001){
            if(dp[i][j].second != INT_MAX / 2){

                //使わなかった場合
                
                //すでになにか購入している場合、0個の情報で塗り替えてはならない
                if(dp[i + 1][j].first != 0){
                    if(dp[i][j].first != 0){
                        if(dp[i + 1][j].second > dp[i][j].second){
                            dp[i + 1][j] = dp[i][j];
                        }
                    }
                }else{
                    dp[i + 1][j] = dp[i][j];
                }

                //つかう場合
                int d = a[i] * mb - b[i] * ma;

                if(dp[i + 1][j + d].first == 0){
                    dp[i + 1][j + d] = mpair(1, dp[i][j].second + c[i]);
                }else{
                    if(dp[i + 1][j + d].second > dp[i][j].second + c[i]){
                        dp[i + 1][j + d] = mpair(1, dp[i][j].second + c[i]);
                    }
                }

                if(j == 4000){
                    if(dp[i + 1][j + d].first == 0){
                        dp[i + 1][j + d] = mpair(1, dp[i][j].second + c[i]);
                    }else{
                        if(dp[i + 1][j + d].second >  c[i]){
                            dp[i + 1][j + d] = mpair(1, c[i]);
                        }
                    }
                }
            }
        }
    }

    if(dp[n][4000].first != 0){
        cout << dp[n][4000].second << endl;
    }else{
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 2816
# coding: utf-8

N = int(input())
D = []
for i in range(N):
    s, p = map(str,input().split())
    p = int(p)
    shop = [s, p, i+1]
    D.append(shop)

D.sort(key=lambda x:x[0])
#print(D[0])
#print(D[1])
T_ = [D[0]]
flg = True
A = []
for i in range(N-1):
    #print(T_)
    if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge')

if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_
#print(A)
for l in A:
    print(l[2])

Measured memory_bytes: 8960
#include<iostream>
using namespace std;
int main(){
	int n,a[110],i,x=-1,y=1001;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>x)
			x=a[i];
		if(a[i]<y)
			y=a[i];
	}

	cout << x-y << endl;
}


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

ll GCD (ll x, ll y){
  ll a = max(x,y);
  ll b = min(x,y);
  if(a%b == 0) return b;
  return GCD(b,a%b);
}

int main(){
  ll n,x;
  cin >> n >> x;
  ll xi[n];
  for(ll i=0;i<n;i++){
    cin >> xi[i];
    xi[i] = abs(x-xi[i]);
  }
  if(n == 1){
    cout << xi[0] << endl;
    return 0;
  }
  ll ans;
  ans = GCD(xi[0],xi[1]);
  for(int i=1; i<n; i++){
    ans = GCD(xi[i],ans);
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
   
    int i,a,b,num;
    char op;
    while(1) {
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
            printf("%d\n",a+b);
        }
        else if(op == '-'){
            printf("%d\n",a-b);
        }
        else if(op == '*'){
            printf("%d\n",a*b);
        }
        else if(op == '/'){
            printf("%d\n",a/b);
        }
        else if(op == '?') {
            break;
        }
    }
    return 0;
    
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1000000010;

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

    vector<vector<int>> f(n, vector<int>(10));
    rep(i, n) {
        rep(j, 10) {
            cin >> f[i][j];
        }
    }

    vector<vector<int>> p(n, vector<int>(11));
    rep(i, n) {
        rep(j, 11) {
            cin >> p[i][j];
        }
    }

    int ans = -INF;
    for(int b = 1; b < (1 << 10); b++) {

        int now = 0;
        rep(i, n) {
            int c_i = 0;
            rep(j, 10) {
                if( (b & (1 << j)) && f[i][j] ) {
                    c_i++;
                }
            }
            now += p[i][c_i];
        }

        ans = max(ans, now);
    }

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

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

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

const ll MOD = 1e9+7;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for(int64_t i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n] = 1;
	return ret;
}

int main(int argc, char **argv)
{
	ll N;
	cin >> N;
	map<ll, ll> m = prime_factor(N);

	ll res{0};
	for (auto &p : m)
	{
		ll cnt = p.second;
		ll d{1};
		while (cnt >= d)
		{
			++res;
			cnt -= d;
			++d;
		}
	}

	std::cout << res << std::endl;
}


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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"

using namespace std;

int main()
{
	
	std::ios_base::sync_with_stdio(false);

	ll a,b;
	cin>>a>>b;
	if(a>=0&&b>=0&&a<=9&&b<=9)
	{
		
			cout<<a*b;
	}
	else
		cout<<-1;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdio>	
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef pair<int, int> P;
char tile[25][25];

int main()
{
	const int dir[][2] = { {-1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };
	int w, h;
	while (scanf ("%d %d", &w, &h ) && w && h ){
		P s = P (-1, -1 );
		rep (i, h ){
			rep (j, w ){
				scanf (" %c", tile[i]+j );
				if (tile[i][j] == '@' ){
					s.first = i, s.second = j;
				} // end if
			} // end rep
		} // end rep
		queue<P> que;
		que.push (s );
		while (!que.empty() ){
			P curr = que.front(); que.pop();
			int row = curr.first;
			int col = curr.second;
			rep (k, 4 ){
				int nr = row + dir[k][0];
				int nc = col + dir[k][1];
				if (nr < 0 || nc < 0 || nr >= h || nc >= w || tile[nr][nc] == '#' || tile[nr][nc] == '@' ) continue;
				que.push (P (nr, nc ) );
				tile[nr][nc] = '@';
			} // end rep
		} // end while
		int res = 0;
		rep (i, h ){
			rep (j, w ){
				if (tile[i][j] == '@' ) res++;
			} // end rep
		} // end rep
		printf ("%d\n", res );
	} // end while

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>

using namespace std;
typedef long long int ll;

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 main(){
    int a,b;    cin >> a >> b;
    if(a>9 || b>9){
        cout << "-1" << endl;
        return 0;
    }
    cout << a*b << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N, A, B; cin >> N >> A >> B;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	ll ans = 0;
	F0R(i, N-1) {
		ans += min(1LL * B, 1LL * A * (arr[i+1] - arr[i]));
	}
	print(ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {


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

		int a=sc.nextInt();
		String s=sc.next();
		if(a>=3200) {
		System.out.println(s);
		}else {
			System.out.println("red");
		}
	}

}


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

signed main() {
  string S; cin >> S;
  string A = "abcdefghijklmnopqrstuvwxyz";

  
  vector<bool> al(26, false);
  for(char s : S) al[s-'a'] = true;
  
  if(S.size() == 26) {
    int i = S.size()-1;
    while(S[i-1] > S[i]) {
      if(i == 1) {
        cout << -1 << endl;
        return 0;
      }
      al[S[i]-'a'] = false;
      i--;
    }
    al[S[i]-'a'] = false;
    while(al[S[i-1]-'a']) S[i-1]++;
    S.erase(i);
    cout << S << endl;
    return 0;
  }
  
  int i = 0;
  while(al[i]) i++;
  S += A[i];
  cout << S << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using namespace std;

int main(){
    int n; cin >> n;
    vector<pair<ll,int>> a(n), b(n);
    ll ma = 0, mi = 1001001001;
    rep(i,n){
        ll x, y; cin >> x >> y; if(x > y) swap(x,y); // x <= y にする
        a[i] = make_pair(x,i);
        b[i] = make_pair(y,i);
        chmax(ma,y); chmin(mi,x);
    }

    ll s1 = 0, s2 = 1001001001;
    rep(i,n){
        chmax(s1, a[i].first); chmin(s2, b[i].first);
    }
    ll ans = (s1 - mi) * (ma - s2);

    sort(all(a));
    s1 = 0; s2 = n-1;
    chmin(ans, (ma - mi) * (a[s2].first - a[s1].first));
    rep(i,n){
        a[i] = b[a[i].second];
        if(a[i].first > a[s2].first) s2 = i;
        if(a[i].first < a[s1].first) s1 = i;
        if(i < n-1 && a[i+1].first < a[s1].first) chmin(ans, (ma - mi) * (a[s2].first - a[i+1].first));
        else chmin(ans, (ma - mi) * (a[s2].first - a[s1].first));
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int x, y, a, b , c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> av(a);
    vector<ll> bv(b);
    vector<ll> cv(c);

    priority_queue<ll, vector<ll>, greater<ll>> aq;
    priority_queue<ll, vector<ll>, greater<ll>> bq;
    int acount = 0;
    int bcount = 0;

    ll asum = 0;
    ll bsum = 0;

    rep(i, a){
        cin >> av[i];

        if(acount < x){
            aq.push(av[i]);
            asum += av[i];
            acount++;
        }else{
            aq.push(av[i]);
            asum += av[i];

            asum -= aq.top();
            aq.pop();
        }

    }

    cerr << asum << endl;

    rep(i, b){
        cin >> bv[i];

        if(bcount < y){
            bq.push(bv[i]);
            bsum += bv[i];
            bcount++;
        }else{
            bq.push(bv[i]);
            bsum += bv[i];

            bsum -= bq.top();
            bq.pop();
        }
    }

    cerr << bsum << endl;

    rep(i, c){
        cin >> cv[i];

        ll atop = aq.top();
        ll btop = bq.top();

        if(atop < btop){
            aq.push(cv[i]);
            asum += cv[i];

            asum -= aq.top();
            aq.pop();
        }else{
            bq.push(cv[i]);
            bsum += cv[i];

            bsum -= bq.top();
            bq.pop();
        }
    }

    cout << asum + bsum << endl;


    return 0;
}


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

int main(){
    int n; scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        int a; scanf("%d", &a);
        if (i & 1 && a & 1) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3752
# -*- coding: utf-8 -*-
from sys import stdin
import math

def is_prime_number(n):
  if n == 1:
    return False
  if n == 2:
    return True
  i = 2
  while i <= math.sqrt(n):
    if n % i == 0:
      return False
    i += 1
  else:
    return True

n = int(stdin.readline().rstrip())
cnt = 0

for i in range(n):
  v = int(stdin.readline().rstrip())
  if is_prime_number(v):
    cnt += 1
else:
  print(cnt)


Measured memory_bytes: 5680