akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int N = sc.nextInt(), M = sc.nextInt(), K = sc.nextInt();
		
		long[] Apref = new long[N+1];
		for (int i = 0; i < N; i++) {
			Apref[i+1] = Apref[i] + sc.nextInt();
		}
		
		TreeMap<Long, Long> map = new TreeMap<>();
		map.put(0l, 0l);
		long s = 0;
		for (int i = 0; i < M; i++) {
			s += sc.nextInt();
			map.put(s, i+1l);
		}
		
		long best = 0;
		for (int i = 0; i <= N; i++) {
			Long k = map.floorKey(K - Apref[i]);
			if (k != null) {
				best = Math.max(best, i + map.get(map.floorKey(K - Apref[i])));
			}
		}
		
		System.out.println(best);
	}
}

Measured memory_bytes: 78132
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				double p = sc.nextDouble();
			
				if(n==0 && m==0 && p==0)	break;
				int gold = 0;
				int x[] = new int[n];
				for(int i=0; i<n; i++) {
					x[i] = sc.nextInt();
					gold += x[i]*100;
				}
				if(x[m-1] == 0) {
					System.out.println(0);
				}else {
					System.out.println((int)((gold-(gold*(p*0.01) ) )/x[m-1]));
				}
				
					
				
			}
			
			
			
			
				
		}
	}
}


Measured memory_bytes: 38000
#include <iostream>


int main() {
  int n, x;
  int rest, count;

  while (true) {
    count = 0;
    std::cin >> n >> x;
    if (n == 0 && x == 0) break;

    for (int i = 1; i < n - 1; i ++) {
      for (int j = i + 1; j < n; j ++) {
        rest = x - (i + j);
        if (rest > j && rest <= n) {
          count += 1;
        }
      }
    }
    std::cout << count << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3084
n = int(raw_input())
mat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    ls = map(int,raw_input().split())
    u = ls[0]
    k = ls[1]
    for m in range(k):
        mat[u-1][ls[2+m]-1] = 1
for item in mat:
    print ' '.join(map(str,item))

Measured memory_bytes: 4292
#include <iostream>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;

vector<char> alps(26,-1), alpt(26,-1); // char - 'a'
string s, t;

int main(){

  cin >> s;
  cin >> t;

  bool ok = true;
  rep(i,s.size()){
    int a = s[i] - 'a';
    int b = t[i] - 'a';

    if(alps[a] != -1 || alpt[b] != -1){
      if(alps[a] != b || alpt[b] != a){
	cout << "No" << endl;
	return 0;
      }
    }
    else{
      alps[a] = b;
      alpt[b] = a;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N],q[N];


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
        string s,t;
        cin>>s>>t;
        int ls=s.size(),lt=t.size();
        int maxn=-1;
        for(int i=0;i+lt<=ls;i++)
        {
            int res=0;
            for(int j=0;j<lt;j++)
            {
                if(t[j]==s[i+j])res++;
            }
            maxn=max(maxn,res);

        }
        cout<<lt-maxn<<endl;
	}
	return 0;
}


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

int main() {
  
   int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  
  int k = 0;
  
  for (int i = 1; i < n - 1; i++){
    if (v.at(i) < v.at(i + 1) 
        && 
        v.at(i) > v.at(i - 1)){
      k++;
    }
    
    else if (v.at(i) > v.at(i+1) 
             && 
             v.at(i) < v.at(i - 1)){
      k++;
    }
  }
  
  cout << k << endl;
  
}
  
  

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

namespace ABC160c
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');

            int k = int.Parse(s[0]);
            int n = int.Parse(s[1]);

            var q = Console.ReadLine().Split(' ');

            List<int[]> list = new List<int[]>();

            int max = 0;
            for (int i = 0; i < n; i++)
            {
                int p = int.Parse(q[i]);
                int dist = p;
                if (i != 0)
                {
                    dist -= list[i - 1][0];
                }

                if (max < dist)
                {
                    max = dist;
                }

                int[] g = { p, dist };
                list.Add(g);
            }
            list[0][1] += k - list[n - 1][0];
            if(max < list[0][1])
            {
                max = list[0][1];
            }

            Console.WriteLine(k - max);
        }
    }
}


