akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,px,py,nx,ny,k,t,d,m,posible;
    while(cin >> n)
    {
        px = py = k = 0; posible = 1;
        for(int i = 0; i < n; i++)
        {
            cin >> t >> nx >> ny;
            d = abs(nx - px) + abs(ny - py);
            m = t - k;
            if(d % 2 != m % 2 || m < d)
                posible = 0;
            px = nx; py = ny;
            k = t;
        }
        cout << (posible? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int Start = A + B;
    if(Start >= 24){
      Start -= 24;
    }
    System.out.print(Start);
  }
}


Measured memory_bytes: 21844
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n, m;
int[] a;

void main() {
    scan(n, m);
    a = readln.split.to!(int[]);

    auto imos = new int[](m + 2);
    auto b = new long[](m + 2);

    long move;

    foreach (i ; 0 .. n - 1) {
        int s = a[i], t = a[i + 1];

        if (s < t) {
            imos[s + 1]++;
            imos[t]--;
        }
        else {
            imos[1]++;
            imos[t]--;
            imos[s + 1]++;
        }

        b[t] += (t - s + m) % m - 1;

        move += min((a[i + 1] - a[i] + m) % m, 1 + (a[i + 1] - 1 + m) % m);
    }

    foreach (i ; 0 .. m) {
        imos[i + 1] += imos[i];
    }

    debug {
        writeln("move:", move);
    }

    long ans = move;

    foreach (i ; 1 .. m) {
        long tmp = move - imos[i] + b[i];
        ans = min(ans, tmp);
        move = tmp;

        debug {
            writeln("move:", move);
        }
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4284
def resolve():
    import math
    N = int(input())
    A = [int(i) for i in input().split()]
    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    lcm -= 1
    sumA = 0
    for a in A:
        sumA += lcm % a
    print(sumA)


resolve()


Measured memory_bytes: 9320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, k, cnt = 0;
  cin >> n >> m;
  vector<int> list(m, 0);
  for (int i = 0; i < n;i++){
    cin >> k;
    vector<int> a(k);
    for (int j = 0; j < k;j++){
      cin >> a[j];
      list[a[j] - 1]++;
    }
  }
  for (int i = 0; i < m;i++){
    if(list[i]==n){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    char S[10001];
    scanf("%s",S);
    for(int i=0;S[i]!=0;i++){
        if(S[i]+N<=90)
            printf("%c",S[i]+N);
        else
            printf("%c",S[i]+N-26);
    }
    return 0;
}

Measured memory_bytes: 128
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s = list(input())
    t = list(input())
    n = len(s)
    for i in range(n):
        if s[i]!=t[i]:
            print('No')
            return
    print('Yes')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10788
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
ll A[N];
rep(i,N){
    cin>>A[i];
}
ll left[N],right[N+1];
left[0]=0;
rep3(i,N-1){
    left[i]=left[i-1]+A[i-1];

}
right[N]=0;
repr3(i,N-1){
    right[i]=right[i+1]+A[i];
}
ll min_abs=INF2;
rep3(i,N-1){
    min_abs=min(min_abs,abs(right[i]-left[i]));

}
cout<<min_abs<<endl;



return 0;
}




Measured memory_bytes: 4992
NIL = -1


class Node():
    __slots__ = ["key", "parent", "left", "right"]

    def __init__(self, key=NIL, parent=NIL, left=NIL, right=NIL):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right


class BinaryTree():
    def __init__(self, node):
        self.root = node

    def insert(self, key):
        if self.root.key == NIL:
            self.root.key = key
            return

        now = self.root
        while now != NIL:
            parent = now
            if   key < now.key:
                now = now.left
            elif key > now.key:
                now = now.right
            else:
                raise
        
        insert = Node(key, parent)

        if   insert.key < parent.key:
            parent.left = insert
        elif insert.key > parent.key:
            parent.right = insert
        else:
            raise

    def find(self, key):
        now = self.root
        while now != NIL:
            if   key < now.key:
                now = now.left
            elif key > now.key:
                now = now.right
            else:
                break

        return now

    def treewalk_inorder(self, node):
        if isinstance(node, int):
            return

        self.treewalk_inorder(node.left)
        print(f" {node.key}", end="")
        self.treewalk_inorder(node.right)

    def treewalk_preorder(self, node):
        if isinstance(node, int):
            return

        print(f" {node.key}", end="")
        self.treewalk_preorder(node.left)
        self.treewalk_preorder(node.right)



n = int(input())

root = Node()
binary_tree = BinaryTree(root)


for _ in range(n):

    command, *list_num = input().split()

    if   command == "insert":
        k = int(list_num[0])
        binary_tree.insert(k)
    elif command == "find":
        k = int(list_num[0])
        if isinstance(binary_tree.find(k), int):
            print("no")
        else:
            print("yes")
    elif command == "print":
        binary_tree.treewalk_inorder(root)
        print()
        binary_tree.treewalk_preorder(root)
        print()
    else:
        raise



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

using namespace std;

int main()
{
    int MAX = 10000;
    vector<bool> isPrime(MAX+1, true);
    isPrime[1] = false;

    for (int i = 2; i <= MAX; i++) {
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) isPrime[i] = false;
        }
    }

    int N;
    while (cin >> N) {
        int count = 0;
        for (int i = 1; i <= N; i++) {
            if (isPrime[i] && isPrime[N-i+1]) count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1196
#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>
using namespace std;
#define MK make_pair
#define F first
#define S second
#define ege pair<int,pair<int,int>> //w,s,t
typedef long long int ll;
const ll MX=1e13;






int main(){
    int v,e;
    ll dis[1000][1000];
    fill(&dis[0][0],&dis[999][1000],MX);
    for(int i=0;i<1000;i++){
        dis[i][i]=0;
    }
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        if(dis[s][t]>d){dis[s][t]=d;}
    }
    for(int i=0;i<v;i++){
        for(int t=0;t<v;t++){
            for(int h=0;h<v;h++){
                if(dis[t][i]==MX || dis[i][h]==MX){continue;}
                if(dis[t][h]>dis[t][i]+dis[i][h]){dis[t][h]=dis[t][i]+dis[i][h];}
            }
        }
    }
    bool j=false;
    for(int i=0;i<v;i++){
        for(int t=0;t<v;t++){
            if(dis[i][t]+dis[t][i]<0){j=true; break;}
        }
    }
    if(j){cout<<"NEGATIVE CYCLE"<<endl; return 0;}
    for(int i=0;i<v;i++){
        for(int t=0;t<v;t++){
            if(dis[i][t]==MX){cout<<"INF";}
            else{cout<<dis[i][t];}
            if(t!=v-1){cout<<" ";}
        }
        cout<<endl;
    }
    
    return 0;
}




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

using namespace std;

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

  char c = s[k-1];
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == c ) {
      cout << c;
    } else {
      cout << '*';
    }
  }
  cout << endl;
  return 0;
}

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

