akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long h = scanner.nextInt();
        final long w = scanner.nextInt();

        System.out.println(Math.min(calcMin(h, w), calcMin(w, h)));
    }

    private static long calcMin(final long a, final long b) {
        long min = Long.MAX_VALUE;
        for (long i = 1; i < a; i++) {
            final long p = i * b;

            final long p1 = (a - i) / 2 * b;
            if ((a - i) % 2 == 0) {
                min = Math.min(min, Math.abs(p - p1));
            } else {
                final long p2 = ((a - i) / 2 + 1) * b;
                min = Math.min(min, max(p, p1, p2) - min(p, p1, p2));
            }

            final long p3 = (a - i) * (b / 2);
            if (b % 2 == 0) {
                min = Math.min(min, Math.abs(p - p3));
            } else {
                final long p4 = (a - i) * (b / 2 + 1);
                min = Math.min(min, max(p, p3, p4) - min(p, p3, p4));
            }
        }
        return min;
    }

    private static long max(final long... values) {
        Arrays.sort(values);
        return values[values.length - 1];
    }

    private static long min(final long... values) {
        Arrays.sort(values);
        return values[0];
    }
}


Measured memory_bytes: 36820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll k;
    cin >> k;
    ll a, b;
    cin >> a >> b;
    string ans = "NG";
    for (int i=1; i*k<1001; i++){
        if (a<=i*k & i*k <= b) ans = "OK";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if(s.size() > k) 
         s=s.substr(0,k)+"...";
    cout << s << endl;
}

Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

MAX_P = 0
MIN_P = 10 ** 10
MAX_M = -(10 ** 10)
MIN_M = 10 ** 10

for x, y in XY:
    P = x + y
    M = x - y

    MAX_P = max(MAX_P, P)
    MIN_P = min(MIN_P, P)

    MAX_M = max(MAX_M, M)
    MIN_M = min(MIN_M, M)

ans = max(MAX_P - MIN_P, MAX_M - MIN_M)

print(ans)



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

namespace EDPC_B
{
    class Program
    {
        public Program() { }

        static void Main(string[] args)
        {
            new Program().Calc();
        }

        Scanner cin;

        int[] _height;
        int[] _minCost;

        int k;

        void Calc()
        {
            cin = new Scanner();

            int n = cin.nextInt();

            k = cin.nextInt();
            _height = cin.ArrayInt(n);

            _minCost = new int[n];
            for (int i = 0; i < n; ++i) { _minCost[i] = int.MaxValue; }

            int ans = MinCostRec(n - 1);

            Console.WriteLine(ans);
        }

        int MinCostRec(int index)
        {
            int minCost = _minCost[index];
            if (minCost != int.MaxValue) { return minCost; }

            if (index == 0) { return 0; }

            minCost = Math.Abs(_height[index] - _height[index - 1]) + MinCostRec(index - 1);

            int jumpCount = k;
            if (index < jumpCount) { jumpCount = index; }

            for (int i = 2; i <= jumpCount; ++i)
            {
                minCost = Math.Min(minCost, Math.Abs(_height[index] - _height[index - i]) + MinCostRec(index - i));
            }

            return (_minCost[index] = minCost);
        }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

}


Measured memory_bytes: 23520
import sys
# sys.setrecursionlimit(100000)
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    S = input()
    stack = []
    for s in S:
        if not stack:
            stack.append(s)
        elif s == "(":
            stack.append(s)
        elif s == ")":
            if stack[-1] == "(":
                stack.pop()
            else:
                stack.append(s)
    cnt = defaultdict(int)
    for s in stack:
        cnt[s] += 1
    left = cnt[")"]
    right = cnt["("]
    ans = ("(" * left) + S + (")" * right)
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 64772
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) (a<b)? a:b; 
#define max(a,b) (a>b)? a:b; 

long long gcd(long long c,long long d){
  return (c%d==0)? d:gcd(d,c%d);
}

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

