akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import re

S = input()

replaced_S = re.sub('[^ATCG]', ' ', S)

list_S = [s for s in replaced_S.split()]

max_length = 0
for s in list_S:
    if len(s) > max_length:
        max_length = len(s)

print(max_length)


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

int main(void){
  
  int C[MAX];
  int n;
  int i,j;
  int s;
  unsigned short *A,*B;
  
  scanf("%d",&n);

  s = sizeof(short)*n + 1;
    
  A = malloc(s);
  B = malloc(s);
  
  for(i = 0;i < MAX;i++){
    C[i] = 0;
  }
    
  for(i = 0;i < n;i++){
    scanf("%hu",&A[i+1]);
    C[ A[i+1] ]++;
  }

  for(i = 1;i <= MAX;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j = 1;j <= n;j++){
    B[ C[A[j]] ] = A[j];
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++){
    if(i != 1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}
      



Measured memory_bytes: 9156
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := NewLazySegTree(n)
	for ; q > 0; q-- {
		if ReadInt() == 0 {
			t.Add(ReadInt(), ReadInt()+1, ReadInt())
		} else {
			Println(t.Find(ReadInt(), ReadInt()+1))
		}
	}
}

type LazySegTree struct {
	nodes []int
	lazy  []int
}

const Inf = 1 << 62
const None = -Inf

func NewLazySegTree(n_ int) *LazySegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	t := &LazySegTree{
		nodes: make([]int, n<<1),
		lazy:  make([]int, n<<1),
	}
	for i := 1; i < len(t.lazy); i++ {
		t.lazy[i] = None
	}
	return t
}

func (t *LazySegTree) lazyEval(k, l, r int) {
	if t.lazy[k] == None {
		return
	}
	t.nodes[k] += t.lazy[k]
	if r-l > 1 {
		t.lazyAdd(k<<1, t.lazy[k])
		t.lazyAdd(k<<1+1, t.lazy[k])
	}
	t.lazy[k] = None
}

func (t *LazySegTree) lazyAdd(k, v int) {
	if t.lazy[k] == None {
		t.lazy[k] = v
	} else {
		t.lazy[k] += v
	}
}

func (t *LazySegTree) Add(a, b, x int) {
	t.addRecur(a, b, x, 1, 0, len(t.nodes)>>1)
}
func (t *LazySegTree) addRecur(a, b, x, k, l, r int) {
	t.lazyEval(k, l, r)
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		t.lazyAdd(k, x)
		t.lazyEval(k, l, r)
	} else {
		t.addRecur(a, b, x, k<<1, l, (l+r)>>1)
		t.addRecur(a, b, x, k<<1+1, (l+r)>>1, r)
		t.nodes[k] = Min(t.nodes[k<<1], t.nodes[k<<1+1])
	}
}

func (t *LazySegTree) Find(a, b int) int {
	return t.findRecur(a, b, 1, 0, len(t.nodes)>>1)
}

