akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n, ans, s[105], d[101];
vector<int> b;
bool v[105];
int main()
{
	int i, j, k, z;
	cin >> n;
	for (i= 2; i <= n; i++) {
		if (v[i]) continue;
		b.push_back(i);
		for (j = i * 2; j <= n; j += i) v[j] = 1;
		for (j = i; j <= n; j *= i) s[i] += n / j;
	}
	d[1] = 1;
	for (i = 2; i <= n; i++) {
		if (v[i]) continue;
		for (j = 75; j >= 0; j--) {
			for (k = 1; k <= s[i]; k++) {
				if (j * (k + 1) <= 75) d[j * (k + 1)] += d[j];
			}
		}
	}
	cout << d[75];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    string s;
    cin >> s;
    int x=0;
    for(int i=0;i<N;i++){
        if(s[i]=='R')x++;
    }
    if(2*x>N)cout << "Yes";
    else cout << "No" << endl;


}

/*



 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N;
  scanf("%d", &N);
  long long a[N];
  long long suml=0;
  long long sumr=0;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &a[i]);
    sumr += a[i];
  }

  long long ans = 200000000000;

  for (int i = 0; i < N-1; ++i){
    suml += a[i];
    sumr -= a[i];
    if(abs(suml-sumr)<ans) ans = abs(suml-sumr);
  }

  cout << ans << endl;



  

}



Measured memory_bytes: 1792
import Foundation

private func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

prefix operator *
private prefix func *<T>(a: inout IndexingIterator<[T]>) -> T {
    return a.next()!
}

func mainB() {
    let S = Array(readLine()!)
    let T = Array(readLine()!)
    
    var ans = 0
    for i in 0..<S.count {
        if S[i] != T[i] {
            ans += 1
        }
    }
    
    print(ans)
}

mainB()


Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

db dp[3005][3005];
db ans;

int main()
{
	start_routine();
	fastio;
	

    ll n;cin>>n;
    db p[n+1];

    for(ll i=1;i<=n;i++)
    	cin>>p[i];

    dp[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
    	dp[i][0]=dp[i-1][0]*p[i];
    	dp[0][i]=dp[0][i-1]*(1.0-p[i]);
    }

    for(ll i=1;i<=n;i++)
    	for(ll j=1;j<=n;j++)
    		if(i+j<=n)
    			dp[i][j]=(dp[i][j-1]*(1.0-p[i+j]))+(dp[i-1][j]*p[i+j]);

    for(ll i=0;i<=n;i++)
    	for(ll j=0;j<=n;j++)
    		if(i>j && i+j==n)
    			ans+=dp[i][j];

   	cout<<stp<<ans;

	end_routine();
}

Measured memory_bytes: 139776
import sys

input = sys.stdin.readline

N = int(input())
A = []
xy = []
ans = []
sm = 0

for _ in range(N):
    temp = int(input())
    A.append([temp, sm])
    sm += temp
    for _ in range(A[-1][0]):
        xy.append(list(map(int, input().split())))
for i in range(2**N):
    flag = True
    binary = bin(i)[2:]
    if len(binary) < N:
        binary = '0' * (N - len(binary)) + binary
    check = [0]*N
    for j, digit in enumerate(binary):
        if digit == '1':
            check[j] = 1
    for j, value in enumerate(check):
        if value == 1:
            for k in range(A[j][0]):
                x = xy[A[j][1]+k][0] - 1
                y = xy[A[j][1]+k][1]
                if check[x] != y:
                    flag = False
    if flag:
        ans.append(check.count(1))

print(max(ans))

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

ll f[100005];

ll dp(ll h[], ll n, ll k){
  f[0] = 0;
  for(int i = 1; i < n; i++){
    f[i] = abs(h[i] - h[i-1]) + f[i-1];
    if(i < k){
      for(int j = i-2; j >= 0; j--){
        if(f[i] <= abs(h[i]-h[j])+f[j]){
          continue;
        }
        else{
          f[i] = abs(h[i]-h[j])+f[j];
        }
      }
    }
    else{
      for(int j = i-2; j >= i-k; j--){
        if(f[i] <= abs(h[i]-h[j])+f[j]){
          continue;
        }
        else{
          f[i] = abs(h[i]-h[j])+f[j];
        }
      }
    }
  }
}

int main(void){
  ll n,k; cin >> n >> k;
  ll h[n]; rep(i,n) cin >> h[i];
  dp(h,n,k);
  cout << f[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n;int sum,b[105];
int main()
{
     cin>>n;
    for(int i=1;i<n;i++)cin>>b[i];
    sum=b[n-1]+b[1];
    for(int i=2;i<n;i++)sum+=min(b[i],b[i-1]);
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200000];
signed main()
{
	int n,i,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ans^=a[i];
	}
	for(i=0;i<n;i++)
		cout<<(ans^a[i])<<' ';
	return 0;
}

Measured memory_bytes: 5096
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, m, X, Y, mx = -200, my = 200;
	cin >> n >> m >> X >> Y;
	vector<int>x(n), y(m);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		mx = max(mx, x[i]);
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
		my = min(my, y[i]);
	}
	mx = max(mx, X); my = min(my, Y);
	if (mx < my) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int w, h, x, y; cin >> w >> h >> x >> y;
	double area = 1LL * w * h;
	cout << area / 2 << ' ' << (x * 2 == w && y * 2 == h) << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
multiset <string> s;
int x,y,z;
int main(){
	cin>>x>>y>>z;
	while(x--)s.insert("a");
	while(y--)s.insert("b");
	while(z--)s.insert("c");
	while(s.size()>1){
		string a=*s.begin();
		string b=*s.rbegin();
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(a+b);
	}
	cout<<*s.begin()<<endl;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a := r.nextInt()
	b, _ := strconv.ParseInt(strings.Replace(r.nextString(), ".", "", 1), 10, 64)

	fmt.Fprintln(stdout, a*int(b)/100)
}


Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
/****************/
/*  Algorithm   */
/****************/

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
	//0,1は含まれない
	if (min < 2) min = 2;
	//探索リスト作成
	vector<int> int_array;
	for (int i = min; i <= max; i++) int_array.push_back(i);
	//素数リスト
	vector<int> sosu;
	//√max
	double stop = sqrt(max);
	//計算
	while (true)
	{
		//素数リストに追加
		sosu.push_back(int_array.front());
		int_array.erase(int_array.begin());
		//停止
		if (stop < (double)(sosu.back())) break;
		//ふるい
		for (int i = 0; i < (int)int_array.size(); i++)
		{
			if (int_array[i] % sosu.back() == 0)
				int_array.erase(int_array.begin() + i);
		}
	}
	sosu.insert(sosu.end(), int_array.begin(), int_array.end());
	return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
	int c = a * b;
	//入れ替え
	if (a < b)
		swap(a, b);
	int r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return c / b;
}

