akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///You are my love
///You are the one that I adore
///You are my love
///You are what I have waited for.
///Oh, you are my love
///Oh, you are my love
///Oh, you are my love
///You are my day
///You changed my Winter into spring
///You came my way and then my heart began to sing
///Oh, you are my love
///Oh, you are my love
///Oh, you are my love
///Times were getting lonely
///I was thinking only
///Yesterday about the friends I thought I had
///But no-one ever came to call on
///They weren't around to close the door on
///Never thought that things would get that way
///You are my love
///You are the one I'll always need
///You are my love
///For you I'd get down on my knees.
///Oh, you are my love
///Oh, you are my love
///Oh,…
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n")
#define no() puts("NO\n")
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define unq(a) sort(all(a)), a.erase(unique(all(a)),a.end())
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
const double EPS = 1e-9;
const int MXX = 1e5 + 5;
#define SIZE 1100002

int cum[1000000 + 5], cum2[1000000 + 5];
int main ()
{
    ll a, b, c;
    cin>>a>>b>>c;
   if(a % c == 0)co<<b/c - a/c + 1<<en;
   else co<<b/c - a/c<<en;

    re 0;
}


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

int main(){
	int n;
	scanf("%d",&n);
	string s;
	cin >> s;
	if(n % 2) printf("No\n");
	else{
		int f = 1;
		for(int i = 0;i < s.size()/2;i++){
			if(s[i] != s[s.size()/2+i]){
				f = 0;
				break;
			}
		}
		if(f) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 10 ;
vector<int> v[N] , a[N] ;
int n , m , k ;
int d[N] , c[N] , cnt = 0 ;
int dp(int x , int mm)
{
  d[x] = cnt , c[cnt] ++ ;
	for(auto u : v[x])
		 if(!d[u])
		  dp(u , x) ;
}
int main()
{
	scanf("%d%d%d" , &n , &m , &k) ;
	for(int i = 1 , x , y ; i <= m ;i ++)
	 scanf("%d%d" , &x , &y) , v[x].push_back(y) , v[y].push_back(x) ;
  for(int i = 1; i <= n ;i ++)
	 if(!d[i]) ++ cnt , dp(i , -1) ;
	for(int i = 1 ,x , y ; i <= k ;i ++)
	 scanf("%d%d" , &x , &y) , a[x].push_back(y) , a[y].push_back(x) ;
	for(int i = 1; i <= n ;i ++)
	 {
		 int t = c[d[i]] ;
		 t -= v[i].size() + 1 ;
  	 for(auto x : a[i])
				if(d[i] == d[x]) t -- ;
		 cout << t << " " ;
	 }
	puts("") ;
 	return 0 ;
}


Measured memory_bytes: 12288
# Cycle Detection for a Directed Graph
[vertex, edge] = list(map(int, input("").split()))
array = [[0 for j in range(vertex)] for i in range(vertex)]

for i in range(edge):
    data = list(map(int, input("").split()))
    array[data[0]][data[1]] = 1

visited = [0 for j in range(vertex)]
result = 0

def dfs(node, goal):
    for t in range(vertex):
        visited[node] = 1
        if array[node][t] != 0 and t == goal:
            global result
            result = 1
        if array[node][t] != 0 and visited[t] == 0:
            dfs(t, goal)

for i in range(vertex):
    visited = [0 for j in range(vertex)]
    dfs(i,i)
    if result == 1:
        print(1)
        break

if result == 0:
    print(0)





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

namespace AtCode
{
    class Class1
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string[] DivInput = Input.Split(' ');
            int H = Convert.ToInt32(DivInput[0]);
            int W = Convert.ToInt32(DivInput[1]);
            string[] mark = new string[H];
            for(int i = 0; i < H; i++)
            {
                mark[i] = Console.ReadLine();
            }
            for(int i = 0; i <H; i++)
            {
                Console.WriteLine(mark[i]);
                Console.WriteLine(mark[i]);
            }
            
        }
        

       
    }
    
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int ans[maxn];
vector<pair<int,int>> g[maxn];

void dfs(int at, int p, int edc) {
  int e = 1;
  if (e==edc) e++;
  for (auto ed: g[at]) {
    int to = ed.first; int idx = ed.second;
    if (to == p) continue;
    ans[idx] = e;
    dfs(to, at, e);
    e++; if (e==edc) e++;
  }
}

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

  cin>>n;

  for (int i=0; i<n-1; i++) {
    int u,v; cin>>u>>v;
    g[u].push_back({v,i});
    g[v].push_back({u,i});
  }


  dfs(1,0,0);

  int c = 0;
  for (int i=0; i<n-1; i++) {
    c = max(c,ans[i]);    
  }


  cout<<c<<"\n";
  for (int i=0; i<n-1; i++) {
    cout<<ans[i]<<"\n";
  }
  

return 0;
}


