akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a, b;
	int h, m;
	cin >> a >> b >> h >> m;

	double ay, ax;
	double by, bx;

	//cout << (2 * (double)h / 12 + (double)2 * m / (60 * 12)) <<endl;
	ax = a * cos(((double)2 * h / 12 + (double)2 * m / (60 * 12)) * M_PI);
	ay = a * sin(((double)2 * h / 12 + (double)2 * m / (60 * 12)) * M_PI);

	bx = b * cos(2 * m* M_PI / 60);
	by = b * sin(2 * m* M_PI / 60);

	//cout << ax << "," << ay << endl;
	//cout << bx << "," << by << endl;

	double dx, dy;

	dx = abs(ax - bx);
	dy = abs(ay - by);
	//cout << dx << "," << dy << endl;

	printf("%.10f\n", sqrt(dx*dx + dy*dy));
}

Measured memory_bytes: 4116
def solve():
    N, M = map(int, input().split())
    k = []
    s = []
    for i in range(M):
        tmp = list(map(int, input().split()))
        tmpk = tmp[0]
        tmps = list(map(lambda x:x-1,tmp[1:]))
        k.append(tmpk)
        s.append(tmps)
    
    p = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set() 
        for j in range(N):
            if (1 << j) & bit:
                on_switches.add(j)
        
        for i in range(M):
            cnt = 0
            for j in range(k[i]):
                if s[i][j] in on_switches:
                    cnt += 1
            
            if cnt % 2 != p[i]:
                break
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    solve()

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

int main(){
	char s[100001];
  vector<bool> c(26,false);
  scanf("%s",s);
  int l=strlen(s);
  for(int i=0;i<l;i++){
  	int tmp=s[i]-'a';
    c[tmp]=true;
  }
  for(int i=0;i<26;i++){
  	if(c[i]==false){
      char ans='a'+i;
    	cout<<ans<<endl;
      	return 0;
    }
  }
  cout<<"None";
}

Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main{
  static int a, b, c;
 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
 
    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();
 
    for(int i = 1; i <= 1000; i++){
      if(a * i % b == c){
        System.out.println("YES");
        return;
      }
    }
    System.out.println("NO");
  }
}

Measured memory_bytes: 23124
import sys

n = int(sys.stdin.readline())

dp = [0 for i in range(n+1)]
cost = list(map(int, sys.stdin.readline().split())) # 0~3
cost.insert(0, 0)

dp[2] = abs(cost[1] - cost[2])


for i in range(3, n+1):
  dp[i] = min(dp[i-1] + abs(cost[i-1] - cost[i]), dp[i-2] + abs(cost[i-2] - cost[i]))
  
print(dp[n])


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

int main()
{
    int N;

    cin >> N;
    vector<int> s(N);
    ll sum = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 != 0)
    {
        cout << sum << endl;
        return 0;
    }
    sort(s.begin(), s.end());
    for (auto t : s)
    {
        if (t % 10 != 0)
        {
            cout << sum - t << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    if(x-1 == 0) x = 14;
    if(y-1 == 0) y = 14;
    cout << (x == y ? "Draw" : (x > y ? "Alice" : "Bob")) << endl;
}

Measured memory_bytes: 256
package main

import (
	"container/heap"
	"fmt"
	"math"
	"sort"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)

	A := make(sort.IntSlice, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		A[i] = a
	}
	sort.Sort(sort.Reverse(A))

	q := make(QS, N)
	for i, d := range A {
		q[i] = &Q{
			idx: i, value: d, index: i,
		}
	}
	heap.Init(&q)

	if N == 1 {
		fmt.Println(A[0] / int(math.Pow(2, float64(M))))
		return
	}
	for M > 0 {
		qi := heap.Pop(&q).(*Q)
		qi.value /= 2
		M--
		A[qi.idx] = qi.value
		heap.Push(&q, qi)
	}

	sum := 0

	for i := 0; i < N; i++ {
		sum += A[i]
	}

	fmt.Println(sum)

}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define int ll
#define Endl endl