//最小公約数
int MinCD(int a, int b)
{
	//入れ替え
	if (a < b)
		swap(a, b);
	int r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main(void)
{
	//vector<int> arr = SOE(0, 100);
	int A, B;
	cin >> A >> B;
	cout << max({ A + B,A - B,A*B }) << endl;
}

Measured memory_bytes: 256
#ABC 104 C - All Green

#ビット総当たりでやる

d, g = map(int, input().split())
#print(d)

p=[]
c=[]

for i in range(d):
  pk, ck = map(int, input().split())
  p.append(pk)
  c.append(ck)
#print(p)
#print(c)
  
ans = 10000#仮の答え

#2^d通り試す
for i in range(2 ** d):
  #右からn番目の桁が1→n+1の配点の問題を完全に解く
  ten = 0
  mondaisu = 0
  for j in range(d):
    if (i>>j)&1 == 1:
      #p[j]個あるj+1の配点の問題を完全に解く
      ten += (j+1)*100*p[j] + c[j]
      mondaisu += p[j]
    else:
      #p[j]個あるj+1の配点の問題は完全にとかない
      k = j
  #フラグの立った配点の問題を全部といた
  if ten > g:
    if ans > mondaisu:
      ans = mondaisu
  else:
    #中途半端に解かないと行けない場合p[k]の問題を中途半端に解く
    if g-ten <= (k+1)*100*p[k] :
      mondaisu += (g-ten-1)//((k+1)*100) +1
      if ans > mondaisu:
        ans = mondaisu
      #中途半端に解いて届かない場合スルー
#  print(mondaisu)    
print(ans)
      

    

Measured memory_bytes: 40432
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,to=b;i<to;++i)
using namespace std;
typedef long long ll;

