akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }
    let mut time = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500 * i + 100 * j + k * 50 == x {
                    time+=1;
                }
            }
        }
    }
    println!("{}", time);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			boolean lu = false;
			boolean ru = false;
			boolean lt = true;
			boolean rt = true;
			int ans = 0;
			for (int i = 0; i < N; ++i) {
				char move = sc.next().charAt(0);
				if (move == 'l') {
					lu = !lu;
				} else {
					ru = !ru;
				}
				if (lu == lt && ru == rt) {
					++ans;
					lt = !lt;
					rt = !rt;
				}
			}
			System.out.println(ans);
		}
	}

}

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

int main() {
    ll ans;
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if((X + D - 1) / D <= K) {
        ll k = K - (X + D - 1) / D;
        ans = X - ((X + D - 1) / D) * D;
        if(k % 2 == 1) {
            ans += D;
        }
    } else {
        ans = X - K * D;
    }
    ans = abs(ans);

    cout << ans << endl;
}

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc052/tasks/abc052_b

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

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

    int curr = 0;
    int ans = curr;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'I')
        {
            curr++;
        }
        else
        {
            curr--;
        }
        ans = max(ans, curr);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3652
S=input()
if S=='SUN':
    print(7)
elif S=='MON':
    print(6)
elif S=='TUE':
    print(5)
elif S=='WED':
    print(4)
elif S=='THU':
    print(3)
elif S=='FRI':
    print(2)
elif S=='SAT':
    print(1)

Measured memory_bytes: 38384
#include <stdio.h>
#define INF 100000000
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[MAX][MAX], d[MAX];

void dijkstra(){

  int i, u, v, mincost=0;
  int color[MAX], pi[MAX];
  
  for(i=0; i<n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }
  d[0] = 0;

  color[0] = GRAY;

  while(1){
    mincost = INF;
    u = -1;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(u == -1) break;

    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && M[u][v] != INF){
	if(d[v] > d[u]+M[u][v]){
	d[v] = d[u]+M[u][v];
	color[v] = GRAY;
	}
      }
    }
  }
}

