akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1'000'000'007;
constexpr ll MOD2   = 998'244'353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int dp[n + 10];

    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }

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

return 0;
}


Measured memory_bytes: 4048
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    l = [[a[i],i] for i in range(len(a))]
    l.sort()
    # eprint("l ",end=": ")
    # eprint(l)
    l_ans=[l[i][1] + 1 for i in range(len(l))]
    print(*l_ans)
    return

if __name__ == '__main__':
    main()

    ''''
    0  1  2 
    2p 3p 1p


    '''


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

int main()
{
    vector<int> a(3);
    rep(i, 0, 3) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    ans += a[2] - a[1];
    a[0] += ans;
    if(a[0]%2 == a[2]%2) ans += (a[2] - a[0])/2;
    else ans += (a[2] - a[0] + 1)/2 + 1;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 2e5 + 7;
int n, f[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int x;
    cin >> x;
    f[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << f[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] y = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        double[] diff = new double[num];

        for (int i = 0; i < num; i++)
        {
            diff[i] = Math.Abs(x[i] - y[i]);
        }

        // p1-p3
        for (double i = 1.0; i < 4.0; i++)
        {
            double sum = 0;

            foreach (double n in diff)
            {
                sum += Math.Pow(n, i);
            }

            double d = Math.Pow(sum, 1.0/i);
            Console.WriteLine(d.ToString("F6"));
        }

        // ???????¨????
        Console.WriteLine(diff.Max().ToString("F6"));
    }
}

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

using namespace std;

int main(void)
{
	std::vector<int> min(10000), max(10000);
	int x, y, cnt = 0;
	
	while(1)
	{
		std::cin >> x >> y;
		
		if( x == 0 && y == 0 ) break;
		
		else if( x >= y )
		{
			min[cnt] = y;
			max[cnt] = x;
		}
		
		else 
		{
			min[cnt] = x;
			max[cnt] = y;
		}
		
		cnt++;
	}
	
	for(int i = 0; i < cnt; i++)
	{
		std::cout << min[i] << " " << max[i] << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> d(n);rep(i,n){cin>>d[i];}
    ll res = 0;
    rep(i,n) {
        repr(j, i+1, n) {
            res += d[i]* d[j];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
List = [] * N
List = input().split(" ")
for i in range(N):
    List[i] = float(List[i]) 
List.sort()
for i in range(N-1):
    List[i+1] = ( List[i] + List[i+1] ) / 2
print(List[N-1])

Measured memory_bytes: 3060
n, m, x = map(int,input().split())
books = []
for i in range(n):
    books.append(list(map(int,input().split())))
mi = 10**100
s = "0"+str(n)+"b"

for i in range(2**n):
    p = [0 for j in range(m)]
    money = 0
    k = str(format(i, s))
    for j in range(n):
        if k[j] == "1":
            money += books[j][0]
            for l in range(m):
                p[l] += books[j][l+1]
    if min(p) >= x and mi > money:
        mi = money

if mi == 10**100:
    print(-1)
else:
    print(mi)


Measured memory_bytes: 9228
#include<cstdio>

char s[1111];
int v[1111];

int main() {
	scanf("%s", s);
	for(int i=0;s[i];i++)
		v[s[i]]++;
	if(v['W'] && !v['E'] ||
	   !v['W'] && v['E'] || 
	   v['N'] && !v['S'] ||
	   !v['N'] && v['S']) 
		printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

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

is_prime = primes(10**5)
like = [False] * 10**5
for i in range(3, 10**5, 2):
    if is_prime[i] and is_prime[(i+1)//2]:
        like[i] = True

cusum = [0] * 10**5
for i in range(3, 10**5, 2):
    cusum[i] = cusum[i-2] + like[i]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())

    if l == 1:
        print(cusum[r])
    else:
        print(cusum[r] - cusum[l-2])

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // i番目がそれまでのやつより小さい.
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    int min = 1e9;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (min > P[i]) {
            cnt++;
            min = P[i];
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
n, d = map(int, input().split())
ans = [-1]*3
for x in range(n+1):
    for y in range(n-x+1):
        if d == 10000*x + 5000*y + 1000*(n-x-y):
            ans = [x, y, n-x-y]
        # if zd//1000 == n-x-y:
        #     ans[0] = x
        #     ans[1] = y
        #     ans[2] = zd//1000
        #     break
print(*ans)

Measured memory_bytes: 2940
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

int n,m;
char s[22][22],c[22];
string f[22];
int fuck[22][22],fuck2[22][22];
int g[22][22];
int a[22];

bool dfs2(int i,int msk)
{
//	cout<<i<<' '<<msk<<endl;
	if(i==-1)
		return true;
	int u=m-1-i;
	if(u==i)
	{
		for(int j=0;j<m;j++)
			if(dfs2(i-1,msk|(1<<j)))
				return true;
	}
	else 
	{
		int t=0;
		while(msk&(1<<t)) t++;
		msk|=1<<t;
		for(int j=0;j<m;j++)
			if((msk&(1<<j))==0&&fuck2[t][j])
				if(dfs2(i-1,msk|(1<<j)))
					return true;
	}	
	return false;
}

bool dfs(int i,int msk)
{
	if(i==-1)
	{
		for(int ii=0;ii<m;ii++)
			for(int j=0;j<m;j++)
			{
				bool flag=1;
				for(int k=0;k<n;k++)
					if(s[a[k]][ii]!=s[a[n-1-k]][j])
					{
						flag=0;
						break;
					}
				fuck2[ii][j]=flag;
			}
//		for(int ii=0;ii<m;ii++) for(int j=0;j<m;j++) cout<<fuck2[ii][j]; 
		return dfs2((m-1)/2,0);
	}
	int u=n-1-i;
	if(u==i)
	{
		for(int j=0;j<n;j++)
		{
			a[i]=j;
			if(dfs(i-1,msk|(1<<j)))
				return true;
		}
	}
	else 
	{
		int t=0;
		while(msk&(1<<t)) t++;
		a[i]=t;
		msk|=1<<t;
		for(int j=0;j<n;j++)
			if((msk&(1<<j))==0&&fuck[t][j])
			{
				a[u]=j;
				if(dfs(i-1,msk|(1<<j)))
					return true;	
			}
	}
	return false;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			c[j]=s[i][j];
		sort(c,c+m);
		f[i]="";
		for(int j=0;j<m;j++)
			f[i]+=c[j];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			fuck[i][j]=(f[i]==f[j]);
	puts(dfs((n-1)/2,0)?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<vector<long long> > x(n, vector<long long>(3));
    for(int i=0; i<n; ++i){
        for(int j=0; j<3; ++j){
            cin >> x[i][j];
        }
    }

    long long ans = 0;
    for(int i=0; i<8; ++i){
        bitset<3> bs(i);
        vector<long long> v(n);
        for(int j=0; j<n; ++j){
            for(int k=0; k<3; ++k){
                if(bs[k])
                    v[j] += x[j][k];
                else
                    v[j] -= x[j][k];
            }
        }
        sort(v.rbegin(), v.rend());
        long long tmp = accumulate(v.begin(), v.begin() + m, 0LL);
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, ans = 0;
  string S;
  cin >> N >> S;
  
  for(int i = 0; i < N-2; i++) {
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C') ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;

    char mark = 'a';
    int ca = 0;
    int cb = 0;
    int cc = 0;
    for(;;) {
        if (mark == 'a') {
            if (ca > Sa.size() - 1) {
                print('A');
                return 0;
            }
            mark = Sa[ca];
            ca++;
        } else if (mark == 'b') {
            if (cb > Sb.size() - 1) {
                print('B');
                return 0;
            }
            mark = Sb[cb];
            cb++;
        } else {
            if (cc > Sc.size() - 1) {
                print('C');
                return 0;
            }
            mark = Sc[cc];
            cc++;
        }
    }
}

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

for i in range(0,N-1,2):
    if A[i+1] > 0 and abs(A[i]) < abs(A[i+1]):
        break
    if A[i] > 0 and A[i+1] > 0:
        break
    A[i] *= -1
    A[i+1] *= -1
print(sum(A))


Measured memory_bytes: 14412
def main():
    from sys import stdin
    input = stdin.readline
    mod = 10**9+7
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    pow2 = [1]
    for i in range(200000):
        pow2.append(pow2[-1]*2 % mod)

    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    root = 0
    d = [-1]*n
    d[root] = 0
    q = [root]
    cnt = 0
    while q:
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq

    for i in range(n):
        di = d[i]
        g[i] = [j for j in g[i] if di <= d[j]]

    d = [j for i, j in sorted([(j, i) for i, j in enumerate(d)])]
    dp = [(0, 0, 1) for _ in [0]*n]

    for i in d[::-1]:
        if g:
            n = sum([dp[j][2] for j in g[i]])+1
            x, y = pow(2, n-1, mod)-1, 0
            for j in g[i]:
                xj, yj, nj = dp[j]
                p1, p2 = pow2[n-nj], pow2[nj]
                x += xj*p1+yj*(p1-1)-p2+1
                y += yj+p2-1
            dp[i] = (x % mod, y % mod, n)

    x = dp[0][0]
    y = pow(2, dp[0][2], mod)
    print(x*pow(y, mod-2, mod) % mod)


main()


Measured memory_bytes: 122252
public class Main
{
  int[ ] f;

  public int
  fibonacci (
    int n
    )
  {
    if ( n == 0 ) return ( 1 );
    if ( n == 1 ) return ( 1 );
    if ( f[ n ] == -1 )
    {
      f[ n ] = fibonacci ( n - 1 ) + fibonacci ( n - 2 );
    }

    return ( f[ n ] );
  }

  public void
  run (
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int n;
    int i;

    n = sc.nextInt ( );
    f = new int[ n + 1 ];
    for ( i = 0; i < f.length; ++i )
      f[ i ] = -1;

    System.out.println ( fibonacci ( n ) );

    return ;
  }

  public static void main ( String[ ] args )
  {
    ( new Main ( ) ).run ( );

    return ;
  }

}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int ans = 0;
  int n,k;cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(All(p));
  for(int i=0;i<k;i++){
    ans += p[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    cout<<(n+d-1)/d;
	return 0;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CY cout<<"Yes\n"
#define CN cout<<"No\n"
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<ll> dp(100005,-1);

void solve()
{
    int x,y; cin>>x>>y;
    set<int>s;
    rep(i,y) {int k; cin>>k; s.insert(k);}
    int a=x,b=x;
    while(1)
    {
        if(s.find(a)==s.end())
            break;
        a--;
    }
    while(1)
    {
        if(s.find(b)==s.end())
            break;
        b++;
    }
    if(abs(a-x)<=abs(b-x)) cout<<a;
    else cout<<b;

}
int main() {
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    ll t;t=1;
 // cin>>t;
    while(t--) solve();
}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int>vec(N),aida(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  for(int i=0; i<N-1; i++){
    aida[i] = vec[i+1]-vec[i];
  }
  aida[N-1] = vec[0]+K-vec[N-1];
  sort(aida.begin(),aida.end());
  cout << K-aida[N-1] << endl;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define all(x)        (x).begin(),(x).end()
#define isWorking()   cout<<"Wroking"<<endl
#define FOR(i,x,y)    for(int i=x; i<y; i++)
#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl
#define SetPrint(a,x) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input

//    cin>>testCase;
    while(testCase--) {

        int n; cin>>n;
        map <string,int> F;
        int maxCnt=0;
        string str;
        for(int i=0; i<n; i++){
            cin>>str;
            F[str]++;
            maxCnt=max(maxCnt,F[str]);
        }
        vector <string> v;
        for(auto it=F.begin(); it!=F.end(); it++){
            if(it->sv==maxCnt) v.push_back(it->fv);
        }
        sort(all(v));
        for(int i=0; i<v.size(); i++) cout<<v[i]<<endl;
    }
    return 0;
}


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));

    n = a.size();
    const ll sum = accumulate(begin(a), end(a), 0LL);
    if(n == 1) {
        cout << sum << endl;
    } else if(n == 2) {
        cout << sum - 1 << endl;
    } else if(n == 3) {
        cout << sum - 3 << endl;
    } else if(n == 4) {
        if(a[3] == 2) {
            cout << 4 << endl;
        } else if(a[0] == 2) {
            cout << sum - 5 << endl;
        } else {
            cout << sum - 6 << endl;
        }
    } else {
        if(a[4] == 2) {
            cout << 4 << endl;
        } else if(a[4] == 3) {
            if(a[3] == 2) {
                cout << 5 << endl;
            } else if(a[1] == 3) {
                cout << sum - 8 << endl;
            } else {
                cout << sum - 7 << endl;
            }
        } else {
            if(a[0] >= 4) {
                cout << sum - 10 << endl;
            } else if(a[1] >= 4) { // a[0] <= 3
                cout << sum - 6 - a[0] << endl;
            } else if(a[2] >= 4) { // a[0] <= 3 && a[1] <= 3
                cout << sum - 3 - (a[0] + a[1]) << endl;
            } else if(a[3] >= 4) { // a[0] <= 3 && a[1] <= 3 && a[2] <= 3
                if(a[0] == 3) {
                    cout << sum - 9 << endl;
                } else if(a[1] == 3) {
                    cout << sum - 8 << endl;
                } else {
                    cout << sum - 7 << endl;
                }
            } else { // ...
                if(a[0] == 3) {
                    cout << sum - 8 << endl;
                } else if(a[1] == 3) { // a[0] == 2
                    cout << sum - 8 << endl;
                } else if(a[2] == 3) { // a[0] == a[1] == 2
                    cout << sum - 7 << endl;
                } else if(a[3] == 3) { // a[0] == a[1] == a[2] == 2
                    cout << sum - 7 << endl;
                } else {
                    cout << sum - 7 << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3160
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n;
pii A[mn];
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    for (int i=1; i<=n; i++) {
        cin>>A[i].XX>>A[i].YY;
        if (n%2==0) A[i].XX*=2, A[i].YY*=2;
    }

    sort(A+1, A+n+1);
    int l = 0;
    if (n%2==0) l = (A[n/2].XX+A[n/2+1].XX)/2;
    else l = A[n/2+1].XX;

    for (int i=1; i<=n; i++) {
        int temp =A[i].XX;
        A[i].XX=A[i].YY;
        A[i].YY=temp;
    }

    sort(A+1, A+n+1);
    int r = 0;
    if (n%2==0) r = (A[n/2].XX+A[n/2+1].XX)/2;
    else r = A[n/2+1].XX;

    cout<<(r-l)+1;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 6776
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



int H, W, K;
char s[310][310];
int ans[310][310];

int main () {
  cin >> H >> W >> K;

  rep(i, H) {
    rep (j, W) {
      cin >> s[i][j];
    }
  }

  int ct = 0;
  vector<int> reserve;

  int tmp_h;

  rep(i, H) {
    bool flg = false;
    int tmp = 0;

    rep (j, W) {
      if (s[i][j] == '#') {
        flg = true;
        ct++;
        for (int k=tmp+1;k<=j;++k) {
          ans[i][k] = ct;
        }
        for (auto h: reserve) {
          for (int k=tmp+1;k<=j;++k) {
            ans[h][k] = ct;
          }         
        }

        tmp = j;
      }
    }

    for (int k=tmp+1;k<=W;++k) {
      ans[i][k] = ct;
      for (auto h: reserve) {
        ans[h][k] = ct;    
      }
    }

    if (!flg) {
      reserve.push_back(i);
    } else {
      reserve.clear();
      tmp_h = i;
    }
  }

  for (auto h: reserve) {
    rep(i, W) {
      ans[h][i] = ans[tmp_h][i];
    }
  }

  rep(i, H) {
    rep (j, W-1) {
      cout << ans[i][j] << " ";
    }
    cout << ans[i][W] << "\n";
  }
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
import collections as cl
import math


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    h, n = MI()
    a = []
    b = []
    for _ in range(n):
        _a, _b = MI()
        a.append(_a)
        b.append(_b)

    max_a = max(a)

    dp = [0] * (h + max_a + 1)

    for i in range(1, h + max_a + 1):
        min_itr = 10**19

        for j in range(n):
            if i - a[j] > 0:
                min_itr = min(min_itr, dp[i - a[j]] + b[j])

            else:
                min_itr = min(min_itr, b[j])

        dp[i] = min_itr

    print(min(dp[h:h+max_a]))


main()


Measured memory_bytes: 74316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,x[110];
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i];
	ll ans=1e18;
	for(int i=0;i<=100;i++){
		ll cnt=0;
		for(int j=0;j<n;j++){
			cnt+=(x[j]-i)*(x[j]-i);
		}
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
#define int long long
#define endl '\n'
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fi first
#define se second
#define F first
#define S second
#define MP make_pair
#define sz(x) (int)x.size()
#define rp(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define fff(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
void solve();
signed main()
{
cin.sync_with_stdio(0);
cin.tie(0);
cin.exceptions(cin.failbit);

int tests=1;
// cin >> tests;
while (tests--)
{
    solve();
}

return 0;
}
void solve(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    if(s=="ARC"){
        cout<<"ABC"<<endl;
    }
}

Measured memory_bytes: 3612
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n, m;
	//cin >> n >> m;
	scanf("%d %d", &n, &m);
	vector< vector< pair<int,int> > > rr(n);
	//vector< vector<int> > rd(n);
	vector<int> pos(n,-1);
	for(int i=0; i<m; ++i)
	{
		int l, r, d;
		//cin >> l >> r >> d;
		scanf("%d %d %d", &l, &r, &d);
		--l, --r;
		rr[l].push_back( make_pair(r,d) );
		//rd[l].push_back(d);
		rr[r].push_back( make_pair(l,-d) );
		//rd[r].push_back(-d);
	}

	vector<bool> aleft(n,true);
	
	bool ans = true;

	queue<int> q;
	int i0 = 0;
	while(ans)
	{
		while(i0 < n && !aleft[i0])
			++i0;
		if(i0 == n)
			break;
		
		pos[i0] = 0;
		q.push(i0);
		aleft[i0] = false;
		
		while(!q.empty() && ans)
		{
			int l = q.front();
			q.pop();
			
			for(int i=0; i<rr[l].size(); ++i)
			{
				int r = rr[l][i].first;
				int p = pos[l] + rr[l][i].second;
				if(!aleft[r] && p != pos[r])
					ans = false;
				
				if(aleft[r])
					q.push(r);
				aleft[r] = false;
				pos[r] = p;
			}
		}
	}
	
	cout << (ans ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 9344
base_num = input("")
base_line = input("")
term = base_line.split(' ')

last_num = int(base_num)-1
sum_num = 0
list_num = list()
for n in term:
    sum_num += int(n)
    list_num.append(int(n))

list_num.sort()

print("{} {} {}".format(list_num[0], list_num[last_num], sum_num))



Measured memory_bytes: 6588
#include <iostream>
#include <set>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, m;
	vector<int> r;
	vector<int> l;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		r.push_back(x);
	}
	
	cin >> m;
	for(int i = 0; i < m; i++) {
		int x;
		cin >> x;
		l.push_back(x);
	}
	sort(r.begin(), r.end());
	sort(l.begin(), l.end());

	vector<int> result;

	set_union(begin(r),end(r),begin(l),end(l),back_inserter(result));

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

	return 0;
}	



Measured memory_bytes: 6472
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;
void merge(int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++)L[i] = A[left + i];
	for (int i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main() {
	int A[MAX], n, i;
	cnt = 0;

	cin >> n;
	for (i = 0; i < n; i++)cin >> A[i];

	mergeSort(A, n, 0, n);

	for (i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;

	return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAX = 400;

ll dp[MAX][MAX];

ll cumul_sum[MAX];
int N;

ll run(int l, int r)
{
	if (dp[l][r] != -1) return dp[l][r];

	ll sum = cumul_sum[r] - (l ? cumul_sum[l-1] : 0);
	dp[l][r] = 1e18;
	for (int j(l); j < r; ++j)
		dp[l][r] = min(dp[l][r], run(l, j) + run(j+1, r) + sum);
	return dp[l][r];
}

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	FOR(i,0, MAX) FOR(j,0, MAX) dp[i][j] = -1;
	FOR(i,0, MAX) dp[i][i] = 0;
	read(N);
	FOR(i,0,N) 
	{
		read(cumul_sum[i]);
		if (i)
			cumul_sum[i] += cumul_sum[i-1];
	}

	pnl(run(0, N-1));
}



Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int INF=(1<<21);
int n;
vector< pair<int,int> >adj[101];

void dijkstra(){
  priority_queue<pair<int,int> >pq;
  int color[101];
  int d[101];
  for(int i=0;i<n;++i){
    d[i]=INF;
    color[i]=WHITE;
  }
  d[0]=0;
  pq.push(make_pair(0,0));
  color[0]=GRAY;
  while(!pq.empty()){
    pair<int,int>f=pq.top();
    pq.pop();
    int u=f.second;
    color[u]=BLACK;
    if(d[u]<f.first*(-1)) continue;
    
    for(int j=0;j<adj[u].size();++j){
      int v=adj[u][j].first;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	pq.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }
  for(int i=0;i<n;++i){
    cout<<i<<" "<<(d[i]==INF? -1 : d[i] )<<endl;
  }
}
int main(){
  int k,u,v,c;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>u>>k;
    for(int j=0;j<k;++j){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 3084
import math
N = int(input())
tc,ts,tf = 0,0,0
C, S, F, =[], [], []
t = 0
for i in range(N-1):
    tc,ts,tf = map(int,input().split())
    C.append(tc)
    S.append(ts)
    F.append(tf)
#print(C,S,F)
for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        if t <= S[j]:
            t = S[j] + C[j]
        else:
            t = math.ceil(t/F[j]) * F[j] + C[j]
    print(t)
print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<int> b(3,0);
    for(i = 0;i < n;++i){
        if(a.at(i)%4 == 0){
            ++b.at(0);
        }else if(a.at(i)%2 == 0){
            ++b.at(1);
        }else{
            ++b.at(2);
        }
    }
    if(b.at(1) == 0){
        if(b.at(0) >= b.at(2)-1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
       if(b.at(0) >= b.at(2)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        } 
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int a[100000];
int b[100000];

int main() {
  int n;
  scanf("%d",&n);
  int au=0,al=0,bu=0,bl=0;
  REP(i,n) {
    int x,y;
    scanf("%d%d",&x,&y);
    a[i] = x+y;
    b[i] = x-y;
    if (a[au] < a[i]) au = i;
    if (a[al] > a[i]) al = i;
    if (b[bu] < b[i]) bu = i;
    if (b[bl] > b[i]) bl = i;
  }
  // auとalを分け、buとblを分けたい
  // au,bu と al,bl に分ける
  int tmp = 0;
  REP(i,n) {
    tmp = max(tmp, min(
                max(a[au]-a[i], b[bu]-b[i]), // au,bu
                max(a[i]-a[al], b[i]-b[bl]))); // al,bl
  }
  int ans = tmp;
  // au,bl と al,bu に分ける
  tmp = 0;
  REP(i,n) {
    tmp = max(tmp, min(
                max(a[au]-a[i], b[i]-b[bl]), // au,bl
                max(a[i]-a[al], b[bu]-b[i]))); // al,bu
  }
  ans = min(ans, tmp);
  printf("%d\n", ans);
}

Measured memory_bytes: 1968
#include<bits/stdc++.h>
using namespace std;
int f[10]={1,1,2,6,24,120,720,5040,40320,362880};
int can(int a[],int n)
{
    int ans=0;
    for(int i=0;i<n;i++)
	{
        int num=0;
        for(int j=i+1;j<n;j++)
		    if(a[j]<a[i]) num++;
        ans+=num*f[n-i-1];
    }
    return ans+1;
}
int n,a,b,s[10];
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>s[i];
    a=can(s,n);
    for(int i=0;i<n;i++) cin>>s[i];
    b=can(s,n);
    cout<<abs(a-b);
    return 0;
}

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

int main() {
    int n;
    vector<int> a, dp;

    cin >> n;
    a.resize(n);
    dp.resize(n + 1);
    for (int &elem : a) {
        cin >> elem;
    }

    dp[2] = abs(a[0] - a[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i - 2] + abs(a[i - 1] - a[i - 3]), dp[i - 1] + abs(a[i - 1] - a[i - 2]));
    }

    cout << dp[n] << "\n";
    return 0;
}


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

int n;
int can[25];
int dp[2100000];

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, n){
			int aij;
			scanf("%d", &aij);
			can[i] |= (aij << j);
		}
	}
	dp[0] = 1;
	rep(i, n){
		int j = can[i];
		rep(mask, (1 << n)){
			if(__builtin_popcount(mask) != i) continue;
			if(dp[mask] == 0) continue;
			j = can[i];
			while(j > 0){
				int now = j & (-j);
				if((mask | now) != mask) dp[mask | now] = (dp[mask | now] + dp[mask]) % Mod;
				j ^= now;
			}
		}
	} 
	cout << dp[(1 << n) - 1] << endl;
	return 0;
} 

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

VV G;
V c, dp;
Vll ans;
ll s = 0;

void dfs(int u, int p=-1) {
  ll tmp = dp[c[u]] + s;
  for (auto v : G[u]) {
    if (v == p) continue;
    ll tmp2 = dp[c[u]] + s;
    dfs(v, u);
    ll x = dp[c[u]] + s - tmp2;
    ans[c[u]] -= x*(x+1)/2;
  }
  ++s;
  dp[c[u]] = tmp - s;
}

int main() {
  ll n; cin >> n;
  G.assign(n, V());
  c.assign(n, 0);
  dp.assign(n, 0);
  ans.assign(n, n*(n+1)/2);

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);
  rep(i, n) {
    ll x = dp[i] + s;
    ans[i] -= x*(x+1)/2;
  }

  rep(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 32976
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;;
typedef vector<pii> vii;
typedef vector<vii> vvii;


const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 100000;
const int MAX_M = 200000;

int N, M, L, R, D;
int pos[MAX_N];
bool used[MAX_N];
vvii dist(MAX_N);

bool dfs(int x) {
  if (used[x]) return true;
  used[x] = true;
  for (vii::iterator it=dist[x].begin(); it!=dist[x].end(); ++it) {
    if (pos[it->first] == INF) {
      pos[it->first] = pos[x] + it->second;
      if (!dfs(it->first)) {
        return false;
      }
    } else {
      if (pos[it->first] != pos[x] + it->second) {
        return false;
      }
    }
  }
  used[x] = false;
  return true;
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    pos[i] = INF;
    used[i] = false;
  }
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D; L--; R--;
    dist[L].PB(MP(R, D));
    dist[R].PB(MP(L, -D));
  }
  for (int i = 0; i < N; i++) {
    if (pos[i] == INF) pos[i] = 0;
    if (!dfs(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
using namespace std; vector<int> p(11000);
vector<int> q(500);
int main()
{
    int n, r; cin >> n; int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    cin >> r;
    for (int i = 0; i < r; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < n; j++) {
            if (q[i] == p[j]) {
                ++sum;
                break;
            }
        }
    }
    cout << sum << endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n,d;cin>>n>>d;
    VL x(n),y(n);
    REP(i,n){
        cin>>x[i]>>y[i];
    }
    LL result = 0;
    REP(i,n){
        if(x[i]*x[i] + y[i]*y[i] <= d*d){
            result++;
        }
    }
    cout<<result<<endl;

	return;
}

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

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

using namespace std;

uint32_t distance(int a, int b, int x, int y)
{
    uint32_t ans1 = abs(b - a);
    uint32_t ans2 = abs(x - a) + abs(y - b) + 1;
    return min<int>(ans1, ans2);
}

int main()
{
    int k, x, y;

    cin >> k >> x >> y;

    vector<int> ans(k - 1);

 
    for(int i = 1; i <= k; ++i)
    {
        for(int j = i + 1; j <= k; ++j)
        {
            uint32_t a = distance(i, j, x, y);
            if(a <= k)
                ++ans[a - 1];
        }
    }
    
    for(int i = 0; i < k - 1; ++i)
    {
        cout << ans[i] << "\n";
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	n *= 2;
	vector<int> vec;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		vec.push_back(x);
	}
	sort(vec.begin(), vec.end());
	int sum = 0;
	for (int i = 0; i < n; i += 2) {
		sum += vec[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

if __name__ == '__main__':
    l = map(int, sys.stdin.read().split())
    for i in range(0, len(l)):
        for j in range(i + 1, len(l)):
            if l[j] < l[i]:
                l[j], l[i] = l[i], l[j]
    print l[0], l[1], l[2]


Measured memory_bytes: 4648