akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var x int

func main() {
	tmp := NextIntsLine()
	x = tmp[0]
	if x < 1200 {
		fmt.Println("ABC")
	} else {
		fmt.Println("ARC")
	}
}


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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;

  int minimun = 1000;
  minimun = min(minimun, P + Q);
  minimun = min(minimun, Q + R);
  minimun = min(minimun, R + P);

  cout << minimun << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int a[maxn];
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int i = 0;
	while(i + 1 < n && a[i + 1] >= i + 2) i++;
	int l = 0, r = 0;
	for(int j = i + 1; j < n; j++) if(a[j] >= i + 1) r++;
	l = a[i] - i - 1;
	if((l % 2) != (r % 2)) cout << "First" << endl;
	else if(l % 2) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}


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

int main() {
  long long n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> a(n);
  long long nowat = n, cnt = 0;
  while (nowat != 0) {
    for (int i = m; i >= 1; i--) {
      if (nowat - i >= 0 && s.at(nowat - i) == '0') {
        nowat -= i;
        a.at(cnt) = i;
        break;
      }
      if (i == 1) {
        cout << -1 << endl;
        return 0;
      }
    }
    cnt++;
  }
  while (a.at(a.size() - 1) == 0) a.pop_back();
  for (int i = 0; i < a.size() - 1; i++)
    cout << a.at(a.size() - 1 - i) << " ";
  cout << a.at(0) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

ll P;
int length;
char s[100001];
bool zeroDiv;

ll inverse(ll a){
    ll res = 1ll;
    int n = P-2;
    while(n > 0){
        if(n & 1){res = (res * a) % P;}
        a = (a*a) % P;
        n >>= 1;
    }

    return res;
}

// expr: term+term, term-term
// term: factor*factor, factor/factor
// factor: (expr), number
// number: [0-9]+

ll Expr(int& index);

ll Number(int& index){
    if(zeroDiv){return -1;}

    ll res = 0ll;
    while(index < length && std::isdigit(s[index])){
        res = res * 10 + s[index] - '0';
        index += 1;
    }

    return res;
}

ll Factor(int& index){
    if(zeroDiv){return -1;}

    ll res;

    if(s[index] == '('){
        index += 1;
        res = Expr(index);
        index += 1;
    }else{
        res = Number(index);
    }

    return res;
}

ll Term(int& index){
    if(zeroDiv){return -1;}

    ll res = Factor(index);

    for(;index<length;){
        if(s[index] == '*'){
            index += 1;
            res = (res * Factor(index)) % P;
        }else if(s[index] == '/'){
            index += 1;
            ll second = Factor(index);
            if(second == 0){zeroDiv = true; return -1;}
            res = (res * inverse(second)) % P;
        }else{
            break;
        }
    }

    return res;
}

ll Expr(int& index){
    if(zeroDiv){return -1;}

    ll res = Term(index);
    
    for(;index<length;){
        if(s[index] == '+'){
            index += 1;
            res = (res + Term(index)) % P;
        }else if(s[index] == '-'){
            index += 1;
            res = ((res - Term(index)) % P + P) % P;
        }else{
            break;
        }
    }

    return res;
}


int main(){
    while(true){
        P = 0;
        length = 0;
        zeroDiv = false;

        char c;
        while((c = getchar()) != '\n'){
            if(std::isspace(c)){continue;}

            s[length++] = c;
        }
        s[length] = '\0';

        if(s[0] == '0'){break;}
    
        int i = 0;
        while(s[i] != ':'){
            P = P * 10 + s[i] - '0';
            i += 1;
        }

        int j = i + 1;
        ll res = Expr(j);
        if(zeroDiv){
            puts("NG");
        }else{
            FOR(k, i+1, length){
                putchar(s[k]);
            }
            printf(" = %lld (mod %lld)\n", res, P);
        }
    }
}

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

using namespace std;

const int MAX_N = 100000;

int n, a, b, x[MAX_N + 1];

long long ans = 0;

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

    cin >> n >> a >> b;

    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }

    for (int i = 2; i <= n; i++) {
        ans += min((long long)(b), (long long)(a) * (long long)(x[i] - x[i - 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, v[100], c[100], sumx=0, sumy=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int k=0; k<n; k++){
        cin >> c[k];
    }
    
    for(int j=0; j<n; j++){
        if(v[j] > c[j]){
            sumx += v[j];
            sumy += c[j];
        }
    }
    cout << sumx - sumy << endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
ans = 0    
for i in range(n):
    ans = max(uf.size(i), ans)
print(ans)        

Measured memory_bytes: 14424
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x, k, d := scanInt(), scanInt(), scanInt()
	if (abs(x)+d-1)/d <= k {
		t := k - abs(x)/d
		if t%2 == 0 {
			fmt.Fprintln(wr, abs(x%d))
		} else {
			fmt.Fprintln(wr, abs(abs(x%d)-d))
		}
	} else {
		fmt.Fprintln(wr, abs(x)-d*k)
	}
}


Measured memory_bytes: 1780
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    string s;
    int k;
    cin >> s >> k;

    string t = s, u = s;
    int tcount = 0, ucount = 0;

    int n = s.size();
    int count = 1;
    int sum = 0;

    for(int i = 0;i < n-1;i ++){
        if(s.at(i) == s.at(i+1)){
            count ++;
        }else{
            sum += count / 2;
            count = 1;
        }
        if(i == n-2) sum += count / 2;
    }

    if(count == n){
        cout << (n * k) / 2 << endl;;
        return 0;
    }

    if(s.at(0) != s.at(n-1)){
        cout << sum * k << endl;
        return 0;
    }

    int countf = 1,countl = 1;
    
    for(int i = 0;;i ++){
        if(s.at(i) == s.at(i+1)){
            countf ++;
        }else{
            break;
        }
    }
    for(int i = n-1;;i --){
        if(s.at(i) == s.at(i-1)){
            countl ++;
        }else{
            break;
        }
    }

    cout << sum * k - ((countf / 2) +  (countl / 2) - ((countf + countl) / 2)) * (k-1) << endl;
}

Measured memory_bytes: 256
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k] or li[-1] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    
    vector<int> L(50), R(50);
    L[0] = 0; R[0] = 1;
    
    int digit = 1;
    
    for(int i = 1; i<50; i++){
        if(L[i-1] <= n && n <= R[i-1]){
            digit = i-1;
            break;
        }
        L[i] = L[i-1] + min(0, (signed)pow(-2,i));
        R[i] = R[i-1] + max(0, (signed)pow(-2,i));
    }
    
    string ans = "";
    for(int i = digit; i>=0; i--){
        int prev = n - pow(-2,i);
        if(L[i] <= prev && prev <= R[i]){
            ans += '1';
            n = prev;
        }else{
            ans += '0';
        }
    }
    
    cout << ans << endl;
}

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

