akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void main_()
{
    ll N;
    cin >> N;

    array<array<int, 10>, 10> c_ij = {};
    for (ll i = 1; i <= N; i++) {
        ll h;
        if (i < 10) {
            h = i;
        } else if (i < 100) {
            h = i / 10;
        } else if (i < 1000) {
            h = i / 100;
        } else if (i < 10000) {
            h = i / 1000;
        } else if (i < 100000) {
            h = i / 10000;
        } else {
            h = i / 100000;
        }
        ll t = i % 10;
        c_ij[h][t]++;
    }

    ll ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += c_ij[i][j] * c_ij[j][i];
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

string t = "yuiophjklnm";

int main()
{
    while(true){
        string s;
        cin >> s;
        if(s == "#") break;
        int n = s.size();
        int ans = 0;
        int lr = -1;
        for(int i = 0; i < n; i++){
            bool r = false;
            for(int j = 0; j < 11; j++){
                if(s[i] == t[j]) r = true;
            }
            if((lr == 0 && r) || (lr == 1 && !r)) ans++;
            if(r) lr = 1;
            else lr = 0;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3208
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
// use std::collections::BinaryHeap;

fn main() {
  let n = read::<i64>();
  let k = read::<i64>();
  let mut l_vec = vec![];
  let mut ans = 0;

  for _ in 0..n {
    l_vec.push(read::<i64>())
  }

  l_vec.sort_by_key(|x| -x);

  for i in 0..k {
    ans += l_vec[i as usize];
  }

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


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

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

		long x = in.nextInt();
		long y = in.nextInt();

		int won = 0;

		if (x == 1)
			won += 300000;
		else if (x == 2)
			won += 200000;
		else if (x == 3)
			won += 100000;

		if (y == 1)
			won += 300000;
		else if (y == 2)
			won += 200000;
		else if (y == 3)
			won += 100000;

		if (x == 1 && y == 1)
			won += 400000;

		System.out.println(won);
	}
}



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

int main(){
  int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;

  cout << arr[k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

    int main(void){
    int c1, c5, c10, c50, c100, c500, sum;
    scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500);
    
    sum=c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 *500;
    if(sum >= 1000){
        printf("1\n");
    }
    else printf("0\n");
    return 0;
}



Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void self_max(int &a, int b) {
	a = max(a, b);
}
vector<int>v[N];
bool check[N];
int dp[N];
int dfs(int s) {
	int path = 0;
	if(check[s]) {
		return dp[s] + 1;
	}
	check[s] = true;
	for(int i : v[s]) {
		self_max(path, dfs(i));
	}
	self_max(dp[s], path);
	return path + 1;
}
int main() {
	int n, m;
	cin>>n>>m;
	rep(i, 0, m) {
		int a, b;
		cin>>a>>b;
		v[a].pb(b);
	}
	int ans = 0;
	rep(i, 1, n + 1) {
		if(!check[i]) {
			self_max(ans, dfs(i) - 1);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8192
package main

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	var asum int
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		asum += as[i]
	}
	sort.Sort(sort.IntSlice(as))
	fs := make([]int, n)
	for i := range fs {
		sc.Scan()
		fs[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(fs)))
	l := -1
	r := int(1e18)
	for r-l > 1 {
		m := (l + r) / 2
		var sum int
		for i := range fs {
			sum += min(m/fs[i], as[i])
		}
		if sum >= max(asum-k, 0) {
			r = m
		} else {
			l = m
		}
	}
	fmt.Println(r)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 7296
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def check(k, A, N, M, V, P):
    #print(k, 'start')
    VAL = A[k] + M
    if VAL < A[P]:
        return False
    if P + N-k >= V:
        return True
    #print('check1')
    checked_arr = A[P:k]
    members = V - P - N + k
    MM = M

    if M * members <= VAL * len(checked_arr) - sum(checked_arr):
        return True
    else:
        return False

def run():
    N, M, V, P, *A = map(int, read().split())

    A = sorted(A)
    A.append(-INF)
    A = A[::-1]
    l = 1
    r = N
    while r-l > 1:
        #print(l, r)
        x = (r + l) // 2
        if check(x, A, N, M, V, P):
            l = x
        else:
            r = x

    #print('last, ', l, r)
    if check(r, A, N, M, V, P):
        print(r)
    else:
        print(l)





if __name__ == "__main__":
    run()


Measured memory_bytes: 18408
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n;
    cin>>n;
    string ans="";
    while(n>0){
            ll m=n%26;
    if(m==0)ans+='z';
    else ans+='a'+(m-1);
    if(n%26==0)n--;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}



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

#define MAX 200000
#define ST 2000000000
typedef long long llong;

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

llong merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  llong cnt=0;
  int n1=mid-left;
  int n2=right-mid;

  for(i=0;i<n1;i++)
    L[i]=A[left+i];

  for(i=0;i<n2;i++)
    R[i]=A[mid+i];

  L[n1]=R[n2]=ST;
  i=j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return cnt;
}

llong mergeS(int A[],int n,int left,int right){
  int mid;
  llong v1,v2,v3;

  if(left+1<right){
    mid=(left+right)/2;
    v1=mergeS(A,n,left,mid);
    v2=mergeS(A,n,mid,right);
    v3=merge(A,n,left,mid,right);
    return v1+v2+v3;
  }
    else return 0;
}

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

  cin>>n;

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

  llong ans = mergeS(A,n,0,n);

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 4652
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
#include <set>
#include <ctime>
#include <cmath>
#include <string>

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int& x : a) {
		cin >> x;
	}
	/*vector<int> a(10000);
	int n = a.size();
	int cnt = 0;*/
	while (k--) {
		vector<int> b(n);
		for (int i = 0; i < n; i++) {
			int l = max(0, i - a[i]);
			int r = min(n - 1, i + a[i]);
			b[l]++;
			if (r < n - 1) {
				b[r + 1]--;
			}
		}
		for (int i = 1; i < n; i++) {
			b[i] += b[i - 1];
		}
		if (a == b) {
			break;
		}
		a = b;
		/*for (int x : a) {
			cout << x << ' ';
		}
		cout << endl;*/
		//cnt++;
	}
	for (int x : a) {
		cout << x << ' ';
	}
}


Measured memory_bytes: 4888
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

class DirectedGraph {
public:
    int V;
    vector<vector<int>> costs;

    DirectedGraph(int v) : V(v), costs(v, vector<int>(v, INF)) {
        for (int i = 0; i < V; i++) {
            costs[i][i] = 0;
        }
    }

    void add_edge(int u, int v, int cost) {
        costs[u][v] = cost;
    }

    void warshall_floyd() {
        for (int k = 0; k < V; k++) {
            for (int i = 0; i < V; i++) {
                for (int j = 0; j < V; j++) {
                    costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
                }
            }
        }
    }
};

class DirectedGraph2 {
    struct edge {
        int to;
        int cost;
    };

public:
    int V;
    vector<vector<edge>> G;

    DirectedGraph2(int v) : G(v), V(v) {}

    void add_edge(int u, int v, int cost) {
        G[u].push_back({v, cost});
    }

    // O(E * logV)
    vector<int> dijkstra(int s) {
        vector<int> d(V, INF);
        d[s] = 0;

        priority_queue<P, vector<P>, greater<>> que;
        que.push({0, s});

        while (!que.empty()) {
            P  p = que.top(); que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;

            for (edge e : G[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push({d[e.to], e.to});
                }
            }
        }

        return move(d);
    }
};

const int MAX_N = 300;
int N, M, L, Q;

struct edge {
    int to;
    int cost;
};

vector<edge> table[MAX_N];

signed main() {
    cin >> N >> M >> L;

    auto g1 = new DirectedGraph2(N);
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g1->add_edge(a, b, c);
        g1->add_edge(b, a, c);
    }

    auto g2 = new DirectedGraph(N);

    for (int i = 0; i < N; i++) {
        vector<int> ds = g1->dijkstra(i);
        for (int j = i + 1; j < N; j++) {
            if (ds[j] <= L) {
                g2->add_edge(i, j, 1);
                g2->add_edge(j, i, 1);
            }
        }
    }

    g2->warshall_floyd();

    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        int ret = g2->costs[s][t];
        if (ret == INF) ret = -1;
        else ret--;
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
def main():
    n = int(input())
    li = list(map(int,input().split()))
    li.sort()
    size = len(li)
    ans = []
    for i in range(li[size-1]+1):
        count = 0
        for j in range(size):
            count += (i - li[j]) ** 2
        ans.append(count)
    min_val = min(ans)
    print(min_val)

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace AtCoderTest
{
    class Program2
    {
        static int sec1_length;
        static int sec2_length;

        static void Main(string[] args)
        {
            string line;

            for (int i = 0; (line = Console.ReadLine()) != null; i++)
            {
                if (i == 0)
                {
                    string[] words = line.Split(' ');
                    sec1_length = int.Parse(words[0]);
                    sec2_length = int.Parse(words[1]);
                }
                else if (i == 1)
                {
                    Console.WriteLine(formatCheck(line));
                }
            }
        }

        static string formatCheck(string str)
        {
            string[] words = str.Split('-');
            int len = words.Length;
            int num1;
            int num2;
            
            if (len != 2)
            {
                return "No";
            }

            if (words[0].Length != sec1_length || words[1].Length != sec2_length)
            {
                return "No";
            }

            try
            {
                num1 = int.Parse(words[0]);
                num2 = int.Parse(words[1]);
            }
            catch
            {
                return "No";
            }

            if (num1 < 0 || num2 < 0)
            {
                return "No";
            }

            return "Yes";
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
import java.io.*;

public class Main{
	public static String judge(double w){
		if( w <= 48.0 ){
			return "light fly";
		} else if( w >= 48.0 && w <= 51.0 ){
			return "fly";
		} else if( w >= 51.0 && w <= 54.0 ){
			return "bantam";
		} else if( w >= 54.0 && w <= 57.0 ){
			return "feather";
		} else if( w >= 57.0 && w <= 60.0 ){
		 	return "light";
		} else if( w >= 60.0 && w <= 64.0 ){
			return "light welter";
		} else if( w >= 64.0 && w <= 69.0 ){
			return "welter";
		} else if( w >= 69.0 && w <= 75.0 ){
			return "light middle";
		} else if( w >= 75.0 && w <= 81.0 ){
			return "middle";
		} else if( w >= 81.0 && w <= 91.0 ){
			return "light heavy";
		} else {
			return "heavy";
		}
	}
	
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<String> result = new ArrayList<String>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				double w = stdIn.nextDouble();
				result.add(judge(w));
			}
			for(String str : result){
				System.out.println(str);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){return null;}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない 異常時:文字列「error」を返す（できる？）
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return "error";}}
function Main() {
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  var output = new Array(N);
  output[0] = 0;
  for(var i = 1; i < N; i++){
    if(i == 1){
       output[i] = Math.abs(list[i] - list[i-1]);
    }else{
       var right = output[i - 2] + Math.abs(list[i] - list[i-2]);
      var left = output[i - 1] + Math.abs(list[i] - list[i-1]);
      if(left > right){
         output[i] = right;
      }else{
         output[i] = left;
      }
    }
  }
  myout(output[N-1]);
}


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

int a,b,c,d;
int h,w;
int n;
char s[200003], t[200003];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	scanf("%d%d",&a,&c);b = a,d = c;
	scanf("%s%s",s,t);
	bool win = true;
	for(int i = 0;i < n;++i) {
		switch(s[i]) {
		case 'L':
			--c;
			if(c <= 0) {
				win = false;
				goto done;
			}
			break;
		case 'R':
			++d;
			if(d > w) {
				win = false;
				goto done;
			}
			break;
		case 'U':
			--a;
			if(a <= 0) {
				win = false;
				goto done;
			}
			break;
		case 'D':
			++b;
			if(b > h) {
				win = false;
				goto done;
			}
			break;
		}
		switch(t[i]) {
		case 'L':
			--d;
			if(d <= 0) d = 1;
			break;
		case 'R':
			++c;
			if(c > w) c = w;
			break;
		case 'U':
			--b;
			if(b <= 0) b = 1;
			break;
		case 'D':
			++a;
			if(a > h) a = h;
			break;
		}
	}
	done:
	if(win) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}


Measured memory_bytes: 640
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
x = {}
for i in d:
    if i in x:
        x[i] += 1
    else:
        x[i] = 1
t.sort()
j, cnt = t[0], 0
for i in t:
    if i == j:
        cnt += 1
    else:
        if not j in x:
            print("NO")
            exit()
        else:
            if cnt > x[j]:
                print("NO")
                exit()
            j, cnt = i, 1
if not j in x:
    print("NO")
    exit()
else:
    if cnt > x[j]:
        print("NO")
        exit()
    j, cnt = i, 1
print("YES")

Measured memory_bytes: 43904
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
	static boolean valid(long arr[],int x){
		for(long i : arr)
			if(i<x) return false;
		return true;
	}

    public static void process()throws IOException
    {
       	int n=ni(),m=ni(),x=ni();
	
		long res=Long.MAX_VALUE,cost=0;

		long understanding[]=new long[m],c[]=new long[n],a[][]=new long[n][m];

		for(int i=0;i<n;i++){
			c[i]=ni();
			for(int j=0;j<m;j++)
				a[i][j]=ni();
		}	 

		for(int mask=0;mask<=Math.pow(2, n)-1;mask++){
			int temp=mask;

			for(int i=0;i<n;i++){
				int choice=(temp&1);

				if(choice==1){
					cost+=c[i];
					for(int j=0;j<m;j++)
						understanding[j]+=a[i][j];
				}

				temp>>=1;
			}

			if(valid(understanding,x))
				res=Math.min(res, cost);

			Arrays.fill(understanding,0);
			cost=0;
		}
		pn((res==Long.MAX_VALUE)?-1:res);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 37428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String []input_array=input.readLine().split(" ");

		int value_x=Integer.parseInt(input_array[0]);

		int value_y=Integer.parseInt(input_array[1]);

		if(value_x<value_y){

			int num=value_x;

			value_x=value_y;

			value_y=num;
		}

		int r=value_x%value_y;

		while(r!=0){

			value_x=value_y;

			value_y=r;

			r=value_x%value_y;

			}


		System.out.println(value_y);

	}

}

Measured memory_bytes: 24420
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$ans=0;
$c=1;
$i=0;
while($i<$n){
	if($a[$i]==$c){
		++$c;
	}else{
		++$ans;
	}
	++$i;
}
echo ($ans==$n)?-1:$ans;

Measured memory_bytes: 19056
import bisect
for e in iter(input,'0'):
 n=int(e)
 c=[sorted(int(input())for _ in[0]*n)]
 c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
 t=f=0
 while 1:
  x=bisect.bisect(c[t],f)
  if not c[t]:break
  f=c[t].pop(x)if x<len(c[t])else 0
  t^=1
 for i in'10':print(len(c[int(i)]))


Measured memory_bytes: 5660
s = list(input())
ans = "AC"
if s[0]!="A":
    ans ="WA"

n = len(s)
a = 0
for i in range(1,n):
    x = ord(s[i])
    if x==ord("C") and i!=1 and i!=n-1:
        a+=1
        continue
    
    if ord("a")<=x and x <= ord("z"):
        continue
    else:
        ans ="WA"
if a!=1:
    ans ="WA"
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int a,b;
  scanf("%d %d",&a,&b);
  while( a!=0 || b!=0) {
    if(a>b) cout << b << " " << a << endl;
    else cout << a << " " << b << endl;
    scanf("%d %d",&a,&b);
  }
}

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


int main(){
  int h,w,anst;
  anst=0;
  cin >> h>>w;
  vector<string> str(h);
  for(int i=0;i<h;i++){
    cin>>str.at(i);
  }
  vector<vector<string>> vec(h,vector<string>(w));
  for(int i=0;i<h;i++){
    for(int k=0;k<w;k++){
      string s=str.at(i);
      vec.at(i).at(k)=s.at(k);
    }
  }
  int L[h][w],R[h][w],D[h][w],U[h][w],T[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      L[i][j]=0;
      R[i][j]=0;
      D[i][j]=0;
      U[i][j]=0;
      T[i][j]=0;
    }
  }
for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
    if(vec.at(i).at(j)=="#") L[i][j]=0;
    else {if(j==0) L[i][j]=1;
         else L[i][j]=L[i][j-1]+1;
       }
       T[i][j]+=L[i][j];
  }
}
for(int i=0;i<h;i++){
  for(int j=w-1;0<=j;j--){
    if(vec.at(i).at(j)=="#") R[i][j]=0;
    else {if(j==w-1) R[i][j]=1;
         else R[i][j]=R[i][j+1]+1;
       }
        T[i][j]+=R[i][j];
  }
}
for(int j=0;j<w;j++){
  for(int i=0;i<h;i++){
    if(vec.at(i).at(j)=="#") D[i][j]=0;
    else {if(i==0) D[i][j]=1;
         else D[i][j]=D[i-1][j]+1;
       }
        T[i][j]+=D[i][j];
  }
}
for(int j=0;j<w;j++){
  for(int i=h-1;0<=i;i--){
    if(vec.at(i).at(j)=="#") U[i][j]=0;
    else {if(i==h-1) U[i][j]=1;
         else U[i][j]=U[i+1][j]+1;
       }
        T[i][j]+=U[i][j];
        anst=max(T[i][j],anst);
  }
}
anst-=3;
  cout<<anst<<endl;
}