signed main(void){
    string S;
    cin >> S;
    int R=(S[5]-'0')*10+(S[6]-'0');
    if(R<=4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}


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

int cnt[110][110];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, N; 
    cin >> W >> H >> N;
    int L = 0, R = W;
    int U = 0, D = H;
    rep(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        rep(i, H + 1) {
            rep(j, W + 1) {
                if (a == 1) L = max(L, x);
                if (a == 2) R = min(R, x);
                if (a == 3) U = max(U, y);
                if (a == 4) D = min(D, y);
            }
        }
    }
    //cout << L << " " << R << " " << U << " " << D << endl;
    if (R - L < 0 || D - U < 0){ cout <<  0 << endl; return 0;}
    cout << max(0, (R - L) * (D - U)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;








int main() {

    
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    int rev = 1;
    int start = 500000;
    int left = start - 1;
    int right = start + 1;
    int b[1000000];
    b[start] = a[0];
    for (int i = 1; i < n; ++i) {
        if (rev % 2 == 0) {
            b[right] = a[i];
            ++right;
        }
        else {
            b[left] = a[i];
            --left;
        }
        ++rev;
    }

    if (rev % 2 == 0) {
        for (int i = left + 1; i <= right - 1; ++i) {
            cout << b[i] << " ";
        }
        cout << endl;
    }
    else {
        for (int i = right - 1; left + 1 <= i; --i) {
            cout << b[i] << " ";
        }
        cout << endl;
    }






    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<long long> R;
  long long a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  R.push_back(a * c);
  R.push_back(a * d);
  R.push_back(b * c);
  R.push_back(b * d);
  
  //R[0] = a * c;
  //R[1] = a * d;
  //R[2] = b * c;
  //R[3] = b * d;
  
  sort(R.begin(), R.end() );
  
  cout << R[3] << endl;
  
  return 0;
}


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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

char s[limit], t[limit];
int l, m;

int x[limit];

int r;

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

	cin>>s;
	l = strlen(s);

	rep(i, l) {
		if(s[i]=='x')x[m]++;
		else {
			t[m] = s[i];
			m++;
		}
	}

	rep(i, m/2) {
		if(t[i] != t[m-i-1]) {
			cout<<-1<<endl;
			return 0;
		}
	}

	rep(i, (m+1)/2) {
		r += abs(x[i]-x[m-i]);
	}

	cout<<r<<endl;

	return 0;
}


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

int main(){
  long long a,b,c;
  cin>>a >>b >>c;
  if(a+b+1>=c){
    cout<<b+c<<endl;
  }else{
    cout<<b+a+b+1<<endl;
  }
  return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  vector<int> b(w);
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < w; i++)
  {
    cin >> b.at(i);
  }

  for (int i = 0; i < h; i++)
  {
    int ans = 0;
    for (int j = 0; j < w; j++)
    {
      ans += a.at(i).at(j) * b.at(j);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int n,m;

int main(){
  cin>>n>>m;
  vector<pair<int,int> > v;
  for(int i = 0; i < m; i++){
    int a,b;
    cin>>a>>b;
     
    v.push_back(make_pair(b,a));
    // bを照準にするために、bをfirstに入れる
    }
    

  sort(v.begin(),v.end());
  int tmp = v[0].first;
  int counter = 1;
  for(int i = 1; i < m; i++){
    if(v[i].second>=tmp){
      counter++;
      tmp = v[i].first;
    }
  }
  cout<<counter<<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int inf = (signed) (~0u >> 1);

typedef class Edge {
	public:
		int ed, nx, r;

		Edge() {	}
		Edge(int ed, int nx, int r) : ed(ed), nx(nx), r(r) {	}
} Edge;

typedef class MapManager {
	public:
		int *h;
		vector<Edge> E;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			memset(h, -1, sizeof(int) * (n + 1));
		}
		~MapManager() {
			delete[] h;
			E.clear();
		}

		void add_edge(int u, int v, int r) {
			E.emplace_back(v, h[u], r);
			h[u] = (signed) E.size() - 1;
		}
		void add_arc(int u, int v, int r) {
			add_edge(u, v, r);
			add_edge(v, u, 0);
		}
		Edge& operator [] (int p) {
			return E[p];
		}
} MapManager;

typedef class Network {
	public:
		int S, T;
		MapManager g;

		int *d, *h;

		Network(int S, int T) : S(S), T(T), g(T) {
			d = new int[(T + 1)];
			h = new int[(T + 1)];
		}
		~Network() {
			delete[] d;
			delete[] h;
		}

		boolean bfs() {
			queue<int> Q;
			memset(d, -1, sizeof(int) * (T + 1));
			d[S] = 0;
			Q.push(S);
			while (!Q.empty()) {
				int e = Q.front();
				Q.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
					eu = g[i].ed;
					if (!g[i].r || ~d[eu])
						continue;
					d[eu] = d[e] + 1;
					Q.push(eu);
				}
			}
			return d[T] != -1;
		}
		
		int dfs(int p, int mf) {
			if (p == T || !mf)
				return mf;
			int flow = 0, f;
			for (int& i = h[p], j, e; ~i; (i != -1) && (i = g[i].nx)) {
				e = g[i].ed, j = i;
				if (g[i].r && d[e] == d[p] + 1 && (f = dfs(e, min(mf, g[i].r))) > 0) {
					g[j].r -= f;
					g[j ^ 1].r += f;
					flow += f;
					mf -= f;
					if (!mf)
						break;
				}
			}
			return flow;
		}

		int dinic() {
			int rt = 0;
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					h[i] = g.h[i];
				rt += dfs(S, inf);
			}
			return rt;
		}

		void add_edge(int u, int v, int r) {
			g.add_arc(u, v, r);
		}
} Network;

const int N = 105;

int n, m;
int a[N][N];
int b[N][N];
int c[N][N];
int id[N][N];
int col[N][N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%d", a[i] + j);
		}
	}
	for (int c = 1, T; c <= m; c++) {
		Network	network (0, T = n + n + 1);
		for (int i = 1; i <= n; i++)
			network.add_edge(0, i, 1);
		for (int i = 1; i <= n; i++)
			network.add_edge(i + n, T, 1);
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (!col[i][j]) {
					network.add_edge(i, (a[i][j] + m - 1) / m + n, 1);
					id[i][j] = (signed) network.g.E.size() - 1;
				}
			}
		}
		network.dinic();
		MapManager& g = network.g;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (!col[i][j] && g[id[i][j]].r) {
					col[i][j] = c;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			b[i][col[i][j]] = a[i][j];
		}
	}
	for (int i = 1; i <= n; i++, putchar('\n')) {
		for (int j = 1; j <= m; j++) {
			printf("%d ", b[i][j]);	
			c[(b[i][j] + m - 1) / m][j] = b[i][j];
		}
	}
	for (int i = 1; i <= n; i++, putchar('\n')) {
		for (int j = 1; j <= m; j++) {
			printf("%d ", c[i][j]);	
		}
	}
	return 0;
}


Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
string s;