const ll mod = 1e9+7;
ll n;
ll a[100000];
ll dp[3001][3001];
ll solve(ll i,ll j){
    if(i==j){
        return a[i];
    }
    if(i>=n || j<0) return INT_MAX;
    if(i>j) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    ll ans=0;
    ans=a[i]+min(solve(i+1,j-1),solve(i+2,j));
    ans=max(ans,a[j]+min(solve(i+1,j-1),solve(i,j-2)));
    return dp[i][j]=ans;

}

int main() {
    memset(dp,-1,sizeof(dp));
    cin>>n;
    ll s=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }

    cout<<2*solve(0,n-1)-s<<endl;

}


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

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

	int N; cin >> N;
	int a[22];
	int sta[50000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int Q; cin >> Q;
	int m[220];
	for (int i = 0; i < pow(2, N); i++) {
		int z = i;
		int c = 0;
		int s = 0;
		while (c < N) {
			if (z % 2 == 1)s += a[c];
			z /= 2;
			c++;
		}
		sta[s] = 1;
	}
	for (int i = 0; i < Q; i++) {
		cin >> m[i];
		if (sta[m[i]] == 1)cout << "yes" << endl;
		else cout << "no" << endl;
	}
}



Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N, A, B, C, D, E, F;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> E;

    F = min(A, min(B, min(C, min(D, E))));

    if (F == A) { 
        if (N % A == 0) { cout << N / A + 4 << endl; }
        else { cout << N / A + 5 << endl; }
    }
    else if (F == B) {
        if (N % B == 0) { cout << N / B + 4 << endl; }
        else { cout << N / B + 5 << endl; }
    }
    else if (F == C) {
        if (N % C == 0) { cout << N / C + 4 << endl; }
        else { cout << N / C + 5 << endl; }
    }
    else if (F == D) { 
        if (N % D == 0) { cout << N / D + 4 << endl; }
        else { cout << N / D + 5 << endl; }
    }
    else if (F == E) { 
        if (N % E == 0) { cout << N / E + 4 << endl; }
        else { cout << N / E + 5 << endl; }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 105

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


int main() {

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

	int ans = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		bool exist = true;
		for (int j = i; j >= 0; j--)
		{
			if (a[j] > a[i])
			{

				exist = false;
				break;
			}
		}
		if (exist)
		{
			ans++;
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    write(N * N * N);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A[100],d,B[100],N,K,i,c,j;
    scanf("%d%d",&N,&K);
    for(i=1;i<=N;i++){
        B[i]=0;
    }
    for(i=0;i<K;i++){
        scanf("%d",&d);
        for(j=0;j<d;j++){
            scanf("%d",&A[j]);
            B[A[j]]++;
        }
    }
    c=0;
    for(i=1;i<=N;i++){
        if(B[i]==0)
          c++;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 3832
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int t;
        
        if( a <= b && b <= c ){
        	System.out.println(a+" "+ b+" "+c);
        }
        else if( a <= c && c <= b ){
        	System.out.println(a+" "+ c+" "+b);
        }
        else if( b <= a && a <= c ){
        	System.out.println(b+" "+ a+" "+c);
        }
        else if( b <= c && c <= a ){
        	System.out.println(b+" "+ c+" "+a);
        }
        else if( c <= a && a <= b ){
        	System.out.println(c+" "+ a+" "+b);
        }
        else{
        	System.out.println(c+" "+ b+" "+a);
        }
    }
}

Measured memory_bytes: 26236
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>

using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); ++i)
#define rep(i,n) REP(i,0,n)