Measured memory_bytes: 301312
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static long H = scan.nextLong();
	static long min = 0;
	//static long []memo = new long[H+1];
	//static boolean []check = new boolean[H+1];
	static Set<Long> memo = new HashSet<Long>();
	static Map<Long,Long> me = new HashMap<Long,Long>();
	static ArrayList<Long> meno = new ArrayList<Long>();
	static Set<Boolean> cheak = new HashSet<Boolean>();
	
	public static void main(String[]args) {
		
			
			
			
			
			System.out.println(monster(H));
			
			
			
			
		
		
		
	}
	
	
	private static long monster(long h) {
		
		if(me.containsKey(h)) {
			return me.get(h);
		}else {
		
		if(h==1) {
			me.put(h, (long)1);
			return 1;	
		}else {
			long k = h/2;
			me.put(h,1+monster(k)+monster(k));
			return 1+monster(k)+monster(k);
			
			
		}
		
		}
		
		
	}
		

}


Measured memory_bytes: 23124
n = int(input())
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
  s = str(input()) 
  if s == "AC":
    c1 += 1
  if s== "WA":
    c2 += 1
  if s == "TLE":
    c3 += 1
  if s == "RE":
    c4 += 1

print("AC x " + str(c1))
print("WA x " + str(c2))
print("TLE x " + str(c3))
print("RE x " + str(c4))

Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;

