akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge {
  ll d, u, v;
public:
  bool operator<(const edge &e) const { return d < e.d; }
};

ll N, A;
vector<edge> D;
vector<pll> E[300];

ll dist(ll s, ll g) {
  ll visited[300];
  REP(i, 0, N) visited[i] = false;
  priority_queue<pll, vector<pll>, greater<pll> > q;
  q.push(pll(0, s));

  while(!q.empty()) {
    ll p = q.top().first;
    ll u = q.top().second;
    q.pop();

    if(u == g) return p;
    if(visited[u]) continue;
    visited[u] = true;

    REP(i, 0, E[u].size()) {
      ll d = E[u][i].first;
      ll v = E[u][i].second;
      q.push(pll(p + d, v));
    }
  }

  return INF;
}

int main(void) {
  cin >> N;
  REP(i, 0, N) REP(j, 0, N) {
    cin >> A;
    if(j > i) D.push_back((edge) { A, i, j });
  }

  sort(D.begin(), D.end());

  ll ans = 0;
  REP(i, 0, D.size()) {
    ll d = dist(D[i].u, D[i].v);
    if(d < D[i].d) {
      ans = -1;
      break;
    }
    if(D[i].d < d) {
      E[D[i].u].push_back(pll(D[i].d, D[i].v));
      E[D[i].v].push_back(pll(D[i].d, D[i].u));
      ans += D[i].d;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1912
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int n = 0;

int finding(vector<long long> &a, int imid) {
    vector<long long> ans(n);
    ans.at(0) = imid * 2;
    for (int i=1; i<n; i++) {
        ans.at(i) = 2 * a.at(i-1) - ans.at(i-1);
        if (ans.at(i) < 0) {
            if (i%2 == 0) return 1;
            else return -1;
        }
    }
    if (ans.at(0)/2 + ans.at(n-1)/2 == a.at(n-1)) {
        for (int i=0; i<n; i++) {
            cout << ans.at(i);
            if (i == n-1) cout << endl;
            else cout << " ";
        }
        return 0;
    }
    if (ans.at(0)/2 + ans.at(n-1)/2 > a.at(n-1)) return -1;
    else return 1;
}

int binary_searching(vector<long long> &a, int imin, int imax) {
    if (imax < imin) return -1;
    int imid = imin + (imax - imin) / 2;
    int buf = finding(a, imid);
    if (buf == 1) {
        return binary_searching(a, imid+1, imax);
    }
    else if (buf == -1) {
        return binary_searching(a, imin, imid-1);
    }
    else {
        return 0;
    }
}

int main() {
    cin >> n;
    vector<long long> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    binary_searching(a, 0, a.at(0));
    return 0;
}


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

const int MAXN = 200005;

int n;

long long c[MAXN];
inline int lowbit(int i)
{ return i&(-i); }
inline void modify(int pos, int dt)
{
        for (; pos <= n; pos += lowbit(pos))
		c[pos] += dt;
}
inline long long sum(int pos)
{
	long long ans = 0;
	for (; pos; pos -= lowbit(pos))
		ans += c[pos];
	return ans;
}

priority_queue<int, vector<int>, greater<int> > st[26], del[26];

char str[MAXN];
bool vis[MAXN];
int cnt[26];

int main()
{
	memset(vis, 0, sizeof vis);
	scanf("%s", str+1);
	n = strlen(str+1);
	for (int i = 1; i <= n; i++) {
		st[str[i]-'a'].push(i);
		cnt[str[i]-'a']++;
	}
	int c = 0;
	for (int i = 0; i < 26; i++)
		if (cnt[i]&1)
			c++;
	if (c > 1) {
		puts("-1");
		return 0;
	}
	long long ans = 0;
	int cur = 0, cc = 0;
	if (c == 1) {
		for (int i = 1; i <= n; i++) {
			if (cnt[str[i]-'a']&1) {
				cc++;
				if (cc == (cnt[str[i]-'a']+1)/2) cur = i;
			}
		}
	}
	int rt = 0;
	for (int i = n; i >= 1; i--) {
		if (vis[i]) continue;
		int pos = str[i]-'a';
		while (vis[st[pos].top()]) throw;
		if (st[pos].top() != i) {
			int p = st[pos].top(); st[pos].pop();
			ans += p-1-sum(p-1);
			modify(p, 1), modify(i, 1), vis[p] = 1, vis[i] = 1;
			if (p > cur) rt++;
		} else ans += abs(i+rt-(n+1)/2), st[pos].pop(), vis[i] = 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3200
// Example program
#include <iostream>
using namespace std;

int main()
{
    int h, w;
    while(1){
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int par[100005];
int rnk[100005];

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  init(N+1);
  for (int i=0; i<M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    unite(x, y);
  }
  set<int> s;
  for (int i=1; i<=N; i++) {
    s.insert(find(i));
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(void){
    int N;
    string Sbuf;
    set<string> S;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Sbuf;
        S.insert(Sbuf);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 19256
#include <atcoder/maxflow>
#include <iostream>

using namespace std;
using namespace atcoder;

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

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

    /**
     * generate (s -> even grid -> odd grid -> t) graph
     * grid(i, j) correspond to vertex (i * m + j)
     **/
    mf_graph<int> g(n * m + 2);
    int s = n * m, t = n * m + 1;

    // s -> even / odd -> t
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (grid[i][j] == '#') continue;
            int v = i * m + j;
            if ((i + j) % 2 == 0) {
                g.add_edge(s, v, 1);
            } else {
                g.add_edge(v, t, 1);
            }
        }
    }

    // even -> odd
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if ((i + j) % 2 || grid[i][j] == '#') continue;
            int v0 = i * m + j;
            if (i && grid[i - 1][j] == '.') {
                int v1 = (i - 1) * m + j;
                g.add_edge(v0, v1, 1);
            }
            if (j && grid[i][j - 1] == '.') {
                int v1 = i * m + (j - 1);
                g.add_edge(v0, v1, 1);
            }
            if (i + 1 < n && grid[i + 1][j] == '.') {
                int v1 = (i + 1) * m + j;
                g.add_edge(v0, v1, 1);
            }
            if (j + 1 < m && grid[i][j + 1] == '.') {
                int v1 = i * m + (j + 1);
                g.add_edge(v0, v1, 1);
            }
        }
    }

    cout << g.flow(s, t) << endl;

    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        int i0 = e.from / m, j0 = e.from % m;
        int i1 = e.to / m, j1 = e.to % m;

        if (i0 == i1 + 1) {
            grid[i1][j1] = 'v';
            grid[i0][j0] = '^';
        } else if (j0 == j1 + 1) {
            grid[i1][j1] = '>'; grid[i0][j0] = '<';
        } else if (i0 == i1 - 1) {
            grid[i0][j0] = 'v';
            grid[i1][j1] = '^';
        } else {
            grid[i0][j0] = '>'; grid[i1][j1] = '<';
        }
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5320
#include <stdio.h>

int main (){
  int a,b,c,y=0,i;

  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if((c%i) == 0) y++;
  }
  printf("%d\n",y);

  return 0;
}

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

int main(){
    int N, A[200], n=0;
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    
    while(1){
        int count=0;
        for(int i=0; i<N; i++){
            if(A[i] % 2 == 0) count++;
            A[i] /= 2;
        }
        if(count != N) break;
        else n++;
    }
    cout << n << endl;
}

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

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

    if (s == "SUN")
        cout << 7 << endl;
    if (s == "MON")
        cout << 6 << endl;
    if (s == "TUE")
        cout << 5 << endl;
    if (s == "WED")
        cout << 4 << endl;
    if (s == "THU")
        cout << 3 << endl;
    if (s == "FRI")
        cout << 2 << endl;
    if (s == "SAT")
        cout << 1 << endl;
}

Measured memory_bytes: 3584
import java.util.*;
 
public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int M = sc.nextInt();
		int total = 0;
		for(int i = 0;i < M;i++) {
			int x = sc.nextInt();
			total += x;
		}
		if(N - total < -1) {
			System.out.println("-1");
		}else {
			System.out.println(N - total);
		}
	}
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

ll N, A, B;

void init()
{
	cin >> N >> A >> B;
}


void solve()
{
	if (A > B || N == 1 && A != B) {
		cout << 0 << endl;
	} else {
		cout << (N - 1) * B + A - (N - 1) * A - B + 1 << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
const int MAX_N=1e5+10;
const int mod=998244353;
int n,x,d[MAX_N];
ll quick_mod(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1) (res*=x)%=mod;
        (x*=x)%=mod,y>>=1;
    }
    return res;
}
int main(){
    cin>>n;
    bool flag=false;
    for(int i=0;i<n;i++){
        cin>>x;
        d[x]++;
        if(i==0){
            flag=(d[0]==1);
        }
    }
    ll ans=(d[0]==1&&flag);
    for(int i=1;i<MAX_N;i++){
        (ans*=quick_mod(d[i-1],d[i]))%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static final long MOD = 1000000007L;

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		long[] a = new long[M];
		long[] steps = new long[N+1];
		for(int i=0;i<N;i++) {
			steps[i] = 0;
		}

		for(int i=0;i<M;i++) {
			a[i] = sc.nextLong();
			steps[(int) a[i]] = -1;
		}

		steps[0] = 1;
		steps[1] = (steps[1] == -1) ? -1 : 1;
		for(int i=2;i<N+1;i++) {

			if(steps[i] == -1) continue;

			if(steps[i-1] == -1 && steps[i-2] == -1) {
				System.out.println(0);
				return;
			}

			if(steps[i-1] == -1) {
				steps[i] = steps[i-2];
			}else if(steps[i-2] == -1) {
				steps[i] = steps[i-1];
			}else {
				steps[i] = (steps[i-1] + steps[i-2])%MOD;
			}
		}
		System.out.println(steps[N]%MOD);
	}
}

Measured memory_bytes: 61028
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        es: [(usize1, usize1); n - 1]
    }
    let d = 1000000007;
    let mut stair = vec![1; k + 1];
    for i in 1..k + 1 {
        stair[i] = stair[i - 1] * i % d;
    }
    let stair_i: Vec<usize> = stair.iter().map(|&x| inv_m(x, d)).collect();
    let mut t = vec![vec![]; n];
    for &(a, b) in &es {
        t[a].push(b);
        t[b].push(a);
    }
    if k < t[0].len() + 1 {
        println!("0");
        return;
    }
    let mut ans = stair[k] * stair_i[k - t[0].len() - 1] % d;
    for &v in &t[0] {
        ans = ans * dfs(v, 0, &t, k, d, &stair, &stair_i) % d;
    }
    println!("{}", ans);
}

