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

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

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

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

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

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

    ($next:expr, 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_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      mut aa: [i64; n],
    }
    aa.sort();
    if aa.len() == 2 {
        println!("{}", aa[1] - aa[0]);
        println!("{} {}", aa[1], aa[0]);
        return;
    }
    let mut r = aa[n-1];
    let mut l = aa[0];
    let mut cmd = vec![];
    for i in 1..n-1 {
        if aa[i] >= 0 {
            cmd.push((l, aa[i]));
            l -= aa[i];
        } else {
            cmd.push((r, aa[i]));
            r -= aa[i];
        }
    }
    cmd.push((r, l));
    r -= l;
    println!("{}", r);
    for (a, b) in cmd {
        println!("{} {}", a, b);
    }
}


Measured memory_bytes: 10108
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()

count = 0
for i in range(N-2):
    for q in range(i+1,N-1):
        for r in range(q+1, N):
            # print(L[i],L[q],L[r])
            if L[i] == L[q] or L[q]==L[r] or L[r]==L[i]:
                continue
            if L[i]+L[q]>L[r] and L[q]+L[r]>L[i] and L[r]+L[i]>L[q]:
                count += 1
                # print(i+1,q+1,r+1)
            # if L[q]+L[r]>L[i]:
            #     count += 1
            # if L[r]+L[i]>L[q]:
            #     count += 1
print(count)
    
        


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,suwa[100000] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		int l,r;
		cin >> l >> r;
		for(int j = l - 1;j < r;j++) suwa[j]++;
	}
	int cnt = 0;
	for(int i = 0;i < 100000;i++) if(suwa[i]) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