void print_arr(vector<int> arr) {
  for(int i=0;i<arr.size();++i) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}

int main() {
  int n;
  cin >> n;
  int arr[n];
  int k;
  cin >> k;
  for(int i=0;i<n;++i) {
    cin >> arr[i];
  }

  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  for(int i=0;i<n;++i) {
    for(int j=i+1 ; j<=i+k; ++j) {
      if(j < n){
	dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]));
      }
    }
  }
  //    print_arr(dp);
  cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASubscribers solver = new ASubscribers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASubscribers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(Math.min(a, b) + " " + Math.max(a + b - n, 0));
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21460
#include <cstdio>

using namespace std;

const int NMAX = 1e5;

int n,m;
int v[NMAX + 5];

int main(){
    scanf("%d %d\n",&n,&m);

    for(int i = 1;i <= m;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        v[l]++;
        v[r + 1]--;
    }

    int total = 0;

    for(int i = 1;i <= n;i++){
        v[i] += v[i - 1];
        total += (v[i] == m);
    }

    printf("%d\n",total);

    return 0;
}


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

int main(){
  int N; cin >> N;
  string s; cin >> s;
  string sf = s.substr(0, N);
  string ss = s.substr(N, N);
  reverse(ss.begin(), ss.end());
  
  ll ans = 0;
  for(int i = 0; i < (1<<N); i++){
    string red = "", blue = "";
    for(int j = 0; j < N; j++){
      if((i>>j)&1) red += sf[j];
      else blue += sf[j];
    }
    
    int R = red.size(), B = blue.size();
    vector<vector<ll> > dp(R+1, vector<ll>(B+1, 0LL) );
    
    dp[0][0] = 1LL;
    for(int r = 0; r < R; r++){
      if(red[r] == ss[r]) dp[r+1][0] = dp[r][0];
    }
    for(int b = 0; b < B; b++){
      if(blue[b] == ss[b]) dp[0][b+1] = dp[0][b];
    }
    
    for(int r = 0; r < R; r++){
      for(int b = 0; b < B; b++){
        if(ss[r+b+1] == red[r]) dp[r+1][b+1] += dp[r][b+1];
        if(ss[r+b+1] == blue[b]) dp[r+1][b+1] += dp[r+1][b];
      }
    }
    ans += dp[R][B];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
//AOJ ITP1_2_A

using System;

class sample
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        double a = double.Parse(str[0]);
        double b = double.Parse(str[1]);

        if (a > b) Console.WriteLine("a > b");
        else if (a < b) Console.WriteLine("a < b");
        else Console.WriteLine("a == b");
    }
}