func (t *LazySegTree) findRecur(a, b, k, l, r int) int {
	t.lazyEval(k, l, r)
	if b <= l || r <= a {
		return Inf
	}
	if a <= l && r <= b {
		return t.nodes[k]
	} else {
		return Min(
			t.findRecur(a, b, k<<1, l, (l+r)>>1),
			t.findRecur(a, b, k<<1+1, (l+r)>>1, r),
		)
	}
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



Measured memory_bytes: 7456
def middle(lst):
    _lst = lst
    _lst.sort()
    return _lst[-2]

def min_times(lst):
    data = lst
    times = 0
    idx_even = []
    idx_odd = []
    for i, v in enumerate(data):
        if v % 2 == 0:
            idx_even.append(i)
        else:
            idx_odd.append(i)
    odd_len = len(idx_odd)
    if odd_len == 2:
        for i in idx_odd:
            data[i] += 1
        times += 1
    if odd_len == 1:
        for i in idx_even:
            data[i] += 1
        times += 1
    times += (max(data) - middle(data)) / 2
    times += (max(data) - min(data)) / 2
    return times

use_data = [int(i) for i in raw_input().strip().split()]

print(min_times(use_data))

Measured memory_bytes: 2692
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d%d%d",&a, &b, &c);
  if(a < b && b < c){
    printf("%d %d %d\n",a, b, c);
  }
  else if(a < c && c < b){
    printf("%d %d %d\n",a, c, b);
  }
else if(b < a && a < c){
    printf("%d %d %d\n",b, a, c);
  }
  else if(b < c && c < a){
    printf("%d %d %d\n",b, c, a);
  }
  else if(c < a && a < b){
    printf("%d %d %d\n",c, a, b);
  }
  else if(c < b && b < a){
    printf("%d %d %d\n",c, b, a);
  }
else if(c == b && b < a){
    printf("%d %d %d\n",c, b, a);
  }
else if(c < b && b == a){
    printf("%d %d %d\n",c, b, a);
  }
  else if(b < c && c == a){
    printf("%d %d %d\n",b, c, a);
 }
  else if(b == c && c == a){
    printf("%d %d %d\n",b, c, a);
  }
 else if(a < c && c == b){
   printf("%d %d %d\n",a, c, b);
 }
   else if(a == c && c < b){
     printf("%d %d %d\n",a, c, b);
 }
 else if(b == a && a < c){
   printf("%d %d %d\n",b, a, c);
 }


  
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

#define UF_NUM 505050

li parent[UF_NUM];
li sizes[UF_NUM];

inline void init_uf() {
    rep(i, UF_NUM) {
        parent[i] = i;
        sizes[i] = 1;
    }
}

inline li find(li x) {
    if (parent[x] == x)return x;
    else return (parent[x] = find(parent[x]));
}

inline void union_(li x, li y) {
    li parent_x = find(x);
    li parent_y = find(y);
    sizes[parent_y] += sizes[parent_x];
    parent[parent_x] = parent_y;
}

PI edges[100100];

li res[100100];
li n, m;

int main() {
    init_uf();
    cin >> n >> m;
    rep(i, m) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[i] = {a, b};
    }

    li res_now = n * (n - 1) / 2;
    for (li i = m - 1; i >= 0; i--) {
        res[i] = res_now;
        li root_x = find(edges[i].F);
        li root_y = find(edges[i].S);
        if (root_x != root_y) {
            res_now -= (sizes[root_x] * sizes[root_y]);
            union_(root_x, root_y);
        }
    }

    rep(i, m) {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	char in[1005];
	while(~scanf("%s",in)){
		VgetI(w);
		int l=strlen(in);
		F(i,0,l) if(i%w==0) printf("%c",in[i]);
		puts("");
	}
}


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

using namespace std;

typedef long long ll;

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

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

	int n;
	ll k;
	cin >> n >> k;

	vector<int> a(n);

	rep(i, n){
		cin >> a[i];
		a[i]--;
	}

	map<int, int> mp;
	set<int> st;

	int x = 0;
	int cnt = 0;
	while(st.count(x) == 0){
		mp[x] = cnt;
		st.insert(x);
		x = a[x];
		cnt++;
	}
	
	int s = mp[x];
	if(k < s){
		for(auto p : mp){
			if(p.second == k){
				cout << p.first + 1 << endl;
				return 0;
			}
		}
	}

	k -= s;
	
	int l = cnt - s;
	k %= l;
	for(auto p : mp){
		if(p.second == k + s){
			cout << p.first + 1 << endl;
			return 0;
		}
	}


}


Measured memory_bytes: 22380
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

ll N, K;
vector<ll> V;

void solve()
{
    cin >> N >> K;
    vector<ll> V(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> V.at(i);
    }

    ll maxCount = 0;
    ll minNK = min(N, K);
    for (ll i = 0; i <= minNK; i++)
    {
        ll lcount = 0;
        vector<ll> MINUS;
        // 左から i個とる
        // 合計を計算
        for (ll l = 0; l < i; l++)
        {
            lcount += V.at(l);
            if (V.at(l) < 0)
            {
                MINUS.push_back(V.at(l));
            }
        }

        for (ll j = 0; j <= minNK - i; j++)
        {
            ll rcount = 0;
            // 右からj個とる
            // 合計を計算
            vector<ll> RMINUS(MINUS.size());
            copy(MINUS.begin(), MINUS.end(), RMINUS.begin());
            for (ll r = 0; r < j; r++)
            {
                rcount += V.at(N - r - 1);
                if (V.at(N - r - 1) < 0)
                {
                    RMINUS.push_back(V.at(N - r - 1));
                }
            }

            sort(RMINUS.begin(), RMINUS.end());
            ll num = RMINUS.size();
            ll allcount = rcount + lcount;
            for (ll m = 0; m < num && m < K - (j + i); m++)
            {
                allcount -= RMINUS.at(m);
            }
            maxCount = max(allcount, maxCount);
        }
    }

    std::cout << maxCount << endl;

    return;
}

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


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

int main(){
  int K;
  string S;
  cin>>K>>S;
  int N=S.size();
  if(N<=K){
    cout<<S<<endl;
  }else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}


Measured memory_bytes: 3632
import java.util.*;

import java.io.*;

public class Main {