fn dfs(r: usize, p: usize, t: &Vec<Vec<usize>>, k: usize, d: usize, s: &Vec<usize>, si: &Vec<usize>) -> usize {
    if k < t[r].len() + 1 {
        return 0;
    }
    let mut ret = s[k - 2] * si[k - 1 - t[r].len()] % d;
    for &c in &t[r] {
        if c == p {
            continue;
        }
        ret = ret * dfs(c, r, t, k, d, s, si) % d;
    }
    ret
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


Measured memory_bytes: 19580
#include <stdio.h>
int main (void)
{
  int i;
  int n,num=1,max=0;
  scanf("%d",&n);
  int high[n];
  //scanf("%d %d",&a,&b);
  for(i=0;i<n;i++){
    scanf("%d",&high[i]);
  }

  max=high[0];
  for(i=1;i<n;i++){
    if(max<=high[i]) {
      num+=1;
      max=high[i];
    }
  }
  
  printf("%d",num);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main (void)
{
  unsigned long a[100];
  unsigned long n, m, mi;
  unsigned long i;
  unsigned long sum = 0;
  
  scanf("%lu %lu", &n, &m);
  mi=0;
  
  for (i=0; i<n; i++) {
    scanf("%lu", &(a[i]));
    sum += a[i];
  }
          
  for (i=0; i<n; i++) {
    if (a[i]*4*m >= sum) {
      mi++;
    }
  }
  
  if (mi >= m) {
    puts("Yes");
  } else {
    puts("No");
  }
          
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << (a<=b?"unsafe":"safe") << endl;
  
}


Measured memory_bytes: 3612
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[1] << s3[2] << endl;
    
    return 0;
}

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

int main() {
  int n;
  int u;
  int array[100][100] = {};
  int v;
  int k;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++) {
      scanf(" %d",&v);
      array[u-1][v-1] = 1;
    }
  }
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      if((j!=n-1)) printf("%d ",array[i][j]);
      else printf("%d",array[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2048
# 1 "c.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "c.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "c.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n;
    cin >> n;
    vi ans(3);
    for(long long &i:ans)
        cin >> i;
    for(long long i=1; i<n; ++i){
        vi aux(3);
        for(long long &j:aux)
            cin >> j;
        vi res(3);
        for(long long j=0; j<3; ++j){
            for(long long k=0; k<3; ++k){
                if(k == j)
                    continue;
                res[j] = max(res[j], ans[k] + aux[j]);
            }
        }
        swap(ans, res);
    }
    cout << *max_element(ans.begin(), ans.end()) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<ctime>
#include<cstdlib>
using namespace std;
int f[105], n, k, d, a1, cnt;
int main(){
	cin>> n>> k;
	for(int i=1; i<=k; i++){
		cin>> d;
		for(int j=1; j<=d; j++){
			cin>> a1;
			f[a1]=1;
		}
	}
	for(int i=1; i<=n; i++){
		if(f[i]==0) cnt++;
		//cout<< f[i]<< endl;
	}
	cout<< cnt;
	return 0; 
} 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
priority_queue < pii > odd,even;
int n,v[200000];
vector <int> o,e;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        int temp;cin>>temp;
        if(i%2==1){o.pb(temp);}
        else{e.pb(temp);}
    }
    sort(o.begin(),o.end());
    sort(e.begin(),e.end());

    int f = 1;
    for(int i=1;i<o.size();i++){
        if(o[i]!=o[i-1]){
            odd.push ( mp (-1 * (n/2-f),o[i-1]) );
            f = 1;
        }
        else f++;
    }
    odd.push( mp (-1 * (n/2-f),o[o.size()-1]) );
    odd.push( mp (-1 * n/2 ,100001) );

    f=1;
    for(int i=1;i<e.size();i++){
        if(e[i]!=e[i-1]){
            even.push(mp(-1*(n/2-f),e[i-1]));
            f=1;
        }
        else f++;
    }
    even.push(mp(-1*(n/2-f),e[e.size()-1]));
    even.push(mp (-1* n/2,100001) );
    int a1,a2,b1,b2,c1,c2,d1,d2;
    a1 = odd.top().fi * -1;
    a2 = odd.top().se;
    odd.pop();
    c1 = odd.top().fi * -1;
    c2 = odd.top().se;

    b1 = even.top().fi * -1;
    b2 = even.top().se;
    even.pop();
    d1 = even.top().fi * -1;
    d2 = even.top().se;

    int ans1,ans2,ans3,ans;

    ans1 = a1+b1;
    ans2 = c1+b1;
    ans3 = a1+d1;

    if(a2 == b2){
        ans = min(ans2,ans3);
    }
    else {ans = ans1;}
    cout<<ans<<endl;

}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