Measured memory_bytes: 9220
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

M = 10**9+7 # 出力の制限
N = n+10 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

ans = 0
for ind in range(n):
    ans += a[ind] * cmb(ind, k-1, M)
    ans -= a[n-1-ind] * cmb(ind, k-1, M)
    ans %= M
print(ans%M)

Measured memory_bytes: 92432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<deque>
#include<set>
#define inf 1e9
#define eps 1e-6
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll a[3];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(register int i=0;i<3;i++)a[i]=read();
	sort(a,a+3);
	for(register int i=0;i<3;i++){if(a[i]%2==0){puts("0");return 0;}}
	printf("%lld\n",a[0]*a[1]);
	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int X,Y,W,H;
int N;

void solve() {
    cin>>X>>Y>>W>>H;
    cin>>N;
    int ans=0;
    rep(i,N) {
        int x,y;
        cin>>x>>y;
        if(X<=x&&x<=X+W && Y<=y&&y<=Y+H) ans++;
    }
    cout<<ans<<endl;
}

int main() {
    int t;
    cin>>t;
    while(t-->0) solve();
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	long long L[87];
	int N;
	scanf("%d", &N);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 2] + L[i - 1];
	}

	printf("%lld\n", L[N]);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  map<int,int>ma;
  rep(i,n)
  {
    int a;
    cin>>a;
    ma[a]++;
  }
  vector<pair<int,int>>mama;
  for(auto tp:ma)
  {
    if(tp.second>=2)mama.push_back({tp.first,tp.second});
  }
  mama.push_back({0,100});
  sort(all(mama),greater<pair<int,int>>());
  ll res=1;
  if(mama[0].second>=4)res=(ll)mama[0].first*mama[0].first;
  else res=(ll)mama[0].first*mama[1].first;
  cout<<res<<endl;




  return 0;

}