bool check(int k){
    vector <int> h(n + 1);
    int c = 0;
    for(int i = 1 ; i < k ; i++){
        c ^= h[i];
        if(s[i] ^ c){
            if(i + k - 1 >= n) return 0;
            h[i + k] ^= 1;
            c ^= 1;
        }
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    n = s.size();
    for(auto &i : s) i -= '0';
    if(s[0]){
        for(auto &i : s) i ^= 1;
    }
    int l = 1, r = n;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) l = mid + 1;
        else r = mid - 1;
    }
    cout << r << endl;
}


Measured memory_bytes: 4276
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int M = cin.nextInt();

        long tmp = M * 1900 + (N-M) * 100;
        long tmp2 = 1;
        for (int i=0; i<M; i++) {
            tmp2 *= 2;
        }
        Console.WriteLine(tmp * tmp2);
    }

    long gcd(long a, long b)
    {
        long tmp;
        if (b > a)
        {
            tmp = a;
            a = b;
            b = tmp;
        }

        if (b == 0)
        {
            return a;
        }

        return gcd(b, a % b);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost

def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
    if iU - iL <= iX :
        iTotalCost = min(iLCost,iUCost)
        for iK in range(iL+1,iU) :
            iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
        return iTotalCost
    else:
        iM = (iU + iL) // 2
        iMCost = fCalcCost(iN,iX,aCum,iM)
        if iLCost < iUCost :
            return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
        else :
            return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    print(fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum))
else:
    print(2*iX + 5*aX[0])


