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

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);

        int count = 0;
        for (int i = a; i <= b; i++) {
            if (i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int N, C, s[101010], t[101010], c[101010];

int z[31][101010];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    for (int j = 0; j < 30; ++j) fill(z[j], z[j]+101010, 0);
    cin >> N >> C;
    for (int j = 0; j < N; ++j) {
        cin >> s[j] >> t[j] >> c[j];
        --c[j];
        ++z[c[j]][s[j]];
        --z[c[j]][t[j]];
    }
    for (int j = 1; j < 101010; ++j) {
        for (int k = 0; k < 30; ++k) z[k][j] += z[k][j-1];
    }
    int ans = 0;
    for (int j = 0; j < 101000; ++j) {
        int v = 0;
        for (int k = 0; k < 30; ++k) {
            v += max(z[k][j], z[k][j+1]);
        }
        ans = max(ans, v);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13696
# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    N, K = i2nn()
    print(N - K + 1)
main()


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

int main(){
  int r,c;
  int n;   
  int dp[1000][1000];
  while(1){
    cin>>r>>c;
    if(r==0)break;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      dp[b-1][a-1]=0;
    }
    dp[c-1][r-1]=1;
    for(int i=c-1;i>=0;i--){
      for(int j=r-1;j>=0;j--){
	if(dp[i][j]==0)continue;
	if(i==c-1 && j==r-1)continue;
	if(i==c-1){
	  dp[i][j]=dp[i][j+1];
	}else if(j==r-1){
	  dp[i][j]=dp[i+1][j];
	}else{
	  dp[i][j]=dp[i+1][j]+dp[i][j+1];
	}
      }
    }
    // cout <<endl<< "Case"  << endl;
    // for(int i=c-1;i>-1;i--){
    //   for(int j=0;j<r;j++){
    // 	printf("%3d",dp[i][j]);
    //   }
    //   cout << endl;
    // }
    cout<<dp[0][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5072
#include <iostream>
#include <string>

int main(int argc, char const* argv[])
{
	std::string str;
	int i = 0, sum;

	while (std::cin >> str)
	{
		sum = 0;

		if (str[0] == '0')
			break;

		for (size_t i = 0; i < str.size(); i++)
			sum += str[i] - '0';

		std::cout << sum << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1184
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool go(vi a, int x) {
	int u = 0, s = 0;
	for(auto i : a) {
		if(i==x) s++;
		else if(i==x-1) u++;
		else return false;
	}
	if(s==1) return false;
	s/=2;
	return u+(s>0) <= x && x <= u+s;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	vi a;
	cin >> n;
	int mx = 0;
	a.resize(n);
	for(auto &i : a) cin >> i, mx = max(mx, i);
	cout << ((go(a, mx)||go(a, mx+1))?"Yes":"No");
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100000+15;
	int a[MAXN] = {0};
int main(){
	int n;
	double t,d;

	cin>>n>>t>>d;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	double min = 0x3f3f3f3f;
	int k = 0;
	for(int i=0;i<n;i++){
		if(fabs(t-a[i]*0.006-d)<min){
			min = fabs(t-a[i]*0.006-d);
			k = i;
		}
	}
	cout<<k+1;
}

Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    res = 0

    if k == 0:
        print(n ** 2)
    else:
        for b in range(k+1,n+1):
            res += (b-k) * (n//b)
            if n % b != 0:
                res +=max(0, n - ((n//b)*b+k) +1)
        print(res)
main()

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			boolean[] bl = new boolean[10];
			for(int i= 0; i < 4; i++){
				a[i] = sc.nextInt();
				bl[a[i]] = true;
			}
			for(int i = 0; i < 4; i++){
				b[i] = sc.nextInt();
			}
			
			int hit = 0, bullow = 0;
			for(int i = 0; i < 4; i++){
				if(b[i] == a[i]){
					hit++;
				}else if(bl[b[i]]){
					bullow++;
				}
			}
			System.out.println(hit + " " + bullow);
		}
	}
}

Measured memory_bytes: 25900
from collections import namedtuple
Node = namedtuple('Node', ['parent', 'children'])

class my_tree:
    def __init__(self, N=[]):
        self.T = {}
        for ni in N: self.addNode(ni)

    def addNode(self, n):
        p = self.T.get(n[0],Node(-1,[None])).parent
        self.T[n[0]] = Node(p,n[2:])
        for c in n[2:]:
            cc = self.T.get(c,Node(-1,[None])).children
            self.T[c] = Node(n[0],cc)

    def getParent(self, i): return self.T[i].parent

    def getChildren(self, i): return self.T[i].children

    def getDepth(self, i):
        if self.T[i].parent == -1: return 0
        return self.getDepth(self.T[i].parent) + 1

    def getNodeType(self, i):
        if self.T[i].parent == -1: return 'root'
        if self.T[i].children    : return 'internal node'
        return 'leaf'

    def getIdList(self): return sorted(self.T.keys())

 
if __name__=='__main__':
    n = int(input())
    N = [None]*n
    for i in range(n): N[i] = list(map(int,input().split()))
    tree = my_tree(N)
     
    for i in tree.getIdList():        
        print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(\
                i, tree.getParent(i), tree.getDepth(i), tree.getNodeType(i), tree.getChildren(i)))

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

namespace ABC_D
{
    class D058
    {

        static int _Mod = 1000000007;

        //累乗(a^n) O(logn)
        public static long ModPow(long a, int n)
        {
            long res = 1;
            while (n > 0)
            {
                if (n % 2 == 1) res = (res * a) % _Mod;
                a = (a * a) % _Mod;
                n >>= 1;
            }
            return res;
        }

        //逆元1/n(mod p) (1<=n<p)
        public static long InverseElement(long n)
        {
            return ModPow(n, _Mod - 2);
        }

        //階乗n!(mod p)のベクトル
        public static List<long> Factorial(int n)
        {
            long x = 1;
            List<long> list = new List<long>();
            list.Add(x);
            for (int i = 1; i <= n; i++)
            {
                x = (x * i) % _Mod;
                list.Add(x);
            }
            return list;
        }

        //階乗の逆元 1/n! (mod p)のベクトル
        public static List<long> InversePower(int n)
        {
            long x = 1;
            List<long> list = new List<long>();
            list.Add(x);
            for (int i = 1; i <= n; i++)
            {
                x = (x * InverseElement(i)) % _Mod;
                list.Add(x);
            }
            return list;
        }

        //組み合わせの数nCr (mod p)
        public static long Combination(int n, int r, List<long> power, List<long> inv)
        {
            long denominator = (inv[r] * inv[n - r]) % _Mod;
            long val = (power[n] * denominator) % _Mod;
            return val;
        }


        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int H = a[0], W = a[1], A = a[2], B = a[3];

            List<long> power = Factorial(H + W);
            List<long> inv = InversePower(H + W);


            long sum = 0;
            for (int i = 0; i < H - A; i++)
            {
                long c1 = Combination(B + i - 1, i, power, inv) % _Mod;
                long c2 = Combination(W + H - B - i - 2, W - B - 1, power, inv) % _Mod;
                sum = (sum + c1 * c2) % _Mod;
            }
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 20320
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'a' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        s: Chars
    }

    if s.len() == 26 {
        let i = s
            .windows(2)
            .enumerate()
            .map(|(i, x)| (i, (x[1], x[0])))
            .rev()
            .find(|(_, (a, b))| a > b);

        match i {
            Some(i) if i.0 != 1 => {
                // println!("{}", i.0);
                let pre = &s[..i.0].iter().collect::<String>();
                let add = s
                    .iter()
                    .skip(i.0 + 1)
                    .filter(|x| **x > s[i.0])
                    .min()
                    .unwrap();
                println!("{}{}", pre, add);
            }
            Some(_) | None =>  println!("-1"),
        }
    } else {
        for c in (A..).take(26).map(|x| x as char) {
            if !s.contains(&c) {
                println!("{}{}", s.iter().collect::<String>(), c);
                return;
            }
        }
    }
}


Measured memory_bytes: 2140
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll ans=0;
  ll n;
  cin>>n;
  ll s=0;
  ll a[n];
  rep(i,0,n) cin>>a[i],s=(a[i]+s)%hell;
  rep(i,0,n){
    s=(s-a[i]+hell)%hell;
    ans=(ans+a[i]*s)%hell;
  }
  cout<<ans<<endl;

}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 5304
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[12][12];
int main(){
	ll h,w;
	while(scanf("%lld%lld",&h,&w),h){
		rep(i,0,h)rep(j,0,w)scanf("%lld",&a[i][j]);
		ll ans=0;
		//[hl,hr]×[wl,wr]を池にする
		rep(hl,1,h-1)rep(hr,hl,h-1)rep(wl,1,w-1)rep(wr,wl,w-1){
			ll inM=0;
			ll ins=0;
			ll oum=10;
			rep(hh,hl,hr+1)rep(ww,wl,wr+1){
				inM=max(inM,a[hh][ww]);
				ins+=a[hh][ww];
			}
			rep(hh,hl-1,hr+2)oum=min(oum,min(a[hh][wl-1],a[hh][wr+1]));
			rep(ww,wl-1,wr+2)oum=min(oum,min(a[hl-1][ww],a[hr+1][ww]));
			if(inM<oum)ans=max(ans,oum*(hr-hl+1)*(wr-wl+1)-ins);
		}
		printf("%lld\n",ans);
	}
}



Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int a = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int h = int.Parse(Console.ReadLine());
            // int Y = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            List<int> count = new List<int>();
            for(int i = 0; i<abc.Count();i++){
                if(count.Count(x=>x==abc[i])==0){
                    count.Add(abc[i]);
                }
            }
            Console.WriteLine(count.Count());
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
Sorted = [list(map(int, input().split())) for _ in range(N)]
Sorted.insert(0, [0, 0, 0])

for i in range(N):
  d = abs(Sorted[i+1][1] - Sorted[i][1]) + abs(Sorted[i+1][2] - Sorted[i][2])
  t = Sorted[i+1][0] - Sorted[i][0]
  if  d > t or d % 2 != t % 2:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 27428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// ここにコードを挿入
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int p = sc.nextInt();
		int t = (a * 3 + p) / 2;
		System.out.println(t);
	}

}

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

// Returns sum of products of all subsets 
// of arr[0..n-1] 
long long int productOfSubsetSums(int arr[], int n)
{    long long int c=pow(10,9)+7;
    long long int ans = 1;
    for (int i = 0; i < 26; ++i )
        ans = (ans * (arr[i] + 1))%c;
    return ans-1;
}

// Driver code 
int main()
{
    int n;
    cin>>n;
    string a;
    cin>>a;
    int arr[26]={0};
    for (int i = 0; i < n; ++i) {
        arr[int(a[i])-97]++;
    }

    cout << productOfSubsetSums(arr, 26);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define P pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define pb push_back
#define M 1000000007
#define for1(i,n) for(ll i=1;i<=n;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)
using namespace std;
int main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string s, t;
	cin >> s >> t;
	ll n = s.length();
	ll count = 0;
	for (ll i = 0; i < n; i++)
	{
		if (s[i] != t[i])
		{
			count++;
		}
	}
	cout << count << "\n";
	return 0;
}

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

constexpr int inf = 1e9;

using pii = pair<int, int>;

int main() {
    const int max_v = 1e6;
    vector<bool> is_prime(max_v, true);
    vector<int> ps;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < max_v; ++i) {
        if(is_prime[i]) {
            ps.push_back(i);
            for(int j = i + i; j < max_v; j += i) {
                is_prime[j] = false;
            }
        }
    }

    int n, m, s, t; cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<int>> g(n);
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    vector<vector<int>> d(n, vector<int>(2, inf));
    d[s][0] = 0;
    queue<pii> que;
    que.emplace(s, 0);
    while(!que.empty()) {
        auto now = que.front(); que.pop();
        const int v = now.first, pari = now.second;
        for(auto to : g[v]) {
            if(d[to][!pari] > d[v][pari] + 1) {
                d[to][!pari] = d[v][pari] + 1;
                que.emplace(to, !pari);
            }
        }
    }
    if(d[t][0] == 2) {
        cout << 2 << endl;
    } else {
        if(d[t][1] == inf) {
            cout << -1 << endl;
        } else if(d[t][1] == 1) {
            cout << 3 << endl;
        } else {
            cout << *lower_bound(begin(ps), end(ps), d[t][1]) << endl;
        }
    }
}



Measured memory_bytes: 14220
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int h, w, k;   cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
        cin >> s[i];
    int ans = 0;
    for (int x = 0; x < (1<<h); x++) {
        for (int y = 0; y < (1<<w); y++) {
            vector<string> t = s;
            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    if ((x>>k)&1 || (y>>l)&1)
                        t[k][l] = 'r';
                }
            }
            int cnt = 0;
            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    if (t[k][l] == '#')
                        cnt++;
                }
            }
            if (cnt == k)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

char a[200010],b[200010];

int main() {
    long long count = 0;
    cin >> a;
    cin >> b;
    
    long long i = 0;
    while (a[i] != '\0')
    {
        if(a[i] != b[i])
        {
            count++;
        }
        i++;
    }
    cout << count;

    return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  map<ll, ll> mp;
  for (int i = 2; i <= n; i++) {
    int now = i;
    for (int j = 2; j * j <= i; j++) {
      while (now % j == 0) {
        mp[j]++;
        now /= j;
      }
    }
    if (now != 1) mp[now]++;
  }
  
  ll ans = 1;
  for (auto i : mp) {
    // cout << i.first << " " << i.second << endl;
    ans *= i.second + 1;
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

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

using namespace std;

using ll = long long ;

int main(){
    ll n , k ;
    cin >> n >> k ;
    ll t = n ;
    string s ;
    cin >> s ;
    vector<ll> groups ;
    for(ll i = 0; i < n;){
        char c = s[i] ;
        ll cnt = 0 ;
        while(i < n && s[i] == c ){
            cnt++ ;
            i++ ;
        }
        groups.push_back(cnt) ;
    }
    n = (ll)groups.size() ;
    vector<ll> sum(n + 1) ;
    for(ll i = 0; i < n; i++){
        sum[i + 1] = sum[i] + groups[i] ;
    }
    ll window = k + k + 1 ;
    if ( window >= n ){
        return cout << t - 1 << endl, 0 ;
    }
    ll ans = 0 ;
    for(ll i = 1; i + window - 1 <= n; i++){
        ll midInterval = sum[i + window - 1] - sum[i - 1] ;
        ll lastInterval = sum[n] - sum[i + window - 1] ;
        ll cntLastInterval = n - i - window + 1 ;
        ll beginInterval = sum[i - 1] ;
        ll cntBeginInterval = i - 1;
        ans = max(ans, (midInterval - 1) + (lastInterval - cntLastInterval) + (beginInterval - cntBeginInterval) );
    }
    cout << ans << endl;
    return 0 ;
}






Measured memory_bytes: 2164
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

int main()
{
	vector<int> dp(2020);
	int s;cin>>s;dp[0]=1;
	for(int i=0;i<=s;i++){
		for(int j=3;j+i<=s;j++) dp[i+j]=(dp[i+j]+dp[i])%mod;
	}
	cout<<dp[s]%mod;
	return 0;	
} 

Measured memory_bytes: 3180
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.List
import Control.Monad

readLine :: Read a => IO [a]
readLine = map read . words <$> getLine

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    print $ length [() | (a, b)<-zip s t, a/=b]

Measured memory_bytes: 19984
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
const int MAX_N=1e5+10;
set<int,greater<int>> s,t;
int n,k;
vector<int> vec;
vector<tuple<int,int,int>> ans;
int main(){
    cin>>n>>k;
    if(n+1<2*k){
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=k;i<=k+n-1;i++){
        t.insert(i);
    }
    for(int i=k+n;i<k+2*n;i++){
        s.insert(i);
    }
    int pos=k+3*n-1;
    for(int i=k+2*n-1;i;i-=2){
        if(t.find(pos-i)==t.end()||pos-i==i){
            break;
        }
        ans.eb(make_tuple(i,pos-i,pos));
        s.erase(i),s.erase(pos-i);
        t.erase(i),t.erase(pos-i);
        pos--;
    }
    while(!s.empty()){
        int v=*s.begin();
        if(t.count(pos-v)){
            ans.eb(make_tuple(v,pos-v,pos));
            s.erase(v),t.erase(pos-v);
            pos--;
        }else{
            break;
        }
    }
    for(auto x:s){
        vec.eb(x);
    }
    for(auto x:t){
        vec.eb(x);
    }
    for(int i=0;i<vec.size()/2;i++){
        ans.eb(make_tuple(vec[i],vec[vec.size()-i-1],pos));
        pos--;
    }
    for(auto x:ans){
        cout<<get<0>(x)<<" "<<get<1>(x)<<" "<<get<2>(x)<<endl;
    }
    return 0;
}

Measured memory_bytes: 13808
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int N, ans = 0, A = 0, B = 0, AB = 0;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++)
    {
        cin >> s.at(i);
        for(int j = 1; j < s.at(i).size(); j++)
        {
            if(s.at(i).at(j) == 'B' && s.at(i).at(j - 1) == 'A') ans++;
        }
        if(s.at(i).at(0) == 'B' && s.at(i).at(s.at(i).size() -1) == 'A') AB++;
        else if (s.at(i).at(0) == 'B' && s.at(i).at(s.at(i).size() - 1) != 'A') B++;
        else if (s.at(i).at(0) != 'B' && s.at(i).at(s.at(i).size() - 1) == 'A') A++;
    }
  	if(A == 0 && B == 0 && AB != 0) cout << ans + AB - 1 << endl;
    else cout << ans + AB + min(A, B)<< endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
ll n,m,k,ans,pos1=-1,pos2=-1,a[maxn],b[maxn],l[maxn],r[maxn];
int main(){
	n=read(),m=read(),k=read();
	l[0]=r[0]=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	for(int i=1;i<=n;i++){
		l[i]=l[i-1]+a[i];
		if(l[i]>k){
			pos1=i-1;
			break;
		}
	}
	for(int i=1;i<=m;i++){
		b[i]=read();
	}
	for(int i=1;i<=m;i++){
		r[i]=r[i-1]+b[i];
		if(r[i]>k){
			pos2=i-1;
			break;
		}
	}
	if(pos1==-1) pos1=n;
	if(pos2==-1) pos2=m;
	ll num=0;
	for(int i=pos1;i>=0;i--){
		ll x=k-l[i];
		while(num<=pos2&&r[num]<=x) ++num;
		ans=max(ans,i+num-1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10024
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
S = input().rstrip()

r_count = S.count('R')
g_count = S.count('G')
b_count = S.count('B')

# ret = 0
# for i in range(N):
#     for d in range(N):
#         j = i + d
#         k = j + d
#         if k >= N:
#             break
#         if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
#             ret += 1

ret = 0
for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret += 1


ans = r_count * g_count * b_count - ret
print(ans)


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

int main()
{
    char comma;
    double x = 0, y = 0, env = 0;
    for (double d, t; cin >> d >> comma >> t && (d || t);) {
        x += sin(env) * d;
        y += cos(env) * d;
        env += t * M_PI / 180;
    }
    cout << (int) x << endl;
    cout << (int) y << endl;

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
using namespace std;
int n,a;
set<int> s;
int main()
{
    //freopen("t.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a);
        s.insert(a);
    }
    printf("%d",s.size());
    //while(1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d",&a);
  if(a==1){
    printf("Hello World\n");
  }else if(a==2){
    scanf("%d",&b);
    scanf("%d",&c);
    printf("%d\n",b+c);
  }
  return 0;
}

Measured memory_bytes: 128
<?php
$l1 = explode(' ', trim(fgets(STDIN)));
$l2 = explode(' ', trim(fgets(STDIN)));
$n = $l1[0];
$k = $l1[1];

$m = max($l2);

if ($k == $m) {
  $res = 'POSSIBLE';
} else if ($k > $m || count($l2) < 2) {
  $res = 'IMPOSSIBLE';
} else {
  //------------------
  // 最大公約数を求める
  //------------------
  // 値の昇順
  asort($l2);
  $v1 = array_pop($l2);
  $cnt = count($l2);
  for ($i = 0; $i < $cnt; $i++) {
    $v2 = array_pop($l2);

    //------------------
    // 2数の最大公約数を求める
    //------------------
    while (true) {
      if ($v1 == 0) {
        $g = $v2;
        break;
      }
      if ($v2 == 0) {
        $g = $v1;
        break;
      }

      if ($v1 == 1 || $v2 == 1) {
        $g = 1;
        break;
      }
      if ($v1 > $v2) {
        $v1 = $v1 % $v2;
        $v3 = abs($v2 - $v1);
      } else {
        $v2 = $v2 % $v1;
        $v3 = abs($v1 - $v2);
      }
      if ($v2 == $v3) {
        $g = $v3;
        break;
      }
      $v1 = $v2;
      $v2 = $v3;
    }
    $v1 = $g;
  }
  if ($g == 0) {
    $res = 'IMPOSSIBLE';
  } else if ($k % $g == 0) {
    $res = 'POSSIBLE';
  } else {
    $res = 'IMPOSSIBLE';
  }
}
echo $res;

Measured memory_bytes: 21928
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int h, w, n;
	cin >> h >> w >> n;
	cout << mod(n, max(h, w)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> a;
vector<int> x;
auto ed = x.begin();

struct Graph {
    struct Vertex { int n, r; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p) {
        auto it = lower_bound(x.begin(), ed, a[i]);
        int a0 = *it;
        *it = a[i];
        auto ed0 = ed;
        if (it == ed) ed++;

        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i);
        }
        v[i].r = ed - x.begin();
        *it = a0;
        ed = ed0;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    x.assign(n, (int)1e9 + 1);
    ed = x.begin();

    g.dfs(0, -1);

    for (int i = 0; i < n; i++) {
        cout << g.v[i].r << '\n';
    }

    return 0;
}

Measured memory_bytes: 23692
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x, a, b;
    cin >> x >> a >> b;
    out((x-a)%b);
    re0;
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n;
	cin >> n;
	int ans = pow(n, 3);
	c(ans);
	ed;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;
typedef long long ll;
const int INF = 1e9;

int K,T;

typedef pair<int,int> pa;
priority_queue<pa> a;

void solve(){
    int pre = -1;
    int res = 0;
    while(1){
        if(a.empty())break;
        pa tmp1 = a.top();
        a.pop();
        if(tmp1.second != pre){
            tmp1.first--;
            if(tmp1.first>0) a.push(tmp1);
            pre = tmp1.second;
        }
        else {
            if(a.empty()){
                res++;
                tmp1.first--;
                if(tmp1.first>0) a.push(tmp1);
                pre = tmp1.second;
            } else{
                pa tmp2 = a.top();
                a.pop();
                tmp2.first--;
                if(tmp2.first>0) a.push(tmp2);
                a.push(tmp1);
                pre = tmp2.second;
            }
        }
    }
    cout << res << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> K >> T;
    REP(i,T){
        int tmp;
        cin >> tmp;
        a.push(make_pair(tmp,i));
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int N,A,B;
 cin>>N>>A>>B;

 if((A-B)%2==0){cout<<"Alice"<<endl;}
 else if((A-B)%2!=0){cout<<"Borys"<<endl;}
 
 return 0;}

Measured memory_bytes: 384
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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println((a - 1) * (b - 1));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 19412
n = int(input())
a = list(map(int,input().split()))

li = []

for i in range(n):
    memo = a[i]-(i+1)
    li.append(memo)

li.sort()
#print(li)
memo = len(li)
memo2 = li[memo//2]

li2 = [-(memo2) for i in range(len(li))]
for i in range(n):
    li[i] = li[i] + li2[i]
#print(li)
ttl = 0
for i in range(n):
    ttl += abs(li[i])

print(ttl)


Measured memory_bytes: 26860
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: String,
    }
    let s = s.chars().collect::<Vec<_>>();
    let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".to_string().chars().collect::<Vec<_>>();
    for i in 0..s.len() {
        print!("{}", chars[((s[i] as usize - 'A' as usize) + n) % 26]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int W, H, x, y, r;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> W >> H >> x >> y >> r;

	if (x + r > W || x - r < 0 || y + r > H || y - r < 0) {
		cout << "No" << "\n";
	}
	else {
		cout << "Yes" << "\n";
	}

	return 0;
}

Measured memory_bytes: 3128
import sys
sys.setrecursionlimit(10**5)

class Segtree():
    INT_MAX=2**31-1
    def __init__(self,n):
        self.n=1
        while self.n<n:
            self.n=self.n*2
        self.ary=[self.INT_MAX]*(2*self.n-1)

    def min_update(self,k,a):
        k+=self.n-1
        self.ary[k]=a
        while k>0:
            k=(k-1)/2
            self.ary[k]=min(self.ary[k*2+1],self.ary[k*2+2])

    def min_query(self,a,b,k,l,r):
        if r==-1:r=self.n
        if (r<=a or b<=l):return self.INT_MAX
        if (a<=l and r<=b):return self.ary[k]
        else:
            vl=self.min_query(a,b,k*2+1,l,(l+r)/2)
            vr=self.min_query(a,b,2*k+2,(l+r)/2,r)
            return min(vl,vr)

    def find_min(self,s,t):
        return self.min_query(s,t+1,0,0,-1)

n,q=map(int,raw_input().split())
st=Segtree(n)
for i in xrange(q):
    com,x,y=map(int,raw_input().split())
    if com==0:
        st.min_update(x,y)
    if com==1:
        print(st.find_min(x,y))

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

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int ans = 0;
    if(A < 0) {
        ans += abs(A) * C + D;
        A = 0;
    }
    ans += (B - A) * E;
    cout << ans << endl;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
long power(long a,long b){return b?power(a*a%inf,b/2)*(b%2?a:1)%inf:1;}

double dp[3007][3007];
int main() {
    int n; cin >> n;
    double p[n]; rep(i, n) cin >> p[i];
    dp[1][1] = p[0];
    dp[1][0] = (1 - p[0]);
    rrep(i, 1, n) {
        rep(j, 3007) {
            if (dp[i][j] == 0) continue;
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    rrep(i, n / 2 + 1, n + 1) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    /*
    rrep(i, 1, n + 1) {
        rep(j, n + 1) cout << dp[i][j] << " "; cout << endl;
    }
     */
}


Measured memory_bytes: 68992
#include<iostream>
#include<iomanip>

#define PI 3.14159265358979
 
using namespace std;
 
int main()
{
  double r;
  cin >> r;
 
  cout << fixed << setprecision(6) << PI * r * r << " " << 2 * PI * r << endl;
 
  return 0;
}

Measured memory_bytes: 1288
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

vector<vector<int>> G;

int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> H(N);
    G.assign(N, vector<int>());
    rep(i, 0, N) { cin >> H[i]; }
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int res = 0;
    rep(i, 0, N) {
        bool good = true;
        for(auto v : G[i]) {
            if(H[i] <= H[v]) {
                good = false;
            }
        }
        if(good) {
            res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 9068
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
c = collections.Counter(prime_factorize(N))

result = 0
for i in c.values():
    temp = 0
    temp_sum = 0
    while True:
        temp += 1
        temp_sum += temp
        if temp_sum > i:
            break
    result += (temp-1)
        
print(result)

Measured memory_bytes: 9468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    int n, temp;
    vector<int> a;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        a.emplace_back(temp);
    }

    int count = 0;

    while(1)
    {
        for (auto& x : a)
        {
            if (x % 2 != 0)
            {
                cout << count << endl;
                return 0;
            }
            x /= 2;
//            cout << x << " ";
        }
//        cout << endl;

        count++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

void A(){
  string s;
  cin >> s;
  if(s[2] == s[3] and s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

void B(){
  int Yen;
  cin >> Yen;
  ll Happiness = 0;
  while(Yen >= 500){
    Happiness += 1000;
    Yen -= 500;
  }
  while(Yen >= 5){
    Happiness += 5;
    Yen -= 5;
  }

  cout << Happiness << endl;
}

void C(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll min = A[N-1] - A[0];
  for(int i = 1; i < N; i++){
    ll temp = K - (A[i] - A[i-1]);
    temp < min ? min = temp:1;
  }

  cout << min << endl;
}
int main(){
  B();
}


Measured memory_bytes: 256
from functools import reduce

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def gcd_list(numbers):
    return reduce(gcd, numbers)
m = gcd_list(A)
flag = 0
for i in range(N):
    if A[i] % m == 0:
        flag += 1
    else:
        pass
if flag == N:
    print(m)
else:
    print(1)



Measured memory_bytes: 14596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	string s;
	int k;
	cin >> k >> s;
	if (s.size() <= k) {
		cout << s << endl;
		return 0;
	}

	cout << s.substr(0, k) << "..." << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
typedef long long ll;

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

int
main(int argc, char *argv[])
{
  int n, k, h[100000];
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n; ++i) scanf("%d", &h[i]);

  qsort(h, n, sizeof(int), asc);
  int j = 0, ans = h[k - 1] - h[0];
  while(j + k - 1 < n){
    ans = min(ans, h[j + k - 1] - h[j]);
    ++j;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 892