Measured memory_bytes: 39008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
ll n, k, ans;
ll a[N], b[N];
int main()
{
	scanf("%lld%lld", &n, &k);
	for(int i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);
	for(ll i = 1; i <= (1ll << 30); i <<= 1) if(k & i) 
	{
		ll tmp = 0, t = (k ^ i) | (i - 1);
		for(int j = 0; j < n; ++j) if((a[j] & t) == a[j]) tmp += b[j];
		ans = max(ans, tmp);
	}
	ll tmp = 0;
	for(int i = 0; i < n; ++i) if((a[i] & k) == a[i]) tmp += b[i];
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}
fn main() {
    let s = get!(String).chars().collect::<Vec<_>>();
    let diff = {
        let mut head: isize = 0;
        let mut tail: isize = s.len() as isize - 1;
        let mut head_cnt_x = 0isize;
        let mut tail_cnt_x = 0isize;
        let mut diff = 0;
        'outer: loop {
            if tail <= head {
                break;
            }
            while s[head as usize] == 'x' {
                head_cnt_x += 1;
                head += 1;
                if head == s.len() as isize {
                    break;
                }
            }
            while s[tail as usize] == 'x' {
                tail_cnt_x += 1;
                tail -= 1;
                if tail == -1 {
                    break;
                }
            }
            diff += (head_cnt_x - tail_cnt_x).abs() as usize;
            if head == s.len() as isize && tail == -1 {
            } else if head == s.len() as isize || tail == -1 {
                println!("{}", -1);
                return;
            } else if s[head as usize] != s[tail as usize] {
                println!("{}", -1);
                return;
            } else {
            }
            head += 1;
            tail -= 1;
            head_cnt_x = 0;
            tail_cnt_x = 0;
        }
        diff
    };
    println!("{}", diff);
}



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

int main() {
  long long x;
  cin >> x;
  int y = 0;
  long long a = 100;
  
  while(a<x){
    a += a/100;
    y++;
  }
  
  cout << y << endl;
	return 0;
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] strArray = str.Split(' ');

            int a = int.Parse(strArray[0]);
            int b = int.Parse(strArray[1]);

            int tasizann = a + b;
            int kakezann = a * b;
            int hikizann = a - b;

            if (tasizann > kakezann && tasizann > hikizann)
                Console.WriteLine(tasizann);
            else if (kakezann > tasizann && kakezann > hikizann)
                Console.WriteLine(kakezann);
            else Console.WriteLine(hikizann);
        }
    }
}

Measured memory_bytes: 13140
from math import sqrt, floor
n = int(input())
ans = 0
for i in range(1, floor(sqrt(n))+1):
    if n % i == 0:
        if n / i < i - 1:
            ans += i - 1
        if i < n / i - 1:
            ans += n // i - 1
print(ans)


Measured memory_bytes: 2940
H, W = map(int, input().split())
a = [[i for i in input()] for _ in range(H)]
a_new = []
a_new_new = []

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            a_new.append(a[i])
            break

a_ = list(zip(*a_new))
a_H  = len(a_)
a_W  = len(a_[0])

for i in range(a_H):
    for j in range(a_W):
        if a_[i][j] == '#':
            a_new_new.append(a_[i])
            break
 
for i in list(zip(*a_new_new)):
    print(''.join(i))

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    int a[105];
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int s=a[n-1]-a[0];
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int num[n],coppy[n];
    rep(i,n) cin >> num[i];
    rep(i,n) coppy[i] = num[i];
    sort(coppy,coppy+n);
    reverse(coppy,coppy+n);
    bool check = false;
    if(coppy[0] == coppy[1]){
        rep(i,n){
            cout << coppy[0] << endl;
        }
    }
    else{
        rep(i,n){
            if(num[i] == coppy[0]){
                cout << coppy[1] << endl;
            }
            else{
                cout << coppy[0] << endl;
            }
        }
    }
}

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

ll choose2(ll n) {
    return n*(n-1)/2;
}

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> cnt(n, 0);
    rep(i, n) cnt[a[i]]++;
    ll tot = 0;
    rep(i, n) tot += choose2(cnt[i]);
    rep(i, n) {
        ll ans = tot;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  long long A,B,N;
  cin >> A >> B >> N;
  
  if (B-1 <= N){
    cout << A*(B-1)/B << endl;
  }
  else {
    cout << A*N/B << endl;
  }
}

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  if(A == B){
    cout << 1 << endl;
    return 0;
  }
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  if(A > B){
    cout << 0 << endl;
    return 0;
  }
  if(N == 2){
    cout << 1 << endl;
    return 0;
  }
  ll Min;
  Min = (N-1)*A+B;
  ll Max;
  Max = (N-1)*B+A;
  cout << Max-Min+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, w[1010];