Measured memory_bytes: 27244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i, n) cin >> t[i];

  sort(t.begin(), t.end());
  int ans = 0;
  int idx = 0;
  while (idx < n) {
    ans++;
    int res = t[idx] + k;
    int cnt = 0;
    while (idx < n && cnt < c && t[idx] <= res) {
      idx++;
      cnt++;
    }
  }
  cout << ans << '\n';






  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
bool ans = false;
int n, xx[1000000], a[1000000];
int main() {
	cin>>n;
	for (int i = 0; i < n; i++) cin>>a[i], xx[i] = a[i];
	sort(xx,xx+n); 
	int mx = xx[n-1];
	if (mx == xx[n-2]) ans = true;
	for (int i = 0; i < n; i++) {
		if (a[i] != mx || ans) cout<<mx<<endl;
		else cout<<xx[n-2]<<endl;
	}
}

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

int main() {

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> costs(n);
    vector<vector<int>> books(n);
    for(int i = 0; i < n; i++) {
        books[i].resize(m);
        cin >> costs[i];
        for(int j = 0; j < m; j++) {
            cin >> books[i][j];
        }
    }

    int min_cost = -1;
    for(int mask = 1; mask < (1 << n); mask++) {
        vector<int> level(m, 0);
        int cost = 0;
        for(int i = 0; i < n; i++) if(mask & (1 << i)) {
            for(int j = 0; j < m; j++) level[j] += books[i][j];
            cost += costs[i];
        }
        bool valid = true;
        for(int j = 0; j < m && valid; j++) if(level[j] < x) {
            valid = false;
        }
        if(valid && (min_cost == -1 || min_cost > cost)) {
            min_cost = cost;
        }
    }

    cout << min_cost << '\n';

    return 0;
}

Measured memory_bytes: 3632
import math

N = int(input())
primes = []


def isprime(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True


for p in range(3, 55556, 2):
    if p % 5 == 1 and isprime(p):
        primes.append(str(p))
    if len(primes) == N:
        break
print(" ".join(primes))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
vector<tuple<int, int, int>> points;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) {
		int x, y; cin >> x >> y;
		points.push_back(make_tuple( x, y, i ));
	}
	sort(all(points));

	set<pair<int, int>> rest;
	dsu uf(N);
	rep(i, 0, N) {
		int x, y, id;
		tie(x, y, id) = points[i];
		while (0 < rest.size()) {
			auto ite = rest.lower_bound({ y, -1 });
			if (ite != rest.begin()) {
				ite--;
				uf.merge(ite->second, id);
				y = ite->first;
				rest.erase(ite);
			}
			else {
				break;
			}
		}
		rest.insert({ y, id });
	}

	rep(i, 0, N) printf("%d\n", uf.size(i));
}







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

int main(){
int n,x[100],y[100];
double ans1=0,ans2=0,ans4=0,ans3=0;
long z=0;
cin>>n;
for(int i=0;i<n;i++)
	{cin>>x[i];
	}
for(int i=0;i<n;i++)
	{cin>>y[i];
	}
for(int i=0;i<n;i++)
	{
	if(x[i]-y[i]<0) {y[i]*=-1;x[i]*=-1;}
	ans1+=x[i]-y[i];
	}
for(int i=0;i<n;i++)
	{z+=(x[i]-y[i])*(x[i]-y[i]);
	}
ans2=sqrt(z);
z=0;
for(int i=0;i<n;i++)
	{z+=pow(x[i]-y[i],3);
	}
ans4=pow(z,1.0/3);
z=0;
for(int i=0;i<n;i++)
	{z=x[i]-y[i];
	if(ans3<z) ans3=z;
	z=0;
	}
printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n",ans1,ans2,ans4,ans3);
return 0;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n;
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9)
	cout<<"hon";
	else if(n==0||n==1||n==6||n==8)
	cout<<"pon";
	else
	cout<<"bon";
	return 0;
}

Measured memory_bytes: 3652
#[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)*}
    };
}

#[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, 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! {
        r: i32,
        g: i32,
        b: i32,
    }
    let val = r * 100 + g * 10 + b;
    if val % 4 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;

