akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    string S;
    int ans = 1000;
    cin >> S;
//    cout << ((S.length() / 3) * 3) << endl;
    for(int i =  0; i < ((S.length() / 3) * 3); i++){
        int temp = 0;
        int k = 100;
        int x = i;
        for(int j = 0; j < 3; j++){
            temp += (k * (S[x] - '0'));
            k /= 10; 
            x++;
        }
//        cout << temp << endl;
        ans = min(ans, abs(753 - temp));
    }    
        cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  map<ll, bool> mp;
  for (ll i = 1; ; i++) {
    if (i < n) {
      mp[i] = true;
      n -= i;
    }
    else if (i == n) {
      mp[i] = true;
      break;
    }
    else {
      mp[i - n] = false;
      mp[i] = true;
      break;
    }
  }
  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (i -> second) cout << (i -> first) << endl;
  }
}

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

int main() {
  int a,b,c;
  cin >> a>>b>>c;
  if(a+b>=c) cout<<"Yes"<<endl;
  else cout << "No"<<endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N, M;
	cin >> N >> M;

	int l, r;
	vector<vector<int>> edges(N);
	for (int i = 0; i < M; i++) {
		cin >> l >> r;
		edges[l - 1].emplace_back(r - 1);
	}

	int ans = 0, cnt = 0, tmp = INF;
	while (cnt < N) {

		if (!edges[cnt].empty()) {
			sort(edges[cnt].begin(), edges[cnt].end());
			tmp = min(tmp, edges[cnt].front());
		}

		if (tmp <= cnt + 1) {
			tmp = INF;
			ans++;
		}

		cnt++;

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5760
#N:生徒の人数、A:登校記録のリスト、i:出席番号、B:登校した生徒の順番のリスト

N=int(input())
A=list(map(int,input().split()))
B=[0 for h in range(N)]
for i in range(1,N+1):
    B[A[i-1]-1]=i
for j in range(N):
    print(B[j],end=" ")


Measured memory_bytes: 14008
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                int cnt = 0;
                for (int si = 0; si < n; si++) {
                    if (cnt == 0 && s[si] - '0' == i) cnt++;
                    else if (cnt == 1 && s[si] - '0' == j) cnt++;
                    else if (cnt == 2 && s[si] - '0' == k) cnt++;
                }
                if (cnt == 3) ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d",&a, &b);

    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2056
import sys

N = int(input())
A = []
[A.append([]) for _ in range(N)]

for i in range(N):
    for j in range(int(input())):
        x , y = map(int,input().split())
        A[i].append([x,y])

maxT = 0

for i in range(2**N ):
    ju = [0] * N
    ind = 0

    trust = 0
    for b in reversed(str(bin(i))[2::]):
        if b == "1":
            ju[ind] = 1
            trust += 1
        ind += 1
    
    flag = 0
    for n in range(N):

        if ju[n] == 0:
            continue

        for  y in A[n]:
            if ju[y[0]-1] != y[1]:
                flag = 1
                break
        
        if flag == 1:
            break
        
    if flag == 0:
        maxT = max(maxT , trust )

print(maxT)







Measured memory_bytes: 3064
using System;
using System.Linq;

class ABC119B{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var Sum = 0.0;
        var input = new String[]{};
        foreach(var n in Enumerable.Range(0,N)){
            input = Console.ReadLine().Split();
            switch(input[1]){
                case "BTC":
                    Sum += double.Parse(input[0])*380000;
                    continue;
                case "JPY":
                    Sum += double.Parse(input[0]);
                    continue;
            }
        }
        Console.WriteLine(Sum);
    }
}

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

int main(){
	long long n=0;
	std::cin>>n;

	std::vector<bool> isPrime(1000001, true);
	isPrime[0]= false;
	isPrime[1]= false;
	
	for(int i=0; i<1000001; i++){
		if(!isPrime[i])
			continue;

		for(int j=2*i; j<1000001; j+=i)
			isPrime[j]= false;
	}

	std::vector<int> primeList;
	for(int i=0; i<1000001; i++){		
		if(isPrime[i])
			primeList.push_back(i);
	}

	std::vector<int> sum(50, 0);
	for(int i=1; i< 49; i++){
		sum[i]= sum[i-1]+i;
	}

	bool isLargePrime= false;
	std::vector<int> numPrime(primeList.size(), 0);
	int primeIdx= 0;
	while(n> 1){
		if(primeIdx>= primeList.size()){
			isLargePrime= true;
			break;
		}

		if(n%primeList[primeIdx] == 0){
			n/= primeList[primeIdx];
			numPrime[primeIdx]++;
		}
		else{
			primeIdx++;
		}
	}

	long long ans=0;

	for(int i=0; i< primeList.size(); i++){
		if(numPrime[i]>0){
			int times=0;
			for(int j=0; j<50; j++){
				if(numPrime[i]< sum[j]){
					times= j-1;
					break;
				}				
			}
			ans+= times;

		}
	}

	if(isLargePrime){
		ans+=1;
	}


	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 4180
n = int(input())

mod = 10 ** 9 + 7
dp = [[[0 for _ in range(2)] for _ in range(2)] for _ in range(n)]
dp[0][0][0] = 8
dp[0][0][1] = 1
dp[0][1][0] = 1
dp[0][1][1] = 0

for i in range(n-1):
    for j in range(2):
        dp[i+1][0][0] = (dp[i][0][0] * 8) % mod
        dp[i+1][0][1] = (dp[i][0][0] + dp[i][0][1] * 9) % mod
        dp[i+1][1][0] = (dp[i][0][0] + dp[i][1][0] * 9) % mod
        dp[i+1][1][1] = (dp[i][0][1] + dp[i][1][0] + dp[i][1][1] * 10) % mod

print((dp[-1][-1][-1]) % mod)

Measured memory_bytes: 392716
#include <stdio.h>
#include <math.h>

int main(void) {

  long n,m,d;
  scanf("%ld %ld %ld", &n, &m, &d);
  long all = pow(n,2);
  long beautiful = (n-d)*2;
  if (d == 0) {
    beautiful = n;
  }
  double ans = (beautiful*1.0)/(all*1.0);
  ans *= m-1;
  printf("%.10lf\n", ans);

  return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

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

    N = N % K;

    N = abs(N - K);
    ll ans1 = N;
    N = abs(N - K);
    ll ans2 = N;
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
width,height,x,y,r = map(int, input().split())

if x - r < 0:
    result = "No"

elif y - r < 0:
    result = "No"

elif x + r > width:
    result = "No"

elif y + r > height:
    result = "No"

else:
    result = "Yes"	

print(result)



Measured memory_bytes: 5596
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
	//this is a sample overloading function for sorting stl
	bool operator()(pii const &a, pii const &b)
	{
		if(a.F==b.F)
			return (a.S<b.S);
		return (a.F<b.F);
	}
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        int n=s.size(),cnt=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]!=t[i]) cnt++;
        }
        cout<<cnt<<endl;

    }
    return 0;
}