long long S1, S2;
vector<int>res;
void Add(int a){
	res.push_back(a);
}
void Print() {
	printf("%d\n", res.size());
	for (auto &tp : res)printf("%d\n", tp);
}
int main() {
	int i, ck = 0, Mx = -2e9, pv = 0, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%lld", &w[i]);
		if (Mx < w[i])Mx = w[i], pv = i;
		if (w[i] > 0) {
			ck = 1;
			if (i % 2)S1 += w[i];
			else S2 += w[i];
		}
	}
	if (!ck) {
		printf("%d\n", Mx);
		for (i = n; i > pv; i--)Add(i);
		for (i = 1; i < pv; i++)Add(1);
		Print();
		return 0;
	}
	vector<int>T;
	if (S1 < S2) {
		printf("%lld\n", S2);
		for (i = 1; i <= n; i++)if (w[i] > 0 && i % 2 == 0)T.push_back(i);
	}
	else {
		printf("%lld\n", S1);
		for (i = 1; i <= n; i++)if (w[i] > 0 && i % 2 == 1)T.push_back(i);
	}
	for (i = n; i > T.back(); i--)Add(i);
	for (i = T.size() - 2; i >= 0; i--) {
		int c = (T[i + 1] - T[i]) / 2 - 1;
		for (j = 0; j < c; j++)Add(T[i] + 2);
		Add(T[i] + 1);
	}
	for (i = 1; i < T[0]; i++)Add(1);
	Print();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b;
	cin >> a >> b;
	int mx = b - a;
	ll bz = 1LL * mx * (mx+1)/2;
	cout << bz - b << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray().Select(i => int.Parse(i.ToString())).ToArray();
            var c0 = s.Count(i => i == 0);
            var c1 = s.Count(i => i == 1);

            Console.WriteLine(Math.Min(c0,c1) * 2);
        }
    }
}


Measured memory_bytes: 17248
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int main()
{
        long long n;
        scanf("%lld",&n);
        long long a[n],dp[n];
//      memset(
        for(int i =0;i<n;i++) scanf("%lld", a+i);
        dp[0] = 0;
        dp[1] = fabs(a[1] - a[0]);
        for(int i = 2;i<n;i++)
        dp[i] = fmin(dp[i-2]+ fabs(a[i] - a[i-2]), dp[i-1] + fabs(a[i] - a[i-1]));
        printf("%lld\n", dp[n-1]);
        return 0;
}


Measured memory_bytes: 1792
open Printf
open Scanf

let () =
  let shiritori a b c =
    if a.[String.length a - 1] = b.[0] && b.[String.length b - 1] = c.[0] then "YES" else "NO" in
  let a, b, c = scanf "%s %s %s\n" (fun x y z -> (x, y, z)) in
  shiritori a b c |> printf "%s\n"


Measured memory_bytes: 384
n = gets.to_i
as = gets.split.map(&:to_i)
total = as.inject(:+)

ss = Array.new(n + 1, 0)
min = 2020202020

as.each_with_index do |a, i|
  ss[i + 1] = ss[i] + a
  diff = (ss[i] + a - (total - ss[i + 1])).abs

  min = diff if diff <= min
end

puts min


Measured memory_bytes: 17668
N = input()
L = len(N)
K = int(input())
if L < K:
    print(0)