struct Node{
	int x, y;
	bool operator < (const Node &b) const {
		return x + y < b.x + b.y; 
	} 
}a[10010];

int n, f[5010][5010];

signed main(void) {
	scanf("%lld", &n); 
	for(int i = 1; i <= n; i++)
		scanf("%lld%lld", &a[i].x, &a[i].y);
	sort(a + 1, a + n + 1);
	memset(f, 0x3f3f, sizeof(f));
	f[0][0] = 0; 
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= i; j++) {
			f[i + 1][j] = min(f[i][j], f[i + 1][j]);
			if(f[i][j] <= a[i + 1].x)
				f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j] + a[i + 1].y);
		}
	}
//	printf("%d\n", f[2][2]);
	for(int j = n; j >= 0; j--)
		if(f[n][j] != 0x3f3f3f3f3f3f3f3f) {
			printf("%lld\n", j);
			return 0;
		} 
}

Measured memory_bytes: 196480
#include<stdio.h>
int main(void)
{
    int k,a,b,i;
    scanf("%d%d%d",&k,&a,&b);
    for(i=a;i<=b;i++)
        if(i%k==0){
            printf("OK\n");
            return 0;
        }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long i,j,k,x,y,z,n;
    cin>>n;
    x=0;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
    	if (i%2==1 && arr[i]%2==1)
    	{
    		x++;
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
signed main(){
int n;
  cin>>n;
  for(int i=0;i<3;i++){
    if(n%10==7){
      cout<<"Yes\n";
      return(0);
    }
    n /= 10;
  }
  cout<<"No\n";
  return(0);
}


Measured memory_bytes: 3588
N = int(input())
A = list(map(int, input().split()))

balls = {}

for a in A:
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1
res = 0
for b in balls:
  count = balls[b]
  res += count * (count-1) // 2

for a in A:
  res -= balls[a] * (balls[a]-1) // 2
  balls[a] -= 1
  res += balls[a] * (balls[a]-1) // 2
  print(res)
  res -= balls[a] * (balls[a]-1) // 2
  balls[a] += 1
  res += balls[a] * (balls[a]-1) // 2

Measured memory_bytes: 90060
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

int solve() {
  int n, m;
  readf("%d %d\n", &n, &m);
  int[] cond_d = new int[m];
  int[] cond_v = new int[m];
  for(int i=0; i<m; i++) {
    readf("%d %d\n", &cond_d[i], &cond_v[i]);
  }
  int[4] ten = [-1,1,10,100];
  int min = n==1 ? 0 : ten[n];
  for(int i=min; i<ten[n]*10; i++) {
    bool br = false;
    for(int j=0; j<m; j++) {
      if(((i/ten[n-cond_d[j]+1]) % 10) != cond_v[j]) {
        br = true;
        break;
      }
    }
    if(!br) return i;
  }
  return -1;
}

void main() {
  writeln(solve());
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
ll N, K;
ll A[MAX_N];

//gcd(a, b)を求める。
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

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

  cin >> N >> K;
  rep(i, N) cin >> A[i];
  sort(A, A+N);

  if (K > A[N-1]) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
  }

  if (N == 1 && A[0] != K) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
  }

  for (int i = 0; i < N; ++i) {
      if (A[i] == K) {
          cout << "POSSIBLE" << endl;
          return 0;
      }
  }

  ll g = gcd(A[0], A[1]);
  for (int i = 2; i < N; ++i) {
      g = gcd(g, A[i]);
  }

  if (K%g == 0) {
      cout << "POSSIBLE" << endl;
  } else {
      cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main() {
    ll N,C=0;
    ll d[57];
    cin >> N;
    rep(i,N){
        cin >>d[i];
    }
    rep(i,N-1){
        REP(j,i+1,N){
            C+=d[i]*d[j];
        }
    }
    cout << C<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int sz=1e6+7;
typedef long long ll;
int n;
ll ans;
ll dp[sz],sum[sz];
// dp[i]表示第一位可以自由选择的长度为i的合法方案数 
int main(){
	scanf("%d",&n);
//	if(n==2) return printf("4\n"),0;
	dp[0]=dp[1]=1;
	sum[0]=1;
	sum[1]=2;
	for(int i=2;i<=n;i++){
		dp[i]=(sum[i-1]-dp[i-2]+mod)%mod;
		sum[i]=(sum[i-1]+dp[i])%mod;
	}
	for(int i=0;i<=n-2;i++) (ans+=dp[i]*(n-1)%mod*n%mod)%=mod;
	(ans+=dp[n-1]*(n-1)%mod)%=mod;
	ans=(ans+1)%mod;
//	(ans+=dp[n])%=mod;
	printf("%lld\n",ans);
}

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

auto& scan_in = std::cin;

// input
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
//Cスタイルの入出力とC++スタイルの入出力の同期を切る操作
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { scan_in >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest& ...rest) { scan_in >> first; MACRO_VAR_Scan(rest...); }
#define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int w_=0; w_<n; ++w_){MACRO_VEC_ROW_Scan(w_, __VA_ARGS__);}
template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest& ...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); }
template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { scan_in >> t[p]; }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest& ...rest) { scan_in >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); }
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)scan_in>>i;