vector<string> v;
string s;
char ss[100005];
int n;

int main(){
	v.pb("maerd");
	v.pb("remaerd");
	v.pb("esare");
	v.pb("resare");
	scanf("%s",ss);
	n=strlen(ss);
	reverse(ss,ss+n);
	s=string(ss);
	int i=0;
	while(i<n){
		bool d=false;
		fore(j,0,v.size()){
			bool m=true;
			fore(k,0,v[j].size()){
				if(i+k>=n)m=false;
				if(s[i+k]!=v[j][k])m=false;
				if(!m)break;
			}
			if(m){i+=v[j].size();d=true;break;}
		}
		if(!d){puts("NO");return 0;}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

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

		int n = sc.nextInt();
		int x = 800 * n;
		int y = (n / 15) * 200;
		System.out.println(x - y);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 20820
#include <stdio.h>
int main(void)
{
    int i;
    char c[1201];
    
    for(i=0;c[i-1]!='\n';i++){
        scanf("%c",&c[i]);
        if(c[i]>=65 && c[i]<=90)
            c[i]=c[i]+32;
        else if(c[i]>=97 && c[i]<=122)
            c[i]=c[i]-32;
    }
    c[i-1]=0;
    printf("%s\n",c);
    return 0;
}



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

int main() {
    int W, H, N;
    cin >> W >> H >> N;

    int A[W][H];
    for (int x = 0; x < W; x++) {
        for (int y = 0; y < H; y++) {
            A[x][y] = 1;
        }
    }

    int x, y, a;
    for (int i = 0; i < N; i++)
    {
        cin >> x >> y >> a;
        
        if (a==1){
            for (int i_x = 0; i_x < x; i_x++) {
                for (int i_y = 0; i_y < H; i_y++) {
                    A[i_x][i_y] = 0;
                }
            }
        }
        else if (a==2)
        {
            for (int i_x = x; i_x < W; i_x++) {
                for (int i_y = 0; i_y < H; i_y++) {
                    A[i_x][i_y] = 0;
                }
            }
        }
        else if (a==3)
        {
            for (int i_y = 0; i_y < y; i_y++) {
                for (int i_x = 0; i_x < W; i_x++) {
                    A[i_x][i_y] = 0;
                }
            }
        }
        else if (a==4)
        {
            for (int i_y = y; i_y < H; i_y++) {
                for (int i_x = 0; i_x < W; i_x++) {
                    A[i_x][i_y] = 0;
                }
            }
        }
    }

    int result = 0;
    for (int x = 0; x < W; x++)
    {
        for (int y = 0; y < H; y++)
        {
            result += A[x][y];
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

double dp[333][333][333];
int N;

double rec(int i, int j, int k)
{
	if(dp[i][j][k] >= 0) return dp[i][j][k];
	if(i+j+k==0) return 0.0;
	double res=0.0;
	if(i>0) res+=rec(i-1, j, k)*i;
	if(j>0) res+=rec(i+1, j-1, k)*j;
	if(k>0) res+=rec(i, j+1, k-1)*k;
	res+=N;
	res*=1.0/(i+j+k);
	return dp[i][j][k]=res;
}

int main(void)
{
	int one, two, three;
	one = 0;
	two = 0;
	three = 0;
	cin >> N;
	REP(i, N){
		int a;
		cin >> a;
		if(a == 1){
			one++;
		}else if(a == 2){
			two++;
		}else{
			three++;
		}
	}

	REP(i, N+1){
		REP(j, N+1){
			REP(k, N+1){
				dp[i][j][k] = -1;
			}
		}
	}
	cout << fixed << setprecision(10) << rec(one, two, three) << "\n";
	return 0;
}


Measured memory_bytes: 262272
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Remainder
{

  static long div = 1000000007;

    static public void Main()
    {
      var NT = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      var N  = NT[0];
      var T  = NT[1];
      var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      var maxies = new long[N]; 
      var max = 0;
      var sum = 0;
      //以降の数の最大値を配列に格納する
      for(int i = N-1; i >= 0;i--){
        if(max < A[i]){
          maxies[i] = A[i];
          max = A[i];
        }else{
          maxies[i] = max;
        }
      }
      
      var dif = 0L;
      for(int i = 0; i < N;i++){
        //Console.WriteLine(maxies[i]);
        if((maxies[i] - A[i]) > dif){
          dif = maxies[i] - A[i];
          sum = 1;
        }else if((maxies[i] - A[i]) == dif){
          sum++;
        }
      }
      Console.WriteLine(sum);
    }

}


Measured memory_bytes: 22496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w, m;
    cin >> h >> w >> m;
    vector<P> v(m);
    map<P, int> mp;
    rep(i, m) {
        cin >> v[i].first >> v[i].second;
        v[i].first--;
        v[i].second--;
        mp[v[i]]++;
    }
    vector<int> x(h);
    vector<int> y(w);
    
    rep(i, m) {
        x[v[i].first]++;
        y[v[i].second]++;
    }
    
    int maxx;
    int vx = 0;
    int maxy;
    int vy = 0;
    rep(i, h) {
        if (x[i]>vx) {
            vx = x[i];
            maxx = i;
        }
    }
    rep(i, w) {
        if (y[i]>vy) {
            vy = y[i];
            maxy = i;
        }
    }
    int ans = x[maxx] + y[maxy];
    vector<int> xx;
    vector<int> yy;
    rep(i, h) {
        if (x[i]==vx) xx.push_back(i);
    }
    rep(i, w) {
        if (y[i]==vy) yy.push_back(i);
    }
    bool ok = false;
    rep(i, xx.size()) {
        rep(j, yy.size()) {
            if (mp[P(xx[i], yy[j])]==0) {
                ok = true;
                break;
            }
        }
        if (ok) break;
    }
    if (!ok) ans--;
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 30812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[105] = {};
    int b[105] = {};
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    int count = 0;
    for (int i = 0; i < 105; i++){
        if(i == N) break;
        if(a[i] == b[i]){
            count++;
            if(count == 3){
                cout << "Yes" << endl;
                return 0;
            }
        }else count = 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define maxn 100005
#define MOD 998244353
using namespace std;
#define ll long long

#define pii pair<ll, ll>
#define piii pair<ll, pii>

#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


ll power(ll a, ll b){
    if(b==0) return 1;
    ll R =1, k=a;
    for (ll j=b;j>0;j/=2){
        if (j&1) R=(R*k)%MOD;
        k=(k*k)%MOD;
    }
    return R;
}

void solve(){

    ll a, b;
    cin  >> a >> b;
    ll k = (a*100)/8 + ((a*100)%8!=0);
    ll l = (b*100)/10 + ((b*100)%10!=0);
    //
    if(k!=l) {
           // cout << (k)/8 << " " << (k)/10 << endl;
        if( (k*8)/100 == a && (k*10)/100 == b) { cout << k ; return; }
        if( (l*8)/100 == a && (l*10)/100 == b) { cout << l ; return;}
        cout << "-1";
    }
    else cout << k ;
}

int main()
{


    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,m = inp
a = na2(n+1,0)
m.times do
  d = inp 
  a[d[0]].push(d[1])
  a[d[1]].push(d[0])
end
ind = -1
a.size.times do |i|
  if(a[i].size == 0)
    next
  else
    ind = i
    break
  end 
end
fl = []
ans = [ind]
fl.push(ind)
used = na(n+1)
used[ind] = true
while(fl.size > 0)
  ii = fl.pop
  dd = a[ii]
  i = (dd.size-1)
  while(i>=0) do
    if(used[dd[i]] == true)
      dd.delete_at(i)
      i-=1
    else
      used[dd[i]] = true
      fl.push(dd[i])
      ans.push(dd[i])
      dd.delete_at(i)
      break
    end
  end
end
fl.push(ind)
while(fl.size > 0)
  ii = fl.pop
  dd = a[ii]
  i = (dd.size-1)
  while(i>=0) do
    if(used[dd[i]] == true)
      dd.delete_at(i)
      i-=1
    else
      used[dd[i]] = true
      fl.push(dd[i])
      ans.unshift(dd[i])
      dd.delete_at(i)
      break
    end
  end
end
p ans.size
(ans.size-1).times do |i|
  print "#{ans[i]} "
end
puts ans[ans.size - 1]

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

int main() {
	int a, b;
	cin >> a >>b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b)cout << "Alice" << endl;
	else if (a == b)cout << "Draw" << endl;
	else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  ll n,a,b; cin >> n >> a >> b;
  if((b-a)%2 == 0){
    cout << (b-a)/2LL << endl;
  }
  else{
    ll ans = min(n-a,b-1);
    chmin(ans, a+(b-a-1)/2);
    chmin(ans, n-b+1+(b-a-1)/2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#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

int M = (int)1e9 + 7;
#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 unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;
typedef complex<int> point;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>


#define cerr cout
#define watch(x) cerr << (#x) << " = " << (x)    << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
	return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
	return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
	return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
	out << "[";
	fori(i, a.size())
		out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
	return out;
}

void smain();

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


	cout << setprecision(12) << fixed;
	smain();
}

#define N 400000
const int oo = (int)1e9;


void smain()
{

	int n, a, b, c, k1 = 0, k2 = 0, k3 = 0;
	cin >> n >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> c;
		k1 += (c <= a);
		k2 += (c > a && c <= b);
		k3 += (c > b);
	}

	cout << min(min(k1, k2), k3);




}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w, n;
  cin >> h >> w >> n;

  h = max(h, w);
  for ( int i = 1; i < 100000; i++ ) {
    if ( h*i >= n ) {
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
void solve(){
    int k,n,C[4010][4010],Pow2[2010];
    cin>>k>>n;
    init_fact(200000);
    rep(i,4001)C[i][0]=1;
    rep(i,4001){
        if(i==0)continue;
        rep(j,4001){
            if(j==0)C[i][j]=1;
            else C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
    Pow2[0]=1;
    rep(i,2001)if(i)Pow2[i]=Pow2[i-1]*2%mod;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            int p;
            if(i<=k)p=i/2-1;
            else p=k-(i/2);                   
            int q=k-p*2-1;
            //cout<<p<<" "<<q<<endl;
            int ans=0;
            rep(r,p+1){
                {
                    ans+=C[p][r]*Pow2[p-r]%mod*C[n+q-1][p+q-r-1]%mod;
                    ans%=mod;
                }
                {
                    ans+=C[p][r]*Pow2[p-r]%mod*C[n+q-2][p+q-r-1]%mod;
                    ans%=mod;
                }
            }
            cout<<ans<<endl;
        }
        if(i%2==1){
            int p;
            if(i<=k+1)p=i/2;
            else p=(i/2)-(i-k)+1;                   
            int q=k-p*2;
            //cout<<p<<" "<<q<<endl;
            int ans=0;
            rep(r,p+1){
                ans+=C[p][r]*Pow2[p-r]%mod*C[n+q-1][p+q-r-1]%mod;
                ans%=mod;
            }
            cout<<ans<<endl;
        }
    }
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}

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

using namespace std;
typedef long long int ll;
const ll INF = 10e9 + 7;

int main()
{
    long n,k;
    cin>>n>>k;

    vector <ll> dp(n+1,INF);
    vector <ll> arr(n+1);
    
    for(int i=0;i<n;i++)
        cin>>arr[i];

    dp[0] = 0;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j] = min(dp[j],abs(arr[j]-arr[i]) + dp[i]);
        }
    }

    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,m,ans;
int main()
{
    sc2(n,m);
    ans+=n*(n-1)/2;
    ans+=m*(m-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int a[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int cnt[3] = {};
  for (int i = 0; i < N; i++) {
    if (a[i] % 4 == 0) cnt[0]++;
    else if (a[i] % 2 == 0) cnt[1]++;
    else cnt[2]++;
  }
  cnt[2] += cnt[1] != 0;
  cout << (cnt[2] <= cnt[0] + 1 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h, w; cin >> h >> w;
	int n; cin >> n;
	int d = max(h, w);
	cout << (n + d - 1) / d << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
long double calc(ll x) {
    long double prob = 1./x;
    return ((x-1)/2+1)*prob;
}
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
    SS(ll,x,y)
    if(x==-y)p(1);
    else if (abs(x)<abs(y))p(abs(y)-abs(x)+(x<0)+(y<0));
    else p(abs(x)-abs(y)+(x>0)+(y>0));
}

Measured memory_bytes: 256
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

long long int non_divide(long long int n, long long int div) {
	return n - n / div;
}

long long int divide(long long int n, long long int div) {
	return n / div;
}

long long int gcd(long long int a,long long int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;

	long long int anti_div_A = A - 1 - divide(A - 1, C) - divide(A - 1, D) + divide(A - 1, lcm(C, D));
	long long int anti_div_B = B - divide(B, C) - divide(B, D) + divide(B, lcm(C, D));
	
	cout << anti_div_B - anti_div_A << endl;

	return 0;
}


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

int main(){
  string s,t;
  int a,b;
  string u;
  cin>>s>>t>>a>>b>>u;
  if(s==u) cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(i=1; i<=n; ++i)
using namespace std;

int xyz(int x, int y, int z){
  return x*x + y*y + z*z + x*y + y*z + z*x;
}

int searchxyz(int i, int x, int y, int z){
  int total=0;
  for(x=1; (y=1) && xyz(x,y,z)<=i; ++x)
    for(y=1; (z=1) && xyz(x,y,z)<=i; ++y)
      for(z=1; xyz(x,y,z)<=i; ++z)
        if(xyz(x,y,z)==i) ++total;
  return total;
}

int main(void){
  int N; cin >> N;
  int i; rep(i, N){
    cout << searchxyz(i,1,1,1) << endl;
  }
    
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    cout << (K<=(N + 1) / 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    vll a(n);
    ll r = 0;
    rep(i, n) {
        cin >>a[i];
    }
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            r += a[i]*a[j];
        }
    }
    mes(r);
    
   
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
ll MOD=13;
int a[3010];
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  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;
  }
};

const int NMAX=3010;
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;	
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

mint b[3010];

int main()
{
  cin >> MOD;
  rep(i,(int)MOD) cin >> a[i];
  
  Make_Fact();
  Make_InvFact();
  
  rep(i,(int)MOD){
    if(a[i]==0) continue;
    mint z = 1;
    rep(j,(int)MOD){
      if(j%2 == 0) b[(int)MOD-1-j] -= Comb(MOD-1,j)*z;
      else b[(int)MOD-1-j] += Comb(MOD-1,j)*z;
      z *= (mint)i;
    }
    b[0] += 1;
  }
  
  rep(i,(int)MOD){
    cout << b[i].x << " ";
  }
  cout  << "\n";
  
  return 0;
}


Measured memory_bytes: 384
import bisect

n = int(input())
l = [int(x) for x in input().split()]

ans = 0
l.sort()
for i in range(n):
    for j in range(i+1, n):
        lt = bisect.bisect_right(l, l[j]-l[i], j+1)
        rt = bisect.bisect_left(l, l[j]+l[i], j+1)
        ans += max(0, rt-lt)
print(ans)

Measured memory_bytes: 47016
#include<stdio.h>
#include<string.h>
long ship[100][100];
int n;
long wfs(int a,int b){
  //dijstra
  long graph[100],min;
  int f[100],i,s,c,next;
  memset(f,0,sizeof(f));
  memset(graph,9,sizeof(graph));
  graph[a]=0;
  s=0;
  c=a;
  while(1){
  	next=-1;
  	f[c]=2;
  	min=100000001;
  	if(c==b){
  		return graph[c];
  	}
  	for(i=0;i<n;i++){
  		if(ship[c][i]>0){
  			if(f[i]<2){
  				if(graph[i]>graph[c]+ship[c][i]){
  					graph[i]=graph[c]+ship[c][i];
  				}
  				f[i]=1;
  			}
  		}
  	}
  	for(i=0;i<n;i++){
  		if(f[i]<2){
  			if(min>graph[i]){
  				min=graph[i];
  				next=i;
  			}
  		}
  	}
  	if(next==-1) return -1;
  	c=next;
  }
}
int main(){
  int k,r,i,a,b;
  long p;
  while(1){
    scanf("%d %d",&n,&k);
    if(n==0) break;
    memset(ship,0,sizeof(ship));
    for(i=0;i<k;i++){
      scanf("%d",&r);
      if(r==0){
        scanf("%d %d",&a,&b);
        printf("%ld\n",wfs(a-1,b-1));
      }else{
        scanf("%d %d %ld",&a,&b,&p);
        if(ship[a-1][b-1]>p || ship[a-1][b-1]==0){
          ship[a-1][b-1]=p;
          ship[b-1][a-1]=p;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 684
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	int n, l;
	cin >> n >> l;

	vector<int> a(n);
	int t = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) {
			if (a[i] + a[i - 1] >= l) {
				t = i;
			}
		}
	}
	if (t == -1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for (int i = 1; i <= t - 1; i++) {
		cout << i << endl;
	}
	for (int i = n - 1; i >= t; i--) {
		cout << i << endl;
	}

	return 0;
}



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

using namespace std;

#define ll long long

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, a*b) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],c[N],b[N],hs[N],tot,head[N],nex[N<<1],to[N<<1],wi[N<<1];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
bool vis[N],use[N];
int lowb(int x)
{
    return lower_bound(hs+1,hs+1+n,x)-hs;
}
int uppb(int x)
{
    return upper_bound(hs+1,hs+1+n,x)-hs;
}
bool dfs(int u)
{
    vis[u]=true;
    int x=c[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(!vis[v]&&dfs(v))
        {
            x^=1;use[wi[i]]=true;
        }
    }
    return x;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]),hs[i]=a[i];
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++)
        a[i]=lowb(a[i]),c[a[i]]=b[i];
    for(int i=n+1;i>=1;i--)
        c[i]^=c[i-1];
    for(int i=1;i<=m;i++)
    {
        int l,r;scanf("%d%d",&l,&r);
        l=lowb(l);
        r=uppb(r)-1;
        if(l<=r)
            add(l,r+1,i),add(r+1,l,i);
    }
    for(int i=1;i<=n+1;i++)
        if(!vis[i]&&dfs(i))
    {
        printf("-1\n");return 0;
    }
    int ans=0;
    for(int i=1;i<=m;i++)
        if(use[i]) ans++;
    printf("%d\n",ans);
    for(int i=1;i<=m;i++)
    if(use[i])
        printf("%d ",i);
}


Measured memory_bytes: 10880