	static int n;
	static long memo[][];
	static int p;
	static int pl[][];
	static pair[] a;
	static int k;

	public static long dp(int msk, int idx) {
		if (idx == n)
			return 0;
		if (memo[msk][idx] != -1)
			return memo[msk][idx];
		long max = k - (idx - Integer.bitCount(msk)) > 0 ? dp(msk, idx + 1) + a[idx].x : dp(msk, idx + 1);

		for (int i = 0; i < p; i++) {
			if (((msk >> i) & 1) == 0) {
				max = Math.max(max, pl[a[idx].y][i] + dp(msk | 1 << i, idx + 1));
			}
		}
		return memo[msk][idx] = max;

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		char c[] = br.readLine().toCharArray();
		int a=0;
		int b=0;
		for (int i = 0; i < c.length; i++) {
			if(c[i]=='A')
				a++;
			else
				b++;
		}
		if(a==0||b==0)
			System.out.println("No");
		else
			System.out.println("Yes");
	}

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

	static class pair {
		int x;
		int y;

		pair(int r, int t) {
			x = r;
			y = t;
		}

		public String toString() {
			return "(" + x + "," + y + ")";
		}

	}
}

Measured memory_bytes: 21200
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
int main()
{
	int a=0,b=0,c=0;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='a')
		{
			a++;
		}
		if(s[i]=='b')
		{
			b++;
		}
		if(s[i]=='c')
		{
			c++;
		}
	}
	if(a>0 && b>0 && c>0)
	{
		cout << "Yes";
	}
	else
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import math
import itertools
n=int(input())
town=[]
for i in range(n):
  xy=list(map(int,input().split()))
  town.append(xy)
p=list(itertools.permutations(town,n))
d=0
for i in range(len(p)):
  for j in range(len(p[i])-1):
    d+=math.sqrt((p[i][j][0]-p[i][j+1][0])**2+(p[i][j][1]-p[i][j+1][1])**2)
print(d/len(p))

Measured memory_bytes: 13908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int64_t s1 = a * b;
  int64_t s2 = c * d;
  
  if(s1 == s2){
    cout << s1 << endl;
  }
  else{
    cout << max(s1, s2) << endl;
  }
  
  


}
             

Measured memory_bytes: 3564
# スペース区切りの整数の入力
N,D=gets.chomp.split(" ").map(&:to_i);
$array = Array.new(N)
n=0
while(n<N)
 $array[n]=gets.chomp.split(" ").map(&:to_i);
  n=n+1
end
def dist(i,j)
d=0
index=0
while(index<D)
d=d+($array[i][index]-$array[j][index])*($array[i][index]-$array[j][index])
index=index+1
end
return d
end
def f(n)
  val= Math.sqrt(n)
  return val-val.to_i
end

count=0
i=0
j=1
while(j<N)
 i=0
 while(i<j)
  if (f(dist(i,j))==0)
  count=count+1
  end
 i=i+1
 end
 j=j+1
end
print(count)

Measured memory_bytes: 1788
# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = map(int, open(0).read().split())

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    # bfs
    queue = deque([1])
    signposts = [0] * (N + 1)
    signposts[1] = 1
    while queue:
        u = queue.popleft()
        for v in graph[u]:
            if not signposts[v]:
                signposts[v] = u
                queue.append(v)

    if all(signposts[2:]):
        print("Yes")
        print("\n".join(map(str, signposts[2:])))
    else:
        print("No")


if __name__ == "__main__":
    main()


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

d = {}
for i in a:
  if i not in d: d[i] = 1
  else: d[i] += 1

ans = 0
t = len(d.keys())
if t <= k:
  print(0)
else:
  p = t-k
  for i in sorted(d.values()):
    if p == 0: break
    ans += i
    p -= 1
  print(ans)
    

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(){
	
	string s; cin >> s;
	cout << (s == "ARC"?"ABC\n":"ARC\n");
	
	return;
}

int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	solve();
		
	return 0;
}


Measured memory_bytes: 3656
def isNotLower(s):
  return not (ord('a') <= ord(s) <= ord('z'))

S = input()

if S[0] != 'A':
  print("WA")
  exit()

if S[2:-1].count('C') != 1:
  print("WA")
  exit()

upper_limit = 2 # only 'A', 'C'
for s in S:
  if isNotLower(s):
    upper_limit -= 1

  if upper_limit < 0:
    print("WA")
    exit()

