akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Flow():
    def __init__(self, e, N):
        self.E = e
        self.N = N
        self.nl = list(range(N))

    def max_flow(self, s, t):
        r = 0
        e = self.E
        v = None

        def f(c):
            v[c] = 1
            if c == t:
                return 1
            for i in e[c]:
                if v[i] is None and f(i):
                    e[c].remove(i)
                    e[i].add(c)
                    return 1
            return

        while True:
            v = [None] * self.N
            if f(s) is None:
                break
            r += 1

        return r

def main():
    rr = []

    def f(m, n):
        b = LI()
        while len(b) < m:
            b += LI()
        r = LI()
        while len(r) < n:
            r += LI()
        s = m + n + 2
        e = collections.defaultdict(set)
        for i in range(m):
            e[0].add(i+1)
        for i in range(n):
            e[m+i+1].add(s-1)

        for i in range(m):
            for j in range(n):
                if fractions.gcd(b[i], r[j]) > 1:
                    e[i+1].add(m+j+1)

        fl = Flow(e, s)

        return fl.max_flow(0, s-1)

    while True:
        m, n = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 33972
import java.util.Scanner;


public class Main {

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

		double L = sc.nextDouble();

		double S = L / 3;
		double W = L / 3;
		double H = L / 3;

		System.out.println(S * W * H);
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

ll mod_ = 1e9 + 7;
ll mod = 13;

ll pow_(ll x, long long int n){
	ll res(1);
	while(n){
		if(n&1){
			res = ((res%mod) * (x%mod))%mod;
		}
		n >>= 1;
		x = ((x%mod) * (x%mod))%mod;
	}
	return res%mod;
}


int main(){
	string s;
	cin >> s;
	reverse(all(s));
	int n = s.size();
	vector<vector<ll>> dp(n + 1, vector<ll>(mod, 0));
	dp[0][0] = 1;
	rep(i,n){
		int c = (s[i] == '?' ? -1 : s[i] - '0');
		rep(j, 10)
		{
			if(c != -1 && c != j)
				continue;
			ll now = (j * pow_(10, i)) % mod;
			rep(k, mod)
			{
				dp[i + 1][(k + now) % mod] += dp[i][k];
				dp[i + 1][(k + now) % mod] %= mod_;
			}
		}
	}
	cout << dp[n][5] % mod_ << endl;

	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;



int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	int c0 = 0, c1 = 0, c2 = 0;
	ll ans = 1;

	rep(i, n) {
		int hoge = 0;
		if (a[i] == c0)hoge++;
		if (a[i] == c1)hoge++;
		if (a[i] == c2)hoge++;

		ans *= hoge;ans %= MOD;

		if (a[i] == c0) { c0++;continue; }
		if (a[i] == c1) { c1++;continue; }
		if (a[i] == c2) { c2++;continue; }
	}

	cout << ans << endl;

}

Measured memory_bytes: 640
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

    int N = sc.nextInt();
    int K = sc.nextInt();
    int k = K;
    Set<Integer> map = new HashSet<>();

    //System.out.println(String.format("N %d  K %d ", N, K));
    while (K-- > 0) {
      int i = sc.nextInt();

      while (i-- > 0) {
        int x = sc.nextInt();
        map.add(x);
      }
    }

    //System.out.println(String.format("S = %s", map.toString()));
    Set<Integer> x = IntStream.rangeClosed(1, N).boxed().collect(Collectors.toSet());
    //System.out.println(String.format("X = %s", x.toString()));

    x.removeAll(map);
    System.out.println(x.size());
  }
}

Measured memory_bytes: 46580
def bingo(a):
    for i in range(3):
        if sum([a[j][i] for j in range(3)]) == 0:
            return 'Yes'
        if sum(a[i]) == 0:
            return 'Yes'
    if a[0][0] + a[1][1] + a[2][2] == 0:
        return 'Yes'
    if a[2][0] + a[1][1] + a[0][2] == 0:
        return 'Yes'
    return 'No'