int main() {
  
  int n,k,x,a=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x<k-x)a+= 2*x;
    else a += 2*(k-x);
  }
  cout << a << endl; 
      
}


Measured memory_bytes: 256
import itertools
n = int(input())
p = [int(x) for x in input().split()]
a  = sorted(p)
q = [int(x) for x in input().split()]
cntp = 0
cntq = 0
cnt=0
for i in itertools.permutations(a):
  cnt+=1
  if p==list(i):
    cntp=cnt
  if q==list(i):
    cntq = cnt
print(abs(cntp-cntq))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
unordered_map<string,int>Q;
int main()
{
    int n ; cin >> n;
    string a;
    for (int i = 1 ; i <= n ; i++) cin >> a , Q[a]++;
    cout << "AC x " << Q["AC"] << endl;
    cout << "WA x " << Q["WA"] << endl;
    cout << "TLE x " << Q["TLE"] << endl;
    cout << "RE x " << Q["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<utility>
#include<queue>
#include<stdio.h>
//#include<sys/time.h>
#include<random>
#include<fstream>
#define INF 2000000000
using namespace std;
typedef std::pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
int n,ans,cnt;
signed main(){
	cin>>n;
	for(int i=1;i<n;i++){
		ans+=n/i;
		if(n%i==0)ans--;
	}
	cout<<ans<<endl;
}


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

using namespace std;


using namespace std;



const double PI = asinl(1) * 2;
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) :x(x),y(y){}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double k) {return Point(x*k,y*k);}
  Point operator / (double k) {return Point(x/k,y/k);}
  double norm(){return x*x+y*y;}
  double abs(){return sqrt(norm());}

  bool operator < (const Point &p) const{
    return x!=p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < (1e-10) && fabs(y-p.y) < (1e-10);
  }
};
typedef Point Vector;
typedef vector<Point> Polygon;

