akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
typedef struct E{
  int T;
  struct E *N;
}e;
e *l[100001];
void df(int i,int a[],int d){
  a[i]=d;
  e *t=l[i];
  while(t!=NULL){
    if(a[t->T]<0)df(t->T,a,d+1);
    t=t->N;
  }
}
int main(){
  e *t;
  int f[100001],s[100001],n,i,x,y;
  scanf("%d",&n);
  for(i=0;i<=n;i++){l[i]=NULL;f[i]=s[i]=-1;}
  for(i=1;i<n;i++){scanf("%d%d",&x,&y);t=malloc(sizeof(t));t->T=y;t->N=l[x];l[x]=t;t=malloc(sizeof(t));t->T=x;t->N=l[y];l[y]=t;}
  df(1,f,0);
  df(n,s,0);
  x=0;for(i=1;i<=n;i++)x+=f[i]<=s[i];
  printf(x>n/2?"Fennec":"Snuke");
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  cin >> n;
  
  auto f = [&](int x) {
    int r = x%10;
    int l = 0;
    while (x) {
      l = x;
      x /= 10;
    }
    return P(l,r);
  };


  map<P,int> freq;
  rrep(i,n) {
    freq[f(i)]++;
  }
  ll ans = 0;
  rrep(i,n) {
    P p = f(i);
    ans += freq[P(p.se,p.fi)];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := 0
    for i:=0;i<n;i++{
        var l,r int
        fmt.Scan(&l,&r)
        ans += r-l+1
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



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

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
class HeapTree
	def initialize
		@node = []
		@n = 0
	end

	private

	def left_key(key)
		2*key+1
	end

	def right_key(key)
		2*key+2
	end

	def from_root_swap(key)
		right = right_key(key)
		left = left_key(key)
		if  key < 0 
			return nil
		end
		if !@node[left] && !@node[right]
			return nil
		elsif @node[left] && !@node[right]
			if @node[left] > @node[key]
				@node[key], @node[left] =  @node[left], @node[key]
				from_root_swap(left)
			end
		elsif @node[right] && !@node[left]
			if @node[right] > @node[key]
				@node[key], @node[right] =  @node[right], @node[key]
				from_root_swap(right)
			end
		elsif @node[key] <= @node[left] && @node[left] >= @node[right]
			@node[key], @node[left] =  @node[left], @node[key]
			from_root_swap(left)
		elsif @node[key] <= @node[right] && @node[right] >= @node[left]
			@node[key], @node[right] =  @node[right], @node[key]
			from_root_swap(right)
		end
	end

	def from_leaf_swap(key)
		if key == 0
			return nil
		end
		parent_key = (key-1)/2
		if @node[parent_key] < @node[key]
			@node[key], @node[parent_key] = @node[parent_key], @node[key]
			from_leaf_swap(parent_key)
		end
	end

	def extract!
		num = @node[0]
		@node[0] = @node.pop
		@n -= 1
		from_root_swap(0)
		return num
	end

	def insert!(num)
		@node << num
		@n += 1
		from_leaf_swap(@n-1)
	end

	# ???????????¢?´¢
	def precedingOrderSearch(key, &func)
		if @node[key]
			func.call(key, @node[key])
			precedingOrderSearch(@node[2*key+1], &func)
			precedingOrderSearch(@node[2*key+2], &func)
		end
	end
	# ???????????¢?´¢
	def afterLineOrderSearch(key, &func)
		if @node[key]
			afterLineOrderSearch(@node[2*key+1], &func)
			afterLineOrderSearch(@node[2*key+2], &func)
			func.call(key, @node[key])
		end
	end
	#???????????¢?´¢
	def centerOrderSearch(key, &func)
		if @node[key]
			centerOrderSearch(@node[2*key+1], &func)
			func.call(key, @node[key])
			centerOrderSearch(@node[2*key+2], &func)
		end
	end

	public

	def insert(num)
		insert!(num)
	end

	def preceding_crawl(&func) #???hoge.precedingCrawl do |key, value| ??????????????????
		precedingOrderSearch(0, &func)
	end

 # ????????????
 def after_line_crawl(&func)
 	afterLineOrderSearch(0, &func)
 end

# ????????????
def center_crawl(&func)
	centerOrderSearch(0, &func)
end

def extract
	extract!
end

def priority_create
	i = 0
	loop{
		key = (@n-1)/2-i
		break if key < 0
		from_root_swap(key)
		i += 1
	}
end

def list
	return @node
end
end



ans = []
head = HeapTree.new
loop {
	str = gets.to_s.chomp!
	if str == "extract"
		ans << head.extract
	elsif str == "end"
		break
	else
		str = str.split
		head.insert str[1].to_i
	end
}


ans.each do |v|
	puts v
end

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

using namespace std;

int a[110];

int main() {
   int n;
   cin >> n;
   rep(i,n)
   cin >> a[i];
   sort(a,a+n,greater<int>());
   int ans=0;
   rep(i,n)
   i%2==0 ? ans+=a[i] : ans-=a[i];
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int I;
    cin >> I;
    int A = I/1000;
    int B = I/100 - A*10;
    int C = I/10 - A*100 - B*10;
    int D = I - A*1000 - B*100 - C*10;
    if (A+B+C+D == 7) {
        cout << A << "+" << B << "+" << C << "+" << D << "=7";
    } else if (A-B+C+D == 7) {
        cout << A << "-" << B << "+" << C << "+" << D << "=7";
    } else if (A+B-C+D == 7) {
        cout << A << "+" << B << "-" << C << "+" << D << "=7";
    } else if (A+B+C-D == 7) {
        cout << A << "+" << B << "+" << C << "-" << D << "=7";
    } else if (A-B-C+D == 7) {
        cout << A << "-" << B << "-" << C << "+" << D << "=7";
    } else if (A-B+C-D == 7) {
        cout << A << "-" << B << "+" << C << "-" << D << "=7";
    } else if (A+B-C-D == 7) {
        cout << A << "+" << B << "-" << C << "-" << D << "=7";
    } else if (A-B-C-D == 7) {
        cout << A << "-" << B << "-" << C << "-" << D << "=7";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#define MAX (int)1e+6
using namespace std;

int main(void){
  int i,j,n;
  int a[181],b[46];
  int dp1[MAX],dp2[MAX];

  b[0] = 0;
  j = 1;
  for(i=0;i<181;i++){
    a[i] = i * (i+1) * (i+2) / 6;
    if(a[i]&1)b[j++] = a[i];
  }

  for(i=0;i<MAX;i++)dp1[i] = dp2[i] = 1000000;

  for(i=0;i<MAX;i++){
    for(j=0;j<181;j++){
      if(i>a[j])dp1[i] = min(dp1[i],dp1[i-a[j]]+1);
      else if(i==a[j])dp1[i]=1;
      else break;
    }
  }
  
  for(i=0;i<MAX;i++){
    for(j=0;j<46;j++){
      if(i>b[j])dp2[i] = min(dp2[i],dp2[i-b[j]]+1);
      else if(i==b[j])dp2[i]=1;
      else break;
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp1[n],dp2[n]);
  return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int main() {
  lint N, K;
  string s;

  cin >> N >> K;
  cin >> s;

  s[K-1] = tolower(s[K-1]);
  cout << s << endl;
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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

	ll w,h,x,y;
	
	double ans=0;

	cin >> w >> h >> x >> y;
	
	ans=(double)(w*h)/2.0;

	cout << ans << "\n";
	
	int num=0;
	if(x*2==w && y*2==h) num=1;
	cout << num << endl;
	
	return 0;
}


//vector<int> a(n);  sort(a.begin(),a.end());
//cout << "test" << "\n";


//g++ -o a a.cpp


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

int main() {
    int n=1, x=1, count=0;
    while(cin >> n >> x) {
        if (n == 0 && x == 0) return 0;
        for (int i=1; i<n-1; i++) {
            for (int j=i+1; j<n; j++) {
                if (x - j - i <= n && x - j - i > j) count++;
            }
        }
        cout << count << endl;
        count =0;
    }
}

 


Measured memory_bytes: 3068
def solve(N,abc):
    dp=[[0]*3 for _ in range(N)]
    dp[0][0]=abc[0][0]
    dp[0][1]=abc[0][1]
    dp[0][2]=abc[0][2]
    for i in range(1,N):
        for j in range(3):
            dp[i][j]=max(dp[i-1][(j+1)%3]+abc[i][j],dp[i-1][(j+2)%3]+abc[i][j])
    return max([dp[N-1][i] for i in range(3)])

N=int(input())
abc=[list(map(int,input().split())) for _ in range(N)]
print(solve(N,abc))


Measured memory_bytes: 47348
from copy import deepcopy
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

ans = 0
for i in range(2 ** h):
    a = deepcopy(c)
    for b in range(h):
        if i >> b & 1:
            a[b] = 'r' * w
    for j in range(2 ** w):
        e = deepcopy(a)
        for l in range(w):
            if j >> l & 1:
                for m in range(h):
                    aa = e[m]
                    e[m] = aa[:l] + 'r' + aa[l + 1:]
        cnt = 0
        aaa = ''.join(e)            
        for d in range(h * w):
            if aaa[d] == '#':
                cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9196
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,vector<int> > P;

static const double eps = 1e-8;

int mypow(int x,int n){
	int res = 1;
	while(n>0){		
		if(n & 1) res = res*x;
		x = x * x;
		n>>=1;
	}
	return res;
}


int conv(vector<int>& sets,int n){
	int res = 0;
	for(int i=0;i<sets.size();i++){
		for(int j=0;j<n;j++){
			if(sets[i] & (1<<j)){
				res += i * mypow(3,j);
			}
		}
	}
	return res;
}

int bfs(int m,int n,vector<int>& root,bool* visited){

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,root));
	visited[conv(root,n)] = 0;
	vector<int> tmp;
	vector<int> sets;
	while(!que.empty()){
		int cost = que.top().first;
		
		sets = que.top().second;

		if(sets[1]==0 && sets[2]==0) return cost;
		if(sets[0]==0 && sets[1]==0) return cost;

		if(cost >= m) break;
		que.pop();
		for(int i=0;i+1<sets.size();i++){
			if((sets[i] && sets[i+1] && sets[i] < sets[i+1]) 
				|| (!sets[i] && sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i+1] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i+1] &= ~(1<<pos);
				tmp[i] |= (1<<pos);

				
				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}

			else if((sets[i] && sets[i+1] && sets[i] > sets[i+1]) 
				|| (sets[i] && !sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i] &= ~(1<<pos);
				tmp[i+1] |= (1<<pos);

				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}
		}
	}
	return -1;
}

int main(){

	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<int> sets(3);
		bool* visited = new bool[mypow(3,n)]();
		for(int i=0;i<3;i++){
			int amount;
			scanf("%d",&amount);
			for(int j=0;j<amount;j++){
				int size;
				scanf("%d",&size);
				sets[i] |= (1<<(size-1)); 
			}
		}

		printf("%d\n",bfs(m,n,sets,visited));
	}
	//printf("%d %d %d\n",mypow(3,0),mypow(3,1),mypow(3,2));
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
using P = pair<Int, Int>;
vector<P> v;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	v.resize(n);
	for(Int i=0; i<n; ++i){
		Int a, b; cin >> a >> b;
		v[i] = P(b, a);
	}
	sort(v.begin(), v.end());
	Int t = 0;
	for(Int i=0; i<n; ++i){
		t += v[i].second;
		if(t > v[i].first){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string L;
  std::cin >> L;
  std::vector<ll> dp1(L.size()+1),dp2(L.size()+1);
  dp1[L.size()]=dp2[L.size()]=1;
  int last_one=L.size();
  for(int i=L.size()-1;i>=0;i--){
    if(L[i]=='0') dp1[i]=dp1[i+1];
    else{
      dp1[i]=(dp2[i+1]+(2*dp1[last_one])%1000000007)%1000000007;
      last_one=i;
    }
    dp2[i]=(dp2[i+1]*3)%1000000007;
  }
  std::cout << dp1[0] << '\n';
  return 0;
}


Measured memory_bytes: 2616
n=int(input())
s=input()
count=0
x=[]
for i in range(n-1):
    a=s[:i+1]
    b=s[i+1:]
    for j in range(97,123):
        if a.count(chr(j))!=0 and b.count(chr(j))!=0:
            count+=1
    x.append(count)
    count=0
print(max(x))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
const ll mod=1e9+7ll;
ll a[100]={1, 2, 4, 5, 8, 10, 13, 14, 18, 21, 26, 28, 33, 36, 40, 41, 46, 50, 57, 60, 68, 73, 80, 82, 89, 94, 102, 105, 112, 116, 121, 122, 128, 133, 142, 146, 157, 164, 174, 177, 188, 196, 209, 214, 226, 233, 242, 244, 253, 260, 272, 277, 290, 298, 309, 312, 322, 329, 340};
map<ll,ll> m;
ll f(ll k)
{
//    cout<<k<<endl;
    if(k<=50)
    {
        return a[k];
    }
    if(m[k])
    {
        return m[k];
    }
    if(k&1)
    {
        return m[k]=(2ll*f(k/2ll)%mod+f(k/2ll-1ll)%mod)%mod;
    }else
    {
        return m[k]=(2ll*f(k/2ll-1ll)%mod+f(k/2ll)%mod)%mod;
    }
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	ll n;
	cin>>n;
	cout<<f(n)<<endl;

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
N, K = list(map(int,input().split()))
p_list = list(map(int,input().split()))

sum = 0
for k in range(K):
  sum += p_list[k]
max = sum

i = 0
while(i + K  < N):
  sum = sum - p_list[i] + p_list[i+K]
  if(sum > max):
    max = sum
  i += 1

print(0.5 * (max+K))

Measured memory_bytes: 25060
n,a,b = map(int,input().split())
M = [1]+[0]*n+[1]
a -= 1
b -= 1
M[a] = 1
M[b] = 1
turn = 1
while True:
    if turn == 1:
        if M[a+1] == 1 and M[a-1] == 0:
            M[a-1] = 1
            M[a] = 0
            a -= 1
            turn *= -1
        elif M[a-1] == 1 and M[a+1] == 0:
            M[a+1] = 1
            M[a] = 0
            a += 1
            turn *= -1
        elif M[a-1] == 0 and M[a+1] == 0:
            M[a+1] = 1
            M[a] = 0
            a += 1
            turn *= -1
        else:
            print("Borys")
            exit()
    else:
        if M[b+1] == 1 and M[b-1] == 0:
            M[b-1] = 1
            M[b] = 0
            b -= 1
            turn *= -1
        elif M[b-1] == 1 and M[b+1] == 0:
            M[b+1] = 1
            M[b] = 0
            b += 1
            turn *= -1
        elif M[b-1] == 0 and M[b+1] == 0:
            M[b-1] = 1
            M[b] = 0
            b -= 1
            turn *= -1
        else:
            print("Alice")
            exit()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 55;
bool can[N];
vector<pii> T[N];

vector<int> a,b;

bool vis[N];
int n;

void dfs(int u){
  vis[u]=true;
  for(auto x : T[u]){
    if(can[x.se]){
      if(!vis[x.fi])dfs(x.fi);
    }
  }
}


bool check(){
  for(int i = 0; i < n; i ++ ){
    for(int j = 0 ; j < N ; j ++ ) vis[j]=false;
    dfs(a[i]);
    if(!vis[b[i]])return false;
  }
  return true;
}

int main(){
  fastIO;
  for(int i = 0 ; i < N ; i ++ ){
    for(int j = 1 ; j < N ; j ++ ){
      if(i % j < i){
        T[i].push_back(mp(i % j, j));
      }
    }
  }
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0 ; i < n; i ++ ) cin >> a[i];
  for(int i = 0 ; i < n; i ++ ) cin >> b[i];
  ll ans = 0;
  for(int bit = N - 1; bit >= 1; bit -- ){
    can[bit]=false;
    for(int j = bit-1; j >= 0 ; j -- ) can[j]=true;
    if(!check()){
      if(bit == N - 1){
        cout << "-1\n";
        return 0;
      }
      ans |= (1ll << bit);
      can[bit]=true;
    }
    else{
      for(int j = bit; j >= 0 ; j -- ) can[j]=false;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
using System;

namespace s8pc_4_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }
            string t = Console.ReadLine();
            int small = 0;
            int question = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i].CompareTo(t) <= 0)
                {
                    s[i] = s[i].Replace('?', 'z');
                    if (s[i].CompareTo(t) >= 0)
                    {
                        question++;
                    }
                    else
                    {
                        small++;
                    }
                }
            }
            for (int i = 1; i <= question; i++)
            {
                Console.Write(small + i + " ");
            }
            Console.WriteLine(small + question + 1);
        }
    }
}

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

namespace RangeMinimumQuery {
  template<typename T, std::size_t N>
  void Init(T (&xs)[N], T max_value) {
    static_assert( (N & (~(N - 1))) == N, "N != 2^n");
    for(int i = 0; i < (int)N; ++i) {
      xs[i] = max_value;
    }
  }
  template<typename T, std::size_t N>
  void Update2(T (&xs)[N], int index) {
    if( index <= 1 ) return;
    int parent = index >> 1;
    int brother = index ^ 0x01;
    if( xs[index] < xs[brother] ) {
      xs[parent] = xs[index];
      Update2(xs, parent);
    }
    else {
      if( xs[parent] != xs[brother] ) {
        xs[parent] = xs[brother];
        Update2(xs, parent);
      }
    }
  }
  template<typename T, std::size_t N>
  void Update(T (&xs)[N], int index0, const T& value) {
    xs[(N >> 1) + index0] = value;
    Update2(xs, (N >> 1) + index0);
  }
  template<typename T, std::size_t N>
  T Query2(T (&xs)[N], int left, int right, int rl, int rr, int id) {
    if( rr <= left or right <= rl ) return xs[0];
    if( left <= rl and rr <= right ) return xs[id];
    int rm = (rl + rr) / 2;
    return std::min(Query2(xs, left, right, rl, rm, (id << 1) + 0),
                    Query2(xs, left, right, rm, rr, (id << 1) + 1));
  }
  // [left0, right0)
  template<typename T, std::size_t N>
  T Query(T (&xs)[N], int left0, int right0) {
    return Query2(xs, left0, right0, 0, N >> 1, 1);
  }
};
using namespace RangeMinimumQuery;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
// 
void Verify_1() {
  int n, q;
  int xs[131072 * 2];
  //int xs[16];
  scanf("%d %d", &n, &q);
  Init(xs, (int)((1U << 31) - 1));
  for(int i = 0; i < q; ++i) {
    int com, x, y;
    scanf("%d %d %d", &com, &x, &y);
    if( com == 0 ) {
      Update(xs, x, y);
    }
    else {
      y += 1;
      printf("%d\n", Query(xs, x, y));
    }
  }
}

int main() {
  Verify_1();  
  return 0;
}

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

int main() { 
  int N;
  string S;
  int nn=0;
  int ans=300000;

  cin >> N >> S ;
   vector<int> black(N);
  vector<int> white(N);
  if( S.at(0) == '#'){
      black.at(0)=1;
    }
    else{
      black.at(0)=0;
    }
  for(int i=1; i<N; i++){
    if( S.at(i) == '#'){
      black.at(i) = black.at(i-1) + 1;
    }
    else{
       black.at(i) = black.at(i-1);
    }
  }//forowari
  if (S.at(N-1) == '.'){
    white.at(N-1)=1;
  }
  else{
    white.at(N-1)=0;
  }
  for(int i = (N-2); i>=0; i--){
    if(S.at(i)=='.'){
       white.at(i) = white.at(i+1) + 1;
    }
    else{
           white.at(i) = white.at(i+1);
    }
  }
  int aa=0;
  for(int i=0; i<(N-1); i++){
    if( (S.at(i) == '.')&(S.at(i+1) == '#') ){
      aa = black.at(i) + white.at(i+1);
      ans = min(ans, aa);
      nn++;
    }
  }
int kouho;
    kouho = min (black.at(N-1) , white.at(0));
 
  
    cout<< min(ans,kouho) <<endl;
 
  }

Measured memory_bytes: 2180
import numpy as np
import sys
n = int(input())
q = []
def judge():
    state = True
    for i in range(n):
        if li[i] == 0:
            continue
        else:
            for j in range(len(q[i])):
                if li[q[i][j][0]] != q[i][j][1]:
                    return False
                else:
                    state = True
    if state == False:
        return False
    else:
        return True

for i in range(n):
    xy = []
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        xy.append([x-1,y])
    q.append(xy)
maxans = 0
for i in range(2**n):
    li = [0]*n
    ans = 0
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = 1
    if judge() == True:
        ans = sum(li)
        maxans = max(maxans,ans)
    else:
        continue
print(maxans)





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

void solve(long long N, std::vector<long long> A) {
    vector<long long> uniq;
    uniq.push_back(A[0]);
    for (size_t i = 1; i < A.size(); i++) {
        if (A[i - 1] != A[i]) {
            uniq.push_back(A[i]);
        }
    }

    vector<long long> v;
    v.push_back(uniq[0]);
    for (long long i = 1; i < (long long)uniq.size() - 1; i++) {
        if ((uniq[i - 1] < uniq[i]) != (uniq[i] < uniq[i + 1])) {
            v.push_back(uniq[i]);
        }
    }
    v.push_back(uniq[uniq.size() - 1]);

    long long ans = 1000;

    long long money = 1000;
    long long stock = 0;
    for (long long i = 0; i < v.size(); i++) {
        if (i % 2) {
            stock = money / v[i];
            money -= stock * v[i];
        } else {
            money += stock * v[i];
            stock = 0;
        }
        ans = max(ans, money);
    }

    money = 1000;
    stock = 0;
    for (long long i = 0; i < v.size(); i++) {
        if (i % 2 == 0) {
            stock = money / v[i];
            money -= stock * v[i];
        } else {
            money += stock * v[i];
            stock = 0;
        }
        ans = max(ans, money);
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3692
#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10**6)
n = int(input())

csf = [list(map(int, input().split())) for i in range(n-1)]

for i in range(n-1):
    csf_tmp = csf[i:]

    c, s, f = csf_tmp[0]

    t = c+s
    for j in range(1, len(csf_tmp)):
        c, s, f = csf_tmp[j]

        if t <= s:
            t = s
        else:
            mod = (t-s) % f
            if mod != 0:
                t += f-mod
        # print(t)
        t += c
        # print(t)
    print(t)
    # print()
print(0)


Measured memory_bytes: 9236
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        s[i]='x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int a[100001]={},N,temp,ans=0;

int main(){
    cin>>N;
    rep(i,N){
        cin>>temp;
        if(temp>100000)ans++;
        else a[temp]++;
    }
    repi(i,1,100001){
        if(a[i]!=i){
            if(a[i]>i){
                ans+=a[i]-i;
            }
            else{
                ans+=a[i];
            }
        }
    }
    out(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
bool is_prime[123456*2+10];
void prime(){
    ll p=0;
    for(int i=0;i<123456*2+10;i++) is_prime[i]=true;
    for(int i=2;i<=123456;i++){
        if(is_prime[i]){
            for(int j=2*i;j<123456*2+10;j+=i) is_prime[j]=false;
        }
    }
}
int main(){
    prime();
    while(1){
        cin>>n;
        //cout<<n<<" start"<<endl;
        if(n==0) break;
        int ans=0;
        for(int i=n+1;i<=2*n;i++){
            if(is_prime[i]) {
                //cout<<i<<" ";
                ans++;
            } 
        }
        //cout<<"ans ";
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3324
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }
  int m = n/8;
  vector<int> ans;
  int a = n%8;
  if (a % 2 == 1) {
    ans.push_back(m*12+6);
  }
  if (a >= 2) {
    ans.push_back(m*12+2);
    ans.push_back(m*12+4);
  }
  if (a >= 4) {
    ans.push_back(m*12+3);
    ans.push_back(m*12+9);
  }
  if (a >= 6) {
    ans.push_back(m*12+8);
    ans.push_back(m*12+10);
  }

  for (int i = 0; i < m; ++i) {
    ans.push_back(i*12+2);
    ans.push_back(i*12+3);
    ans.push_back(i*12+4);
    ans.push_back(i*12+6);
    ans.push_back(i*12+8);
    ans.push_back(i*12+9);
    ans.push_back(i*12+10);
    ans.push_back(i*12+12);
  }
  for (int i : ans) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"os"
)

func solve(N, digits, acc int, d3, d5, d7 bool) int {
	if digits == 0 {
		if acc <= N && d3 && d5 && d7 {
			return 1
		}
		return 0
	}

	res := solve(N, digits-1, acc*10+3, true, d5, d7) +
		solve(N, digits-1, acc*10+5, d3, true, d7) +
		solve(N, digits-1, acc*10+7, d3, d5, true)
	if acc <= N && d3 && d5 && d7 {
		res++
	}
	return res
}

func main() {
	r := os.Stdin
	var N int
	fmt.Fscan(r, &N)

	//generate
	res := solve(N, 9, 0, false, false, false)
	fmt.Println(res)
}


Measured memory_bytes: 512
#!/usr/bin/env python3
#ABC91 B

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
for i in range(n):
    ans = max(ans,s.count(s[i])-t.count(s[i]))
print(ans)


Measured memory_bytes: 38256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;
const ll INF = 100000;
int main() {
	ll N, Q, sum = 0;
	cin >> N;
	vector<ll> A(N);
	vector<ll> W(INF,0);
	rep(i, N) {
		cin >> A[i];
		W[A[i]]++;
	}
	rep(i, N) sum += A[i];
	cin >> Q;
	vector<ll> ans(Q);
	rep(i, Q) {
		ll B, C;
		cin >> B >> C;
		W[C] += W[B];
		sum += (C - B) * W[B];
		W[B] = 0;
		ans[i] = sum;
	}
	rep(i, Q) cout << ans[i] << endl;
	return 0;
}

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

int main() {
  int alice = 0, bob = 0;
  int n;
  vector<int> num;

  scanf("%d", &n);

  for (int k = 0; k < n; k++) {
    int t;
    scanf("%d", &t);
    num.push_back(t);
  }

  sort(num.begin(), num.end(), greater<int>());

  for (int k = 0; k < n; k++) {
    k % 2 == 0 ? alice += num[k] : bob += num[k];
  }
  int ans = alice - bob;
  printf("%d\n", ans);
}

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

count = 0
for i in range(1, n):
    l = s[:i]
    r = s[i:]
    
    x = 0
    if len(set(l)) > len(set(r)):
        x = len(set(l)) - len(set(l) - set(r))
    else:
        x = len(set(r)) - len(set(r) - set(l))
    
    if count < x:
        count = x

print(count)

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

int main() {
  int N;
  int a, b = 0;
  cin >> N;
  vector <int>cards(N);
  
  for (int i = 0; i < N; i++){
    cin >> cards.at(i);
  }
  std::sort(cards.begin(), cards.end(), greater<>());

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      a += cards.at(i);
    } else {
      b += cards.at(i);
    }
  }
  cout << a - b << endl;
}

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

typedef long long int ll;

int main()
{
    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1;
        return 0;
    }

    if(w % 2 == 0){
        cout << w / 2 * h;
    }
    else if(h % 2 == 0){
        cout << h / 2 * w;
    }
    else{
        ll ans = (w + 1) / 2 * (h + 1) / 2;
        ans += (w / 2) * (h / 2);
        cout << ans;
    }

    return 0;
}

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

int main(){
  int64_t N;
  cin >> N;
  priority_queue<string> S;
  string s;
  for(int i=0;i<N;i++){
    cin >> s;
    S.push(s);
  }
  string a="0";
  int64_t x=0;
  for(int i=0;i<N;i++){
    if(S.top()==a){
      S.pop();
    }else{
      a=S.top();
      x++;
      S.pop();
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 11592
// Delete the dynamically allocated memory
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ll n;
	cin>>n;
	mk(arr,n,ll)
	for(ll i=0;i<n;i++){
		arr[i]=0;
	}
	for(ll i=1;i*i<=n;i++){
		for(ll j=1;j*j<=n;j++){
			for(ll k=1;k*k<=n;k++){
				ll v=(i+j)*(i+j)+(i+k)*(i+k)+(j+k)*(j+k);
				if(v%2==0){
					v=v/2;
					if(v<=n){
						arr[v-1]++;
					}	
				}
			}
		}
	}
	for(ll i=0;i<n;i++){
		cout<<arr[i]<<"\n";
	}
	delete[] arr;
	return 0;
}

Measured memory_bytes: 3644
def tramp(gen):
    stack = [gen]
    val = None
    while stack:
        try:
            stack.append(stack[-1].send(val))
            val = None
        except StopIteration as e:
            stack.pop()
            val = e.args
    return val
    
N, M, K = map(int, input().split())
adj = [[] for _ in range(N)]
blks = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
for _ in range(K):
    a, b = map(int, input().split())
    blks[a - 1].add(b - 1)
    blks[b - 1].add(a - 1)
vis = [False] * N
def go(curr):
    if vis[curr]:
        return
    vis[curr] = True
    comp.add(curr)
    for n in adj[curr]:
        yield go(n)
ans = [0] * N
for i in range(N):
    comp = set()
    if vis[i]:
        continue
    tramp(go(i))
    for i in comp:
        x = len(comp) - 1 - len(adj[i])
        for k in blks[i]:
            if k in comp:
                x -= 1
        ans[i] = x
print(*ans)


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

public class Main {
	class Total {
		int id, total;
		public Total(int id, int total){
			this.id = id;
			this.total = total;
		}
		public void add(int x){
			total += x;
		}
	}
	class PriorityQueue {
		Total[] heap;
		int size;
		int[] idx;
		public PriorityQueue(int n){
			heap = new Total[n];
			size = n;
			idx = new int[n];
			for(int i = 0; i < n; i++){
				heap[i] = new Total(i+1, 0);
				idx[i] = i;
			}
		}
		public void addValue(int a, int x){
			heap[idx[a]].total += x;
			if( x > 0 ){
				heapify_up(idx[a]);
			} else {
				heapify_down(idx[a]);
			}
		}
		public void swap(int x, int y){
			Total temp = new Total(heap[x].id, heap[x].total);
			heap[x] = heap[y];
			heap[y] = temp;
			idx[heap[x].id-1] = x;
			idx[heap[y].id-1] = y;
 		}
		public int compare(Total x, Total y){
			if( x.total > y.total ){
				return -1;
			}
			if( x.total == y.total && x.id < y.id ){
				return -1;
			}
			return 1;
		}
		public void heapify_up(int a){
			int par = (a-1)/2;
			if( compare(heap[a], heap[par]) < 0 ){
				swap(a, par);
				heapify_up(par);
			}
		}
		public void heapify_down(int a){
			int ch1 = 2*a+1;
			int ch2 = 2*a+2;
			int max = a;
			if( ch1 < size && compare(heap[ch1], heap[max]) < 0 ){
				max = ch1;
			}
			if( ch2 < size && compare(heap[ch2], heap[max]) < 0 ){
				max = ch2;
			}
			if( max != a ){	
				swap(a, max);
				heapify_down(max);
			}
		}
	}
	public void solve() throws IOException {
		int n = nextInt();
		PriorityQueue queue = new PriorityQueue(n);
		int q = nextInt();
		for(int i = 0; i < q; i++){
			int a = nextInt();
			int v = nextInt();
			queue.addValue(a-1, v);	
			writer.println(queue.heap[0].id + " " + queue.heap[0].total);
		}			
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
}

Measured memory_bytes: 97688
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
#define ll long long
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  ll N;
  cin >> N;
  ll A[100100];
  FOR(i, 0, N) cin >> A[i];
  
  ll ans;
  ll ansg=0;
  ll ansk=A[0];
  FOR(i, 0, N){
    if(i%2==0) ansg += A[i];
    else ansg -= A[i];
  }
  FOR(i, 1, N){
    if(i%2!=0) ansk += A[i];
    else ansk -= A[i];
  }
  
  cout << ansg << " ";
  cout << ansk << " ";
  FOR(i, 2, N){
    if(i%2==0) {
      ansg = ansg + 2*A[i-1] - 2*A[i-2];
      cout << ansg << " ";
    }else{
      ansk = ansk + 2*A[i-1] - 2*A[i-2];
      cout << ansk << " ";
    }
  }
      
}

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

vector<int> eratosthenes() {
  int MAX = 1010;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i < MAX; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j < MAX; j += i)
      is_prime[j] = 0;
  }
  return is_prime;
}

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

  auto isPrime = eratosthenes();

  ll M = 1000000007;
  map<int, int> m;
  for (ll k = 2; k <= n; k++) {
    ll x = k;
    for (ll i = 1; i <= n; i++) {
      if (isPrime[i] == 1) {
        while (x % i == 0) {
          x /= i;
          m[i] += 1;
        }
      }
    }
  }
  ll cnt = 1;
  for (auto v : m) {
    cnt = cnt % M * (v.second + 1) % M;
  }
  cout << cnt % M << endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(input().split()).astype(int)

# res = np.sum(A == np.arange(1,N+1).reshape(N,1), axis= 1)
res = np.zeros(N).astype(int)
for i in range(N-1):
    res[A[i]-1] += 1
for i in range(N):
    print(res[i])

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

int main() {
  int n;
  cin >> n;
 vector<int> p(n);
  rep(i, n){
    cin >>p.at(i);
  }
  int count=0;
  rep(i,n-2){
    if((p.at(i)<p.at(i+1) &&p.at(i+1)<p.at(i+2))||(p.at(i)>p.at(i+1) && p.at(i+1)>p.at(i+2))){
	count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var c = GetString().ToCharArray();

		var csum = new long[N + 1];
		for(long i = 0; i < N; i++)
			csum[i + 1] = (c[i] == 'R') ? (csum[i] + 1) : csum[i];

		long ans = long.MaxValue;		
		long R = c.Count(x => x == 'R');
		for(long i = 0; i <= N; i++)
			chmin(ref ans, Abs(R - i) + Abs(csum[i] - i));

		WriteLine(ans);	
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 30632
#include <iostream>
using namespace std;
int main(){
    int K,N;
    cin >> K>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int max=0;
    for(int i=0;i<N-1;i++){
        if(A[i+1]-A[i]>(K+1)/2){
            if(max<K-(A[i+1]-A[i])){
                max=K-(A[i+1]-A[i]);
            }
        }else{
            if(max<A[i+1]-A[i]){
                max=A[i+1]-A[i];
            }
        }
    }
    if(A[N-1]-A[0]>(K+1)/2){
            if(max<K-(A[N-1]-A[0])){
                max=K-(A[N-1]-A[0]);
            }
        }else{
            if(max<A[N-1]-A[0]){
                max=A[N-1]-A[0];
            }
    }
    cout << K-max;
    return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), K = in.ni();
        int[] a = in.ni(n);
        int l = 0, r = inf;
        while(r-l>1){
            int mid = (l+r)/2;
            int k = 0;
            for(int i = 0; i < n; i++) k += (a[i] + mid - 1) / mid-1;
            if(k<=K) r = mid;
            else l = mid;
        }
        out.println(r);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 55036