vector<int> g[1010];
int n, m;
 
vector<bool> visited, matched;
vector<int> levels, matching;
 
bool augment(int left) {
  if(left == n) return true;
  if(visited[left]) return false;
  visited[left] = true;
  rep(i, g[left].size()) {
    int right = g[left][i];
    int next = matching[right];
    if (levels[next] > levels[left] && augment(next)) {
      matching[right] = left;
      return true;
    }
  }
  return false;
}
 
int bimatch() {
  matching.assign(m, n);
  matched.assign(n, false);
  //int ret = 0;
  bool cont;
  do {
    levels.assign(n+1, -1);
    levels[n] = n;
    queue<int> q;
    rep(left, n) if (!matched[left]) {
      q.push(left);
      levels[left] = 0;
    }
    while(!q.empty()) {
      int left = q.front();
      q.pop();
      rep(i, g[left].size()) {
        int right = g[left][i];
        int next = matching[right];
        if (levels[next] < 0) {
          levels[next] = levels[left] + 1;
          q.push(next);
        }
      }
    }
    visited.assign(n, false);
    cont = false;
    /*
    rep(i,n){
      cout << "match:" << i << " : " << matched[i] << endl;
    }
    rep(i,n){
      cout << "levels:" << i << " : " << levels[i] << endl;
    }
      */
    rep(left, n) if(!matched[left] && augment(left)){
      matched[left] = cont = true;
      //ret++;
    }
  } while(cont);
  //printf("ret:%d\n",ret);
  return count(matched.begin(), matched.end(), true);
}

int blue[510],red[510];