print("AC")


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int n;
	cin >> n;

	// 解答用変数
	ll ans = 0;
	map<int,int> a;
	rep(i,n){
		int temp;
		cin >> temp;
		a[temp]++;
		ans += temp;
	}

	// クエリ実行
	int q;
	cin >> q;
	int b,c;
	rep(i,q){
		cin >> b >> c;
		// a内にbの要素があるかどうか
		auto itr = a.find(b);
		if(itr != a.end()){
			int count = itr->second;
			ans += (c - b) * count;
			a[c] += count;
			a.erase(b);
		}
		cout << ans << endl;
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 7548
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int cnt = 0;
    int A2, B2, C2;
    if (A == B && B == C && C == A) {
        if (A % 2 == 0) {
            cout << "-1" << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    else if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << 0 << endl;
    }
    else {
        while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            A2 = B / 2 + C / 2;
            B2 = C / 2 + A / 2;
            C2 = A / 2 + B / 2;
            A = A2;
            B = B2;
            C = C2;
            cnt++;
        }
        cout << cnt << endl;
    }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S.at(i);
  vector mh = {-1, 0, 1, 0};
  vector mw = {0, 1, 0, -1};
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      if (S.at(h).at(w) == '#') {
        bool b = 0;
        for (int i = 0; i < 4; i++) {
          int nh = h + mh.at(i);
          int nw = w + mw.at(i);
          if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
          if (S.at(nh).at(nw) == '#') b = 1;
        }
        if (!b) return cout << "No" << "\n", 0;
      }
    }
  }
  cout << "Yes" << "\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int l1;
#define input l1 t;cin>>t;while(t--)
#define pb push_back
int main(){
	l1 n,m,c=0;
  	cin>>n>>m;
  	l1 x;
  vector<l1>a;
  	for(l1 i=0;i<n;i++){
    cin>>x;
      a.pb(x);     
    }
  l1 s=accumulate(a.begin(),a.end(),0);
  l1 u=(s/(4*m));
  if(u*4*m!=s)
    u++;
  for(l1 i=0;i<n;i++){
       if(a[i]>=u)
         c++;
   }
  if(c>=m)
    	cout<<"Yes\n";
  else
    	cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(void){
    int N, ans = 0;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; ++i){
        std::cin >> A[i];
        --A[i];
    }

    for (int i = 0; i < N; ++i){
        if (i == A[A[i]]) ++ans;
    }

    std::cout << ans / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 3676
import sys
from scipy.sparse.csgraph import floyd_warshall
input = sys.stdin.readline

INF = float('inf')
n, m, l = map(int, input().split())
table_1 = [ [0 for _ in range(n) ] for _ in range(n) ]
table_2 = [ [0 for _ in range(n) ] for _ in range(n) ]

for _ in range(m):
    a, b, c = map(int, input().split())
    if c<=l:
        table_1[a-1][b-1] = c
        table_1[b-1][a-1] = c

table_1 = floyd_warshall(csgraph=table_1, directed=False)

for i in range(n):
    for j in range(i+1, n):
        if table_1[i][j] <= l:
            table_2[i][j] = 1
            table_2[j][i] = 1

table_2 = floyd_warshall(csgraph=table_2, directed=False)

q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    if table_2[s-1][t-1] == INF:
        print(-1)
    else:
        print(int(table_2[s-1][t-1])-1)

Measured memory_bytes: 18332
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200001)

typedef struct _range {
    int upper, lower;
    struct _range *ubound, *lbound;
} Range;

Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    return range;
}

int idx[N_MAX];
long long sum;
Range range;

void calc(int value, register int index) {
    register Range *tmp = &range;
    long long len1, len2, len3;
    for (;;) {
        if (tmp->lower <= index && index <= tmp->upper) {
            len1 = (long long)(tmp->upper - tmp->lower + 1);
            len2 = (long long)(tmp->upper - index);
            len3 = (long long)(index - tmp->lower);
            sum += (len1 * (len1 + 1LL) - (len2 * (len2 + 1LL)) - (len3 * (len3 + 1))) / 2LL * (long long)value;
            if (tmp->lower == index) {
                tmp->lower++;
            } else if (tmp->upper == index) {
                tmp->upper--;
            } else {
                tmp->lbound = newRange(tmp->lower, index - 1);
                tmp->ubound = newRange(index + 1, tmp->upper);
                tmp->lower = tmp->upper = index;
            }
            break;
        } else if (index < tmp->lower) {
            tmp = tmp->lbound;
        } else {
            tmp = tmp->ubound;
        }
    }
}


