akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MAXN
#define MAXM
using namespace std;
int n,m;

int main()
{
	string s;
	cin>>s;
	int len=s.size();
	int m1=0,m2=0;
	for (int i=0;i<len;i++)
	{
		if (i%2)
		{
			if (s[i]=='0')
			{
				m1++;
				continue;
			}
			m2++;
			continue;
		}
		if (s[i]=='1')
		{
			m1++;
			continue;
		}
		m2++;
	}
	printf("%d",min(m1,m2));
	return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a + b == c || b + c == a || c + a == b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	double a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main()
{
	int n;
	string s;
	int i, j, k, l;
	set<string> substringSet;
	char sub[4];
	int digitCount2[10] = { 0 };
	int digitCount1[10] = { 0 };
	set<char> zero;
	set<char> one;
	set<char> two;
	cin >> n;
	cin >> s;

	for (l = 0; l < 10; l++)
	{
		digitCount1[l] = 0;
		digitCount2[l] = 0;
	}


	for (i = 0; i < s.length() - 2; i++)
	{
		if (zero.find(s[i]) != zero.end())
		{
			if (zero.size() >= 10) break;
			else continue;
		}
		zero.insert(s[i]);
		for (j = s.length() - 1; j >= 2; j--)
		{
			if (one.find(s[j]) != one.end())
			{
				if (one.size() >= 10) break;
				else continue;
			}
			one.insert(s[j]);

			for (k = i + 1; k < j; k++)
			{
				if (two.find(s[k]) != two.end())
				{
					if (two.size() >= 10) break;
					else continue;
				}
				two.insert(s[k]);
				sub[0] = s[i];
				sub[1] = s[k];
				sub[2] = s[j];
				sub[3] = 0;
				substringSet.insert((sub));
				//std::cout << s[i] << s[k] << s[j] << endl;
				if (two.size() >= 10) break;
			}
			two.clear();
			if (one.size() >= 10) break;
		}
		one.clear();
	}

	std::cout << substringSet.size() << endl;

	return 0;
}

Measured memory_bytes: 384
#include <cstdio> 
using namespace std; 
int main() {
  long  incrementer[200001] = {0}; 
  long n; 
  long nombreLu; 
  scanf("%ld", &n);  
  for (long i = 2; i <= n; i ++) {
    scanf("%ld", &nombreLu);
    incrementer[nombreLu] ++; 
  }
  for (long i = 1; i <= n; i ++) {
    printf("%ld\n", incrementer[i]); 
  }
  return 0; 
}

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

namespace ABC144B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N > 99)
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine(
                Enumerable.Range(1, 9)
                          .SelectMany(i => Enumerable.Range(1, 9)
                                                     .Select(j => i * j))
                          .Any(x => x == N) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d;
    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        d.push_back(x);
    }
    sort(d.begin(), d.end());
    if(n%2==0) {
        cout << d[n/2]-d[n/2-1] << endl;
        return 0;
    } else {
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
  string a, b;
  cin >> a >> b;
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

bool isVowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

int main(){ 
    do_not_disturb
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (b+1 != d ? 1 : 0);
    
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct point{
	double x;
	double y;
};

bool side(point p1, point p2, point p3){
	return (p3.y-p1.y)*(p2.x-p1.x)-(p3.x-p1.x)*(p2.y-p1.y)>0;
}

int main(void){
    point p1, p2, p3, p0;
	
	while (true){
		cin>>p1.x>>p1.y;
		if (cin.eof()) break;
		cin>>p2.x>>p2.y;
		cin>>p3.x>>p3.y;
		cin>>p0.x>>p0.y;

		if (side(p1, p2, p0) == side(p2, p3, p0) && side(p2, p3, p0) == side(p3, p1, p0))
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
    return 0;
}

Measured memory_bytes: 1216
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

N = i_inpl()
W = l_inpl()

ans = INF
for i in range(1, N):
    S1 = W[:i]
    S2 = W[i:]
    ans = min(ans, abs(sum(S1)-sum(S2)))

print(ans)

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace boost::multiprecision;
using namespace std;
int main(){
    cpp_int a,b;
    cin>>a;
    cin>>b;
    if(a>b){
        cout<<"GREATER"<<endl;
    }
    else if(a<b){
        cout<<"LESS"<<endl;
    }
    else{
        cout<<"EQUAL"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        int sum = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            sum += a;
            ary[i] = a;
        }
        sum = (int) Math.round(sum / (n * 1.0));
        for (int i = 0; i < n; i++) {
            ans += Math.pow(sum - ary[i], 2);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b = LI()
a -= 1; b -= 1
ans = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]


flg = 0
for y in range(99, 50, -2):
    for x in range(0, 100, 2):
        if not a:
            flg = 1
            break
        ans[y][x] = '.'
        a -= 1
    if flg:
        break

flg = 0
for y in range(0, 50, 2):
    for x in range(0, 100, 2):
        if not b:
            flg = 1
            break
        ans[y][x] = '#'
        b -= 1
    if flg:
        break


print(100, 100)
for i in ans:
    print(''.join(i))



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

int main(){
  int num1,num2,x,dig;
  cin >> num1;
  num2 = num1;
  
  while(num2){
	dig = num2 % 10;
    x += dig;
    num2 /= 10;
  }
  
  if((num1 % x) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
  int total;
  int one;
    cin >> total >> one;
  
  int a;
    a = total % 500;
  
  if (a <= one){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

using ll = long long;

bool canTake(string &s, int const pos)
{
	return s[pos - 1] != s[pos + 1];
}

void take(string &s, int pos)
{
	string tmp = s.substr(0, pos) + s.substr(pos + 1);
	s = tmp;
}

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

	string current = "First";
	while (true)
	{
		if (s.length() == 2)
		{
			// 取れなかった = 今の手番が負け = 相手が勝利
			cout << ((current == "First") ? "Second" : "First") << endl;
			return 0;
		}

		bool taken = false;
		for (int i = 1; i < s.length() - 1; i++)
		{
			if (canTake(s, i))
			{
				take(s, i);
				i--;
				current = (current == "First") ? "Second" : "First";
				taken = true;
				break;
			}
		}
		if (!taken)
		{
			// 取れなかった = 今の手番が負け = 相手が勝利
			cout << ((current == "First") ? "Second" : "First") << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 576
#include<stdio.h>
int main()
{
    char s[200];

    scanf("%s",s);

    int len=0;

    for(int i=0; s[i]!=0;i++)
    len++;

    int count=0;
    for(int i=0,j=(len-1);i<=j;i++,j--)
    {
        if(s[i]!=s[j])
        count++;
    }

    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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




int main(){
    int N, a; std::cin >> N;
    bool lose(true);
    for(int i(0); i < N; ++i){
        std::cin >> a;
        if(a % 2) lose = false;
    }
    std::cout << (lose ? "second" : "first") << std::endl;
    return 0;
}


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

using namespace std;

static void solve()
{
  int a, b, c;
  set<int> s;
  cin >> a >> b >> c;
  int now = 0;
  int d = 0;
  while (true) {
    if(now <= c && c <= now + a) {
      cout << d * 60 + c << "\n";
      return;
    }
    if(s.count(now)) {
      cout << -1 << "\n";
      return;
    }
    s.insert(now);
    now += a + b;
    d += now / 60;
    now %= 60;
  }
}

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

Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    string s;
    cin >> s;
    int ans = 1000;
    string abc = "abcdefghijklmnopqrstuvwxyz";
    for(int i = 0; i < 26; i++){
        int checker = 0;
        vector<int> v;
        v.push_back(-1);
        for(int j = 0; j < s.size(); j++){
            if(s[j] == abc[i]){
                v.push_back(j);
            }
        }
        v.push_back(s.size());
        for(int j = 0; j < v.size() - 1; j++){
            checker = max(checker, v[j + 1] - v[j] - 1);
        }
        ans = min(ans, checker);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
#point = 1
t = 0
"""for i in range(t, n):
  point = point*a[i]"""
  
#print(point)
#t = 0
for j in range(k, n):
  #point0 = point
  #point = point*a[j]/a[t]
  if a[j] > a[t]:
    print("Yes")
  else:
    print("No")
  t+=1



Measured memory_bytes: 94252
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m,l;
  cin>>n>>m>>l;
  vll a(m),b(m),c(m);
  vvll t(n,vll(n,INF));
  rep(i,n) t[i][i]=0;
  rep(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    t[a[i]][b[i]]=c[i];
    t[b[i]][a[i]]=c[i];
  }
  rep(k,n)rep(i,n)rep(j,n){
    t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
  }
  rep(i,n)rep(j,n){
    if(t[i][j]<=l){
      chmin(t[i][j],1LL);
    }
  }
  rep(i,n)rep(j,n){
    if(t[i][j]>l){
      chmax(t[i][j],INF);
    }
  }
  rep(k,n)rep(i,n)rep(j,n){
    t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
  }
  ll q;
  cin>>q;
  rep(i,q){
    ll s,tt;
    cin>>s>>tt;
    s--;tt--;
    if(t[s][tt]==INF)COUT(-1);
    else COUT(t[s][tt]-1);
  }
}

Measured memory_bytes: 4984
N = int(input())
a = list(map(int, input().split()))

dictA = {}

for x in a:
    dictA.setdefault(x, 0)
    dictA[x] += 1
    if x - 1 > 0:
        dictA.setdefault(x - 1, 0)
        dictA[x - 1] += 1
    dictA.setdefault(x + 1, 0)
    dictA[x + 1] += 1
print(max(dictA.values()))


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

int main(void)
{
  int a, b, c;
  double rad, s, l, h;
  scanf("%d %d %d", &a, &b, &c);
  
  rad = c * M_PI / 180.0;   //????????¢?????????
  s = 1 / 2.0 * a * b * sin(rad);   //????§???¢?????¢???
  l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));   //????????????
  h = s * 2.0 / a;    //a???????????¨??????????§???¢?????????
  
  printf("%lf\n%lf\n%lf\n", s, l, h);
  return (0);
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;

  if( (c+b-1)/b <= (a+d-1)/d ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict
N,W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
DP = defaultdict(int)
DP[0] = 0
for weight, value in wv:
  exists = list(DP.items())
  for key, total in exists:
    new_key = key + weight
    if new_key > W:
      continue
    new_total = total + value
    if DP[new_key] < new_total:
      DP[new_key] = new_total

print(max(DP.values()))

Measured memory_bytes: 9804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,j,n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main(){
    ll n;
    cin >> n;
    ll t[n];
    
    rep(i,n){
        cin>>t[i];
    }
    if(n==1){
        cout<<t[0]<<endl;
        return 0;
    }
    ll c = t[0]/gcd(t[0],t[1]);
    c*=t[1];
    REP(i,2,n){
        ll d = t[i]/gcd(c,t[i]);
        d*=c;
        c = d;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

template<class T>
struct segment_tree {
    using F = function<T(T,T)>;
    int n;
    vector<T> data;
    F f;
    T init_v;

    segment_tree(int n_, T init_v, F f) : f(f), init_v(init_v) {
        n = 1;
        while (n < n_) n *= 2;
        data.assign(2*n-1,init_v);
    }

    //kをaに変更
    void update(int k, T a) {
        k += n-1;
        data[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = f(data[k*2+1],data[k*2+2]);
        }
    }

    //[a,b)のquery,kは節点番号
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T operator[](int a) {return data[a+n-1];}
};

int main() {
    int n, k; cin >> n >> k;
    vint p(n);
    rep(i,n) cin >> p[i];
    auto f_min = [](int a, int b) {
        if (a < b) return a;
        else return b;
    };
    auto f_max = [](int a, int b) {
        if (a < b) return b;
        else return a;
    };
    segment_tree<int> sg_min(n,inf,f_min);
    segment_tree<int> sg_max(n,-1,f_max);
    rep(i,n) {
        sg_min.update(i,p[i]);
        sg_max.update(i,p[i]);
    }
    vector<pair<bool,bool>> data;
    for (int i = 0; i <= n-k; i++) {
        pair<bool,bool> tmp = make_pair(false,false);
        if (sg_min.query(i,i+k) == p[i]) tmp.first = true;
        if (sg_max.query(i,i+k) == p[i+k-1]) tmp.second = true;
        data.push_back(tmp);
    }
    vint len(n,1);
    for (int i = n-1; i >= 0; i--) {
        if (p[i] > p[i+1] || i == n-1) continue;
        len[i] = len[i+1] + 1;
    }
    int ans = 0;
    bool no_change = false;
    for (int i = 0; i <= n-k; i++) {
        if (len[i] >= k) {no_change = true; continue;}
        if (i-1 >= 0 && data[i-1].first && data[i].second) continue;
        ans++;
    }
    if (no_change) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 9480
#include<stdio.h>

int main()
{
  int a,b,k;
  
  scanf("%d%d%d",&a,&b,&k);
  
  int i,j;
  
  if(a+(k-1)<b-(k-1))
  {
    for(i=0;i<k;i++)
    {
      printf("%d\n",a+i);
    }
    for(j=k;j>0;j--)
    {
      printf("%d\n",b-(j-1));
    }
  }
  else
  {
    for(i=0;i<(b-a)+1;i++)
    {
      printf("%d\n",a+i);
    }
  }
        
    
  return 0;
}

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

int main()
{

    string s;
    cin >> s;
    int l = s.size(), ara[27] = {0}, f = 0;
    for(int i = 0; i < l; i++)
    {
        ara[s[i]-'a']++;
        if(ara[s[i]-'a'] > 1)f++;
    }
    if(f)printf("no");
    else printf("yes");
    return 0;
}


Measured memory_bytes: 256
n,y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):#
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 40684
#include<iostream>

#define int long long
using namespace std;

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

int n;
int a[500000], sum, b[500000], cnt;

signed main()
{
	cin >> n;
	int x = 1000000000;
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		a[i] = abs(b[i]);
		if (b[i] < 0) cnt++;
		sum += a[i];
		x = min(x, a[i]);
	}
	if (cnt % 2) sum -= 2 * x;
	cout << sum;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;



void solve(){

    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    
    if (x/d >= k){
        cout << x - k*d;
    }
    else{
        ll n = x/d;
        k-=n;
        x%=d;
        if (k%2==0){
            cout << x;
        }
        else{
            cout << d-x;
        }
    }
}


int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}














Measured memory_bytes: 3620
#include <stdio.h>

main() {
  int n, s, x, i, min, max;

  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    s=0;
    for(i=0 ; i<n ; i++) {
      scanf("%d", &x);
      s += x;
      if(i==0) max = min = x;
      if(x < min) min = x;
      if(x > max) max = x;
    }
    s -= max+min;
    s/=(n-2);
    printf("%d\n", s);
  } 
  return 0;
}

Measured memory_bytes: 596
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ if odd (a + b) then (a + b + 1) `div` 2 else (a + b) `div` 2


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
vector<int> v;
int n;
int main() {
    DAU
    cin >> n;
    v = vector<int>(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    if (v.size() == n)
        cout << "YES";
    else cout << "NO";
    PLEC
}


Measured memory_bytes: 1024
count = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L, R = A[left: left + n1], A[mid: mid + n2]
    global count

    L.append(2000000000)
    R.append(2000000000)

    i, j = 0, 0
    for k in range(left, right):
        #print("k", k, "l", left, "m", mid, "r", right, "L", L, "R", R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            count += len(L) - 1 - i
            j += 1


def mergeSort(A, left, right):
    #print("l", left, "r", right)
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


n = int(input())
input_list = list(map(int, input().split(' ')))

mergeSort(input_list, 0, n)
print(count)



Measured memory_bytes: 27476
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = defaultdict(int)
for i in range(N):
    S[s()] += 1

M = n()
T = defaultdict(int)
for i in range(M):
    T[s()] += 1

max_coin = 0

for k, v in S.items():
    coin = v - T[k]
    if coin > max_coin:
        max_coin = coin
for k, v in T.items():
    coin = S[k] - v
    if coin > max_coin:
        max_coin = coin

print(max_coin)



Measured memory_bytes: 3316
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    C = False
    F = False
    for i in range(len(s)):
        if s[i] == 'C':
            C = True
        elif s[i] == 'F' and C:
            F = True
    if C and F:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string S, T;
  int size_S, size_T;

  cin >> S >> T;
  size_S = S.length();
  size_T = T.length();

  if(size_T == size_S + 1){
    if(S == T.substr(0, size_S)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;
    cin >> n;
    vector<int> q;
    for(int i=0;i<n;i++){
        cin >> l;
        q.emplace_back(l);
    }
    sort(q.begin(),q.end(),greater<int>());
    if(q[0]<accumulate(q.begin(),q.end(),0)-q[0]){cout << "Yes" << endl;}
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=200010;
int n,k;
long long a[MAXN];
int nump;
inline bool cmp(long long x,long long y)
{
	return abs(x)>abs(y);
}
int main()
{
	read(n),read(k);
	for(int i=1;i<=n;++i) read(a[i]);
	if(k==n)
	{
		long long ret=1;
		for(int i=1;i<=n;++i) ret*=a[i],ret%=mod;
		write((ret%mod+mod)%mod),putchar('\n');
		return 0;
	}
	for(int i=1;i<=n;++i)
	if(a[i]>=0) ++nump;
	if(nump==0&&k%2==1)
	{
		sort(a+1,a+n+1),reverse(a+1,a+n+1);
		long long ret=1;
		for(int i=1;i<=k;++i) ret*=a[i],ret%=mod;
		write((ret%mod+mod)%mod),putchar('\n');
		return 0;
	}
	stable_sort(a+1,a+n+1,cmp);
	long long minp=2147483647,maxp=-1,minn=0,maxn=-2147483647;
	long long p1=0,p2=0,p3=0,p4=0;
	long long ans=1;
	for(int i=1;i<=k;++i) ans*=a[i],ans%=mod;
	if(ans>=0)
	{
		write(ans),putchar('\n');
		return 0;
	}
	for(int i=1;i<=k;++i)
	if(a[i]>=0&&a[i]<minp) minp=a[i],p1=i;
	else if(a[i]<0&&a[i]>maxn) maxn=a[i],p4=i;
	for(int i=k+1;i<=n;++i)
	if(a[i]>=0&&a[i]>maxp) maxp=a[i],p2=i;
	else if(a[i]<0&&a[i]<minn) minn=a[i],p3=i;
	if(minp==2147483647||minn==0)
	{
		ans=1;
		for(int i=1;i<=k;++i)
		if(i!=p4) ans*=a[i],ans%=mod;
		ans*=a[p2],ans%=mod;
	}
	else if(maxp==-1||maxn==-2147483647)
	{
		ans=1;
		for(int i=1;i<=k;++i)
		if(i!=p1) ans*=a[i],ans%=mod;
		ans*=a[p3],ans%=mod;
	}
	else if(minn*maxn>maxp*minp)
	{
		ans=1;
		for(int i=1;i<=k;++i)
		if(i!=p1) ans*=a[i],ans%=mod;
		ans*=a[p3],ans%=mod;
	}
	else
	{
		ans=1;
		for(int i=1;i<=k;++i)
		if(i!=p4) ans*=a[i],ans%=mod;
		ans*=a[p2],ans%=mod;
	}
	write(ans),putchar('\n');
	return 0;
}


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


typedef long long ll;

using namespace std;


const ll mod=1000000007;

int  main(){

    string s;
    cin>>s;

    int n=s.size();

    reverse(s.begin(),s.end());

    vector<int> vec(2019,0);

    ll t=1;
    ll k=0;
    ++vec[0];

    for(int i=0;i<n;++i){
        k=(((s[i]-'0')*t)+k)%2019;
        ++vec[k];
        t=(t*10)%2019;
    }


    ll ans=0;


    for(int i=0;i<2019;++i){
        if(vec[i]>1){
            ans+=(vec[i]*(vec[i]-1))/2;
        }
    }
  
cout<<ans<<endl;


   
}



Measured memory_bytes: 3736
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static List<String> permutation(List<String> list, String target, String ans){
        if(target.length() <= 1) {
            list.add(ans + target);
        } else {
            for (int i = 0; i < target.length(); i++) {
                permutation(
                        list,
                        target.substring(0, i) + target.substring(i + 1),
                        ans + target.charAt(i)
                );
            }
        }
        return list;
    }
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());

        String[][] line = new String[2][1];

        for(int i = 0; i < 2; i++) {
            Arrays.fill(line[i], "");
            for(int j = 0; j < n; j++) {
                line[i][0] += scanner.next();
            }
        }

        String number = "";
        for(int i = 1; i <= n; i++) {
            number += i;
        }

        List<String> listA = new ArrayList<>();
        permutation(listA, number, "");

        int sum = 0;
        for(int j =0; j < line.length; j++) {
            for(int i =0; i < listA.size(); i++) {
                if(listA.get(i).equals(line[j][0])) {
                    if(sum == 0) {
                        sum += i;
                    } else {
                        sum -= i;
                    }
                }
            }
        }

        System.out.println(Math.abs(sum));
    }
}


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

int main(){
  int n,m,count;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> m;
    if(m % 2 == 0)
      if(m % 3 != 0 && m % 5 != 0)
        count++;
    }

  if(count == 0){
    cout << "APPROVED" << endl;
  } else {
    cout <<"DENIED" << endl;}
  
  return 0;
}
        
    

Measured memory_bytes: 256
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  char s[8];

  puts("0");
  fflush(stdout);

  scanf("%s", s);
  if (*s == 'V') return 0;  

  int lb=0, ub=N;
  while (true) {
    int mid=(lb+ub)>>1;
    printf("%d\n", mid);
    fflush(stdout);

    char t[8];
    scanf("%s", t);
    if (*t == 'V') return 0;
    ((mid&1)^(*s==*t)? lb:ub) = mid;
  }
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#define endl    "\n"
#define int		long long
#define mp		make_pair
#define pb		push_back
#define fi		first
#define se 		second
#define sz(x)	((int)(x).size())
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);

void solve (){
    int n, k; cin>>n>>k;
    int p[n];
    for(int i = 0; i < n; i++){
        cin>>p[i];
    }
    
    sort(p, p+n);
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum = sum + p[i];
    }
    cout<<sum<<endl;
}

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0);
    solve();
    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -o "%e" "%f" -g -D_GLIBCXX_DEBUG

Measured memory_bytes: 3608
import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
for i in range(5,B,6):
    p = (i-5)//6
    k = p+i
    ini = (i*5-1)//6
    if l[p] == 1:
        l[k::i] = [0] * len(l[k::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[k+2::i+2] = [0] * len(m[k+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 4 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Measured memory_bytes: 12020
def is_prime():
    n = int(input())
    if n == 2: return True
    if n < 2 or not n % 2: return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if not n % i: return False
    
    return True

def main():
    ans = 0
    for i in range(int(input())):
        ans += is_prime()
        
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5668
s=input()
k=int(input())
p=0
if s[0]==s[-1]:
  p+=1

if len(s)==1:
  print(k//2)
else:
  l=[1]
  for i in range(len(s)-1):
    if s[i]!=s[i+1]:
      l.append(1)
    else:
      l[-1]+=1
  x=[i//2 for i in l]
  y=sum(x)
  if len(l)>1:
    if s[0]==s[-1]:
      if (l[0]+l[-1])%2==1:
        print(y*k)
      else:
        print(y*k+p*(k-1))
    else:
      print(y*k+p*(k-1))
  else:
    print((len(s)*k)//2)




Measured memory_bytes: 38532
from collections import Counter
n = int(input())
XY = [list(map(int,input().split())) for _ in range(n)]
dXY = Counter([])
for i in range(n):
    for j in range(n):
        if i!=j:
            dXY += Counter([str(XY[i][0]-XY[j][0])+'_'+str(XY[i][1]-XY[j][1])])
if n==1:
    print(1)
else:
    print(n-dXY.most_common()[0][1])

Measured memory_bytes: 9696
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    n = len(S)
    for i in range(2, n, 2):
        mid = (n - i) // 2
        if S[:mid] == S[mid:n - i]:
            ret = n - i
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
package main

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

func main() {
	var n int
	var a []int
	n, a = receiveStdin()

	var b []string
	for _, v := range a {
		n := strconv.Itoa(v)
		b = append(b, n)
	}
	fmt.Println(strings.Join(b, " "))

	for i := 1; i < n; i++ {
		v := a[i]
		j := i - 1
		for {
			if j >= 0 && a[j] > v {
				a[j+1] = a[j]
				j--
			} else {
				break
			}
		}
		a[j+1] = v

		var b []string
		for _, v := range a {
			n := strconv.Itoa(v)
			b = append(b, n)
		}
		fmt.Println(strings.Join(b, " "))
	}

}

func receiveStdin() (int, []int) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	var a []int
	for i := 0; i < n; i++ {
		sc.Scan()
		b, e := strconv.Atoi(sc.Text())
		if e != nil {
			panic(e)
		}

		a = append(a, b)
	}

	return n, a
}



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

class O
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var p2 = Enumerable.Range(0, n + 1).Select(i => 1 << i).ToArray();

		var dp = new int[n + 1, p2[n]];
		dp[0, 0] = 1;
		for (int i = 0, i2 = 1; i < n; i++, i2++)
			for (int f = 0, f2; f < p2[n]; f++)
			{
				if (dp[i, f] == 0) continue;
				for (int j = 0; j < n; j++)
				{
					if (a[i][j] == 0) continue;
					if ((f2 = f | p2[j]) == f) continue;
					dp[i2, f2] = (dp[i2, f2] + dp[i, f]) % 1000000007;
				}
			}
		Console.WriteLine(dp[n, p2[n] - 1]);
	}
}


Measured memory_bytes: 175072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::pair<char,int> pci;
typedef std::vector<int> vi;
typedef std::vector<char> vc;
typedef std::vector<pci> vpci;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str s;
int main(){
  cin>>s;
  int ss=s.size();
  int cnt=0;
  rep(i,ss){
    if(s[i]=='x') continue;
    else cnt++;
  }
  bool f=true;
  int res=0;
  int fr=0,ba=ss-1,cf,cb;
  rep(i,(cnt+1)/2){
    cf=0;cb=0;
    while(s[fr]=='x'){
      fr++;
      cf++;
    }
    while(s[ba]=='x'){
      ba--;
      cb++;
    }
    if(s[fr]==s[ba]){
      res+=std::abs(cf-cb);
    }
    else{
      f=false;
      break;
    }
    fr++;ba--;
  }
  if(f) prin(res);
  else prin(-1);
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int N,K;in(N,K);
  vector<int>p(N);ins(p);
  vector<double>P(N),s(N+1,0.0);
  rep(i,N){
    P[i]=(double)(p[i]+1)/2.0;
    s[i+1]+=s[i]+P[i];
  }
  double ans=0;
  rep(i,N-K+1){
    double tmp=s[i+K]-s[i];
    ans=max(tmp,ans);
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4736
//1616

#include <stdio.h>

int main(void)
{
    int n, m, i, j, a[1000000], max = 0, tmp;

    while (1)
    {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }

        max = 0;

        for (i = 0; i < n; i++)
        {
            for (j = i + 1; j < n; j++)
            {
                tmp = a[i] + a[j];
                if (a[i] + a[j] <= m && a[i] + a[j] > max)
                {
                    max = tmp;
                }
            }
        }

        if (max == 0)
        {
            printf("NONE\n");
        }
        else
        {
            printf("%d\n", max);
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="AKIHABARA"||s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"||s=="KIHBARA"||s=="KIHABRA"||s=="KIHABAR"||s=="AKIHBRA"||s=="AKIHBAR"||s=="AKIHABR"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHABR"||s=="AKIHBR"||s=="KIHBR"){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

typedef pair<double, double> point;

double area(point A, point B, point C)
{
	double x1 = B.first  - A.first;
	double x2 = C.first  - A.first;
	double y1 = B.second - A.second;
	double y2 = C.second - A.second;
	return 0.5 * abs(x1*y2 - x2*y1);
}

int main()
{
	vector<point> coordinate;
	double x, y;
	char dummy;
	while ( cin >> x >> dummy >> y ) coordinate.push_back( make_pair(x, y) );
	
	double area_of_polygon = 0.0;
	for (vector<point>::iterator it = coordinate.begin()+1; it != coordinate.end()-1; it++) {
		area_of_polygon += area(coordinate.at(0), *it, *(it+1));
	}
	cout << fixed << setprecision(6) << area_of_polygon << endl;
	
	return 0;
}

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

int main() {
  int n,x;
  cin >> n >> x;

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

  int cnt = 1;
  int cur = 0;

  for (int i = 0; i < n; i++) {
    cur = cur + a[i];
    if(cur <= x) cnt++;
  }
  cout << cnt << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector <int> x(m, 0); 
    rep(i, m) cin >> x[i];
    if (n >= m) cout << 0 << endl;
    else {
        sort(x.begin(), x.end());
        vector <int> diff(m - 1, 0); 
        rep(i, m - 1) diff[i] = x[i + 1] - x[i];
        sort(diff.begin(), diff.end());
        int dist = x[m - 1] - x[0];
        rep(i, n - 1) {
            dist -= diff[m - 2 - i]; 
        }   
        cout << dist << endl;
    }   
}

Measured memory_bytes: 1024
# time complexity: O(N*N!) (本当はO(N!))
# space complexity: O(M)
from itertools import permutations


N, M = [int(elem) for elem in input().split(' ')]
edge_set = set([tuple([int(elem) - 1 for elem in input().split(' ')]) for _ in range(M)])
edge_set |= {(edge[1], edge[0]) for edge in edge_set}
assert len(edge_set) == 2 * M

num_possible_path = 0
for permutation in permutations(range(1, N), N-1):
    permutation = [0] + list(permutation)
    for i in range(N - 1):
        if tuple(permutation[i:i+2]) not in edge_set:
            break
        else:
            continue
    else:
        num_possible_path += 1

print(num_possible_path)


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

using namespace std;

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

	int a, b;
	cin >> a >> b;
	int s = 0;
	for (int i = 1; i <= (b - a); ++i) {
		s += i;
	}
	cout << s - b;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define fo(i,a,n) for(i=a;i<n;i++)
    #define ll long long
    #define deb(x) cout << #x << "=" << x << endl
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define all(x) x.begin(), x.end()
    #define clr(x) memset(x, 0, sizeof(x))
    #define sortall(x) sort(all(x))
    #define sortrev(x) sort(all(x),greater<int>())
    #define pi 3.1415926535897932384626

    typedef pair<int,int> pii;
    typedef pair<ll, ll> pl;
    typedef vector<int>	vi;
    typedef vector<ll>	vl;
    typedef vector<pii>	vpii;
    typedef vector<pl>	vpl;
    typedef vector<vi>	vvi;
    typedef vector<vl>	vvl;
    typedef vector<double> vd;


    const int mod = 100000007;
    const int inf = 100000005;
    const int N = 200005, M = N;
    int i,j,n,m;

    ll cnt , idx;
    vi temp;


    void solve() {
       ll x,y;
       cin>>x>>y;

       ll aa,bb;
       bool f = 0;
       fo(i,0,2001) {
         double a = i * 0.08;
         double b = i * 0.10;

         aa = (int)(a);
         bb = (int)(b);
         if(aa == x && bb == y) {
            f = 1;
            cout<<i<<"\n";
            break;
         }
       }
       if(!f) cout<<"-1\n";

    }

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

        int t = 1;
        //cin >> t;
        while(t--) {
          solve();
        }

        return 0;
    }




Measured memory_bytes: 3500
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int cout = 0;
	for(int i=0; i<n; i++) {
		if(sc.nextInt() % 2 == 1) {
			cout++;
		}
	}
	if(cout % 2 == 1) {
		System.out.println("NO");
	} else {
		System.out.println("YES");
	}
}
}


Measured memory_bytes: 50884