int main(){
  while(scanf("%d%d",&n,&m),n|m){
    //init
    rep(i,1010)g[i].clear();
    visited.clear();
    matched.clear();
    levels.clear();
    matching.clear();
    
    
    
    rep(i,n)scanf("%d",blue+i);
    rep(i,m)scanf("%d",red+i);

    rep(i,n){
      rep(j,m)if( __gcd(blue[i],red[j])!=1 ){
        g[i].push_back(n+j);
        g[n+j].push_back(i);
      }
    }
    //
    /*
    rep(i,n+m){
      printf("%d: ",i);
      rep(j,g[i].size())printf("%d ",g[i][j]);
      puts("");
    }
      */
    m += n;
    printf("%d\n",bimatch());
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n,m,res = 0;
  cin >> n >> m;
  vector<int> s(n,0);
  REP(i,m){
    int l,r;cin >> l >> r;
    l--,r--;
    s[l]++;
    if(r != n-1)s[r+1]--;
  }
  REP(i,n)if(i)s[i] += s[i-1];
  sort(ALL(s),greater<int>());
  REP(i,n){
    if(s[i] >= m)res++;
  }
  cout << res << endl;
  



  return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  for(int i = 0; i < N-1; i++) sum += L[i];
  if(sum > L[N-1]) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


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

int main() {
  int N;
  int d[100];
  int i, j;
  int sum = 0;
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> d[i];
  for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
      sum += d[i]*d[j];
    }
  }
  cout << sum << endl;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

long modpow(long x, long y, long m) {
   if( y == 0 ) return 1;
   long t = modpow(x, y / 2, m);
   return y % 2 == 1 ? ((x * t) % m) * t % m : (t * t) % m;
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, m; scan(n, m);
      if( std::abs(n - m) >= 2 ) {
         puts("0");
         return;
      }
      long a = 1, b = 1;
      long mod = 1000000007;
      for(long i = 1; i <= n; ++i) {
         a = (a * i) % mod;
      }
      for(long i = 1; i <= m; ++i) {
         b = (b * i) % mod;
      }
      long res = a * b % mod;
      if( n == m ) res = (res * 2) % mod;
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;//使うのはs2の頭だけ。
  cout << "A" << s2[0] << "C" << endl;
}


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

int main() {
  int N;
  cin >> N;
  set<string> kuzi;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    kuzi.insert(tmp);
  }
  cout << kuzi.size() << endl;
}


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

int main() {
  int N,a,b,c,d;
  cin >> N;
  a = (N - N % 1000)/1000;
  b = ((N - a * 1000) - N % 1000 % 100)/100;
  c = ((N - a * 1000 - b * 100) - N % 1000 % 100 % 10)/10;
  d = ((N - a * 1000 - b * 100 * c * 10) - N % 1000 % 100 % 10 % 1)/1;
  if (a==b && b==c || b==c && c==d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

typedef complex<double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
inline double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;

inline int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) > EPS)   return +1;		// counter clockwise
	if(cross(b, c) < -EPS)   return -1;		// clockwise
	if(dot(b, c) < -EPS)     return +2;		// c--a--b on line
	if(norm(b) + EPS < norm(c)) return -2;		// a--b--c on line
	return 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