int main(void){
    register int i, n;
    int a;
    
    scanf("%d", &a); n = a;

    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        idx[a] = i;
    }
    
    range.upper = n - 1;
    
    for (i = 1; i <= n; i++) {
        calc(i, idx[i]);
    }
    
    printf("%lld\n", sum);

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string ans = "Three";
  for(int i=0; i<N; i++){
    char S;
    cin >> S;
    if(S=='Y'){
      ans = "Four";
    }
  }
  cout << ans << endl;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int p[N];
    for(int i =0; i < N; i++){
        cin >> p[i];
    }
    int maxsum = 0;
    for(int j =0; j < K; j++){
        maxsum += p[j];
    }
    int partsum = maxsum;
    for(int i =0; i < N - K; i++){
        partsum += p[i + K] - p[i];
        if(partsum > maxsum) maxsum = partsum;
    }
    cout <<setprecision(10)<< (maxsum + K)/2.0 << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
 int num;
 int digitsin[3];
 int digitsout[3];
 int i;

 scanf("%d",&num);
 digitsin[2]=num/100;
 digitsin[1]=(num-100*digitsin[2])/10;
 digitsin[0]=(num-100*digitsin[2]-10*digitsin[1]);
 for(i=0;i<3;i++)
 {
  if (digitsin[i]==1)
  { 
   digitsout[i]=9;
  }else if (digitsin[i]==9)
  {
   digitsout[i]=1;
  }else
  {
   digitsout[i]=digitsin[i];
  }
 }
 for(i=0;i<3;i++) printf("%d",digitsout[2-i]);
 printf("\n");
 return 0;
}


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

template<class T> inline T gcd(T a, T b) {
    if (b == 0) return a;
    return  gcd(b, a % b);
}

template<class T> inline T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll l = lcm(c, d);
    ll divL = (b / l) - ((a - 1) / l);
    ll divC = (b / c) - ((a - 1) / c);
    ll divD = (b / d) - ((a - 1) / d);

    ll ans = (b - a + 1) - (divC + divD - divL);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
B = [A[i]+i for i in range(N)]
C = [i-A[i] for i in range(N)]
d1 = defaultdict(lambda:0)
d2 = defaultdict(lambda:0)
for b in B:
    d1[b] += 1
for c in C:
    d2[c] += 1
ans = 0
for b in d1:
    ans += d1[b]*d2[b]

print(ans)

Measured memory_bytes: 165048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using int64 = long long;

const int MAXN = 200000;

static int64 A[MAXN];
static vector<int> tree[MAXN];

int64 dfs(int v, int p) {
    if (tree[v].size() == 1) {
        return A[v];
    }
    int64 sum = 0,
          maxc = 0;

    for (int to : tree[v]) {
        if (to == p) continue;
        int64 child = dfs(to, v);
        if (child < 0) return -1;
        sum += child;
        maxc = max(maxc, child);
    }
    // sum - A[v]個のペアを作りたい
    int64 L = sum - A[v];

    if (L < 0 or min(sum / 2, sum - maxc) < L) return -1;
    return sum - 2 * L;
}

int main() {
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    if (N == 2) {
        cout << (A[0] == A[1] ? "YES" : "NO") << endl;
        return 0;
    }

    int r = -1;
    for (int i = 0; i < N; i++) if (tree[i].size() > 1) r = i;

    if (dfs(r, -1) == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

typedef long long ll;

const ll inf = 1000000000;

int main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    
    if (x1 == 0) {
        cout << 1 << endl;
    } else if (x2 == 0) {
        cout << 2 << endl;
    } else if (x3 == 0) {
        cout << 3 << endl;
    } else if (x4 == 0) {
        cout << 4 << endl;
    } else {
        cout << 5 << endl;
    }
}


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

int main()
{
    int n;
    while(cin>>n)
    {
        set <string> s;
        string a;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            s.insert(a);
        }
        cout<<s.size()<<endl;
    }
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int64_t ans = 0;
    for (int64_t i = 0; i < S.size() / 2; i++) {
        if (S[i] != S[S.size() - 1 - i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int h[999999];
  for(int i=1;i<N+1;i++){
    cin>>h[i];
  }
  int dp[999999];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<N+1;i++){
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
     for(int j=2;j<K+1;j++){
       if(i-j>=1){
         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
       }
     }
  }
  cout<<dp[N]<<endl;
}
  


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

#define ll long long

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

	set<string> s;

	string x;

	for(int i=0;i<n;i++)
	{
		cin >> x;
		s.insert(x);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 19256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        vector<unsigned long long>vec,v;
        while(n--){
            unsigned long long t;
            cin>>t;
            vec.push_back(t);
        }
        sort(vec.begin(),vec.end());
        unsigned long long tot=0,ans=0;
        for(int i=1;i<vec.size();i++){
            tot+=vec[i-1];
            v.push_back(tot);
        }
        for(int i=0;i<v.size();i++){
            ans+=v[i];
        }
        cout<<ans<<endl;
    }
}

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

#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
                                           	
const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;
const ll INF = 1e18;

int dp[N][5], a[N], b[N], c[N];

int main() {
	cin.tie(0);  	
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	for (int i = 2; i <= n; i++) {
		dp[i][1] = a[i] + max(dp[i - 1][2], dp[i - 1][3]);
		dp[i][2] = b[i] + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = c[i] + max(dp[i - 1][1], dp[i - 1][2]);
	}
	cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
	return 0;
}                                                

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

using namespace std;

const int   N   = 4e3 + 1;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if(a >= mod)a -= mod;
    if(a < 0)   a += mod;
}

