akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
        for (int i = 0; i < 3; i++) {
            int a = cin.Int();
            int b = cin.Int();
            if (a == 1) n1++;
            else if (a == 2) n2++;
            else if (a == 3) n3++;
            else if (a == 4) n4++;

            if (b == 1) n1++;
            else if (b == 2) n2++;
            else if (b == 3) n3++;
            else if (b == 4) n4++;
        }

        var arr = new int[] { n1, n2, n3, n4 };
        Array.Sort(arr);

        Console.WriteLine(arr[0] == 1 && arr[1] == 1 && arr[2] == 2 && arr[3] == 2 ? "YES" : "NO");
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
n,t=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[0]*(t+max(l)[0])
l.sort()
for a,b in l:
  for i in range(0,t+a)[::-1]: 
    if i-a>=0:
      dp[i]=max(dp[i],dp[i-a]+b)
print(max(dp[t:]))

Measured memory_bytes: 46936
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N ;
    vector<pair<ll,ll>> a(N+1);
    vector<ll> b(N+1);
    rep(i,N){
        cin >> a[i+1].first;
        a[i+1].second = i+1;
    }
    sort(ALL(a));
    ll t = 0;
    ll p1 = N + 1;
    for(ll i = N;i>0;i--){
        t += (ll)a[i].first;
        if(a[i].first != a[i-1].first){
            p1 = min(p1,a[i].second);
            b[p1] += t - (N+1-i)*(a[i-1].first);
            t = (N+1-i)*(a[i-1].first);
        }
    }
    for(int i=1;i<=N;i++)cout << b[i] << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main()
{
	ll N,ANS=0,min=200001;
	vector<ll>V;
	cin>>N;
	rep(i,N){
		ll t;
		cin>>t;
		V.push_back(t);
	}
	rep(i,N){
		if(V[i]<min)ANS++;
		if(V[i]<min)min=V[i];
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 0; i < n; i++)
        scanf("%d",&a[i]);
    int ans = ((n-1)%(k-1)!=0) + (n-1)/(k-1);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
s = sorted(s)
r = 0
k = 0
for i in range(n):
    if s[i] == s[i+1]:
        k += 1
    else:
        r += (k+1)*k//2
        k = 0
r += (k+1)*k//2
print(r)

Measured memory_bytes: 26720
#include <stdio.h>

int main(void)
{
	int a[100][100];
	int n;
	int i, j, k, l;
	int kami = 0;
	int kami2[100];
	
	scanf("%d", &n);
	
	while (n != 0) {
		
		for (i = 0; i < 50; i++) {
			kami2[i] = 0;
			kami = 0;
		}
		for (j = 0; j < 10; j++) {
			for (i = 0; i < 10; i++) {
				a[i][j] = 0;
			}
		}
		
		for (j = 0; j < n; j++) {
			for (i = 0; i < n; i++) {
				scanf("%d", &a[i][j]);
			}
		}
		
		for (j = 0; j < n + 1; j++) {
			if (j < n) {
				for (i = 0; i < n; i++) {
					printf("%5d", a[i][j]);
				}
				for (i = 0; i < n; i++) {
					kami += a[i][j];
				}
				printf("%5d", kami);
				a[n][j] = kami;
				kami = 0;
				printf("\n");
			}
			else {
				for (k = 0; k <= n; k++) {
					for (l = 0; l < n + 1; l++) {
						kami2[k] += a[k][l];
					}
				}
				
				for (k = 0; k < n + 1; k++) {
					printf("%5d", kami2[k]);
				}
				
				printf("\n");
				
				//for (k = 0; k < n; k++) {
				//	kami += a[n][k];
				//}
				
				//printf("%5d\n", kami);
			}
			
			
		}
		scanf("%d", &n);
		
	}
	return (0);
}

Measured memory_bytes: 624
#include<bits/stdc++.h> 
using namespace std;
using ll = long long;
ll a[200005];
ll n;
bool cmp(ll a,ll c){
	return a>c;
}
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,cmp);

	
	if(n==2) {
		cout<<a[0]<<endl;
		exit(0);
	}
	n--;
	ll t;
	ll q = n;
	if(n&1){
		t = (n-1)/2;
		t++;
	}
	else{
		n++;
		t = (n-1)/2;
		t++; 
	}
	ll ans = a[0];
	for(ll i=1;i<t;i++){
		ans += 2LL * a[i];
	}
	if(q%2 == 0){
		ans -= a[t-1];
	}
	cout<<ans<<endl;
	return 0;
}






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

