akhauriyash/Code-Regression huggingface dataset:
//				package Dynamic;
import java.io.*;
import java.util.*;
public class Main{
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
    static public void main(String[] args)throws IOException{
    	st=new StringTokenizer(br.readLine());
    	int n=i();
    	double ar[]=ard(n);
    	PriorityQueue<Double> p=new PriorityQueue<>();
    	for(int x=0;x<n;x++)	p.add(ar[x]);
    	while(p.size()!=1)
    	{
    		p.add((p.poll()+p.poll())/2);
    	}
    	pl(p.poll()+"");
    }
    
    static int i()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Integer.parseInt(st.nextToken());
    }
    static long l()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Long.parseLong(st.nextToken());
    }
    static String s()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return st.nextToken();
    }
    static double d()throws IOException
    {
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	return Double.parseDouble(st.nextToken());
    }
    static void p(String p)
    {
    	System.out.print(p);
    }
    static void pl(String pl)
    {
    	System.out.println(pl);
    }
    static void pl()
    {
    	System.out.println();
    }
    static int[] ari(int n)throws IOException
    {
    	int ar[]=new int[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=i();
    	return ar;
    }
    static long[] arl(int n)throws IOException
    {
    	long ar[]=new long[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=l();
    	return ar;
    }
    static String[] ars(int n)throws IOException
    {
    	String ar[]=new String[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=s();
    	return ar;
    }
    static double[] ard(int n)throws IOException
    {
    	double ar[]=new double[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=d();
    	return ar;
    }
    static char[] arc(int n)throws IOException
    {
    	char ar[]=new char[n];
    	if(!st.hasMoreTokens())
    		st=new StringTokenizer(br.readLine());
    	for(int x=0;x<n;x++)
    		ar[x]=st.nextToken().charAt(0);
    	return ar;
    }
    static void pari(int ar[])
    {
    	for(int a:ar)
    		System.out.print(a+" ");
    }
    static void parl(long ar[])
    {
    	for(long a:ar)
    		System.out.print(a+" ");
    }
    static void pars(String ar[])
    {
    	for(String a:ar)
    		System.out.print(a+" ");
    }
    static void pard(double ar[])
    {
    	for(double a:ar)
    		System.out.print(a+" ");
    }
    static void parc(char ar[])
    {
    	for(char a:ar)
    		System.out.print(a+" ");
    }
}

Measured memory_bytes: 21076
nk = list(map(int, input().split()))
a = [input().split() for l in range(nk[1]*2)]

import itertools

#nk = [3, 2]
#a = [['2'], ['1', '3'], ['1'], ['3']]

#偶数参照
a_2 = a[1::2]

count = 0

aaa = list(itertools.chain.from_iterable(a_2))

for m in range(1, nk[0]+1):

    if not(str(m) in aaa):
        count += 1

print(count)

Measured memory_bytes: 9392
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

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

Node root;

Node treeMinimum(Node x){
	while (x->left!=NIL){
		x = x->left;
	}
	return x;
}

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

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y

	if (z->left == NIL && z->right == NIL){//子なし
		if (z->parent->left == z){
			z->parent->left = NIL;
		}
		else{
			z->parent->right = NIL;
		}
		free(z);
	}
	else if (z->left != NIL && z->right != NIL){//子2人
		x = z->right;
		while (x->left != NIL){
			x = x->left;
		}
		z->key = x->key;
		treeDelete(x);
		
	}
	else{//子1人
		if (z->left!=NIL){//左に子がいたら
			if (z->parent->left == z){//zが親の左側にいたら
				z->parent->left = z->left;
				z->left->parent = z->parent;
			}
			else{//zが親の右側にいたら
				z->parent->right = z->left;
				z->left->parent = z->parent;
			}
		}
		else{//右に子がいたら
			if (z->parent->left == z){//zが親の左側にいたら
				z->parent->left = z->right;
				z->right->parent = z->parent;
				free(z);
			}
			else{//zが親の右側にいたら
				z->parent->right = z->right;
				z->right->parent = z->parent;
			}
		}
	}
}

Node sss(int k, Node x){
	if (x == NIL){ return x; }
	if (k < x->key){
		if (x->left != NIL){
			return sss(k, x->left);
		}
		else{
			return x;
		}
	}
	else{
		if (x->right != NIL){
			return sss(k, x->right);
		}
		else{
			return x;
		}
	}
}

void insert(int k){
	Node y = sss(k,root);
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	z->parent = y;

	if (y == NIL){ root=z; }
	else if (y->key < k){
		y->right = z;
	}
	else{
		y->left = z;
	}
}

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


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

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

	return 0;
}

Measured memory_bytes: 19360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int t = in.nextInt();
		int e = in.nextInt();
		int t1 = t - e;
		int t2 = t + e;
		int num = -1;
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			if (num == -1) {
				for (int j = t1; j <= t2; j++) {
					if (j % x == 0) {
						num = i + 1;
					}
				}
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 12000
N = int(input())
st = input()
ans_st = ""

for i in range(len(st)):
  ch_ord = ord(st[i])
  if ch_ord + N > 90:
    ans_st += chr(ch_ord + N - 26)
  else:
    ans_st += chr(ch_ord + N)
print(ans_st)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
    double x1,y1,x2,y2,x3,y3;
    double a,b,c,x,y;
    double n,px,py,r;
    cin >> n;
    while(n--){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        a = sqrt(pow(x2-x1,2) + pow(y2-y1,2));
        b = sqrt(pow(x3-x2,2) + pow(y3-y2,2));
        c = sqrt(pow(x3-x1,2) + pow(y3-y1,2));
        
        x = ((a*a)-((b*b)+(c*c)))/(-2*b*c);
        y = sqrt(1-x*x);
        r = a/(2*y);
        px = ((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
        py = ((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
        
        printf("%.3f %.3f %.3f\n", px, py, r);
    }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; 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;}
typedef long long ll;

int n,k,p;
string s,t;

int main() {
  cin >> n;
  map<int,int> m;
  rep(i,n){
    int a; cin >> a; m[a]++;
  }
  vector<int> v;
  for(auto a : m){
    if(a.second>=2) v.push_back(a.first);
    if(a.second>=4) v.push_back(a.first);
  }
  sort(v.rbegin(),v.rend());
  cout << (v.size() ? (ll)v[0]*v[1] : 0) << endl;
}

Measured memory_bytes: 4992
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int x; cin>>x;

    int c = x / 100;

    cout << (100 * c <= x && x <= 105 * c) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int imos1[100010], imos2[100010];
int n, w, h;
signed main() {
    cin >> n >> w >> h;
    memset(imos1, 0, sizeof(imos1));
    memset(imos2, 0, sizeof(imos2));
    rep(i,0,n) {
        int x, y, z; cin >> x >> y >> z;
        imos1[max((ll)0, x-z)]++; imos1[min(w, x+z)]--;
        imos2[max((ll)0, y-z)]++; imos2[min(h, y+z)]--;
    }
    bool ng1 = false, ng2 = false;
    ng1 |= imos1[0] == 0; ng2 |= imos2[0] == 0;
    rep(i,1,w) imos1[i] += imos1[i-1], ng1 |= imos1[i] == 0;
    rep(i,1,h) imos2[i] += imos2[i-1], ng2 |= imos2[i] == 0;
    if(ng1 && ng2) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4672
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		int n=sc.nextInt();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long[] x=new long[n+1];
		for(int i=1;i<=n;i++){
			x[i]=sc.nextLong();
		}
		long tired=0;
		for(int i=1;i<=n-1;i++){
			if(a*(x[i+1]-x[i])>=b) tired=tired+b;
			else tired=tired+a*(x[i+1]-x[i]);
		}
		System.out.println(tired);
	}
}

Measured memory_bytes: 50564
#include<stdio.h>

int main(void)
{
	int i;
	int n;
	int t;
	int a[100];
	int score=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&t);
		a[i]=t;
	}
	
	for(i=0;i<n;i++){
		if(a[i]%2==1){
			score++;
		}else{
			if(a[i]%6==0 || a[i]%10==0)
				score++;
		}
	}
	if(score==n)
			printf("APPROVED");
	else
			printf("DENIED");
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N,M,X,Y;

  cin>>N>>M>>X>>Y;

  int x[101];
  int y[101];

  cin>>x[0];

  int maxx=x[0];
  
  for(int i=1;i<N;i++){
    cin>>x[i];
    maxx=max(maxx,x[i]);
  }

  cin>>y[0];

  int minn=y[0];
  
  for(int i=1;i<M;i++){
    cin>>y[i];

    minn=min(minn,y[i]);
  }

  for(int i=maxx+1;i<=minn;i++){

    if(X<i&&i<Y){
      cout<<"No War"<<endl;
      return 0;
    }
  }

  cout<<"War"<<endl;
  
  return 0;

}

  
  


Measured memory_bytes: 256
class UnionFind():

    def __init__(self, n):
        # n個の要素
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        要素xのrootを見つける
        """
        if self.parents[x] < 0:
            return x
        else:
            # 再帰的にrootを求める
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        """
        要素x,要素yについて
        rootが同じ場合そのまま
        異なる場合は要素xの末尾に要素yを付ける
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """
        要素xの集合の大きさを返す
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        要素xと要素yのrootが同じか返す
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def __str__(self):
        return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))


# N人でM個の情報
N, M = map(int, input().split())
# AとBは友達であるという情報がM個
A_B = [list(map(int, input().split())) for _ in range(M)]
union = UnionFind(N)

for a, b in A_B:
    union.unite(a-1, b-1)
ans = 0
for i in range(N):
    ans = max(ans, union.size(i))
print(ans)


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a-1)%2==0){
		cout<<"Borys"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
	return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int nTotal = szArr.Length;
            long[] arr = new long[nTotal];

            long sum = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                arr[i] = long.Parse(szArr[i]);
                sum += arr[i];
            }

            long a = arr[0];
            long b = arr[1];
            long c = arr[2];
            //long sum = a + b + c;

            long max = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
            }

            if ((max * 3) % 2 == sum % 2)
            {
                Console.WriteLine((max * 3 - sum) / 2);

            }
            else
            {
                Console.WriteLine(((max + 1) * 3 - sum) / 2);

            }

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main(){
    unsigned long int a, b, r;
    unsigned long int x, tmp;

    scanf("%lu %lu", &a, &b);

    x = a * b;
     /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    printf("%lu\n", x/b);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    double d,t,s;
    cin >> d >> t >> s;
    double m = d/s;
    //cout << m;
    if(m<=t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3704
import decimal
import math
from itertools import permutations

decimal.getcontext().prec = 16

cache = {}


def distance(a, b):
  return math.sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2))


N = int(input())

P = [None] * N
for i in range(N):
  P[i] = tuple(map(int, input().split()))

total = 0
count = 0
for points in permutations(P, len(P)):
  it = iter(points)
  last = next(it)
  for p in it:
    total += distance(p, last)
    last = p
  count += 1

print(total / count)


Measured memory_bytes: 5972
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define ll long long 
#define SDOI2020 RP++ 
using namespace std;
ll a,b,c; 
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


int main()
{
	cin>>a>>b;
	a = a % b;
	printf("%lld\n",min(a,abs(a - b)));
	
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int flag = 1, i, j, a[101]={},n, count = 0, tmp;
    scanf("%d", &n);
    for( i = 0; i < n; i++ ){
        scanf("%d", &a[i]);
    }
    while( flag ){
        flag = 0;
        for( j = n-1; j >= 1; j-- ){
            if( a[j] < a[j-1] ){
                tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                flag = 1;
                count += 1;
            }
        }
    }
    for( i = 0; i < n; i++ ){
        printf("%d", a[i]);
        if( i != n-1 ){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 604
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N = 200000;
	
	bool a[200000], p[200000];
	int sum[200000];
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	sum[0] = 0;
	sum[1] = 0;
	
	for(int i = 2; i < N; i++){
		p[i] = false;
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
			if(a[(i + 1) / 2]){
				p[i] = true;
			}
		}
		sum[i] = sum[i - 1] + p[i];
	}
	
	int Q;
	cin >> Q;
	
	for(int i = 0; i < Q; i++){
		int l, r;
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) b.at(a.at(i)-1)=i+1;
    rep(i,n) cout << b.at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  string s;
  int n;
  cin >> s >> n;
  int x = s.size();
  x = (x + n - 1) / n;
  rep(i,s.size()){
    if(i % n == 0)cout << s[i];
  }
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int judge ( int );

int main()
{
    int q;
    std::cin >> q;
    for ( int cnt = 0; cnt < q; cnt ++ )
    {
        int n;
        std::cin >> n;
        std::cout << judge(n) << std::endl;
    }
}

int judge ( int n )
{
    // log使うのが面倒くさい
    int tmp;
    int d = 0;
    int max = 0;
    int step = 0;
    int o[10000];
    
    for ( int i = 0; i < 10000; i++ )
    {
        o[i] = 0;
    }
    
    while(true)
    {
    
//    std::cout << "3 " << n << std::endl;
    tmp = n;
    d = 0;
    do
    {
        tmp /= 10;
        d ++;
    } while ( tmp != 0 );
    
    if ( d == 1 )
    {
        break;
    }
    
    tmp = 1;
    max = 0;
    for ( int i = 0; i < d-1; i ++ )
    {
        tmp *= 10;
//        std::cout << "    " << i << " " << (n/tmp) * (n%tmp) << std::endl;
        if ( max < (n/tmp) * (n%tmp) )
        {
            max = (n/tmp) * (n%tmp);
        }
    }
    
    o[step] = n;
    n = max;
    for ( int i = 0; i < step+1; i ++ )
    {
        if ( o[i] == n )
        {
            step = -1;
            break;
        }
    }
    step ++;
    
    }
    
    return step;
}

Measured memory_bytes: 1196
import collections

N, K = map(int,input().split())
l = list(map(int,input().split()))

c = collections.Counter(l)
ans = 0
if K >= len(c):
    pass
elif len(c) > K:
    p = [s[1] for s in c.most_common()[::-1][:(len(c)-K)]]
    ans = sum(p)
print(ans)

Measured memory_bytes: 39320
# -*- coding: utf-8 -*-
N = int(input())
S = input()

# カウント (:+1, ):-1
def func_cnt(str):
    cntlist = []
    tmp = 0
    for s in str:
        if s == "(":
            tmp += 1
        else:
            tmp -= 1
        cntlist.append(tmp)
    
    return cntlist

# ( 不足数
cntlist = func_cnt(S)

while min(cntlist) < 0:
    S = "(" * abs(min(cntlist)) + S
    cntlist = func_cnt(S)

S = S + ")" * cntlist[-1]

print(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()


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

	int s=0;
	for(int i=1;i<=n;i++) if(!(i%5==0 or i%3==0))s += i;
	cout << s << endl;
}

Measured memory_bytes: 3652
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/26/20 20:17:32
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n,m,s; cin>>n>>m>>s;
  struct Train {
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }
  for (int i = 0; i < n; i++) {
    int c,d; cin>>c>>d;
    graph[i].emplace_back(i,-c,d);
  }
  constexpr ll MAX = 2500;
  constexpr ll INF = 1e18;
  vector<array<ll, MAX+1>> dp(n);
  for (auto& arr:dp) arr.fill(INF);
  dp[0][min(s,MAX)] = 0;
  priority_queue<Train, vector<Train>, greater<>> qs;
  qs.emplace(0,s,0);
  while (not qs.empty()) {
    auto [s,c,d] = qs.top(); qs.pop();
    if (d > dp[s][min(c,MAX)]) continue;
    for (auto t:graph[s]) {
      if (c-t.c<0) continue;
      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;
      dp[t.s][min(c-t.c,MAX)] = d+t.d;
      qs.emplace(t.s, c-t.c, d+t.d);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << *min_element(dp[i].begin(), dp[i].end()) << endl;
  }

  return 0;
}


Measured memory_bytes: 7300
#include <iostream>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
	int H,W;
	std::cin >> H >> W;
	string str;
	std::vector<std::vector<int>> v;
	v.resize(H+2);
	for (size_t i = 0; i < H+2; i++) {
		for (size_t j = 0; j < W+2; j++) {
			v[i].push_back(-2);
		}
	}

	for (size_t i = 1; i < H+1; i++) {
		std::cin >> str;
		for (size_t j = 1; j < W+1; j++) {
			if (str[j-1] == '.') {
				v[i][j] = 0;
			}
			if (str[j-1] == '#') {
				v[i][j] = -1;
			}
		}
	}

	for (size_t i = 1; i < H+1; i++) {
		for (size_t j = 1; j < W+1; j++) {
			if (v[i][j] != -1) {
				if (v[i-1][j-1] == -1) v[i][j]++;
				if (v[i-1][j] == -1) v[i][j]++;
				if (v[i-1][j+1] == -1) v[i][j]++;
				if (v[i][j-1] == -1) v[i][j]++;
				if (v[i][j+1] == -1) v[i][j]++;
				if (v[i+1][j-1] == -1) v[i][j]++;
				if (v[i+1][j] == -1) v[i][j]++;
				if (v[i+1][j+1] == -1) v[i][j]++;
			}
		}
	}

	for (size_t i = 1; i < H+1; i++) {
		for (size_t j = 1; j < W+1; j++) {
			if (v[i][j] == -1) {
				std::cout << "#";
			}
			else {
				std::cout << v[i][j];
			}
		}
		std::cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1e9+7
#define ll long long
#define clr(c) memset(c,0,sizeof(c))
const int M=2e5+10;
const int N=1e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1; char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-48; c=getchar();}
	return b*sum;
}
ll n,m,b;
ll a[M];
map<ll,ll> mp;
int main()	
{	
	ll i,j;
	n=read();
	for(i=1;i<=n;i++)
	{
		ll x=read();
		if(mp.count(x))
		{
			printf("NO");
			return 0;
		}
		mp[x]=1;
	}
	printf("YES");
	return 0;
} 

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

def fusion(list_s):
  fusioned_s = ''
  for index, char in enumerate(list_s):
    if index != len(list_s) -1 and char != list_s[index + 1]:
      fusioned_s += char
    elif index == len(list_s) -1:
      fusioned_s += char
      
  return fusioned_s

print(len(fusion(s)))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

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

    int n,x,m,ans = 0,min = 1000;
	cin >> n >> x;

	int count = n;

	rep(i,n){
		cin >> m;
		ans += m;
		if(min > m) min = m;
	}
	while(1){
		if(ans > x){
			count--;
			break;
		}
		if(ans == x) break;
		ans += min;
		count++;
	}

	cout << count << endl;

    return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class t>
struct scc{
	const int n;
	const vvc<int>&g;
	vi ord,low,bl,st;
	int s,head;
	vvc<int> idx,gr;
	void dfs(int v){
		ord[v]=low[v]=head++;
		st.pb(v);
		for(auto to:g[v]){
			if(ord[to]==-1){
				dfs(to);
				chmin(low[v],low[to]);
			}else if(bl[to]==-1)
				chmin(low[v],ord[to]);
		}
		if(ord[v]==low[v]){
			int c=idx.size();
			idx.eb();
			while(1){
				int a=st.back();
				st.pop_back();
				bl[a]=c;
				idx.back().pb(a);
				if(v==a)break;
			}
		}
	}
	scc(const vvc<t>&gg):n(gg.size()),g(gg),
		ord(n,-1),low(n,-1),bl(n,-1){
		head=0;
		rep(i,n)if(ord[i]==-1)
			dfs(i);
		s=idx.size();
		rep(i,n)
			bl[i]=s-1-bl[i];
		reverse(all(idx));
		//construct the graph
		vc<bool> u(s);
		gr.resize(s);
		rep(i,s){
			for(auto v:idx[i]){
				for(auto to:g[v])if(bl[v]<bl[to]){
					if(!u[bl[to]])
						gr[bl[v]].pb(bl[to]);
					u[bl[to]]=1;
				}
			}
			for(auto v:idx[i])
				for(auto to:g[v])
					u[bl[to]]=0;
		}
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n,m;cin>>n>>m;
	vvc<int> g(n);
	rep(i,m){
		int u,v;cin>>u>>v;
		g[u].pb(v);
	}
	
	scc<int> s(g);
	
	int q;cin>>q;
	rep(i,q){
		int u,v;cin>>u>>v;
		cout<<(s.bl[u]==s.bl[v])<<"\n";
	}
}



Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int max_score = 10000;

int main() {
    int N; cin >> N;
    vector<bool> dp(max_score + 1, false);
    dp[0] = true;
    REP(i, 0, N) {
        int s; cin >> s;
        for (int j = max_score; j >= 0; j--) {
            if (j + s <= max_score) dp[j + s] = (dp[j + s] | dp[j]);
        }
    }

    for (int i = max_score; i >= 0; i--) if (i % 10 != 0 && dp[i]) {
        cout << i << endl;
        return 0;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max();

// RMQ
template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        n = 1;
        while(n < n_) n <<= 1;
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(r - l == w) return dat[v];
        T res = inf;
        res = std::min(res, query(v*2, w/2, l, min(r, w/2)));
        res = std::min(res, query(v*2+1, w/2, max(0, l-w/2), r-w/2));
        return res;
    }
    void update(int i, T x){
        i += n;
        dat[i] = x;
        while(i != 1){
            dat[i>>1] = min(dat[i], dat[i^1]);
            i /= 2;
        }
    }
    T query(int l, int r){
        return query(1,n,l,r);
    }
    size_t size() const {
        return n;
    }
};

int main(){
    fastios();
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        rep(i,q){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << endl;
            }
        }
    }
}

Measured memory_bytes: 2052
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>
#include<map>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << 0 << endl;
		return 0;
	}
	ff(i, 1, x+1) {
		if (i * 108 / 100 == x) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, m;
    cin >> n >> m;
    vi x(m);
    rep(i, m) {
        cin >> x[i];
    }
    sort(all(x));

    vi sa(m-1);
    rep(i, m-1) {
        sa[i] = x[i+1]-x[i];
    }
    vi sa_ = sa;
    sort(all(sa_));
    int nn = m-n;
    ll ans = 0;
    if(nn > 0) {
        rep(i, nn) {
            ans += sa_[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=1;
template<typename T=int>
T gi() {
    T x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
string to_string(string s) { return '"'+s+'"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b?"true":"false"); }
template<typename A,typename B> string to_string(pair<A,B> p) {
    return "("+to_string(p.fi)+","+to_string(p.se)+")";
}
template<typename T> string to_string(T v) {
    int fst=1;string ret="{";
    for(auto x:v) {
        if(!fst) ret+=",";
        fst=0,ret+=to_string(x);
    }
    ret+="}";return ret;
}
void dbg_out() { cerr<<endl; }
template<typename Head,typename... Tail> void dbg_out(Head H,Tail... T) {
    cerr<<" "<<to_string(H);
    dbg_out(T...);
}
#define dbg(...) cerr<<"{"<<#__VA_ARGS__<<"}:",dbg_out(__VA_ARGS__)

template<typename T>
int qpow(int a,T b) {
    int ret=1;
    while(b) {
        if(b&1) ret=1ll*ret*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return ret;
}

const int N=2e5+10;

int n,Q,f[N];
vector<tuple<int,int,int>> e;

namespace dsu {

    int fa[N];

    void init() {
        for(int i=1;i<=n;i++) fa[i]=i;
    }

    int getf(int x) {
        return x==fa[x]?x:fa[x]=getf(fa[x]);
    }

    bool merge(int x,int y) {
        x=getf(x),y=getf(y);
        if(x==y) return 0;
        fa[y]=x;return 1;
    }
    
}

int main() {
    n=gi(),Q=gi();
    memset(f,0x3f,sizeof(f));
    while(Q--) {
        int a=gi()+1,b=gi()+1,c=gi();
        chkmin(f[a],c+1),chkmin(f[b],c+2);
        e.pb(mt(c,a,b));
    }
    for(int i=2;i<=n;i++) chkmin(f[i],f[i-1]+2);
    chkmin(f[1],f[n]+2);
    for(int i=2;i<=n;i++) chkmin(f[i],f[i-1]+2);
    for(int i=1;i<=n;i++) e.pb(mt(f[i],i,i%n+1));
    dsu::init();
    sort(all(e));
    ll ans=0;
    for(auto x:e) {
        int u=get<1>(x),v=get<2>(x),w=get<0>(x);
        if(dsu::merge(u,v)) ans+=w;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9328
N, A, B = map(int, input().split())
S = input()

count_all = 0
rank_b = 1
for c in S:
  if c == "a":
    if count_all < (A + B):
      print("Yes")
      count_all += 1
    else:
      print("No")
  elif c == "b":
    if count_all < (A + B) and (rank_b <= B):
      print("Yes")
      count_all += 1
      rank_b += 1
    else:
      print("No")
  elif c == "c":
    print("No")


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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

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

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	vi v{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};
	cin >> k;
	cout << v[k-1] << endl;

}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

using int64 = long long;

vector< int64 > divisor(int64 n)
{
    vector< int64 > ret;
    for(int64 i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main(){
    lint N;
    cin >> N;
    auto factor = divisor(N);
    lint ans = 0;
    for(lint i: factor){
        if(i > 1 && N / (i - 1) == N % (i - 1)){
            ans += i - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int max=0;
        
        for(int i=1;i<=1000;i++){
            for(int k=2;k<=1000;k++){
                if((int)Math.pow(i,k)>x) break;
                if((int)Math.pow(i,k)>max){
                    max=(int)Math.pow(i,k);
                }
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define min(a, b) a < b ? a : b
int main(void)
{
    int a, b, ab, x, y;
    scanf("%d%d%d%d%d", &a, &b, &ab, &x, &y);
    if (ab * 2 >= a + b)
    {
        printf("%d\n", a * x + b * y);
        return 0;
    }
    
    int buy_half = min(x, y);
    int left_x = x - buy_half;
    int left_y = y - buy_half;
        
    if (left_x)
    {
        if (ab * 2 < a)
        {
            printf("%d\n", ab * (buy_half + left_x) * 2);
        }
        else
        {
            printf("%d\n", ab * buy_half * 2 + a * left_x);
        }
        return 0;
    }
        if (left_y)
        {
            if (ab * 2 < b)
            {
                printf("%d\n", ab * (buy_half + left_y) * 2);
            }
            else
            {
                printf("%d\n", ab * buy_half * 2 + b * left_y);
            }
        return 0;
    }
    
    printf("%d\n", ab * buy_half * 2);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int d,s=0;
  int i;
  while(scanf("%d",&d)!=EOF){
    s=0;
    for(i=1;i*d<600;i++){
      s+=(i*d)*(i*d)*d;
    }
    printf("%d\n",s);
  }
  return(0);
}

Measured memory_bytes: 596
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
 for j in range(b+1):
  for k in range(c+1):
   if 500*i+100*j+50*k == x:
    count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	set<string> s;
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		s.insert(S[i]);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 25052
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

ll n;
char s[200000];
bool a[200000];

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

    REP(ani1,2) {
        REP(ani2,2) {
            a[0] = ani1;
            a[1] = ani2;


            FOR(i,2,n) {
                if(a[i - 1] ^ (s[i - 1] == 'o')) {
                    a[i] = !a[i - 2];
                }else {
                    a[i] = a[i - 2];
                }
            }

            bool f = true;

            if(a[0]) {
                if(s[0] == 'o') {
                    if(a[n - 1] != a[1]) {
                        f = false;
                    }
                }else {
                    if(a[n - 1] == a[1]) {
                        f = false;
                    }
                }
            }else {
                if(s[0] == 'o') {
                    if(a[n - 1] == a[1]) {
                        f = false;
                    }
                }else {
                    if(a[n - 1] != a[1]) {
                        f = false;
                    }
                }
            }
            if(a[n - 1]) {
                if(s[n - 1] == 'o') {
                    if(a[n - 2] != a[0]) {
                        f = false;
                    }
                }else {
                    if(a[n - 2] == a[0]) {
                        f = false;
                    }
                }
            }else {
                if(s[n - 1] == 'o') {
                    if(a[n - 2] == a[0]) {
                        f = false;
                    }
                }else {
                    if(a[n - 2] != a[0]) {
                        f = false;
                    }
                }
            }
            if(f) {
                REP(i,n) {
                    if(a[i]) {
                        cout << 'S';
                    }else {
                        cout << 'W';
                    }
                }
                cout << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 512