akhauriyash/Code-Regression huggingface dataset:
n, a, b, c = map(int, input().split())
ls = []
for _ in range(n):
    ls.append(input())

abc = {'A': a, 'B': b, 'C': c}

def answer():
    solution = []
    if a + b + c == 0:
        return False, None
    elif a + b + c == 1:
        for s in ls:
            s0, s1 = s[0], s[1]
            if abc[s0] == 1:
                abc[s0] -= 1
                abc[s1] += 1
                solution.append(s1)
            elif abc[s1] == 1:
                abc[s0] += 1
                abc[s1] -= 1
                solution.append(s0)
            else:
                return False, None
        return True, solution
    else:
        for i, s in enumerate(ls):
            s0, s1 = s[0], s[1]
            if abc[s0] == 0 and abc[s1] == 0:
                return False, None
            elif i == n - 1:
                if abc[s0] == 0:
                    abc[s0] += 1
                    abc[s1] -= 1
                    solution.append(s0)
                else:
                    abc[s0] -= 1
                    abc[s1] += 1
                    solution.append(s1)
            elif abc[s0] == 0:
                abc[s0] += 1
                abc[s1] -= 1
                solution.append(s0)
            elif abc[s1] == 0:
                abc[s0] -= 1
                abc[s1] += 1
                solution.append(s1)
            elif abc[s0] == 1 and (s0 in ls[i + 1]):
                abc[s0] += 1
                abc[s1] -= 1
                solution.append(s0)
            else:
                abc[s0] -= 1
                abc[s1] += 1
                solution.append(s1)
        return True, solution


yn, solution = answer()
if yn:
    print('Yes')
    for s in solution:
        print(s)
else:
    print('No')



Measured memory_bytes: 17120
#include <stdio.h>
#include <math.h>
int main(void) {
	int a,b,c,d,e;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	int t;
	if(a<0){
	    a=abs(a);
		t=a*c+d+(e*b);
		printf("%d\n",t);
	}
	else{
		t=(e*(b-a));
		printf("%d\n",t);
	}	
	return 0;
}


Measured memory_bytes: 2064
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut start = HashSet::new();
    let mut goal = HashSet::new();
    for _ in 0..m {
        let tmp = get!(usize, usize);
        if tmp.1 == n {
            goal.insert(tmp.0);
        }
        if tmp.0 == 1 {
            start.insert(tmp.1);
        }
    }
    if goal.is_empty() || start.is_empty() {
        println!("IMPOSSIBLE");
        return;
    }
    for _ in start.intersection(&goal) {
        println!("POSSIBLE");
        return;
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 11208
#include<iostream>

using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, 0, n);

    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 6984
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    ll x;
    ll s=0,t=0;
    cin>>x;
    for(ll a=0; a<=300; ++a){
        for(ll b=-300; b<=300; ++b){
            if(a<=b) continue;
            if(x%(a-b)==0){
                ll y=x/(a-b);
                if(y==(a*a*a*a+ a*a*a*b+ a*a*b*b+ a*b*b*b+ b*b*b*b)){
                    s=a; t=b;
                    break;
                }
            }
        }
    }
    cout<<s<<" "<<t<<endl;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

multiset<int> s;
vi ans, a;
vector<bool> vis;
vector<vi> adjList;