struct Segment{
  Point p1,p2;
  Segment(){}
  Segment(Point p1, Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

struct Circle{
  Point c;
  double r;
  Circle(Point c,double r):c(c),r(r){}
};

double norm(Vector a){
  return a.x*a.x+a.y*a.y;
}
double abs(Vector a){
  return sqrt(norm(a));
}
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Vector a,Vector b){
  return (fabs((dot(a,b))-(0.0)) < (1e-10));
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
  return (fabs((dot(s1.p2-s1.p1,s2.p2-s2.p1))-(0.0)) < (1e-10));
}

bool isParallel(Vector a,Vector b){
  return (fabs((cross(a,b))-(0.0)) < (1e-10));
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
  return (fabs((cross(s1.p2-s1.p1,s2.p2-s2.p1))-(0.0)) < (1e-10));
}

Point project(Segment s,Point p){
  Vector base = s.p2 - s.p1;
  double r = dot(p-s.p1,base)/norm(base);
  return s.p1 + base * r;
}

int main(){
    Point p1,p2;
    Segment s;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    s = Segment(p1,p2);
    int q;cin >> q;
    for(int i=0;i<q;i++){
        Point t;
        cin >> t.x >> t.y;
        cout << fixed << setprecision(8) << project(s,t).x << " " << fixed << setprecision(8) << project(s,t).y << endl;
    }
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b, num, now, deep[100010];
vector <int> v[100010];
void dfs(int x)
{
	if (deep[x] != -1)return ;
	for (int i = 0; i < v[x].size(); ++i)dfs(v[x][i]);
	deep[x] = now++;
}
int main()
{
	memset(deep, -1, sizeof(deep));
	cin >> n >> m;
	for (int i = 1; i <= n - 1 + m; ++i){
		cin >> a >> b;
		v[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i){
		dfs(i);
	}
	for (int i = 1; i <= n; ++i){
		if (v[i].size() == 0)cout << 0 << endl;
		else{
			int s = v[i][0];
			for (int j = 0; j < v[i].size(); ++j){
				if (deep[s] < deep[v[i][j]])s = v[i][j];
			}
			cout << s << endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main(){
    int t;
    cin >> t;
    rep(i, t){
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << endl;
    } 
}

Measured memory_bytes: 3632
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let s = cin.next();
    let t = cin.next();
    let s = s.as_bytes();
    let t = t.as_bytes();

    if s.len() < t.len() {
        println!("UNRESTORABLE");
        return;
    }

    let mut ans = String::new();
    for _ in 0..s.len() {
        ans += "~"
    }

    for i in 0..(s.len()-t.len()+1) {
        let mut ok = true;
        let mut cur = Vec::new();
        for j in 0..s.len() {
            if j >= i && j < i + t.len() {
                cur.push(t[j-i])
            } else {
                cur.push(s[j])
            }
            ok &= s[j] == b'?' || s[j] == cur[j]
        }
        let cur = String::from_utf8(cur).unwrap();
        let cur = cur.replace("?", "a");
        if ok && ans > cur {
            ans = cur
        }
    }

    if ans.chars().nth(0) == Some('~') {
        println!("UNRESTORABLE")
    } else {
        println!("{}", ans)
    }
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include <iostream>

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) {
        return false;
    }

    for (int i = 2; i * i <= num; i += 1) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

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

    for (int i = 6; n > 0; i += 5) {
        if (IsPrime(i)) {
            cout << i << " ";
            n -= 1;
        }
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
n,b,f[50001];main(a){for(;++a<5e4;)for(b=a;!f[a]&&b+a<5e4;)f[b+=a]=1;for(;~scanf("%d",&n);n&&printf("%d\n",b))for(b=0,a=1;a++<n/2;)f[a]+f[n-a]||b++;}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <cstdlib> 
#include <cmath>
#include <vector>
#include <set>
using namespace std;
int main(void)
{
    int N;
    cin >> N;
    int temp;
    int ans = 1;
    int kaisu = 0;
    for(int i=2;i<=32;i++){
        temp = i;
        kaisu = 0;
        while(temp <=1000){
            if(kaisu == 1 && temp <= N && temp > ans){
                ans = temp;
            }
            temp = temp * i;
            kaisu = 1;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    cout << (n+1) / 2 << endl;
    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int a[N] , sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int count = 0;
    double lim = (double)sum/(4*M);
    for (int i = 0; i < N; i++) {
        if (lim <= a[i]) count++;
        if (count >= M) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll x, a;
  cin >> x >> a;
  if(x<a){
    cout << 0 << endl;
  }
  else{
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		Arrays.setAll(s, i -> sc.next());
		
		int p = 0;
		while (s[p].length() > 0) {
			int np = s[p].charAt(0) - 'a';
			s[p] = s[p].substring(1);
			p = np;
		}
		
		System.out.println((char) ('A' + p));
		
		sc.close();
	}
}




Measured memory_bytes: 32188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DArrangement {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      if (n==2) {
        cout << -1 << endl;
        return;
      }

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

      set<int> st;
      for(int i=1; i<=n; i++) {
        st.insert(i);
      }

      priority_queue<P> que;
      for(int i=1; i<=n; i++) {
        que.emplace(cnt[i], i);
      }

      vector<int> b(n);
      for(int i=0; i<n-3; i++) {
        auto it = st.begin();
        if (i > 0 && a[b[i-1]] == *it) ++it;
        b[i] = *it;

        while (que.top().first >= n-1-i) {
          if (st.find(que.top().second) == st.end()) {
            // already removed
            que.pop();
            continue;
          } else if (que.top().first != cnt[que.top().second]) {
            // update
            que.pop();
            que.emplace(cnt[que.top().second], que.top().second);
            continue;
          }
          b[i] = que.top().second;
          que.pop();
          break;
        }

        st.erase(b[i]);
        cnt[a[b[i]]]--;
      }

      // brute-force search
      vector<int> vec;
      for(auto e: st) {
        vec.push_back(e);
      }

      do {
        b[n-3] = vec[0];
        b[n-2] = vec[1];
        b[n-1] = vec[2];
        if (a[b[n-4]] != b[n-3] && a[b[n-3]] != b[n-2] && a[b[n-2]] != b[n-1]) {
          for(auto e: b) {
            cout << e << ' ';
          }
          cout << endl;
          return;
        }
      } while (next_permutation(all(vec)));
    }
};

signed main() {
  DArrangement solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> A >> B >> C >> X >> Y;
	if (2 * C > A + B) {
		ans = A * X + B * Y;
	}
	else {
		if (X > Y) {
			if (2 * C > A)ans = 2 * C * Y + A * (X - Y);
			else ans = 2 * C * X;
		}
		else {
			if (2 * C > B)ans = 2 * C*X + B * (Y - X);
			else ans = 2 * C*Y;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct Starry_Sky_Tree
{
	int data[(1<<19)-1],datb[(1<<19)-1];//data:add,datb:max
	Starry_Sky_Tree()
	{
		memset(data,0,sizeof(data));
		memset(datb,0,sizeof(datb));
	}
	void update(int a,int b,int x,int k,int l,int r)
	{
		if(a>=r||l>=b)return;
		else if(a<=l&&r<=b)
		{
			data[k]+=x;
			while(k>0)
			{
				k=(k-1)/2;
				datb[k]=max(data[k*2+1]+datb[k*2+1],data[k*2+2]+datb[k*2+2]);
			}
		}
		else
		{
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
		}
	}
	int query(int a,int b,int k,int l,int r)
	{
		if(a>=r||l>=b)return 0;
		if(a<=l&&r<=b)return data[k]+datb[k];
		else return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r))+data[k];
	}
};
Starry_Sky_Tree sst;
P a[100000];
int N,H;
int main()
{
	cin >> N >> H;
	for(int i=0;i<N-1;i++)cin >> a[i].fi >> a[i].sec;
	priority_queue<P> q;//fi num,sec index
	int now=H;
	ll ans=0ll;
	for(int i=0;i<N-1;i++)
	{
		sst.update(i,i+1,now,0,0,1<<18);
		now-=a[i].fi;
		q.push(P(a[i].sec,i));
		while(now<=0)
		{
			//loop:;
			P m=q.top();
			q.pop();
			int mx=sst.query(m.sec,i+1,0,0,1<<18);
			if(mx+m.fi>H)
			{
				m.fi=H-mx;
				q.push(m);
				//goto loop;
				continue;
			}
			int num=min((-now)/m.fi+1,(H-mx)/m.fi);
			ans+=(ll)num;
			now+=num*m.fi;
			sst.update(m.sec,i+1,num*m.fi,0,0,1<<18);
			q.push(m);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6936
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 2e9, mod = 1e9 + 7;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    string s, t; cin >> s >> t;
    vi pres(s.size()+1), pret(t.size()+1);
    pres[0] = pret[0] = 0;
    for(int i=0;i<s.size();i++) pres[i+1] = (pres[i] + (1 + s[i] - 'A')) % 3;
    for(int i=0;i<t.size();i++) pret[i+1] = (pret[i] + (1 + t[i] - 'A')) % 3;
    int q; cin >> q;
    for(int a ,b,c,d;q--;){
        cin >> a >> b >> c >> d;
        if((pres[b] - pres[a - 1] + 3) % 3 == (pret[d] - pret[c - 1] + 3) % 3) cout <<"YES";
        else cout <<"NO";
        cout <<'\n';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2512
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int a, b;
	cin >> a >> b;
	string s1, s2;
	for (int i = 0; i < a; i++)
		s1 += char(b + '0');
	for (int i = 0; i < b; i ++)
		s2 += char(a + '0');
	cout << (s1 < s2 ? s1 : s2);

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

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

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int n;
    cin>>n;
    int fp=n/100;
    int sp=n%100;
    if(fp>=1 && fp<=12){
        if(sp>=1 && sp<=12) cout<<"AMBIGUOUS";
        else cout<<"MMYY";
    }
    else{
        if(sp>=1 && sp<=12) cout<<"YYMM";
        else cout<<"NA";
    }
    return 0;
}

Measured memory_bytes: 3644
/////////////////////    答案    /////////////// 
/*
注意点：
1. 
*/
//----------------------自打1------------------ 

#include<iostream>
using namespace std;
int c[10010],a[2000005],b[2000005];
int main(){
	int n,k=10010;
	cin>>n;
	for(int i=0;i<k;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=0;i<k;++i){
		c[i]+=c[i-1];
	}
	for(int i=n-1;i>=0;--i){				//1.for n-1 to 0 保证了稳定性 
		b[c[a[i]]]=a[i];
		c[a[i]]--;
	}
	for(int i=1;i<=n;++i){
		cout<<b[i]<<" \n"[i==n];
	}
	return 0;
}


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

using namespace std;
// Problem:0023
int main()
{
	int n; double ax, ay, ar, bx, by, br, d, rPlus, rMinus;
	cin >> n;
	
	for (int i=0; i<n; i++) {
		cin >> ax >> ay >> ar >> bx >> by >> br;
		d = (ax - bx)*(ax - bx) + (ay - by)*(ay - by);
		rPlus = (ar + br)*(ar + br);
		rMinus = (ar - br)*(ar - br);
		
		if (d > rPlus)
			cout << 0 << endl;
		else if (rPlus > d && d > rMinus)
			cout << 1 << endl;
		else if (d < rMinus)
			cout << (ar>br ? 2 : -2 )<< endl;
		else
			cout << 1 << endl;
	}
	return 0;
}

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

int main(){
	int N;string S;
	cin >> S ;
	N = S.size();
  	int ans = N, len;
	for(int i = 0;i < N-1;i++){
		if(S[i]!=S[i+1]){
			len = max(i+1,N-i-1);
			ans = min(ans,len);
		}
  	}
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
string S;
cin >> S;
int a = 0;
for (int i = 0; i < S.size(); i++){
if (S[i] == '1') {a++;}
}
cout << a << endl;
}

  


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split())) 
b = list(map(int, input().split()))
c = list(map(int, input().split()))
now = a[0]
ans = sum(b)
for i in a[1:]:
  if i == now + 1:
    ans += c[now - 1]
  now = i
print(ans)

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

int main()
{
    int n,i,j,mt=-9999;
    cin>>n;
    int r1[n];
    int r2[n];
    for(i=0;i<n;i++) cin>>r1[i];
    for(i=0;i<n;i++) cin>>r2[i];
    for(j=0;j<n;j++)
    {
        //int cn=r1[0];
        int cn=0;
        for(i=0;i<n;i++)
        {
            if(i==j) cn=cn+r1[i]+r2[i];
            else if(i>j) cn+=r2[i];
            else cn+=r1[i];
        }
        //cout<<cn<<"\n";
        mt=max(mt,cn);
    }
    cout<<mt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;
typedef vector<int> Vec;
typedef vector<Vec> Mat;

int N, M;
int mod = 998244353;

int Gauss(Mat& A) {
    int rank = 0;

    REP(j, M) {
        int pivot = -1;
        FOR(i, rank, N - 1) {
            if (A[i][j] == 1) {
                pivot = i;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[rank], A[pivot]);
        REP(i, N) {
            if (i == rank) continue;
            if (A[i][j] == 0) continue;
            REP(k, M) {
                A[i][k] ^= A[rank][k];
            }
        }
        ++rank;
    }
    return rank;
}

int binpow(int x, int p) {
    if (p == 0) return 1;

    if (p % 2 == 0)
        return binpow((x * x) % mod, p / 2);
    else
        return (x * binpow(x, p - 1)) % mod;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N >> M;

    Mat A(N, Vec(M));
    REP(i, N) REP(j, M) cin >> A[i][j];

    int rank = Gauss(A);
    cout << (binpow(2, N + M - 1) - binpow(2, N + M - rank - 1) + mod) % mod << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{

    static long M=(long)1e9+7;
    
    public static int recur(int []arrr,int n){
    	if(n<=0){
    		return 0;
    	}
    	return recur(arrr,n-1)+arrr[n-1];
    }
    
    public static void main(String[] args) {
        FastReader fs=new FastReader();
        int n=fs.nextInt();
        int [][]arr=new int[n][3];
        for(int i=0;i<n;i++){
        	arr[i][0]=fs.nextInt();
        	arr[i][1]=fs.nextInt();
        	arr[i][2]=fs.nextInt();
        }
        int [][]dp=new int[n][3];
        dp[0][0]=arr[0][0];
        dp[0][1]=arr[0][1];
        dp[0][2]=arr[0][2];
        for(int i=1;i<n;i++){
        	for(int j=0;j<3;j++){
        		int m=0;
        		for(int k=0;k<3;k++){
        			if(k!=j){
        				m=Math.max(dp[i-1][k],m);
        			}
        		}
        		dp[i][j]=m+arr[i][j];
        	}
        }
        int a=Math.max(dp[n-1][0],dp[n-1][1]);
        a=Math.max(a,dp[n-1][2]);
        System.out.println(a);
    }
    
    public static long inv(long a, long mod){
        return pow(a, mod-2,mod);
    }
    public static long mul(long a,long b,long mod){
        long res=0;
        while(b!=0){
            if ((b & 1) == 1){ res = (res + a) % mod;}
            a = (a + a) % mod;
            b >>= 1;
        }
        return res;
    }
    
    public static long pow(long a, long n, long mod){
        long res=1;
        while(n != 0){
            if ((n & 1) == 1) res = mul(res, a, mod)%mod;
            a = mul(a , a, mod)%mod;
            n >>= 1;
        }
        return res;
    }
    
    public static long gcd(long a, long b){
        if(a == 0) return b;
        return b == 0 ? a: gcd(b, a % b);
    }

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 49476
#include<bits/stdc++.h>
using namespace std;
double a[50+5];

int main(){
	int n;
	double sum=0;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	sum = (a[0]+a[1])/2;
	for(int i=2;i<n;i++)
		sum =(sum+a[i])/2;
	cout << sum << endl;
	return 0;
}

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


int main() {
  int N;
  bool is_ok = false;
  cin >> N;
  vector<int> t(110000), x(110000, 0), y(110000, 0);
  repeat(i, N) {
    cin >> t[i] >> x[i] >> y[i];
  }
  
  for(int i = 0; i < N; i++) {
    is_ok = (t[i] % 2) == ((x[i] + y[i]) % 2) ? true : false;
    if (t[i] < (x[i] + y[i])) { is_ok = false; }
    if (!is_ok) break;
  }
  cout << (is_ok ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;

int n, k;
int a;
int ans;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d%d", &n, &k);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a);

		if (a == 1) {
			int ans1, ans2;
			int pos, last, moves;

			pos = i;
			moves = ceil((double)(pos - 1) / (k - 1));
			last = (k - 1) * moves + 1;
			ans1 = moves;
			moves = ceil((double)(n - last) / (k - 1));
			ans1 += moves;
			
			pos = (n + 1) - pos;
			moves = ceil((double)(pos - 1) / (k - 1));
			last = (k - 1) * moves + 1;
			ans2 = moves;
			moves = ceil((double)(n - last) / (k - 1));
			ans2 += moves;

			ans = min(ans1, ans2);
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int n,m[200000],i,j,c,q,p;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&m[i]);
	}
	c=m[0];
	p=m[1]-m[0];
	
	for(i=0; i<n; i++){
		if(m[i]<c){
			c=m[i];
		}
		if(i != n-1){
			q=m[i+1]-c;
			if(q > p){
				p=q;
			}
		}
	}
	
	printf("%d\n",p);
	
	return 0;
}



Measured memory_bytes: 2548
#include <bits/stdc++.h>
typedef long long ll;
const ll p = 1e9 + 7;
const int N = 5e5 + 54;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int n, m;
ll frac[N], inv[N], ans;
inline ll qpow(ll x, ll y, ll ret = 1) { for (; y; x = x * x % p, y >>= 1) if (y & 1) ret = ret * x % p; return ret; }
inline ll C(int x, int y) { 
	if (x > y) return 0;
	else return frac[y] * inv[x] % p * inv[y - x] % p; 
}
inline ll P(int x, int y) {
	if (x > y) return 0;
	else return frac[y] * inv[y - x] % p;
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> n >> m;
    frac[0] = 1;
    for (int i = 1; i <= m; ++i) frac[i] = (ll)frac[i - 1] * i % p;
    inv[m] = qpow(frac[m], p - 2);
    for (int i = m; i; --i) inv[i - 1] = (ll)inv[i] * i % p;
    
    for (int i = 0; i <= n; ++i) {
		if (i & 1) ans = (ans - C(i, n) * P(n - i, m - i) % p + p) % p;
		else ans = (ans + C(i, n) * P(n - i, m - i) % p) % p;
	}
	ans = ans * P(n, m) % p;
    std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11400
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;
    VL ans(n + 1);
    rep(a, 1, 200)
    {
        rep(b, 1, 200)
        {
            rep(c, 1, 200)
            {
                ll x = a * a + b * b + c * c + a * b + b * c + c * a;
                if (x <= n)
                {
                    ans[x]++;
                }
            }
        }
    }
    rep(i, 1, n + 1)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio> 
typedef long long ll;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
const int N=605;
int n,m,col1[N][N],col2[N][N],tag[2][2];
inline void solve(ri d,int col[N][N]){
	ri i,j,k;
	k=0;
	while(d%4==0) d>>=2,++k;
	if(d&1){
		for(i=0;i<m;++i)
			for(j=0;j<m;++j)
				if((i>>k)+(j>>k)&1)
					col[i][j]=1;
	}
	else{
		for(i=0;i<m;++i)
			for(j=0;j<m;++j)
				if((i>>k)&1)
					col[i][j]=1;
	}
}
int main(){
	ri d1,d2,i,j,x,y,cnt;
	gi(n);gi(d1);gi(d2); 
	m=n<<1;
	solve(d1,col1);
	solve(d2,col2);
	for(i=0;i<m;++i)
		for(j=0;j<m;++j)
			++tag[col1[i][j]][col2[i][j]];
	for(i=0;i<=1;++i)
		for(j=0;j<=1;++j)
			if(tag[i][j]>=n*n){
				cnt=0;
				for(x=0;x<m;++x)
					for(y=0;y<m;++y)
						if(col1[x][y]==i&&col2[x][y]==j){
							print(x);putc(' ');print(y);putc('\n');
							if(++cnt==n*n) return 0;
						}
			}
}

Measured memory_bytes: 7040
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

const int MAXM = (int)1e5 + 5;

int x[MAXM];
int y[MAXM];
int z[MAXM];

vector<int> edges[MAXM];
bool vis[MAXM];

void dfs(int i) {
    vis[i] = true;
    for (auto to: edges[i]) {
        if (!vis[to]) {
            dfs(to);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &x[i], &y[i], &z[i]);
        edges[x[i]].push_back(y[i]);
        edges[y[i]].push_back(x[i]);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 10112