akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m, x) = readListOfInt() 
    val a = readListOfInt()
    val leftCost = a.count { it < x }
    val rightCost = a.count { it > x }
    println(Math.min(leftCost, rightCost))
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37748
//Name: Aizu PR
//Level: 1
//Category: 文字列,String,やるだけ
//Note:

#include <iostream>
#include <string>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    cin.ignore();
    for(int i = 0; i < N; ++i) {
        string str;
        getline(cin, str);
        while(true) {
            size_t pos = str.find("Hoshino");
            if(pos == string::npos) break;
            str = str.substr(0, pos) + "Hoshina" + str.substr(pos + 7);
        }
        cout << str << endl;
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;

	if(a ^ b && a ^ c && b ^ c) cout << 3 << endl;
	else if(a ^ b || a ^ c || b ^ c) cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
bool f[100010];
int c[100010];
bool prime(int);
int r,l;
int main()
{
	int q,i,j;
	for(i=2;i<=100000;i++)
	{
		if (!f[i])
    	{
    		for (j=i+i;j<=100000;j+=i)
    		{
    			f[j]=true;
    		}
    	}
	}
	for(i=3;i<=100000;i+=2)
	{
		if(!f[i] && !f[(i+1)/2])
		{
			c[i]=1;
		}
	}
	for(i=3;i<=100000;i++)
	{
		c[i]+=c[i-1];
	}
	cin>>q;
	for(i=1;i<=q;i++)
	{
		cin>>l>>r;
		cout<<c[r]-c[l-1]<<endl;
	}
	
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n;

	cin >> n;

	int num[4][3][10] = {};


	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		num[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				printf(" %d", num[i][j][k]);
			}
			printf("\n");
		}
		if (i < 3) {
			printf("####################\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){ 
	int i,j,n,m,f=0;
	cin>>n>>m;
	char s[n+5][m+5];
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>s[i][j];
		}
	}
/*	cout<<endl;
	
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
	*/
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
		
			if((s[i][j]=='#')){
				f=0;
				if((s[i][j+1]=='#'||s[i][j-1]=='#'||s[i+1][j]=='#'||s[i-1][j]=='#')){
					f=1;
			//		cout<<i<<"   "<<j<<endl;
				//	break;
				}
				if(f==0){
					cout<<"No"<<endl;return 0;
				}
			}	
		}
	}
	//if(f==1)
	{
		cout<<"Yes"<<endl;
	}
		
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  cout << (b-a+1) -( (b/c) -(a-1)/c +(b/d) -(a-1)/d -b/lcm(c,d) +(a-1)/lcm(c,d)) << endl;
}

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

#define ll long long int
#define vl vector<ll>
#define vvl vector<vl>