// output
template<typename T>void MACRO_OUT(const T t) { std::cout << t; }
template<typename First, typename...Rest>void MACRO_OUT(const First first, const Rest...rest) { std::cout << first << " "; MACRO_OUT(rest...); }
#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";

// utility
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define RREP(w, n) RFOR(w, 0, n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)


#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define F         first
#define S         second

template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if (f) Out(y); else Out(n); }

signed main() {
    INIT;


    // ⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎
	int K, S;
	cin >> K >> S;
 
	long long ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (z >= 0 && z <= K) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#![allow(unused)]

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n = sc.get();
    let avec: Vec<i64> = (0..n).map(|_| sc.get()).collect();

    let mut hash = std::collections::HashMap::with_capacity(n);

    for i in 0..n {
        *hash.entry((i as i64) - avec[i]).or_insert(0) += 1;
    }

    let ans: i64 =
        (0..n).map(|i| hash.get(&((i as i64) + avec[i])).unwrap_or(&0)).sum();
    println!("{}", ans);
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin>>str;
	int k=str.size();
	if(k%2==0){
	for(int i=0; i<(str.size())/2;i++){
		cout<<str.at(2*i);
		}
		cout<<endl;
	}
	else{
		for(int i=0; i<(str.size())/2+1;i++){
		cout<<str.at(2*i);
	}
	cout<<endl;
	}
}

Measured memory_bytes: 512
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=[0]
visited = [False]*n

while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    vi a(N);
    in(N,a);
    
    int M = 0;
    vl ans(N,0);
    for (int i = N; i > 0; i--) {
        ll aa = 0;
        for (int j = i*2; j <= N; j+=i) {
            if(ans[j-1] % 2 == 1) aa++;
        }
        if(aa % 2 == 1 && a[i-1] == 0) ans[i-1] = 1;
        else if(aa % 2 == 0 && a[i-1] == 1) ans[i-1] = 1;
        
    }
    vi b;
    rep(i,N){
        if(ans[i] != 0) M++,b.pb(i+1);
    }
    cout << M << endl;
    if(M!=0){
        outve(b);
    }
    
    

    return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) ((a,0,sizeof(a)))