Measured memory_bytes: 4992
slis=list(map(int,input()))
e_slis=[]
o_slis=[]
for i in range(len(slis)):
	if i%2==0:
		o_slis.append(slis[i])
	else:
		e_slis.append(slis[i])
print(min(o_slis.count(0)+e_slis.count(1),o_slis.count(1)+e_slis.count(0)))	
	

Measured memory_bytes: 4768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < s.size() / 2; i++) {
		if (s.substr(0, i) == s.substr(i, i)) {
			ans = max(ans, i * 2);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << n / 3 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = Integer.parseInt(scan.next());
        int B = Integer.parseInt(scan.next());
        int C = Integer.parseInt(scan.next());
        int K = Integer.parseInt(scan.next());

        if (A >= K) {
            System.out.println(K);
        } else if ((A + B) >= K) {
            System.out.println(A);
        } else {
            System.out.println(A - (K - (A + B)));
        }
    }
}

Measured memory_bytes: 27008
def solve(arr, n, k, pos)
  len = n
  while len != 1
    arr.slice!(pos)
    len -= 1
    pos = (pos + k - 1) % len
  end
  arr[0]
end

loop do
  n, k, m = gets.split.map(&:to_i)
  break if n == 0
  puts solve((1..n).to_a, n, k, m - 1)