int main(){
    int n, m; cin >> n >> m;
    vector<int> x(100000, 0), y(100000, 0);
    vector<pair<int, bool>> memo;  // 玉の個数 赤があるか
    int ans = 0;
    for(int i=0; i<n; i++){
        if(i==0){
            memo.push_back(make_pair(1, true));
        }else{
            memo.push_back(make_pair(1, false));
        }
    }
    for(int i=0; i<m; i++){
        int x, y; cin >> x >> y;
        x = x -1;
        y = y -1;
        if(memo[x].second){
            memo[y].second = true;
        }
        memo[x].first--;
        memo[y].first++;
        if(memo[x].first==0){
            memo[x].second = false;
        }
    }

    for(int i=0; i<n; i++){
        if(memo[i].second){
            ans ++ ;
        }
    }
    cout << ans << endl;
    return 0;    

}

Measured memory_bytes: 5024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var end = S.Length - T.Length;
        var left = 0;
        var result = new List<int>();
        for (int i = 0; i <= end; i++)
        {
            var count = 0;
            for (int j = 0; j < T.Length; j++)
            {
                if (S[left + j] == T[j]) count++;
            }
            result.Add(count);
            left++;
        }


        Console.WriteLine(T.Length - result.Max());
    }
}

Measured memory_bytes: 26544
#include<iostream>
#include"bits/stdc++.h"
#include<math.h>
#include<string.h>
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve()
{
	int n,flag=0;
	cin>>n;
	while(n>0)
	{
		int x=n%10;
		if(x==7)
			{
				flag=-1;
			}
		n=n/10;
	}
	if(flag==-1)
		cout<<"Yes";
	else
		cout<<"No";
}
void solve1()
{
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0)
			continue;
		if(i%5==0)
			continue;
		sum+=i;
	}
	cout<<sum;
}

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

}
void solve2()
{
	ll k,sum=0;
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int p=1;p<=k;p++)
			{
				sum+=gcd(gcd(i,j),p);
			}
		}
	}
	cout<<sum;
}
int main()
{
	fastio();
	//solve();
	//solve1();
	//cout<<gcd(gcd(10,30),10);
	solve2();
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    REP(i,m) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool> vis(n,false);
    queue<pii> q;
    q.push({0,0});
    vis[0]=true;
    while(!q.empty()) {
        int d=q.front().first;
        int v=q.front().second; q.pop();
        if(v==n-1) {
            if(d==2) {
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
        FORE(x,g[v]) {
            if(vis[x]) continue;
            vis[x]=true;
            q.push({d+1,x});
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

int *createList(int num)
{
	int i, *list = new int[num];
	for (i = 0; i < num; i++)
		cin >> list[i];
	return list;
}

void selectionSort(int num, int *list)
{
	int i, j, mini, temp, swaps = 0;
	for (i = 0; i < num; i++)
	{
		mini = i;
		for (j = i; j < num; j++)
			if (list[j] < list[mini]) mini = j;
		if (i != mini)
		{
			temp = list[i];
			list[i] = list[mini];
			list[mini] = temp;
			swaps++;
		}
	}
	for (i = 0; i < num - 1; i++)
		cout << list[i] << " ";
	cout << list[num - 1] << endl;
	cout << swaps << endl;
}

int main()
{
	int num, *list;
	cin >> num;
	list = createList(num);
	selectionSort(num, list);
	return 0;
}

Measured memory_bytes: 1188
N = int(input())
S = []
for n in range(N):
    S.append(input())
dic = {}


for n in range(N):
    if S[n] not in dic:
        dic[S[n]] = 1
    else:
        dic[S[n]] += 1

max = max(dic.values())
out = []

for key,val in dic.items():
    if val == max:
        out.append(key)

out.sort()
for key in out:
    print(key)

Measured memory_bytes: 35216
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BPalindromicNumbers {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b;
        in >> a >> b;
        int res = 0;
        FOR(n, a, b + 1) {
            string S = to_string(n), T = S;
            reverse(all(T));
            res += S == T;
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BPalindromicNumbers solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2
 
using namespace std;

ll a[ 1001 ];
ll sum[ 2020 ];

int main() {
	int n, x;
	ll ans = 0;
	scanf( "%d", &n );
	for( int i = 1; i <= n; ++i ) {
		scanf( "%d", &x );
		++a[ x ];
	}
	for( int i = 1; i <= 1000; ++i )
		sum[ i ] = sum[ i - 1 ] + a[ i ];
	for( int i = 1; i <= 1000; ++i ) {
		if( !a[ i ] )
			continue;
		for( int j = 1; j < i; ++j ) {
			if( !a[ j ] )
				continue;
			if( j - 1 > i - j )
				ans += a[ i ] * a[ j ] * ( sum[ j - 1 ] - sum[ i - j ] );
			if( j + j > i )
				ans += a[ i ] * a[ j ] * ( a[ j ] - 1 ) / 2;
		}
		ans += a[ i ] * ( a[ i ] - 1 ) / 2 * sum[ i - 1 ];
		if( a[ i ] >= 3 )
			ans += a[ i ] * ( a[ i ] - 1 ) * ( a[ i ] - 2 ) / 6;
	}
	printf( "%lld", ans );
	return 0;	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(){
  ll n,k;
  cin>>n>>k;
  ll p[n];
  rep(i,0,n)cin>>p[i];
  sort(p,p+n);
  ll sum=0;
  rep(i,0,k){
    sum+=p[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3644
import sys
import collections

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    LRD = [[int(x) for x in input().split()] for _ in range(M)]
    A = [[] for j in range(N + 1)]

    if M == 0:
        print("Yes")
        return

    slist = set()
    for l, r, d in LRD:
        A[l].append([r, d])
        A[r].append([l, -d])
        slist.add(l)
        slist.add(r)

    dmemo = [None] * (N + 1)

    f = False
    for i in list(slist):
        if dmemo[i] is not None:
            continue
        s = collections.deque()
        s.append(i)
        dmemo[i] = 0

        while s:
            c = s.pop()
            for r, d in A[c]:
                if dmemo[r] is not None:
                    if dmemo[r] - dmemo[c] != d:
                        f = True
                        break
                else:
                    dmemo[r] = dmemo[c] + d
                    s.append(r)
            if f:
                break
        if f:
            break

    if f:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 105576
import math
import copy
import sys

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputaList = [int(n) for n in inputa]

# inputb = input().split()
# inputbList = [int(n) for n in inputb]
#
inputList = []
inputNumList = []
for i in range(a):
    inputNum = input()
    inputNumList = list(inputNum)
    inputList.append(inputNumList)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

# row
for i in range(len(inputList)-1, -1, -1):
    flg = True
    for j in range(len(inputList[i])):
        if inputList[i][j] =="#":
            flg = False
            break

    if flg:
        del inputList[i]

# colum
for j in range(b-1, -1, -1):
    flg = True
    for i in range(len(inputList)):
        if inputList[i][j] == "#":
            flg = False
            break

    if flg:
        for i in range(len(inputList)):
            del inputList[i][j]

for i in range(len(inputList)):
    print("".join(inputList[i]))






Measured memory_bytes: 3572
import bisect
s = input()
t = input()

s_len = len(s)
t_len = len(t)

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

def get_ord(c):
    return ord(c)-97

for i in range(s_len):
    ord_c = get_ord(s[i])
    n[ord_c].append(i)

#print(n)

#print("s_len",s_len)
#print("t_len",t_len)

def get_ans():
    res = 0
    for i in range(t_len):
        
        rr = res % s_len
        t_ord = get_ord(t[i])
        words = n[t_ord]
        
        if(len(words)==0):
            return -1
        if(i==0 and words[0] == 0):
            res = 0
            continue
    
        if(words[len(words)-1]<=rr):
            res += s_len - rr 
            #print("add",s_len-rr)
            rr = -1
        
        bis = bisect.bisect_right(words,rr)
        #print(bis,len(words),rr,words)
        w = words[bis]


        if(rr!=-1):
            res += w - rr
        else:
            res += w
        #print(t[i],words,rr,res)
    
    return res+1

print(get_ans())

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

#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");

int main() {
  int n, m;
  cin >> n >> m;
  vector< vector<int> > Graph(n);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;--b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  //bfs
  vector<bool> visited(n);
  vector<int> hint(n);
  queue<int> qi;

  visited[0] = true;
  qi.push(0);

  while(!qi.empty()) {
    int v = qi.front();
    qi.pop();

    for (int nv : Graph[v]) {
      if (visited[nv] != false) continue;

      visited[nv] = true;
      hint[nv] = v;
      qi.push(nv);
    }
  }

  cout << "Yes" << endl;
  for (int i = 1;  i < n; i++) {
    cout << hint[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 10036
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=200010;

int n,k,a[N],b[N];

int main(){
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]),b[a[i]]++;
  sort(b+1,b+1+n,greater<int>()); sort(a+1,a+1+n); n=unique(a+1,a+1+n)-a-1;
  if(n<=k) return puts("0"),0;
  int ans=0;
  while(n>k) ans+=b[n--]; printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1792
def gcd_e(x, y):
  if y == 0:
    return x
  else:
    return gcd_e(y,x%y)      

def lcm(x, y):
  return (x * y) // gcd_e(x, y)

n,m=list(map(int,input().split()))
A=list(map(int,input().split()))
a,b=A[0],0

for i in range(1,n):
  b = A[i]
  a = lcm(a,b)
  
for i in set(A):
  if (a // i) % 2 == 0:
    print('0')
    exit()    
  
if a // 2 > m:
  print('0')
else:
  print((m-a//2)//a+1)

Measured memory_bytes: 14244
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; int aux;
	cin >> n;
	vector<int>nums;
	int suma1 = 0;
	int suma2 = 0;
	while(n--){
		cin >> aux;
		nums.push_back(aux);
	}
	sort(nums.begin(), nums.end());
	for(int i = nums.size() - 1; i >= 0; i--){
		if(i % 2 == 0) suma2+=nums[i]; else suma1 += nums[i];
	}
	cout << abs(suma1-suma2);
	return 0;
}

Measured memory_bytes: 256
const val DREAM = "dream"
const val DREAMER = "dreamer"
const val ERASE = "erase"
const val ERASER = "eraser"

fun main(args: Array<String>) {
    var s = readLine()!!
    while(s.isNotEmpty()){
        when{
            s.endsWith(DREAMER)-> {
                s = s.substringBeforeLast(DREAMER)
            }
            s.endsWith(ERASER) -> {
                s = s.substringBeforeLast(ERASER)
            }
            s.endsWith(DREAM) -> {
                s = s.substringBeforeLast(DREAM)
            }
            s.endsWith(ERASE) -> {
                s = s.substringBeforeLast(ERASE)
            }
            else -> {
                println("NO")
                return
            }
        }
    }
    println("YES")
}

Measured memory_bytes: 116476
/*
ID: jerrywcy
TASK: AtCoder Beginner Contest 106 Problem C
LINK: https://abc106.contest.atcoder.jp/tasks/abc106_c
LANG: C++
*/
#include<bits/stdc++.h>

using namespace std;

string s;
int k;

int main() {
	cin>>s;
	cin>>k;
	int i,j;
	i=0;
	while (k && s[i]=='1'){
		k--;
		i++;
	}
	if (k)cout<<s[i]<<endl;
	else cout<<1<<endl;
}

Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define endl 			"\n"
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(10);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	int n, temp;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int first[n], second[n];
	first[0] = a[0];
	second[n - 1] = a[n - 1];
	for (int i = 1; i < n; i++)
	{
		first[i] = __gcd(first[i - 1], a[i]);
	}
	for (int i = n - 2; i >= 0; i--)
	{
		second[i] = __gcd(second[i + 1], a[i]);
	}
	int ans = max(first[n - 2], second[1]);
	for (int i = 1; i < n - 1; i++)
	{
		temp = __gcd(first[i - 1], second[i + 1]);
		ans = max(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5932
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int[] b = new int[n+1];
		b[0] = Integer.MAX_VALUE;
		b[n] = Integer.MAX_VALUE;
		for(int i =0 ; i< n-1; i++) {
			b[i+1] = sc.nextInt();
		}
		
		int a[] = new int[n];
		
		int sum = 0;
		for(int i = 0 ; i < n;i++) {
			a[i] = Math.min(b[i], b[i+1]);
			sum += a[i];
		}
		
		System.out.println(sum);
	}
}


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

int calc_digits(long long N) {
    int res;
    while(N != 0) {
        res++;
        N /= 10;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    long long max = -1;
    for(long long i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            if(max < i) {
                max = i;
            }
        }
    }
    cout << calc_digits(N/max) << endl;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

string s;
ll d;
ll dp[200010][210][2];



ll solve(ll i,ll s1,ll p){
	if(dp[i][s1][p] != -1)
		return dp[i][s1][p];
	if(i >= (s.size())){
		if(s1 == 0)
			return 1;
		else
			return 0;
	}
	ll ans=0;
	if(p==1){
		for(int j=0;j<(s[i]-'0');j++){
			ans = (ans + solve(i+1,(s1+j)%d,0)) % mod;
		}
		ans = (ans + solve(i+1,(s1+s[i]-'0'+d)%d,1)) % mod;
	}
	else{
		for(int j=0;j<=9;j++){
			ans = (ans + solve(i+1,(s1+j)%d,0)) % mod;
		}
	}
	return dp[i][s1][p] = ans % mod;
}

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s>>d;
    for(int i=0;i<210;i++){
    	for(int j=0;j<200010;j++){
    		dp[j][i][0] = -1;
    		dp[j][i][1] = -1;
    	}
    }
    cout << (solve(0,0,1) - 1+mod)%mod;

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


Measured memory_bytes: 657280
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n,m = LI()
        if n == 0 and m == 0:
            break
        v = [[] for i in range(n)]
        for i in range(m):
            a,b = LI()
            a -= 1
            b -= 1
            v[a].append(b)
            v[b].append(a)
        bfs_map = [1 for i in range(n)]
        bfs_map[0] = 0
        f = [0 for i in range(n)]
        q = deque()
        q.append(0)
        fl = 1
        while q:
            if not fl:break
            x = q.popleft()
            for y in v[x]:
                if bfs_map[y]:
                    bfs_map[y] = 0
                    f[y] = (1-f[x])
                    q.append(y)
                else:
                    if f[y] == f[x]:
                        print(0)
                        fl = 0
                        break
        if fl:
            ans = []
            k = sum(f)
            if k%2 == 0:
                ans.append(k//2)
            k = len(f)-sum(f)
            if k%2 == 0:
                ans.append(k//2)
            ans = list(set(ans))
            ans.sort()
            print(len(ans))
            for i in ans:
                print(i)
    return

#B
def B():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)

    def factorize(n):
        if n < 4:
            return {n:1}
        i = 2
        d = defaultdict(int)
        m = n
        while i**2 <= n:
            if m%i == 0:
                while m%i == 0:
                    m//=i
                    d[i] += 1
            i += 1
        d[m] += 1
        return d
    p,q = LI()
    g = gcd(p,q)
    ans = q//g
    if ans == 1:
        print(1)
    else:
        d = factorize(ans)
        ans = 1
        for i in d.keys():
            ans *= i
        print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 8228
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    a = [A[i], B[i], C[i]]
    a.sort()
    if a[0] == a[1] and a[1] == a[2]:
        ans += 0
    elif a[0] == a[1] or a[1] == a[2]:
        ans += 1
    else:
        ans += 2

print(ans)

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

int main() {
	int A , B , C , D ;
  	cin >> A >> B >> C >> D ;
    if((A + B) == (C + D)){
    	cout << "Balanced" << endl;
    }else if((A + B) > (C + D)){
    	cout << "Left" << endl;
    }else{
    	cout << "Right" << endl;
    }
}


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

int n, c[2];
int main()
{
	int t;
	cin >> n;
	while (n--) {
		scanf("%d", &t);
		c[t % 2]++;
	}
    cout << (c[1] % 2 ? "NO" : "YES") << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L,R = [],[]
for i in range(N):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

# 原点を追加
L.append(0)
R.append(0)

# 左端点は降順に、右端点は昇順にソート
L.sort(reverse=True)
R.sort()

Ans = 0
for i in range(N+1):
    if L[i] > R[i]:
        Ans += (L[i] - R[i])*2

print(Ans)

Measured memory_bytes: 11480
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {


    zoom;
    ll N, i;
    cin >> N;
    vector<ll> h(N), dp(N);
    for(i = 0; i < N; i += 1)
        cin >> h[i];
    dp[N - 1] = 0;
    dp[N - 2] = (ll)abs(h[N - 1] - h[N - 2]);
    for(i = N - 3; i >= 0; i -= 1)
        dp[i] = (ll)min(dp[i + 1] + (ll)abs(h[i] - h[i + 1]), dp[i + 2] + (ll)abs(h[i] - h[i + 2]));
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b>c+d) printf("Left\n");
	if(a+b==c+d) printf("Balanced\n");
	if(a+b<c+d) printf("Right\n");
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        N: usize,
        X: i64,
        x: [i64; N],
    }
    println!("{}", x.iter().fold((X - x.get(0).unwrap()).abs(), |acc, cur| gcd(acc, (X - cur).abs())));
}

pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


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

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            if (str[2] == str[3] && str[4] == str[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <random>
#include <complex>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <bitset>

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

ll gcd(ll a, ll b) {
    if (!a) return b;
    return gcd(b%a, a);
}
ll ext_gcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b) {
        d = ext_gcd(b, a%b, y, x);
        y -= a / b*x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int w, d, n, m, t, u, h;
int x, tu, th;
void init() {
    m = t-m%t;
    u = gcd(t, w+d), h = gcd(t, m);
    tu = t/u; th = t/h;
    ll xx, y;
    ext_gcd(m, t, xx, y);
    x = ((xx % th) + th) % th;
}
int solve() {
    init();
    int res = 0;
    int l = 0;

    int s = 0;
    int hud = h/u, hum = h%u;
    int iud = 0, ium = 0;
    for (int i = 0; i < t; i += h) {
        if (s<n) {
            res += max(0, (i-w)/u - l);
            l = iud;
        }
        s += x;
        if (s >= th) s -= th;
        iud += hud;
        ium += hum;
        if (ium >= u) {
            iud++;
            ium -= u;
        }
    }
    res += max(0, (t-w)/u - l);
    return res;
}

int main() {
    cin >> w >> d >> n >> m >> t; w++; d--;
    printf("%.20f\n", 1.0 * solve() / tu);
    return 0;
}

Measured memory_bytes: 1172
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        String op = scanner.next();
        int B = Integer.parseInt(scanner.next());
        scanner.close();

        if (op.equals("+")) {
            System.out.println(A + B);
        }

        if (op.equals("-")) {
            System.out.println(A - B);
        }
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] data = new int[n];
		int ramp = 1;
		int sum = 0;
		for(int i=0; i<n; i++){
			data[i] = sc.nextInt();
		}
		
		while(true){
			if(sum>n){
				System.out.println(-1);
				break;
			}else if(ramp == 2){
				System.out.println(sum);
				break;
			}
			ramp = data[ramp-1];
			sum++;
		}
	}
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  ll dx = tx - sx;
  ll dy = ty - sy;
  for (long long i = 0; i < dy; i++) {
    cout << 'U';
  }
  for (long long i = 0; i < dx; i++) {
    cout << 'R';
  }
  for (long long i = 0; i < dy; i++) {
    cout << 'D';
  }
  for (long long i = 0; i < dx; i++) {
    cout << 'L';
  }
  cout << 'L';
  dy++;
  dx++;
  for (long long i = 0; i < dy; i++) {
    cout << 'U';
  }
  for (long long i = 0; i < dx; i++) {
    cout << 'R';
  }
  cout << 'D';
  cout << 'R';
  for (long long i = 0; i < dy; i++) {
    cout << 'D';
  }
  for (long long i = 0; i < dx; i++) {
    cout << 'L';
  }
  cout << 'U';
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {// Main
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
   long n = sc.nextLong();
  long k = sc.nextLong();
  long pre = 0 ;
  long suf = n ;
  int d = 1 ; 

  for(int i = 1 ; i <k ; i ++ ) {
	  pre+=d;
	  suf += (n - d );
	  d++;
  }	
  
  long ans = 0  ; 
  long mod = 1000000007;
  for(long i = k ; i <=  n+1 ; i++) {
	  long range = (suf - pre +1);
	  ans = (ans%mod + range%mod)%mod ;
	  pre+=d;
	  suf += (n-d);
  d++;
  }
  System.out.println(ans);
	}

	
}

Measured memory_bytes: 35712
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
XL = li2(N)
R = dp2(0, 2, N)

for i in range(N):
    R[i][0] = XL[i][0] - XL[i][1]
    R[i][1] = XL[i][0] + XL[i][1]


R = sorted(R, key=lambda x:x[1])
m = -float('inf')
cnt = 0
for i in range(N):
    if R[i][0] >= m:
        cnt += 1
        m = R[i][1]

print(cnt)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}


Measured memory_bytes: 256
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
void solve()
{
  int k;
  cin >> k;
  int a[32]={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
};
  cout << a[k-1];
  return;
}
signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>=1&&a<=9&&b>=1&&b<=9)printf("%d",a*b);
	else printf("-1");
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
using namespace std;

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

int n_base_sum(int a,int n){
    int res = 0;
    while(a>0){
        res += a%n;
        a /= n;
    }
    return res;
}

int main(){
    int N;cin>>N;
    int ans=N;
    REP(i,N+1){
        int tmp = n_base_sum(i,6) + n_base_sum(N-i,9);
        ans = min(ans,tmp);
    }
    cout << ans;
}



Measured memory_bytes: 256
# N, D, K = map(int,input().split())
# LR = [list(map(int,input().split())) for _ in range(D)]
# ST = [list(map(int,input().split())) for _ in range(K)]

s = input()
n = len(s)

cand = list(set(s))
ans = n

def simulate(t):
    cnt = 0
    now = s
    while len(set(now)) != 1:
        ne = ""
        for i in range(len(now)-1):
            if t in (now[i], now[i+1]):
                ne += t
            else:
                ne += "@"
        cnt += 1
        now = ne
    return cnt

for ch in cand:
    ans = min(ans, simulate(ch))
print(ans)

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


int main()
{
    int n,m;
    cin >>n>>m;
    ll sum=0;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin >>arr[i];
        sum+=arr[i];
    }
    bool flag=false;
    int count=0;
    for(int i=0;i<n;i++)
    {
        ll temp = arr[i]*4*m;
        if(temp>=sum)
        {
            count++;
        }
        if(count==m)
        {
            flag =true;
            break;
        }
    }
    if(flag)
        cout <<"Yes";
    else
        cout <<"No";
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc141/tasks/abc141_e
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using I = int;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (I i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    I N;
    string S;
    cin >> N >> S;
    I len = S.length(), maxv = 0;
    REP(d, len) {
        I cnt = 0;
        REP(i, len - d) {
            if (S[i] == S[i + d]) {
                cnt++;
            } else {
                cnt = 0;
            }
            maxv = max(maxv, min(cnt, d));
        }
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 384
n, k = [int(x) for x in input().split()]
r, s, p = [int(x) for x in input().split()] # グー：r チョキ：s パー：p
t = list(input())

addscoremap = {'r': p, 's': r, 'p': s}

score = 0

for i in range(n):
  if (0 <= i-k) and (t[i] == t[i-k]):
    t[i] = 'x'
    continue
  score += addscoremap[t[i]]

print(score)


Measured memory_bytes: 4084
#include <iostream>
#include <string>

int main()
{
	std::string s;
	std::getline(std::cin, s);
	for (int i=0; s[i]; ++i) {
		if (65 <= s[i] && s[i] <=90) s[i] += 32;
		else if (97 <= s[i] && s[i] <=122) s[i] -= 32;
	}
	std::cout << s << '\n';
}

Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

#include <iostream>

int main()
{
    double T, X;
    cin >> T >> X;

    cout << fixed << setprecision(15) << T / X << endl;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var s0 = Console.ReadLine().Trim();
        var n = int.Parse(Console.ReadLine().Trim());
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            var s1 = Console.ReadLine().Trim();
            var s2 = s1 + s1;
            if (s2.IndexOf(s0) >= 0) count++;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9864
ns = list(map(int, input()))

def comb(num):
    if num <= 0:
        return 1
    return 2 ** (num - 1)

ans = 0
for l, n in enumerate(ns):
    rmax = len(ns) - l
    for r in range(rmax):
        co = comb(l + 1) * comb(rmax - r - 1)
        ans += n * 10**r * co

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    if(s[5]=='1' || s[6]>= '5')
        cout << "TBD\n";
    else
        cout << "Heisei\n";
    
    return 0;
}

Measured memory_bytes: 256