b = []
c = []
d = []
while True:
    a = input().split()
    a[0] = int(a[0])
    a[1] = int(a[1])
    if a[0] == 0 and a[1] == 0:
        break
    elif a[1]%2 == 0:
        b.append("#."*(a[1]//2)+"#")
        c.append((a[0],a[1]))
    else:
        b.append("#."*(a[1]//2)+"#.")
        c.append((a[0],a[1]))
for i in range(len(c)):
    if c[i][0]%2 == 0:
        for j in range(c[i][0]//2):
            print(b[i][0:-1])
            print(b[i][1:])
    else:
        for j in range(c[i][0]//2):
            print(b[i][0:-1])
            print(b[i][1:])
        print(b[i][0:-1])
    print("\n",end="")


Measured memory_bytes: 5640
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        var hm = new HashMap<Integer, Integer>();
        var wm = new HashMap<Integer, Integer>();
        var mm = new HashSet<String>();
        for (int i = 0; i < m; i++) {
            int hh = Integer.parseInt(sc.next());
            int ww = Integer.parseInt(sc.next());
            hm.merge(hh - 1, 1, Integer::sum);
            wm.merge(ww - 1, 1, Integer::sum);
            mm.add(hh + " " + ww);
        }
        long ans = 0;
        var ah = sortByValue(hm);
        var aw = sortByValue(wm);
        int maxh = 0;
        var listh = new ArrayList<Integer>();
        int maxw = 0;
        var listw = new ArrayList<Integer>();
        for (Map.Entry<Integer, Integer> e : ah.entrySet()) {
            int temp = e.getValue();
            if (temp < maxh) {
                break;
            }
            maxh = temp;
            listh.add(e.getKey());
        }
        for (Map.Entry<Integer, Integer> e : aw.entrySet()) {
            int temp = e.getValue();
            if (temp < maxw) {
                break;
            }
            maxw = temp;
            listw.add(e.getKey());
        }
        for (int i = 0; i < listh.size(); i++) {
            for (int j = 0; j < listw.size(); j++) {
                if (!mm.contains((listh.get(i) + 1) + " " + (listw.get(j) + 1))) {
                    System.out.println(maxh + maxw);
                    return;
                }
            }
        }
        System.out.println(maxh + maxw - 1);
    }

    public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
        return map.entrySet().stream()
                .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
                        (oldValue, newValue) -> oldValue, LinkedHashMap::new));
    }
}

Measured memory_bytes: 173960
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int arg_min(vector<int> a){
    int minval=10000000;
    for (int i=0;i<a.size(); i++){
        if (minval > a[i]){
            minval = a[i];
        }
    }

    int min_arg;
    for (int i=0;i<a.size(); i++){
        if(a[i]==minval){
            min_arg = i;
            break;
        }
    }

    return min_arg;
}

int main(){
    vector<int> a(5);
    for (int i=0; i<5; i++){
        cin >> a[i];
    }

    vector<int> b(5);
    for (int i=0; i<5; i++){
        if(a[i] % 10 == 0){
            b[i] = 10;
        }else{
            b[i] = a[i]%10;
        }
    }

    int index = arg_min(b);

    int ans = 0;

    for(int i=0; i<5; i++){
        if (i==index || a[i]%10==0){
            ans += a[i];
        }else{
            ans += (a[i]/10) * 10 + 10;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    string N;
    cin>>N;

    int len=N.size();
    ll r=0;

    for(ll i=0;i<len;i++){
        ll d=N[i]-'0';
        r=(r*10+d)%9;
    }
    if(r==0)
        cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 3768
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
S = [list(input()) for _ in range(h)]



def clear_maze(h, w, ch, cw, dh, dw, S):
    visited = [[-1] * w for _ in range(h)]
    visited[ch - 1][cw - 1] = 0
    queue = deque([[ch - 1 , cw - 1]])
    m_queue = deque([])
    while queue or m_queue:
        if queue:
            y, x = queue.popleft()
        else:
            n_y, n_x, y, x = m_queue.popleft()
            if visited[n_y][n_x] != -1:
                continue
            visited[n_y][n_x] = visited[y][x] + 1
            y, x = n_y, n_x
        if [y, x] == [dh - 1, dw - 1]:
            return visited[y][x]
        num = 0
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y = y + i
            n_x = x + j
            if n_y >= 0 and n_y < h and n_x >= 0 and n_x < w and S[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                visited[n_y][n_x] = visited[y][x]
                queue.append([n_y, n_x])
        for i in range(-2, 2 + 1):
            for j in range(-2, 2 + 1):
                if not [i, j] in ([1, 0], [-1, 0], [0, 0], [0, 1], [0, -1]):
                    n_y = y + i
                    n_x = x + j
                    if n_y >= 0 and n_y < h and n_x >= 0 and n_x < w and S[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                        m_queue.append([n_y, n_x, y, x])
    return -1

print(clear_maze(h, w, ch, cw, dh, dw, S))

Measured memory_bytes: 189852
s=input()

if len(s)==1:
    print(int(s))
else:
    def count(num):
        # basecase
        if len(num)==1:
            return 0
        else:
            a=0
            for j in range(1,len(num)):
                a+=int(num[:j])*2**(len(num[j:])-1)+int(num[j:])+count(num[j:])
            return a
    ans=int(s)+count(s)
    print(ans)


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

int main() {

    ll N;
    cin >> N;

    string s;
    vector<string> S;
    for (int i = 0; i < N; i++) {
        cin >> s;
        S.push_back(s);
    }

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

    vector<int> count(200010, 1);
    int max_count = 1;
    for (int i = 1; i < N; i++) {
        if (S[i] == S[i-1]) {
            count[i] = count[i-1] + 1;
            max_count = max(max_count, count[i]);
        }
    }

    for (int i = 0; i < N; i++) {
        if (count[i] == max_count) {
            cout << S[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 15728
def bubble_sort(a, n)
  flag = true
  cnt = 0
  while flag do
    flag = false
    (n-1).downto(1) do |j|
      if a[j] < a[j-1]
        t = a[j]
        a[j] = a[j-1]
        a[j-1] = t
        flag = true
        cnt += 1
      end
    end
  end
  [a, cnt]
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

a, num = bubble_sort(a, n)
puts a.join(" ")
puts num






Measured memory_bytes: 6868
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ret = 0
for i in range(n):
    left = min(a[i], b[i])
    b[i] -= left
    right = min(a[i + 1], b[i])
    a[i + 1] -= right
    ret += left + right
print(ret)

Measured memory_bytes: 18624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

char rep[100003];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) rep[i] = '*';
	string s;
	cout << 0 << endl;
	cin >> s;
	rep[0] = s[0];
	int res = 19;
	int lo = 0, hi = n;
	while (hi - lo > res) {
		int mid = lo + (hi - lo) / 2;
		cout << mid << endl;
		cin >> s;
		if (s[0] == 'V') return 0;
		rep[mid] = s[0];
		--res;
		if ((mid - lo)%2 == 1 && rep[mid] == rep[lo] || (mid - lo) % 2 == 0 && rep[mid] != rep[lo]) {
			hi = mid;
		}
		else {
			lo = mid;
		}
	}
	for (int i = lo; i < hi; ++i) cout << i << endl;
	return 0;
}


Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n,i,j;
    cin>>n;
    vector<ll>v(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<i;j++)
        {
            ll ab = v[i]+v[j];
            ll c = lower_bound(v.begin(),v.end(),ab)-v.begin();
            ll l = i+1;
            ans+=(c-l);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int top;
    static int[] s;

    static void push(int x) {
        s[++top] = x;
    }

    static int pop() {
        top--;
        return s[top + 1];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = new int[1000];
        while (sc.hasNext()) {
            String s = sc.next();
            char c = s.charAt(0);
            if (c == '+') {
                int k = pop();
                int k2 = pop();
                push(k2 + k);
            } else if (c == '-') {
                int k = pop();
                int k2 = pop();
                push(k2 - k);
            } else if (c == '*') {
                int k = pop();
                int k2 = pop();
                push(k2 * k);
            } else {
                push(Integer.parseInt(s));
            }

        }
        System.out.println(pop());
        sc.close();
    }
}


Measured memory_bytes: 26236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m; cin>>n>>m;
    ll ans=0;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            if(i>=n) ans=max(ans,m/i);
            if(m/i>=n) ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL gcd(LL a, LL b){
    if (!b) return a;
    return gcd(b,a%b);
}

LL N,a[100010],K;

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

    int i; LL gd=0,mx=0;
    for (i=1; i<=N; i++){
        cin >> a[i];
        mx=max(mx,a[i]);
        gd=gcd(a[i],gd);
    }


    if (K%gd || mx<K) cout << "IMPOSSIBLE\n";
    else cout << "POSSIBLE\n";
    return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int x = N * 800;
        int y = N / 15 * 200;
        System.out.println(x - y);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <algorithm>

int N, A[112345];
int ans;

int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }

	std::sort(A, A + N);
	for (int i = 0; i < N-1; ++i)
	{
		if (A[i] == A[i + 1])
		{
			++ans;
		}
	}
	ans = (ans % 2 == 0 ? N - ans : N - (ans + 1));

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;
#define F first
#define S second
int main() {
  int n;
  while(cin >> n,n) {
    set<pii> se;
    REP(i,n) {
      int x,y;
      cin >> x >> y;
      se.insert(pii(x,y));
    }
    int res = 0;
    FOR(it,se) {
      FOR (jt,se) {
        int vx = it->F - jt->F;
        int vy = it->S - jt->S;
        int s = vx*vx+vy*vy;
        if (s <= res) continue;
        if (se.count(pii(it->F-vy,it->S+vx)) && se.count(pii(jt->F-vy,jt->S+vx))) 
          res = s;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1004
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var a = xArray(1,n+1);
  var ans = 1;
  for(var i = 2; i <= n; i++){
    if(a[i] === 1){
      ans += i*2;
      for(var j = i+i; j <= n; j+=i){
        var t = j, s = 1;
        while(t % i === 0)t /= i, s++;
        a[j] *= s;
      }
    }else{
      ans += i*a[i];
    }
  }
  return ans;
}

Measured memory_bytes: 195636
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef pair<double, double> P;
const double EPS = 1e-4;

#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;

vector<P> center(P a, P b)
{
    auto t = atan2(b.second - a.second, b.first - a.first);
    auto x = hypot(a.first - b.first, a.second - b.second) / 2;
    auto y = sqrt(1.0 - x * x);
    auto cs = cos(t), sn = sin(t);
    return { 
        { cs * x - sn * y + a.first, sn * x + cs * y + a.second },
        { cs * x + sn * y + a.first, sn * x - cs * y + a.second }
    };
}

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        vector<P> pnt;
        loop (n, i) {
            double x, y; cin >> x >> y;
            pnt.emplace_back(x, y);
        }
        int ans = 1;
        loop (n, i) loop (n, j) {
            auto ps = center(pnt[i], pnt[j]);
            for (auto o : ps) {
                int cnt = 0;
                loop (n, l) {
                    auto x = o.first - pnt[l].first;
                    auto y = o.second - pnt[l].second;
                    if (x * x + y * y < 1 + EPS) cnt++;
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n;ll ans=1,cnt,res;
map<pll,int>mp,mp2;vi v;
map<pll,bool>vis;
signed main()
{
	Very_fast;
	cin>>n;
	rep(i,n)
	{
		ll a,b;
		cin>>a>>b;
		if(a<0&&b<0)a=-a,b=-b;
		if(a!=0&&b!=0)
		{
			ll g=gcd(abs(a),abs(b));
			a/=g;
			b/=g;
			if(b<0)a=-a,b=-b;
			mp[MP(a,b)]++;
		}else{
			if(a==0&&b==0)
			{
				res++,res%=mod;
				continue;
			}
			else if(a==0)b=1;
			else a=1;
			mp2[MP((ll)a,(ll)b)]++;
		}
	}
	ans*=(kissme(mp2[MP(1ll,0ll)],2)+kissme(mp2[MP(0ll,1ll)],2)-1)%mod;
	ans%=mod;
	for(map<pll,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		pll p=it->first;
		ll sum,num=it->second;
		if(vis[p])continue;
		if(p.F<0)p.F=-p.F,p.S=-p.S;
		sum=kissme(num,2)+kissme(mp[MP(-p.S,p.F)],2);
		vis[MP(-p.S,p.F)]=true;
		sum--;sum%=mod;
		if(it->F.F==-p.S&&it->F.S==p.F)sum=2;
		ans=ans*sum%mod;
	}
	cout<<(ans-1+mod+res)%mod<<"\n";
	return 0;
}

Measured memory_bytes: 53536
#include<bits/stdc++.h>
using namespace std;
int n, k;
double p[35], ans;
int main(){
    scanf("%d%d", &n, &k);
    p[0] = 1;
    for(int i = 1; i < 30; i++) p[i] = p[i-1] / 2;
    for(int i = 0; i < n; i++){
        int t = 0, s = i+1;
        while(s < k){
            s *= 2;
            t++;
        }
        ans += p[t];
    }
    printf("%.10f\n", ans/n);
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
MOD = 10 ** 9 + 7
ans = 0

for i in range(61):
    cnt = np.count_nonzero(A & 1)
    ans += (2 ** i) * cnt * (N - cnt)
    A >>= 1

print(ans % MOD)

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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;


int main()
{
    ll mat[3][3] ;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> mat[i][j] ;
        }
    }
    ll n, x, flag = 0 ;
    map <ll, ll> mp ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> x ;
        mp[x]++ ;
    }
    if (mp[mat[0][0]] > 0 and mp[mat[0][1]] > 0 and mp[mat[0][2]] > 0)  cout << "Yes" ;
    else if (mp[mat[0][0]] > 0 and mp[mat[1][0]] > 0 and mp[mat[2][0]] > 0) cout << "Yes" ;
    else if (mp[mat[0][0]] > 0 and mp[mat[1][1]] > 0 and mp[mat[2][2]] > 0) cout << "Yes" ;
    else if (mp[mat[2][0]] > 0 and mp[mat[2][1]] > 0 and mp[mat[2][2]] > 0) cout << "Yes" ;
    else if (mp[mat[0][2]] > 0 and mp[mat[1][2]] > 0 and mp[mat[2][2]] > 0) cout << "Yes" ;
    else if (mp[mat[1][0]] > 0 and mp[mat[1][1]] > 0 and mp[mat[1][2]] > 0) cout << "Yes" ;
    else if (mp[mat[0][1]] > 0 and mp[mat[1][1]] > 0 and mp[mat[2][1]] > 0) cout << "Yes" ;
    else if (mp[mat[0][2]] > 0 and mp[mat[1][1]] > 0 and mp[mat[2][0]] > 0) cout << "Yes" ;
    else    cout << "No" ;
}


Measured memory_bytes: 256
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int d,n;cin>>d>>n;
	int p[d];
	for(int i = 0; d > i; i++){
		cin>>p[i];
	}
	z o[n];
	for(int i = 0; n > i; i++){
		cin>>o[i].a>>o[i].b>>o[i].c;
	}
	for(int i = 0; n > i; i++){
		if(o[i].a <= p[0] && p[0] <= o[i].b)dp[0][i] = 0;
		else dp[0][i]=-1;
	}
	for(int i = 1; d > i; i++){
		for(int j = 0; n > j; j++){
			int mx = -1;
			if(o[j].a <= p[i] && p[i] <= o[j].b){
				for(int k = 0; n > k; k++){
					if(dp[i-1][k]==-1)continue;
					mx = max(mx,dp[i-1][k]+abs(o[k].c-o[j].c));
				}
				dp[i][j]=mx;
			}else{
				dp[i][j]=-1;
			}
		}
	}
	int ans = 0;
	for(int i = 0; n > i; i++){
		ans = max(ans,dp[d-1][i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3288
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n-k+1):
    l, r = a[i], a[i + k -1]
    time = min(abs(l) + abs(l - r), abs(r) + abs(l - r))
    ans = min(ans, time)
print(ans)

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

int n, m;

int k[20];

int ison[20][20];
int p[20];

int isOK(int b){
    vector<int> vec;

    for(int i = 0;i < n;i++){
        vec.push_back((b & (1 << i)) != 0 ? 1 : 0);
    }

    for(int i = 0;i < m;i++){
        int ans = 0;
        for(int j = 0;j < k[i];j++){
            ans += vec[ison[i][j]];
        }
        if(ans % 2 != p[i]){
            return 0;
        }
    }

    return 1;
}

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

    for(int i = 0;i < m;i++){
        cin >> k[i];
        for(int j = 0;j < k[i];j++){
            cin >> ison[i][j];
            ison[i][j]--;
        }
    }

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

    int ans = 0;
    for(int i = 0;i < (1 << n);i++){
        ans += isOK(i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
// https://beta.atcoder.jp/contests/abc084

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int N ;
    vector<int> C;
    vector<int> S;
    vector<int> F;
#ifdef SUBMIT
    cin >> N;
    N -= 1;
    C.resize(N);
    S.resize(N);
    F.resize(N);
    for (int k = 0; k < N; ++k) {
        cin >> C[k] >> S[k] >> F[k];
    }
#else
    N = 4 - 1;
    C = {12, 44, 66};
    S = {13, 17, 4096};
    F = {1, 17, 64};
#endif
//    C[N - 1] = 0, S[N - 1] = 0, F[N - 1] = 0;

    for (int i = 0; i < N; ++i) {
        int t = 0;
        for (int j = i; j < N; ++j) {
            if (t <= S[j]) t = S[j];
            else {
                auto diff = t - S[j];
                auto wait = F[j] * ((diff + (F[j] - 1)) / F[j]);
                t = S[j] + wait;
            }

            t += C[j];
        }

        cout << t << endl;
    }
    cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class CODEFESTIVAL_2016_FINALB
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var list = new List<long>();
            var sum = 0L;
            for (var i = 1; i <= N; i++)
            {
                sum += i;
                list.Add(i);
                if (sum > N) break;
            }
            list.Remove(sum - N);
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 15072
S = input()
if S == "SAT":
    print(1)
elif S == "FRI":
    print(2)
elif S == "THU":
    print(3)
elif S =="WED":
    print(4)
elif S == "TUE":
    print(5)
elif S == "MON":
    print(6)
elif S == "SUN":
    print(7)        

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

int main() {
    int count=0;
    char a, b;
    while (1) {
        char b=a;
        scanf("%c",&a);
        if (b=='\n'&&a=='0') return 0;
        if (a=='\n') {
            printf("%d\n",count);
            count=0;
        }
        else count+=a-48;
    }
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include<cstdio>
using namespace std;
int f[100010];
int a[100010];
int main() {
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	f[1]=a[1];
	int ans=1;
	for(int i=2;i<=m;i++){
		if(a[i]<=f[ans])  f[++ans]=a[i];
		else{
			int l=1,r=ans;
			while(l<r){
				int mid=(l+r)>>1;
				if(f[mid]>=a[i]) l=mid+1;
				else r=mid;
			}
			f[l]=a[i];
		}
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, char *argv[])
{
  char s[200001];
  scanf("%s", s);

  int k = 1;
  int i = 0;
  int l = 0;

  i = 1;
  l = 1;
  int n = strlen(s);
  while (i < n) {
    if (l > 1) {
      k++;
      l = 1;
      i++;
    } else {
      if (s[i] != s[i - 1]) {
	k++;
	l = 1;
	i++;
      } else if (i != n - 1){
	k++;
	l = 2;
	i += 2;	
      } else break;
    }
  }

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

  return 0;
}
      
	

  


Measured memory_bytes: 384
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int N;

void dfs(int N) {
  if (N == 0) return;
  if (N%2 == 0) {
    dfs(N/(-2)); cout << 0;
  } else {
    if (N < 0) {dfs(N/(-2)+1); cout << 1;}
    else {dfs(N/(-2)); cout << 1;}
  }
  return;
}

int main() {
  cin >> N;

  if (N == 0) {
    cout << 0 << endl;
    return 0;
  } else {
    dfs(N);
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC162
{
    class Program
    {
        /*
         * static void Main(string[] args)
        {

            var N = int.Parse(Console.ReadLine());
            long o= 0;
            for(int i = 0; i < N; i++)
            {
                if (i % 3 == 0 || i % 5 == 0) continue;
                o += i;
            }
            Console.WriteLine(o);
        }*/

        static Dictionary<(int, int), int> gcdData;
        static int gcd(int a,int b)
        {
            if (gcdData.ContainsKey((a, b))) return gcdData[(a, b)];
            if (a < b)
            {
                var rr = gcd(b, a);
                gcdData[(a, b)] = rr;
                return rr;
            }
            if (b == 0)
            {
                gcdData[(a, b)] = a;
                return a;
            }
            var r =gcd(b, a % b);
            gcdData[(a, b)] = r;
            return r;
        }
        static int gcd(int a,int b,int c)
        {
            return gcd(gcd(a, b), c);
        }

        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var sum = 0;
            gcdData = new Dictionary<(int, int), int>();
            for(int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        sum += gcd(i, j, k);
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 30736
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
int solve(){
	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	cin>>v;
	sort(v.begin(),v.end());
	cout<<accumulate(v.begin(),v.begin()+k,0);	
	return 0;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    int a, b;
    scanf(" %d %d", &a, &b);
    
    if(a+b == 15){
        printf("+");
    }
    else if(a*b == 15){
        printf("*");
    }
    else{
        printf("x");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <cstdio> 
using namespace std;

const int maxn=25;
int l, n, src, dst, m;

int main(){
	scanf("%d", &l); --l;
	for (int i=l+1; i; i>>=1) ++n;
	m=n*2-2;
	for (int i=21; i>=0; --i) if ((l-(1<<n-1)+1)&(1<<i)) ++m;
	printf("%d %d\n", n, m);
	src=n; dst=1; int t=1;
	for (int i=1; i<n; ++i, t*=2){
		printf("%d %d %d\n", i, i+1, t);
		printf("%d %d %d\n", i, i+1, 0); }
	int nowe=(1<<(n-1)); l=l-nowe;
	while (l>=0){
		for (t=21; t>=0; --t) if (l-(1<<t)>=-1) break;
		printf("%d %d %d\n", t+1, src, nowe);
		nowe+=(1<<t); l-=(1<<t);
	}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    if(N % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        int ans = 1000 - N % 1000;
         cout << ans  << endl;
    }
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, B;
int ans;

int main(){
	cin >> A >> B;
	if (A < 10 && A > 0){
		if (B < 10 && B > 0){
			ans = A*B;
			cout << ans << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			char[] red = scanner.next().toCharArray();
			if (red[0] == '-')
				break;
			char[] green = scanner.next().toCharArray();
			char[] x = scanner.next().toCharArray();
			int p = 0, pr = 0, pg = 1;
			char c = green[0];
			while (p < x.length) {
				if (c == x[p]) {
					c = red[pr++];
					p++;
				} else {
					System.out.print(c);
					c = green[pg++];
				}
			}
			System.out.println(c + String.valueOf(green).substring(pg));
		}
	}
}

Measured memory_bytes: 17164
n,a,b = gets.chomp.split(" ").map(&:to_i)
if n == 1
  if a == b
    puts 1
  else
    puts 0
  end
else
  cnt =  b * (n-2) - a * (n-2) + 1
  cnt = 0 if cnt < 0
  puts cnt
end


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

vector<int> sons[100001]={};
queue<int> q; 
int da[100001]={}, db[100001]={};
bool v[100001]={};

int main(){
	int n,a,b,x,u;
	cin>>n;
	for(int i=1;i<=n-1;i++){
		cin>>a>>b;
		sons[a].push_back(b);
		sons[b].push_back(a);
	}
	a=1,b=n;
	// do bfs from a
	memset(v, 0, sizeof(v));
	for(int i=1;i<=n;i++) da[i]=1e9;
	da[a]=0; v[a]=1; q.push(a);
	while(!q.empty()){
		x=q.front();
		for(int i=0;i<sons[x].size();i++){
			u=sons[x][i];
			if(!v[u]){
				da[u]=da[x]+1;
				v[u]=1;
				q.push(u);
			}
		}
		q.pop();
	}
	// do bfs from b
	memset(v, 0, sizeof(v));
	for(int i=1;i<=n;i++) db[i]=1e9;
	db[b]=0; v[b]=1; q.push(b);
	while(!q.empty()){
		x=q.front();
		for(int i=0;i<sons[x].size();i++){
			u=sons[x][i];
			if(!v[u]){
				db[u]=db[x]+1;
				v[u]=1;
				q.push(u);
			}
		}
		q.pop();
	}
	int snuke=0, fennec=0;
	for(int i=1;i<=n;i++){
		if(da[i]>db[i]) snuke++;
		else if(da[i]<=db[i]) fennec++;
	}
	//cout<<snuke<<endl;
	//cout<<fennec<<endl;
	if(snuke>=fennec) cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}


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

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

    int n; cin >> n;
    map<string, int> m;
    rep(i,n){
        string s; cin >> s;
        m[s]++;
    }
    string key[4] = {"AC", "WA", "TLE", "RE"};
    rep(i,4) cout << key[i] << " x " << m[key[i]] << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cmath>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    for(int i = 0; i <= x; i++) {
        if(y == (i * 2) + ((x - i) * 4)) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

int main(){
    vector<int> X(5);
    for(int i=0; i<5; ++i) cin >> X.at(i);

    for(int i=0; i<5; ++i){
        if(X.at(i) == 0) cout << i+1 << endl;
    }
}


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

int main() {
  long long n,m,x;
  cin>>n>>m>>x;
  vector<long long>c(n);
  vector<vector<long long>>a(n,vector<long long>(m));
  for(int i=0;i<n;i++){
    cin>>c.at(i);
    for(int j=0;j<m;j++){
      cin>>a.at(i).at(j);
    }
  }
  long long ans=100000000;
  for(int i=0;i<1<<n;i++){
    vector<long long>X(m);
    bool Q=true;
    long long cost=0;
    for(int j=0;j<n;j++){
      if(i>>j&1){
        cost+=c.at(j);
        for(int k=0;k<m;k++){
          X.at(k)+=a.at(j).at(k);
        }
      }
    }
    for(int u=0;u<m;u++){
        if(X.at(u)<x){
          Q=false;
        }
      }
      if(Q){
        ans=min(ans,cost);
      }
    }
  
  if(ans==100000000){
    cout<<"-1"<< endl;
    return 0;
  }
  cout<<ans<< endl;
}
  
      
    

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


#define gc getchar
#define pc putchar

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
*/

/*
        two functions for policy based data structure. it is

                find_by_order() and order_of_key().

        The first returns an iterator to the k-th largest element (counting from zero),
        the second returns the number of items in a set that are strictly smaller than our item

*/

#define vi vector<int>
#define si set<int>
#define vs vector<string>
#define pii pair<int,int>
#define vpi vector<pii>
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define mpi map<int,int>
#define i64 long long int
#define endl '\n'
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Rep(i,x,y) for(int i=x;i<=y;i++)
#define eps 1e-8
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt","w", stdout)
#define sz size()
#define dbg(x) cerr << "yo is " << x << endl;
#define dbg2(x,y) printf("yo is %d! and %d!\n",x,y)
#define foreach(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define sqr(a) (a) * (a)
#define clr clear()
#define CASE(a) printf("Case %d: ",a)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)

//int dx[] = {0,1,0,-1};
//int dy[] = {1,0,-1,0};
//int dx[] = { -1, -1,  0, 1, 1, 1,  0, -1 };
//int dy[] = {  0, -1, -1, -1,  0, 1, 1, 1 };
//int dxK[] = { -2, -2, -1, 1, 2, 2, 1, -1 };
//int dyK[] = { -1, 1, 2, 2, 1, -1, -2, -2 };

//functions

//i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}

//inline void fastRead(i64 *a){register char c=0;while(c<33)c=gc();*a=0;while(c>33){*a=*a*10+c-'0';c=gc();}}

//inline void fastWrite(int a){char snum[20];int i=0;do{snum[i++]=a%10+48;a=a/10;}while(a!=0);i=i-1;while(i>=0)pc(snum[i--]);pc('\n');}

//i64 bigmod(i64 num,i64 n){if(!n)return 1;i64 x=(bigmod(num,n/2)*bigmod(num,n/2))%mod;if(n%2)x=(x*num)%mod;return x;}

//i64 modinverse(i64 num){return bigmod(num,mod-2);}

//void combination(int pos,int last){if(pos==k+1){for(int i=1;i<=k;i++)cout << tem[i];cout << endl;return;}
//for(int i=last+1;i<=n-k+pos;i++){tem[pos] = num[i-1];combination(pos+1,i);}}
//i64 power(i64 value, i64 base){i64 result = 1;For(i,base)result *= value;return result;}
//int Set(int N,int pos){return N = (1<<pos);}
//int reset(int N,int pos){return N &= (~(1<<pos));}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}

//typedef tree< int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > Set;

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

    int gg = 0;
    while(gg < s.sz)
    {
        cout << s[gg];
        gg += n;
    }

    return 0;
}



Measured memory_bytes: 256