Measured memory_bytes: 30464
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i < t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int x[N], y[N];
    rep(i, N) cin >> x[i] >> y[i];
    int cnt[N] = {};
    rep(i, 250000) {
        double maxd = -INF;
        int index = 0;
        double theta = (i/125000.0) * M_PI;
        rep(j, N) {
            if (maxd < x[j] * cos(theta) + y[j] * sin(theta)){
                index = j;
                maxd = x[j] * cos(theta) + y[j] * sin(theta);
            }
        }
        cnt[index]++;
    } 
    cout << fixed;
    rep(i, N) cout << cnt[i] / 250000.0 << endl;
    
    

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b;
	char op;
	do
	{
		scanf("%d %c %d", &a, &op, &b);
		switch (op)
		{
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		}
	} while (op != '?');
	return 0;
}


Measured memory_bytes: 2104
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s: String = sc.read();
    println!("{} {}", &s[0..4], &s[4..12]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define sz int(1e5+1)
int main()
{
    string s1, s2;

    cin>>s1>>s2;
    s1='0'+s1;
    s2='0'+s2;
    int n=s1.size(), m=s2.size();
    
    vector < vector<int> > dp(n+1,vector<int>(m+1,0));

    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(s1[i]==s2[j]){
                dp[i][j]=1+dp[i-1][j-1];
            }else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    int y=n-1,x=m-1;
    string s = "";
    while(dp[y][x]){
        int mxx = max(dp[y-1][x-1], max(dp[y-1][x], dp[y][x-1]));
        if(mxx!=dp[y][x]){
            s=s1[y]+s;
            y--, x--;
        }else{
            if(dp[y-1][x]==dp[y][x])
                y--;
            else if (dp[y-1][x-1]==dp[y][x]){
                y--, x--;
            }else{
                x--;
            }
        }
    }

    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 35712
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m,x;

int main()
{
    cin >> x;
    n = x/100;
    m = x%100;
    if(1 <= n&&n <= 12&&(1 > m||m > 12))
    {
        cout << "MMYY";
    }
    else if(1 <= m&&m <= 12&&(1 > n||n > 12))
    {
        cout << "YYMM";
    }
    else if(1 <= n&&n <= 12&&1 <= m&&m <= 12)
    {
        cout << "AMBIGUOUS";
    }
    else cout << "NA";
}

#endif // 1++

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

char grid0[110][110];
char grid1[110][110];
char grid2[110][110];

int main(){
  int h,w;
  cin>>h>>w;
  rep(i,h)rep(j,w){
    cin>>grid0[i][j];
  }
  int H=0;
  rep(hi,h){
    bool flag=0;
    rep(wi,w){
      if(grid0[hi][wi]=='#')flag=1;
    }
    if(flag){
      rep(wi,w){
        grid1[H][wi]=grid0[hi][wi];
      }
      H++;
    }
  }
  int W=0;
  rep(wi,w){
    bool flag=0;
    rep(hi,H){
      if(grid1[hi][wi]=='#')flag=1;
    }
    if(flag){
      rep(hi,H){
        grid2[hi][W]=grid1[hi][wi];
      }
      W++;
    }
  }
  rep(hi,H){
    rep(wi,W){
      cout<<grid2[hi][wi];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3644
#include <stdio.h>
int main(void){
    // Your code here!
    int N,A[25],B[50],C[50],sum=0;
    scanf("%d",&N);
    for(int i=1;i <= N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=1;i <= N;i++){
        scanf("%d",&B[i]);
    }
    for(int i=1;i <= N-1;i++){
        scanf("%d",&C[i]);
    }
    
    for(int i = 1;i <= N;i++){
        sum+=B[i];
        if(A[i+1]-A[i] == 1){
            sum+=C[A[i]];
        }
    }
    printf("%d",sum);
}


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

int main(){
	int k,s,ans=0;
	cin>>k>>s;
	for(int i=0;i<=k;++i)
		for(int j=0;j<=k;++j)
			if(s-i-j<=k&&s-i-j>=0)++ans;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

r,g,b = map(str,input().split())

tmp = int(r+g+b)

if tmp % 4 == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,d,ans=0,x,y;cin>>n>>d;
    f(i,0,n)
    {
        cin>>x>>y;
        x=abs(x);y=abs(y);
        double dist=x*x+y*y;
        dist=sqrt(dist);
        if(dist<=d) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3696
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int sum=a+b;
    int sum1=a-b;
    int sum2=a*b;
    int max=sum;
    if(sum1>max)
        max=sum1;
    if(sum2>max)
        max=sum2;
    printf("%d\n",max);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int br[150];
char ch[100005];

int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", ch);
	string s = ch;
	ll sol = 1;
	for (int i=0 ; i<n ; i++) {
		br[s[i]]++;
	}
	for (int i=0 ; i<150 ; i++) {
		sol = (sol * (br[i]+1)) % MOD;
	}
	sol = (sol + MOD - 1) % MOD;
	printf("%lld\n", sol); 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int A,B;
    cin >>A>>B;
    string str;
    cin >> str;
    int s = 0;
    bool result = true;
    for(char a:str){
        if(s != A&&'-' == a){
            result = false;
        }
        if(s == A&&'-' != a){
            result = false;
        }
        s++;
    }
    cout <<(result?"Yes":"No")<<endl;
    return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A, P; cin >> A >> P;

	int ans = A*3 + P;

	ans /= 2;
	cout << ans << endl;
	


	return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int num=0;
        ArrayList<Integer> V = new ArrayList<>();
        ArrayList<Integer> C = new ArrayList<>();
        for(int i=0;i<N;i++) V.add(sc.nextInt());
        for(int i=0;i<N;i++) C.add(sc.nextInt());
        for(int i=0;i<N;i++) if(V.get(i)-C.get(i)>0) num+=V.get(i)-C.get(i);
        System.out.println(num);
    }
}


Measured memory_bytes: 21844
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll N;
vector<ll> A;

int main(void){
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];
  bool Alleven = 1;
  rep(i, N){
    if(A[i] % 2) Alleven = 0;
  }
  if(Alleven){
    cout << "second" << endl;
  }else{
    cout << "first" << endl; 
  }







}


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

int main() {
  int N, Sum;
  cin >> N;
  Sum = 0;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    Sum += r - l + 1;
  }
  
  cout << Sum << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

    int i , x , y ,d;

    for(i = 0; ;i++){

        cin >> x >> y;

        if(x > y){

            d = x;

            x = y;

            y = d;

        }

        if(x == 0 && y == 0) break;

        cout << x << " " << y << endl;

    }

return 0;
    
}

Measured memory_bytes: 1160
import math
N=int(input())
A=list(map(int,input().split()))
ans = []
AV=sum(A)//N
for j in range(AV-10,AV+11):
    kouho=[]
    for i in A:
        kouho.append((i-j)**2)
    ans.append(sum(kouho))
print(min(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    std :: cin >> k;
    std :: cout << a[k-1] << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll tmp = 0;
  vector<ll> buf1(N);
  for (int i = 0; i < N; i++)
  {
    buf1[i] = tmp;
    if (S[i] == 'W')
      tmp++;
  }

  tmp = 0;
  vector<ll> buf2(N);
  for (int i = N - 1; i >= 0; i--)
  {
    buf2[i] = tmp;
    if (S[i] == 'E')
      tmp++;
  }

  ll ans = N;
  for (int i = 0; i < N; i++) {
    ans = min(ans, buf1[i] + buf2[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 5380
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    vector<ll> x, y;
    rep(i, n) {
        if (a[i] < b[i]) x.push_back(b[i] - a[i]);
        else y.push_back(a[i] - b[i]);
    }
    if (x.size() == 0) {
        cout << "0\n";
        return 0;
    }
    
    ll sum = 0;
    for (ll x_ : x) sum += x_;
    sort(all(y));
    reverse(all(y));
    rep(i, y.size()) {
        sum -= y[i];
        if (sum <= 0) {
            cout << i + 1 + x.size() << "\n";
            return 0;
        }
    }
    
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 5888
N, K = map(int, input().split())
V = list(map(int, input().split()))

# 最終的に「持っているもの」の価値の合計を高めたい
# Dから取り出すことをpop、Dに詰めることをenqueueとする
ans = 0
for pop_cnt in range(K + 1):
    enqueue_cnt = K - pop_cnt

    if pop_cnt > N:
        continue

    for l in range(pop_cnt + 1):
        holding = []

        r = pop_cnt - l
        holding += V[:l]
        holding += V[N - r:]

        holding.sort()
        tmp_ans = sum(holding)

        for e in range(enqueue_cnt):
            if e >= len(holding):
                break

            if holding[e] < 0:
                tmp_ans += -holding[e]

        ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll h,n;
ll a[1005],b[1005];
ll dp[10005];
ll ans=10000000000000000;
int main(void){
	cin>>h>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<10005;i++){
		dp[i]=10000000000000000;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<10005;j++){
			if(j-a[i]>=0){
				dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
			}
		}
	}
	for(int i=h;i<10005;i++){
		ans=min(ans,dp[i]);
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 384
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve=f.filter((1<).snd).IM.toDescList.IM.fromListWith(+).map(\a->(a,1)).tail
f((a,k):_)|k>=4=a*a
f((a,_):(b,_):_)=a*b
f _=0

Measured memory_bytes: 21960
#include <bits/stdc++.h>
 
#define Set(a, b) memset(a, (b), sizeof(a))
#define F first
#define S second
#define FT front()
#define BK back()
#define PB push_back
#define MP make_pair
#define repi(i, l, r) for (int i=l ; i <= (int)(r) ; ++i)
#define repd(i, r, l) for (int i=r ; i >= (int)(l) ; --i)
#define repv(x, v) for (auto (x) : v)
#define all(cont) cont.begin(), cont.end()
#define Sort(n) sort(all(n))
#define Sortcmp(n) sort(all(n), cmp)
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define nl "\n"

using namespace std;

bool cmp(const pair<long,long> &a,
              const pair<long,long> &b)
{
    return (a.second < b.second || (a.second == b.second && a.first < b.first));
}

bool binarySearch(int arr[], int n, int x){
    int k = 0;
    for (int b = n/2; b >= 1; b/2)
        while (k+b < n && arr[k+b] <= x) k += b;

    if (arr[k] == x) return k;
    return -1;
}

/* ASCII Table */
/* 48 == '0', 57 = '9', 65 == 'A', 90 == 'Z', 97 == 'a', 122 == 'z' */  

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    long a, b;
    int k;

    cin >> a >> b >> k;

    repi(i, 1, k){
        if(i % 2){
            if(a % 2) a--;
            b += (a/=2);
        } 
        else{
            if(b % 2) b--;
            a += (b/=2);
        }
    }

    cout << a << " " << b << nl;
    return 0;
}

/* Compile */
// g++ -std=c++11 -O2 -Wall test.cpp -o test
 
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("%d\n", ans);
    }
    return 0;
}
 */
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("Case #%d: %d\n", counterT, ans);
    }
    return 0;
}
 */

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 998244353;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var S = Str;
		var k = F - 1;
		foreach (var c in S) Write(c == S[k] ? c : '*');
		WriteLine();
	}
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
using T = pair<i64, P>;
const i64 M = 1000000007;
signed main() {
  i64 N;
  cin >> N;
  vector<i64> A(N), B(N);
  cin >> A >> B;
  i64 ans = -1;
  REP(k, 1 << N) {
    vector<P> Ev, Od;
    i64 popcnt = 0;
    REP(i, N) {
      i64 flip = (k >> i) & 1;
      popcnt += flip;
      i64 a = flip ? B[i] : A[i];
      i64 parity = i & 1 ^ flip;
      (parity == 0 ? Ev : Od).emplace_back(a, i);
    }
    if (popcnt % 2 == 1) continue;
    i64 d = Ev.size() - Od.size();
    if (d != 0 && d != 1) continue;
    sort(ALL(Ev));
    sort(ALL(Od));
    vector<P> C(N);
    i64 cnt = 0;
    REP(i, N) {
      C[i] = (i % 2 == 0 ? Ev : Od)[i / 2];
    }
    REP(i, N - 1) {
      if (C[i].first > C[i + 1].first) goto cont;
    }
    REP(i, N) FOR(j, i + 1, N) {
      cnt += C[i].second > C[j].second;
    }
    if (ans == -1 || ans > cnt) {
      ans = cnt;
    }
    cont:;
  }
  cout << ans << endl;
}


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

int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin >> a[i];
  }
  int k;
  cin >> k;

  sort(a.begin(),a.end());
  
  if(k==1){
      a[2] *= 2;
  }else{
    for(int i=0;i<k;i++){
      a[2] *= 2;
    }
  }
  cout << a[0]+a[1]+a[2] <<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

string S;
int main () {
    cin >> S ;
    int l = S.size();
    int cnt = 0;
    for(int i=0; i<l; i++) if( S[i] == 'o') cnt++;
    if( 15 - l >= 8 - cnt) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a,b,c,d;
    a=b=c=d=0;
    for(int i=0;i<n;++i){
        string s;
        cin>>s;

        if(s=="AC") a++;
        if(s=="WA") b++;
        if(s=="RE") c++;
        if(s=="TLE") d++;


    }


    cout<<"AC x "<<a<<endl;
      cout<<"WA x "<<b<<endl;
        cout<<"TLE x "<<d<<endl;
          cout<<"RE x "<<c<<endl;








    return 0;
}



Measured memory_bytes: 3624
n=int(input())
h=list(map(int,input().split()))
err=0
for i in range(n-1)[::-1]:
    if(h[i]>h[i+1]):
        h[i]=h[i]-1
    if(i<n-2):
        if(h[i]>h[i+1]):
            err=1
if(h[n-2]>h[n-1]):
    err=1
if(err==1):
    print('No')
else:
    print('Yes')
#print(h)

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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int sum = 0;
    rep(i, N) {
        sum++;
        int d = 1;
        while(d+A[i] <= D) {
            sum++;
            d += A[i];
        }
    }

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

Measured memory_bytes: 256
def divide_by_2(n):
    cnt = 0
    while True:
        if n % 2 == 0:
            n //= 2
            cnt += 1
        else:
            break
    return cnt


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    ans = 0

    for a in a_list:
        ans += divide_by_2(a)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68740
#include <stdio.h>

int bignumber(int a, int b){
    if(a>b){
        return(a);
    } else {
        return(b);
    }
}

int main(void){
    long long N;
    scanf("%lld",&N);
    for (long long h=bignumber(N/4,1); h<=3500; h++){
        for (long long n=h; n<=3500; n++){
            for (long long w=n; w<=3500; w++){
                if (N*(h*n+n*w+w*h)==4*n*h*w){
                    printf("%lld %lld %lld\n",h,n,w);
                    return 0 ;
                }
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
string s;
cin>>n;
cin>>s;
int r = 0;
for(int i = 1; i < n; i++) {
int k = 0;
for(char c = 'a'; c <='z'; c++) {
  bool f = false, t = false; 
  for(int j = 0; j < i; j++) {
  if( s[j] == c) f = true;
  }
  for(int j = i; j < n; j++) {
  if(s[j] == c) t = true;
  }
  if(f && t) k++;
}
  if(r < k) r = k;
}
  
cout<<r<<endl;
return 0;
}

Measured memory_bytes: 256
from math import factorial

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

l = [0, 0]
for a in A:
    l[a%2] += 1

even = (2**l[0])*sum(factorial(l[1])//factorial(l[1]-i)//factorial(i) for i in range(0, l[1]+1, 2))
# print(even, 2**N)
if P:
    print(2**N-even)
else:
    print(even)

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

int main() {
  ll N, D;
  cin >> N >> D;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    ll a = x * x + y * y;
    if (a <= D * D) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans;
    if(k<=a){
        ans=k;
    }
    else if(k<=a+b){
        ans=a;
    }
    else {
        ans=a-(k-(a+b));
    }
    cout<<ans<<endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long Inf = (long) 1e18;
		long[] dp = new long[N];
		for(int i=0;i<N;i++){
			dp[i] = Inf;
		}
		
		dp[0] = 0;
		for(int i=0;i<N;i++){
			if(i + 1 < N){
				dp[i + 1] = Math.Min(dp[i + 1], dp[i] + Math.Abs(H[i + 1] - H[i]));
			}
			if(i + 2 < N){
				dp[i + 2] = Math.Min(dp[i + 2], dp[i] + Math.Abs(H[i + 2] - H[i]));
			}
		}
		
		Console.WriteLine(dp[N-1]);
	}
	int[] H;
	int N;
	public Sol(){
		N = ri();
		H = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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


int V, E, R, S[500010], T[500010], D[500010];
int C[100010];

const int inf = 10000*100000+100;

int main(){
  cin >> V >> E >> R;
  for (int i = 0; i < E; ++i)
  {
    cin >> S[i] >> T[i] >> D[i];
  }
  for (int i = 0; i < V; ++i)
  {
    if(i!=R){
      C[i]=inf;
    }else{
      C[i] = 0;
    }
  }
  // for (int t = 0; t < V; ++t)//Vは街の数
  while(true)
  {
    bool update = false;
    for (int i = 0; i < E; ++i)//Eは辺の数
    {
      int s=S[i], t=T[i], d=D[i];
      if(C[s]<inf &&(C[s]+d <C[t]) ){
        C[t]=C[s]+d ;
        update = true;
      }
    }
    if(!update) break;
  }

  for (int i = 0; i < V; ++i)
  {
    if (inf==C[i])
    {
      cout <<"INF"<<endl;
    }else{
      cout <<C[i]<<endl;
    }
  }
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
ll arr[N];
int main()
{
    FIO
    ll x = 0;
    int n; cin>>n;
    for(int i = 0 ; i<n ; i++)
    {
        cin>>arr[i];
        x ^= arr[i];
    }
    for(int i = 0 ; i<n ; i++)
        cout<< (arr[i]^x) <<" ";
    return 0;

}

Measured memory_bytes: 5148
#!/usr/bin/env python3

n = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0

for i in range(1, n - 1):
    a, b, c = p_list[i - 1], p_list[i], p_list[i + 1]
    if a <= b <= c or c <= b <= a:
        count += 1

ans = count
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001
 
int X[4]={1,-1,0,0};
int Y[4]={0,0,1,-1};
bool vis[1001][1001]={};
char arr[1001][1001];
int h,w;
int cal[1001][1001]={};
 
bool valid(int x,int y){
    if(x<0 || y<0 || x>=h || y>=w || arr[x][y]=='#' || vis[x][y]){
        return 0;
    }
    return 1;
}
 
int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,x,t;
	    cin >> n >> x >> t;
	    if(n%x==0){
	        cout << (n/x)*t;
	    }else{
	        cout << (n/x+1)*t;
	    }
	}
	return 0;
}

Measured memory_bytes: 3576
import sys
import itertools

# import numpy as np

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

N, M = map(int, readline().split())
A = [None]*M
B = [None]*M
for i in range(M):
    A[i], B[i] = map(int, readline().split())

ans = min(B) - max(A)

print(ans + 1 if ans >= 0 else 0)


Measured memory_bytes: 10912
#include <iostream>
#include <string>
using namespace std;
int main() {
  int A,B;
  std::cin >> A >> B;
  if ((1<=A&&A<=9)&&(1<=B&&B<=9)) {
    std::cout << A*B << '\n';
  }
  else{
    std::cout << -1 << '\n';
  }
}


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

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

b = sum(a)

c=a[0]
d=b-c
mi=abs(c-d)

for i in range(1,n-1):
    c+=a[i]
    d-=a[i]
    if abs(c-d)<mi:
        mi=abs(c-d) 

print(mi)

Measured memory_bytes: 23928
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;cin>>k;
  vi A;
  map<ll,bool>used;
  queue<ll>que;
  for(int i=1;i<10;i++){
    que.push(i);
    A.pb(i);
    used[i] = true;
  }

  while(!que.empty()){
    ll now = que.front();
    que.pop();
    if(now > 3235566667)continue;
    if(now%10 == 0){
      if(used[now*10+1] == false){
	used[now*10+1] = true;
	que.push(now*10+1);
	A.pb(now*10+1);
      }
      if(used[now*10] == false){
	used[now*10] = true;
	que.push(now*10);
	A.pb(now*10);
      }
    }else if(now%10 == 9){
      if(used[now*10+8] == false){
	used[now*10+8] = true;
	que.push(now*10+8);
	A.pb(now*10+8);
      }
      if(used[now*10+9] == false){
	used[now*10+9] = true;
	que.push(now*10+9);
	A.pb(now*10+9);
      }
    }else{
      if(used[now*10+(now%10)-1] == false){
	used[now*10+(now%10)-1] = true;
	que.push(now*10+(now%10)-1);
	A.pb(now*10+(now%10)-1);
      }
      if(used[now*10+(now%10)+1] == false){
	used[now*10+(now%10)+1] = true;
	que.push(now*10+(now%10)+1);
	A.pb(now*10+(now%10)+1);
      }
      if(used[now*10+(now%10)] == false){
	used[now*10+(now%10)] = true;
	que.push(now*10+(now%10));
	A.pb(now*10+(now%10));
      }
    }
  }
  sort(ALL(A));
  // for(int i=0;i<k;i++)cout<<A[i]<<endl;
  cout<<A[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 24176
#include <stdio.h>

int main(){

	char X,Y;

	scanf("%c %c",&X,&Y);

	if(X-'A'<Y-'A'){
	printf("<\n");
	}
	else if(X-'A'>Y-'A'){printf(">\n");}
	else{
	printf("=\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sp std::fixed<<std::setprecision
#define MOD 1000000007
#define MAX 1e18
#define N 1000005
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n , ans = 0;
    cin >> n;
    ll a[n];
    for( int i = 0 ; i < n ; i++ )
        cin >> a[i];
    sort( a , a + n );
    ans = a[( n / 2 )] - a[(n / 2) - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <map>


using namespace std;

typedef pair<int,int> P;

int main(){

    int h,w,n;
    long ans[10] = {0};
    map<P,int> m;
    
    

    cin >> h >> w >> n;
    for(int i = 0;i<n;i++){
        int a,b;
        cin >> a >> b;
        for(int j = -2;j <= 0;j++){
            for(int k =-2; k <= 0; k++){
                if(a+j <= 0 || a+j >=h-1 || b+k <= 0 || b+k >=w-1){
                    continue;
                }
                if(m.count(make_pair(a+j,b+k)) != 0 ){
                    m[make_pair(a+j,b+k)]++;
                }else{
                    m[make_pair(a+j,b+k)] = 1;
                }
                //cout << a+j << "," << b+k << " = " << m[make_pair(a+j,b+k)] << endl;
            }
        }    
    }
    for( auto a : m){
        ans[a.second]++;
        //cout << a.first.first << "," << a.first.second << "=" << a.second << endl;
    }
    ans[0] = (long)(h-2)*(long)(w-2);
    for(int i = 1; i<10;i++){
        ans[0]-=ans[i];
    }
    for(int i = 0;i<10;i++){
        cout << ans[i] << endl;
    }


}

Measured memory_bytes: 56448
#include<stdio.h>

#define N 1000000

int A[N],n;

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  scanf("%d",&q);
for(i=0;i<q;i++){
 scanf("%d",&k);
 if( binarySearch(k))sum++;
  }

 
 printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2144
n, m = map(int, input().split())
grid = [input() for i in range(n)]

res = 0
dirs = [(0,1),(1,0),(0,-1),(-1,0)]

for a in range(n):
  for b in range(m):
    if grid[a][b] != '.':
      continue
    vis = set([(a,b)])
    q = [(a,b,0)]
    qi = 0
    while qi < len(q):
      i, j, c = q[qi]
      res = max(res, c)
      qi += 1
      for di, dj in dirs:
        ni, nj = i + di, j + dj
        if (ni, nj) in vis or ni < 0 or ni >= n or nj < 0 or nj >= m or grid[ni][nj] != '.':
          continue
        vis.add((ni, nj))
        q.append((ni, nj, c+1))
print(res)
    


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

using namespace std;

#define INF 210000000
#define int long long

signed main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i=1;i<=n;i++){
		if (i % 5 != 0 && i % 3 != 0) ans += i;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3640
x1,y1,x2,y2 = map(float,input().split())
q = int(input())
x,y = [],[]
for i in range(q):
    x_t,y_t = map(float,input().split())
    x.append(x_t)
    y.append(y_t)

if x1 == x2:
    for i in range(q):
        print(x1,y[i])
elif y1 == y2:
    for i in range(q):
        print(x[i],y1)
else:
    a = (y2-y1)/(x2-x1)
    b = y1-a*x1
    for i in range(q):
        d = y[i]+(1/a)*x[i]
        px = (d-b)/(a+1/a)
        py = a*px+b
        print(px,py)

Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,b=0,a=0,ans;
	cin>>n;
	long long p[n];
	for(long long i=1;i<=n;i++)
	{
	    cin>>p[i];
	    if(p[i]!=i)
		{
			a++;
		}
	}
	if(a>2)
	{
		cout<<"NO";
	}
	else
	{
		cout<<"YES";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
    // ArrayList<Integer> lis = new ArrayList<Integer>();
    // ArrayList<Integer> map[]=new ArrayList[26];
    // static HashMap<Integer,Long> map = new HashMap<Integer,Long>();

    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong(),ans=0;
        
        ans = c * max(x,y)*2;
        ans = min(ans,(a+b)*min(x,y)+abs(x-y)*( x > y ? a:b ));
        ans = min(ans, 2 * c * min(x,y) +abs(x-y)*( x > y ? a:b ));

        // for (int i=0; i<n; i++) {

        // }

        out.println(ans);
        out.flush();
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 21204
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int x=0,p=0;
};
bool cmp(node a,node b)
{
   return   a.x<b.x;
}
int main()
{   node a[100005];
    node b[100005];
    int l=1,n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i].x);
        a[i].p=i;
    }
    sort(a+1,a+n+1,cmp);
    int ans=0;
    for(i=1;i<=n;i++)
    {
        if(abs(a[i].p-i)%2!=0)
        {
            ans++;
        }
    }
    printf("%d\n",ans/2);
    return 0;
}
//

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  cout << min(A,B) + min(C,D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MOD = 1000000007;
vector<ll> p(100010,0);
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void Main(){
    ll n=3;
    ll k;cin>>k;
    for(ll i = k;i > 0; i--){
        p[i] = modpow(k/i,n,MOD);
        for(ll j = 2; j * i <= k; j++){
            p[i] -= p[i*j];
            p[i] = (p[i]+MOD)%MOD;
        }
        ans += i * p[i] % MOD;
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 3908
def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        halfP = p // 2
        half = modpow(a, halfP)
        return half * half % mod
    else:
        return a * modpow(a, p-1) % mod

def comb(a, b):
    if b > a - b:
        return comb(a, a-b)
    ansMul = 1
    ansDiv = 1
    for i in range(b):
        ansMul *= a - i
        ansDiv *= i + 1
        ansMul %= mod
        ansDiv %= mod

    ans = ansMul * modpow(ansDiv, mod-2) % mod
    return ans

N, K = map(int, input().split())
mod = 10 ** 9 + 7
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
        continue
    ans = comb(N-K+1, i) * comb(K-1, i-1)
    ans %= mod
    print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); //9 90 900 
	ll a, b, h; cin >> a >> b >> h;
	cout << a * h + (b - a) * h / 2 << '\n';



}

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

int main() {
	int a,b,c,d;
   cin>>a>>b>>c>>d;
   int k=max(a,c);
  int t=min(b,d);
   if(t-k>0)cout<<t-k;
   else cout<<0;
	return 0;
}

Measured memory_bytes: 3520
#include <stdio.h>
#include <math.h>

typedef long long ll;

int main() {
	int d, t, s;
	scanf("%d %d %d", &d, &t, &s);
	if (s * t >= d)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1736