// !CAUTION! number は有理数以上
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
G convex_cut(const G& po, const L& l) {
  G Q;
  for (int i = 0; i < po.size(); ++i) {
    P A = curr(po, i), B = next(po, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

int main(){
	int n;
	while(cin >> n, n){
		G g(n);
		rep(i, n) cin >> g[i].real() >> g[i].imag();
		double lo = 0, hi = 20000, mid;
		rep(it, 100){
			mid = (lo + hi) / 2;
			G g2 = g;
			rep(i, n){
				P d = g[(i + 1) % n] - g[i];
				d *= P(0, 1);
				d *= mid / abs(d);
				g2 = convex_cut(g2, L(g[i] + d, g[(i + 1) % n] + d));
			}
			if(g2.empty()) hi = mid;
			else lo = mid;
		}
		printf("%.9f\n", hi);
	}
	return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector <queue<string>> a(n+1);

	rep(i, m) {
		int b;
		string c;
		cin >> b >> c;
		a[b].push(c);
	}

	int aac = 0;
	int awa = 0;

	rep(i, n+1) {
		int wa = 0;
		while (!a[i].empty()) {
			string q = a[i].front();
			a[i].pop();
			if (q == "WA") wa++;
			if (q == "AC") {
				aac += 1;
				awa += wa;
				break;
			}
		}

	}

	cout << aac << " " << awa << endl;

	return 0;
}


Measured memory_bytes: 72280
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

template <typename T>
using GPQ=priority_queue<T,vector<T>,greater<T>>;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll x,y,a,b,c,ans=0; cin >> x >> y >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  rep(i,0,a) cin >> p[i];
  rep(i,0,b) cin >> q[i];
  rep(i,0,c) cin >> r[i];
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  sort(r.rbegin(),r.rend());
  vector<ll> pqmix;
  rep(i,0,x){
  	ans+=p[i];
  	pqmix.push_back(p[i]);
  }
  rep(i,0,y){
  	ans+=q[i];
  	pqmix.push_back(q[i]);
  }
  sort(pqmix.begin(),pqmix.end());
  ll res=ans;
  rep(i,0,min(c,x+y)){
  	ans-=pqmix[i];
  	ans+=r[i];
  	res=max(ans,res);
  }


  cout << res << endl;
}

Measured memory_bytes: 4852
n = gets.chomp.to_i
x_arr=gets.chomp.split(" ").map(&:to_i)

arr = x_arr.sort
a = arr[n/2-1]
b = arr[n/2]

x_arr.each do |x|
  if x <= a then
    puts b
  else
    puts a
  end
end


Measured memory_bytes: 25444
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 10e13
int main(){	
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	   	ll n;
	   	cin >> n;
	   	ll ans = badi_val;
	   	for(ll i = 1 ; i * i <= n ; i++)
	   	{
	   		if(n % i == 0){
	   			ans = min(i + (n/i) - 2 , ans);
	   		}
	   	} 
	   	if(ans == badi_val)
	   	{
	   		cout << -1 << endl;
	   	}
	   	else
	   		cout << ans << endl;
		return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define precision(x) fixed << setprecision(x)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define SUM(x) accumulate(all(x),0LL)
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double PI = acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int n, min, max;
    ll sum;
    cin >> n;
    vector<int>a(n,0);
    rep(i,n) cin >> a.at(i);
    min = MIN(a);
    max = MAX(a);
    sum = SUM(a);
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3144
import math
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n = n >> 1
    return res


n = int(input())

if n == 1:
    print(0)
else:
    r = modpow(10, n, 1000000007) - 2 * modpow(9, n, 1000000007) + modpow(8, n, 1000000007)
    print(r % 1000000007)



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

int cmp(const void *n1, const void *n2)
{
    return *(int *)n1 - *(int *)n2;
}

int main(void)
{

    int totalDistance, houseNum;
    
    scanf("%d%d", &totalDistance, &houseNum);

    int distance[houseNum];
    for (int index = 0; index < houseNum; index++)
    {
        scanf("%d", &distance[index]);
    }

    int moveDistance[houseNum * 2];
    for (int index = 0; index < houseNum * 2; index++)
    {
        if (index == 0)
        {
            moveDistance[index] = distance[houseNum - 1] - distance[index];
        }
        else if (index == (houseNum * 2) - 1)
        {
            moveDistance[index] = distance[houseNum - 1] - distance[0];
        }
        else if (index % 2 == 1)
        {
            moveDistance[index] = totalDistance - distance[index / 2] + distance[(index / 2) + 1];
        }
        else
        {
            moveDistance[index] = totalDistance - distance[index / 2] + distance[(index / 2) - 1];
        }
    }

    qsort(moveDistance, houseNum * 2, sizeof(int), cmp);

    printf("%d", moveDistance[0]);

}

Measured memory_bytes: 4092
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

double h;

int main()
{
	while(scanf("%lf",&h)!=EOF)
	{
		printf("%d\n",(int)ceil(h*h/(double)98)+1);
	}
	return 0;
}

Measured memory_bytes: 3156
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1E+09 + 7;
const ll INF = 5E18;
const int MAX_N = 50;

int N, K;
P X[MAX_N], Y[MAX_N];

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

    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        X[i] = P(x, y);
        Y[i] = P(y, x);
    }

    sort(X, X + N);
    sort(Y, Y + N);

    ll ans = INF;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ll uy = Y[j].first;
            ll ly = Y[i].first;

            vector<P> vx;
            for (int k = 0; k < N; k++) {
                ll y = X[k].second;
                if (y >= ly && y <= uy) {
                    vx.push_back(X[k]);
                }
            }
            //cout << "uy = " << uy << ", ly = " << ly << ", vx.size = " << vx.size() << "\n";

            if (vx.size() < K)
                continue;

            int cont = 1;
            int l = 0;
            int r = 0;
            for (;;) {
                while (r < vx.size() - 1 && cont < K) {
                    cont++;
                    r++;
                }
                if (cont < K)
                    break;
                ll rx = vx[r].first;
                ll lx = vx[l].first;
                //cout << "rx = " << rx << ", lx = " << lx << "\n";
                ans = min(ans, (uy - ly) * (rx - lx));
                cont--;
                l++;
            }
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3608
import math

originN = int(raw_input())
N = originN
primes = []
while True:
    if N % 2 == 0:
        primes.append(2)
        N /= 2
    else:
        break
i = 3
while True:
    if N == 1 or N < i**2:
        break
    while True:
        if N % i == 0:
            primes.append(i)
            N /= i
        else:
            break
    i += 2
if N != 1:
    primes.append(N)
if primes[0] == 2:
    print str(originN/2)+" "+str(originN)+" "+str(originN)
elif primes[0] == 3:
    print str(originN/3)+" "+str(originN*2)+" "+str(originN*2)
else:
    p = int(math.ceil(float(primes[0])/4.0))
    if primes[0] % 4 == 1:
        if p % 2 == 0:
            print str(originN/primes[0]*p)+" "+str(originN*p/2)+" "+str(originN*p)
        else:
            isValid = False
            for h in xrange(1, 3501):
                for n in xrange(1, 3501):
                    if (4*n*h-n*originN-h*originN) > 0 and (originN*n*h) % (4*n*h-n*originN-h*originN) == 0:
                        isValid = True
                        print str(h)+" "+str(n)+" "+str((originN*n*h)/(4*n*h-n*originN-h*originN))
                        break
                if isValid: break
    else:
        print str(originN/primes[0]*p)+" "+str(originN*p*2)+" "+str(originN*p*2)
        

Measured memory_bytes: 3300
#include<stdio.h>
#define MAX 101
int main(){
  int a[MAX][MAX] = {};
  int datanum,temp,temp2,i,j;
  scanf("%d",&datanum);
  
  for(i=1;i<=datanum;i++){
  scanf("%d",&temp);
  scanf("%d",&temp);
  for(j=0;j<temp;j++){
  scanf("%d",&temp2);
  a[i][temp2] =1;
}
}
  for(i=1;i<=datanum;i++){
  for(j=1;j<=datanum;j++){
  if(j != 1)printf(" ");
  printf("%d",a[i][j]);
    }
  printf("\n");
}
  return 0;
}



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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	int n; cin >> n;
	vector<vector<ii>> g(n);
	vi d(n);
	FOR (i, 0, n - 2) {
		int x, y, z; cin >> x >> y >> z;
		g[x].emplace_back(y, z);
		g[y].emplace_back(x, z);
		d[x] ^= z;
		d[y] ^= z;
	}
	vi f(16);
	FOR (i, 0, n - 1) f[d[i]]++;
	int ans = 0;
	vi yo;
	FOR (i, 1, 15) {
		ans += f[i] / 2;
		if (f[i] & 1) {
			yo.push_back(i);
		}
	}
	int no = sz(yo);

	vector<int> dp(1 << no);
	vector<int> X(1 << no);

	dp[0] = 0;
	FOR (i, 1, (1 << no) - 1) {
		X[i] = X[i & (i - 1)] ^ yo[__builtin_ctz(i)];
		for (int j = i; j > 0; j = (j - 1) & i) {
			if (X[j] == 0) {
				dp[i] = max(dp[i], dp[i ^ j] + 1);
			}
		}
	}
	cout << no - dp[(1 << no) - 1] + ans << "\n";


	return 0;
}


Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, x, first;
    cin >> n >> x >> first;

    int ret = abs(x - first);
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        ret = __gcd(ret, abs(x - a));
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())
K = int(input())