end

Measured memory_bytes: 13080
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int INF = 1e9;
const int L = 128;
const string ANS = "holllad0npePIt0";

int query(const string &s) {
#ifdef LOCAL
    vector<vi> dp(si(s)+1, vi(si(ANS)+1));
    dforsn(i,0,si(s)+1) dforsn(j,0,si(ANS)+1) {
        if (i == si(s)) dp[i][j] = si(ANS)-j;
        else if (j == si(ANS)) dp[i][j] = si(s)-i;
        else {
            dp[i][j] = 1 + min(dp[i+1][j], dp[i][j+1]);
            dp[i][j] = min(dp[i][j], (s[i] != ANS[j]) + dp[i+1][j+1]);
        }
    }
    return dp[0][0];
#else
    cout << "? " << s << endl;
    int ans; cin >> ans;
    return ans;
#endif
}

int len;

string merge(const string &s, const string &t) {
    string ans;
    int i = 0, j = 0;
    while (i < si(s) && j < si(t)) {
        auto query_string = ans + t[j] + s.substr(i);
        if (query(query_string) > len - si(query_string)) {
            ans += s[i];
            i++;
        }
        else {
            ans += t[j];
            j++;
        }
    }
    ans += s.substr(i);
    ans += t.substr(j);
    return ans;
}