else:

    def main(d, k):
        if (L - d) < k:
            return 0
        if N[d] == "0":
            return main(d + 1, k)
        if k == 1:
            return ((L - d) - 1) * 9 + int(N[d])
        elif k == 2:
            return (
                ((((L - d) - 1) * ((L - d) - 2)) // 2) * 81
                + ((L - d) - 1) * 9 * (int(N[d]) - 1)
                + main(d + 1, k - 1)
            )
        elif k == 3:
            return (
                ((((L - d) - 1) * ((L - d) - 2) * ((L - d) - 3)) // 6) * (9 ** 3)
                + ((((L - d) - 1) * ((L - d) - 2)) // 2) * 81 * (int(N[d]) - 1)
                + main(d + 1, k - 1)
            )

    print(main(0, K))



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

int main(){
  int n;
  cin >> n;
  bool flg = true;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;

    if(a%2==0){
      if(a%3!=0 && a%5!=0) flg = false;
    }
  }
  if(flg)puts("APPROVED");
  else puts("DENIED");
  
}

Measured memory_bytes: 256
s = input().split()
h = int(s[0])
w = int(s[1])

mine = [[0 for j in range(w)] for i in range(h)]


# 入力
for j in range(h):
    p = input()
    q = list(p)
    for i in range(w):
        mine[j][i] = str(q[i])

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            continue

        num = 0
        for d in range(len(dx)):
            ni = i + dy[d]
            nj = j + dx[d]

            if ni < 0 or h <= ni:
                continue
            if nj < 0 or w <= nj:
                continue
            if mine[ni][nj] == '#':
                num += 1
        
        
        mine[i][j] = str(num)

for i in range(h):
    for j in range(w):
        print(mine[i][j],end='')
    print('')

print('')


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

using namespace std;
#define int long long
#define rep(i,N) for(int (i)=0;(i) < (N);++(i))

struct coor{int x,y;};

bool dp_x[8100][32100];
bool dp_y[8100][32100];


signed main(){
    string s;cin>>s;
    s+="T";
    int X,Y; cin>>X>>Y;
    X += 16000; Y += 16000;

    int cnt = 0;
    bool dir = true; //0 -> X , 1 -> Y 
    vector<int> step_x,step_y;
    rep(i,s.size()){
        if(s[i] == 'F') ++cnt;
        else{
            if(dir) step_x.push_back(cnt);
            else step_y.push_back(cnt);
            dir = !dir;
            cnt = 0;
        }
    }
    step_x.push_back(0); step_y.push_back(0); 

    dp_x[0][16000 + step_x[0]] = true;
    dp_y[0][16000 + step_y[0]] = dp_y[0][16000 - step_y[0]] = true;

    for(int i=1; i < step_x.size(); ++i){
        for(int x = 8000; x <= 24000; ++x){
                dp_x[i][x] = dp_x[i-1][x + step_x[i]] | dp_x[i-1][x - step_x[i]];
        }
    }

    for(int i=1; i < step_y.size(); ++i){
        for(int y = 8000; y <= 24000; ++y){
                dp_y[i][y] = dp_y[i-1][y + step_y[i]] | dp_y[i-1][y - step_y[i]];
        }
    }

    if(dp_x[step_x.size()-1][X] && dp_y[step_y.size()-1][Y]) cout<<"Yes\n";
    else cout<<"No\n";
}
    


Measured memory_bytes: 251520
// Selection Sort
#include <stdio.h>

int selectionSort(int A[], int N)
{
    int i, j, minj, tmp, cnt = 0;
    for(i=0; i<N; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            cnt++; 
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
        }
    }
    return cnt; 
}

int main(void)
{
    int N, i;
    scanf("%d", &N);
    int A[N];
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    int cnt = selectionSort(A, N);
    for(i=0; i<N; i++){
        if(i==N-1){
            printf("%d\n", A[i]);
        }else{
            printf("%d ", A[i]);
        }
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2104
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    inf = 10**17
    #mod = 10**9 + 7

    n,m,s = map(int, input().split())
    s = min(s, 2500)
    # edge[i]:頂点iからの[行先, 必要な銀貨, 時間]
    edge = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b,c,d = map(int, input().split())
        edge[a-1].append((b-1, c, d))
        edge[b-1].append((a-1, c, d))

    # 銀貨との交換を自己ループとする
    for i in range(n):
        c, d = map(int, input().split())
        edge[i].append((i, -c, d))

    dp = [[inf]*2501 for _ in range(n)]
    dp[0][s] = 0
    # [時間, 所持金, 頂点]
    hq = [(0, s, 0)]
    heapify(hq)

    while hq:
        t, ginka, v = heappop(hq)
        if dp[v][ginka] < t:
            continue
        for nv, a, b in edge[v]:
            if ginka < a:
                continue
            ng = ginka - a
            if ng > 2500:
                ng = 2500
            for i in range(ng, -1, -1):
                if dp[nv][i] > t+b:
                    dp[nv][i] = t+b
                    f = 1
                else:
                    break
            else:
                heappush(hq, (t+b, ng, nv))
            if i != ng:
                heappush(hq, (t+b, ng, nv))
    
    for i in range(1, n):
        print(min(dp[i]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 71736
import math
A,B = map(int,input().split())
Acand = []
for i in range(math.ceil(A*(100/8)),math.floor((A+1)*(100/8))):
  Acand.append(i)
Bcand = []
for i in range(math.ceil(B*10),math.floor((B+1)*10)):
  Bcand.append(i)
doub = list(set(Acand) & set(Bcand))
doub.sort()
if len(doub) == 0:
  print(-1)
else:
  print(doub[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

long long M  = 1e9+7;
 
signed main(){
    fast;
    int n;
    set <string> st;
    cin >> n;
    for(int i=0 ; i<n ; i++){
    	string x; cin >> x;    		st.insert(x);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19260
#include<bits/stdc++.h>
    #define int long long int  
    using namespace std;
    string s,t;
    int dp[3001][3001];
    int solve(int idx1,int idx2)
    {
        if(idx1==0 || idx2==0) return 0;
        if(dp[idx1][idx2]!=-1)
            return dp[idx1][idx2];

        if(s[idx1-1]==t[idx2-1])
            return dp[idx1][idx2]=1+solve(idx1-1,idx2-1);
        return dp[idx1][idx2]=max(solve(idx1-1,idx2),solve(idx1,idx2-1));
    }

    signed main()
    {
        

        cin>>s>>t;
        memset(dp,-1,sizeof dp);
        solve(s.size(),t.size());

        int i = s.size(),j = t.size();
        /*vector<char>v;
        while(i>0 and j >0)
        {
            if(dp[i][j]==dp[i-1][j])
                i--;
           else  if(dp[i][j]==dp[i][j-1])
                j--;
            else 
            {
                v.push_back(s[i-1]);
                i--;
                j--;
            }
        }
        reverse(v.begin(),v.end());
        for(auto it:v)
            cout<<it;*/
      
        char lcs[4000];
        int index=dp[s.size()][t.size()];
        lcs[index]= '\0';

       // int i = m, j = n; 
        while (i > 0 && j > 0) 
        { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
        if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
        } 
        cout<<lcs<<"\n";
    }

Measured memory_bytes: 70912
N = int(input())
BX = list(map(int, input().split()))

AX = [0 for _ in range(N)]
AX[N-1] = BX[N-2]
AX[N-2] = BX[N-2]
for i in reversed(range(N - 2)):
    if BX[i] < BX[i+1]:
        AX[i+1] = BX[i]
    AX[i] = BX[i]
    
print(sum(AX))
    

Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    int n,m;
    cin>>n>>m;
	priority_queue<int> que;
	rep(i,0,n){
		int a;
		cin>>a;
		que.push(a);
	}
	rep(i,0,m){
		int a=que.top();
		que.pop();
		a=a/2;
		que.push(a);
	}
	ll sum=0;
	rep(i,0,n){
		sum=sum+que.top();
		que.pop();
	}
	cout<<sum<<endl;
	return 0;
	
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 892
#include<stdio.h>
main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n],b[m],vote[n];
    int i,j;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        vote[i]=0;
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            if(b[i]>=a[j]){
                vote[j]++;
                break;
            }
        }
    }
    int ans=0,max=vote[0];
    for(i=1;i<n;i++){
        if(max<vote[i]){
            max=vote[i];
            ans=i;
        }
    }
    printf("%d\n",ans+1);
    return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int x, y, n;
  int res[17][17];
  while (cin >> x >> y, x || y ) {
    memset(res[0] + 0, 0, sizeof(int) * 17 * 17);
    cin >> n;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      res[b - 1][a - 1] = -1;
    }

    res[0][0] = 1;
    for (int i = 0; i < y; i++)
      for (int j = 0; j < x; j++)
        if (res[i][j] < 0)
          continue;
        else if (i == 0 && j > 0)
          res[i][j] = res[i][j - 1] < 0 ? 0 : res[i][j - 1];
        else if (i > 0 && j == 0)
          res[i][j] = res[i - 1][j] < 0 ? 0 : res[i - 1][j];
        else if (i > 0 && j > 0)
          res[i][j] = (res[i][j - 1] < 0 ? 0 : res[i][j - 1])
                    + (res[i - 1][j] < 0 ? 0 : res[i - 1][j]);
    cout << res[y - 1][x - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#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 sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n,a;
	cin >> n;
	vector<ll>vc(n);
	for (int i = 0; i < n-1; i++) {
		cin >> a;
		vc[--a]++;
	}
	for (int i = 0; i < n; i++)
		cout << vc[i] << '\n';
	return 0;
}

Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main(void) {
	int N, M;
	ll ans = 0, c = 0;
	scanf("%d%d", &N, &M);
	vector<ll> A(N), S(N + 1);
	map<ll, ll> R;
	rep(i, 0, N)scanf("%lld", &A[i]);
	S[0] = 0;
	rep(i, 1, N + 1)S[i] = S[i - 1] + A[i - 1];
	rep(i, 0, N + 1)R[S[i] % M]++;
	for (auto c : R)ans += c.second * (c.second - 1) / 2;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5760
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll a,b,ans=0; cin>>a>>b;
    if(a>0) a--;
    if(b&(1LL)){
        if(!(b&(1LL<<1))) ans^=1LL;
    }
    else{
        if(b&(1LL<<1)) ans^=1;
        rep(i,50){
            if(b&(1LL<<(i+1))) ans^=(1LL<<(i+1));
        }
    }
    if(a&(1LL)){
        if(!(a&(1LL<<1))) ans^=1LL;
    }
    else{
        if(a&(1LL<<1)) ans^=1;
        rep(i,50){
            if(a&(1LL<<(i+1))) ans^=(1LL<<(i+1));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	if(n==1)
	{
		if(m==1)	printf("1\n");
		else if(m==2)	printf("0\n");
		else	printf("%lld\n",m-2);
	}
	else if(m==1)
	{
		if(n==2)	printf("0\n");
		else	printf("%lld\n",n-2);
	}
	else
		printf("%lld\n",n*m-2*n-2*m+4);
	return 0;
}

Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    ll n, k;

    cin >> n >> k;

    ll backet[200200] = {0};

    for(int i = 1; i <= n; i++){
        backet[i % k]++;
    }
    
    ll ans = 0;
    for(int a = 0; a < k; a++){
        int b = (k - a) % k;
        int c = (k - a) % k;
        if((b + c) % k == 0){
            ans+= backet[a] * backet[b] * backet[c];
        }
    }

    cout << ans << endl;
    
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N, M, P;
    while(cin >> N >> M >> P, N != 0){
        vector<int> vote(N);
        int sum = 0;
        rep(i, N) {
            cin >> vote[i];
            sum += vote[i];
        }
        sum = (100 - P) * sum;
        if(vote[M-1] == 0) cout << 0 << endl;
        else cout << sum / vote[M-1] << endl;
    }
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define ll long long
#define db double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(a) (int)a.size()
#define sl(a) scanf("%lld",&a)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define p1(a) cout<<"warning-1-->> "<<a<<endl
#define p2(a,b) cout<<"warning-2-->>> "<<a<<' '<<b<<endl
#define p3(a,b,c) cout<<"warning-3-->>>"<<a<<' '<<b<<' '<<c<<endl
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fore(i,l,n) for(int i=int(l);i<int(n);i++)
#define clr(a) memset(a,0,sizeof(a))
#define MS(a,b) memset(a,b,sizeof(b))
#define SQ(a) (long long)a*a
#define bg begin()
#define en end()
//Value Define
#define MAX (int)(1e5+100)
#define MOD (int)(1000000007)
#define INF (long long)(1e18)
#define PI (double)acos(-1.00)
#define epsilon (double)0.00000001

using namespace std;

void solve(){
    ll a,v,b,w,t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    //if(a>=b) {printf("YES\n");return;}
    ll da,d;
    da=v*t;
    d=w*t;
    ll dif=abs(a-b);
    if(da>=d+dif) printf("YES\n");
    else printf("NO\n");

}
int main(){
    //freopen("in.txt","r",stdin);
    int t=1,ts=0;// si(t);
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Finding_Missing_Cards
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            FindingMissingCards problem = new FindingMissingCards();
            for (int i = 0; i < count; i++)
            {
                string line = Console.ReadLine();
                string[] strs = line.Split(' ');

                problem.AddCard(strs[0], int.Parse(strs[1]));
            }

            List<string> answers = problem.FindMissingCards();
            foreach (string answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }

    public class FindingMissingCards
    {
        
        private List<List<bool>> isFinded;

        public FindingMissingCards()
        {
            isFinded = new List<List<bool>>();
            for (int i = 0; i < 4; i++)
            {
                isFinded.Add(new List<bool>());
                for (int j = 0; j < 13; j++)
                {
                    isFinded[i].Add(false);
                }
            }
        }

        public void AddCard(string suit, int number)
        {
            if (suit.Equals("S")) isFinded[0][number - 1] = true;
            if (suit.Equals("H")) isFinded[1][number - 1] = true;
            if (suit.Equals("C")) isFinded[2][number - 1] = true;
            if (suit.Equals("D")) isFinded[3][number - 1] = true;

        }

        public List<string> FindMissingCards()
        {
            List<string> missingCards = new List<string>();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    if (isFinded[i][j] == false)
                    {
                        string card = "";
                        if (i == 0) card += "S";
                        if (i == 1) card += "H";
                        if (i == 2) card += "C";
                        if (i == 3) card += "D";

                        card += " " + (j + 1);
                        missingCards.Add(card);
                    }
                }
            }
            return missingCards;
        }
    }
}

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________

	ll a, b, n;
	cin >> a >> b >> n;
	ll x = min(n, b - 1);
	cout << (a * x) / b - a*(x / b) << en;
	return 0;
}


Measured memory_bytes: 3652
/* title: Caesar Cipher
	 source: JOI 2006-2007 Yosen No.3
	 hint: Just do it
*/
	 

#include <iostream>
#include <string>
using namespace std;


int main()
{
	string text;
	cin >> text;

	for(int i = 0; i < text.size(); i++) {
		text[i] -= 3;
		if(text[i] < 'A') text[i] += 'Z' - 'A' + 1;
	}

	cout << text << endl;
}

Measured memory_bytes: 1184
using System;

namespace AtCoder {
    class Unbalanced {
        static bool can(string S, int H) {
            int from = 0, to = H;
            bool parityFlag = false;
            for (int i = 0; i < S.Length; i++) {
                if (from == to) {
                    parityFlag = true;
                }

                if (!parityFlag) {
                    if (S[i] == '0') {
                        if (from == H) {
                            return false;
                        }

                        from++;
                        to = Math.Min(to + 1, H);
                    } else if (S[i] == '1') {
                        if (to == 0) {
                            return false;
                        }

                        from = Math.Max(from - 1, 0);
                        to--;
                    } else {
                        from = Math.Max(from - 1, 0);
                        to = Math.Min(to + 1, H);
                    }
                } else {
                    if (S[i] == '0') {
                        if (from == H) {
                            return false;
                        }

                        from++;
                        to = (to == H ? to - 1 : to + 1);
                    } else if (S[i] == '1') {
                        if (to == 0) {
                            return false;
                        }
                        from = (from == 0 ? 1 : from - 1);
                        to--;
                    } else {
                        from = (from == 0 ? 1 : from - 1);
                        to = (to == H ? to - 1 : to + 1);
                        if (from > to) {
                            return false;
                        }
                    }
                }
            }

            return true;
        }

        static void Main(string[] args) {
            string S = Console.ReadLine();
            int N = S.Length;

            int L = 0, R = N;

            while (R - L > 1) {
                int H = (L + R) / 2;
                if (can(S, H)) {
                    R = H;
                } else {
                    L = H;
                }
            }

            Console.WriteLine(R);
        }
    }
}


Measured memory_bytes: 20568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int solve(vector<int> g,int done){
  //cout<<"//"<<done<<"//  ";
  //rep(i,g.size()) cout<<g[i]<<"  ";
  //cout << endl;
  if(g.size() == 1) return g[0] - done;
  int index = distance(g.begin(), min_element(all(g)));
  int m = g[index] - done;
  if(index == 0){
    vector<int> right;
    copy(g.begin()+1,g.end(),back_inserter(right));
    return m + solve(right, done + m);
  }
  if(index == g.size()-1){
    vector<int> left;
    copy(g.begin(), g.end()-1,back_inserter(left));
    return m + solve(left, done + m);
  }
  else{
    vector<int> left;
    vector<int> right;
    copy(g.begin(), g.begin()+index ,back_inserter(left));
    copy(g.begin()+index+1 , g.end(),back_inserter(right));
    return m + solve(left, done + m) + solve(right, done + m);
  }
}

int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  cout << solve(h,0) << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,h,m = LI()
x = 30 * h +  (30 / 60) * m
y = 6 * m
z = abs(x-y)
z = min(360 - z, z)
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(z))
print(math.sqrt(c))

Measured memory_bytes: 65796
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define swap(a,b) (a+=b,b=a-b,a-=b)
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void AscRadix32(int *a,const int sz,const int minus)
{
  /*http://users.encs.concordia.ca/~chvatal/notes/rsort.html*/
  int x,shift=0,elem[256],temp[sz];
  while(shift<32)
  {
    int bucket[256]={0};
    rep(i,sz){x=(a[i]>>shift)&255;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,255)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&255;a[elem[x]]=temp[i];elem[x]++;}
    shift+=8;
  }
  rep(i,minus/2)swap(a[sz-minus+i],a[sz-1-i]);
  rep(i,(sz-minus)/2)swap(a[i],a[sz-minus-1-i]);
  rep(i,sz/2)swap(a[i],a[sz-1-i]);
}
int main(void)
{
  int N=IN(),c=CH(),i=0,m=0,p=0,z=0,temp,A[N];
  long K=0,low=-1e18,mid,high=-low,count;while(c>47&&c<58){K=K*10+c-48,c=CH();}
  rep(j,N){A[j]=IN();if(A[j]<0)m++;else if(A[j]>0)p++;else z++;}
  AscRadix32(A,N,m);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;else temp=0;
  if(K<=1l*m*p)high=1l;else low=-1l;
  while(high-low>1)
  {
    mid=(low+high)/2,count=0;
    if(!mid)count=1l*m*p;
    else if(mid>0)
    {
      count=1l*m*p+1l*z*(m+p)+1l*z*(z-1)/2;temp=N-1;i=m+z;if(count>=K){high=mid;continue;}
      while(i<N){while(1l*A[temp]*A[i]>=mid){temp--;}if(temp>i)count+=1l*temp-i,i++;else break;}
      temp=0;i=m-1;if(count>=K){high=mid;continue;}
      while(i>=0){while(1l*A[temp]*A[i]>=mid){temp++;}if(temp<i)count+=1l*i-temp,i--;else break;}
    }
    else
    {
      temp=m-1;i=N-1;
      while(i>=m+z){while(temp>=0&&1l*A[temp]*A[i]>=mid){temp--;}if(temp>=0){count+=1l*temp+1;}i--;}
    }
    if(count<K)low=mid;else high=mid;
  }
  return OUT(low),0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, K;
  while(cin >> N >> K,N){
  VL xs(N);
  REP(i,N) cin >> xs[i];

  LL acc = 0;
  REP(i,K) acc += xs[i];
  LL ans = acc;
  for(int i=K;i<N;++i){
	acc += xs[i] - xs[i-K];
	maxi(ans, acc);
  }
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
//import java.lang.Math;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int count = 0;
        for(int i = 0 ; n != 0 ; i++){
            n = n / k;
            count++;
        }
        System.out.print(count);
    }
}

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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  
  vector<vector <int>> A(n, vector<int> (m));
  vector<int> B(m);
  
  for (int i = 0; i < m; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int sum, count = 0;
  
  for (int i = 0; i < n; i++) {
    sum = c;
    for (int j = 0; j < m; j++) {
      sum += A.at(i).at(j) * B.at(j);
    }
    if (sum > 0) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,k;
    cin>>n>>k;
    map<ll,ll>mp;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        mp[x]=mp[x]+y;
    }
    ll p=0;
    for(int i=1;i<=100000;i++)
    {
        if(p+mp[i]<k)
        {
            p=p+mp[i];
        }
        else
        {
            cout<<i;
            exit(0);
        }
    }}

Measured memory_bytes: 9864
/*input
aaaA
abc
*/
fn main() {
    let mut alpha = std::collections::BTreeMap::new();
    alpha.insert('a', 0);
    alpha.insert('b', 0);
    alpha.insert('c', 0);
    alpha.insert('d', 0);
    alpha.insert('e', 0);
    alpha.insert('f', 0);
    alpha.insert('g', 0);
    alpha.insert('h', 0);
    alpha.insert('i', 0);
    alpha.insert('j', 0);
    alpha.insert('k', 0);
    alpha.insert('l', 0);
    alpha.insert('m', 0);
    alpha.insert('n', 0);
    alpha.insert('o', 0);
    alpha.insert('p', 0);
    alpha.insert('q', 0);
    alpha.insert('r', 0);
    alpha.insert('s', 0);
    alpha.insert('t', 0);
    alpha.insert('u', 0);
    alpha.insert('v', 0);
    alpha.insert('w', 0);
    alpha.insert('x', 0);
    alpha.insert('y', 0);
    alpha.insert('z', 0);
    let mut s;
    loop {
        s = format!("");
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => {
                break;
            }
            Ok(_) => {
                for i in s.to_lowercase().chars() {
                    if i.is_alphabetic() {
                        *alpha.get_mut(&i).unwrap() += 1;
                    }
                }
            }
            Err(_) => {}
        };
    }
    //*alpha.get_mut(&i).unwrap() = *alpha.get_mut(&i).unwrap() + 1;
    for i in alpha {
        println!("{} : {}", i.0, i.1);
    }
}



Measured memory_bytes: 5056