int main() {

    ll H, N;
    cin >> H >> N;

    vector<int> V, W;
    int a, b;

    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        V.push_back(a);
        W.push_back(b);
    }

    int **dp = new int*[1010];
    for (int i = 0; i < 1010; i++) {
        dp[i] = new int[20010];
    }

    for (int i = 0; i <= N; i++) {
        for (int v = 1; v < 20010; v++) {
            dp[i][v] = 1e9;
        }
    }


    for (int i = 0; i < N; i++) {
        for (int v = 0; v < 20010; v++) {
            dp[i+1][v] = min(dp[i+1][v], dp[i][v]);
            if (v >=V[i]) {
                dp[i+1][v] = min(dp[i+1][v], dp[i+1][v-V[i]] + W[i]);
            }
        }
    }

    int ans = 1e9;
    for (int v = H; v < 20000; v++) {
        ans = min(ans, dp[N][v]);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string a,s,c;
  cin>>a>>s>>c;
  cout<<'A'<<s[0]<<'C'<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int less(const void* a, const void* b){
  return *(int*)a - *(int*)b;
}

int is_no_need(int i, const int* a, int K, int N){
  int dp[K];
  for(int k = 0; k < K; k++) dp[k] = 0;
  
  for(int j = 1; j <= N; j++){
    for(int k = K - 1; k >= 0; k--){
      if(j != i && a[j] <= k && dp[k - a[j]] + a[j] > dp[k])
        dp[k] = dp[k - a[j]] + a[j];
    }
  }
  
  return dp[K - 1] + a[i] < K;
}

int count_no_need(const int* a, int K, int N){
  //不必要でないカードのうち, 書かれた数が最小であるもの
  int need = N + 1;
  //不必要であるカードのうち, 書かれた数が最大であるもの
  int no_need = 0;
  
  while(need - no_need > 1){
    int i = (need + no_need) / 2;
    
    if(is_no_need(i, a, K, N)) no_need = i;
    else need = i;
  }
  
  return no_need;
}

int main(){
  int N, K;
  scanf(" %d %d ", &N, &K);
  
  int a[N + 1];
  a[0] = 0;
  for(int i = 1; i <= N; i++) scanf(" %d ", a + i);
  qsort(a, N + 1, sizeof(int), less);
  
  printf("%d\n", count_no_need(a, K, N));
  
  return 0;
}


Measured memory_bytes: 252
#include<stdio.h>
#include<string.h>
     
int main(){
    char s[15];
    scanf("%s", s);
     
    int idx = 0;
    char arr[11] = {'\0'};
    int len = strlen(s);
    
	for(int i = 0; i < len;i++){
        if(s[i] == '0'){
          arr[idx] = '0';
          idx++;
        }
		
	else if (s[i] == '1'){
          arr[idx] = '1';
          idx++;
        }
		
	else if(s[i] == 'B'){
          if (idx != 0){
            idx--;
            arr[idx] = '\0';
          }
        }
      }
	printf("%s", arr);
    return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int MAXN = 3005;
const int MOD = 1000000007;

class TaskE {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int rows, cols, bombs;
		cin >> rows >> cols >> bombs;
		unordered_map<int,int> rowToCols, colToRows;
		unordered_map<int,vector<int>> rowToValues;
		vector<int> x(bombs), y(bombs);
		set<pair<int,int>> all;
		for(int i = 0; i < bombs; i++) {
			cin >> x[i] >> y[i];
			rowToCols[x[i]]++;
			colToRows[y[i]]++;
			rowToValues[x[i]].push_back(y[i]);
			all.insert({x[i], y[i]});
		}
		assert(all.size() == bombs);
		int ans = 0;
		for(int i = 0; i < bombs; i++) {
			ans = max(ans, rowToCols[x[i]] + colToRows[y[i]] - 1);
		}
		multiset<int> s;
		for(auto item : colToRows) {
			s.insert(item.second);
		}
		for(auto item : rowToCols) {
			int row = item.first;
			for(int col : rowToValues[row]) {
				s.erase(s.find(colToRows[col]));
			}
			ans = max(ans, (!s.empty() ? *s.rbegin() : 0) + item.second);
			for(int col : rowToValues[row]) {
				s.insert(colToRows[col]);
			}
		}
		cout << ans << endl;
			
	}
	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}



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

 int main(){
     int N;cin>>N;
     int sum=0;
     vector<int> usable;

     for(int i=0;i<N;i++){
         int k;cin>>k;
         sum+=k;
         if(k%10)usable.push_back(k);
     }

     if(sum%10){
         cout<<sum<<endl;
         return 0;
     }
     if(usable.size()==0){
         cout<<0<<endl;
         return 0;
     }
     sort(usable.begin(),usable.end());
     cout<<sum-usable.at(0)<<endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
    int n, i, k;
    char s[100005];
    scanf("%s", &s);
    k = strlen(s);
    n = 1;
    for (i = 0; i < k - 1; i++) {
        if (s[i] != s[i + 1])
            n++;
    }
    printf("%d\n", n - 1);
    return 0;
}


Measured memory_bytes: 384
import java.io.*;

public class Main {
   public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try {
      int count = 0;
      String line = reader.readLine();
      for (int i = 0; i < 3; i++) {
         char c = line.charAt(i);
         if (c == 'o') {
            count ++;
         }
      }
      System.out.println(700 + 100 * count);
      } catch (IOException e) {
         System.out.println(e);
      }
   }
}

Measured memory_bytes: 21972
fn factor(mut n: usize) -> Vec<(usize, usize)> {
    let mut ret = vec![];
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut cnt = 0;
        while n % i == 0 {
            cnt += 1;
            n /= i;
        }
        if cnt != 0 {
            ret.push((i, cnt));
        }
    }
    if n != 1 {
        ret.push((n, 1));
    }
    ret
}