string go(const vector<string> &seq, int l, int r) {
    if (l+1 == r) return seq[l];
    int m = (l+r)/2;
    auto s = go(seq,l,m), t = go(seq,m,r);
    return merge(s,t);
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    string alpha;
    forn(i,26) {
        alpha += 'a'+i;
        alpha += 'A'+i;
        if (i < 10) alpha += '0'+i;
    }

    len = 0;
    vector<string> seq;
    for (auto c : alpha) {
        int k = L - query(string(L,c));
        if (k) seq.eb(k,c);
        len += k;
    }
    auto ans = go(seq, 0, si(seq));
    cout << "! " << ans << endl;

    return 0;
}


Measured memory_bytes: 3776
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            for (var i = 0; i <= X / 100; i++)
            {
                if (100 <= X && X <= 105 * i)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            Console.WriteLine("0");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t N, Y;
	cin >> N >> Y;

	for (int32_t cnt_man = 0; ; cnt_man++) {
		if (cnt_man > N || cnt_man * 10000 > Y)
			break;

		for (int32_t cnt_gosen = 0; ; cnt_gosen++) {
			if (cnt_man + cnt_gosen > N || cnt_man * 10000 + cnt_gosen * 5000 > Y)
				break;

			int32_t cnt_sen = N - cnt_man - cnt_gosen;
			int32_t total_money =  cnt_man * 10000 + cnt_gosen * 5000 + cnt_sen * 1000;
			if (total_money > Y)
				break;

			if (total_money == Y) {
				cout << cnt_man << " " << cnt_gosen << " " << cnt_sen << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {

  case class Bulb(nSwitch: Int, switches: IndexedSeq[Int], parity: Int)


  def read() = {
    val sc = new Scanner(System.in)
    val nSwitch, nBulb = sc.nextInt()
    val ks = IndexedSeq.fill[(Int, IndexedSeq[Int])](nBulb) {
      val k = sc.nextInt()
      val s = IndexedSeq.fill[Int](k)(sc.nextInt()-1)
      (k, s)
    }
    val p = IndexedSeq.fill(nBulb)(sc.nextInt())
    val bulbs = (ks, p).zipped.map((kse, pe) => Bulb(kse._1, kse._2, pe))
    (nSwitch, nBulb, bulbs)
  }

  def solve(nSwitch: Int, nLight: Int, bulbs: IndexedSeq[Bulb]): Int = {
    //On: 1, Off: 0

    def lights(switchInfo: IndexedSeq[Int], bulb: Bulb): Boolean = {
      bulb.switches.map(switchInfo).sum % 2 == bulb.parity
    }

    val allSwitchInfo = for (switchBinaryInfo <- 0 until (1 << nSwitch)) yield {
      IndexedSeq.tabulate(nSwitch)(k => (switchBinaryInfo >> k) & 1)
    }

    allSwitchInfo.count(switchInfo => bulbs.forall(bulb => lights(switchInfo, bulb)))
  }

  def main(args: Array[String]): Unit = {
    val (nSwitch, nBulbs, bulbs) = read()
    val result = solve(nSwitch, nBulbs, bulbs)
    println(result)
  }
}

Measured memory_bytes: 29972
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
long long a,b,af,bf;
int main()
{
    cin>>a>>b;
    af=1LL;
    bf=1LL;
    for(int i=1;i<=a;i++)
    {
        af=(af*(1LL*i))%MOD;
    }
    for(int i=1;i<=b;i++)
    {
        bf=(bf*(1LL*i))%MOD;
    }
    if(abs(a-b)>1)
    {
        printf("0\n");
    }
        else
    {
       if(a==b)
       {
           printf("%lld\n",(2LL*af*bf)%MOD);
       }
        else printf("%lld\n",(af*bf)%MOD);

    }
    return 0;
}


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

int const N_MAX = 100000;
int const Q_MAX = 5000;

int S[N_MAX];
int T[Q_MAX];

int linearSearch(int key, int n) {
  S[n] = key;
  int i = 0;
  while (S[i] != key) i++;
  if (i == n) return 0;
  return 1;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> T[i];
  }
  int dep = 0;
  for (int i = 0; i < q; ++i) {
    dep += linearSearch(T[i], n);
  }
  cout << dep << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define inf 100000000000000LL
#define ll long long
#define mx 1000007
using namespace std;

vector< vector<ll> > tree( 4LL*mx, {0LL,inf} );

ll f(vector<ll> line, int x){
	return line[0] * x + line[1];
}

void insert(vector<ll> line, int lo = 1, int hi = mx, int i = 1){
	int m = (lo + hi) / 2;
	bool left = f(line, lo) < f(tree[i], lo);
	bool mid = f(line, m) < f(tree[i], m);

	if(mid) swap(tree[i], line);

	if(hi - lo == 1) return;
	else if(left != mid) insert(line, lo, m, 2*i);
	else insert(line, m, hi, 2*i+1);
}

ll query(int x, int lo = 1, int hi = mx, int i = 1){
	int m = (lo+hi)/2;
	ll curr = f(tree[i], x);
	if(hi-lo==1) return curr;
	if(x<m) return min(curr, query(x, lo, m, 2*i));
	else return min(curr, query(x, m, hi, 2*i+1));
}

ll dp[mx];

int main()
{
	ll n,c;
	cin>>n>>c;

	ll h[n+5];

	for( int i=1;i<=n;i++ )
	{
		cin>> h[i];

		if(i>1)
			dp[i]= h[i]*h[i]+c+query( h[i] );

		insert( { -2*h[i], h[i]*h[i]+dp[i] } );
	}

	cout<< dp[n] <<"\n";
}


Measured memory_bytes: 225264
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();

		int[] A = new int[60000];

		int[] dA = {3,5,7};
		int x = 0;
		int y = 0;

		int count = 0;
		Queue<String> queue = new ArrayDeque<String>();
		queue.add("3");
		queue.add("5");
		queue.add("7");

		while(y < N){
			x = Integer.parseInt(queue.poll());
			for(int i = 0 ; i < 3 ; i++){
				y = x * 10 + dA[i];
				queue.add(String.valueOf(y));
				//System.out.println(y);

			if(y >100 && y <= N){
				//System.out.println(y);
				String yy = String.valueOf(y);
				if(yy.contains("3")&&yy.contains("5")&&yy.contains("7")){
					//System.out.println(yy);
					count++;
				}
			}


			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 26580
N,M,C = map(int,input().split())
Bls = list(map(int,input().split()))
ii = 0
for i in range(N):
    sum1 = 0
    Als = list(map(int,input().split()))
    for j in range(M):
        sum1 += Bls[j]*Als[j]
    if sum1 + C > 0:
        ii += 1
print(ii)

Measured memory_bytes: 9132
#include <stdio.h>
int main()
{
	int h=0,m,s;
	scanf("%d",&s);
	m=s/60;
	if(h=m/60)
	{
		m=m%60;
	}
		s=s%60;
   	printf("%d:%d:%d\n",h,m,s);
   	return 0;
}

Measured memory_bytes: 592
def solve():
	t,*a=open(0)
	h,w=map(int,t.split())
	a=[[int(x)%2 for x in y.split()] for y in a]
	ret=[]
	for i in range(h):
		for j in range(w-1):
			if a[i][j]:
				a[i][j+1]^=1
				ret+=[" ".join(map(str,[i+1,j+1,i+1,j+2]))]
	for i in range(h-1):
		if a[i][-1]:
			a[i+1][-1]^=1
			ret+=[" ".join(map(str,[i+1,w,i+2,w]))]
	print(len(ret),*ret,sep="\n")
	
if __name__=="__main__":
	solve()

Measured memory_bytes: 18548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, W;
    cin >> n >> W;
    vector<pair<int, int>> arr(n);
    for (auto &x : arr) cin >> x.first >> x.second;
    int dp[n][W+1];
    for (int j = 0; j <= W; ++j) dp[0][j] = (j >= arr[0].first) ? arr[0].second : 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= W; ++j)
        {
            if (j >= arr[i].first)
                dp[i][j] = max(dp[i-1][j], arr[i].second + dp[i-1][j-arr[i].first]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n-1][W] << '\n';
    return 0;
}

Measured memory_bytes: 78336