a = []
for _ in range(3):
    li = list(map(int, input().split()))
    a.append(li)
n = int(input())
b = [int(input()) for i in range(n)]

for num in b:
    for i, ai in enumerate(a):
        for j, aij in enumerate(ai):
            if aij == num:
                a[i][j] = 0
print(bingo(a))


Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n, ans = 0;
	string s;
	char hoge = ' ';
	cin >> n;
	cin >> s;
	rep(i,s.length()) {
		if (hoge != s[i]) {
			ans += 1;		
		} 
		hoge = s[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
n = gets.chomp.to_i
i = 1
cnt = 0
while i**2 <= n
  if (n-i) % i == 0 && (((n-1)/i > 0) && n/((n-i)/i) == i)
    cnt += (n-i) / i
  end
  i += 1
end
puts cnt


Measured memory_bytes: 1788
#include<iostream>

using namespace std;

int main(){

	int n, t[200], m, p, x;
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++){ 
		cin >> t[i];
	}
	
	cin >> m;
	for (int j = 0; j < m; j++){
		cin >> p >> x;
		
		for (int i = 0; i < n; i++){
			if (i != p-1) sum += t[i];
			else sum += x;
		}

		cout << sum << endl;
		sum = 0;
	}



	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <string.h>
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int m = ri();
	std::vector<int> hen[n];
	for (int i = 0; i < m; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].push_back(b);
	}
	int s = ri() - 1, t = ri() - 1;
	int dist[n][3];
	for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) dist[i][j] = 1000000000;
	std::queue<std::pair<int, int> > que;
	dist[s][0] = 0;
	que.push({s, 0});
	while (que.size()) {
		auto i = que.front();
		que.pop();
		int next_second = (i.second + 1) % 3;
		for (auto j : hen[i.first]) {
			if (dist[j][next_second] > dist[i.first][i.second] + 1) {
				dist[j][next_second] = dist[i.first][i.second] + 1;
				que.push({j, next_second});
			}
		}
	}
	std::cout << (dist[t][0] == 1000000000 ? -1 : dist[t][0] / 3) << std::endl;
	return 0;
}



Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int a,b,k;
	cin >> a >> b >> k;
	for(int i=0;i<k;i++)
	{
		if(i%2==0)
		{
			if(a%2==1)a--;
			a/=2;
			b+=a;
		}		
		else
		{
			if(b%2==1)b--;
			b/=2;
			a+=b;
		}
	}
	cout << a << " " << b <<  endl;


	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int i = 0;i < M;i++) {
			for(int j = 9;j < D;j++) {
				if((j+1)/10 >= 2 &&
						(j+1)%10 >= 2 &&
						(i+1) == ((j+1)/10)*((j+1)%10)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22996
#include <stdio.h>

#define MAX 100

int main(){

  int n,i,j,tmp;

  int tyouten[MAX],dekazu[MAX],ikisaki[MAX][MAX];

  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++) ikisaki[i][j]=0;
}

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d%d",&tyouten[i],&dekazu[i]);

    for(j=0;j<dekazu[i];j++){
      
      scanf("%d",&tmp);

      ikisaki[i][tmp-1]=1;

    }
  }

  for(i=0;i<n;i++){

    for(j=0;j<n;j++){

      if(j==n-1) printf("%d",ikisaki[i][j]);

	else printf("%d ",ikisaki[i][j]);

      /*      if(ikisaki[i][j]==1) printf("1 ");
      else printf("0 ");
      */
}

    printf("\n");

}

  return 0;

}