int main()
{
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  A--;
  
  long long B_C=(B-B%C)/C;
  long long B_D=(B-B%D)/D;
  long long B_CD=(B-B%lcd(C,D))/lcd(C,D);
  long long A_C=(A-A%C)/C;
  long long A_D=(A-A%D)/D;
  long long A_CD=(A-A%lcd(C,D))/lcd(C,D);
  long long cnt=B_C-A_C+B_D-A_D-(B_CD-A_CD);
  
  cout<<B-A-cnt;
}


Measured memory_bytes: 764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x := iSScan(3)
	sort.Sort(sort.Reverse(sort.IntSlice(x)))
	ans := x[0] - x[1]
	x[2] += ans
	if x[2] == x[0] {
		fmt.Println(ans)
	} else if x[2]%2 == x[0]%2 {
		fmt.Println(ans + (x[0]-x[2])/2)
	} else {
		fmt.Println(ans + (x[0]-x[2])/2 + 2)
	}
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

llong func(llong n){
    if(n == 0) return 1;
    return n*func(n-1)%MOD;
}

int main()
{
llong n,m;
cin>>n>>m;
llong ans;
if(abs(n-m)>1) ans=0;
else if(abs(n-m)==1) ans=func(n)*func(m)%1000000007;
else if(n==m) ans=2*func(n)*func(m)%1000000007;

cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define infinity 1e18
using namespace std;

ll dp[401][401];
ll s[401];

ll sum(ll i, ll j)
{
    if(i == 0)
    return s[j];
    
    return (s[j] - s[i-1]);
}

ll fun(ll i, ll j)
{
    //Base Case
    if(i == j)
    return 0;
    if(i > j)
    return 0;
    
    //Lookup
    if(dp[i][j] != -1)
    return dp[i][j];
    
    //Rec Case
    ll ans = infinity;
    for(ll k=i;k<j;k++)
    {
        ans = min(ans, fun(i,k)+fun(k+1,j)+sum(i,j));
    }
    
    return dp[i][j] = ans;
}

int main()
{
    fast_io;
    
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    cin>>s[i];
    
    for(ll i=1;i<n;i++)
    {
        s[i] += s[i-1];
    }
    memset(dp,-1,sizeof(dp));
    
    cout<<fun(0,n-1)<<endl;
    
    return 0;
}

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

typedef long long ll;

int main() {
	ll n,a,b,c,d; cin>>n>>a>>b>>c>>d;
	n--;
	
	for (ll x = 0, y = n; x <= n; x++,y--) {
		if (a + x*c - y*d <= b && b <= a + x*d - y*c) {
			cout<<"YES"<<endl; return 0;
		}
	}
	
	cout<<"NO"<<endl; return 0;
}	
	


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


N, K = map(int, input().split())


def Base_10_to_n(X, n):
	if (int(X/n)):
		return Base_10_to_n(int(X/n), n)+str(X%n)
	return str(X%n)

print(len(Base_10_to_n(N, K)))


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,e) for(int i=s;i<e;i++)

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (b % a == 0)cout << b / a << endl;
	else cout << int(b / a) + 1 << endl;
	return 0;
}


Measured memory_bytes: 3112
mapping = {}
def find(l, e, start, end):
	global mapping
	if e in mapping:
		return mapping[e]
	mid = (start+end)//2
	if (l[mid] == e):
		mapping[e] = (e, e)
		return mapping[e]
	elif (l[mid] > e):
		if (l[mid-1] < e):
			mapping[e] = (l[mid-1], l[mid])
			return mapping[e]
		return find(l, e, start, mid)
	elif (l[mid] < e):
		if (l[mid+1] > e):
			mapping[e] =  (l[mid], l[mid+1])
			return mapping[e]
		return find(l, e, mid, end)

def print_sum(input):
	global mapping
	mapping = {}
	d, n, m = input[0], input[1], input[2]
	S, K = input[3:3+n-1], input[3+n-1:]
	S = sorted(S)
	S = [S[-1]-d, 0] + S + [d]
	sum = 0
	for k in K:
		low, high = find(S, k, 0, len(S))
		sum += min(k-low, high-k)
	print sum