int main(){

  int i, j, c, k, u, v;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = INF;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      M[u][v] = c;
    }
  }

  dijkstra();

  for(i=0; i<n; i++){
    printf("%d ", i);
    if(d[i] == INF) printf("%d\n", -1);
    else printf("%d\n", d[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007
#define PAI 3.14159265359

double f(double q, double a, double b){
  return abs(tan(q*PAI/180)-b/a);
}

int main() {
  ll a,b,x;
  cin>>a>>b>>x;
  if(1.*a*a*b/2.<=1.*x){
    double b1 = 2.*(a*a*b-x)/a/a;
    double left = 0.0;
    double right = 90.0;

    rep(i,0,300){
      double d = (right - left) / 3.0;
      double l = f(left + d,a, b1);
      double r = f(right - d,a, b1);
      if(l > r){
        left = left + d;
      }else{
        right = right - d;
      }
    }
    printf("%20.20f\n", left);
  }
  else{
    double b1 = 2.*x/a/b;
    double left = 0.0;
    double right = 90.0;

    rep(i,0,300){
      double d = (right - left) / 3.0;
      double l = f(left + d, b1, b);
      double r = f(right - d, b1, b);
      if(l > r){
        left = left + d;
      }else{
        right = right - d;
      }
    }
    printf("%20.20f\n", left);
  }
  return 0;
}

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

int findPos(int dp[], int lis, int cur) {
	int floor = 0;
	int ceiling = lis;
	while (floor <= ceiling) {
		int guessIdx = floor + (ceiling - floor) / 2;
		int guessValue = dp[guessIdx];
		if (cur == guessValue) {
			return guessIdx;
		}
		if (cur > guessValue) {
			floor = guessIdx + 1;
		} else {
			ceiling = guessIdx - 1;
		}
	}
	if (dp[floor] < cur) return floor + 1;
	return floor;
}

int getLIS(int a[], int n) {
	int dp[ARR_LEN];
	dp[0] = a[0];
	int lis = 0;
	for (int i = 1; i < n; i++) {
		int cur = a[i];
		if (cur <= dp[0]) {
			dp[0] = cur;
		} else if (cur > dp[lis]) {
			lis++;
			dp[lis] = cur;
		} else {
			int pos = findPos(dp, lis, cur);
			dp[pos] = cur;
		}
	}
	return lis + 1;
}

int main() {
	int a[ARR_LEN], n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int lis = getLIS(a, n);
	cout << lis << endl;
	return 0;
}



Measured memory_bytes: 3884
#include <stdio.h>

int main(void)
{
	double syosu, sum, syosu2;
	int a;
	
	while (scanf("%lf", &syosu) != EOF){
		sum = 0;
		a = 1;
		while (a != 11) {
			if (a == 1) {
				sum += syosu;
				syosu2 = syosu;
			}
			else if (a % 2 == 0) {
				sum += syosu2 * 2.0;
				syosu2 = syosu2 * 2.0;
			}
			else if (a % 2 == 1) {
				sum += syosu2 / 3.0;
				syosu2 = syosu2 / 3.0;
			}
			a++;
		}
		printf("%.8f\n", sum);
	}
	
	return (0);
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
  cout << "Left" << endl;
  }
  else if (A + B == C + D) {
  cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}
int main(){
  ll n;cin>>n;
  cout<<factorial(n)<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std; 
//#define endl "\n";
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
const long long int mod=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m,x,y;
	cin>>n>>m;
	vector<int>b(n,1);
	vector<bool>v(n,false);
	v[0]=true;
	for(int i=0;i<m;i++)
	{
	    ll x,y;
	    cin>>x>>y;
	    x--;y--;
	    b[x]--;
	    b[y]++;
	    if(v[x]==true)
	        v[y]=true;
	    if(b[x]==0)
	        v[x]=false;
	}
	ll ans=0;
	for(int i=0;i<v.size();i++)
	    if(v[i])
	        ans++;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3684
using System;
using System.Collections.Generic;

namespace B___TAKOYAKI_FESTIVAL_2019
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var d = new List<int> ();
            var ans = 0;
            var input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < n; i++)
            {
                d.Add (int.Parse (input[i]));
            }
            for (var i = 0; i < n; i++)
            {
                for (var j = i + 1; j < n; j++)
                {
                    ans += d[i] * d[j];
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    vector<ll>As(200020,0),Bs(200020,0);
    ll maxA=0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        As[a[i]]++;
        maxA=max(maxA,a[i]);
    }
    for(ll i=0;i<n;i++){
        cin >> b[i];
        Bs[b[i]]++;
        maxA=max(maxA,b[i]);
    }

    for(ll i=0;i<=maxA;i++){
        if(As[i]+Bs[i]>n){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    reverse(b.begin(),b.end());
    ll t=-1;
    for(ll i=0;i<n;i++){
        if(a[i]==b[i]){
            t=a[i];
            break;
        }
    }

    if(t==-1){
        for(ll i=0;i<n;i++){
            cout << b[i] << " ";
        }
        cout << endl;
        return 0;
    }

    ll ib=0;
    for(ll i=0;i<n;i++){
        if(a[i]==b[i]){
            swap(b[ib],b[i]);
            ib++;
        }
    }

    ib=n-1;
    for(ll i=0;i<n;i++){
        if(a[i]==b[i]){
            swap(b[i],b[ib]);
            ib--;
        }
    }

    for(ll i=0;i<n;i++){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

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

const ll N=3E5+7;
ll arr[N];
ll crr[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll x;
		cin>>x;
		arr[x]++;
		crr[arr[x]]++;//出现arr[x]次的元素的个数 
	}
	for(int i=1;i<=n;i++) crr[i]+=crr[i-1];
	for(int k=1;k<=n;k++){
		ll ans=0;
		ll left=0,right=n;
		while(left<=right){
			ll mid=(left+right)/2;
			if(k*mid<=crr[mid]) {
				left=mid+1;
				ans=max(ans,mid);
			}
			else{
				right=mid-1;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 5504
#include <stdio.h>
#define MAX 100

int chenge;

int check(int [],int);
void SelectionSort(int [],int);
void swap(int [],int,int);

int main(void){
  
  int i,n;
  int A[MAX];
  
  scanf("%d",&n);

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

  /*??????????????????????????????????????????????????則??????
    ?????????????????????????????????????????則????????属???
    ???????????????????????????*/
  if(check(A,n) == 1)
  SelectionSort(A,n);

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


  printf("%d\n",chenge);

  return 0;
}

//????????即???????????\??????????????????????賊???????
void SelectionSort(int A[],int n){

  int i,j;
  int mini;
  int flag;

  chenge = 0;

  for(i=0;i<n;i++){
    mini = i;
    flag=0;
    for(j=i+1;j<n;j++){
      if(A[j] < A[mini]){
        mini = j;
	flag=1;
      }   
    }
    swap(A,i,mini);

    if(flag==1)
    chenge++;   
  }
}

//??卒????????\?????????
void swap(int A[],int i,int mini){

  int tmp;

  tmp = A[i];
  A[i] = A[mini];
  A[mini] = tmp; 
}


//???????????????????????????????????????????????則??????
int check(int A[],int n){
  
  int i,j;
  int count=0;
  int check;
  
  for(i=0;i<n;i++){
    check = A[i];
    for(j=i+1;j<n;j++){
      if(check > A[j])
	count++;
    }
  }
  if(count == 0)
    return 0;

  else
    return 1;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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() {
  string s;
  cin >> s;
  ll i = 0, cnt1 = 0, cnt2 = 0, ans = 0;
  while (i < s.size()) {
    while (i < s.size() && s[i] != 'A') {
      cnt1 = 0;
      i++;
    }
    while (i < s.size() && s[i] == 'A') {
      cnt1++;
      i++;
    }
    while (i < s.size()-1 && s[i] == 'B' && s[i+1] == 'C') {
      cnt2++;
      i += 2;
    }
    ans += cnt1*cnt2;
    cnt2 = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int w,r,N; cin >> N;
    string S; cin >> S;
    int cour=0,couw;
    int ans=0;
    rep(r,N){
        if(S[r] == 'R') cour++;;
    }
    couw = N - cour;
    for(int i = 0;i<cour;i++){
        if(S[i] == 'W'){ans++;}
    }
    
    AA(ans);
    return 0;
}

Measured memory_bytes: 3764
use std::cmp;

const INF: i64 = 1e16 as i64;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a = sc.read();
    let b = sc.read();
    let q = sc.read();
    let s: Vec<i64> = sc.vec(a);
    let t: Vec<i64> = sc.vec(b);
    let x: Vec<i64> = sc.vec(q);

    let shrine = q + 1;
    let temple = q + 2;

    let mut all = vec![];
    all.extend(s.iter().map(|&s| (s, shrine)));
    all.extend(t.iter().map(|&t| (t, temple)));
    all.extend(x.iter().enumerate().map(|(i, &x)| (x, i)));
    all.sort();

    let mut prev_temple = vec![0; q];
    let mut prev_shrine = vec![0; q];
    let mut last_shrine = -INF;
    let mut last_temple = -INF;
    for &(x, i) in all.iter() {
        if i == shrine {
            last_shrine = x;
        } else if i == temple {
            last_temple = x;
        } else {
            prev_shrine[i] = last_shrine;
            prev_temple[i] = last_temple;
        }
    }

    let mut next_temple = vec![0; q];
    let mut next_shrine = vec![0; q];
    let mut last_shrine = INF;
    let mut last_temple = INF;
    for &(x, i) in all.iter().rev() {
        if i == shrine {
            last_shrine = x;
        } else if i == temple {
            last_temple = x;
        } else {
            next_shrine[i] = last_shrine;
            next_temple[i] = last_temple;
        }
    }

    for i in 0..q {
        let next_shrine = next_shrine[i] - x[i];
        let next_temple = next_temple[i] - x[i];
        let prev_shrine = x[i] - prev_shrine[i];
        let prev_temple = x[i] - prev_temple[i];

        let prev = cmp::max(prev_shrine, prev_temple);
        let next = cmp::max(next_shrine, next_temple);

        let c1 = cmp::min(prev_shrine * 2 + next_temple, prev_shrine + next_temple * 2);
        let c2 = cmp::min(next_shrine * 2 + prev_temple, next_shrine + prev_temple * 2);

        println!("{}", cmp::min(cmp::min(c1, c2), cmp::min(prev, next)));
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 17304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    ll ans = LINF;
    for(ll h=1;h<H;h++){
        ll S1 = h * W;
        //横に分ける
        ll h2 = H - h;
        ll S2 = (h2/2) * W;
        ll S3 = (h2 - (h2/2)) * W;
        if(S2 > 0 && S3 > 0) chmin(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
        //縦に分ける
        ll w = W / 2;
        S2 = h2 * w;
        S3 = h2 * (W - w);
        if(S2 > 0 && S3 > 0) chmin(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    for(ll w=1;w<W;w++){
        ll S1 = w * H;
        //縦に分ける
        ll w2 = W - w;
        ll S2 = (w2/2) * H;
        ll S3 = (w2 - (w2/2)) * H;
        if(S2 > 0 && S3 > 0) chmin(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
        //横に分ける
        ll h = H / 2;
        S2 = w2 * h;
        S3 = w2 * (H - h);
        if(S2 > 0 && S3 > 0) chmin(ans,max({S1,S2,S3}) - min({S1,S2,S3}));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

void checkStream() {
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
}

int fact(const int &num, const int &end) {
    if (!num) return 1;
    int ans {1};
    for (int i {num}; i > end; --i) {
        ans *= i;
    }
    return ans;
}

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

    int n {}, m {};
    cin >> n >> m;

    int ans {};
    if (n >= 2) {
        ans = fact(n, (n-2))/2;
    }
    if (m >= 2) {
        ans += fact(m, (m-2))/2;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
//#include <climits>
std::vector<long long> bellman_ford(long long n, long long m, std::vector<std::vector<long long>> &edge, long long start) {
	std::vector<long long> ret(n, LLONG_MAX);
	ret[start] = 0;
	for (long long i = 0; i < n - 1; i++) {
		for (long long j = 0; j < m; j++) {
			long long u = edge[j][0], v = edge[j][1], w = edge[j][2];
			if (ret[u] < LLONG_MAX) ret[v] = std::min(ret[v], ret[u] + w);
		}
	}
	for (long long i = 0; i < m; i++) {
		long long u = edge[i][0], v = edge[i][1], w = edge[i][2];
		if (ret[u] < LLONG_MAX && ret[u] + w < ret[v]) return {};
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m, p;
	cin >> n >> m >> p;
	vector<vector<vector<ll>>> v(n, vector<vector<ll>>(0));
	for (ll i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p; c *= -1;
		v[a].push_back({c, b});
	}

	vector<vector<vector<ll>>> w(n, vector<vector<ll>>(0));
	queue<ll> task;
	task.push(0);
	vector<ll> seen(n, false);
	seen[0] = true;
	while (task.size()) {
		ll x = task.front();
		task.pop();
		for (auto i : v[x]) {
			w[i[1]].push_back({i[0], x});
			if (!seen[i[1]]) {
				task.push(i[1]);
				seen[i[1]] = true;
			}
		}
	}
	vector<vector<ll>> edge(0);
	task.push(n - 1);
	vector<bool> seen2(n, false);
	seen2[n - 1] = true;
	while (task.size()) {
		ll x = task.front();
		task.pop();
		for (auto i : w[x]) {
			edge.push_back({i[1], x, i[0]});
			if (!seen2[i[1]]) {
				task.push(i[1]);
				seen2[i[1]] = true;
			}
		}
	}

	m = edge.size();
	vector<ll> x = bellman_ford(n, m, edge, 0);
	x = bellman_ford(n, m, edge, 0);
	if (x.empty()) cout << -1 << endl;
	else cout << max(0ll, -x[n - 1]) << endl;
}


Measured memory_bytes: 4668
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a,b,p,c=0,d=0,f=0;
  cin >> n >> a >> b;
  for(int i=0; i<n; i++) {
    cin >> p;
    if(p<=a) {
      c++;
    }
    else if(p>a&&p<=b) {
      d++;
    }
    else {
      f++;
    }
  }
  cout << min({c,d,f}) << endl;
}

Measured memory_bytes: 256
/// sultanov      

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()

using namespace std;
using namespace __gnu_pbds;
                                                          
template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int N = 2e2;
const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    map<int, int> red, cnt;
    red[1] = 1;
    for (int i = 1; i <= n; i++)
        cnt[i] = 1;
    int ans = 0;
    for (int x, y; q--;) {
        cin >> x >> y;
        cnt[x]--, cnt[y]++;
        if (red[x])
            red[y] = 1;
        if (!cnt[x])
            red[x] = 0;
    }
    for (int i = 1; i <= n; i++)
        ans += red[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
long long n, k, s;
vector<long long> v(1005);
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)cin >> v[i];
	sort(v.begin() + 1, v.begin() + n + 1);
	for (int i = 1; i <= k; ++i)
		s += v[i];
	cout << s;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000000
using namespace std;
const int maxn=1e6+2;
main()
{
	fastread;
	lld i,j,n,m,w;
	cin>>n>>w;
	lld dp[w+2][n+2],arr[n+2],val[n+2];
	memset(dp,0,sizeof(dp));
	for(i=1;i<=n;++i)
	{
		cin>>arr[i];
		cin>>val[i];
	}
	for(i=1;i<=w;++i)
	{
		for(j=1;j<=n;++j)
		{
			if(arr[j]<=i)
			{
				dp[i][j]=max(dp[i-arr[j]][j-1]+val[j],dp[i][j-1]);
			}
			else
			{
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	cout<<dp[w][n];
}

Measured memory_bytes: 80000
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

int main(){
	long long N;
	cin >> N;
	vector<long long> a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	long long count = 0;
	for(int i=0;i<N;i++){
		while(!(a[i] % 2)){
			a[i] /= 2;
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
typedef long long ll; typedef long double db;
const int N = 5e3 + 5, M = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  ll x, y, u, v;
  cin >> x >> y;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    ll p = x / u + (x % u > 0), q = y / v + (y % v > 0);
    p = max(p, q);
    x = p * u, y = p * v;
//cout << x << ' ' << y << '\n';
  }
  cout << x + y;
}


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

int main(){
    static int N, M, P[200000], Q[200000], C[200000];
    cin >> N >> M;

    // 頂点として存在するものを列挙
    typedef pair<int, int> Pair;
    vector<Pair> pairs;
    for(int i=0; i<N; i++) pairs.push_back({i, -1});

    for(int i=0; i<M; i++){
        cin >> P[i] >> Q[i] >> C[i];
        P[i]--; Q[i]--;
        pairs.push_back({P[i], C[i]});
        pairs.push_back({Q[i], C[i]});
    }

    // 座標圧縮の要領で頂点にインデックスを付ける
    sort(pairs.begin(), pairs.end());
    pairs.erase(unique(pairs.begin(), pairs.end()), pairs.end());
    int sz = pairs.size();
    // 逆引き
    map<Pair, int> pair2index;
    for(int i=0; i<sz; i++) pair2index[pairs[i]] = i;

    // 辺を張る
    vector<vector<Pair>> edges(sz);
    // 改札の出入り
    for(int i=0; i<sz; i++){
        if(pairs[i].second == -1) continue;
        int station = pairs[i].first;
        int out = pair2index[{station, -1}];
        edges[i].push_back({out, 0});
        edges[out].push_back({i, 1});
    }
    // 路線の移動
    for(int i=0; i<M; i++){
        int a = pair2index[{P[i], C[i]}], b = pair2index[{Q[i], C[i]}];
        edges[a].push_back({b, 0});
        edges[b].push_back({a, 0});
    }

    int start = pair2index[{0, -1}], goal = pair2index[{N-1, -1}];
    const int INF = 1e9;
    vector<int> dist(sz, INF);
    dist[start] = 0;
    // 01-BFS
    deque<int> que;
    que.push_back(start);
    while(que.size()){
        int i = que.front(); que.pop_front();
        for(auto& p : edges[i]){
            int j = p.first, c = p.second;
            if(dist[j] > dist[i] + c){
                dist[j] = dist[i] + c;
                if(c == 0){
                    que.push_front(j);
                }else{
                    que.push_back(j);
                }
            }
        }
    }

    cout << (dist[goal] == INF ? -1 : dist[goal]) << endl;
    return 0;
}

Measured memory_bytes: 69996
n=int(input())
a=list(map(int,input().split()))
p=1
s=0
t=0
if 0 in a:
    t=1
    p=0
else:
    t=0
for i in range(0,n):
    if s==0 and t==0:
        p=p*a[i]
        if p >10**18:
            s=1
            p=-1
        else:
            continue
    else:
        break
print(p)

Measured memory_bytes: 21824
#include <cstdio>
#include <algorithm>

int n, x, y, b, p;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int ans;
        scanf("%d %d %d %d", &x, &y, &b, &p);

        ans = x * b + y * p;
        if(b < 5 && p >= 2 && (int)((x * 5 + y * p) * 0.8) < ans)
        ans = (int)((x * 5 + y * p) * 0.8);
        if(b >= 5 && p < 2 && (int)((x * b + y * 2) * 0.8) < ans)
        ans = (int)((x * b + y * 2) * 0.8);
        if(b < 5  && p < 2 && (int)((x * 5 + y * 2) * 0.8) < ans)
        ans = (int)((x * 5 + y * 2) * 0.8);
        if(b >= 5 && p >= 2 && (int)((x * b + y * p) * 0.8) < ans)
        ans = (int)((x * b + y * p) * 0.8);

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


    }

    return 0;
}

Measured memory_bytes: 2736
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// greatest common divisor and least common multiple
// gcd is calculated by Euclidean Algorithm
// lcm = m * n / gcd(m,n)
template <typename T = int>
T gcd(T a, T b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template <typename T = int>
T lcm(T m, T n) {
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main() {
    ll n, x, d;
    cin >> n >> x >> d;
    if (d == 0) {
        cout << (x == 0 ? 1 : n + 1) << "\n";
        return 0;
    }
    ll g = gcd(abs(x), abs(d));
    if (d < 0)
        g *= -1;
    x /= g;
    d /= g;
    map<int, vector<pll>> imos;
    for (ll i = 0; i <= n; ++i) {
        ll l = (0 + i - 1) * (i) / 2;
        ll r = (n - 1 + n - i) * (i) / 2;
        l += x * i / d;
        r += x * i / d;
        imos[(i * x) % d].emplace_back(l, 1);
        imos[(i * x) % d].emplace_back(r + 1, -1);
    }
    ll ret = 0;
    for (auto &im : imos) {
        sort(im.second.begin(), im.second.end());
        ll prev  = -INF;
        ll depth = 0;
        for (auto &p : im.second) {
            if (depth > 0) {
                ret += p.first - prev;
            }
            prev = p.first;
            depth += p.second;
        }
    }
    cout << ret << "\n";
    return 0;
}


Measured memory_bytes: 25216
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] b = new int[9];
        for (int i = 0; i < 9; i++) {
            b[i] = sc.nextInt();
        }
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>(n);
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }
        if ((set.contains(b[0]) && set.contains(b[1]) && set.contains(b[2]))
                || (set.contains(b[3]) && set.contains(b[4]) && set.contains(b[5]))
                || (set.contains(b[6]) && set.contains(b[7]) && set.contains(b[8]))
                || (set.contains(b[0]) && set.contains(b[3]) && set.contains(b[6]))
                || (set.contains(b[1]) && set.contains(b[4]) && set.contains(b[7]))
                || (set.contains(b[2]) && set.contains(b[5]) && set.contains(b[8]))
                || (set.contains(b[0]) && set.contains(b[4]) && set.contains(b[8]))
                || (set.contains(b[2]) && set.contains(b[4]) && set.contains(b[6]))
        ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// 枝定義
struct Edge
{
	int	to;
	ll	dist;
	Edge(){}
	Edge(int to, ll dist) : to(to), dist(dist){}
};

template <class E>
using Graph = vector<vector<E>>;

// dfs
Graph<Edge>		G;
vector<int>		color;
bool dfs(int from, int fromCol)
{
	color[from] = fromCol;
	for (auto next : G[from]) {
		if (color[next.to] == 0) {
			if (!dfs(next.to, fromCol * (-1))) {
				return false;
			}
		} else if (color[next.to] == fromCol) {
			return false;
		} else {
			// すでに塗ってる
		}
	}

	return true;
}

// メイン
int main()
{
	ll N, M;
	cin >> N >> M;
	G.resize(N);
	color.resize(N, 0);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].emplace_back(Edge(b, 1));
		G[b].emplace_back(Edge(a, 1));
	}

	ll ans;
	if (dfs(0, 1)) {
		ll white = 0;
		ll block = 0;
		REP(i, N) {
			if (color[i] == 1) {
				white++;
			} else {
				block++;
			}
		}
		ans = white * block - M;
	} else {
		ans = N * (N - 1) / 2 - M;
	}

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


Measured memory_bytes: 8448
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int X = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        System.out.println((X-A)%B);

        in.close();
    }
}


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

int main() {
  int k;
  string s;
  cin >> s >> k;
  vector<string> c(k * s.length());
  for(int i = 0; i < s.length(); i++)
    for(int j = 0; j < k; j++)
      c.at(k * i + j) = s.substr(i, j + 1);
  sort(c.begin(), c.end());
  unique(c.begin(), c.end());
  cout << c.at(k - 1) << endl;
}

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

using namespace std;
#define BUF (55560)
#define ll long long 

int n;

char f[BUF];
vector<int> v;


bool isprm(int num)
{
    double sqnum = sqrt(num+1);
    for (int i = 3; i <= sqnum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){
	cin >> n;
	int cnt = 0;
	
	for(int i=11;i<BUF;i+=10){
		if(isprm(i)==true && i%5==1){
			v.push_back(i);
			cnt++;
		}
		if(cnt==n) break;
	}
	for(int i=0;i<n;i++){
		cout << v[i] << " ";  
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  int n, a[100], max = 0, min = 1000000000;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &a[i]);
    if ( max < a[i] ) max = a[i];
    if ( a[i] < min ) min = a[i];
  }

  printf("%d\n", max - min);

  return 0;
}


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

int main(){
	int n, m ,c;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>> a(n,vector<int>(m));
	rep(i,m) cin >> b[i];
	rep(i,n) rep(j,m) cin >> a[i][j];

	int res=0;
	rep(i,n){
		int tmp=c;
		rep(j,m){
			tmp+=a[i][j] * b[j];
		}
		if(tmp>0){
			res++;
		}
	}
	cout << res << endl;
	return 0;
}



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

void prians(bool answer) {
  if(answer)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}
string s;
int cnt[26] = {0};
bool ch = 1;

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i) {
    if(cnt[s[i] - 'a'] == 1) ch = 0;
    ++cnt[s[i] - 'a'];
  }
  prians(ch);
  return 0;
}

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

int main()
{
    int n,a,b,i,s,c,sum;
    cin>>n>>a>>b;

    sum=0;
    for(i=1;i<=n;i++)
    {
        c=i;
        s=0;
        while(c != 0)
        {
            s += c%10;
            c/=10;
        }
        if(s>=a && s<=b)
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split(' '))

if a > b and b > c and a > c:
    print('No')
if a > c and a > b and c > b:
    print('Yes')
elif b > a and b > c and a > c:
    print('No')
elif b > c and c > a and b > a:
    print('Yes')
elif c > a and c > b and a > b:
    print('No')
elif  c > b and c > a and b > a:
    print('No')

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;
public class Main { 
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
      	int X = reader.nextInt();
      if (X == 3 || X == 5 || X == 7) {
      	System.out.print("YES");
      } else {
      	System.out.print("NO");
      }	
    }
}

Measured memory_bytes: 25300
n,y = list(map(int,input().split()))
if y/10000 > n:
    print('-1 -1 -1')
if y/10000 ==n:
    print('%d %d %d' % (y/10000, 0, 0))
else:
    b = False
    YY =[]
    Y10=int(y/10000)
    Y5 =int(y/5000)
    Y1 =int(y/1000)
    for i in range(Y10,-1,-1):
        if b== True or i > n:
            break
        for j in range(Y5+1-2*i):
            if b == True or i+j > n:
                break
            k = n - i - j
            if i*10000+j*5000+k*1000 ==y:
                YY = [i,j,k]
                print('%d %d %d' % (YY[0], YY[1], YY[2]))
                b = True
                break
            else:
                YY=[]
        if i == 0 and b == False:
            print('-1 -1 -1')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    
    if (n==1){
        cout<<"Hello World"<<endl;
    }
    
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string a,b;
	cin>>a>>b;
	int x,y,z;
	if(a.size()>b.size()){
		cout<<"GREATER"<<endl;
	}
	else if(a.size()<b.size()){
		cout<<"LESS"<<endl;
	}
	else{
		for(int i=0;i<a.size();i++){
			y=a[i]-'0';
			z=b[i]-'0';
			x=y-z;
			//cout<<x<<endl;
			if(x>0){
				cout<<"GREATER"<<endl;
				return 0;
			}
			else if(x<0){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}
}

Measured memory_bytes: 256
T = [int(input()) for _ in range(5)]

MaxTime = 0
for t in T:
	MaxTime += ((t + 9) // 10) * 10

MaxDiffTime = 10
for t in T:
	if t % 10 != 0:
		MaxDiffTime = min(MaxDiffTime, t % 10)

print(max(0, MaxTime - (10 - MaxDiffTime)))


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main() {
    int h,w; cin >> h >> w;
    vector<vector<int>> grid(h+2, vector<int>(w+2, -1));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> grid[i][j];
        }
    }

    vector<vector<int>> res;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(h==1 && w== 1) break;
            if(grid[i][j] % 2 == 0) continue;
            vector<int> order{i, j};
            bool f_odd = false;
            rep(k, 4){
                int y = i + dy[k], x = j + dx[k];
                if(grid[y][x] != -1 && grid[y][x] % 2 == 1){
                    f_odd = true;
                    order.push_back(y); order.push_back(x);
                    grid[i][j]--; grid[y][x]++;
                    break;
                }
            }
            if(!f_odd){
                rep(k, 4){
                    int y = i + dy[k], x = j + dx[k];
                    if(grid[y][x] != -1){
                        order.push_back(y); order.push_back(x);
                        grid[i][j]--; grid[y][x]++;
                        break;
                    }
                }
            }
            res.push_back(order);
        }
    }
    cout << res.size() << ln;
    rep(i, res.size()){
        cout << res[i][0] << " " << res[i][1] << " " << res[i][2] << " " << res[i][3] << ln;
    }   
}

    

Measured memory_bytes: 9904
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double INF = 1e9;

Point READP(){
    double x,y;
    scanf(" %lf %lf", &x, &y);
    return {x,y};
}

VP READ(){
    return VP({READP(), READP()});
}

const int N = 14;
double dp[1<<N][N][2];

int main(){
    int CASE = 1;
    int n;
    while(scanf(" %d", &n),n){
        vector<VP> s(n);
        rep(i,n) s[i] = READ();

        rep(i,1<<N)rep(j,N)rep(k,2) dp[i][j][k] = INF;
        rep(i,n)rep(j,2) dp[1<<i][i][j] = 0;

        rep(mask,1<<n)rep(i,n){
            if(!(mask>>i&1)) continue;
            rep(ii,2){
                double D = dp[mask][i][ii];
                Point start = s[i][ii];

                // next
                rep(j,n){
                    if(mask>>j&1) continue;
                    rep(jj,2){
                        Point goal = s[j][jj];
                        int nmask = mask|(1<<j);
                        dp[nmask][j][!jj] = min(dp[nmask][j][!jj], D+abs(start-goal));
                    }
                }
            }
        }

        double ans = INF;
        rep(i,n)rep(j,2) ans = min(ans, dp[(1<<n)-1][i][j]);

        rep(i,n) ans += abs(s[i][0]-s[i][1]);
        printf("Case %d: %.5f\n", CASE, ans);
        ++CASE;
    }
    return 0;
}



Measured memory_bytes: 6728
#include <stdio.h>
 
int main(void)
{
	int a[3],b[3],i;
	int c[4]={};
	for (i=0;i<3;i++)	scanf("%d %d",&a[i],&b[i]);
	for (i=0;i<3;i++) {
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for (i=0;i<4;i++) {
		if (c[i]>=3) {
			printf("NO\n");
			return 0;
		}
	}	
 
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    X,Y,Z,K = LMIIS()
    A = LMIIS()
    B = LMIIS()
    C = LMIIS()
    

    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    
    AB.sort(reverse=True)

    ABC = []
    for ab in AB[:K]:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])

    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 147760
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int ll

const int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e9 + 100;
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


#define N 100000

vector <int> g[N];


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;

	

	int p = 2, k = 1;

	while (k < n)
	{
		k += p;
		p++;
	}

	if (k != n)
	{
		cout << "No";
	}
	else
	{
		int o = 1;
		cout << "Yes" << endl;
		for (int i = 1; i <= p; i++)
		{
			for (int j = i + 1; j <= p; j++)
			{
				g[i].push_back(o);
				g[j].push_back(o);
				o++;
			}
		}
		cout << p << endl;
		for (int i = 1; i <= p; i++)
		{
			cout << g[i].size() << " ";
			for (int j = 0; j < g[i].size(); j++)
				cout << g[i][j] << " ";
			cout << endl;
		}
	}

}

Measured memory_bytes: 5632
/**
*    created: 16.05.2020 08:07:58
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    ll n;
    cin>>n;
    ll ans=0;
    rep(i, sqrt(n) + 1) if (i * i <= n) ans = i*i;
    cout << ans<< endl;
}

Measured memory_bytes: 256