akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

vector<vector<int>> graph;
set<P> st;


int main(){
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  int mx = (n - 1) * (n - 2) / 2;
  if (mx < k) {
    puts("-1");
    return 0;
  }
  vector<P> ans;
  rep(i, n - 1) {
    ans.emplace_back(i + 1, n);
  }
  vector<P> edge;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      edge.emplace_back(i + 1, j + 1);
    }
  }
  int add = mx - k;
  rep(i, add) {
    ans.push_back(edge[i]);
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i].first << ' ' << ans[i].second << endl;


}

Measured memory_bytes: 384
def piyo():
    s = list(str(input()))
    c = 0
    a = 0
    if s[0]!="A":
        return "WA"
    if s[1]=="C" or s[len(s)-1]=="C":
        return "WA"
    for hage in s:
        if hage!="A" and hage!="C":
            if hage.isupper():
                return "WA"
        if hage=="C":
            c+=1
        if hage=="A":
            a+=1
    if c>1 or c==0:
        return "WA"
    if a>1:
        return "WA"
    return "AC"
        
if __name__ == '__main__':
    hoge=piyo()
    print(hoge)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = as.nextInt();
		int[] a;
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(as.next());
		}
		int l=0;
		for(int i=0;i<n;i++){
			if(a[i]%2==1){
				l++;
			}
		}
		if(l%2==0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 31904
class Edge
  attr_accessor :dest, :weight
  def initialize dest, weight
    @dest = dest
    @weight = weight
  end
end


class Graph
  def initialize n
    @n = n + 1
    @adjenceList = []
    @n.times do |i|
      @adjenceList[i] = []
    end
  end

  def addEdge i, j, weight
    edge1 = Edge.new j, weight
    @adjenceList[i] << edge1

    edge2 = Edge.new i, weight
    @adjenceList[j] << edge2
  end

  def menboku
    kiten_count = 0
    @n.times do |i|
      is_kiten = @adjenceList[i].length % 2 == 1
      if is_kiten
        kiten_count += 1
      end
    end

    start_count =  @adjenceList[0].length
    goal_count = @adjenceList[1].length

    if (kiten_count == 2 && start_count % 2 == 1 && goal_count % 2 == 1)
      puts "OK"
    else
      puts "NG"
    end
  end
end

data_set = {}
STDIN.each_line {|line|
  n_m = line.split " "
  n = n_m[0].to_i
  n -= 1
  m = n_m[1].to_i
  m -= 1

  if n == -1 && m == -1
      # 出力
      graph = Graph.new 100
      data_set.each do | key , val |
        val.each do |vertex|
          graph.addEdge key, vertex, 0
        end
      end

      graph.menboku
      data_set.clear
  else
      if !data_set.has_key? n
        data_set[n] = []
      end
      data_set[n] << m
      last = m
  end
}



Measured memory_bytes: 6872
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n;
int v[101] = {0};

int num(int a){
	int cnt = 0;
	for(int i = 2; i <= n; i++){
		if(v[i] >= a-1) cnt++;
	}
	return cnt;
}

int main(){
	cin >> n;
	
	for(int i = 2; i <= n; i++){
		int cnt = i;
		for(int j = 2; j <= i; j++){
			while(cnt % j == 0){
				cnt /= j;
				v[j]++;
			}
		}
	}
	
	cout << num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)/2 << endl;
	
	return 0;
}

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