typedef long long ll;
typedef pair<int,int> P;
vector<int> prime;
vector<P>v;
int vis[100005];
int n,m;
void get_prime(){
    for(int i=2;i<=100000;i++){
        if(vis[i]) continue;
        prime.push_back(i);
        for(int j=2;j*i<=100000;j++)
            vis[j*i]=1;
    }
}
void get_factor(int m){
    for(int i=0;prime[i]*prime[i]<=m;i++){
        if(m%prime[i]) continue;
        int ans=0;
        while(!(m%prime[i])) ans++,m/=prime[i];
        v.push_back(P(prime[i],ans));
    }
    if(m!=1) v.push_back(P(m,1));
}
ll quick_pow(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1) ans=ans*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return ans;
}
ll cal(ll a,ll b){
    ll ans=1ll;
    for(ll i=a;i>a-b;i--)
        ans=ans*i%MOD;
    for(int i=2;i<=b;i++)
        ans=ans*quick_pow(i,MOD-2)%MOD;
    return ans;
}
int main(){
    get_prime();
    scanf("%d%d",&n,&m);
    get_factor(m);
    ll ans=1ll;
    for(int i=0;i<v.size();i++){
        ans=ans*cal(n+v[i].second-1,v[i].second)%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 100005
ll dp[MX][2];
ll wt[101], val[101];
int main() {
	int n, w;
	cin >> n >> w;
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
		cin >> wt[i] >> val[i], sum += val[i];
		for (int j = 0; j <= sum; ++j)
			dp[j][0] = dp[j][1] = 1e18;
		dp[0][0] = dp[0][1] = 0;

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= sum; ++j) {
			if(j >= val[i])
				dp[j][1] =  min(dp[j][0], dp[j - val[i]][0] + wt[i]);
			else
				dp[j][1] = dp[j][0];
		}
		for (int j = 1; j <= sum; ++j)
			dp[j][0] = dp[j][1];
	}
	ll ans = 0;
	/*for(int i = 0; i <= 1; ++i) {
		for (int j = 0; j <= sum; ++j)
			cout << dp[j][i] << " ";
		cout << endl;
	}*/
	for (ll i = 1; i <= sum; ++i)
		if(dp[i][1] <= w)
			ans = i;
	cout << ans << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,x;
    cin>>a>>b>>x;
    if(x<b){
        cout<<(a*x)/b;
    }
    else{
        cout<<(a*(b-1))/b;
    }
    return 0;
}

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

int main() 
{
    int N, K;
    cin >> N >> K; 
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    sort(h.rbegin(), h.rend());
    int min_dist = 1000000001;
    for (int i = 0; i < N-(K-1); i++) 
    {
        if (h[i] - h[i+(K-1)] < min_dist) min_dist = h[i] - h[i+(K-1)];
    }
    cout << min_dist << endl;
}

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

using namespace std;

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

	if (a == 'H') {
		if (b == 'D') {
			cout << 'D' << endl;
			return 0;
		}
		cout << 'H' << endl;
		return 0;
	}
	
	if (b == 'H') {
		cout << 'D' << endl;
		return 0;
	}
	cout << 'H' << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vector<pi> plus,minus;
    int cnt=0;
    rep(i,N){
        string s; cin>>s;
        int M = s.size();
        int pd=0,cs=0;
        rep(j,M){
            if (s[j]=='(') pd++;
            else{
                if(pd>0) pd--;
                else cs++;
            }
        }
        cnt+=pd-cs;
        if (pd>=cs) plus.pb({cs,pd});
        else minus.pb({pd,cs});
    }
    auto noret=[](){cout<<"No\n"; exit(0);};
    if (cnt) noret();
    int A = plus.size();
    int B = minus.size();
    sort(all(plus));
    sort(rall(minus));
    int st=0;
    rep(i,A){
        st-=plus[i].fi;
        if (st<0) noret();
        st+=plus[i].se;
    }
    rep(i,B){
        st-=minus[i].se;
        if (st<0) noret();
        st+=minus[i].fi;
    }
    cout<<"Yes\n";
    return 0;
}


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

int N,M; vector<vector<pair<int,int>>> P;
void input()
{
    cin >> N >> M;
    P.resize(N+1);
    for(int i=0; i<M; ++i){
        int p,y; cin >> p >> y;
        P[p].emplace_back(make_pair(y,i+1));
    }
}

string make_num(int i, int j)
{
    string ans="";
    int loop = 12;
    while(loop > 6){
        if(j > 0){
            ans += j%10 + '0';
            j /= 10;
        } 
        else ans += '0';
        --loop;
    }
    while(loop > 0){
        if(i > 0){
            ans += i%10 + '0';
            i /= 10;
        }
        else ans += '0';
        --loop;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}

void solve()
{
    vector<pair<int,string>> C;
    for(int i=1; i<=N; ++i){
        sort(P[i].begin(),P[i].end());
        for(int j=0; j<P[i].size(); ++j){
            C.emplace_back(make_pair(P[i][j].second,make_num(i,j+1)));
        }
    }
    sort(C.begin(),C.end());
    for_each(C.begin(),C.end(),[](pair<int,string> p){
        cout << p.second << endl;
    });
}

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

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C)
{
    cout << ((A + B >= C) ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256