int f[N][N];
int g[N][N];

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

    int n, m, k;

    cin >> n >> m >> k;

    f[0][0] = 1;

    for(int i = 1 ; i < n + m ; ++i)
        for(int j = 0 ; j <= n ; ++j)   {
            g[i][j] = (j ? g[i][j - 1] : 0);
            add(g[i][j],f[i - 1][j]);
            f[i][j] = g[i][j];
            if(j >= k)  add(f[i][j],-g[i][j - k]);
        }

    int ans = 0;

    while(n > 0)    {
        add(ans,f[(n + m - 1) / (k - 1)][n]);
        n -= k - 1;
    }

    cout << ans << endl;
}


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

int main(){
  int a,b,c,d,e[110],f[110];
    cin>>a>>b>>c>>d;
 
  for(int i=0;i<a;i++)
    cin >> e[i];
  for(int i=0;i<b;i++)
    cin >>f[i];
  
  sort(e,e+a,greater<int>());
  sort(f,f+b);
  
  for(int g=-100;g<=100;g++){
  if((c<g)&&(g<=d)&&(e[0] <g)&&(f[0] >=g)){
    cout << "No War" << endl;
    
    return 0;
  }
     }
     cout <<"War" <<endl;
     
     return 0;
     }


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

int main() {

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

    int ans = (3 * A + P) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>
int N, M, a[100001], b[100001];
int main()
{
	scanf("%d%d", &N, &M);
	a[1] = 1;
	std::fill(b + 1, b + N + 1, 1);
	while (M--)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		if (a[u] == 1)
		{
			if (b[u] == 1)
				a[u] = 0;
			a[v] = 1;
		}
		b[u]--;
		b[v]++;
	}
	printf("%d\n", int(std::count(a + 1, a + N + 1, 1)));
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n;
int v[MAX];

void solve() {
	cin >> n;
	int x=0;
	for(int i=0; i<n; i++) {
		cin >> v[i];
		x ^= v[i];
	}
	for(int i=0; i<n; i++) {
		cout << (x^v[i]) << " ";
	}
	cout << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 4376
N,K = map(int, input().split())
S = input()
newS = ''
for i in range(N):
  if i == K-1:
    if S[i] == 'A':
      newS += 'a'
    if S[i] == 'B':
      newS += 'b'
    if S[i] == 'C':
      newS += 'c'
  else:
    newS += '{}'.format(S[i])

print(newS)

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  ll sum[n+10]={};
  for(int i=1;i<=n;i++){
    cin>>sum[i];
    sum[i]+=sum[i-1];
  }
  ll ans=llINF;
  for(int i=1;i<n;i++){
    // cout<<sum[i]<<" ";
    ans=min(ans,abs(sum[n]-2*sum[i]));
  }
  //cout<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n;
    int a[15];
    int x[15][15];
    int y[15][15];
    int f[15];
    cin>>n;
    REP(i,n){
        cin>>a[i];
        REP(j,a[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ma=0;
    REP(i,1<<n){
        REP(j,n)f[j]=(i>>j)&1;
        // REP(j,n)cout<<f[j]<<" ";cout<<endl;
        bool ok=true;
        REP(j,n){
            if(f[j]==0)continue;
            REP(k,a[j]){
                if(f[x[j][k]]!=y[j][k])ok=false;
            }
        }
        // cout<<ok<<endl;
        int cnt=0;
        if(ok)REP(j,n)if(f[j])cnt++;
        ma=max(ma,cnt);
    }
    cout<<ma<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int W = 1e9;
int n, c, v[105];
long long w[105], mem[105][N];
bool vis[105][N];

long long dp(int idx, int val) {
	if (val <= 0) {
		return 0;
	}
	if (idx == n) {
		return W + 1;
	}
	if (vis[idx][val]) {
		return mem[idx][val];
	}
	vis[idx][val] = true;

	long long ans = dp(idx + 1, val);
	ans = min(ans, w[idx] + dp(idx + 1, val - v[idx]));

	return mem[idx][val] = ans;
}

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

	cin >> n >> c;

	int V = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		V += v[i];
	}

	int ans = 0;
	for (int i = 0; i <= V; i++) {
		if (dp(0, i) > c) continue;
		ans = i;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 90496
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    string S[60];
    int T[60];
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>S[i]>>T[i];
        sum+=T[i];
    }
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=T[i];
        if(s==S[i]) break;
    }
    cout<<sum-ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0;
  cin >>a>>b>>c>>d;
  for(int n=0;n<a;n++) cin >>i[n];
  for(int n=0;n<b;n++) cin >>u[n];
  sort(u,u+b);
  sort(i,i+a,greater<long long>());
  c=max(c,i[0]);
  d=min(d,u[0]);
  if(c<d) cout <<"No War\n";
  else cout <<"War\n";
  return (0);
}


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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: [i64; 3],
    }
    let sum = a.iter().sum::<i64>();
    let ans = if sum >= 22 { "bust" } else { "win" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    answer = 0
    last = 0
    for _ in range(N):
        a = read_int()
        if a != 0:
            answer += (last+a)//2
            last = (last+a)%2
        else:
            last = 0
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 74568
#include <iostream>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int i, j, k, l, m, n;
int H, W, N, Q;
int a, b, c;



unsigned long long Comb(int n, int k)
{
	int i;
	unsigned long long c=1;
	for(i=0;i<k;i++)
	{
		c = c*(n - i) / (1 + i);
	}
	return c;
}

int main()
{
	int P;
	cin >> N >> P;
	int odd = 0, even = 0;
	for (i = 0; i < N; i++)
	{
		cin >> a;
		if (a & 1)
		{
			odd++;
		}
		else
		{
			even++;
		}
	}
	unsigned long long pow2 = (1ULL << even);//偶数の袋は選択どちらでもよい
	unsigned long long select=0;
	unsigned long long comb;
	if (P)
	{
		comb = odd;
		j = 1;
	}
	else
	{
		comb = 1;
		j = 0;
	}
	for (i = P; i <= odd; i += 2)
	{
		select += comb;
		comb = comb*(odd - j) / (1 + j);
		comb = comb*(odd - j - 1) / (2 + j);
		j += 2;
	}
	cout << select*pow2 << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> leftb;
    vector<int> rightb;

    rep(i,n) {
        if(i % 2 == 0) {
            rightb.push_back(a[i]);
        }else {
            leftb.push_back(a[i]);
        }
    }
    vector<int> yesreverse;
    vector<int> notreverse;

    if(n % 2 == 0) {
        yesreverse = leftb;
        notreverse = rightb;
    }else {
        yesreverse = rightb;
        notreverse = leftb;
    }

    reverse(yesreverse.begin(), yesreverse.end());
    for(auto v : yesreverse) {
        cout << v  << " ";
    }
    for(auto v : notreverse) {
        cout << v  << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4724
N = gets.to_i

NN = 55555
prime = [true] * (NN+1)
prime[0] = prime[1] = false

for i in 2..(NN**0.5)
  next unless prime[i]
  (i+i).step(NN, i).each do |ii|
    prime[ii] = false
  end
end

primes = prime.map.with_index.select {|a, i| a }.map {|a, i| i }
primes1 = primes.select {|i| i%10==1 }
puts primes1.take(N).join(' ')


Measured memory_bytes: 3068
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  static Scanner in;
  static PrintWriter out;
  static String INPUT = "";

  static void solve() {
    String s = in.nextLine();

    System.out.println(s.replace("?", "D"));
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  static int ni() {
    return Integer.parseInt(in.next());
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty()) System.out.println(Arrays.deepToString(o));
  }
}


Measured memory_bytes: 42392
let popcnt x =
  let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in
  let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in
  let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in
  let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in
  let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in
  (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d\n%s" @@ fun n x ->
  let x = Array.init n @@ String.get x in
  let dp = Array.make (n + 2) 0 in
  for i = 1 to n + 1 do
    dp.(i) <- 1 + dp.(i mod popcnt i)
  done;
  let pop = Array.fold_right (function '0' -> Fun.id | '1' -> succ) x 0 in
  let m0 = Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop + 1)) 0 x in
  let m1 =
    if pop = 1
    then 0
    else Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop - 1)) 0 x in
  Fun.flip Array.iteri x @@ fun i c ->
    let i = n - i - 1 in
    Printf.printf "%d\n" @@
    if c = '0'
    then 1 + dp.((m0 + power (fun x y -> (x * y) mod (pop + 1)) 1 2 i) mod (pop + 1))
    else if pop = 1
    then 0
    else 1 + dp.((m1 + pop - 1 - power (fun x y -> (x * y) mod (pop - 1)) 1 2 i) mod (pop - 1))