Measured memory_bytes: 3800
import java.util.Arrays;
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc077/tasks/arc084_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		for(int i=0; i<N; i++) a[i] = Integer.parseInt(sc.next());
		for(int i=0; i<N; i++) b[i] = Integer.parseInt(sc.next());
		for(int i=0; i<N; i++) c[i] = Integer.parseInt(sc.next());
		sc.close();
		
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		
		long[] dpb = new long[N];
		int ci = 0;
		for(int i=0; i<N; i++){
			while(ci<N && b[i]>=c[ci]) ci++;
			dpb[i] = N-ci;
		}
		for(int i=N-2; i>=0; i--){
			dpb[i] = dpb[i]+dpb[i+1];
		}
		int bi = 0;
		long ans = 0;
		for(int i=0; i<N; i++){
			while(bi<N && a[i]>=b[bi]) bi++;
			if(bi>=N) break;
			ans += dpb[bi];
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 63876
import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(int, input().split())) for _ in range(3)]

for j in range(n):
    if not ((a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j]) or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])):
        print("No")
        exit()

for j in range(n):
    if (j % 2) ^ (((a[0][j] - 1) // 3) % 2) == 1:
        print("No")
        exit()

# BIT
def add(a, w, bit):
    x = a
    while x <= 3 * n:
        bit[x] += w
        x += x & -x

def solve(a, bit):
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & -x
    return ret

bit_odd = [0] * (3*n+1)
inv_odd = 0
flip_even = 0
for j in range(n):
    if j % 2 == 1:
        if a[0][j] > a[1][j]:
            flip_even += 1
    else:
        inv_odd += j//2 - solve(a[0][j], bit_odd)
        add(a[0][j], 1, bit_odd)
if flip_even % 2 != inv_odd % 2:
    print("No")
    exit()


bit_even = [0] * (3*n+1)
inv_even = 0
flip_odd = 0
for j in range(n):
    if j % 2 == 0:
        if a[0][j] > a[1][j]:
            flip_odd += 1
    else:
        inv_even += j//2 - solve(a[0][j], bit_even)
        add(a[0][j], 1, bit_even)
if flip_odd % 2 != inv_even % 2:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 23132
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int length(char* str) {
	int i = 0;
	while (str[i]) {
		i++;
	}
	return i;
}

int main() {
	char a[10];
	int b = 0;
	int c = 0;
	cin >> a;
	int d = length(a);
	for (int i = 0; i < d; i++) {
		if (a[i] == 'A' || a[i] == 'T' || a[i] == 'G' || a[i] == 'C') {
			c++;
			if (c > b) {
				b = c;
			}
		}
		else {
			c = 0;
		}
	}
	cout << b;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main() {
  int a, b;
  while(scanf("%d%d", &a, &b) != EOF) {
    if (a==0&&b==0) break;
    if (b < a) printf("%d %d\n", b, a);
    else printf("%d %d\n", a,b);
  }
}


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

int n;
string s[1000000];
using PP = pair<int, int>;
PP cat(const string& t) {
  int cnt = 0;
  int mn = 0;
  for (char c : t) {
    cnt += (c == '(' ? 1 : -1);
    mn = min(mn, cnt);
  }
  return { -mn, cnt };
}

bool ok(vector<PP> v) {
  sort(v.begin(), v.end());
  int cnt = 0;
  for (auto p : v) {
    int a = p.first;
    int b = p.second;
    if (a > cnt) return false;
    cnt += b;
  }
  return true;
}

bool sub() {
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (char c : s[i]) {
      cnt += (c == '(' ? 1 : -1);
    }
  }
  if (cnt != 0) return false;
  
  vector<PP> up;
  vector<PP> dn;
  for (int i = 0; i < n; ++i) {
    auto p = cat(s[i]);
    if (p.second >= 0) {
      up.push_back(p);
    } else {
      dn.push_back({ p.first + p.second, -p.second });
    }
  }
  return ok(up) && ok(dn);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  cout << (sub() ? "Yes" : "No") << endl;  
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    ans += a[i] - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int bj[maxn];
int main()
{
    int n;
    gg(n);
    int d=0;
    int x;
    repd(i,1,n)
    {
    	cin>>x;
    	d=gcd(d,x);
    }
    printf("%d\n",d);
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long signed int ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
string S;
vector<ll> number;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>S;
	REP(i, S.length()) {
		number.push_back(S[S.length()-1-i]-'0');
	}
	ll sum = 0;
	for (int bit = 0; bit < (1 << S.length()-1); ++bit) {
		ll tmp = 1;
		ll tmp2;
		REP(i, S.length()) {
			tmp2 = number[i] * tmp;
			
			if (!(bit & (1 << i))) {
				tmp *= 10;
			}else{
			    tmp=1;
			}
			sum+=tmp2;
		}
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	ll a[n], b[n], c[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	ll ans=0;
	for(int p=0; p<8; p++){
		int s[3], t=p;
		for(int i=2; i>=0; i--){
			s[i]=2*(t%2)-1;
			t/=2;
		}
		ll v[n];
		for(int i=0; i<n; i++){
			v[i]=s[0]*a[i]+s[1]*b[i]+s[2]*c[i];
		}
		sort(v, v+n, greater<ll>());
		ll sum=0;
		for(int i=0; i<m; i++){
			sum+=v[i];
		}
		ans=max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

tmp_ans_Takahashi = A - K

if tmp_ans_Takahashi >= 0:
    print(str(tmp_ans_Takahashi) + " " + str(B))

elif tmp_ans_Takahashi < 0:
    tmp_ans_Aoki = B - (K - A)
    if tmp_ans_Aoki >=0:
        print("0 " + str(tmp_ans_Aoki))
    else:
        print("0 0")

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


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

  map<P,int> mp;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      //ll tmpa=a[i]-a[j];
      //ll tmpb=b[i]-b[j];
      if(i==j)continue;
      mp[P(a[i]-a[j],b[i]-b[j])]++;
    }
  }
  int num=0;
  ll p,q;
  for(auto v : mp){
    //cout << num << endl;
    if(v.second>num){
      p=v.first.first;
      q=v.first.second;
      num=v.second;
    }
  }
  //cout << p << q << endl;
  ll ans=n;
  for(int i=0;i<n;++i){
    ll tmpp=a[i]-p;
    ll tmpq=b[i]-q;
    for(int j=0;j<n;++j){
      if(a[j]==tmpp && b[j]==tmpq) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	bool bad = false;
	for (int i = 1; i < s.length(); i++) {
		if (s[i] == s[i-1]) bad = true;
	}
	cout << (bad? "Bad" : "Good") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a;
        String operator;
        int b;
        int answer = 0;
        while (true) {
             a = sc.nextInt();
             operator = sc.next();
             b = sc.nextInt();

            switch (operator) {
                case "+": 
                    answer = a + b;
                    break;
                case "-": 
                    answer = a - b;
                    break;
                case "*": 
                    answer = a * b;
                    break;
                case "/": 
                    answer = a / b;
                    break;
                case "?": 
                    return;
            }   
         System.out.println(answer);
        }
    }
}


Measured memory_bytes: 26380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, tmp = INF, ans = 0;
    cin >> N;
    rep(i, N){
        ll a;
        cin >> a;
        if(tmp > a){
            ans++;
            tmp = a;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {}

    def dfs(m, cost):
        if m not in memo or memo[m] > cost:
            memo[m] = cost

            if m > 0:
                dfs(m // 2, cost + (m % 2) * d + a)
                dfs(m // 3, cost + (m % 3) * d + b)
                dfs(m // 5, cost + (m % 5) * d + c)

                dfs((m + (2 - m % 2)) // 2, cost + (2 - m % 2) * d + a)
                dfs((m + (3 - m % 3)) // 3, cost + (3 - m % 3) * d + b)
                dfs((m + (5 - m % 5)) // 5, cost + (5 - m % 5) * d + c)

                dfs(0, cost + m * d)

    dfs(n, 0)
    print(memo[0])


Measured memory_bytes: 121848
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
ll modularExponentiation(ll x,ll n,ll M)
{ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
int main()
{
    rkc;
    string s,t;
    cin>>s>>t;
    ll c=0;
    fl(i,0,3)if(s[i]==t[i])c++;
    cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h;
	cin >> h;
	int ans = 0;
	int now = 1;
	while(h){
		ans += now;
		now += now;
		h /= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
//for CodeForces
#pragma GCC target("avx,avx2")
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
map<long long int, int>soinnsuu(long long int a) {
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;


	return ans;
}
int main() {

	long long int N;cin>>N;
	auto mp=soinnsuu(N);
	int ans_a=mp.size();
	long long int ans_b=1;
	for(auto m:mp)ans_b*=m.second+1;
	ans_b--;
	cout<<ans_a<<" "<<ans_b<<endl;
	return 0;
}


Measured memory_bytes: 3104
SA = input()
SB = input()
SC = input()

card = SA[0]

SA_CNT = 1
SB_CNT = 0
SC_CNT = 0


while True:
    if card == 'a':
        if SA_CNT < len (SA):
            card = SA[SA_CNT]
            SA_CNT += 1
        else:
            print('A')
            break
    if card == 'b':
        if SB_CNT < len (SB):
            card = SB[SB_CNT]
            SB_CNT += 1
        else:
            print('B')
            break
    if card == 'c':
        if SC_CNT < len (SC):
            card = SC[SC_CNT]
            SC_CNT += 1
        else:
            print('C')
            break

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll const MAX = 100005;
ll a[MAX], b[MAX] = {};

int main(){
	ll n;
	cin >> n;
	ll x = 0;
	REP(i, 1, n) {
		cin >> a[i];
		x ^= a[i];
	}
	ll ans = 0;
	REP(i, 1, n) {
		ll u = 1;
		ll v = a[i];
		while ((v & 1) == 0) {
			u++;
			v /= 2;
		}
		b[i] = u;
		//cout << i << " " << b[i] << endl;
	}
	while (x > 0) {
		ll y = x;
		ll u = 0;
		while (y > 0) {
			u++;
			y /= 2;
		}
		//cout << x << " ! " << u  << endl;
		bool flag = 1;
		REP(i, 1, n) {
			if (u == b[i]) {
				x ^= a[i];
				x ^= (a[i] - 1);
				//cout << i << " " <<x << endl;
				b[i] = -1;
				ans++;
				flag = 0;
				break;
			}
		}
		if (flag == 1) {
			cout << -1 << endl;
			return 0;
		}
		
	}	
	cout << ans << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005,ha=1e9+7;

inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}

inline int ksm(int x,int y){
	int an=1;
	for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
	return an;
}

int jc[N],ni[N],f[N],n,a,b,c,d,ans,inv[N];

inline void init(){
	jc[0]=1;
	for(int i=1;i<=n;i++) jc[i]=jc[i-1]*(ll)i%ha;
	ni[n]=ksm(jc[n],ha-2);
	for(int i=n;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}

inline void dp(){
	f[0]=1;
	for(int i=a;i<=b;i++) // 最外层枚举 队伍的人数 
	    for(int m=i*c,j=min(i*d,n);j>=m;j--) // 第二层枚举 已经选好的人数
		    for(int k=c,now=ksm(ni[i],c),M=j-c*i;k<=d&&M>=0;k++,M-=i,now=now*(ll)ni[i]%ha)
		        /* 第三层枚举 这种人数的队伍选几个*/
				ADD(f[j],jc[j]*(ll)now%ha*(ll)ni[M]%ha*(ll)f[M]%ha*(ll)ni[k]%ha);
}

int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	init(),dp(),printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int rsum[80001];
int main(){
	string s;
	while (cin >> s) {
		if (s == "0")break;
		int n = s.length();
		rep(i, n+1) {
			rsum[i] = 0;
		}
		ll out = 0;
		rsum[0] = 0;
		rep(i, n) {
			if (i % 2) {
				rsum[i + 1] = (rsum[i] - (s[i] - '0')+11) % 11;
			}
			else {
				rsum[i + 1] = (rsum[i] + (s[i] - '0'))%11;
			}
		}
		rep(j, 11) {
			ll x = 0;
			per(i, n + 1) {
				if (rsum[i] == j) {
					if(i<n&&s[i]!='0')out += x;
					x++;
				}
			}
		}
		cout << out << endl;
	}
	return 0;
}


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

int n;
int p[100100],d[100100];

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p[i];
    d[i] = -1;
  }

  d[0] = 0;
  queue<int> q; q.push(0);

  while(q.size()){
    int now = q.front(); q.pop();

    for(int i=1;i<=6;i++){
      int nxt = now+i;
      while(d[nxt]<0){
	d[nxt] = d[now] + 1;
	if(p[nxt])nxt += p[nxt];
	else q.push(nxt);
      }
    }
  }
  cout << d[n-1] << endl;
}

Measured memory_bytes: 1996
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bits/stdc++.h>
using namespace std;

#define MOD 1e9+7
#define ll long long int

int logdayo(ll y,ll x){
	ll z=(ll)(y/x);
	ll ans=0;
	ll memo=2;
	for(memo=2;memo<=z;){
		ans++;
		memo*=2;
	}
	return ans;
}

int main(void){
	ll x,y;
	cin>>x>>y;
	int ans = (int)logdayo(y,x) + 1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.split("\n").map(Number);

let min = lines[1];

let n = lines[2]-lines[1];

for(var i =3;i<lines[0]+1;i++){
    if(lines[i-1]<min){
        min = lines[i-1]
    }

    if(lines[i]-min>n){
        n = lines[i]-min
    }

}

console.log(n)


Measured memory_bytes: 40652
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    struct P
    {
        public int index;
        public int dif;
        public P(int index, int dif)
        {
            this.index = index;
            this.dif = dif;
        }
    }
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ab = new int[num][];
        var ao = new P[num];
        for(var i = 0; i < num; i++)
        {
            ab[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            ao[i] = new P(i, ab[i][1] + ab[i][0]);
        }
        var set = new HashSet<int>();
        ao = ao.OrderByDescending(v => v.dif).ToArray();
        var resa = 0L;
        var rest = 0L;
        for(var i = 0; i < num; i++)
        {
            if (i % 2 == 0)
            {
                rest += ab[ao[i].index][0];
            }
            else
            {
                resa += ab[ao[i].index][1];
            }
        }
        WriteLine(rest-resa);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 29244
N = int(input())
v = list(map(int, input().split()))
v.sort()
u = [0]*(N-1)
for i in range(N-1):
    if i == 0:
        u[0] = (v[0] + v[1]) / 2
    else:
        u[i] = (u[i-1]+v[i+1])/2
print(u[-1])

Measured memory_bytes: 3060
h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[0 for j in range(w)] for k in range(h)]
buf = (h+w)*80
for i in range(h):
  for j in range(w):
      t = grid[i][j]
      if i == j == 0:
        dp[i][j] = 1 << buf+t | 1 << buf-t
      if j > 0:
        dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t
      if i > 0:
        dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t
for i in range(buf):
  if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):
    print(i)
    exit()

Measured memory_bytes: 20468
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

const int N = 2e3 + 5;
int dp[N][N];

int a[N], b[N];

void upd(int &x, int y) {
    x = (x + y) % mod;
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    fr(i, 1, n) {
        cin >> a[i];
    }
    fr(i ,1, m) {
        cin >> b[i];
    }
    fr(i, 1, n) {
        fr(j, 1, m) {
            upd(dp[i][j], dp[i - 1][j]);
            upd(dp[i][j], dp[i][j - 1]);
            upd(dp[i][j], mod - dp[i - 1][j - 1]);
            if(a[i] == b[j])
                upd(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }
    cout << (dp[n][m] + 1) % mod << endl;
    return 0;
}

Measured memory_bytes: 16000
a,b,c = map(int, input().split())
out = 0

if a % 2 == b % 2 == c % 2:
  pass
elif a % 2 == b % 2:
  out += 1
  a += 1
  b += 1
elif a % 2 == c % 2:
  out += 1
  a += 1
  c += 1
else:
  out += 1
  b += 1
  c += 1
  
l = sorted([a, b, c])
while True:
  if l[1] == l[2]:
    break
  out += 1
  l[0] += 1
  l[1] += 1
while True:
  if l[0] == l[1]:
    break
  out += 1
  l[0] += 2

print(out)

Measured memory_bytes: 3064
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < (tx - sx); i++) {
            ans.append("R");
        }
        for (int i = 0; i < (ty - sy); i++) {
            ans.append("U");
        }
        for (int i = 0; i < (tx - sx); i++) {
            ans.append("L");
        }
        for (int i = 0; i < (ty - sy); i++) {
            ans.append("D");
        }

        // 左から迂回
        ans.append("L");
        for (int i = 0; i < (ty - sy) + 1; i++) {
            ans.append("U");
        }
        for (int i = 0; i < (tx - sx) + 1; i++) {
            ans.append("R");
        }
        ans.append("D");

        // 右から迂回
        ans.append("R");
        for (int i = 0; i < (ty - sy) + 1; i++) {
            ans.append("D");
        }
        for (int i = 0; i < (tx - sx) + 1; i++) {
            ans.append("L");
        }
        ans.append("U");
        System.out.println(ans);
    }
}

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

using namespace std;

typedef vector<int> Vec;
typedef vector<Vec> Mat;

Mat a(5, Vec(5));
int score[5];

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

bool inField(int x, int y)
{
    return (0 <= x && x < 5 && 0 <= y && y < 5);
}

int erase(Mat &m)
{
    bool e[5][5] = {{}};
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {                        
            if (m[i][j] == 0) {
                continue;
            }
            int cnt[2] = {1, 1};
            for (int k = 0; k < 4; k++) {
                int ni = i + dy[k];
                int nj = j + dx[k];
                while (inField(ni, nj) &&
                       m[i][j] == m[ni][nj]) {
                    ni += dy[k];
                    nj += dx[k];
                    ++cnt[k&1];
                }
            }
            if (cnt[0] >= 3 || cnt[1] >= 3) {
                e[i][j] = 1;
            }
        }
    }
    int point = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (e[i][j]) {
                point += score[m[i][j]-1];
                m[i][j] = 0;
            }
        }
    }
    return point;
}

void fall(Mat &m)
{
    for (int j = 0; j < 5; j++) {
        for (int i = 4; i >= 1; i--) {
            if (m[i][j] == 0) {                
                for (int k = i-1; k >= 0; k--) {
                    if (m[k][j] != 0) {
                        swap(m[i][j], m[k][j]);
                        break;
                    }
                }
            }
        }
    }
}

int calc(Mat &m, int bp)
{
    int point = erase(m) * bp;
    fall(m);
    return point;
}

int get_point()
{
    Mat b = a;
    int point = 0, bp = 1;
    bool update = 1;
    
    while (update) {
        update = 0;        
        Mat nb = b;
        point += calc(nb, bp);
        if (nb != b) {        
            update = 1;
            b = nb;
            bp++;
        }
    }
    return point;
}

int dfs(int y, int x, int n)    
{
    int point = get_point();
    if (n > 0) {
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (inField(nx, ny)) {
                swap(a[ny][nx], a[y][x]);
                point = max(point, dfs(ny, nx, n-1));
                swap(a[ny][nx], a[y][x]);
            }        
        }
    }
    return point;
}

int main()
{
    int n;
    while (cin >> n, n != -1) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> a[i][j];
            }
        }
    
        for (int i = 0; i < 5; i++) {
            cin >> score[i];
        }

        int max_point = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                max_point = max(max_point, dfs(i, j, n));
            }
        }   
        cout << max_point << endl;
    }
    return 0;
}

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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n;
	cin>>n;
	ll a[n];
	map<ll,ll>cnt;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll ans=0;
	for(auto it=cnt.begin();it!=cnt.end();it++){
		ans+=(it->second)*(it->second-1)/2;
	}
	for(ll i=0;i<n;i++){
		cout<<ans-(cnt[a[i]]*(cnt[a[i]]-1)/2)+((cnt[a[i]]-1)*(cnt[a[i]]-2)/2)<<endl;
	}

	return 0;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<string>s(N);
    rep(i, N)cin >> s[i];
    int M; cin >> M;
    vector<string>t(M);
    rep(i, M)cin >> t[i];
    vector<int>v(N+1);
    rep(i, N) {
        rep(j, N)if (s[i] == s[j])v[i]++;
        rep(j, M)if (s[i] == t[j])v[i]--;
    }
    sort(v.begin(), v.end());
    cout << v[N] << endl;
}

Measured memory_bytes: 3604
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
kin = int(input())
print(k[kin-1])

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node treeserch(Node,int);
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSuccessor(Node);


Node treeMinimum(Node x){


}

Node treeMaximum(Node x){

}

Node treeSearch(Node u, int k)
{
  while(u != NIL && k != u->key)
    {
      if(k < u->key)
	u = u->left;
      else
	u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x){


}


void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right;
	}
    }
  z->parent = y;
  if(y==NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
	{
	  y->left = z;
	}
      else
	{
	  y->right = z;
	}
    }

}

void inorder(Node u)
{
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}



Measured memory_bytes: 20484
from collections import deque

n,x,y = map(int,input().split())

adj = [[] for i in range(n)]

adj[x-1].append(y-1)
adj[y-1].append(x-1)

for i in range(n-1):
    adj[i].append(i+1)
    adj[i+1].append(i)

ans = [0]*(n-1)
for i in range(n):
    q = deque([])
    q.append(i)

    dist = [-1]*n
    dist[i] = 0

    while len(q) > 0:
        v = q.popleft()
    
        for nv in adj[v]:
            if dist[nv] != -1:
                continue
        
            dist[nv] = dist[v] + 1
            q.append(nv)
    for i in dist:
        if i != 0:
            ans[i-1] += 1

for i in ans:
    print(i//2)

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int n,i;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i;
    int a[4];
    for(i=0; i<3; i++) {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[1]==a[2])
        cout<<a[0]<<endl;
    else if(a[0]==a[2])
        cout<<a[1]<<endl;
    else if(a[0]==a[1])
        cout<<a[2]<<endl;
    return 0;
}


Measured memory_bytes: 256
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)

def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return min_i - 1
    index = (max_i + min_i)//2
    while True:
        if func(index) <= target:
            if target < func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1

#for x in xs:
N = len(xs) - 1
rs = [0]*I
mny = N+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = bsearch(0, N-l+2, N+1, lambda k: x > X//(k-(N-l+1)))
    y+=1
    #print(l, y, X//(y-(N-l+1)))
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Measured memory_bytes: 118328
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    int N; cin >> N;
    int ans = pow(N,3);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int a,b;cin >> a >> b;
  cout << ((a>=10||b>=10)?-1:a*b) << endl;
}


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

const int N = 1e5+3;
vector<int>v[N];
bool vis[N];
list<int>L;

void dfs(int u, bool des)
{
    for(int i=0; i<v[u].size(); ++i)
    {
        int e = v[u][i];
        if(!vis[e])
        {
            if(des) L.push_front(e);
            else L.push_back(e);
            vis[e] = true;
            dfs(e, des);
            return;
        }
    }
}
int main()
{
    int n, m, a, b;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    L.push_back(1);
    L.push_back(v[1][0]);
    vis[1] = vis[v[1][0]] = true;
    dfs(1,true);
    dfs(v[1][0], false);
    printf("%d\n",L.size());
    for(auto it=L.begin(); it!=L.end(); ++it)
        printf("%d ",*it);
    printf("\n");
    return 0;
}


Measured memory_bytes: 9472
#!/usr/bin/env ruby
# frozen_string_literal: true
n = gets.to_i
arr = []
n.times do |i|
  s,p = gets.split
  arr << [i+1,s,p.to_i]
end
arr.sort_by!{|i,s,p| [s,-p]}
arr.each do |w|
  puts w[0]
end

Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int n;
	long long m;
	vector<long long>b[4];
	long long c[4];
	long long a[4];
	long long x,z,y;
	long long ans;
	for (int i = 0; i < 4; i++){
		a[i] = 0;
		c[i] = 0;
	}
	ans = 0;
	scanf("%d %lld", &n,&m);

	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &x, &y);
			if (i == 0)z = x;
		b[x - z].push_back(y);
		c[x - z] = c[x - z] + y;
		a[x - z] = a[x - z] + x;
	}

	for (int i = 0; i < 4; i++){
		b[i].push_back(10000000001);
		c[i] = c[i] + 10000000001;
		sort(b[i].begin(), b[i].end());
	}
	x = 0;
	y = 0;

	for (int i1 =0; i1 < b[0].size(); i1++){
		y = y + b[0][b[0].size()-1-i1];
		if (i1 != 0)x = x + z;
		for (int i2 = 0; i2 < b[1].size(); i2++){
			y = y + b[1][b[1].size() - 1 - i2];
			if (i2 != 0)x = x + z + 1;
			for (int i3 = 0; i3 < b[2].size(); i3++){
				y = y + b[2][b[2].size() - 1 - i3];
				if (i3 != 0)x= x + z + 2;
				for (int i4 = 0; i4 < b[3].size(); i4++){
					y = y + b[3][b[3].size() - 1 - i4];
					if (i4 != 0)x = x + z+3;
					if (x <= m){
						if (ans < y)ans = y;
					}
				}
				 y = y - c[3];
				 x = x - a[3];
			}
			y = y - c[2];
			x = x - a[2];
		}
		y = y - c[1];
		x = x - a[1];
	}
	printf("%lld\n", ans-40000000004);

	return 0;
}


Measured memory_bytes: 256