Measured memory_bytes: 644
#include <iostream>
#include <string>
using namespace std;
int gcd(int a,int b){
  int c;
  while(a){
    c=b%a;
    b=a;
    a=c;
  }
  return b;
}
int main(){
  int n;
  string c;
  cin>>n;cin.ignore();
  while(n--){
    getline(cin,c);
    bool flag=false;
    for(int i=1;i<26;i++){
      if(gcd(i,26)!=1) continue;
      for(int j=0;j<26;j++){
	string p;
	for(string::iterator it=c.begin();it!=c.end();it++){
	  if(*it==' '){
	    p+=*it;
	  }
	  else p+=(char)(((int(*it)-'a')*i+j)%26+'a');
	}
	if(p.find("this")!=string::npos||p.find("that")!=string::npos){
	  cout<<p<<endl;
	  flag=true;
	  break;
	}
      }
      if(flag) break;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
    ll n;
    cin >> n;
    ll a[n],prefix[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	prefix[i]=0;
    }
    prefix[0]=a[0];
    for(int i=1;i<n;i++) prefix[i]=(prefix[i-1]+a[i])%1000000007;
    ll sum=0;
    for(int i=1;i<n;i++){
        sum+=(((a[i]%1000000007)*(prefix[i-1]%1000000007))%1000000007);
    }
    cout << sum%1000000007;
	return 0;
}


Measured memory_bytes: 6716
#include<iostream>
using namespace std;
int main()
{
int n;cin>>n;
  string a,b;
  cin>>a>>b;
  string::iterator it; 
   string::iterator it1; 
  for (it=a.begin(),it1=b.begin(); it!=a.end()&&it1!=b.end(); it++,it1++) 
    cout << *it<<*it1; 
    cout << endl; }

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {

	int n, m;

	while (cin >> n >> m, n != 0 && m != 0) {
		vector<int>v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		int ans = -1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j && max(ans, v[i] + v[j]) <= m) {
					ans = max(ans, v[i] + v[j]);
				}
			}
		}
		if (ans == -1) {
			cout << "NONE" << endl;
		}
		if (ans != -1) {
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3072
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val c = sc.nextLong()
    val k = sc.nextLong()
    val t = (0 until n).map { sc.next().toLong() }
    println(problem011a(n, c, k, t))
}

fun problem011a(n: Int, c: Long, k: Long, t: List<Long>): Int {
    val t = t.sorted()
    val bus = mutableListOf<MutableList<Long>>()
    bus.add(mutableListOf())
    val queue = ArrayDeque<Long>()
    for (i in 0 until n) {
//        debugLog(bus, t[i])
//        if (bus.last().isNotEmpty()) {
//            debugLog(t[i] - bus.last()[0], k)
//        }
        if (bus.last().size.toLong() == c || (bus.last().isNotEmpty() && t[i] - bus.last()[0] > k)) {
            bus.add(mutableListOf())
        }
        bus.last().add(t[i])
    }
    return bus.count()
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, w, h;
    cin >> n >> h >> w;
    cout << (n - w + 1) * (n - h + 1) << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


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

int main() {
  int N;
  vector<int> v;
  int i;

  cin >> N;
  for(i=0; i<N; i++) {
    int n;
    cin >> n;
    v.push_back(n);
  }

  sort(v.begin(), v.end());
  //cout << v[0] << " " << v[i-1] << endl;                              

  cout << v[i-1] - v[0] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  REP(i, 0, H) {
    cin >> S[i];
  }

  REP(h, 0, H) {
    REP(w, 0, W) {
      if (S[h][w] == '.') {
        continue;
      }

      bool ok = false;
      if (h > 0) {
        if (S[h - 1][w] == '#') {
          ok = true;
        }
      }
      if (h < H - 1) {
        if (S[h + 1][w] == '#') {
          ok = true;
        }
      }
      if (w > 0) {
        if (S[h][w - 1] == '#') {
          ok = true;
        }
      }
      if (w < W - 1) {
        if (S[h][w + 1] == '#') {
          ok = true;
        }
      }

      if (!ok) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

type work struct {
	a int
	b int
}

type works []work

func (a works) Len() int {
	return len(a)
}

func (a works) Swap(i,j int) {
	a[i],a[j] = a[j],a[i]
}

func (a works) Less(i,j int) bool {
	return a[i].b < a[j].b
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()

	w := make(works,n)
	for i := 0; i < n; i++ {
		w[i].a, w[i].b = scanInt(), scanInt()
	}

	sort.Sort(w)
	f := true

	t := 0
	for _, e := range w {
		if t+e.a>e.b {
			f = false
			break
		}
		t += e.a
	}

	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	
}


Measured memory_bytes: 6272
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,m = myinput()
a = list(myinput())

ans = n - sum(a)

if ans<0:
    print(-1)
else:
    print(ans)

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


int main()
{
	int a,b,cost;
	cin >> a >> b;
	if(a >= 13){
		cost = b;
	}
	else if(a >= 6 && a <= 12){
		cost = b/2;
	}
	else
		cost = 0;
	cout << cost;
	
	
}	


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace q2
{
    class Program
    {
        static void Main(string[] args)
        {
            var values1 = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            var values2 = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            var N = values1[0];
            var M = values1[1];
            var cnt = 0;
            var total = 0;
            foreach (var v in values2)
            {
                total += v;
            }
            foreach (var v in values2)
            {
                if ((v*(4 * M)) >= total)
                {
                    cnt += 1;
                }
            }
            var result = cnt >= M;
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
int main() {
    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;
    std::string s = { "No" };
    if (x >= r && x <= w - r && y >= r && y <= h - r) {
        s = "Yes";
    }
    std::cout << s << std::endl;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n,m,k,a[N],b[N],cur,got,i;
ll pre[N];
ll bs(ll v){
    ll l,mid,h;
    l = 1; h = m;
    while(l <= h){
        mid = (l + h)/2;
        if (pre[mid] <= v) l = mid + 1;
        else h = mid - 1;
    }
    return h;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n>>m>>k;
    for (i = 1;i <= n;i++)  cin>>a[i];
    for (i = 1;i <= m;i++){
        cin>>b[i];
        cur += b[i];
        pre[i] = cur;
    }
    cur = 0;
    ll maxx = 0;
    for (i = 0;i <= n;i++){
        cur += a[i]; got = k - cur;
        if (got < 0) continue;
        ll p = bs(got);
        maxx = max(maxx,i + p);
    }
    cout<<maxx;
}



Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e7+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
ll nm[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	for(int i=1;i<=n;i++)
  		for(int j=1;j<=n/i;j++)
  			nm[i*j]++;
  	ll ans=0;
  	for(int i=1;i<=n;i++)
  		ans+=nm[i]*i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81732
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=500+10;
bool bz[maxn];
int cnt[maxn];
int x[maxn],b[maxn],a[maxn*maxn];
int i,j,k,l,t,n,m,tot,top;
bool czy;
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&t);
		a[x[i]=t]=i;
	}
	fo(i,1,n*n) 
		if (a[i]) b[++top]=a[i];
	fo(i,1,n) cnt[i]=i-1;
	fo(i,1,n*n)
		if (!a[i]){
			fo(j,1,n)
				if (cnt[b[j]]){
					a[i]=b[j];
					cnt[b[j]]--;
					break;
				}
		}
	fo(i,1,n) cnt[i]=n-i;
	fd(i,n*n,1)
		if (!a[i]){
			fd(j,n,1)
				if (cnt[b[j]]){
					a[i]=b[j];
					cnt[b[j]]--;
					break;
				}
		}
	czy=1;
	fo(i,1,n){
		tot=0;
		fo(j,1,n*n)
			if (a[j]==i){
				tot++;
				if (tot==i) break;
			}
		if (j!=x[i]){
			czy=0;
			break;
		}
	}
	if (!czy) printf("No\n");
	else{
		printf("Yes\n");
		fo(i,1,n*n) printf("%d ",a[i]);
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=a+b)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
//var input = 1463616;
var n = parseInt(input);
var on = n;

var primes = [];
while (n % 2 == 0) {
    primes.push(2);
    n = n / 2;
}
for (var i = 3; i * i <= n * n; i += 2) {
    while (n % i == 0) {
        primes.push(i);
        n /= i;
    }
}
if (n > 1) primes.push(n);

console.log(on + ': ' + primes.join(' '));


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

int main() {
  int N,L,sum;
  cin >> N;
  L = log10(N);
  int Sum =0;
  int n =N;
  for (int i=0; i<=L; L--){
    sum = n/(pow(10,L));
    Sum += sum;
    n -= sum*pow(10,L); 
  }
  if (N%Sum == 0) {
    cout << "Yes" << endl;
  }
  else { 
    cout << "No" << endl;
  }
}


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
 ll n,m ;
  cin >> n>>m;
  vvi graph(100005);
    for (int j = 0; j <n +1; ++j) {
        graph[j]= vi () ;
    }

    for (int a,b, i = 0; i <n ; ++i) {
        cin >> a>>b;
        graph[a].pb(b);
    }
    priority_queue <int> qq;
ll res =0;
    for (int k = 1; k <=m ; ++k) {
        FORR(el,graph[k])qq.push(el);

        if(qq.size()){
            res+=qq.top();
            qq.pop();
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int n;cin>>n;
    VI A(n);
    rep(i,n)cin>>A[i];
    ll ans=0;
    ll m=A[0];
    rep(i,n){
        if(m>A[i]){
            ans+=m-A[i];
        }
        else{
            m=A[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}


int main(){
	int n;
	cin>>n;
	int a[n];
	bool ok=false;
	rep(i,n){
		cin>>a[i];
		if(a[i]==1) ok=true;
	}
	if(!ok){
		cout<<-1<<endl;
		return 0;
	}
	int b=1;
	int ans=0;
	rep(i,n){
		if(a[i]==b) b++;
		else ans++;
	}
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) cout << "3C" << (n % 39 < 10 && n % 39 != 0 ? "0" : "") << (!(n % 39) ? 39 : n % 39) << endl;
}

Measured memory_bytes: 3140
n,x,y = map(int,input().split())
al = [0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        if i <= x:
            if j <= x:
                al[j-i-1] += 1
            elif j <= y:
                now = min(j-i,y-j+(x-i)+1)
                al[now-1] += 1
            else:
                al[j-y+(x-i)] += 1
        elif i <= y:
            if j <= y:
                now = min(j-i,y-j+(i-x)+1)
                al[now-1] += 1
            else:
                now = min(j-i,j-y+(i-x)+1)
                al[now-1] += 1
        else:
            al[j-i-1] += 1
for i in al:
    print(i)

Measured memory_bytes: 3444
N=int(input())
Sdict={}

for i in range(N):
	s=input()
	if s in Sdict:
		Sdict[s]+=1
	else:
		Sdict[s]=1

vmax=max(Sdict.values())

#Sdict_sorted=sorted(Sdict.items(), key=lambda x:x[1])
#print(Sdict_sorted)

anskeys = [k for k, v in Sdict.items() if v == vmax]
for ans in sorted(anskeys):
	print(ans)

Measured memory_bytes: 145296
#include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 1000, ave = 0; 
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1000000000000000007
#define pb emplace_back
typedef vector<int> vi;

void solve(){
int a=0,w=0,l=0,q=0,m=0,r=0,p=0,x=0,y=0,n=0;
cin>>a;
cout<<a+pow(a,2)+pow(a,3)<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
  	solve();
  }
  return 0;
} 	

Measured memory_bytes: 4300
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

vector<ll> L,P;
ll f(ll l,ll x){
	if(l==0){
		return x<=0 ? 0LL : 1LL;
	}
	else if(x<=L[l-1]+1) return f(l-1,x-1);
	else return P[l-1]+1LL+f(l-1,x-2-L[l-1]);
}

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

	ll N=in<ll>(),X=in<ll>();
	L.resize(N+1),P.resize(N+1);
	L[0]=1LL,P[0]=1LL;
	for(int i=1;i<N+1;i++){
		L[i] = 2*L[i-1]+3LL;
		P[i] = 2*P[i-1]+1LL;
	}

	ll c = f(N,X);

	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    string a;
    cin>>a;
    int n=a.length();
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<i+1<<" "<<i+2;
            return 0;
        }
        if(i<n-2)
        {
            if(a[i]==a[i+2])
            {
                cout<<i+1<<" "<<i+3<<"\n";
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1;
} 


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

  int max_n = max(a+b, a-b);
  
  cout << max(max_n, a*b) << endl;

}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
    
  if ((A+B)>(C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B)<(C+D)){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF (int)(2e18) //1e16
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
 
using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T; 
    int a,b,da,db;
    cin>>a>>b>>n>>m;
    cout<<max({a*n,a*m,b*n,b*m});
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;

signed main()
{
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    rep(i, N-1) {
        if (A[i] == A[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
ans = []

n, L = map(int, input().split())
A = list(map(int, input().split()))

que = deque()
for i, a in enumerate(A):
    while que and a <= que[-1][1]:
        que.pop()
    que.append((i,a))

    ans.append(que[0][1])

    if que and que[0][0] <= i+1-L:
        que.popleft()
    
ans = ans[L-1:]
print(*ans)



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

using namespace std;
typedef long long ll;
int n;
ll a[1000005], s[1000005];
ll cal(ll x1, ll x2, ll x3, ll x4){
	if(x1 < x2) swap(x1, x2);
	if(x1 < x3) swap(x1, x3);
	if(x1 < x4) swap(x1, x4);
	if(x2 < x3) swap(x2, x3);
	if(x2 < x4) swap(x2, x4);
	if(x3 < x4) swap(x3, x4);
	return x1 - x4;
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &a[i]);
		s[i] = s[i - 1] + a[i];
	}
	ll ans = 1e18;
	for(int i = 2; i <= n - 2; i ++){
		ll s1 = s[i] / 2;
		int pos1 = lower_bound(s + 1, s + i, s1) - s;
		ll s2 = (s[n] - s[i]) / 2;
		int pos2 = lower_bound(s + i + 1, s + n, s2 + s[i]) - s;
		if(pos1 >= 1 && pos1 < i && pos2 > i && pos2 < n){
			ans = min(ans, cal(s[pos1], s[i] - s[pos1], s[pos2] - s[i], s[n] - s[pos2]));
		}
		if(pos1 - 1 >= 1 && pos1 - 1 < i && pos2 > i && pos2 < n){
			ans = min(ans, cal(s[pos1 - 1], s[i] - s[pos1 - 1], s[pos2] - s[i], s[n] - s[pos2]));
		}
		if(pos1 >= 1 && pos1 < i && pos2 - 1 > i && pos2 - 1 < n){
			ans = min(ans, cal(s[pos1], s[i] - s[pos1], s[pos2 - 1] - s[i], s[n] - s[pos2 - 1]));
		}
		if(pos1 - 1>= 1 && pos1 - 1 < i && pos2 - 1 > i && pos2 - 1 < n){
			ans = min(ans, cal(s[pos1 - 1], s[i] - s[pos1 - 1], s[pos2 - 1] - s[i], s[n] - s[pos2 - 1]));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int cnt[100001][2] = {};
	for(int i = 0; i < n; i++){
		int v;
		cin >> v;
		cnt[v][i % 2]++;
	}
	int res[2][2] = {};
	for(int i = 0; i < 2; i++){
		for(int j = 1; j <= 100000; j++){
			if(cnt[j][i] > cnt[res[i][0]][i]){
				res[i][1] = res[i][0];
				res[i][0] = j;
			}
			else if(cnt[j][i] > cnt[res[i][1]][i]) res[i][1] = j;
		}
	}
	if(res[0][0] != res[1][0]) cout << n - cnt[res[0][0]][0] - cnt[res[1][0]][1] << endl;
	else cout << n - max(cnt[res[0][0]][0] + cnt[res[1][1]][1], cnt[res[0][1]][0] + cnt[res[1][0]][1]) << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, M; cin >> N >> M;
    dsu uf(N);
    rep(i, M) {
        int A, B; cin >> A >> B;
        uf.merge(--A, --B);
    }
    set<int> s;
    rep(i, N) s.insert(uf.leader(i));
    cout <<  s.size()- 1 << endl;
}


Measured memory_bytes: 7480
N,Y=map(int, input().split())
count=0

for i in range(N+1):
    if count==0:
        pass
    else:
        break
    for j in range(N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            print(i,j,N-i-j)
            count+=1
            break
        else:
            pass
if count==0:
    print(-1,-1,-1)
else:
    pass


Measured memory_bytes: 3060
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

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;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	int ans = 1;
	int max_num = 0;
	for (int i = 1; i <= n; ++i)
	{
		int num = 0;
		int val = i;
		while (val % 2 == 0)
		{
			num++;
			val /= 2;
		}
		if (max_num < num)
		{
			max_num = num;
			ans = i;
		}
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)

string S;
int mem[3000];
int ans, mod = 2019;

signed main()
{
    cin >> S;
    reverse(S.begin(), S.end());

    int now = 0, tmp = 1;
    mem[0] = 1;
    for(auto e : S)
    {
        now = (now + (e - '0') * tmp) % mod;
        ans += mem[now];
        mem[now]++;
        tmp = (tmp * 10) % mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3708
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

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

    	int N=sc.nextInt();

    	int A=0;
    	int B=0;
    	int min=99999999;
    	for(int i=1;i<N;i++) {
    		A=i;
    		B=N-A;

    		if(min>getdigitsum(A)+getdigitsum(B)) {
    			min=getdigitsum(A)+getdigitsum(B);
    		}
    	}

    	System.out.println(min);


    }

    public static int getdigitsum(int d) {
    	int result=0;
    	while(d>0) {
    		result+=d%10;
    		d/=10;
    	}

    	return result;
    }
}


Measured memory_bytes: 23892
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);

int cmb(int n,int k){
    int res=1;
    int nn=n;
    int kk=1;
    for(int i=0;i<k;i++){
        res*=nn-i;
        res/=kk+i;
    }
    return res;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(rall(v));
    double sum=0;
    rep(i,a) sum+=v[i];
    cout<<(double)(sum/a)<<endl;
    int memo=v[a-1];
    int nn=0;
    rep(i,n){
        if(v[i]==memo) nn++;
    }
    int ans=0;
    for(int k=a;k<=b;k++){
        int kk=0;
        rep(i,k){
            if(v[i]==memo) kk++;
        }
        if(v[0]==v[k-1]) ans+=cmb(nn,kk);
        else if(k==a) ans+=cmb(nn,kk);
        // cout<<k<<endl;
    }
    cout<<ans<<endl;
    
}

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

int main()

{
	long double a ,b,c;
	cin>>a>>b>>c;
	long double eps = 1.0E-14;

 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }

 return 0;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>	// require fabs, sqrt
using namespace std;

int main()
{
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	for (int i = 0; i < n; ++i){
		getline (cin, str );
		vector <double> cx (2, 0.0), cy (2, 0.0), r (2, 0.0);
		stringstream ss(str);

		ss >> cx[0] >> cy[0] >> r[0] >> cx[1] >> cy[1] >> r[1];
		double d = sqrt ( (cx[1] - cx[0])*(cx[1] - cx[0]) + (cy[1] - cy[0])*(cy[1] - cy[0]) );

		if (d >= 0 && d < fabs (r[1] - r[0])){
			if (r[0] > r[1]){		// B in A
				cout << "2" << endl;
			}else if (r[0] < r[1]){	// A in B
				cout << "-2" << endl;
			}else{
				cout << "1" << endl;
			} // end if
		}else if ( ( d >= fabs(r[1] - r[0]) ) && ( d <= r[0] + r[1] ) ){
			cout << "1" << endl;
		}else{
			cout << "0" << endl;
		} // end if
	} // end for
		
	return 0;
}

Measured memory_bytes: 0