Measured memory_bytes: 9908
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 2005;

int n, m, a[MAXN][MAXN], Q, s1[MAXN][MAXN], s2[MAXN][MAXN], s3[MAXN][MAXN];
char ch[MAXN];

inline int solve(int x, int y)
{
	if( !x || !y ) return 0;
	return s3[ x ][ y ] - s1[ x - 1 ][ y ] - s2[ x ][ y - 1 ];
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read(), m = read(), Q = read();
	for( int i = 1 ; i <= n ; i++ )
	{
		scanf( "%s", ch + 1 );
		for( int j = 1 ; j <= m ; j++ ) a[ i ][ j ] = ch[ j ] - '0';
	}
	for( int i = 1 ; i < n ; i++ )
		for( int j = 1 ; j <= m ; j++ )
		{
			if( a[ i ][ j ] && a[ i + 1 ][ j ] ) s1[ i ][ j ]++;
			s1[ i ][ j ] += s1[ i ][ j - 1 ] + s1[ i - 1 ][ j ] - s1[ i - 1 ][ j - 1 ];
		}
	for( int i = 1 ; i <= n ; i++ )
		for( int j = 1 ; j < m ; j++ )
		{
			if( a[ i ][ j ] && a[ i ][ j + 1 ] ) s2[ i ][ j ]++;
			s2[ i ][ j ] += s2[ i ][ j - 1 ] + s2[ i - 1 ][ j ] - s2[ i - 1 ][ j - 1 ];
		}
	for( int i = 1 ; i <= n ; i++ )
		for( int j = 1 ; j <= m ; j++ )
			s3[ i ][ j ] = a[ i ][ j ] + s3[ i - 1 ][ j ] + s3[ i ][ j - 1 ] - s3[ i - 1 ][ j - 1 ];
	while( Q-- )
	{
		int x1 = read(), y1 = read(), x2 = read(), y2 = read();
		int ret = s3[ x2 ][ y2 ] - s3[ x1 - 1 ][ y2 ] - s3[ x2 ][ y1 - 1 ] + s3[ x1 - 1 ][ y1 - 1 ];
		ret -= s1[ x2 - 1 ][ y2 ] - s1[ x1 - 1 ][ y2 ] - s1[ x2 - 1 ][ y1 - 1 ] + s1[ x1 - 1 ][ y1 - 1 ];
		ret -= s2[ x2 ][ y2 - 1 ] - s2[ x1 - 1 ][ y2 - 1 ] - s2[ x2 ][ y1 - 1 ] + s2[ x1 - 1 ][ y1 - 1 ];
		printf( "%d\n", ret );
	}
}


