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

class WeightedUnionFind {
public:
	vector<int> par;
	vector<int> rank;
	vector<int> diff_weight;

	WeightedUnionFind() {}
	WeightedUnionFind(int size, int weight) {
		rank.resize(size, 0);
		par.resize(size, 0);
		diff_weight.resize(size, 0);
		for (int i = 0; i<size; i++) makeSet(i, weight);
	}

	void makeSet(int x, int weight) {
		par[x] = x;
		rank[x] = 0;
		diff_weight[x] = weight;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	bool relate(int x, int y, int w) {
		w += weight(x); w -= weight(y);
		x = findSet(x); y = findSet(y);

		if (x == y) return false;
		if (rank[x] < rank[y]) {
			swap(x, y);
			w = -w;
		}
		if (rank[x] == rank[y]) rank[x]++;
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	int diff(int x, int y) {
		return weight(y) - weight(x);
	}

	int weight(int x) {
		findSet(x);
		return diff_weight[x];
	}

	int findSet(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = findSet(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

};

int main() {
	int N, M;
	cin >> N >> M;

	WeightedUnionFind wuf = WeightedUnionFind(N, 0);

	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D;
		L--; R--;

		if (!wuf.same(L, R)) {
			wuf.relate(L,R,D);
		}
		else {
			if (wuf.diff(L, R) != D) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer A = scan.nextInt();
        Integer B = scan.nextInt();
        Integer C = scan.nextInt();
        Integer answer = 0;
        if(A-B < C) {
            answer = C-A+B;
        }
        else {
            answer = 0;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision; 
#define int int128_t
#define fr(a,b) for(int i=a;i<b;i++)
#define frn(a,b) for(int i=a;i>=b;i--)

int32_t main(){
	
	int x;
	cin>>x;
	int a = 100;
	int t = 0;
	while(a<x){
		a = a*101;
		a = a/100;
		t++;
	}
	cout<<t;
}

Measured memory_bytes: 3664
#include <iostream>
using namespace std;
long long pow3(int n) { return (long long)n*n*n; }
int main()
{
    int N, K;
    cin >> N >> K;
    if (K%2 == 0) {
        cout << (pow3(N/K) + pow3(N/(K/2) - N/K)) << endl;
    } else {
        cout << pow3(N/K) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[0]*N
    for i in range(1,N):
        dp[i]=min(
            
            dp[j]+abs(h[j]-h[i]) for j in range(max(i-K,0),i)
            )
    print(dp[N-1])
main()


Measured memory_bytes: 13928
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(){
	int n,m;
	priority_queue<pii> data;
	while(cin>>n>>m,n||m){

		int d[110]={0};
		rep(i,110)d[i]=0;
		for(int i =0;i < n;i++){
			int cnt = 0;
			for(int j =1;j <=m;j++){
				int x;
				cin>>x;
				if(x){
					d[j]++;
				}
			}
		}
		for(int i =1;i <=m;i++){
			data.push(pii(d[i],-i));
		}
		int k =data.size();
		while(!data.empty()){
			cout <<-data.top().second;data.pop();
			if(!data.empty())cout <<" ";
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
n="0"+input()
x=len(n)
k=int(input())
l=[int(i) for i in n]
dp=[[[0]*5,[0]*5] for i in range(x)]
dp[0][0][0]=1
r=0
#dp 0=n, 1=under
for i in range(1,x):
    for j in range(2):
        dp[i][1][0]=1
        for p in range(1,k+1):
            if j==0 and l[i]==0:
                dp[i][0][p]=dp[i-1][0][p]
            elif j==0 and l[i]!=0 and dp[i-1][0][p-1]:
                dp[i][0][p]=1
            if j==1:
                dp[i][1][p]=dp[i-1][1][p]+(dp[i-1][1][p-1]*9)+(dp[i][0][p]*max(0,l[i]-1))+([0,1][l[i]!=0 and dp[i-1][0][p]])
print(dp[-1][0][k]+dp[-1][1][k])

Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()
	r.Scan(true)
	b := r.nextStringArray().toInts()
	r.Scan(true)
	c := r.nextStringArray().toInts()

	pt := 0
	for i := range a {
		pt += b[a[i]-1]
		if i > 0 && a[i-1]+1 == a[i] {
			pt += c[a[i-1]-1]
		}
	}
	fmt.Fprintln(stdout, pt)
}


Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function

data Bulb = On {-# UNPACK #-} !Int | Off {-# UNPACK #-} !Int deriving (Eq)

instance Ord Bulb where
  compare (On x) (On y) = compare x y
  compare (On x) (Off y) | x <= y    = LT
                         | otherwise = GT
  compare (Off x) (On y) | x < y     = LT
                         | otherwise = GT
  compare (Off x) (Off y) = compare x y

main :: IO ()
main = do
  getLine
  ls <- flip (zipWith $ flip ($)) (cycle [On,Off]) .
          unfoldr (BSL.readInt . BSL.dropWhile (<'-')) <$> BSL.getContents
  let onoff = map (\case ls@(On _ : _) -> length ls
                         ls@(Off _ : _) -> -length ls) $ group $ sort ls
  print $ maximum $ scanl (+) 0 onoff



Measured memory_bytes: 96476
#include<stdio.h>
int main(void)
{
	int x,t,max=0,i,j;
	for(i=0; i<2; i++)
	{
		t=0;
		for(j=0; j<4; j++)
		{
			scanf("%d", &x);
			t+=x;
		}
		if(max<t)
		max=t;
	}
	printf("%d\n", max);
	
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
using namespace std;
int main(void){
    int a;
    int b;
    int c;
 std::cin >>a; cin>>b;cin >>c;
 
    int left, middle, right;
    
    if (a > b && a > c) {
        right = a;
        if(b > c){
            middle = b;
            left = c;
        }else{
            middle = c;
            left =b;
        }
    }else if(a < b && a < c){
        left = a;
        if(b > c){
            right = b;
            middle = c;
        }else{
            right = c;
            middle = b;
        }
        
    }else{
        middle = a;
        if(b > c){
            right = b;
            left = c;
        }
    }
std::cout << left << " " << middle << " " << right << std::endl;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef vector<int> vi; 
typedef pair<int,int> pii; 
#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 

void solve(){
  ll a,b; cin>>a>>b; 
  cout<<a*b/(__gcd(a,b))<<endl; 
}

int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int A,B,C;
  cin >> A>>B>>C;

  if(A==7 && B==5 && C==5){
    cout << "YES" << endl;
  }else if (A==5 && B==7 && C==5) {
    cout << "YES" << endl;
  }else if (A==5 && B==5 && C==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

vector< vector<int> > AdjList;
vector<int> reachable;

void init(int N) {
	for(int i = 0; i < N; i++) {
		reachable.push_back(-1);
		vector<int> empty;
		AdjList.push_back(empty);
	}
}

int main() {
	int N, M; cin >> N >> M;
	init(N);
	for(int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a -= 1; b -= 1;
		AdjList[a].push_back(b);
		AdjList[b].push_back(a);
	}
	reachable[0] = 1;
	for(int i = 0; i < AdjList[0].size(); i++) {
		reachable[AdjList[0][i]] = 1;
	}

	for(int i = 1; i < N; i++) {
		if(reachable[i] == 1) {
			for(int j = 0; j < AdjList[i].size(); j++) {
				if(reachable[AdjList[i][j]] == -1) {
					reachable[AdjList[i][j]] = 2;
				}
			}
		}
	}

	if(reachable[N-1] != -1) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool fc(vector<vector<int>> &gr, pair<int, int> p){
  vector<bool> vb(gr.size(), false);
  vb.at(0) = true;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int now = q.front(); q.pop();
    for(auto i : gr.at(now)){
      if(make_pair(now,i) == p || make_pair(i, now) == p) continue;
      if(vb.at(i) == true) continue;
      vb.at(i) = true;
      q.push(i);
    }
  }
  rep(i, vb.size()){
    if(vb.at(i) == false) return true;
  }
  return false;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n, vector<int>());
  vector<pair<int, int>> vp(m);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    gr.at(a).push_back(b);
    gr.at(b).push_back(a);
    vp.at(i) = make_pair(a, b);
  }
  int ans = 0;
  rep(i, m){
    if(fc(gr, vp.at(i)) == true) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll f[101][11], p[101][11];
int main() {
  int n;
  cin >> n;
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -INF;
  for (int b = 1; b < (1 << 10); b++) {
    ll t = 0;
    for (int i = 0; i < n; i++) {
      ll c = 0;
      for (int j = 0; j < 10; j++)
        if ((b >> j & 1) && f[i][j]) c++;
      t += p[i][c];
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int S,s,m,h;

	scanf("%d",&S);

        h=S/3600;
        m=(S-h*3600)/60;
        s=S-h*3600-m*60;


	printf("%d:%d:%d\n",h,m,s);

	return 0;

}

Measured memory_bytes: 2744
#include<iostream>
#include<queue>
#include<utility>
typedef std::pair<int,int> PP;
int H, W, N;
int sh, sw;
char tar[9] = { '1','2','3','4','5','6','7','8','9' };
char HW[1000][1000];
int cnt = 0;
const int INF = 1 << 30;
int ans;
int tx, ty;
int D[1000][1000];
void solve(int h, int w) {
	std::queue<std::pair<int,int>> q;
	q.push(std::make_pair(h, w));
	for (int a = 0; a < H; a++) {
		for (int b = 0; b < W; b++) {
			D[a][b] = INF;
		}
	}
	D[h][w] = 0;
	while (q.size()) {
		std::pair<int, int> p = q.front();
		q.pop();
		if (HW[p.first][p.second] == tar[cnt]) {
			ans += D[p.first][p.second];
			tx = p.first;
			ty = p.second;
			return;
		}
		int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
		for (int i = 0; i < 4; i++) {
			int ux = p.first + dx[i];
			int uy = p.second + dy[i];
			if (0 <= ux&&ux < H && 0 <= uy&&uy < W&&D[ux][uy] == INF&&HW[ux][uy] != 'X') {
				q.push(std::make_pair(ux, uy));
				D[ux][uy] = D[p.first][p.second] + 1;
			}
		}
	}
	return;
}
int main() {
	std::cin >> H >> W >> N;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			std::cin >> HW[i][j];
			if (HW[i][j] == 'S') {
				sh = i;
				sw = j;
			}
		}
	}
	solve(sh, sw);
	for (int i = 0; i < N; i++) {
		cnt = i;
		solve(tx, ty);
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8020
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
f=[1]
for i in range(N):
  f+=[f[-1]*(i+1)%mod]
def comb(a,b):
  return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

    
max=0
for i in range(K-1,N):
  max+=comb(i,K-1)*A[i]
  max%=mod
for i in range(N-K+1):
  max-=comb(N-i-1,K-1)*A[i]
  max%=mod
print(max)

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

int main(){
int N;
cin >> N;
int ans = 0;

for (int i =1 ; i <= N; i++){
 string x = to_string(i);
  if (x.size() % 2 == 1){
   ans++; 
  }
}
   cout << ans << endl; 

}


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

using namespace std;

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

	long long n;
	cin >> n;

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

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

	cout << a[n-1]; 

	return 0;
}

Measured memory_bytes: 1792
// Author: Mrigank
/* Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll r;
    cin >> r;
    ld p = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
    cout << 2 * p * r << endl;
}

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	for (char &c: S) c = (c - 'A' + N) % 26 + 'A';
	cout << S;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1e+9;

int main(){
	int n,m;
	while( cin >> n >> m , n||m ){
		int d[2][101][101];
		for(int i=0 ; i < 101 ; i++ ){
			for(int j=0 ; j < 101 ; j++ ){
				d[0][i][j] = (i==j)? 0 : INF;
				d[1][i][j] = (i==j)? 0 : INF;
			}
		}

		for(int i=0 ; i < n ; i++ ){
			int a,b,cost,time;
			cin >> a >> b >> cost >> time;
			d[0][a][b] = cost;
			d[0][b][a] = cost;
			d[1][a][b] = time;
			d[1][b][a] = time;
		}
		for(int k=1 ; k <= m ; k++ ){
			for(int i=1 ; i <= m ; i++ ){
				for(int j=1 ; j <= m ; j++ ){
					d[0][i][j] = min( d[0][i][j] , d[0][i][k]+d[0][k][j] );
					d[1][i][j] = min( d[1][i][j] , d[1][i][k]+d[1][k][j] );
				}
			}
		}
		int k;
		cin >> k;
		for(int i=0 ; i < k ; i++ ){
			int p,q,r;
			cin >> p >> q >> r;
			cout << d[r][p][q] << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int N; cin >> N;
    long long dp[100010][3];
    long long a[100010][3];
    rep(i, N)
    {
        rep(j, 3) cin >> a[i][j];
    }

    rep(i, N)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long ans = 0;
    rep(j, 3) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 4992
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto S = A.map!(a => a.sum).sum % 2;
    Tuple!(int, int, int, int)[] ans;

    foreach (i; 0..H) {
        foreach (j; 0..W-1) {
            if (A[i][j] % 2 == 1) {
                if (S == 1) {
                    S = 0;
                    continue;
                }
                ans ~= tuple(i+1, j+1, i+1, j+2);
                A[i][j+1] += 1;
            }
        }
        if (A[i][W-1] % 2 == 1 && S == 0) {
            ans ~= tuple(i+1, W, i+2, W);
            A[i+1][W-1] += 1;
        }
    }

    ans.length.writeln;
    foreach (a; ans) writeln(a[0], " ", a[1], " ", a[2], " ", a[3]);
}


Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  out((a + b) * c / 2);
  memi;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
    using namespace std;
    using ll = long long ;
    ///PBDS Starting.......

    //#include <ext/pb_ds/assoc_container.hpp>
    //#include <ext/pb_ds/tree_policy.hpp>
    //using namespace __gnu_pbds;
    //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

    ///PBDS_SET
    ///Index of Value - .order_of_key()
    ///Value at Index - .find_by_order()
    ///typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set;
    ///typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset;

    /// PBDS closing......
    #define int long long
    #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
    #define endl '\n'
    ///............Author..................................................................
    ///........... :: .....................................................................
    ///...........(  NOBODY  )................................................................
    ///........... Bangabandhu Sheikh Mujibur Rahman Science and Technlogy University,Gopalganj
    ///........... ( N~76 ) ...................................................................
    ///........... No Copyright .....You can copy and paste my code without any permission.....
    /// !!!!!!!!!!!!!!!........................................................................
    #define pb push_back
    #define esp 0.000000001
    #define pi acos(-1)
    #define N 1000009
    #define ff first
    #define ss second
    #define all(x) x.begin(),x.end()
    /// Code Loading Please wait.............
    /// returning to N~76.
    /// Loading Finished.....................

    int32_t main()
    {
        FAST_IO;
       int n;
       cin>>n;
       map<int,int>boss;
       for(int i=1;i<n;i++ )
       {
           int x;
           cin>>x;
           boss[x]++;
       }
       for(int i=1;i<=n;i++)
       {
           cout<<boss[i]<<endl;
       }
        return 0;
    }



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

int main() {
  int H, W;
  cin >> H >> W;
  string image[H + 1];

  for (int i = 1; i <= H; i++) {
    cin >> image[i];
  }

  for (int i = 1; i <= 2 * H; i++) {
    cout << image[(i + 1) / 2] << endl;
  }

  return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	map<ll, int> m;
	rep(i, 0, n) {
		int t; cin >> t;
		m[t]++;
	}
	vector<ll> v;
	for (auto p : m) rep(i, 0, p.second / 2) v.push_back(p.first);
	reverse(all(v));
	print(sz(v) >= 2 ? v[0] * v[1] : 0);
}


Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;
int a[4];
bool b[3];
bool cal(bool b[]) {
	int ret = a[0];
	for (int i = 0;i < 3;i++) {
		if (b[i])ret += a[i + 1];
		else ret -= a[i + 1];
	}
	return ret == 7;
}
void out() {
	for (int i = 0;i < 3;i++) {
		cout << a[i];
		cout << (b[i] ? "+" : "-");
	}
	cout << a[3] << "=7";
}
int main()
{
	char temp;
	for (int i = 0;i < 4;i++) {
		cin >> temp;
		a[i] = temp - '0';
	}

	for (int num = 0;num < 8;num++) {
		b[0] = num % 2;
		b[1] = (num >> 1) % 2;
		b[2] = (num >> 2) % 2;
		if (cal(b)) {
			out();
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i/60-h*60;
   s = i % 3600%60;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}
// comments for human
// 1 min = 60 sec
// 1 hour = 60 min = 3600 sec


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

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int main(){
    int N, X;
    cin >> N >> X;
    int m[N];
    rep(i, N){
        cin >> m[i];
        X -= m[i];
    }
    sort(m, m+N);
    int ans = N;
    ans += X / m[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$server = "php://stdin";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
$map=[];$max=0;
for($i=0;$i<$t;$i++)
{
    $s=trim(fgets($handle));
    if(isset($map[$s]))
    {
        $map[$s]+=1;
    }else
    $map[$s]=1;

    if($max<$map[$s])
        $max=$map[$s];
}
ksort($map);
foreach ($map as $k=>$v)
{
    if($v==$max)
    {
        echo $k."\n";
    }
}
?>

Measured memory_bytes: 20728
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    a--;b--;
    string s[100];
    for(int i=0;i<50;i++){
        s[i]="";
        for(int j=0;j<100;j++){
            s[i]+='#';
        }
    }
    for(int i=50;i<100;i++){
        s[i]="";
        for(int j=0;j<100;j++){
            s[i]+='.';
        }
    }
    for(int i=0;i<50;i+=2){
        if(a==0){
            break;
        }
        for(int j=0;j<100;j+=2){
            s[i][j]='.';
            a--;
            if(a==0){
                break;
            }
        }
    }
    for(int i=99;i>=50;i-=2){
        if(b==0){
            break;
        }
        for(int j=0;j<100;j+=2){
            s[i][j]='#';
            b--;
            if(b==0){
                break;
            }
        }
        
    }
    cout<<100<<" "<<100<<endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << s[i][j];
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
 
struct sword{
	int a;
	int b;
}kat[200005];
 
int cmp1(sword x,sword y){
	if (x.a>y.a) return 1;
	else if (x.a==y.a&&x.b>y.b) return 1;
	return 0;
}
 
int cmp2(sword x,sword y){
	if (x.b>y.b) return 1;
	else if (x.b==y.b&&x.a>y.a) return 1;
	return 0;
}
 
int main(){
	int n,h;
	cin>>n>>h;
	for (int i=1;i<=n;i++){
		cin>>kat[i].a>>kat[i].b;
	}
	
	int ans=0;
 
		sort(kat+1,kat+1+n,cmp1);
		sort(kat+2,kat+2+n,cmp2);
			for (int i=1;i<=n&&kat[i].b>=kat[1].a;i++){
				h-=kat[i].b;
				ans++;
				if (h<=0) break;
			}
			if (h>0){
				ans+=h/kat[1].a;
				h%=kat[1].a;
				if (h>0) ans++;
			}
	
	cout<<ans;
	
	
}

Measured memory_bytes: 1024
module Vector =
  struct
    type t = { x: float; y: float }
    let eps = 1e-10
    let init x y = {x = x; y = y}
    let add v1 v2 = {x = v1.x +. v2.x; y = v1.y +. v2.y}
    let sub v1 v2 = {x = v1.x -. v2.x; y = v1.y -. v2.y}
    let mul v a = {x = v.x *. a; y = v.y *. a}
    let div v a = {x = v.x /. a; y = v.y /. a}
    let norm v = v.x *. v.x +. v.y *. v.y
    let abs v = sqrt (norm v)
    let dot v1 v2 = v1.x *. v2.x +. v1.y *. v2.y
    let cross v1 v2 = v1.x *. v2.y -. v1.y *. v2.x
    type ccw_t = Ccw | Cw | Ob | Of | Os
    let ccw p0 p1 p2 =
      let v0 = sub p1 p0
      and v1 = sub p2 p0 in
      if cross v0 v1 > eps then Ccw
      else if cross v0 v1 < (-1.0) *. eps then Cw
      else if dot v0 v1 < (-1.0) *. eps then Ob
      else if (norm v0) < (norm v1) then Of
      else Os
  end

let id x = x

let rec read n = if n <= 0 then [] else let z = Scanf.scanf "%f,%f\n" (fun x y -> Vector.init x y) in z :: read (n - 1)

let rec convex clst rlst = 
  match (clst, rlst) with
  | ([], _) -> rlst
  | (c :: crest, []) -> convex crest [c]
  | (c :: crest, [r]) -> convex crest [c;r]
  | (c :: crest, r1 :: r2 :: rrest) -> if Vector.ccw r2 r1 c = Vector.Cw then convex crest (c :: rlst)
                                       else convex clst (r2 :: rrest)

let solve lst =
  let slst = List.sort compare lst in
  let rslst = List.rev slst in
  let ul = convex slst [] in
  let ll = convex rslst [] in
  (List.length lst) - (List.length ul) - (List.length ll) + 2

let _ = 
  let rec loop () = 
    let n = Scanf.scanf "%d\n" id in
    if n = 0 then ()
    else
      begin
        let xy = read n in
        Printf.printf "%d\n" @@ solve xy;
        loop ()
      end
  in loop ()

Measured memory_bytes: 2368
n = int(input())
s = input()

if n % 2 == 1:
    print('No')
else:
    ok = True
    for i in range(n // 2):
        if s[i] != s[n // 2 + i]:
            ok = False
            break
    if ok:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
 
struct node{
  struct node *par;
  struct node *left;
  struct node *right;
  int key;
};
typedef struct node* NodePointer;
 
void init(void);
NodePointer makenode(int);
void insert(int,NodePointer);
void preorder(NodePointer);
void inorder(NodePointer);
NodePointer find(int,NodePointer);
void delete_node(NodePointer); 
NodePointer tree_successor(NodePointer);
NodePointer tree_minimum(NodePointer);

NodePointer head, tail;
 
int main(){
  char str[7];
  int n,k;
  NodePointer x;
 
  init();
  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,str);
 
    if(str[0] == 'i'){
      scanf("%d" ,&k);
      insert(k, head);
    }else if(str[0] == 'p'){
      inorder(head->right);
      puts("");
      preorder(head->right);
      puts("");
    }else if(str[0] == 'f'){
      scanf("%d" ,&k);
      if(find(k,head->right) != NULL){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }else{
      scanf("%d" ,&k);
      x = find(k,head->right);
      delete_node(x);
    }
  }
 
  return 0;
}
 
void init(){
  head = makenode(-1);
  tail = makenode(-1);
  head->par = head;;
  head->right = tail;
  head->left = tail;
}
 
NodePointer makenode(int k){
  NodePointer x;
 
  x = malloc(sizeof(struct node));
  x->key = k;
  x->left = x->right = tail;
 
  return x;
}
 
void insert(int k, NodePointer p){
  if(k < p->key){
    if(p->left == tail){
      p->left = makenode(k);
      p->left->par = p;
    }else{
      insert(k,p->left);
    }
  }else{
    if(p->right == tail){
      p->right = makenode(k);
      p->right->par = p;
    }else{
      insert(k,p->right);
    }
  }
}
 
void preorder(NodePointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->left);
    preorder(node->right);
  }
}
 
void inorder(NodePointer node){
  if(node != tail){
    inorder(node->left);
    printf(" %d", node->key);
    inorder(node->right);
  }
}
 
NodePointer find(int k,NodePointer node){
  if(node == tail){
    return NULL;
  }
 
  if(node->key == k){
    return node;
  }else if(node->key < k){
    return find(k,node->right);
  }else{
    return find(k,node->left);
  }
}

void delete_node(NodePointer node){
  NodePointer x,y;
  if(node->left == tail || node->right == tail){
    y = node;
  }else{
    y = tree_successor(node);
  }

  if(node->left != tail){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != tail){
    x->par = y->par;
  }
  if(y->par == tail){
    node->par = x;
  }else if(y == y->par->left){
    y->par->left = x;
  }else{
    y->par->right = x;
  }

  if(y != node){
    node->key = y->key;
  }
}

NodePointer tree_successor(NodePointer x){
  NodePointer y;

  if(x->right != tail){
    return tree_minimum(x->right);
  }

  y = x->par;
  while(y != tail && x == y->right){
    x = y;
    y = y->par;
  }

  return y;
}

NodePointer tree_minimum(NodePointer x){
  while(x->left != tail){
    x = x->left;
  }
  return x;
}



Measured memory_bytes: 20440
N = int(input())

L = [0] * 101
for i in range(1, 101):
    cnt = 0
    tmp = i
    while tmp % 2 == 0:
        cnt += 1
        tmp //= 2
    L[i] = cnt

print(L.index(max(L[1:N+1])) if N !=1 else 1)

Measured memory_bytes: 9076
n, k = map(int,input().split(" "))
trees = []
for i in range(n):
    trees.append(int(input()))

trees.sort()
min_val = trees[k-1] - trees[0]
for i in range(1, n - k + 1):
    min_val = min(abs(trees[i+k-1] - trees[i]), min_val)
print(min_val)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A);
	vector<int> b(B);
	for (int i = 0; i < A; i++)cin >> a[i];
	for (int i = 0; i < B; i++)cin >> b[i];
	int minA = *min_element(a.begin(), a.end());
	int minB = *min_element(b.begin(), b.end());
	int ans = minA+minB;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c; x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        if (a - b >= c) System.out.println(0);
        else System.out.println(c - (a - b));
    }
}

Measured memory_bytes: 21844
#include "iostream"
#include "string"
using namespace std;

int main(int argc, char const *argv[])
{
	string t;
	string W;
	int count=0;

	cin >> W;
	// cout << "W = " << W << endl;
	while(cin >> t)
	{
		for(int i=0; i<t.size();i++)
		{
			if(isupper(t[i]))
			{
				t[i]+= 32;
			}
		}
		if (t == "END_OF_TEXT")
		{
			break;
		}
		if (t == W)
		{
			count++;
		}
	}

	cout << count <<endl;
	return 0;
}



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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();

            Console.WriteLine(input[0] - (input[1] - 1));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll k;
cin>>k;
if(k>1&&k<=50){
    vector<int> a(k,k);
    cout<<k<<endl;
    for(int i=0;i<k;i++)cout<<a[i]<<" ";
    cout<<endl;
}
else if((k==1||k==0)){
    if(k==0){
        cout<<2<<endl;
        cout<<1<<" "<<1<<endl;
    }
    else {
        cout<<2<<endl;
        cout<<0<<" "<<2<<endl;
    }
}
else{
    ll t=k%50;
    cout<<50<<endl;
    vector<ll> a(50,k/50+50);
    for(int i=t;i<50;i++)a[i]-=t+1;
    for(int i=0;i<50;i++)cout<<a[i]<<" ";
    cout<<endl;
    
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;

int n,a[N],nxt[N];
int gor[N][66];
__int128 st[N][66];
ll k;

int main() {
	scanf("%d%lld",&n,&k);
	rep(i,0,n) scanf("%d",a+i);
	per(i,0,n) nxt[a[i]]=n+i;
	per(i,0,n) {
		gor[i][0]=nxt[a[i]]+1;
		st[i][0]=gor[i][0]-i;
		gor[i][0]=gor[i][0]%n;
		nxt[a[i]]=i;
	}
	rep(j,1,60) {
		rep(i,0,n) {
			gor[i][j]=gor[gor[i][j-1]][j-1];
			st[i][j]=st[i][j-1]+st[gor[i][j-1]][j-1];
		}
	}
	int p=0;
	ll pos=0;
	per(j,0,60) {
		if (pos+st[p][j]<=n*k) {
			pos+=st[p][j];
			p=gor[p][j];
		}
	}
	VI ans;
	while (pos<n*k) {
		int c=a[pos%n];
		if (pos+st[pos%n][0]>n*k) {
			ans.pb(c);
			pos++;
		} else {
			pos+=st[pos%n][0];
		}
	}
	for (auto p:ans) printf("%d ",p); puts("");
}


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


int main(){
    int in;
    int judgeNumber;
    int count=0;
    cin>>in;
    while(in>0){
        judgeNumber=in%10;
        if(judgeNumber==1)count++;
        in/=10;
    }
    cout<<count<<endl;
    return(0);
}

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

def binary_search(func, array, left=0, right=-1):
    if right==-1:right=len(array)-1
    y_left, y_right = func(array[left]), func(array[right])
    while True:
        middle = (left+right)//2
        y_middle = func(array[middle])
        if y_left==y_middle: left=middle
        else: right=middle
        if right-left==1:break

    return left

cumA = [0]
for i in range(N):
  cumA.append(cumA[-1]+A[i])
  
cumB = [0]
for i in range(M):
  cumB.append(cumB[-1]+B[i])
cumB.append(10**20)
  
if cumA[-1]+cumB[-1]<=K:
  print(N+M)
  exit()
  
if A[0] > K and B[0] > K:
  print(0)
  exit()
  
ans = 0
for i in range(N+1):
  if K-cumA[i]<0:break
  idx = binary_search(lambda x:x<=K-cumA[i],cumB)
  res = max(0,i+idx)
  ans = max(ans, res)
  
print(ans)

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

int main() {
  int n; cin >> n;
  
  double ans = 0;
  if(n % 2 == 0)
    ans = 0.5;
  else{
    double cc = (n + 1) / 2;
    ans = cc / n;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
	if(i == 0):
		ans += B[i]
	elif(i == N-1):
		ans += B[i-1]
	else:
		ans += min(B[i-1], B[i])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,w,n;
  cin>>h>>w>>n;
  int m=max(h,w);
  int r=(n+m-1)/m;
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    bool four = false;
    for (int i = 0; i < n; ++i) {
        char s; cin >> s;
        if (s == 'Y') {
            four = true;
            break;
        }
    }
    cout << (four ? "Four" : "Three");
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
vvi g;

int prim(){
    vi d(n,inf),p(n,-1);
    d[0]=0;
    vector<bool> b(n);
    while(true){
        int u;
        int m=inf;
        rep(i,n){
            if(m>d[i]&&!b[i]){
                u=i;
                m=d[i];
            }
        }
        if(m==inf)break;
        b[u]=true;
        rep(v,n){
            if(!b[v]&&g[u][v]!=inf){
                if(d[v]>g[u][v]){
                    d[v]=g[u][v];
                    p[v]=u;
                }
            }
        }
    }
    int s=0;
    rep(i,n){
        if(p[i]!=-1)s+=g[i][p[i]];
    }
    return s;
}

void run(){
    cin>>n;
    g=vvi(n,vi(n));
    rep(i,n){
        rep(j,n){
            int c;
            cin>>c;
            g[i][j]=c==-1?inf:c;
        }
    }
    cout<<prim()<<endl;
}


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

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

  map<string, int> m;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    m[s]++;
  }

  map<int, vector<string>> mp;
  for (auto& e : m) {
    mp[e.second].push_back(e.first);
  }

  int mx = 0;
  for (auto& e : mp) {
    mx = max(mx, e.first);
  }

  auto& ans = mp[mx];
  sort(ans.begin(), ans.end());

  for (auto& s : ans)
    cout << s << endl;
}

Measured memory_bytes: 26868
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices = [int(i) for i in tmp_prices]
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[i])
  
print(ans)
  

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define endl '\n'
typedef long long LL;
using namespace std;

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

  int t = 1; //cin >> t;
  while (t--){
    LL x; cin >> x;
    int ans = 0;
    LL cur = 100;
    while (cur < x){
      cur += cur / 100;
      ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3652
// C - Chocolate Bar
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)

ll check1(int Y, int X){//"||||"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	for(ll x1=1; x1<=X-2; ++x1){
		ll x2 = (X-x1)/2;
		ll x3 = X - x1 - (X-x1)/2;
		s1 = Y * x1;
		s2 = Y * x2;
		s3 = Y * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

ll check2(int Y, int X){//"T"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	for(ll y1=1; y1<=Y-1; ++y1){
		ll y2 = Y-y1;
		ll x1 = X;
		ll x2 = X/2;
		ll x3 = X-x2;
		s1 = y1 * x1;
		s2 = y2 * x2;
		s3 = y2 * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

int main(){
	int H,W; cin>>H>>W;
	ll ans = LLONG_MAX;
	ans = min({ans, check1(H, W), check1(W, H)});
	ans = min({ans, check2(H, W), check2(W, H)});
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int N,A;
	int x;
	
	scanf("%d", &N);
	scanf("%d", &A);
	
	x= N%500;
	
	if(A >= x){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

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

int main(){
    while (true){
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        else if (m == -1 || f == -1 || (m + f) < 30) cout << "F" << endl;
        else if ((m + f) >= 80) cout << "A" << endl;
        else if (65 <= (m + f)) cout << "B" << endl;
        else if (50 <= (m + f)) cout << "C" << endl;
        else if (30 <= (m + f)){
            if (r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092