void dfs(int i)
{
    if(vis[i])
        return;
    vis[i] = true;
    // LIS
    s.insert(a[i]);
    auto it = s.lower_bound(a[i]);
    int del = -1;
    if(++it != s.end()){
        del = *it;
        s.erase(it);
    }
    // Final answer
    ans[i] = s.size();

    for(auto j: adjList[i]){
        dfs(j);
    }
    // Backtrack
    if(del != -1)
        s.insert(del);
    s.erase(s.find(a[i]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n;
    cin >> n;
    a.resize(n + 1);
    REP(i, 1, n + 1){
        cin >> a[i];
    }
    adjList.resize(n + 1);
    REP(i, 0, n - 1){
        int u, v;
        cin >> u >> v;
        adjList[u].PB(v);
        adjList[v].PB(u);
    }
    ans.resize(n + 1);
    vis.resize(n + 1);
    dfs(1);
    REP(i, 1, n + 1){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
	int n, t[100], m, p[100], x[100];
	cin >> n;
	int res = 0;
	for (int i = 0;i < n;i++) {
		cin >> t[i];
		res += t[i];
	}
	cin >> m;
	for (int i = 0;i < m;i++)cin >> p[i] >> x[i];
	int max = 0;
	for (int i = 0;i < m;i++) {
		cout << res - (t[p[i]-1] - x[i]) << endl;
	}
}

Measured memory_bytes: 256
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(deftype int32 () '(signed-byte 32))

(defun main ()
  (let* ((n (read))
         (k (read))
         (a (make-array n :element-type 'int32))
         (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
    (let ((stream (make-string-input-stream (read-line))))
      (loop for i from 0
         for j = (read stream nil) until (null j)
         do (setf (aref a i) j)))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (loop with from-val of-type int32 = (aref dp i)
         for j of-type int32 from (1+ i) to (+ i k)
         while (< j n)
         do
           (let ((nval (+ from-val (abs (- (aref a i) (aref a j))))))
             (setf (aref dp j) (min (aref dp j) nval)))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


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

int main(){
  string S ;
  cin >> S;
  int N = S.size();
  int ans = 0;
  
  for(int i = 0; i < N; i++){
    if(S[i] == '1'){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n,cur = 0;
  cin >> n;
  vector<int64_t> v(n);
  for(int i = 0;i < n;i++)cin >> v[i];
  vector<int64_t> res(n,0);
  for(int i = 0;i < n;i++){
      if(!(i & 1))res[0] += v[i];
      else res[0] -= v[i];
  }
  res[1] += v[0];
  for(int i = 1;i < n;i++){
    if(i & 1)res[1] += v[i];
    else res[1] -= v[i];
  }
  for(int i = 2;i < n;i++){
    res[i] += res[i-2];
    res[i] += 2*v[i-1];
    res[i] -= 2*v[i-2];
  }
  for(auto au : res){
    cout << au << " ";
  }
  return 0;
}

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

const long double pi = 3.141592653589L;

int main()
{
    int n;
    while(cin >> n, n != -1){
        complex<long double> p(1.0L);
        for(int i = 0; i < n-1; ++i){
            p = p + polar(1.0L,arg(p) + pi / 2);
        }

        cout << p.real() << endl << p.imag() << endl;
    }
}

Measured memory_bytes: 1248
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine()

    out.println(
      if (n.contains('7')) {
        "Yes"
      } else {
        "No"
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 54504
#include<iostream>
int main(){
	int i, s;
	char d[1001];
	while (i = 0, s = 0,std::cin >> d){
		while (d[i] - '\0'){
			s += d[i] - '0';
			++i;
		}
		if (s == 0)break;
		std::cout << s << std::endl;
	}
}

Measured memory_bytes: 1140
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    dic = dict()

    for i in range(n - 1):
        if a_lst[i] in dic:
            dic[a_lst[i]] += 1
        else:
            dic[a_lst[i]] = 1

    dic_keys = dic.keys()
    for i in range(1, n + 1):
        if i in dic_keys:
            print(dic[i])
        else:
            print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 119156
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int k;cin>>k;
  int hoge[32]={ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<hoge[k-1]<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

vector<int> edge[10];

int main() {
	
	int n, m, ans = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].pb(b); edge[b].pb(a);
	}

	int pm[10];
	for (int i = 0; i < n; i++)pm[i] = i;

	bool flag[10];
	do {
		if (pm[0] != 0)continue;
			for (int i = 0; i < n; i++) flag[i] = false;
			flag[0] = true;
			for (int i = 0; i < n-1; i++) {
				for (vector<int>::iterator it = edge[pm[i]].begin(); it != edge[pm[i]].end(); it++) {
					if (*it == pm[i + 1] && !flag[pm[i+1]]) {
						flag[pm[i + 1]] = true;
					}
				}
			}
			for (int i = 0; i < n; i++) {
				if (!flag[i]) break;
				if (i == n - 1) ans++;
			}
		
	} while (next_permutation(pm, pm + n));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int A, B, C;
    cin >> A >> B >> C;
    if((A <= C and C <= B) or (B <= C and C <= A)) cout << "Yes" << endl;
    else cout << "No" << endl;


}


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

int main(){
  int N;
  cin >> N;
  int s;
  int ma;
  int sum=0;
  for(int i=1;i<=N;i++){
    sum+=i;
    if(N-sum<i+1){
      int diff=N-sum;
      s=i-diff+1;
      ma=i+1;
      break;
    }
  }
  for(int i=1;i<=ma;i++){
    if(i==s){
      continue;
    }
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int s[105];
int main()
{
    int a,b,k; cin>>a>>b>>k;
    int len=0;
    for(int i=1;i<=min(a,b);i++){
		if(a%i==0&&b%i==0){
			s[len++]=i;
		}
    }
    reverse(s,s+len);
    cout<<s[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, pii>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 100;
int a[N];
pii cnt1[N], cnt2[N];
bool cmp(pii a, pii b) {
    return a.fi > b.fi;
}
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i < N; i++) cnt1[i].se = cnt2[i].se = i, cnt1[i].fi = cnt2[i].fi = 0;
    for (int i = 1; i <= n; i++) {
        if(i&1) cnt1[a[i]].fi++;
        else cnt2[a[i]].fi++;
    }
    sort(cnt1+1, cnt1+N, cmp);
    sort(cnt2+1, cnt2+N, cmp);
    int ans;
    if(cnt1[1].se == cnt2[1].se) {
        ans = n - max(cnt1[1].fi+cnt2[2].fi, cnt1[2].fi+cnt2[1].fi);
    }
    else ans = n - cnt1[1].fi - cnt2[1].fi;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2176
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		//int N = sc.ni();
		String S = sc.next();
		String[] alpha = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

		for(int i = 0;i<alpha.length;i++){
			if(S.equals(alpha[i])){
				pw.print(alpha[i+1]);
			}
		}
		pw.close();
	}

	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) {
		long ans = 1;
		x %= m;
		while (y > 0) {
			if(y % 2 == 1)
				ans = (ans * x) % m;
			y /= 2;
			x = (x * x) % m;
		}
		return ans;
	}

    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[1]-arr2[1]; //ascending order
	          }
		});
		return array;
	}

    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

        double nd() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
 
using namespace std;
int n, m, k, l, dp[3002][3002], tab[150], tab2[105];
long double xd[100000],xd3[100000],xd2[100000],xd1[100000];
string slowo1, slowo2;
char a[3002], b[3002];
vector<char> wektor;
int main()
{
    ios_base::sync_with_stdio(false);
        cin>>slowo1>>slowo2;
        n=slowo1.size();
        m=slowo2.size();
        for(int i=1; i<=n; i++){
            a[i]=slowo1[i-1];
            dp[i][0]=0;
            tab[int(slowo1[i-1]-'a')]++;
        }
        for(int i=1; i<=m; i++){
            b[i]=slowo2[i-1];
            dp[0][i]=0;
            tab2[int(slowo2[i-1]-'a')]++;
        }
 
 
        for(int i=1; i<=n; i++){
            for(int j=1; j<=m; j++){
                if(a[i]==b[j]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
 
 
 
        while((n>0)||(m>0)){
            if((dp[n][m]==dp[n-1][m])&&(dp[n-1][m]>0)){
 
            n--;
            }else  if((dp[n][m]==dp[n][m-1])&&(dp[n][m-1]>0)){
 
            m--;
            }else if((dp[n][m]-1==dp[n-1][m-1])&&(dp[n-1][m-1]>0)){
                wektor.push_back(a[n]);
                n--;
                m--;
            }else{
            break;
            }
        }
        //cout<<a[m]<<" "<<b[m]<<'\n';
 
        if(wektor.size()==0){
          for(int i=0; i<26; i++){
            //cout<<tab[i]<<" "<<tab2[i]<<'\n';
            if((tab[i]>0)&&(tab2[i]>0)){
              cout<<char(i+'a');
              break;
            }
          }
        //else{
          //cout<<" ";
        //}
        }else{
          cout<<b[m];
          for(int i=wektor.size()-1; i>=0; i--){
            cout<<wektor[i];
        }
      }
    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100];
const int maxn =1e5+10;
int a[maxn],b[maxn];
int main(){
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        int x,y;
        for(int i=0;i<m;i++){
            scanf("%d%d",&x,&y);
            b[x] = max(b[x],a[y]);
            b[y] = max(b[y],a[x]);
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(a[i]>b[i]){
                ans+=1;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, tmp;
    cin >> N;
    int cnt[N + 1];
    for(int i = 0; i < N + 1; i++)
    {
        cnt[i] = 0;
    }
    for(int i = 1; i < N + 1; i++)
    {
        tmp = i;
        while(tmp % 2 == 0)
        {
            cnt[i]++;
            tmp /= 2;
        }
    }
    int max = 0;
    tmp = 0;
    for(int i = 0; i < N + 1; i++)
    {
        if(tmp <= cnt[i])
        {
            tmp = cnt[i];
            max = i;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m,x;
	ll ans=INFLL;
	cin >>n>>m>>x;
	VVi data(n,Vi(m,0));
	Vi yen(n);
	rep(i,n){
		cin>>yen[i];
		rep(j,m){
			cin>>data[i][j];
		}
	}
	Vi now(m,0);
	ll nowy=0LL;
	bool can=true;
	rep(bit,1<<n){
		can=true;
		nowy=0LL;
		rep(i,m){
			now[i]=0;
		}
		rep(i,n){
			if(bit&1<<i ){
				nowy += yen[i];
				rep(j,m){
					now[j]+=data[i][j];
				}
			}
		}
		rep(j,m){
			
			if(now[j] <x){
				can=false;
			}
		}
		if(can){
			chmin(ans,nowy);
		}
	}
	if(ans!=INFLL){
	cout<<ans<<endl;}else{
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

const int LIM = 1.5e3 + 5;

struct data { int x, d; };
bool operator < (data a, data b) { return a.d > b.d; }

int n, m, dis[LIM][LIM], max, ans;
std::vector<data> edg[LIM];
bool chk[LIM], vis[LIM];
std::priority_queue<data> q;

void dijkstra(int s, int *dis)
{
	q.push({s, 0});
	while (!q.empty())
	{
		data x = q.top(); q.pop();
		if (!vis[x.x])
		{
			vis[x.x] = true;
			dis[x.x] = x.d;
			for (data y : edg[x.x])
				if (!vis[y.x])
					q.push({y.x, x.d + y.d});
		}
	}
}

void trace(int x, int *dis)
{
	vis[x] = true;
	if (!chk[x]) { --ans; chk[x] = true; }
	for (data y : edg[x])
		if (!vis[y.x] && dis[y.x] == dis[x] - y.d)
			trace(y.x, dis);
}

int main()
{
	scanf("%d%d", &n, &m);
	while (m--)
	{
		int u, v, d; scanf("%d%d%d", &u, &v, &d);
		edg[u].push_back({v, d});
		edg[v].push_back({u, d});
	}
	
	for (int i = 1; i <= n; ++i)
	{
		memset(vis, 0x00, sizeof(vis));
		dijkstra(i, dis[i]);
		for (int j = 1; j <= n; ++j)
			max = std::max(max, dis[i][j]);
	}
	
	for (int i = 1; i <= n; ++i)
	{
		memset(vis, 0x00, sizeof(vis));
		for (int j = 1; j <= n; ++j)
			if (dis[i][j] == max)
				trace(j, dis[i]);
	}
	
	printf("%d\n", ans + n);
	for (int i = 1; i <= n; ++i)
		if (!chk[i]) printf("%d\n", i);
}


Measured memory_bytes: 11680
import sys


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r))
                         for r in self.roots())


input = sys.stdin.buffer.readline
N, M = map(int, input().split())

uf = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A - 1, B - 1
    uf.union(A, B)

# print(uf)

ans = 0
for i in uf.roots():
    ans = max(ans, uf.size(i))
print(ans)


Measured memory_bytes: 18440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  if(n <= 2){
    cout << 0 << endl;
    return 0;
  }
  sort(a.begin(),a.end());
  ll res = 0;
  for(int i = 0;i < n - 2;i++){
    for(int j = i + 1;j < n - 1;j++){
      for(int k = j + 1;k < n;k++){
        if(a[i] != a[j] && a[j] != a[k]){
          if(a[i] + a[j] > a[k])res++;
        }
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3628
N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [0 for i in range(N)]
for i in range(1, N):
  buf = dp[i-1] + abs(A[i]-A[i-1])
  for k in range(2,K+1):
    if i-k < 0:
      break
    buf = min(buf, dp[i-k] + abs(A[i]-A[i-k]))
  dp[i] = buf
print(dp[N-1])

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

int main() {
    int64_t M,N,m;
    cin >> N >> M;
    int64_t sum = 0;

    for(int i = 0; i < M; i++){
        cin >> m;
        sum += m;
    }

    if(N - sum >= 0){
        cout << N - sum << endl;
    }else{
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  cin>>n>>k;
  ll a[n];
  for(i=0;i<n;i++)
  {
   cin>>a[i]; 
  }
  sort(a,a+n);
  ll ans=0;
  for(i=0;i<k;i++)
  {
   	ans+=a[i]; 
  }
  cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3676
input_line = map(int,raw_input().split(" "))
K = input_line[0]
S = input_line[1]
count = 0
for k in range(K+1):
	for kk in range(K+1):
		X = S - kk - k
		if 0 <= X <= K:
			count += 1

print count

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   
   int r;
   cin>>r;
   cout<<r*r<<endl;
    return 0;
}

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

int main(){
    int a[3];

    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }

    sort(a, a + 3);

    for (int i = 0; i < 3; ++i) {
        cout << a[i] << (i < 2 ? " " : "\n");
    }

}

Measured memory_bytes: 3108
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
x = []
y = []
for i in c:
    if c[i] > 3:
        y.append(i)
    if c[i] > 1:
        x.append(i)
x.sort()
y.sort()
ans1 = ans2 = 0
if len(x) > 1:
    ans1 = x[-1]*x[-2]
if len(y) > 0:
    ans2 = y[-1]**2
print(max(ans1, ans2))

Measured memory_bytes: 18600
#include<iostream>
#include<queue>

using namespace std;

static const int N=100;
static const int INFTY=(1<<21);

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

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++){
        d[i]=INFTY;
    }
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front(); 
        q.pop();
        for(int v=0; v<n; v++){
            if(M[u][v]==0){continue;}
            if(d[v]!=INFTY){continue;}
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i=0; i<n; i++){
        cout<<i+1<<" "<<((d[i]==INFTY)? (-1):d[i])<<endl;
    }
}

int main(){
    int u,v,k;
    cin>>n;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j]=0;
        }
    }

    for(int i=0; i<n; i++){
        cin>>u>>k;
        u--;
        for(int j=0; j<k; j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    bfs(0);
    return 0;
}





Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int p[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>p[i];
    int cnt=0;
    rep(i,n){
        if(p[i]==(i+1)%(n+1)){
            swap(p[i],p[(i+1)%n]);
            ++cnt;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

bool check(string s , int i , int j ) {
	while(i <= j) {
		if(s[i] != s[j]) return false;
		i++;
		j--;
	}
	return true;
}

signed main() {
	string s; cin >> s;
	string x;
	x.push_back('f');
	x += s;
	s = x;
	int n = sz(s);
	n--;
	bool ff = true;
	ff &= check(s , 1 , n );
	ff &= check(s , 1 , (n - 1) / 2);
	ff &= check(s , (n + 3) / 2 , n);
	if(ff) w << "Yes";
	else w << "No";
}


Measured memory_bytes: 256
A,B = map(int,input().split())

if B == 1:
  print(0)
  exit()
if A >= B:
  print(1)
  exit()
if A < B:
  count = A
  tap = A-1
  answer = 1

  while(count<B):
    count += tap
    answer += 1
  print(answer)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();	
        
        int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
		}
		
		Arrays.sort(map);
		
		System.out.println(map[map.length-1] - map[0]);
    }
}




Measured memory_bytes: 21716
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a, b, c;
    char temp;
    cin>>a>>temp>>b>>temp>>c;
    if(a>2019)
    {
        printf("TBD");
    }
    else if(a<=2019)
    {
        if(b<=4)
        {
            if(c<=30)
            {
                printf("Heisei");
            }
        }
        else if(b>4)
        {
            printf("TBD");
        }
    }
}


Measured memory_bytes: 3592
# -*- coding: UTF-8 -*-

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

r = 0
k = 0

for i in range(n):
    if r >= 0:
        m = min(r + b[i], a[i])
        k += m
        re = b[i] - max(0, m - r)
        r = re

    else:
        m = min(b[i], a[i])
        k += m
        r = b[i] - m

if r > 0:
    k += min(r, a[n])


print(k)


Measured memory_bytes: 18376
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    if(N*2>=M)cout<<(ll)M/2<<endl;
    else {
        double k=(M-2*N)/4;
        k+=N;
        ll d=k;
        cout<<d<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
constexpr char ln = '\n';
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    int N,M; cin >> N >> M;
    scc_graph scc(N);
    rep(i,M) {
        int a,b; cin >> a >> b;
        scc.add_edge(a,b);
    }

    auto G = scc.scc();
    cout << G.size() << ln;
    for (auto &arr : G) {
        cout << arr.size();
        for (auto j : arr) cout << " " << j;
        cout << ln;
    }
}


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

long long gcd (long long a, long long b) {
	if (a%b==0)
		return b;
	return gcd (b, a%b);
}

bool isprime (long long n) {
	for (long long i=2; i*i<=n; i++) {
		if (n%i==0)
			return false;
	}
	return true;
}

int main () {
	long long A,B;
	cin >> A >> B;
	long long g = gcd (A, B);
	int sum = 0;
		for (long long i=1; i*i<=g; i++)
			if (g%i==0) {
				if (isprime (i)) {
					sum ++;
				}
				if (isprime (g/i) && i*i!=g) {
					sum ++;
				}
			}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include"math.h"
#include<vector>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define dou(s) atof(s.c_str())
#define lll(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define delete(a,i) a.erase(a.begin()+i)
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define START int main(){cin.tie(0);ios::sync_with_stdio(false);
#define END }
using namespace std;
START
string s;
line(s);
vector<ll> a;
bool b=false;
string t="";
rep(i,0,s.size()){
  if(b AND s[i]==' '){
    b=false;
    a.push_back(lll(t));
    t="";
  }else if(s[i]=='-'){
    a[a.size()-2]-=a[a.size()-1];
    a.pop_back();
  }else if(s[i]=='+'){
    a[a.size()-2]+=a[a.size()-1];
    a.pop_back();
  }else if(s[i]=='*'){
    a[a.size()-2]*=a[a.size()-1];
    a.pop_back();
  }else if(s[i]!=' '){
    t+=s[i];
    b=true;
  }
}
cout<<a[0]<<endl;
END


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "E:\CP\Debugger\debugger.h"
#else 
#define debug(x...)
#endif
#define int long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TC int tc; cin>>tc; for(int cn=1; cn<=tc; ++cn) 

signed main(){
    int s, w; cin>>s>>w;

    cout<<(s>w? "safe\n": "unsafe\n");   
}

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

typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;

ll N, M, K;

// auto mod int
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

    mint ans = 0;
    rep(i, M) {
        ans += i * (M - i) * N * N;
    }
    combination comb(N * M);

    // y についても
    rep(i, N) {
        ans += i * (N - i) * M * M;
    }

    ans *= comb(N * M - 2, K - 2);

    cout << ans.x << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
//#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
//#include <random>
#include <complex>
//#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


template<typename T>
class Lazy_Segment_Tree {//0-indexed ??????
public:
	vector<T> data,lazy;
	int n;
	Lazy_Segment_Tree(int a) :n(1) {
		while (n < a) n *= 2;
		data.resize(n * 2 - 1);
		lazy.resize(n * 2 - 1);
	}

	void add(int a, int b, T ad, int num = 0, int base = 1) {
		int l = (num + 1 - base) * (n / base), r = l + n / base;
		if (a == l && b == r)
			lazy[num] += ad;
		else {
			data[num] += ad*(b-a);
			int nr = (l + r) / 2;
			if (nr > a) add(a, min(b, nr), ad, num * 2 + 1, base * 2);
			if (nr < b) add(max(a, nr), b, ad, num * 2 + 2, base * 2);
		}
	}

	T sum(int a, int b, int num = 0, int base = 1) {
		int l = (num + 1 - base) * (n / base), r = l + n / base;
		data[num] += lazy[num]*(r-l);
		if(num < n-1) lazy[num * 2 + 1] += lazy[num], lazy[num * 2 + 2] += lazy[num];
		lazy[num] = T();
		if (a == l && b == r)
			return data[num];
		else {
			int nr = (l + r) / 2;
			T ret = T();
			if (nr > a) ret += sum(a, min(b, nr), num * 2 + 1, base * 2);
			if (nr < b) ret += sum(max(a, nr), b, num * 2 + 2, base * 2);
			return ret;
		}
	}
};




signed main() {
	int n, m;
	scnaf("%d %d", &n, &m);
	Lazy_Segment_Tree<ll> lseg(n);
	REP(i, m) {
		int mode;
		scanf("%d", &mode);
		if (mode) {
			int a, b;
			scnaf("%d %d", &a, &b);
			printf("%lld\n", lseg.sum(a-1,b));
		}
		else {
			int a, b,c;
			scnaf("%d %d %d", &a, &b, &c);
			lseg.add(a-1,b,c);
		}
	}

	return 0;
}

Measured memory_bytes: 7028
import math 

A, B = map(int, input().split())

if (A / 0.08) > (B / 0.10):
  withOutA = math.ceil(A / 0.08)
  withOutB = math.floor(B / 0.10)
else:
  withOutA = math.floor(A / 0.08)
  withOutB = math.ceil(B / 0.10)


mark = True

for i in range(min(int(withOutA), int(withOutB)), max(int(withOutA), int(withOutB)) + 1):  
  if math.floor(i * 0.08) == A and math.floor(i * 0.10) == B:
    print(i)
    mark = True
  else:
    mark = False

if not mark:
  print(-1)

Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] ints = Arrays.stream(in.nextLine().split(" "))
                .mapToInt(Integer::parseInt)
                .sorted()
                .toArray();
        int ans = ints[2] - ints[0];
        System.out.println(ans);
    }
}

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

typedef long long int ll;
#define f(a, b) for(auto i = a;i < b;i++)

bool sortbysec(const pair<ll, ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 
void solve()
{
	return ;
}

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;


	cout << c << " " << a << " " << b << "\n";
}

Measured memory_bytes: 256
/***************************************************************
     File Name: A.cpp
     Created Time: 六  5/ 5 20:16:52 2018
 **************************************************************/
#define MEM0(x) memset(x,0,sizeof(x))
#define MEM1(x) memset(x,-1,sizeof(x))
#define MEMX(x) memset(x,0x3f,sizeof(x))
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> v;
  for (int i = 1; i <= 12; ++i) {
    v.push_back(i*30 + i);
  }
  // for (auto it : v) {
  //   cout << it << ' ';
  // } cout << endl;
  int x, y;
  while (cin >> x >> y) {
    x = x*30 + y;
    int ans = 0;
    for (auto it : v) {
      if (it <= x) ++ans;
    }
    cout << ans << endl;
  }
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost
    ll a, b, c;
    cin >> a >> b >> c;

    int flag = 0;
    if(c >= a + b)
    {
        if(4*a*b < (c - (a + b))*(c - (a + b))) flag = 1;
    }
    
    if(flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

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

Measured memory_bytes: 256