table = list(map(int,input().split()))

ans = 0

for i in range(N):
    x,y = table[i-1],i
    ans += min(2*x, 2*(K-x))

print("%d"%(ans))


Measured memory_bytes: 3444
fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let x: u32 = iter.next().unwrap().parse().unwrap();
    let mut xs = vec![x];
    for _ in 0..n {
        xs.push(iter.next().unwrap().parse().unwrap());
    }
    xs.sort();
    let ds = (0..n).map(|i| xs[i + 1] - xs[i]);
    let mut ans = 0;
    for d in ds {
        ans = gcd(d, ans);
    }
    println!("{}", ans);
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}


Measured memory_bytes: 6396
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define int long long
using namespace std;
void solve(){

}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  string str , tmp;
  str = '1';
  cin>>tmp;
  str += tmp;
  if(str[3] == str[4] && str[5] == str[6]){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-7
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n;
vector<int> to[100050];
int color[100050];
int visited[100050];
vector<int> road;
int isConnect;

void dfs1(int index){
	if (index==1)	isConnect=1;
	visited[index]=1;
	for (unsigned int i=0;i<to[index].size()&&!isConnect;i++){
		if (!visited[to[index][i]])	dfs1(to[index][i]);	
	}
	visited[index]=0;
	if (isConnect)	road.push_back(index);
}

void dfs(int index){
	for (unsigned int i=0;i<to[index].size();i++){
		if (!color[to[index][i]])	{
			color[to[index][i]]=color[index];
			dfs(to[index][i]);	
		}
	}
}

int main(){
	n=read();
	for (int i=1,x,y;i<n;i++){
		x=read();y=read();
		to[x].push_back(y);
		to[y].push_back(x);
	}
	visited[1]=1;
	memset(color,0,sizeof(color));
	memset(visited,0,sizeof(visited));
	isConnect=0;
	road.push_back(1);
	dfs1(n);
	color[1]=1;color[n]=-1;
	for (int i=road.size()/2;i>=0;i--)	color[road[i]]=1;
	for (int i=road.size()/2+1;i<road.size();i++)	color[road[i]]=-1;
	for (int i=1;i<=n;i++){
		if (color[i])	dfs(i);
	}
	int sum=0;
	for (int i=1;i<=n;i++){
		sum+=color[i];
	}
	if (sum>0)	printf("Fennec\n");
	else		printf("Snuke\n");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);

    rep(i,n) cin >> x.at(i);

    int power = 1000000000;

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

    int mini = x.at(0);
    int maxi = x.at(n-1);
    int sum;

    for (int i=mini; i<=maxi; i++) {
        sum = 0;
        for (int j=0; j<n; j++) {
            sum += pow((x.at(j)-i),2);
        }
        power = min(power, sum);
    }

    cout << power << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n , a , hiyo[200005]={};
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> a;
        hiyo[a]++;
    }
    
    for(int i=1;i<=n;i++){
        cout << hiyo[i] << endl;
    }
    return(0);
}