Measured memory_bytes: 64640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long xx[N];
	long long yy[N];
	long long a[N];
	bool b[40];
	long long c[40];
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	x = MOD - 2;
	f(i, 40) {
		if (x % 2 == 1)b[i] = true;
		else b[i] = false;
		x = x / 2;
	}
	f(i, N) {
		c[0] = i;
		f(j, 39)c[j + 1] = (c[j] * c[j]) % MOD;
		y = 1;
		f(j, 40)if (b[j])y = (y*c[j]) % MOD;
		a[i] = y;
	}

	scanf("%lld", &n);
	f(i, n) {
		scanf("%lld", &xx[i]);
	}
	f(i, n - 1)yy[i] = xx[i + 1] - xx[i];
	z = 1;
	f(i, n - 1)z = (z*(i + 1)) % MOD;
	f(i, n + 1)a[i] = (a[i] * z) % MOD;
	s = 0;
	f(i, n - 1) {
		s = (s + a[i + 1]) % MOD;
		ans = (ans + (s*yy[i])) % MOD;
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		
		
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		long a[]=new long[n];
		long c=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextLong();
			while(a[i]%2==0) {
				c++;
				a[i]=a[i]/2;
			}
		}
		System.out.println(c);
	
	
	
	
	}
	
}





Measured memory_bytes: 34576
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
void solve()
{
    ll k;cin>>k;
    ll a,b;cin>>a>>b;
    for(ll i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;return;
        }
    }
    cout<<"NG"<<endl;return;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 3652
n = int(input())
p_list = list(map(int, input().split()))

count = 0
for i in range(n-2):
    p0 = p_list[i]
    p1 = p_list[i+1]
    p2 = p_list[i+2]
    if (p0 < p1 and p1 < p2) or (p0 > p1 and p1 > p2):
        count += 1

print (count)

Measured memory_bytes: 3060