akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    L = sorted(lmi())
    print(L[0]+L[1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import sys
import math

def resolve():
        input = sys.stdin.readline
        a,b,x=map(int,input().rstrip().split())

        ax=(a-1)//x
        bx=b//x

        ans=bx-ax
        ans=math.floor(ans)
        print(ans)
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 8 2"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """0 5 1"""
        output = """6"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """9 9 2"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """1 1000000000000000000 3"""
        output = """333333333333333333"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct data{
	llong place;
	llong cost;

	data(){};
	data(llong place, llong cost) :
		place(place),
		cost(cost)
	{}

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};


int main(){
	llong n, m, s, t;
	vector<vector<vector<P> > > edges;
	vector<vector<llong> > dis;

	cin >> n >> m >> s >> t;
	edges.resize(n+1, vector<vector<P> >(2));
	llong u, v, a, b;
	for(int i = 0; i < m; i++){
		cin >> u >> v >> a >> b;
		edges[u][0].push_back(P(v,a));
		edges[v][0].push_back(P(u,a));
		edges[u][1].push_back(P(v,b));
		edges[v][1].push_back(P(u,b));
	}

	dis.resize(2, vector<llong>(n+1, inf));
	dis[0][s] = 0;
	dis[1][t] = 0;

	for(int i = 0; i < 2; i++){
		priority_queue<data, vector<data>, greater<data> > q;
		q.push(data((i==0?s:t),0));
		while(q.size()){
			data now = q.top();
			q.pop();
			if(dis[i][now.place] < now.cost)
				continue;

			for(int j = 0; j < edges[now.place][i].size(); j++){
				P edge = edges[now.place][i][j];
				data next(edge.first, now.cost + edge.second);
				if(dis[i][next.place] <= next.cost)
					continue;
				dis[i][next.place] = next.cost;
				q.push(next);
			}
		}
	}

	vector<llong> ans;
	llong maxi = -inf;
	llong money = 1e15;
	for(int i = n-1; i >= 0; i--){
		maxi = max(maxi, money - dis[0][i+1] - dis[1][i+1]);
		ans.push_back(maxi);
	}

	reverse(BE(ans));
	for(auto x : ans)
		cout << x << endl;

	return 0;
}

Measured memory_bytes: 23812
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

const int N = (int)1e5 + 5;
vector<ll>s;
vector<ll>cache(N,MOD);

ll res(ll top)
{
	if(top == 0)
	{
		return 0;
	}
	else if(top == 1)
	{
		if(cache[top] != MOD)
		{
			return cache[top];
		}
		ll ans = (abs(s[top] - s[top-1]));
		//ERR2(top, ans);
		return cache[top] = ans;
	}
	else
	{
		if(cache[top] != MOD)
		{
			return cache[top];
		}
		ll ans = min((abs(s[top]-s[top-1]) + res(top-1)), 
						(abs(s[top] - s[top-2]) + res(top - 2))
						);
		//ERR2(top, ans);
		return cache[top] = ans;
	}
}

int main()
{
	ll n;
	cin>>n;
	s.resize(n);
	FOR(i,0,n) cin>>s[i];
	vector<ll>dp(N,MOD);
	dp[0] = 0;
	if(n == 1)
	{
		cout<<dp[0]<<endl;
		return 0;
	}
	dp[1] = abs(s[1] - s[0]);
	
	FOR(i,2,n)
	{
		dp[i] = min(abs(s[i]-s[i-1]) + dp[i-1],
				abs(s[i] - s[i-2]) + dp[i-2]
				);	
	}	
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 5644
#include<stdio.h>
#include<string.h>
int main(void){

    int dice[10],i;
    char s[101];
    int cnt_1,cnt_2;
    int flg_1,flg_2;
    int num_1,num_2;
    int x;

    for(i=0;i<6;i++) scanf("%d",&dice[i]);
    scanf("%s",s);

    for(i=0;i<strlen(s);i++){
        if(s[i]=='S'){
            x=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=x;
        }
        if(s[i]=='E'){
            x=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=x;
        }
        if(s[i]=='N'){
            x=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=x;
        }
        if(s[i]=='W'){
            x=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=x;
        }
    }
    printf("%d\n",dice[0]);
    return 0;
}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	if(n>=k){
		if(n%k==0){
			cout<<0;
			return 0;
		}
		else n=n%k;
	}
	cout<<min(n,k-n);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);

        long ans = 0;
        for (int i = 0; i < k; i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32908
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
A = LI()

max_now = A[0]
ans = 0

for Ai in A:
    max_now = max(max_now, Ai)
    ans += max_now - Ai
    
print(ans)

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL<<31;
constexpr static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    string s;
    cin >> n >> s;

    string initial_two[] = {"SS", "SW", "WW", "WS"};
    rep(i, 4) {
        string zoo = initial_two[i];
        for (int i = 1; i < n - 1; ++i) {
            if (s[i] == 'o') {
                if (zoo[i] == 'S') zoo += zoo[i - 1];
                else zoo += (zoo[i - 1] == 'S' ? 'W' : 'S');
            } else { // x
                if (zoo[i] == 'S') zoo += (zoo[i - 1] == 'S' ? 'W' : 'S');
                else zoo += zoo[i - 1];
            }
        }
        // cout << zoo << endl;
        bool flag = true;
        string check = zoo[n - 1] + zoo + zoo[0];
        for (int i = 1; (i <= n) && flag; ++i) {
            if (check[i] == 'S' && s[i - 1] == 'o') {
                if (check[i - 1] != check[i + 1]) flag = false;
            }
            if (check[i] == 'S' && s[i - 1] == 'x') {
                if (check[i - 1] == check[i + 1]) flag = false;
            }
            if (check[i] == 'W' && s[i - 1] == 'o') {
                if (check[i - 1] == check[i + 1]) flag = false;
            }
            if (check[i] == 'W' && s[i - 1] == 'x') {
                if (check[i - 1]!= check[i + 1]) flag = false;
            }
        }
        if (flag) {
            cout << zoo << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 792
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
  private static int Greater(char a, char b)
  {
    if (a < b) return 1;
    else if (a > b) return -1;
    else return 0;
  }
  static void Main(string[] args)
  {
    char[] s = Console.ReadLine().ToCharArray();
    char[] t = Console.ReadLine().ToCharArray();

    Array.Sort(s);
    Array.Sort(t, Greater);

    int pos = 0;
    int size = Math.Min(s.Length, t.Length);
    bool ok = true;
    while (pos < size)
    {
      if (s[pos] == t[pos])
      {
        ++pos;
        continue;
      }
      if (t[pos] < s[pos]) ok = false;
      break;
    }

    if (pos == size)
    {
      if (t.Length <= s.Length) ok = false;
    }

    if (ok)
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13396
s = input()
rl = []
lr = [-1]
output = [0]*len(s)
for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "L":
        rl.append(i)
    elif s[i] == "L" and s[i+1] == "R":
        lr.append(i)
lr.append(len(s)-1)
for i in range(len(rl)):
    x = rl[i]-lr[i]
    if x%2 == 0:
        output[rl[i]] += int(x/2)
        output[rl[i]+1] += int(x/2)
    else:
        output[rl[i]] += int(x//2)+1
        output[rl[i]+1] += int(x/2)
    y = lr[i+1]-rl[i]
    if y%2 == 0:
        output[rl[i]+1] += int(y/2)
        output[rl[i]] += int(y/2)
    else:
        output[rl[i]+1] += int(y//2)+1
        output[rl[i]] += int(y/2)
output = list(map(str,output))
print(" ".join(output))

Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;

int s,w;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout <<"safe";
}

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

int main() {
  int n;
  cin>>n;
  if(n<1200) cout<<"ABC"<<endl;
  else if(n<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

signed main() {
    int n, d;
    cin >> n >> d;

    int ans = 0;
    rep(i, n) {
        int x, y;
        cin >> x >> y;

        if (x * x + y * y <= d * d) ++ ans;
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define P pair<int,int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define int long long

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    if(n == 1 or n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for(int i = 1; i < n; i+=2){
        if(s[i-1] == 'h' && s[i] == 'i');
        else {
            flag = false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

const int maxn=2000+10;

int cnt[maxn];
ll ans[maxn];

const int MOD=1e9+7;

int sum(int l,int r){
	int ret=0;
	rep(i,l,r) ret+=cnt[i];
	return ret%MOD;
}
int a[maxn];
int main()
{
	int n,k;cin>>n>>k;
	rep(i,1,n) cin>>a[i];
	rep(i,1,n)
	{
		ans[i]=1ll*sum(a[i]+1,2000)*k%MOD;
		++cnt[a[i]];
	}
	ll Ans=0;
	rep(i,1,n){
		ans[i]=(ans[i]+1ll*k*(k-1)/2%MOD*sum(a[i]+1,2000))%MOD;
		Ans+=ans[i];
	}
	cout<<Ans%MOD<<endl;
	return 0;
}


Measured memory_bytes: 256
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    const int N = 5e5;
    int a[N] = {0};

    a[0] = 1;
    a[1] = 1;

    vi v;

    for(int i=2;i<N;++i) {
    	if(a[i] == 0) {
    		v.pb(i);

    		for(int j=2*i;j<N;j+=i)
    			a[j] = 1;

    	}
    }

    // cout<<v.size()<<"\n";

    ll x;
    cin>>x;

    for(int j: v) {
    	if(j >= x) {
    		cout<<j<<"\n";
    		break;
    	}
    }

    return 0;
}

Measured memory_bytes: 2560
//In The Name of ALLAH//

/*      ______     _    _______
       |  ___ \   | |  |  ____/   /\
       | |   \ \  | |  | |       /  \
       | |___/ /  | |  | |___   / /\ \
       |     _/   | |  |  __/  / /__\ \
       | |\ \     | |  | |    / ______ \
       | | \ \    | |  | |   / /      \ \
       |_|  \_\   |_|  |_|  /_/        \_\
*/

#include<bits/stdc++.h>

//#define FILEIO
#define ll long long

using namespace std;

const int SZ = 100005;
const int LIM = 1000000000;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
    return (a > b);
}

void solve()
{
    ll n, nw, wt[110], v[110];
    cin >> n >> nw;
    ll kp[n + 5][nw + 5];
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= nw; j++)
        {
            kp[i][j] = 0;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> wt[i] >> v[i];
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= nw; j++)
        {
            if(wt[i] > j)
            {
                kp[i][j] = kp[i - 1][j];
            }
            else
            {
                kp[i][j] = max(kp[i - 1][j], kp[i - 1][j - wt[i]] + v[i]);
            }
        }
    }

   /* for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= nw; j++)
        {
            cout << kp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << kp[n][nw] << endl;
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    //int tc;

    //cin >> tc;
    //while(tc--)
    {
        solve();
    }

    return 0;
}





Measured memory_bytes: 82320
import Data.List (sort)
import Data.Bool (bool)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  xs <- sort . map read . words <$> getLine
  let
      ds = reverse $ sort $ zipWith subtract xs (tail xs)
      gaps = sum $ take (n - 1) ds
  print $ bool 0 (last xs - head xs - gaps) (n < m)


Measured memory_bytes: 32508
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, mx = 0;
    cin >> n;
    map<string, int> tb;
    string s;
    FOR(i, 0, n)
    {
        cin >> s;
        if(tb.find(s) == tb.end())
        {
            tb[s] = 0;
        }
        tb[s] += 1;
        if(mx < tb[s])
        {
            mx = tb[s];
        }
    }
    for(auto it: tb)
    {
        if(it.S == mx)
        {
            cout << it.F << '\n';
        }
    }
}


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

minus=0
abssum=0
absmin=10**9
for i in range(0,N):
    if A[i]<0:
        minus=minus+1
    if abs(A[i])<absmin:
        absmin=abs(A[i])
    abssum=abssum+abs(A[i])

if minus%2==0:
    print(abssum)
else:
    print(abssum-2*absmin)


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int main(){
	int a=read(),b=read();
	int n=b-a;
	int s=0;
	for(int i=1;i<=n;i++){
		s+=i; 
	}
	cout<<s-b;
	return 0;
}


Measured memory_bytes: 256
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll logx=30;
const ll N=1e3+5;
const ll INF=1e18+5;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)
 
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
int main()
{
  ll n;
  cin>>n;
  string s;
  ll ans=0;
  set<string> ser;
  map<string,ll> cnt;
  for(ll i=0;i<n;i++)
  {
    cin>>s;
    sort(all(s));
    ser.insert(s);
    cnt[s]++;
  }
  for(auto i:ser)
  {
    ll cur=cnt[i];
    ans+=(cur*(cur-1))/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}


int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());


    ll x;
    cin >> x;
    ll ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x/5);
    cout << ans;

    
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(char, b);

  map<char, char> mp;
  mp['A'] = 'T', mp['T'] = 'A', mp['C'] = 'G', mp['G'] = 'C';

  outl(mp[b]);

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  if (s == "ARC") cout << "ABC" << endl;
  return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    cin >> S;
    vector<vector<bool>> vis(H, vector<bool>(W));
    int ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (vis[i][j]) continue;
            int bl = 0, wh = 0;
            vis[i][j] = true;
            (S[i][j] == '#' ? bl : wh)++;
            queue<pii> q;
            q.push({i, j});
            while (!q.empty()) {
                int y = q.front().first;
                int x = q.front().second; q.pop();
                REP(d, 4) {
                    int yy = y + DY[d];
                    int xx = x + DX[d];
                    if (!INSEG(0, yy, H) || !INSEG(0, xx, W)) continue;
                    if (vis[yy][xx]) continue;
                    if (S[y][x] == S[yy][xx]) continue;
                    vis[yy][xx] = true;
                    (S[yy][xx] == '#' ? bl : wh)++;
                    q.push({yy, xx});
                }
            }
            ans += bl * wh;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n[3];
	cin>>n[0]>>n[1]>>n[2];
	sort(n,n+3);
	cout<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
	return 0;
}



Measured memory_bytes: 3116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = sc.nextInt() + sc.nextInt() + sc.nextInt();
        if (sum >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 21716
n = int(input())
a = [int(input()) for _ in range(n)]

ans, tmp = 0, 0
for i in range(n - 1, 0, -1):
    if a[i] - a[i - 1] > 1:
        print(-1)
        break
    if tmp != a[i]:
        ans += a[i]
    tmp = max(a[i] - 1, 0)
else:
    print(ans if a[0] == 0 else - 1)


Measured memory_bytes: 83504
while True:
    n,x = map(int,raw_input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for a in xrange(1,n+1):
        for b in xrange(1,n+1):
            if a == b:
                break
            for c in xrange(1,n+1):
                if a == c or b == c:
                    break
                if a+b+c == x:
                    count +=1
    print count

Measured memory_bytes: 4212
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  string s; cin>>s;
  bool ok = false;
  FORN(i,0,s.size()) if(s[i] == '7') ok = true;
  cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define mod 1000000007
#define N 1005
using namespace std;

int n, m, a[N], b[N], f[N][N], cost[N][N], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	while(y)
	{
		if(y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1; 
	}
	return res; 
}

int main()
{
	n = read <int> (), m = read <int> (); 
	for(int i = 1; i <= n; i++)
		a[i] = read <int> ();
	for(int i = 1; i <= n; i++)
		b[i] = read <int> ();
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= m; j++)
			for(int k = a[i]; k <= b[i]; k++)
				cost[i][j] = (1ll * cost[i][j] + fpow(k, j)) % mod;
	f[0][0] = 1; 
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= m; j++)
			for(int k = 0; k <= j; k++)
				f[i][j] = (1ll * f[i][j] + 1ll * f[i - 1][k] * cost[i][j - k] % mod) % mod; 
	printf("%d\n", f[n][m]); 
	return 0; 
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;
}

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

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

int main() {
  ll k, x;
  cin >> k >> x;

  ll minimum = -1000000;
  ll maximum = 1000000;
  
  for(ll i = x - (k-1); i < x + k; i ++){
    if(i < minimum || i > maximum) continue;
    cout << i << " ";
    
  }
  

}



Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x = x ^ a[i];
    }
    if (x == 0)
    {
        cout << 0;
        return 0;
    }
    int ans = 0;
    vector<int> b = a;
    for (int j = 30; j >= 0; j--)
    {
        int t = 0;
        if (x & (1 << j))
        {
            for (int i = 0; i < n; i++)
            {
                if (b[i] == a[i] && (b[i] & (1 << j)) && !(b[i] & ((1 << j) - 1)))
                {
                    x ^= b[i];
                    b[i]--;
                    x ^= b[i];
                    t = 1;
                    break;
                }
            }
            if (!t)
            {
                cout << -1;
                return 0;
            }
            else
            {
                ans++;
            }
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> t(n+1);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        t[a].push_back(b);
        t[b].push_back(a);
    }

    bitset<100'010> v;
    v[1] = v[n] = 1;
    queue<pair<int, int>> q;
    q.emplace(1, 0);
    q.emplace(n, 1);
    vector<int> s { 1, 1 };
    while (!q.empty()) {
        auto tmp = q.front(); q.pop();
        for (auto& e : t[tmp.first]) {
            if (v[e]) continue;
            q.emplace(e, tmp.second);
            s[tmp.second]++;
            v[e] = 1;
        }
    }
    cout << (s[0] > s[1] ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0]!=s[3] && s[0]==s[1] && s[2]==s[3]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main(){
 int n;
 cin >> n;
 long n_num[n];
 for( int i=0; i<n; i++ ){
   cin >> n_num[i];
 }

 int q;
 cin >> q;
 long q_num;
 int count = 0;
 for( int j=0; j<q; j++ ){
   cin >> q_num;
   for( int i=0; i<n; i++ ){
     if( q_num == n_num[i] ){
       count++;
       break;
     }
   }
 }

 cout << count << endl;

 return 0;
}


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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    bool a[n];
    for (int i = 0; i < n; i++)
    {
        a[i] = false;
    }
    int count = 0;
    while (k--)
    {
        int d;
        cin >> d;
        while (d--)
        {
            int b;
            cin >> b;
            if (a[b - 1] == false)
            {
                a[b - 1] = true;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] == false)
            count++;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  while (N != 0) {
    if (N % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

int dx[4] = { 0, -1, 1, 0 };
int dy[4] = { -1, 0, 0, 1 };

int main() {
  int x;
  cin >> x;
  vector<bool> expo(x + 1);

  expo[1] = 1;
  for (int b = 2; b <= x; ++b) {
    int v = b * b;
    while (v <= x) {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = x; i >= 1; --i) {
    if (expo[i]) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
n = int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if (p[i]<p[i+1] and p[i-1]<p[i]) or (p[i]>p[i+1] and p[i-1]>p[i]):
        ans=ans+1
print(ans)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int res = 0, maxi = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a > maxi) {
      maxi = a;
      res = a + b;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
 
int p2[101010];
int p3[101010];
 
string s;
int n;
 
int dp(int i) {
  if(i == n) return 1;
 
  int r = 0;
  if(s[i] == '1') {
    r = (r + p3[n-1-i]) % MOD;
    r = (r + 1LL*dp(i+1)*2) % MOD;
  }
  else {
    r = dp(i+1);
  }
 
  return r;
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 
  cin >> s;
  n = s.size();
 
  p2[0] = p3[0] = 1;
  for(int i=1; i<=100000; i++) p2[i] = (p2[i-1] * 2) % MOD;
  for(int i=1; i<=100000; i++) p3[i] = (1LL * p3[i-1] * 3) % MOD;
 
  cout << dp(0) << endl;
 
  return 0;
}

Measured memory_bytes: 4432
N, K, L=map(int, input().split())

R=[[] for i in range(N)]
T=[[] for i in range(N)]


class UnionFind():
  # 作りたい要素数nで初期化
  # 使用するインスタンス変数の初期化
  def __init__(self, n):
    self.n = n
    # root[x]<0ならそのノードが根かつその値が木の要素数
    # rootノードでその木の要素数を記録する
    self.root = [-1]*(n+1)
    # 木をくっつける時にアンバランスにならないように調整する
    self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
    # ここで代入しておくことで、後の繰り返しを避ける
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

    # 木の併合、入力は併合したい各ノード
  def Unite(self, x, y):
    # 入力ノードのrootノードを見つける
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    # すでに同じ木に属していた場合
    if (x == y):
      return 
      # 違う木に属していた場合rnkを見てくっつける方を決める
      #rnkが大きい方に結合
    elif (self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x

    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      # rnkが同じ（深さに差がない場合）は1増やす
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1

  # xとyが同じグループに属するか判断
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  # ノードxが属する木のサイズを返す
  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uniR=UnionFind(N)
for i in range(K):
  p,q=map(int, input().split())
  R[p-1].append(q-1)
  R[q-1].append(p-1)
  
  uniR.Unite(p-1,q-1)
uniT=UnionFind(N)  
for i in range(L):
  r, s=map(int, input().split())
  T[r-1].append(s-1)
  T[s-1].append(r-1)
  
  uniT.Unite(r-1,s-1)
dic = {}  
for i in range(N):
    val = (uniR.Find_Root(i), uniT.Find_Root(i))
    if val in dic:
        dic[val] += 1
    else:
        dic[val] = 1
        
for i in range(N):
    print(dic[(uniR.Find_Root(i), uniT.Find_Root(i))], end=" ")

Measured memory_bytes: 85936
k=int(input())
list=[1,2,3,4,5,6,7,8,9]
for i in range(k-1):
  m=list[i]
  n=m*10+m%10
  if m%10!=0:
    list.append(n-1)
  list.append(n)
  if m%10!=9:
    list.append(n+1)
print(list[k-1])

Measured memory_bytes: 15764
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
	int num;
	// 入力Nを受け取る
	scanf("%d", &num);

	// num % 10で1の位を取得する
	// switch文で各値に対してnum本の本の読み方を出力する
	switch(num % 10){
		case 2: case 4: case 5: case 7: case 9:
			printf("hon");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon");
			break;
		default:
			printf("bon");
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    vector<string> T;
    T.push_back("SUN");
    T.push_back("MON");
    T.push_back("TUE");
    T.push_back("WED");
    T.push_back("THU");
    T.push_back("FRI");
    T.push_back("SAT");

    REP(i,T.size()){
        string x = T[i];
        if(S == x){
            cout << 7-i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x_array = list(map(int, input().split()))
y_array = list(map(int, input().split()))

d1, d2, d3, dx = 0, 0, 0, 0
for i in range(n):
    d1 += abs(x_array[i] - y_array[i])
    d2 += (x_array[i] - y_array[i])**2
    d3 += abs(x_array[i] - y_array[i])**3
    d = abs(x_array[i] - y_array[i])
    if d > dx:
        dx = d
print(d1)
print(d2**0.5)
print(d3**(1/3))
print(dx)


Measured memory_bytes: 5644