while (True):
	d = int(raw_input())
	if d == 0: break
	n, m = int(raw_input()), int(raw_input())
	input = [d, n, m]
	for i in range(n-1+m):
		next_int = int(raw_input())
		input.append(next_int)
	print_sum(input)

Measured memory_bytes: 16380
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,n;
  cin >> N;
  int sum = 0;
  n = N;
  while(n >= 1){
    sum += n % 10;
    n /= 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

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

    int n, count = 0;
    cin >> n;
    vector<int> v(n);

    for (auto& i : v)
    {
        cin >> i;
    }
    for (auto& i : v)
    {
        while (true)
        {
            if (i % 2 == 0)
            {
                i /= 2;
                count++;
            }
            else
            {
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
package main

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

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

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	n, k, c := bs.IntScan(), bs.IntScan(), bs.IntScan()
	s := strings.Split(bs.Scan(), "")

	l := make([]string, n)
	r := make([]string, n)

	var index int
	var lCount int
	lPos := []int{}
	var rCount int

	index = 0
	for {
		if s[index] == "o" {
			l[index] = "o"
			lCount++
			lPos = append(lPos, index)
			index += c
		}
		index++
		if index >= n {
			break
		}
	}

	index = n - 1
	for {
		if s[index] == "o" {
			ok := true
			for i:=1; i<=c; i++ {
				if index + i >= n {
					break
				}
				if r[index+i] == "o" {
					ok = false
					break
				}
			}
			if ok {
				rCount++
				r[index] = "o"
			}
		}
		index--
		if index < 0 {
			break
		}
	}

	if lCount == rCount && lCount == k {
		for _, i := range lPos {
			if l[i] == "o" && l[i] == r[i] {
				bw.Printf("%v\n", i+1)
			}
		}
	}
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

int main()
{
   int N;
   int A[100];

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

   int M = 0;
   
   for(int i=0; i<N; i++)
   { 
   	 for(int j=0; j<N; j++)
     {
        M =  max(M, abs(A[i]-A[j]));
     }
   }

   cout << M << endl;

   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















class dinic {
private:
    struct edge {
        ll to, cap, rev;
    };
    vector<vector<edge>> list;  // グラフの隣接リスト
    vector<ll> level;    // sからの距離
    vector<ll> iter;     // どこまで調べ終わったか
public:
    dinic(ll n) : list(n), level(n), iter(n){}
    
    void add_edge(ll from, ll to, ll cap){
        list[from].push_back({to, cap, (ll)list[to].size()});
        list[to].push_back({from, 0, (ll)list[from].size() - 1});
    }
    
    void bfs(ll s){
        level.assign(level.size(), -1);
        queue<ll> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            ll v = que.front(); que.pop();
            for(auto &x : list[v]){
                if(x.cap > 0 && level[x.to] < 0){
                    level[x.to] = level[v] + 1;
                    que.push(x.to);
                }
            }
        }
    }
    
    ll dfs(ll v, ll t, ll f){
        if(v == t) return f;
    
        for(ll &i = iter[v]; i < list[v].size(); i++){
            edge &e = list[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                ll d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    list[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    ll max_flow(ll s, ll t){
        ll flow = 0;
    
        for(;;){
            bfs(s);
            if(level[t] < 0) return flow;
            
            iter.assign(iter.size(), 0);
            
            ll f;
            while((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }
};

int main(){
    ll h, w;
    cin >> h >> w;
    dinic dic(h + w + 2);
    REP(i, h){
        string s;
        cin >> s;
        REP(j, w){
            if(s[j] == 'o'){
                dic.add_edge(i, h + j, 1);
                dic.add_edge(h + j, i, 1);
            }
            if(s[j] == 'S'){
                dic.add_edge(h + w, i, INF);
                dic.add_edge(h + w, h + j, INF);
            }
            if(s[j] == 'T'){
                dic.add_edge(i, h + w + 1, INF);
                dic.add_edge(h + j, h + w + 1, INF);
            }
        }
    }
    ll ans = dic.max_flow(h + w, h + w + 1);
    cout << ((ans < INF)? ans : -1) << endl;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	map<int, int> mp;
	int x = 0;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
		mp[a[i]]++;
		x ^= a[i];
	}

	if (x == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	sort(all(a));
	//if (mp.size() > 3) {
	//	cout << "No" << endl;
	//}
	//else {
	//	bool yes = true;
	//	if (mp.size() == 1) {
	//		if (mp[0] == 0)
	//			yes = false;
	//	}
	//	else if (mp.size() == 2) {
	//		if (mp[0] > 0) {
	//			if (mp[a.back()] != mp[0] * 2)
	//				yes = false;
	//		}
	//		else
	//			yes = false;
	//	}
	//	else {
	//		for (auto x : mp) {
	//			if (x.second != N / 3)
	//				yes = false;
	//		}
	//	}
	//	if (yes)cout << "Yes" << endl;
	//	else cout << "No" << endl;
	//}

	return 0;
}

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

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans;
	if (m <= 2 * n)ans = m / 2;
	else ans = n + (m - (2 * n)) / 4;
	cout << ans << endl;
}

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






int main() {
    int A, B;
    cin >> A >> B;
    int ans = A - (B * 2);
    if(ans <= 0) print(0);
    else print(ans);
}



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

int main(){
    ll n, k;    cin >> n >> k;
    map<ll, ll> ball;
    for(int i=0; i<n; i++){
        ll x;   cin >> x;
        ball[x] += 1;
    }
    vector<ll> a;
    for(auto x: ball)   a.push_back(x.second);

    sort(a.begin(), a.end());
    ll sum=0;
    if(k<a.size())
        for(int i=0; i<a.size(); i++){
            sum += a.at(i);
            if(a.size()-(i+1)==k) break;
        }
    cout << sum << endl;
}

Measured memory_bytes: 14964
import numpy as np
N, M = map(int, input().split())
LL, RR = map(int, input().split())
for i in range(M-1):
    L, R = map(int, input().split())
    LL = max(L, LL)
    RR = min(R, RR)
print(max(RR-LL+1,0))

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

using namespace std;

typedef long long int64;

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

	int n; cin >> n;

	vector<int64> value(n);

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

	sort(value.begin(), value.end());

	vector<int64> acc(n + 1);

	for (int i = 1; i <= n; ++i)
		acc[i] = acc[i - 1] + value[i - 1];

	int p = n;

	while (p > 1){
		if (value[p - 1] <= 2 * acc[p - 1])
			p--;
		else
			break;
	}

	cout << n - p + 1 << endl;

	return 0;
}


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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;

void solve() {
  ll k, a, b;
  cin >> k >> a >> b;
  ll x = 1;
  ll c = 0;
  while(true) {
    c = k * x;
    if (c > b) {
      PRINT("NG"); 
      break;
    } else if (c >= a && c <=b) {
      PRINT("OK");
      break;
    }
    x++;
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#define Maxn 52

using namespace std;

int A[Maxn], B[Maxn], C[Maxn];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> A[i];
	for(int i = 1; i <= n; i++)
		cin >> B[i];
	for(int i = 1; i <= n-1; i++)
		cin >> C[i];
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		sum += B[A[i]];
		if(A[i] == A[i-1]+1)
			sum += C[A[i-1]];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
 
int main() {

	
  
    lld n,x,t;
    cin>>n>>x>>t;

    lld c=ceil(n*1.0/x);

    cout<<c*t;


  
  return 0;
}

Measured memory_bytes: 3712
a=int(input())
b=[]
c=[0,0,0,0,0,0,0,0,0]
ans1=0
ans2=0
jdg=0

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

for i in range(a):
    if(int(b[i])<3200):
        jdg=int(b[i]/400)
        c[jdg]+=1
    else:
        c[8]+=1

for i in range(8):
    if(c[i] >= 1):
        ans1+=1
ans2=ans1+c[8]
if(ans1==0):
    ans1=1

print('%d %d' % (ans1, ans2))


Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
using namespace std;
const int MAXN=1005;
 
int n;
long long A[MAXN];
bool keep[MAXN];
 
vector<int> ans;
 
void del(int pos)
{
	for(int i=pos;i<=n;i++)
		A[i]=A[i+1],keep[i]=keep[i+1];
	n--;
}
 
int main()
{
	scanf("%d",&n);
	bool flag=false;
	for(int i=1;i<=n;i++)
		scanf("%lld",A+i),flag|=(A[i]>0);
	if(flag==false)
	{
		int mx=-0x7FFFFFFF,pos;
		for(int i=1;i<=n;i++)
			if(mx<A[i])
				mx=A[i],pos=i;
		printf("%d\n%d\n",mx,n-1);
		for(int i=1;i<pos;i++)
			printf("1\n");
		for(int i=n-pos+1;i>=2;i--)
			printf("%d\n",i);
		return 0;
	}
	long long sum1=0,sum2=0;
	for(int i=1;i<=n;i+=2)
		if(A[i]>0)
			sum1+=A[i];
	for(int i=2;i<=n;i+=2)
		if(A[i]>0)
			sum2+=A[i];
	if(sum1>sum2)
	{
		for(int i=1;i<=n;i+=2)
			if(A[i]>0)
				keep[i]=true;
	}
	else
	{
		for(int i=2;i<=n;i+=2)
			if(A[i]>0)
				keep[i]=true;
	}
	
	while(n>1)
	{
		if(keep[1]==false)
		{
			ans.push_back(1);
			del(1);
			continue;
		}
		if(keep[n]==false)
		{
			ans.push_back(n);
			del(n);
			continue;
		}
		bool flag=false;
		for(int i=2;i<n;i++)
			if(keep[i-1]&&keep[i+1])
			{
				ans.push_back(i);
				A[i-1]+=A[i+1];
				del(i);
				del(i);
				flag=true;
				break;
			}
		if(flag)continue;
		for(int i=2;i<n;i++)
			if(!keep[i-1]&&!keep[i+1])
			{
				ans.push_back(i);
				A[i-1]+=A[i+1];
				del(i);
				del(i);
				break;
			}
	}
	printf("%lld\n",A[1]);
	printf("%d\n",(int)ans.size());
	for(int i=0;i<(int)ans.size();i++)
		printf("%d\n",ans[i]);
	
	return 0;
}

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

using namespace std;
#define ll long long
int dp[3000][3000] , mx;
string s,s2;

ll solve(int i , int j)
{
    if (i==s.size() || j==s2.size()) return 0;

    if (dp[i][j] != -1) return dp[i][j];

    ll  ans=0;
    if (s[i]==s2[j]) ans = max(ans , solve(i+1 , j+1)+1);
    else
    {
        ans = max( solve(i+1 , j) , solve(i , j+1));
    }
    return dp[i][j]=ans;
}
/*
ll solve(int nn , bool b)
{

    if (!nn && b) return dp[0]=1;
    if (!nn && !b) return 0;
     if (dp[nn] != -1) return dp[nn];
    ll ans=0;
    for (int i=1; i<=k; i++)
    {
        if (nn-i >=0 )
        {
            if (i>=d) ans = ( ans%mod + solve(nn-i , 1)%mod )%mod;
            else ans = ( ans%mod + solve(nn-i , b)%mod )%mod;
        }
    }

    dp[nn]=ans;

    return ans;
} if (dp[nn] != -1) return dp[nn];
*/

int main()
{
    memset(dp , -1 , sizeof(dp));

    /*
    cin >> n >> k >> d; if (dp[nn] != -1) return dp[nn];
    cout << solve(n , 0) << "\n";
    cout << dp[1] << " " << dp[2] << " " << dp[3] << "\n";
    */

    cin >> s >> s2;
    mx = solve(0,0);
    int i = 0, j = 0;
    while(i<s.size() && j<s2.size())
    {
        if (s[i]==s2[j])
            cout << s[i], i++, j++;
        else
            if (solve(i+1 , j) > solve(i , j+1)) i++;
            else j++;
    }

    return 0;
}


Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
static const int MAX = 200000;
void show_st(int *st, int N)
{
  for(int i = 0; i < N ; i++)
  {
    if(i > 0)cout << " ";
    cout << st[i];
  }
  cout << endl;
  cout << st[N] << endl;//交換回数の表示
}
void sort_2(int *st, int N)
{
  int tmp,cnt = 0;
  for(int i = 0 ; i < (N - 1) ; i++)
  {
    for(int j =(N -1); j > i; j--)
    {
      if(st[j] < st[j - 1])
      {
        tmp = st[j - 1];
        st[j - 1] = st[j];
        st[j] = tmp;
        cnt ++;
      }
    }
  }
  st[N] = cnt;
}
int main()
{
  int n,R[MAX];
  cin >> n;
  for(int i = 0; i < n ; i++ )cin >> R[i];
  sort_2(R,n);
  show_st(R,n);
  return 0;
}


Measured memory_bytes: 3036
N,A,B,C = map(int,input().split())
L = [int(input()) for i in range(N)]

from itertools import product

ans = 10**10
for pro in product([0,1,2,3], repeat= N):
    cost,lena,lenb,lenc = -30,0,0,0
    for i in range(N):
        if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
    if lena == 0 or lenb == 0 or lenc == 0:
        continue
    cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc)
    ans = min(ans,cost)
print(ans)


Measured memory_bytes: 3064
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 3e3+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

db p[maxn];
db dp[maxn][maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n;
    scanf("%d", &n);

    for(int i = 1; i <= n; i++) scanf("%lf", &p[i]);

    db answer = 0.0;
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            if(j > 0)   dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
            else        dp[i][j] = dp[i - 1][j] * (1 - p[i]);
        }
    }
    for(int j = n / 2 + 1; j <= n; j++) answer += dp[n][j];

    printf("%.10f\n", answer);


    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

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

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

  while(n) {
    if (n % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }

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


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 1005
const ll INF = 1e9 + 7;

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

int h, w;
char mp[ARRAY_MAX][ARRAY_MAX];
int cost[ARRAY_MAX][ARRAY_MAX];


int main() {

	cin >> h >> w;
	queue<pii> que;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cost[i][j] = -1;
		}
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> mp[i][j];
			if (mp[i][j] == '#')
			{
				que.push(pii(i, j));
				cost[i][j] = 0;
			}
		}
	}

	while (!que.empty())
	{
		int y = que.front().first;
		int x = que.front().second;
		que.pop();

		for (int i = 0; i < 4; i++)
		{
			int ny = y + dy[i];
			int nx = x + dx[i];

			if (0 <= nx && nx < w && 0 <= ny && ny < h && mp[ny][nx] == '.' && cost[ny][nx] == -1)
			{
				que.push(pii(ny, nx));
				cost[ny][nx] = cost[y][x] + 1;
			}
		}
	}
	
	int maxi = 0;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			maxi = max(maxi, cost[i][j]);
		}
	}
	cout << maxi << endl;

	return 0;
}





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

using u64 = uint64_t;

u64 eval(const std::vector<u64> &xs, size_t ix)
{
    u64 sum = 0;
    for (auto x : xs) {
        if (x > xs[ix]) {
            sum += x - xs[ix];
        } else {
            sum += xs[ix] - x;
        }
    }
    return sum;
}

int main()
{
    u64 n;
    std::vector<u64> as;
    std::cin >> n;
    for (u64 i = 0; i < n; i++) {
        u64 a;
        std::cin >> a;
        as.push_back(a + n - i);
    }
    std::sort(as.begin(), as.end());

    if (as.size() % 2 == 1) {
        size_t ix = as.size() / 2;
        std::cout << eval(as, ix) << std::endl;;
    } else {
        size_t ix1 = as.size() / 2;
        size_t ix2 = ix1 - 1;
        std::cout << std::min(eval(as, ix2), eval(as, ix2)) << std::endl;
    }

    
    return 0;
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	long long a[11000], b[11000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	long long suma = 0, sumb = 0;
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		long long d = a[i] - b[i];
		if (d < 0) {
			if (d % 2 == 0)suma += -d;
			else {
				suma += -d + 1;
				sumb++;
			}
		}
		else if (d > 0) {
			sumb += d;
		}

	}
	if (suma >= sumb * 2)cout << "Yes";
	else cout << "No";
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000], B[110000];
int D[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    rep(i, N) { cin >> B[i]; }
    rep(i, N) { D[i] = A[i] - B[i]; }
    int tarinai = 0, ans = 0;
    rep(i, N) {
        if (D[i] < 0) {
            tarinai -= D[i];
            ans++;
        }
    }
    sort(D, D + N), reverse(D, D + N);
    rep(i, N) {
        if (tarinai <= 0) { break; }
        tarinai -= D[i];
        ans++;
    }
    if (tarinai > 0) { cout << -1 << endl; }
    else { cout << ans << endl; }

}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
	long long int n,pow=1;
	cin >> n;
	for(int i=1; i<=n;i++){
		pow=pow*i;
		pow=pow%1000000007;
	}
	
	cout << pow << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
bool check(ll n){
    bool a=false, b=false ,c=false;
    string s = to_string(n);
    for(auto i:s){
        if(i=='7') a=true;
        if(i=='5') b=true;
        if(i=='3') c=true;
    }
    return a&b&c;
}

void calc(ll x){
    if(x>n) return;
    if(check(x)) ans++;
    calc(10*x+7);
    calc(10*x+5);
    calc(10*x+3);
}

int main(void){
    cin >> n;
    calc(0);
    cout << ans << endl;
    
}


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

using namespace std;

int main() {
                string S, T, U;
                int A, B;

                cin >> S >> T;
                cin >> A >> B;
                cin >> U;

                if (U == S) { A--; }
                if (U == T) { B--; }

                cout << A << " " << B << endl;
                return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  int n;
  cin>>n;
  
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  
  ll ans=A[0];
  for(int i=1;i<n;i++){
    ans=gcd(ans,A[i]);
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 4020
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $s=[];
  for($i=0;$i<$n;$i++){
    list($a) = explode(" ", trim(fgets(STDIN))); 
    if(!isset($s[$a])) $s[$a]=0;
    $s[$a]++;
  }

  list($m) = explode(" ", trim(fgets(STDIN)));
  $t=[];
  for($i=0;$i<$m;$i++){
    list($a) = explode(" ", trim(fgets(STDIN))); 
    if(!isset($t[$a])) $t[$a]=0;
    $t[$a]++;
  }

  $ans=0;
  foreach($s as $k => $v){
    $cnt=$v;
    if(isset($t[$k])){
      $cnt-=$t[$k];
    }
    $ans = max($ans, $cnt);
  }
  echo $ans;

Measured memory_bytes: 16188
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    set<int> s;
    int a ,b ,c;
    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
}

Measured memory_bytes: 256
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=[i+1 for i in range(n)]
p_num=-1
q_num=-1
for i,peri in enumerate(itertools.permutations(l,n)):
    peri=list(peri)
    if p_num==-1:
        flag=True
        for j in range(n):
            if peri[j]!=p[j]:
                flag=False
                break
        if flag:
            p_num=i
    if q_num==-1:
        flag=True
        for j in range(n):
            if peri[j]!=q[j]:
                flag=False
                break
        if flag:
            q_num=i
    if p_num!=-1 and q_num!=-1:
        break
if p_num>q_num:
    print(p_num-q_num)
else:
    print(q_num-p_num)


Measured memory_bytes: 74124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char S;
    cin >> S;
    if (S=='a'||S=='i'||S=='u'||S=='e'||S=='o'){
        cout << "vowel" <<endl;
    }
    else{
        cout << "consonant" <<endl;
    }

}

Measured memory_bytes: 764
s = input()

N,W,S,E = s.count("N"),s.count("W"),s.count("S"),s.count("E")

cond = 1

if N == 0 and S > 0:
	cond = 0
if S == 0 and N > 0:
	cond = 0
if W == 0 and E > 0:
	cond = 0
if E == 0 and W > 0:
	cond = 0

if cond:
	print("Yes")
else:
	print("No")

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

using namespace std;

long long ok(int x, int y){
	return x * 1LL * x + y * 1LL *  y;
}

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


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  vector<pair<int, int>> vp;
  for (int i = 0; i < m; i++) {
    int b, c;
    cin >> b >> c;
    vp.push_back(make_pair(c, b));
  }
  sort(vp.rbegin(), vp.rend());

  vector<int> d;
  for (int i = 0; i < vp.size(); i++) {
    for (int j = 0; j < vp[i].second; j++) {
      d.push_back(vp[i].first);
    }
    if (d.size() > n) {
      d.resize(n);
      break;
    }
  }

  for (int i = 0; i < d.size(); i++) {
    if (d.at(i) > a.at(i)) {
      a.at(i) = d.at(i);
    }
  }

  ll ans = 0;
  for (int x: a) {
    ans += x;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int A, B, C;
    cin >> A >> B >> C;
    REP (i, B) {
        if (A * (i + 1) % B == C) {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
n =  int(input())
a = 0

if n <= 0 or 1000 <= n:
  exit()
list1 = list(map(int, input().split()))
#i = 0の時はエラーが出る
for i in range(n-1, 0, -1):
  j = i
  while (j < n) and (list1[j] < list1[j-1]):
    tmp = list1[j-1]
    list1[j-1] =  list1[j]
    list1[j] = tmp
    j += 1
    a += 1
print(' '.join(map(str, list1)))
print(a)



Measured memory_bytes: 5592
#!/usr/bin/env python3
k, n = map(int, input().split())
a = list(map(int, input().split()))

ans = k

for i in range(len(a)):
    if i == 0:
        r = a[-1] - a[i]
        l = a[i] + (k - a[i + 1])
    elif i == n - 1:
        r = (k - a[i]) + a[i - 1]
        l = a[i] - a[0]
    else:
        r = (a[n-1] - a[i]) + ((k - a[n-1]) + a[i - 1])
        l = (a[i] - a[0]) + ((k - a[i + 1]) + a[i - 1])
    
    ans = min(ans, r, l)

print(ans)

Measured memory_bytes: 33688
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int flag = 1;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = n; i > 1; i--)
	{
		if (a[i] >= a[i - 1]) continue;
		a[i - 1]--;
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] >= a[i - 1]) continue;
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 768
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<Vec<char>> = (0..H).map(|_| {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    }).collect();

    const INF: i64 = 1_000_000_000;
    let mut q = std::collections::VecDeque::new();
    let mut dp = vec![vec![INF; W]; H];
    for i in 0..H {
        for j in 0..W {
            if A[i][j] == '#' {
                q.push_back((0, i, j));
                dp[i][j] = 0;
            }
        }
    }
    while let Some((d, i, j)) = q.pop_front() {
        for (u, v) in vec![(i + 1, j), (i.saturating_sub(1), j), (i, j + 1), (i, j.saturating_sub(1))] {
            if u < H && v < W && dp[u][v] > d + 1 {
                dp[u][v] = d + 1;
                q.push_back((d + 1, u, v));
            }
        }
    }
    let ans = dp.iter().map(|a| a.iter().max().unwrap()).max().unwrap();

    println!("{}", ans);
}

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

int main() {
    int N, Q;
    std::string S;
    std::cin >> N >> S >> Q;

    std::set<int> alpha[26];
    for (size_t i = 0; i < S.size(); ++i) {
        alpha[S[i] - 'a'].insert(i);
    }

    int v;
    for (int i = 0; i < Q; ++i) {
        std::cin >> v;
        if (v == 1) {
            int l;
            char r;
            std::cin >> l >> r;
            --l;
            const int c = r - 'a';
            for (int i = 0; i < 26; ++i) {
                if (alpha[i].count(l) == 1) {
                    alpha[i].erase(l);
                }
            }

            alpha[c].insert(l);
        } else {
            int l, r;
            std::cin >> l >> r;
            --l;
            --r;
            int cnt = 0;
            for (int i = 0; i < 26; ++i) {
                auto itr = alpha[i].lower_bound(l);
                if (itr != alpha[i].end() && *itr <= r) {
                    ++cnt;
                }
            }

            std::cout << cnt << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 27208