Measured memory_bytes: 4412
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define tm1 ff
#define tm2 ss.ff
#define tm3 ss.ss
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define fill(x,v) memset(x,v,sizeof(x))
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N=450;
string board[N];
bool vst[N][N];
int n,m;
int fx[]={1,0,-1,0};
int fy[]={0,1,0,-1};

inline ii dfs(int i,int j){
	vst[i][j]=true;
	ii val={board[i][j]=='#',board[i][j]!='#'};
	FER(c,0,4){
		int x=j+fx[c];
		int y=i+fy[c];
		if(x<0||x>=m)continue;
		if(y<0||y>=n)continue;
		if(vst[y][x])continue;
		if(board[y][x]==board[i][j])continue;
		ii res=dfs(y,x);
		val.ff+=res.ff;
		val.ss+=res.ss;
	}
	return val;
}


int main(){
	fastio;
	cin>>n>>m;
	ll ans=0;
	FER(i,0,n)cin>>board[i];
	FER(i,0,n)FER(j,0,m)if(!vst[i][j]){
		ii val=dfs(i,j);
		ans+=val.ff*val.ss;
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 14336
#include<stdio.h>
int main(void)
{
  int s,m,h;
  scanf("%d",&s);
  h=s/3600;
  s=s%3600;
  m=s/60;
  s=s%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
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*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

struct edge{int to,cost;};

signed main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    //cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vector<vector<edge>> g(n);
    vector<int> color(n,-1);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].PB(edge{v,w});
        g[v].PB(edge{u,w});
    }

    color[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(color[nv.to]!=-1) continue;
            if(nv.cost%2==0){
                color[nv.to]=color[v];
                que.push(nv.to);
            }else{
                color[nv.to]=color[v]^1;que.push(nv.to);
            }
        }
    }
    rep(i,n) cout<<color[i]<<endl;
}

Measured memory_bytes: 11356
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        x: usize,
        a: usize,
    }

    let ans = if x < a {
        0
    } else {
        10
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352