bool used[26];

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    string s;
    cin >> s;
    int nc = 0;
    for(c : s) {
        used[c - 'a'] = true;
        nc++;
    }
    if(nc == 26) {
        string ss(s);
        if(!next_permutation(s.begin(), s.end())) {
            cout << -1 << endl;
            return 0;
        }
        for(int i = 0; i < s.size(); i++) {
            if(s[i] != ss[i]) {
                cout << s.substr(0, i + 1) << endl;
                return 0;
            }
        }
    } else {
        cout << s;
        for(int i = 0; i < 26; i++) {
            if(!used[i]) {
                cout << (char)('a' + i) << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<utility>
using namespace std;
 
typedef long long ll;


int main(){
	string str;
    cin >> str;
    bool n=false,s=false,w=false,e=false;
    if(str.find("N")!=-1) n=true;
    if(str.find("W")!=-1) w=true;
    if(str.find("S")!=-1) s=true;
    if(str.find("E")!=-1) e=true;
    if(n && !s){
    	cout << "No";
        return 0;
    }
    if(!n && s){
    	cout << "No";
        return 0;
    }
    if(w && !e){
    	cout << "No";
        return 0;
    }
    if(!w && e){
    	cout << "No";
        return 0;
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  ll n, m, d;
  cin >> n >> m >> d;

  double ans;
  if(d == 0){
    ans = (1.0 / n) * (m - 1);
  }
  else{
    ans = ((2.0 * (n - d)) / (n * n)) * (m - 1);
  }

  printf("%.7lf\n", ans);

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, S: "List[str]"):
    """
    0は縦に入っている1は横に入っていることを表す
    """
    dominos = []
    i = 0
    while i < N:
        if S[0][i] == S[1][i]:
            dominos.append(0)
        else:
            dominos.append(1)
            i += 1
        i += 1

    answer = 3 if dominos[0] == 0 else 6
    for i in range(1,len(dominos)):
        if dominos[i] == 0 and dominos[i-1] == 0:
            answer *= 2
        elif dominos[i] == 1 and dominos[i-1] == 0:
            answer *= 2
        elif dominos[i] == 0 and dominos[i-1] == 1:
            answer *= 1
        elif dominos[i] == 1 and dominos[i-1] == 1:
            answer *= 3
        answer %= MOD
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(2)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def ext_gcd(a, b):
    if b == 0:
        return 1, 0
    q, t = divmod(a, b)
    x, y = ext_gcd(b, t)
    return y, (x - q * y)


def main():
   a, b = map(int, input().split())
   print(*ext_gcd(a,b))
   return


main()


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

queue<long>q;
int main(){
    int K;
    cin >> K;
    for (int i=1; i<10; i++){
        q.push(i);
    }
    while (K--){
        long x = q.front();
        q.pop();
        if (K==0){
            cout << x << endl;
            return 0;
        }
        if (x % 10 != 0){
            q.push(10*x+x%10-1);
        }
        q.push(10*x+x%10);
        if (x % 10 != 9){
            q.push(10*x+x%10+1);
        }
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int a[1000001];

int main(void){
	int i,j,x,y,p,q,flg;

	while(scanf("%d%d",&x,&y) && (x||y)){
		flg = 0; //1:ツ循ツ甘つつキツづゥ 0:ツ循ツ甘つつオツづ按つ「
		memset(a,-1,sizeof(a));

		for(i=0;;i++){
			x = x - y * (x / y);
			if(x == 0) break;
			if(a[x] != -1){
				flg = 1;
				j = a[x];
				break;
			}
			a[x] = i;
			x *= 10;
		}

		printf("%d %d\n",flg ? j : i, flg ? i-j : 0);
	}

  return 0;
}

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
#define m 1000000007
int main()
{
	int n,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a) for(int i=0;i<(a).size();i++) cin>>(a)[i]

int main()
{
    int K, X;
    cin >> K >> X;
    if(500*K>=X)
        cout << "Yes";
        else
        {
            cout << "No";
        }

        return 0;
}

Measured memory_bytes: 256
import sys
import math
def main():
  n, k = map(int, input().split())
  a = list(map(int, input().split()))
  lo = 1
  up = 10**9 + 1
  while up-lo != 1:
    mid = (up + lo)//2
    temp =  0
    for i in a:
      temp += math.ceil(i / mid)-1
    if temp <= k:
      up = mid
    else:
      lo = mid
  temp = 0
  for i in a:
    temp += math.ceil(i/lo)-1
  if  temp <= k:
    print(lo)
  else:
    print(up)
      

if __name__ == "__main__":
  main()

Measured memory_bytes: 31244
#include<stdio.h>
int inf = 1000000001;
int n;
int t[101];
int u[101];

int check(int x){
  int i=0,a=inf;
  for(i=1;i<=n;i++){
    if(i==x+1)continue;
    if(a==inf)a=u[i]-u[i-1];
    if(a!=u[i]-u[i-1])return 0;
  }
  return 1;
}

void solve(){
  int i;
  for(i=0;i<n;i++){
    u[i]=u[i+1];
    if( check(i) ){
      printf("%d\n",t[i]);
      return;
    }
    u[i]=t[i];
  }
  printf("%d\n",t[n]);
}

int main(){
  int i;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<=n;i++){
      scanf("%d",&t[i]);
      u[i]=t[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1032
#include<stdio.h>
long long power(long long, long long, long long);
main()
{
        int m, n;
        scanf("%d %d", &m, &n);
        printf("%lld\n", power(m, n, 1000000007));
}
long long power(long long m, long long n, long long M)
{
        long long res;
        if(!n){
                return 1;
        }
        res = power(m * m % M, n / 2, M);
        if(n % 2){
                res = res * m % M;
        }
        return res;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())

int main() {
    int n;
    set<vector<int> > st;
    cin >> n;
    REP(i,n){
        vector<int> p(3);
        cin >> p[0] >> p[1] >> p[2];
        SORT(p);
        st.insert(p);
    }
    cout << n-st.size() << endl;
    return 0;
}



Measured memory_bytes: 3248
#include <iostream>
#include <cmath>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){
    
    int n;
    cin >> n;
    int p[n],h[n];
    
    rep(i,0,n)
        cin >> h[i];
    
    p[0] = 0;
    p[1] = abs(h[1] - h[0]);
    rep(i,2,n)
        p[i] = min(p[i-2]+abs(h[i]-h[i-2]),p[i-1]+abs(h[i]-h[i-1]));
    
    cout << p[n-1] << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  int n,A,B; read(n,A,B);
  if(n==1) return printf("%d\n",A==B),0;
  if(A>B) return puts("0"),0;
  LL l=1ll*(n-2)*A,r=1ll*(n-2)*B;
  printf("%lld\n",r-l+1);
	return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    vector<bitset<64>> masks(n);
    rep(i, n) {
        int k, b;
        cin >> k;
        while (k > 0) {
            cin >> b;
            masks[i].set(b);
            k--;
        }
    }

    bitset<64> a;
    int q, op, m;

    cin >> q;
    rep(i, q) {
        cin >> op >> m;
        if (op == 0) cout << a[m] << endl;
        if (op == 1) a |= masks[m];
        if (op == 2) a &= ~masks[m];
        if (op == 3) a ^= masks[m];
        if (op == 4) cout << ((a & masks[m]) == masks[m]) << endl;
        if (op == 5) cout << (a & masks[m]).any() << endl;
        if (op == 6) cout << (a & masks[m]).none() << endl;
        if (op == 7) cout << (a & masks[m]).count() << endl;
        if (op == 8) cout << (a & masks[m]).to_ullong() << endl;
    }
}



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

using namespace std;

int main()
{
    int H, W, a = 0;
    string S;
    vector<string> v;
    cin >> H >> W;

    for (int i = 0; i < H; i++)
    {
        cin >> S;
        v.push_back(S);
    }

    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc=new Scanner(System.in);
         int w=sc.nextInt();
         int h=sc.nextInt();
         String a[]=new String[w];
          for(int i=0;i<w;i++)
          {
              a[i]=sc.next();
          }
         
         for(int f=0;f<h+2;f++)
         {
             System.out.print("#");
             
         }
         System.out.println();
         for(int k=0;k<w;k++)
         {
             System.out.println("#"+a[k]+"#");
             
             
         }
        for(int f=0;f<h+2;f++)
         {
             System.out.print("#");
             
         } 
         
    }}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
	int i=1, n, k;
	int j;
	long double sum = 0.0;
	long double sum_1;

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

	sum_1 = (double)1/ n;

	while(i <= n){
		j = 0;
		while(1){
			if(i * pow(2 , j) >= k) break;
			j++;
		}
		sum += sum_1 * pow((double)1/2, j);
		i++;
	} 

	printf("%.15Lf", sum);
		
	return 0;
}

Measured memory_bytes: 128
import java.util.*;


class Main{
  public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
		
		int[] x= new int[5];
		
		for (int i = 0; i < 5; i++) {
		   x[i] = sc.nextInt();
		}
		
		int t = 0;
		int i = 0;
		
		do {
			if ( x[i] == 0)
			{
				t = 1;
				//System.out.println("x[i] = "+ x[i]);
			}
			else
			{
				i++;
			}
			
		}while(t == 0);
		
		System.out.println(i+1);
  }
}

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

const int Nmax=200010;

int main() {
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	if(A+B > C+D) cout << "Left" << endl;
	else if(A+B < C+D) cout << "Right" << endl;
	else cout << "Balanced" << endl;
	
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

map<in,in> ret;

void soin(in n){
    // map<in,in> ret;
    for(in i=2;i*i<=n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]++;
    return;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
 in n;
 cin>>n;
 REP(i,1ll,n+1ll){
   soin(i);
 }
 in ans=1ll;
 for(auto x:ret){
     ans *=(x.second+1ll);
     ans %=MOD;
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LevenshteinDistance solver = new LevenshteinDistance();
        solver.solve(1, in, out);
        out.close();
    }

    static class LevenshteinDistance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final String x = in.next();
            final String y = in.next();

            out.printf("%d\n", editDistance(x, x.length(), y, y.length()));
        }

        private int editDistance(final String a, final int alen, final String b, final int blen) {
            int[][] dp = new int[alen + 1][blen + 1];

            for (int i = 0; i < alen + 1; i++) {
                dp[i][0] = i;
            }

            for (int j = 0; j < blen + 1; j++) {
                dp[0][j] = j;
            }

            for (int i = 1; i < alen + 1; i++) {
                for (int j = 1; j < blen + 1; j++) {
                    dp[i][j] = Math.min(dp[i][j - 1] + 1, dp[i - 1][j] + 1);

                    if (a.charAt(i - 1) == b.charAt(j - 1)) {
                        dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]);
                    } else {
                        dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + 1);
                    }
                }
            }

            return dp[alen][blen];
        }

    }
}