int main() {
  int n,m; cin >> n >> m;
  vector<vector<int>> g(n+1, vector<int>());
  rep(i,m) {
    int a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  const int NIL = 1e9;
  vector<int> ed(n+1,NIL);
  int ans = 0;
  for (int x = 1; x<n+1; x++) {
    if (ed[x] != NIL) continue;
    ed[x] = x;
    stack<int> S;
    S.push(x);
    while(!S.empty()) {
      int u = S.top(); S.pop();
      rep(i,g[u].size()) {
        int v = g[u][i];
        if (ed[v] == NIL) {
          ed[v] = x;
          S.push(v);
        }
      }
    }
  }
  map<int,int> ma;
  rep(i,n+1) {
    if (ed[i] == NIL) continue;
    ma[ed[i]]++;
  }
  for (auto a : ma) ans = max(ans,a.second);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17936
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def main():
    N = NI()


    def num_divisors_table(n):
        table = [0] * (n + 1)

        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1

        return table
    D = num_divisors_table(N)
    ans = 0
    for i in range(1, N+1):
        ans += D[i] * i
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 146596
import sys
X, N = map(int, input().split())
if N==0:
    tmp = input()
    print(X)
    sys.exit(0)

p = list(map(int, input().split()))
tmp = 10**9
ans = 0
for i in range(-1, 102):
    if i not in p:
        if tmp > abs(i-X):
            ans = i
            tmp = abs(i-X)
print(ans)

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

int main() {
    std::vector<long long int> v(100010, 0);
    long long int n,k;
    std::cin >> n >> k;

    long long int a,b;
    for (long long int i = 0; i < n; i++) {
        std::cin >> a >> b;
        v[a] += b;
    }

    for (long long int i = 1; i < 100001; i++) {
        k -= v[i];
        if (k <= 0) {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
using namespace std;
 
int main()
{
	int n, m;
 
	vector<int> vec;
 
	cin >> n >> m;
 
	for (int i = 0; i < m; ++i)
	{
		vec.emplace_back();
		cin >> vec.back();
	}
 
	int sum = 0;
	for (const auto& v : vec)
		sum += v;
 
	int ans = n - sum;
	if (ans < 0)
		ans = -1;
 
	cout << ans << "\n";
 
	return 0;
}

Measured memory_bytes: 3648
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  x=sorted(list(map(int,input().split())))
  if n>=m:
    print(0)
  else:
    y=sorted([x[i]-x[i-1] for i in range(1,m)])
    ans=x[-1]-x[0]-sum(y[m-n:])
    print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 13956
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  if res==1:
    if a==0:
      res=0
    elif a%2==0:
      ans+=a//2
      res=1
    else:
      ans+=(a+1)//2
      res=0
  else:
    ans+=a//2
    if a%2==1:
      res=1
print(ans)


Measured memory_bytes: 3060
n = gets.to_i
def get(a)
  puts a
  STDOUT.flush
  case gets[0]
  when ?V
    exit
  when ?M
    0
  when ?F
    1
  else
    raise
  end
end
l = 0
r = n-1
m = p
sl = get l
sr = get r
sm = p
while true do
  m = (l + r) / 2
  sm = get m
  if ((m-l)%2 == 0) ^ (sm == sl)
    r = m
    sr = sm
  else
    l = m
    sl = sm
  end
end

Measured memory_bytes: 4432
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		sc.close();
		char before = S[0];
		int ans = 0;
		for(int i = 1; i < S.length; i++) {
			boolean ok = false;
			char s = S[i];
			if((before == '0' && s == '1')
				|| (before == '1' && s == '0')) {
				ok = true;
			} else {
				s = before == '0' ? '1' : '0';
			}
			before = s;
			if(!ok) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	int len = s.length();

	for (int i = 0;i < len;i += 2) {
		cout << s[i];
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<char> c(N);
    ll n_r = 0, n_w = 0;
    ll ans = 0;
    rep(0, i, N)
    {
        cin >> c.at(i);
        if (c.at(i) == 'R')
        {
            n_r++;
        }
        else
        {
            n_w++;
        }
    }
    rep(0, i, n_r)
    {
        if (c.at(i) == 'W')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using P = pair<ll, int>;

const int SIZE = 200005;
int par[SIZE];
int r[SIZE];

void init (int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		r[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 (r[x] < r[y]) {
		par[x] = y;
    } else {
		par[y] = x;
		if (r[x] == r[y]) r[x]++;
    }
}

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

struct edge {int u, v; ll cost;};
bool comp(const edge&  e1, const edge& e2) {
	return e1.cost < e2.cost;
}

edge es[SIZE];
int V, E;
ll kruscal() {
	sort(es, es + E, comp);
	init(V + 1);
	ll res = 0;
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}


int main() {
	int N;
	cin >> N;
	P x[SIZE], y[SIZE];
	for (int i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		x[i] = P(a, i);
		y[i] = P(b, i);
	}
	//sort(x.begin(), x.end());
	//sort(y.begin(), y.end());
	sort(x, x + N);
	sort(y, y + N);

	E = 0;
	V = N;
	for (int i = 0; i < N - 1; i++) {
		ll a = x[i].first;
		ll b = x[i + 1].first;
		int n = x[i].second;
		int m = x[i + 1].second;

		es[E++] = (edge){n, m, b - a};
	}
	for (int i = 0; i < N - 1; i++) {
		ll a = y[i].first;
		ll b = y[i + 1].first;
		int n = y[i].second;
		int m = y[i + 1].second;

		es[E++] = (edge){n, m, b - a};
	}

	ll res = kruscal();
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, now = 1;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a.at(i);
    ll ans = 0;
    rep(i, 60){
        ll z = 0, o = 0;
        rep(j, n){
            if(a.at(j) & (1LL << i))o++;
            else z++;
        }
        ans += (((1LL<<i) % mod)*(z%mod))%mod*(o%mod)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

set<int> adjl[100005];
vector<int> orig[100005];
int p[100005];
bool removed[100005];

void dfs(int node,int parent){
    for (int x : orig[node]){
        if (x==parent) continue;
        adjl[node].insert(x);
        p[x] = node;
        dfs(x,node);
    }
}


int main(){
int n;
scanf("%d",&n);
for (int x = 0; x<n-1; x++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    orig[a].push_back(b);
    orig[b].push_back(a);
}
if (n==2){
    printf("Second");
    return 0;
}
int root = -1;
for (int x = 0; x<n; x++){
    if (orig[x].size()>1){
        root = x;
    }
}
p[root] = -1;
dfs(root,-1);
queue<int> q;
for (int x = 0; x<n; x++){
    if (adjl[x].size()==0){
        if (p[x]!=-1 && adjl[p[x]].size()==1){
            if (p[x]!=root)
                q.push(x);
        }
    }
}
while (!q.empty()){
    int node = q.front();
    q.pop();
    removed[node] = true;
    removed[p[node]] = true;
    if (p[p[node]]!=-1){
        adjl[p[p[node]]].erase(p[node]);
        if (adjl[p[p[node]]].size()==0){
            if (p[p[p[node]]]!=-1 && adjl[p[p[p[node]]]].size()==1){
                if (p[p[p[node]]]!=root)
                    q.push(p[p[node]]);
            }
        }
        else if (adjl[p[p[node]]].size()==1){
            int consider = *(adjl[p[p[node]]].begin());
            if (adjl[consider].size()==0){
                if (p[p[node]]!=root)
                    q.push(consider);
            }
        }
    }

}

for (int x = 0; x<n; x++){
    if (removed[x]) continue;
    int num1 = 0;
    for (int y : adjl[x]){
        if (adjl[y].size()==0) num1++;
    }
    if (num1>1){
        printf("First");
        return 0;
    }
}
if (adjl[root].size()==0){
    printf("First");
}
else{
    printf("Second");
}
}


Measured memory_bytes: 15744
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N, K; cin >> N >> K;
	vector<int> h(N); rep(i, 0, N)cin >> h[i];
	vector<lli> dp(N,MOD); dp[0] = 0;

	rep(i, 0, N) {
		rep(k, 1, K + 1) {
			if (i + k < N) { 
				dp[i + k] = (dp[i + k] < (dp[i] + abs(h[i + k] - h[i]))) ? dp[i + k] : (dp[i] + abs(h[i + k] - h[i]));
			}
		}
		//cout << i << " " << dp[N - 1] << endl;
	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 1536
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);

#ifdef BUGGY
	bool DEBUG = 1;
#endif
#ifndef BUGGY
	bool DEBUG = 0;
#endif

int nodes, qws;
int freq[200000];

int main()
{
	scanf("%d %d", &nodes, &qws);

	for(int i = 0; i < qws; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		freq[x]++;
		freq[y]++;
	}

	for(int i = 0; i <= nodes; i++)
	{
		if(freq[i] % 2 == 1)
		{
			printf("NO\n");
			return 0;
		}
	}

	printf("YES\n");

	return 0;
}
/*
	Powered by Buggy Plugin
*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int dx = x2-x1;
    int dy = y2-y1;
    cout<<x2-dy<<' '<<y2+dx<<' '<<x1-dy<<' '<<y1+dx;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n";
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int a[7];
	int ans;
	for(int i=1;i<=5;i++)
	{
		cin>>a[i];
		if(a[i]==0)
			ans=i;
	}
	cout<<ans<<endl;

	
	
}

Measured memory_bytes: 3640
#pragma GCC diagnostic ignored "-Wunused-result"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e6 + 34;
//const ll INF = (ll)1e18 + 41;
const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;
bool D = false;

void solve() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll g = __gcd(n, m);

	for (int i = 0; i < g; i++) {
		if (s[n / g * i] != t[m / g * i]) {
			cout << "-1\n";
			return;
		}
	}

	cout << n * m / g << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tst = 1;
	//scanf("%d", &tst);
	//cin >> tst;
#ifdef MADE_BY_SERT
	D = true;	
	tst = 3;
	while (tst--) {
		solve();
	}
#else
	while (tst--) solve();
#endif
}


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

using namespace std;
struct UnionFind {
	vector<long long> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(long long N) : par(N) { //最初は全てが根であるとして初期化
		for (long long i = 0; i < N; i++) par[i] = -1;
	}

	long long root(long long x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] < 0) return x;
		return par[x] = root(par[x]);
	}

	void unite(long long x, long long y) { // xとyの木を併合
		long long rx = root(x); //xの根をrx
		long long ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[ry] += par[rx];
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	bool same(long long x, long long y) {
		long long rx = root(x);
		long long ry = root(y);
		return rx == ry;
	}
	long long size(long long x) {
		return -par[root(x)];
	}
};

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> E(M);
	for (long long i = 0; i < M; i++) cin >> E[i].first >> E[i].second;
	vector<long long> Ans(M);
	UnionFind Nums(N);
	Ans[M - 1] = N * (N - 1) / 2;
	for (long long i = M - 1; i >= 1; i--) {
		long long a = E[i].first, b = E[i].second;
		Ans[i - 1] = Ans[i];
		if (!Nums.same(a - 1, b - 1)) {
			Ans[i - 1] -= Nums.size(a - 1) * Nums.size(b - 1);
			Nums.unite(a - 1, b - 1);
		}
	}
	for (long long a : Ans) cout << a << endl;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, A;
  cin >> X >> A;
  if (X < A) {
    cout << "0\n";
  } else {
    cout << "10\n";
  }
  return 0;
}

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

ac=[0]*N
score=[]

for q in range(Q):
    ac[int(input())-1]+=1


for n in range(N):
    score.append(K-Q+ac[n])

for s in score:
    if s > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 81800
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

using Graph = vector<vector<int>>;

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

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

  V path;
  vector<bool> chosen(N, false);
  path.push_back(0);
  chosen[0] = true;

  bool next = true;
  while (next) {
    next = false;
    for (auto e : G[path.back()]) {
      if (!chosen[e]) {
        path.push_back(e);
        chosen[e] = true;
        next = true;
        break;
      }
    }
  }

  reverse(all(path));
  
  next = true;
  while (next) {
    next = false;
    for (auto e : G[path.back()]) {
      if (!chosen[e]) {
        path.push_back(e);
        chosen[e] = true;
        next = true;
        break;
      }
    }
  }

  cout << path.size() << endl;
  for (auto e : path) {
    cout << (e+1) << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6776
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;

int group(int n){
    if(n==2)
        return 2;
    else if(n==4 || n==6 || n==9 || n==11)
        return 1;
    else
        return 0;

}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    string s;
    cin >> s;
    string ans;
    repeat(i, s.length()){
        if(s[i] == '0'){
            ans+='0';
        }
        else if(s[i] == '1'){
            ans+='1';
        }
        else if(!ans.empty()){
            ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

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

  ll ans = hh * ww - h * ww - hh * w + h * w;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NitroBoost \
        ios_base::sync_with_stdio(false); \
        cin.tie(NULL);
#define ll long long
#define fori(i,l,n) for(int i=l;i<n;i++)
#define ford(i,n,l) for(int i=n;i>l;i--)
#define All(i,x) for(auto i=x.begin();i!=x.end();++i)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define test int t;cin>>t;while(t--)
#define pb(i) push_back(i)
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n"
#define str(n) to_string(n)
#define fi first
#define sec second
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
const double pi=3.141592653589793;
const int MOD=1e9+7;
ll power(ll x, ll y, ll m) 
{
     ll res = 1;x %= m;
    while (y > 0) {
        if (y & 1)
        res = (res*x) % m;
        y>>=1;
        x = (x*x) % m;
    }
    return res%m;
}
int look[100001];
int dp(int a[],int n){
    if(n<=0)
    return 0;
    if(look[n]==-1){
        if(n==1)
        look[n]=abs(a[1]-a[0]);
        else 
        look[n]=min(dp(a,n-1)+abs(a[n]-a[n-1]),dp(a,n-2)+abs(a[n]-a[n-2]));
    }
    return look[n];
}
void solve(){
    fori(i,0,100001)
    look[i]=-1;
    int n;
    cin>>n;
    int a[n];    
    fori(i,0,n)
    cin>>a[i];
    cout<<dp(a,n-1);
}
int main(){  
    NitroBoost
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //test
    {
        solve();
    }
    return 0;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) ans += (s[i] == t[i]);
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n,m; cin>>n>>m;
	vector<string> v(n);
	rep(i,n) cin>>v[i];
	sort(all(v));
	for(auto x:v) cout<<x;
}

Measured memory_bytes: 3604
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    for (int i = 0; i < n-1; ++i) cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i < n-1; ++i) {
        ll nowT = 0ll;
        nowT = s[i]+c[i];
        for (int j = i+1; j < n-1; ++j) {
            if(nowT <= s[j]) nowT = s[j];
            else {
                int y = nowT/f[j];
                if (nowT%f[j] == 0) nowT = (f[j]*y);
                else nowT = f[j]*(y+1);
            }
            nowT+=c[j];
        }
        cout << nowT << std::endl;
    }
    cout << 0 << std::endl;
    return 0;
}

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

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

int main(int argc, char const *argv[]) {
    int k;
    cin >> k;

    int sum = 0;
    for (size_t i = 1; i <= k; i++) {
        for (size_t j = 1; j <= k; j++) {
            for (size_t m = 1; m <= k; m++) {
                sum += gcd(gcd(i, j), m);
            }
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>

#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
 int main(){
   
    ios::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
   
   
long long n,arr[1000000],brr[1000000];
       cin >> n;
  
       for(long long i=0;i<n-1;i++){
        cin >> arr[i];
        
       }
       for(long long i=0;i<n;i++){
       brr[i]=0;
        
       }

       for(long long i=0;i<n-1;i++){
        brr[arr[i]-1]++;
       }
       for(long long i=0;i<n-1;i++){
        cout << brr[i]<<"\n";
        if(i==n-2)
          break;
       }
   cout << brr[n-1];
   return 0;
}

Measured memory_bytes: 6304
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(char c: s) {
        if (c == 'R')
            cnt += 1;
        else
            cnt -= 1;
    }
    if (cnt > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;int main(){int n;cin>>n;cout<<n<<":";for(int i=2;i<sqrt(n)+1;i++){while(1){if(n%i!=0)break;n/=i;cout<<" "<<i;}}if(n!=1)cout<<" "<<n;cout<<endl;return 0;}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main() {
    int a,b,c,t,s;
    cin>>a>>b>>c;
    t=a;
    s=0;
    while(t <= b){
        if(c%t == 0){
            s++;}
        t++;
    }
    cout<<s<<endl;
    return 0;
}

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

int A[4];
string s;

bool solve() {
    cin >> s;
    for (char c : s) {
        if (c == 'N') A[0]++;
        if (c == 'S') A[1]++;
        if (c == 'W') A[2]++;
        if (c == 'E') A[3]++;
    }
    if (A[0] > 0 && A[1] == 0) return false;
    if (A[1] > 0 && A[0] == 0) return false;
    if (A[2] > 0 && A[3] == 0) return false;
    if (A[3] > 0 && A[2] == 0) return false;
    return true;
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
C=['.'*(W+2)]+['.'+input()+'.'for _ in[0]*H]+['.'*(W+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if C[i][j]=='#'and'#'not in[C[i-1][j], C[i][j-1], C[i][j+1], C[i+1][j]]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
	string a, b;
	cin >> a >> b;
	
	if (a.length() > b.length()) {
		cout << "GREATER" << "\n";
		return 0;
	}
	
	else if (a.length() < b.length()) {
		cout << "LESS" << "\n";
		return 0;
	}
	
	int num, num1;
	for (int i = 0; i < a.size(); i++) {
		num = a[i] - '0';
		num1 = b[i] - '0';
		
		if (num > num1) {
			cout << "GREATER" << "\n";
			return 0;
		}
		
		else if (num < num1) {
			cout << "LESS" << "\n";
			return 0;
		}
	}
	
	cout << "EQUAL" << "\n";
 
	
	return 0;
} 


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

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

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}



int main(void){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
    B[A[i]] = i;
  }
  ll ans = 0;
  set<ll> S;
  S.insert(-1);
  S.insert(N);
  rep(i, N){
    ll pos = B[i];
    auto right = S.lower_bound(pos);
    auto left = right;
    left--;
    ll l = *left;
    ll r = *right;
    ans += (i+1) * (pos-l) * (r-pos);
    S.insert(pos);
  }
  cout << ans << endl;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i]=='?')s[i]='D';
  }
  cout << s << endl;
}

Measured memory_bytes: 3756
use text_io::*;
use std::collections::HashMap;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut c:usize = read!();
    let mut k:usize = read!();
    let mut n:usize = 0;
    while a>=b {
        b *= 2;
        n += 1;
    }
    while b>=c {
        c *= 2;
        n += 1;
    }
    if k >= n {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

Measured memory_bytes: 2132
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int[] changeCount = new int[n];
        int[] revCount = new int[n];
        for (int i = 1; i < s.Length; i++)
        {
            changeCount[i] = changeCount[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
        }
        for (int i = s.Length - 2; i >= 0; i--)
        {
            revCount[i] = revCount[i + 1] + (s[i + 1] == 'E' ? 1 : 0);
        }
        var cost = changeCount.Zip(revCount, (x, y) => x + y).ToArray();
        Console.WriteLine(cost.Min());
    }
}

Measured memory_bytes: 19040
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------    
    ll x,y;cin>>x>>y;
    if(x%y==0){
        cout<<-1<<endl;
    }
    else cout<<x<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------











































Measured memory_bytes: 3692
N = int(input())
a = list(map(int, input().split()))
color = [0 for _ in range(9)]
for item in a:
    if item <= 399:
        color[0] = True
    elif 400 <= item <= 799:
        color[1] = True
    elif 800 <= item <= 1199:
        color[2] = True
    elif 1200 <= item <= 1599:
        color[3] = True
    elif 1600 <= item <= 1999:
        color[4] = True
    elif 2000 <= item <= 2399:
        color[5] = True
    elif 2400 <= item <= 2799:
        color[6] = True
    elif 2800 <= item <= 3199:
        color[7] = True
    else:
        color[8] += 1

m = color[:8].count(True)
M = m + color[8]
if m:
    print(m, M)
else:
    print(1, M)


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


int main(){
    int h, w;
    cin >> h >> w;
    vector<int> a(26);
    rep(i, h*w){
        char c; cin >> c;
        a[c-'a']++;
    }
    int p = 0, q = 0;
    rep(i, 26){
        if (a[i]%4 > 0) q++;
        if (a[i]%2 > 0) p++;
    }
    int mx = ((h%2) * w + (w%2) * h) / 2;
    if (p <= 1 && q <= mx) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  
  ll copy = a;
  a = a - min(a, k);
  b = b - min(b, k-min(copy, k));
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import copy
n=int(input())
ab = []
for _ in range(n):
    s=input()
    ab.append(s)

for i in range(n-1):
    if ab[i][-1] != ab[i+1][0]:
        print('No')
        exit()

cp = copy.copy(ab)

cp = list(set(cp))

if len(ab) == len(cp):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
ans=[]
anscnt=0
for i in range(n-1,-1,-1):
    ai=a[i]
    j=2*(i+1)-1
    while n>j:
        ai^=b[j]
        j+=i+1
    if ai==1:
        b[i]=1
        ans.append(i+1)
        anscnt+=1
print(anscnt)
if anscnt>0:
    ans.reverse()
    print(*ans)

Measured memory_bytes: 14108
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 100005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
char s[MN];
int x[MN],y[MN],b[MN];
int n,tot,cnt;
bool a[MN];
int main()
{
	scanf("%s",s);n=strlen(s);
	for (int i=1;i<=n;++i) a[i]=s[i-1]-'0'; 
	for (int i=1;i<=n-i;++i)
	if (a[i]^a[n-i]) {printf("-1");return 0;}
	if ((!a[1])||a[n]) {printf("-1");return 0;}
	for (int i=1;i<=n;++i) if (a[i]) b[++tot]=i;
	for (int i=2;i<=tot;++i){
		x[++cnt]=b[i-1];y[cnt]=b[i];
		for (int j=b[i-1]+1;j<b[i];++j)
		x[++cnt]=j,y[cnt]=b[i];
	}if (b[tot]!=n-1) {printf("-1");return 0;}
	for (int i=1;i<=cnt;++i)
	printf("%d %d\n",x[i],y[i]);
	printf("%d %d\n",n-1,n);return 0;
}

Measured memory_bytes: 2688
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

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

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

    int N;
    cin >> N;
    vector<int> A, B;
    int in;
    rep(_, N) {
        cin >> in;
        A.push_back(in);
        B.push_back(in);
    }

    int Bcnt = 0;

    for (int i = N; i > 0; i--) {
        int j = 2;
        while (i * j <= N) {
            B[i-1] ^= B[i*j-1];
            j++;
        }

        if (B[i-1] == 1) Bcnt++;
    }

    prints(Bcnt);

    rep(i, N) {
        if (B[i] == 1) {
            cout << i+1 << " ";
        }
    }
    cout << endl;

    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll K;
    cin >> K;
    ll n = 7;
    rep(i, K + 1) {
        if (n % K == 0) {
            cout << i + 1 << '\n';
            return;
        }
        n = n * 10 + 7;
        n %= K;
    }
    cout << -1 << '\n';
}

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


Measured memory_bytes: 3652
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
int main()
{
	int a, b;
		cin >> a >> b;
	cout << a-b+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N];
vector <ll> v[105];
vector <ll> num;
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
int main()
{
    fast;
    ll n; double maxx = -1;
    cin >> n;
    for(int i = 1; i <= 1009; i ++){
        for(int j = 2; j <= 1009; j ++){
            double k = pow(i, j);
            if(k <= n){
                maxx = max(k, maxx);
            }
            else break;
        }
    }
    cout << maxx;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    #define out(a) cout<<a<<" "
    #define all(a) (a).begin(), (a).end()
    #define upper_index(v, a) (int)distance(v.begin(), upper_bound((v).begin(), (v).end(), a))
    #define lower_index(v, a) (int)distance(v.begin(), lower_bound((v).begin(), (v).end(), a))
    typedef long long ll;
    const long long INF = 1e17;
     
    int main() {
        ll n,k;
        cin>>n>>k;
        ll a=0,b=0;
        for(int i=1;i<=n;++i){
            if (i%k==0) ++a;
            if (i%k==k/2) ++b;
        }
        a=a*a*a;
        b=b*b*b;
        if (k%2==0){
            cout<<a+b<<endl;
        }else{
            cout<<a<<endl;
        }
    }

Measured memory_bytes: 256