fn main() {
    proconio::input! {
        n :usize,
    }
    let factors = factor(n);
    let mut count = 0usize;
    for item in &factors {
        let mut a = item.1;
        for i in 1.. {
            if a >= i {
                a -= i;
            } else {
                break;
            }
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2172
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	m := make(map[string]bool, n)

	var x string
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		m[x] = true
	}

	c := 0
	for _, v := range m {
		if v {
			c++
		}
	}

	if c == 3{
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}


Measured memory_bytes: 512
import copy

H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(input().split())
aa = copy.copy(a)
#print(a)
aaa = 0
d = ""
for i in range(W):
    d += "."
for i in range(H):
    if a[i][0] == d:
        aa.pop(i-aaa)
        aaa += 1
#print(aa)
b = []
bb = ""
for i in range(W):
    for j in range(H-aaa):
        bb += aa[j][0][i]
    b.append(bb)
    bb = ""
#print(b)
d = ""
for i in range(H-aaa):
    d += "."
#print(d)
bc = copy.copy(b)
bbb = 0
for i in range(W):
    if b[i] == d:
        bc.pop(i-bbb)
        bbb += 1
#print(bc)
ans = []
ansc = ""
for i in range(H-aaa):
    for j in range(W-bbb):
        ansc += bc[j][i]
    ans.append(ansc)
    ansc = ""
#print(ans)
for i in range(H-aaa):
    print(ans[i])

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    
    
    int h, a;
    cin >> h >> a;

    int cnt = 0;
    while(h > 0){
        cnt++;
        h -= a;
    }


    cout << cnt << endl;

    



    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N	20000
#define N_	(N * 2)

int xx[N_], n;

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return xx[i] - xx[j];
}

int ii[N_], pp[N_], ll[N_], rr[N_];

int ds[N_], rr_[N_];

int find(int i) {
	return ds[i] < 0 ? i : (ds[i] = find(ds[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (ds[i] > ds[j]) {
		ds[i] = j;
	} else {
		if (ds[i] == ds[j])
			ds[i]--;
		ds[j] = i;
		rr_[i] = rr_[j];
	}
}

int cc[N_];

void update(int i, int c) {
	cc[i] = c;
	if (i > 0 && cc[i - 1])
		join(i - 1, i);
	if (i + 1 < n * 2 && cc[i + 1])
		join(i, i + 1);
}

int get(int i) {
	return i >= n * 2 || !cc[i] ? i : rr_[find(i)] + 1;
}

int qu[N_], cnt;

void dfs1(int i) {
	int l, j;

	update(pp[ii[i] ^ 1], -1);
	l = ll[i];
	while ((j = get(l)) <= rr[i])
		if (j == i)
			l = i + 1;
		else
			dfs1(pp[ii[j] ^ 1]);
	qu[--cnt] = i;
}

void dfs2(int i, int c) {
	int l, j;

	update(i, c);
	i = pp[ii[i] ^ 1], l = ll[i];
	while ((j = get(l)) <= rr[i])
		if (j == i)
			l = i + 1;
		else
			dfs2(j, c);
}

int solve(int d) {
	int h, i, l, r, c;

	for (i = 0, l = 0, r = 0; i < n * 2; i++) {
		while (l < i && xx[ii[i]] - xx[ii[l]] >= d)
			l++;
		while (r < n * 2 && xx[ii[r]] - xx[ii[i]] < d)
			r++;
		ll[i] = l, rr[i] = r - 1;
	}
	for (i = 0; i < n * 2; i++)
		ds[i] = -1, rr_[i] = i, cc[i] = 0;
	cnt = n * 2;
	for (i = 0; i < n * 2; i++)
		if (!cc[pp[ii[i] ^ 1]])
			dfs1(i);
	for (i = 0; i < n * 2; i++)
		ds[i] = -1, rr_[i] = i, cc[i] = 0;
	c = 0;
	for (h = 0; h < n * 2; h++) {
		i = qu[h];
		if (!cc[i])
			dfs2(i, ++c);
	}
	for (i = 0; i < n; i++)
		if (cc[pp[i << 1 | 0]] == cc[pp[i << 1 | 1]])
			return 0;
	return 1;
}

int main() {
	int i, lower, upper;

	scanf("%d", &n);
	for (i = 0; i < n * 2; i++)
		scanf("%d", &xx[i]);
	for (i = 0; i < n * 2; i++)
		ii[i] = i;
	qsort(ii, n * 2, sizeof *ii, compare);
	for (i = 0; i < n * 2; i++)
		pp[ii[i]] = i;
	lower = 0, upper = 1000000000;
	while (upper - lower > 1) {
		int d = (lower + upper) / 2;

		if (solve(d))
			lower = d;
		else
			upper = d;
	}
	printf("%d\n", lower);
	return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

//////////////////////////////////////////////////////////////////////
int x[10][10];
int main(void) {
	ll l, r; cin >> l >> r;
	if (r - l >= 672) {
		cout << 0 << endl;
		return 0;
	}
	else {
		ll ans = 2020;
		for (ll i = l; i <= min(r-1,l + 671); i++) {
			for (ll j = i + 1; j <= min(r,l + 672); j++) {
				ll res = i * j % 2019;
				mins(ans, res);
			}
		}
		cout << ans << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
  ll n ; cin>> n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  vector<ll> B(13) ;
  rep(i,n) B[A[i]] ++ ;
  ll ans=0 ; bool ok= 0 ;
  for(int i=0 ;i<(1<<13) ; i++ ){
    if(ok)  break ;
    ll bns=100 ;
    bitset<13> s(i) ;
    vector<ll> time ;
    rep(i,13){
      if(B[i]>=3){
        ans=0 ; 
        ok= 1 ;
        break ;
      }
      if(B[i]==2){
        time.pb(i) ;
        time.pb(24-i) ;
      }
      if(B[i]==1){
        if(s[i]==0) time.pb(i) ;
        else time.pb(24-i) ;
      }
    }
    if(ok) break ;
    time.pb(0) ;
    ll k= time.size() ;
    rep(i,k-1){
      rep2(j,i+1,k-1){
        ll a= abs(time[i]-time[j]) ;
        chmin(bns,min(a,24-a)) ;
      }
    }
    chmax(ans,bns) ;
  }
  cout<<ans<<endl ;
   return 0 ;
 }

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

// int main() {
//     cout << 200000 << endl;
//     rep(i, 200000) {
//         cout << 2020202020 << " ";
//     }
//     cout << endl;
// }

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    ll tmp = 0, best = 1e18, bestlen = 0;
    ll ans = 1e18;
    rep(i, N-1) {
        tmp += A[i];
        ll tmp2 = sum - tmp;
        ans = min(ans, abs(tmp - tmp2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int x;

int main(){
    cin>>x;
    if(x>=30) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
# coding: utf-8
# 2分探索


def binarySearch(target, data_list, n):
    left = 0
    right = n
    middle = int((right - left) / 2)

    while data_list[middle] != target:
        if (middle == left or middle == right):
            return 0

        left, right = [left, middle
                       ] if data_list[middle] > target else [middle, right]
        middle = left + int((right - left) / 2)

    return 1


if __name__ == "__main__":
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(j) for j in input().split()]

    total = 0

    for target in T:
        total += binarySearch(target, S, n)

    print(total)



Measured memory_bytes: 16900
#include<iostream>

using namespace std;

int main(void) {
	double x[3] = { 0,0,0 };
	double y[3] = { 0,0,0 };
	double xp = 0, yp = 0;
	int flag[3] = { 0,0,0 };

	while (cin >> x[0]>> y[0]>> x[1]>> y[1]>> x[2]>> y[2]>> xp>> yp) {
		for (int i = 0; i < 3; i++) {
			int temp1 = (i + 1) % 3;
			int temp2 = (i + 2) % 3;
			double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) - (x[temp1] - x[i]) * (y[temp2] - y[i]);
			double checkP = (y[temp1] - y[i]) * (xp - x[i]) - (x[temp1] - x[i]) * (yp - y[i]);

			if (checkI * checkP > 0) {
				flag[i] = 1;
			}
		}
		if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		flag[0] = 0;
		flag[1] = 0;
		flag[2] = 0;
	}
	

	return 0;
}

Measured memory_bytes: 1220
from collections import deque,defaultdict
def bfs(sy,sx,gy,gx):
    q = deque([[sy,sx]])
    visited[sy][sx]=0
    while q:
        y,x = q.popleft()
        if [y,x]==[gy,gx]:
            return visited[y][x]
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx = y+j,x+k
            if ny<0 or ny>h-1 or nx<0 or nx>w-1 or path[ny][nx]=="#":
                continue
            if path[ny][nx]=="." and visited[ny][nx]==-1:
                visited[ny][nx]=visited[y][x]+1
                q.append([ny,nx])

h,w=map(int,input().split())
path=[input() for i in range(h)]
visited=[[-1]*w for i in range(h)]
sy,sx=0,0
gy,gx=h-1,w-1
bfs(sy,sx,gy,gx)
# print(visited)

if visited[gy][gx]==-1:
    print(-1)
    exit()

c=0
for i in range(h):
    for j in range(w):
        if path[i][j]=='#':
            c+=1
print(h*w-c-(visited[gy][gx]+1))

Measured memory_bytes: 3316
N=int(input())
p=10**9+7

def pow_k(x,n,p=10**9+7):
    if n==0:
        return 1
    K=1
    while n>1:
        if n%2!=0:
            K=(K*x)%p
        x=(x*x)%p
        n//=2
    return (K*x)%p


print((pow_k(10,N)-2*pow_k(9,N)+pow_k(8,N))%p)

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long A, long long B){
    i64 x = N / (A + B);
    cout << x * A + min(N - x * (A + B), A) << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void){
	int max , i , n , buf;
	double r , l[3];

	while(1){
		max = 0;
		scanf("%lf %lf %lf" , &l[0] , &l[1] , &l[2]);
		if(l[0]==0&&l[1]==0&&l[2]==0) break;
		for(i=0;i<3;i++){
			if(l[i] > l[max]){
				max = i;
			}
		}
		r = sqrt(pow(l[(max+1)%3],2) + pow(l[(max+2)%3],2)) / 2;
		scanf("%d" , &n);
		for(i=0;i<n;i++){
			scanf("%d" , &buf);
			if(buf > r){
				printf("OK\n");
			}else{
				printf("NA\n");
			}
		}
	}

	return 0;
}

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

int N, M;
vector<vector<ll>> val(1001, vector<ll>(3));

int main(void){
    
    cin >> N >> M;
    for(int i = 0; i < N; ++i) cin >> val[i][0] >> val[i][1] >> val[i][2];
    
    ll ans = LLONG_MIN;
    for(int k = 0; k < 8; ++k){
        vector<ll> v;
        for(int i = 0; i < N; ++i) {
            ll num = 0;
            if (1 << 2 & k)num += val[i][0];
            else num -= val[i][0];
            if (1 << 1 & k)num += val[i][1];
            else num -= val[i][1];
            if (1 << 0 & k)num += val[i][2];
            else num -= val[i][2];
            v.emplace_back(num);
        }
        sort(v.begin(), v.end(), greater<ll>());
        ll sum = 0;
        for(int i = 0; i < M; ++i) sum += v[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int maxN = *max_element(A.begin(), A.end());
	int maxR = 0;
	int bestR = 0;
	for (int i = 0; i < N; i++) {
		int r = min(A[i], maxN-A[i]);
		if (r > maxR) {
			maxR = r;
			bestR = A[i];
		}
	}
	cout << maxN << ' ' << bestR << '\n';

	return 0;
}

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

int main(void){
    long long X;
    cin >> X;
    bool breakable = false;
    for(long long B = -120LL; B<119LL; B++){
        for(long long A = B+1LL; A<120LL; A++){
            if(A*A*A*A*A-B*B*B*B*B==X){
                cout << A << " " << B << endl;
                breakable = true;
                break;
            }
        }
        if(breakable)break;
    }
    return 0;
}

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

string judge(int);

int main()
{
	int E, Y;
	cin >> E >> Y;
	switch(E)
	{
		case 0:
			cout<<judge(Y)<<endl;
			break;
		case 1:
			cout<<Y+1867<<endl;
			break;
		case 2:
			cout<<Y+1911<<endl;
			break;
		case 3:
			cout<<Y+1925<<endl;
			break;
		case 4:
			cout<<Y+1988<<endl;
			break;
	}
}

string judge(int Y)
{
	if(Y>=1989)
		return "H" + to_string(Y-1988);
	if(Y>=1926)
		return "S" + to_string(Y-1925);
	if(Y>=1912)
		return "T" + to_string(Y-1911);
	if(Y>=1868)
		return "M" + to_string(Y-1867);
}

Measured memory_bytes: 3228
from bisect import bisect_left

N = int(input())
A = list(map(int,input().split()))
A.sort()
B = list(map(int,input().split()))
B.sort()
C = list(map(int,input().split()))
C.sort()

"""
前処理で中部に大きさb以下のパーツを使える場合の組み合わせの数を計算しておく。
"""

tmp1 = [0]
for b in B:
    a = bisect_left(A,b)
    tmp1.append(tmp1[-1]+a)

tmp2 = 0
for c in C:
    idx = bisect_left(B,c)
    tmp2 += tmp1[idx]
print(tmp2)


Measured memory_bytes: 105156
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    int i = 0;
    while (i < s.length() && s[i] == 'F') {
        x--;
        i++;
    }
    int n = s.length();
    vector<bool> canx(n + 1);
    vector<bool> cany(n + 1);
    canx[0] = cany[0] = true;
    int d = 0;
    while (i < s.length()) {
        d ^= 1;
        i++;
        int p = 0;
        while (i < s.length() && s[i] == 'F') {
            p++;
            i++;
        }
        vector<bool> &v = (d == 0 ? canx : cany);
        vector<bool> vv(n + 1);
        for (int j = 0; j <= n; j++) {
            if (v[j]) {
                vv[j + p] = true;
                vv[abs(j - p)] = true;
            }
        }
        v = vv;
    }

    if (canx[abs(x)] && cany[abs(y)]) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

const int N=1e5+100;

/*struct node
{
    int x;
    bool operator < (const node &a) const
    {
        return x<a.x;
    }
};*/
priority_queue<double,vector<double>,less<double>>q;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    double x;
    for(int i=1;i<=n;i++){
        scanf("%lf",&x);
        q.push(x);
    }
    for(int i=1;i<=m;i++){
        double k=q.top();q.pop();
       // cout<<k<<endl;
        q.push(k/2);
    }
    ll ans=0;
    while(q.size()){
        ans+=int(q.top());q.pop();
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1400
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
s=[]
for i in a:
  if(i.count("#")!=0):s.append(i)
a = [list(x) for x in zip(*s)]
s=[]
for i in a:
  if(i.count("#")!=0):s.append(i)
a = [list(x) for x in zip(*s)]
for i in a:print("".join(i))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int tmpc=n/4+1;
    int tmpd=n/7+1;
    int ans=0;
    bool flag=false;
    for(int i=0;i<tmpc;i++){
        for(int j=0;j<tmpd;j++){
            ans=4*i+7*j;
            if(ans==n){
                flag=true;
                break;
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}
 
 
 
signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  rep(i,0,siz(s)){
    if(s[i]=='1')s[i]='9';
    else if(s[i]=='9')s[i]='1';
  }
  cout<<s<<ENDL;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 22 21:00:13 JST 2020
 **/

bool is_palindrome(const string& s) {
    REP(i, s.size()) {
        if (s[i] != s[s.size() - 1 - i]) return false;
    }
    return true;
}

signed main() {
    string s;
    cin >> s;
    Int n = s.size();
    string a = s.substr(0, n / 2);
    string b = s.substr(n / 2 + 1, n / 2);
    bool ok = is_palindrome(a) && is_palindrome(b) && is_palindrome(s);
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	while (cin >> n) {
		int cnt = 0;
		rep(a, 10)rep(b, 10)rep(c, 10)rep(d, 10) {
			if (a + b + c + d == n)cnt++;
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3084
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,d,count=0;
  cin>>n>>d;
  long long a,b;
  for(int i=0;i<n;i++)
  {
    cin>>a>>b;
    a=a*a;b=b*b;
    if(sqrt(a+b)<=d)
      count++;
  }
  cout<<count<<endl;
}

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

using namespace std;

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

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

   sort(p,p+N);
   reverse(p,p+N);

   int sum = p[0] / 2;
   for(int i=1;i<N;i++){
      sum += p[i];
   }

   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int N = 0;
int M = 0;
vector<int> path;
int main(void) {
  cin >> N >> M;
  path.resize(N);
  for (int i = 0; i < N; i++) path[i] = i;

  int val[10][10] = {};
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    val[a - 1][b - 1] = 1;
    val[b - 1][a - 1] = 1;
  }

  Sort(path);

  int count = 0;
  do {
    int c = 0;
    if (path[0] != 0) break;
    for (int i = 0; i < N - 1; i++) {
      if (val[path[i]][path[i + 1]] != 0) c++;
    }
    if (c == N - 1) count++;
  } while (next_permutation(path.begin(), path.end()));
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  int n;
  int b, f, r, v;
  int l1[10]={0,0,0,0,0,0,0,0,0,0};
  int l2[10]={0,0,0,0,0,0,0,0,0,0};
  int l3[10]={0,0,0,0,0,0,0,0,0,0};
  int m1[10]={0,0,0,0,0,0,0,0,0,0};
  int m2[10]={0,0,0,0,0,0,0,0,0,0};
  int m3[10]={0,0,0,0,0,0,0,0,0,0};
  int n1[10]={0,0,0,0,0,0,0,0,0,0};
  int n2[10]={0,0,0,0,0,0,0,0,0,0};
  int n3[10]={0,0,0,0,0,0,0,0,0,0};
  int o1[10]={0,0,0,0,0,0,0,0,0,0};
  int o2[10]={0,0,0,0,0,0,0,0,0,0};
  int o3[10]={0,0,0,0,0,0,0,0,0,0};

  cin>>n;

  for(int i=0; i<n; i++){
    cin>>b>>f>>r>>v;

    if(b==1){
      if(f==1){
        l1[r-1]=l1[r-1]+v;
      }
      if(f==2){
        l2[r-1]=l2[r-1]+v;
      }
      if(f==3){
        l3[r-1]=l3[r-1]+v;
      }
    }

    if(b==2){
      if(f==1){
        m1[r-1]=m1[r-1]+v;
      }
      if(f==2){
        m2[r-1]=m2[r-1]+v;
      }
      if(f==3){
        m3[r-1]=m3[r-1]+v;
      }
    }

    if(b==3){
      if(f==1){
        n1[r-1]=n1[r-1]+v;
      }
      if(f==2){
        n2[r-1]=n2[r-1]+v;
      }
      if(f==3){
        n3[r-1]=n3[r-1]+v;
      }
    }

    if(b==4){
      if(f==1){
        o1[r-1]=o1[r-1]+v;
      }
      if(f==2){
        o2[r-1]=o2[r-1]+v;
      }
      if(f==3){
        o3[r-1]=o3[r-1]+v;
      }
    }
  }


  for(int j=0; j<10; j++){
    cout<<" "<<l1[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<l2[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<l3[j];
  }
  cout<<endl;

  cout<<"####################"<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<m1[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<m2[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<m3[j];
  }
  cout<<endl;

  cout<<"####################"<<endl;
  for(int j=0; j<10; j++){
    cout<<" "<<n1[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<n2[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<n3[j];
  }
  cout<<endl;

  cout<<"####################"<<endl;
  for(int j=0; j<10; j++){
    cout<<" "<<o1[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<o2[j];
  }
  cout<<endl;

  for(int j=0; j<10; j++){
    cout<<" "<<o3[j];
  }
  cout<<endl;
}

Measured memory_bytes: 3112
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
# print(a)
q = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            q.append([i, j])
    elif i % 2 == 1:
        for j in range(W - 1, -1, -1):
            q.append([i, j])
# print(q)
N = 0
ans_arr = []
for qi in range(len(q)):
    i = q[qi][0]
    j = q[qi][1]
    if a[i][j] % 2 == 0:
        pass
    elif a[i][j] % 2 == 1 and qi != len(q) - 1:
        N += 1
        a[i][j] -= 1
        a[q[qi + 1][0]][q[qi + 1][1]] += 1
        ans_arr.append([i, j, q[qi + 1][0], q[qi + 1][1]])

print(N)
for x1, x2, x3, x4 in ans_arr:
    print(x1 + 1, x2 + 1, x3 + 1, x4 + 1)


Measured memory_bytes: 50236
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

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

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    string s;
    cin >> s;
    bool ok = false;
    for(const char& c : s) if( c == '7' ) ok = true;
    if(ok) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

int binary(ll num, int n){
    ll ans=0;
    int d=0;
    for(int i=0; num>0; i++){
        ans = ans+(num%n)*pow(10, i);
        num = num / n;
        d++;
    }
    return d;
}

int main(){
    ll n;
    int k;
    cin >> n >> k;
    out(binary(n, k));

}

Measured memory_bytes: 256
#include "stdio.h"
#include "string.h"

int main( void )
{
    int a,b;
    char sum[16];
    
    while( scanf("%d %d",&a,&b) != EOF ){
        sprintf(sum,"%d",a+b);
        printf("%ld\n",strlen(sum) );   
    } 
}

Measured memory_bytes: 1744
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define f0(i,n)for(ll i=0;i<n;i++)
#define f0r(i,n)for(ll i=n-1;i>=0;i--)
#define fc(i,c,n,s)for(ll i=c;i<=n;i+=s)
#define fcr(i,c,n,s)for(ll i=n;i>=c;i-=s)
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif
	ll h,nh;
	cin >> h;
	ll ans = 0;
	ll add = 1;
	while (h) {
		ans += add;
		add <<= 1;
		h >>= 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=-1000000000,cnt=0,sum=0;
  cin >> n;
  long long a[n][10],b[n][11];
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin >> b[i][j];
    }
  }
  for(int i0=0;i0<2;i0++){
    for(int i1=0;i1<2;i1++){
      for(int i2=0;i2<2;i2++){
        for(int i3=0;i3<2;i3++){
          for(int i4=0;i4<2;i4++){
            for(int i5=0;i5<2;i5++){
              for(int i6=0;i6<2;i6++){
                for(int i7=0;i7<2;i7++){
                  for(int i8=0;i8<2;i8++){
                    for(int i9=0;i9<2;i9++){
                      if(i0+i1+i2+i3+i4+i5+i6+i7+i8+i9){                        
                        sum=0;
                        for(int i=0;i<n;i++){
                          cnt=(i0 and a[i][0])+(i1 and a[i][1])+(i2 and a[i][2])+(i3 and a[i][3])+(i4 and a[i][4])+(i5 and a[i][5])+(i6 and a[i][6])+(i7 and a[i][7])+(i8 and a[i][8])+(i9 and a[i][9]);
                          sum+=b[i][cnt];
                        }
                        ans=max(ans,sum);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   ll x,y;
   cin>>x>>y;
   
   ll sum = 0;
   sum+=(max((ll)0,4-x)*100000 + max((ll)0,4-y)*100000);
   if(x + y == 2)
        sum+=400000;
   cout<<sum;        
   
   return 0;
}  
   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
std::vector<int> qsort(std::vector<int> xs);


int main(){
	std::vector<int> vec(5);
	for(int i=0;i<5;i++){
		std::cin>>vec[i];
	}
	vec=qsort(vec);
	for(int i=4;i>-1;i--){
		std::cout<<vec[i];
		if(i!=0)std::cout<<" ";
		else std::cout<<std::endl;
	}
	
	
	return 0;
}

std::vector<int> qsort(std::vector<int> xs){

	if(xs.empty())return xs;
	else{
			int x=xs[0];
		std::vector<int> left;
		std::vector<int> right;
		for(int i=1;i<xs.size();i++){
			if(x>xs[i])left.push_back(xs[i]);
			else if(x<=xs[i])right.push_back(xs[i]);
		}
		left=qsort(left);
		right=qsort(right);
		left.push_back(x);
		left.insert(left.end(),right.begin(),right.end());
		return left;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int dp[3005][3005];

int dfs(std::vector<int>& a, int taro, int l, int r) {
	if (dp[l][r] != -1e15) return dp[l][r];
	if (l > r) {
		return 0;
	} 
	if (taro)
		return (dp[l][r] = max(dfs(a, !taro, l + 1, r) + a[l], dfs(a, !taro, l, r - 1) + a[r])); 
	return (dp[l][r] = min(dfs(a, !taro, l + 1, r) - a[l], dfs(a, !taro, l, r - 1) - a[r])); 
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	for (int i = 0; i < 3005; ++i) 
		for (int j = 0; j < 3005; ++j) 
			dp[i][j] = -1e15;
	int ans = dfs(a, 1, 0, n - 1);
	cout << ans;
}

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

int main(){
  int l,r,d,ans=0;cin>>l>>r>>d;
  for(int i=l;i<=r;i++) if(!(i%d)) ans++;

  cout<<ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vector<int>>
#define vl vector<long long>
#define vl2 vector<vector<long long>>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.length() <= k) cout << s << endl;
    else{
        rep(i,k) cout << s[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624