Measured memory_bytes: 31592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    map<string,ll> m;
    while(n--){
    	string s;
    	cin>>s;
    	sort(s.begin(),s.end());
    	m[s]++;
    }
    map<string,ll>::iterator itr;
    ll count_pair = 0;
    for(itr = m.begin();itr!=m.end();itr++){
    	ll temp = itr->ss;
    	count_pair+= (temp*(temp-1))/2;
    }
    cout<<count_pair<<endl;
    return 0;
}


Measured memory_bytes: 11264
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n,m;

int main(){
	cin >> n >> m;
	int puiss=1;
	for(int i=0;i<m;i++) puiss*=2;
	
	cout << ((n-m)*100+m*1900)*puiss << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int k,x; cin >> k >> x;
    int left = (x-k+1>-1000000 ? x-k+1 : -1000000);
    int right = (x+k-1<1000000 ? x+k-1 : 1000000);
    for(int i = left; i <= right; ++i) {
        if(i==right) cout << i << endl;
        else cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 384
n = int(input())
s = input()
x = int(s, 2)
pcx = s.count("1")
pc1 = x % (pcx - 1) if pcx > 1 else 0
pc2 = x % (pcx + 1)

def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

for i, y in enumerate(s):
    k = n - 1 - i
    if y == "0":
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)



Measured memory_bytes: 9504
import math

n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
#s = int(input())
#list = list(s)

#print(n, m)
#print(table)
#print(light)

p = 0.0

for i in range(n):
    j = i + 1
    if (j < k) :
        p += 2 ** ( - math.ceil( math.log2(k / j) ) )
    else :
        p += 1
p = p / n

print(p)


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

#define int long long

const int MAXN = 1;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n;
int ans;

signed main () {
	cin >> n;
	while(n >= 500) ans += 1000,n -= 500;
	ans += n / 5 * 5;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
	int n=read();long long ans=1;
	for(int i=1;i<=n;i++)ans=ans*i%1000000007;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <queue>

using namespace std;
const int maxn = 200005;
int r,c,n,tot,stk[maxn],top,ins[maxn];
struct node {int x,y,i,l;}p[maxn];
int ask(int x,int y) {
	if (x==0) return 1;
	if (y==c) return 2;
	if (x==r) return 3;
	if (y==0) return 4;
	return 0;
}
bool comp(node a,node b) {
	if (a.l!=b.l) return a.l<b.l;
	if (a.l==1) return a.y<b.y;
	if (a.l==2) return a.x<b.x;
	if (a.l==3) return a.y>b.y;
	return a.x>b.x;
}

int main()
{
	#ifdef LOCAL_JUDGE
		freopen("connected.in","r",stdin);
		freopen("connected.out","w",stdout);
	#endif
	scanf("%d %d %d",&r,&c,&n);
	for (int i=1;i<=n;i++)
	{
		int x1,y1,l1;scanf("%d %d",&x1,&y1);l1=ask(x1,y1);
		int x2,y2,l2;scanf("%d %d",&x2,&y2);l2=ask(x2,y2);
		if (l1&&l2)
			p[++tot]=(node){x1,y1,i,l1},
			p[++tot]=(node){x2,y2,i,l2};
	}
	sort(p+1,p+tot+1,comp);
	for (int v,i=1;i<=tot;i++)
	if (!ins[v=p[i].i]) stk[++top]=v,ins[v]=1;
	else {
		if (stk[top]!=v) {printf("NO");return 0;}
		top--;
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

int n;
string s;
int nx[500005];
int dp[500005];

int main(void)
{
	cin >> n;
	cin >> s;
	s = "#" + s;
	s += "0";
	
	int cnt = 0;
	for(int i = 1; i <= n; i++) if(s[i] == '1') cnt++;
	
	for(int i = n; i >= 1; i--){
		nx[i] = nx[i+1];
		if(s[i+1] == '0') nx[i] = i+1;
	}
	for(int i = 1; i <= n; i++) dp[i] = 1e9;
	for(int i = 1; i <= n; i++){
		if(s[i] == '0'){
			dp[i] = min(dp[i], dp[i-1]);
			continue;
		}
		dp[i] = min(dp[i], dp[i-1]+1);
		if(nx[i] < n+1 && s[nx[i]+1] == '1') dp[nx[i]+1] = min(dp[nx[i]+1], dp[i-1]+1);
		if(i < n && s[i+1] == '0'){
			if(nx[i+1] >= i+3) dp[nx[i+1]-1] = min(dp[nx[i+1]-1], dp[i-1]+1);
			if(nx[i+1] >= i+4) dp[nx[i+1]-2] = min(dp[nx[i+1]-2], dp[i-1]+1);
		}
	}
	cout << cnt - dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N+1);
    repr(i, 1, N+1) cin >> a[i];

    vector<vector<int>> fi(H+1, vector<int>(W+1, 0));
    int color = 1;

    repr(i, 1, H+1){
        if(i%2 == 1){
            repr(j, 1, W+1){
                fi[i][j] = color;
                a[color]--;
                if(a[color] == 0) ++color;
            }
        }
        else{
            reprrev(j, 1, W+1){
                fi[i][j] = color;
                a[color]--;
                if(a[color] == 0) ++color;
            }
        }
    }


    repr(i, 1, H+1){
        repr(j, 1, W+1){
            if(j != 1) cout << ' ';
            cout << fi[i][j];
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int dig = ceil(log10(N + 1));
  int ans = 0;
  for (int i = 1; i < dig; i += 2) {
    ans += 9 * pow(10, i - 1);
  }
  if (dig % 2 == 1)
    ans += N - pow(10, dig - 1) + 1;
  cout << ans << "\n";
  // print();
}

Measured memory_bytes: 512