akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    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...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   vector<long int> v(3);
   for(long int i = 0; i < 3; i++)
   	cin>>v[i];

   sort(v.begin(),v.end());

   if(v[2] == v[0] && v[0] == v[1])
   	return cout<<"No",0;
   else if(v[2] == v[1] || v[1] == v[0])
   	return cout<<"Yes",0;
   cout<<"No";
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 1000000000
int n,m,r[21][21],cost[21][21];
int x1,x2,y1,y2;
int d[21];
int BF(int a,int b){
  for(int i=0;i<21;i++)d[i]=INF;
  d[a]=0;
  for(int i=0;i<n*2;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        if(r[j][k])
          d[k]=min(d[k],d[j]+cost[j][k]);
      }
    }
  }
  return d[b];
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    r[a][b]=1;r[b][a]=1;
    cost[a][b]=c;cost[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  // cout<<BF(x1,x2)<<endl;
  //cout<<BF(x2,x1)<<endl;
  cout<<y1-y2-BF(x1,x2)-BF(x2,x1)<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a, b, c, ans=0;
	cin>> a >> b >> c;

	for(int i=a;i<=b;i++){
		if(i%c==0) ans++;
	}
	cout<< ans << endl;
 
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

ll dp[405][405];

int main() {
    int n; cin >> n;
    vint a(n);
    vll sum(n+1,0);
    rep(i,n) {
        int x; cin >> x;
        a[i] = x;
        sum[i+1] = sum[i] + x;
    }
    rep(i,n)rep(j,n) dp[i][j] = inf_l;
    rep(i,n) dp[i][i] = 0;
    for (int len = 1; len < n; len++) {
        for (int l = 0; l < n-len; l++) {
            int r = l+len;
            for (int k = l; k < r; k++) {
                chmin(dp[l][r],dp[l][k]+dp[k+1][r]+(sum[k+1]-sum[l])+(sum[r+1]-sum[k+1]));
            }
        }
    }
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n, m, a, b;
	cin >> n >> m;
	
	//vector < int > graph[n];
	int graph[n][n]; //graphの記憶
	int cities[n]; //next_permutation用
	for(int i =0; i< n; i++){
		cities[i] = i;
		for(int j = 0; j < n; j++){graph[i][j] = 0;}
	}
	
	for(int i = 0; i< m; i++){
		cin >> a >> b;
		graph[a-1][b-1] = 1;
		graph[b-1][a-1] = 1;
	}
	
	int count = 0;
	do{
		count ++;
		//for(int i = 0; i< n; i++){cout << cities[i];}
		//cout << " :check the root" << endl;
		for(int i = 0; i< n-1; i++){
			//cout << cities[i] << ", "<<cities[i+1] << endl;
			if(graph[cities[i]][cities[i+1]] == 0){
				//cout << "break"<< endl;
				count --; break;
			}
			
		}
	}while(next_permutation(cities+1, cities+n)); 
	//始点が1(cities, graphのインデックス0)固定なので, cities[1] ~ cities[n-1]までを変更
	//この覚え方間違えそうだな・・・
	
	cout << count << endl;
	return 0;


}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	int pre = a.at(0), cnt = 1;
	a.at(0) = -1;
	for (int i = 0; i < N; i++) {
		if (pre == 2) break;
		if (pre == -1) {
			cnt = -1;
			break;
		}
		int tmp = a.at(pre - 1);
		cnt++;
		a.at(pre - 1) = -1;
		pre = tmp;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
import numpy as np
import itertools

N, M, X = map(int, input().split())
C_list = []
ans = []

for _ in range(N):
    C_list.append(list(map(int, input().split())))
    
for i in range(1,N+1):
    for j in itertools.combinations(C_list, i):
        a = np.zeros(M+1)
        for k in j:
            a += np.array(k)
        if np.all(a[1:]>=X):
            ans.append(a[0])
if ans:
    print(int(min(ans)))
else:
    print(-1)

Measured memory_bytes: 26992
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    int x=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
        x^=v[i];
    }
    for(int i=0; i<n; i++) cout<<(x^v[i])<<" ";

    return 0;
}


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

using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  int sum = 0;
  switch (X) {
  case 1:
    sum += 300000;
    break;
  case 2:
    sum += 200000;
    break;
  case 3:
    sum += 100000;
    break;
  }
  switch (Y) {
  case 1:
    sum += 300000;
    break;
  case 2:
    sum += 200000;
    break;
  case 3:
    sum += 100000;
    break;
  }
  if (X == 1 && Y == 1) {
    sum += 400000;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define M(a,b) (a<b?a:b)
#define F(i,n) for(int i=0;i<n;i++)
int n,m,a,b,c,d,e[20][20];int main(){memset(e,31,1600);scanf("%d%d",&n,&m);F(i,m){scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;e[a][b]=c;e[b][a]=d;}scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;F(k,n)F(i,n)F(j,n) e[i][j] = M(e[i][j],e[i][k]+e[k][j]);printf("%d\n",c-d-e[a][b]-e[b][a]);return 0;}

Measured memory_bytes: 0
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def cmb(n, k):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

N, K = lr()
MOD = 10 ** 9 + 7
U = 2010 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
red = N-K
for i in range(1, K+1):
    # (red+1)Ci
    answer = 0 if red+1 < i else cmb(red+1, i)
    #print(answer)
    remain = K - i
    # remainをiの中に自由にいれる、i-1の壁を用意
    # (remain+(i-1)) C remain
    answer *= cmb(remain+i-1, remain)
    print(answer%MOD)

# 15


Measured memory_bytes: 12860
object Main {

    def main(args: Array[String]): Unit = {
        val sc = new java.util.Scanner(System.in)

        combination(sc)
    }

    def combination(scanner: java.util.Scanner): Unit = {
        val n, x = scanner.nextInt
        var count = 0

        if( n != 0 || x != 0 ) {
            for( i <- 1 to n-2 ) {
                for( j <- i+1 to n-1 ) {
                    if( i < j && j < x-i-j && x-i-j <= n ) count += 1
                }
            }

            println(count)
            combination(scanner)
        }
    }
}


Measured memory_bytes: 45156
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    edge = [(k, v) for k, v in cnt.items() if v >= 2]
    edge.sort(reverse=True)

    if len(edge) >= 1 and edge[0][1] >= 4:
        ans = edge[0][0] ** 2
    elif len(edge) >= 2:
        ans = edge[0][0] * edge[1][0]
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()


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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M;
lld a[300002],sum[300002],tmp[300002];
lld d[300002],d1[300002],d2[300002];
struct data{
	lld a,b;
	data(){}
	data(lld a,lld b):a(a),b(b){}
};
struct CHT{
	int cr,cf;
	data line[300002];
	void init(){
		cr = cf = -1;
	}
	lld ccw(data x,data y,data z){
		return (x.a*y.b+y.a*z.b+z.a*x.b)-(x.b*y.a+y.b*z.a+z.b*x.a);
	}
	lld f(int num,lld x){
		return line[num].a*x+line[num].b;
	}
	lld getv(lld x){
		while(cf && f(cf-1,x) >= f(cf,x)) cf--;
		return f(cf,x);
	}
	void add(lld a,lld b){
		while(cr > 0 && ccw(line[cr-1],line[cr],data(a,b)) <= 0) cr--;
		cf = min(cf,cr);
		if(cr != cf) return;
		cr++; cf++;
		line[cr] = {a,b};
	}
}cht;

void setting(lld D[]){
	cht.init();
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	cht.add(0,0);
	for(lld i=1; i<=N; i++){
		D[i] = max(cht.getv(i)+(i*(i+1)/2)-sum[i],D[i-1]);
		cht.add(-i,D[i]+sum[i]+(i*(i-1)/2));
	}
}

void divide(int s,int e){
	if(s == e){
		//d[s] = max(d1[s-1]+d2[s+1]+1-a[s],d[s]);
		return;
	}
	int m = (s+e)>>1;
	lld res;
	divide(s,m);
	divide(m+1,e);
	cht.init();
	for(lld i=s-1; i<m; i++){
		cht.add(-i,d1[i]+sum[i]+(i*(i-1)/2));
	}
	for(lld i=m+1; i<=e; i++){
        tmp[i] = cht.getv(i)+(i*(i+1)/2)-sum[i]+d2[i+1];
	}
	res = -Linf;
	for(lld i=e; i>=m+1; i--){
        res = max(res,tmp[i]);
        d[i] = max(res,d[i]);
	}
	cht.init();
	for(lld i=m+2; i<=e+1; i++){
		cht.add(-i,d2[i]-sum[i-1]+(i*(i+1)/2));
	}
	res = -Linf;
	for(lld i=s; i<=m; i++){
        res = max(cht.getv(i)+(i*(i-1)/2)+sum[i-1]+d1[i-1],res);
		d[i] = max(res,d[i]);
	}
}

int main(){
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
        scanf("%lld",&a[i]);
        d[i] = -Linf;
	}
	setting(d1);
	reverse(a+1,a+N+1); setting(d2); reverse(a+1,a+N+1); reverse(d2+1,d2+N+1);
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	divide(1,N);
	scanf("%d",&M);
	for(int i=1; i<=M; i++){
		int x; lld y;
		scanf("%d %lld",&x,&y);
		printf("%lld\n",max(d1[x-1]+d2[x+1],d[x]+a[x]-y));
	}

	return 0;
}


Measured memory_bytes: 17280
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int i = sc.nextInt();
		int j = sc.nextInt();
		if(500 * i >= j) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35568
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 1005
using namespace std;
struct node
{
    int x,y,step;
};
node now,net;
char mp[Maxn][Maxn];
int vis[Maxn][Maxn];
int dt[][2] = {{0,1},{1,0},{0,-1},{-1,0}};
int h,w,n;
int total;
int startx,starty;
int bfs(char endd)
{
    MEM(vis,0);
    queue<node>q;
    vis[startx][starty]=1;
    q.push({startx,starty,0});
    while(!q.empty())
    {
        now=q.front();
        q.pop();
        if(mp[now.x][now.y]==endd)
        {
            startx=now.x;
            starty=now.y;
            return now.step;
        }
        for(int i=0; i<4; i++)
        {
            net.x=now.x+dt[i][0];
            net.y=now.y+dt[i][1];
            net.step=now.step+1;
            if(!vis[net.x][net.y]&&mp[net.x][net.y]!='X'&&net.x>=0&&net.x<h&&net.y>=0&&net.y<w)
            {
                vis[net.x][net.y]=1;
                q.push(net);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>h>>w>>n;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
        {
            cin>>mp[i][j];
            if(mp[i][j]=='S')
            {
                startx=i;
                starty=j;
            }
        }
    total=0;
    for(int i=1; i<=n; i++)
    {
        total+=bfs(char(i+'0'));
    }
    cout<<total<<endl;

}





Measured memory_bytes: 8068
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	int a[n+1],b[n+1];
	int aa[n+1],bb[n+1];
	for(int i=1;i<=n;i++)aa[i]=i;
	for(int i=1;i<=n;i++)bb[i]=i;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	int cnt=0;
	do{
		cnt++;
		int ff=1;
		for(int i=1;i<=n;i++){
			if(aa[i]==a[i]);
			else{
				ff=0;
				break;
			}
		}
		if(ff)break;
	}
	while(next_permutation(aa+1,aa+n+1));
	int cnt1=0;
	do{
		cnt1++;
		int ff=1;
		for(int i=1;i<=n;i++){
			if(bb[i]==b[i]);
			else{
				ff=0;
				break;
			}
		}
		if(ff)break;
	}
	while(next_permutation(bb+1,bb+n+1));
	cout<<abs(cnt1-cnt)<<endl;	
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x;
    cin >> x;
    int a = 0;
    int b = x;
    for(int i=0;i<8;i++){
        int c;
        c = b%10;
        a += c;
        b /= 10;
        if(b==0)
            break;
    }
    if(x%a==0){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>

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


Measured memory_bytes: 2680
def examA():
    X, Y, Z = LI()
    X, Y = Y,X
    X,Z = Z, X
    print(X,Y,Z)
    return

def examB():
    N, M = LI()
    A = LI()
    need = (sum(A)-1)//(4*M) + 1
    ans = 0
    #print(need)
    for a in A:
        if a>=need:
            ans += 1
    if ans>=M:
        print("Yes")
    else:
        print("No")
    return

def examC():
    N, K = LI()
    ans = N%K
    if K-ans<ans:
        ans = K-ans
    print(ans)
    return

def examD():
    def bfs(n):
        # 点の数、スタートの点、有向グラフ
        W = [""] * n
        # 各点の状態量、最短距離とか,見たかどうかとか
        que = deque()
        for i in range(1,10):
            que.append(str(i))
            W[i-1] = str(i)
        i = 9
        while(i<n):
            now = que.popleft()
            end = now[-1]
            for j in [-1,0,1]:
                ne = int(end)+j
                if 0<=ne<=9:
                    W[i] = now + str(ne)
                    que.append(W[i])
                    i += 1
                    if i==n:
                        break
        return W
    K = I()
    if K<=12:
        ans = K
        print(ans)
        return
    ans = bfs(K)[-1]
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examD()

"""

"""

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

int main(){
    int N,T;
    vector<int> t;
    cin>>N>>T;
    for (int i=0; i<N; i++) {
        int x;
        cin>>x;
        t.push_back(x);
    }
    vector<int> time;
    for (int i=0; i<N-1; i++) {
        if (t[i+1]-t[i]<T) {
            time.push_back(t[i+1]-t[i]);
        }else{
            time.push_back(T);
        }
    }
    int sum=accumulate(time.begin(), time.end(),0)+T;
    cout<<sum<<endl;
    return 0;
}


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

int main() {

  string s;
  cin >> s;

  rep(i, s.size()) { cout << 'x'; }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  for j in range(1,k+1):
    if i-j>=0:
      res=abs(h[i]-h[i-j])
      dp[i]=min(dp[i],dp[i-j]+res)
    else:
      break
print(dp[n-1])
  

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

using namespace std;
int main(){
  int n;
   cin >>n;
  
  vector<long> x(n),y(n);
  for(int i=0;i<n;i++) {
    cin >> x[i];
    y[i]=x[i];
  }
  sort(y.begin(),y.end(),greater<long>());
  
 
  for(int i=0;i<n;i++){
  if((x[i]>y[n/2-1])||(x[i]==y[n/2-1]&&y[n/2-1]>y[n/2])) cout << y[n/2] << endl;
  else cout << y[n/2-1] << endl;
  }
    
  
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
long long arr[3005];
long long dp[3001][3001][2];
long long solve(int idx1,int idx2,bool turn)
{
    if(idx1 > idx2)
        return 0;
    if(dp[idx1][idx2][turn] != -1)
        return dp[idx1][idx2][turn];
    if(turn)
        return dp[idx1][idx2][turn] = max(arr[idx1] + solve(idx1+1,idx2,!turn),arr[idx2] + solve(idx1,idx2-1,!turn));
    else
        return dp[idx1][idx2][turn] = min(-arr[idx1] + solve(idx1+1,idx2,!turn),-arr[idx2] + solve(idx1,idx2-1,!turn));
}
int main()
{
    memset(dp,-1,sizeof dp);
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
        cin >> arr[i];
    cout << solve(1,n,1);
    return 0;
}


Measured memory_bytes: 141184
from collections import defaultdict

n, k = map(int, input().split())
A = list(map(int, input().split()))
d = defaultdict(int)

for a in A:
    d[a] += 1

kinds = len(d)
d = sorted(d.items(), key=lambda x: x[1])
ans = 0

for i in range(kinds - k):
    ans += d[i][1]

print(ans)


Measured memory_bytes: 39344
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
 
int main() {
boost
int k;
int x;
cin>>k>>x;
if(k==1)
	cout<<x;
else{	
for(int i=(x-k+1);i<(x+k);++i)
	cout<<i<<" ";
}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 101415
#define  vi vector<int>
#define  v  vector
#define die exit(0)
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 
gp_hash_table<int, int> table;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};


int seive[N];


void solve()
{

    for(int i = 2 ; i <= N-20 ; i++)
    {
    	if(seive[i] > MOD)continue;
    	seive[i] = i;
    	for(int j = i+i ; j<=N-10 ; j+=i)seive[j] = MOD*MOD;
    }
	

	
	rfor(i,N-30,1)
	{
		//if(seive[i] == 0){cout<<i;die;}

		seive[i] = min(seive[i],seive[i+1]);
	}
	seive[1] = 2;
	int x;
	cin>>x;
	cout<<seive[x];
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       g++ -g c.cpp ; timeout 2s ./a.out

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    if (T.length() == S.length() + 1 && T.substr(0, S.length()) == S)
        cout << YES << endl;
    else
        cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

struct UnionFind{
    vector<int> data;
	UnionFind(int size):data(vector<int>(size,-1)){}
    bool unionSet(int x,int y){
        x = root(x),y = root(y);
        if(x != y){
			if(data[y] < data[x])swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x,int y){return root(x) == root(y);}
    int root(int x){return data[x] < 0 ? x : data[x] = root(data[x]);}
    int size(int x){return -data[root(x)];}
};

int main(){
    int N;
    cin >> N;
    vector<pair<int, int> > X(N);
    vector<pair<int, int> > Y(N);
    REP(i, N){
        int x, y;
        cin >> x >> y;
        X[i] = make_pair(x, i);
        Y[i] = make_pair(y, i);
    }
    sort(ALL(X));
    sort(ALL(Y));
    vector<pair<LL, pair<int, int> > > edges;
    REP(i, N-1){
        LL dx = X[i+1].first - X[i].first;
        LL dy = Y[i+1].first - Y[i].first;
        edges.push_back(make_pair(dx, make_pair(X[i+1].second, X[i].second)));
        edges.push_back(make_pair(dy, make_pair(Y[i+1].second, Y[i].second)));
    }
    sort(ALL(edges));
    UnionFind uf(N);
    LL res = 0;
    REP(i, edges.size()){
        int a = edges[i].second.first;
        int b = edges[i].second.second;
        if(uf.unionSet(a, b)){
            res += edges[i].first;
        }
    }
    cout << res << endl;

    return 0;
}


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

int main() {
    int64_t A,B,C,K;
    cin >> A >> B >> C >> K;
    
    int64_t ans = 0;
    if ( K <= A ){
        ans = K;
    } else if ( K <= A + B ){
        ans = A;
    } else {
        ans = A - ( K - A - B );
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 3.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}

#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n,m;
double p[3000];


 


double cache[3005][3005];
int vis[3005][3005];


long double dp(int pos, int head){


	if(pos==n)
		return (head*2>=n);



	if(vis[pos][head])
		return cache[pos][head];


	vis[pos][head]=1;
	cache[pos][head]=p[pos]*dp(pos+1,head+1)+(1-p[pos])*dp(pos+1,head);
	return cache[pos][head];





}



 
void solve(){
 
 
	cin>>n;
	fr(i,0,n) cin>>p[i];


	cout<<dp(0,0);









 
}
 



signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Measured memory_bytes: 139904
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
using v =vector<ll>;
using vv = vector<v>;
using p = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(n);i++)
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}
ll dx[4] ={1,0,-1,0};
ll dy[4] ={0,1,0,-1};

void d(){
    ll h,w;
    cin >> h >> w;
    auto s = vector<string>(h,string(w,'#'));
    auto d = vv(h,v(w,INF));
    ll c=0;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            c+=s[i][j]=='.'?1:0;
        }
    }
    d[0][0]=1;
    auto q = queue<p>();
    q.push(p(0,0));

    while(!q.empty()){
        auto u = q.front(); q.pop();
        if(u.first==h-1&&u.second==w-1) break;
        for(int i=0;i<4;i++){
            auto y=u.first+dy[i];
            auto x=u.second+dx[i];
          	if(0<=x&&x<w&&0<=y&&y<h&&s[y][x]=='.'&&d[y][x]==INF){
                d[y][x] = d[u.first][u.second] + 1;
                q.push(p(y,x));
            }
        }
    }  

    cout << (d[h-1][w-1]==INF?-1:c-d[h-1][w-1]); 
}

int main(){
  d();
}

Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    cout << s.rfind('Z') - s.find('A') + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],h[1000005];
bool getdiv(int x)
{
	for(int i=1;i*i<=x;i++)
	{
		if(x%i==0)
		{
			h[i]++;
			if(i!=1&&h[i]>1) return 1;
			if(x/i!=i) 
			{
				h[x/i]++;
				if(x/i!=1&&h[x/i]>1) return 1;
			}
		}
	}
	return 0;
}
bool check()
{
	for(int i=1;i<=n;i++)
	{
		if(getdiv(a[i])) return 0;
	}
	return 1;
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(check()) 
	{
		puts("pairwise coprime");
		return 0;
	}
	int GCD=a[1];
	for(int i=2;i<=n;i++) GCD=__gcd(a[i],GCD);
	if(GCD==1) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}

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

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


int main(){
	ll N; cin>>N;
  vector<ll> a(N+1);
  rep(i,N) cin>>a[i];
  a[N]=a[0];
  vector<ll> sa(N);
  vector<ll> mou(N+3);
  
  rep(i,N) sa[i]=a[i+1]-a[i];
  
  mou[1]=0;
  for(int i=0;i<=N-1;i+=2){
  	mou[i+3]=mou[i+1]+sa[i]*2;
  }
  mou[2]=mou[N+2];
  for(int i=1;i<=N-2;i+=2){
  	mou[i+3]=mou[i+1]+sa[i]*2;
  }
  ll rain=0,mourain=0;
  rep(i,N){
    rain+=a[i];
    mourain+=mou[i+1];
  }
  rep1(i,N){
  	mou[i]+=(rain-mourain)/N;
  }
  
  rep1(i,N) printf("%lld ",mou[i]);
}

Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(43);

int n, l;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> l;
	int res = 0, a = 999999;
	for (int i = 1; i <= n; i++)
	{
		res += l + i - 1;
		if (abs(l + i - 1) < abs(a))
			a = l + i - 1;
	}
	cout << res - a;
	return 0;
}

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

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

  string s;
  cin >> s;
  int a[s.size()] = {0};
  int r = 0;
  int l = 0;
  int c = 0;
  for (int i = 0; i < s.size(); i++) {
    c++;
    if (s[i] == 'R' && s[i+1] == 'L') {
      r = c;
      c = 0;
    }
    if ((s[i] == 'L' && s[i+1] == 'R') || (i == s.size() - 1)) {
      l = c;
      c = 0;
      a[i-l] += (r+1)/2 + l/2;
      a[i-l+1] += (l+1)/2 + r/2;
      r = 0;
      l = 0;
    }
  }
  for (int i = 0; i < s.size(); i++) {
    cout << a[i] << '\n';
  }
}

Measured memory_bytes: 1104
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("ABC", X) :- X < 1200, !.
f("ARC", X) :- X < 2800, !.
f("AGC", X).

main :-
	get_number(A),
    get_number(B),
    get_number(C),
    X is max(max(A, B), C),
    Y is min(min(A, B), C),
    Z is X - Y,
    writeln(Z).


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

int main() {
  int D;
  cin >> D;
  
  vector<int> c(27), tmp(27);
  vector<vector<int>> s(D+1 , vector<int>(27));
  for (int i = 1; i <= 26; i++)  cin >> c.at(i);
  for (int i = 1; i <= D; i++)  for(int j = 1; j <= 26; j++)  {
    cin >> s.at(i).at(j);
  }
  
  vector<int> last(27);//最終開催日
  for (int i = 1; i <= 26; i++) last.at(i) = 0;
  
  vector<int> t(D+1);//開催テストタイプ
  for (int i = 1; i <= D; i++)  cin >> t.at(i);
  
  
  vector<int> dd(D+1), qq(D+1);
  for (int i = 1+1; i <= D; i++) {
    int mmax = 0, ttyp;
    for (int j = 1; j <= 26; j++) {
      int tmp = abs(s.at(i).at(j) - s.at(i-1).at(j) );
      if (mmax < tmp) {
        mmax = tmp;
        ttyp = j;
      }
    }
    qq.at(i) = ttyp;
  }
  
  //初期計算
  for (int i = 1; i <= D; i++) {
    int typ = 0;
    int smax = 0,stf;
    for (int j = 1; j <= 26; j++) {
      stf = s.at(i).at(j) + (i-last.at(j)) * c.at(j);
      if (stf > smax) {
        smax = stf;
        typ = j;
      }
    }
    
    last.at(typ) = i;
    
    t.at(i) = typ;   
  }
  
  vector<int> stf(D+1);
  int sf = 0;
  for (int i = 1; i <= D; i++) {
    sf += s.at(i).at(t.at(i));
    last.at(t.at(i)) = i;
    
    for (int j = 1; j <= 26; j++) {
      sf -=c.at(j)*(i-last.at(j));
    }
    stf.at(i) = sf;
  }
  
  
  vector<int> dmaxtyp(D+1);
  for (int i = 1; i <= D; i++) {
    int mmax = 0, tmp = 0;
    for (int j = 1; j <= 26; j++) {
      if (mmax < s.at(i).at(j)) {
        tmp = j;
        mmax = s.at(i).at(j);
      }
    }
    dmaxtyp.at(i) = tmp;
    
  }
  
  //局所探索?
  for (int k = 1; k <= D; k++) {
    int oldsf = sf;
    int oldtyp = t.at(k);
    sf = 0;
    t.at(k) = qq.at(k);
    for (int i = 1; i <= 26; i++) last.at(i) = 0;
    
    for (int i = 1; i <= D; i++) {
      sf += s.at(i).at(t.at(i));
      last.at(t.at(i)) = i;

      for (int j = 1; j <= 26; j++) {
        sf -=c.at(j)*(i-last.at(j));
      }

    }
    if (oldsf > sf) {
      t.at(k) = oldtyp;
      sf = oldsf;
    }
  }
  //cout << sf << endl;
  for (int i = 1; i <= D; i++) cout << t.at(i) << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
int read_int(){int c,r;while((c=getchar())<48);r=c-48;while((c=getchar())>47)r=r*10+c-48;return r;}
void write_int(int x){int b[10],*p=b;do*p++=48+x%10,x/=10;while(x);do putchar(*--p);while(p>b);}

template<class T, T Op(T, T), T E()> struct SegmentTree {
  const int n;
  V<T> t;
  SegmentTree(int _n) : n(_n), t(2 * n, E()) {}
  T& operator[](int i) { return t[n + i]; }
  void build() { for (int i = n - 1; i >= 1; --i) t[i] = Op(t[2 * i], t[2 * i + 1]); }
  T acc(int l, int r) const {
    T a = E(), b = E();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = Op(a, t[l++]);
      if (r & 1) b = Op(t[--r], b);
    }
    return Op(a, b);
  }
  void set(int i, const T& a) {
    t[i += n] = a;
    while (i >>= 1) t[i] = Op(t[2 * i], t[2 * i + 1]);
  }
};
template<class T> T _min(T a, T b) { return b < a ? b : a; }
template<class T> T _max(T a, T b) { return a < b ? b : a; }
// template<class T> T inf() { return 0.49 * numeric_limits<T>::max(); }
int inf() { return ~(~0U << 31); }

int main() {
  int n = read_int(), q = read_int();
  SegmentTree<int, _min, inf> st(n);
  while (q--) {
    if (read_int() == 0) {
      int i = read_int(), x = read_int();
      st.set(i, x);
    } else {
      int l = read_int(), r = read_int() + 1;
      write_int(st.acc(l, r));
      putchar('\n');
    }
  }
}


Measured memory_bytes: 3552
#include <iostream>
using namespace std;
#define LL long long

int main()
{
    int taka_tai, taka_kou, ao_tai, ao_kou;
    cin >> taka_tai >> taka_kou >> ao_tai >> ao_kou;

    while (true) {
        ao_tai -= taka_kou;
        if (ao_tai <= 0) {
            cout << "Yes" << endl;
            break;
        }

        taka_tai -= ao_kou;
        if (taka_tai <= 0) {
            cout << "No" << endl;
            break;
        }

    }

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	ll k;
	cin >> k;

	if(k % 2 == 0 || k % 5 == 0){
		cout << -1 << endl;
		exit(0);
	}

	ll lim = 1e7;
	ll ans = 1;
	ll t = 7;
	while(ans < lim){
		if(t % k == 0){
			cout << ans << endl;
			exit(0);
		}

		t *= 10;
		t += 7;
		t %= k;
		ans++;
	}

	cout << -1 << endl;
}


Measured memory_bytes: 3632
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    set<string> s;
    for(int i = 0; i < n; i++){
        string str;
        cin>>str;
        s.insert(str);
    }
    cout<<s.size();
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

int main() {
	string str;
	bool table[26] = { false };

	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		table[str[i] - 'a'] = true;
	}

	int i = 0;
	while (i < 26) {
		if (table[i] == false) {
			break;
		}
		i++;
	}

	if (i < 26) {
		cout << (char)('a' + i) << endl;
	}
	else {
		cout << "None" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
typedef struct{
    long long price;
    long long number;
} shop;
long long Min(long long x,long long y){
    return x<y?x:y;
}
shop a[100001]={0};
int compare(const void *x,const void *y){
    
    if(((shop *)x)->price<((shop*)y)->price)return -1;
    return 1;
}
int main(){
    int n,m;
    long long ans=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i].price,&a[i].number);
    }
    qsort(a,n,sizeof(shop),compare);
    int i=0;
    while(m>0){
        ans+=(Min(m,a[i].number)*a[i].price);
        m-=a[i].number;
        i++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3324
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n<1200){
      System.out.println("ABC");
    }
    else if(n<2800){
      System.out.println("ARC");
    }
    else{
      System.out.println("AGC");
    }
  }
}

Measured memory_bytes: 21840
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val s = sc.next()
        var ans = 0
        for (i in 1 until n) {
            val front = Array(26) { false }
            for (f in 0 until i) {
                front[s[f] - 'a'] = true
            }
            val back = Array(26) { false }
            for (b in i until n) {
                back[s[b] - 'a'] = true
            }
            var cnt = 0
            for (c in 0 until 26) {
                if (front[c] && back[c]) cnt++
            }
            ans = Math.max(ans, cnt)
        }

        println(ans)
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]
}

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

typedef long long ll;

ll l[200005],r[200005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> l[i] >> r[i];
	}
	sort(l,l+n);
	sort(r,r+n);
	if( n % 2 == 1 )
	{
		cout << abs(r[n/2] - l[n/2]) + 1 << '\n';
	}else
	{
		ll l1 = l[n/2];
		ll l2 = l[n/2-1];
		ll r1 = r[n/2];
		ll r2 = r[n/2-1];
		cout << r1 + r2 - l1 - l2 + 1 << '\n';
	}
	return 0;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (u == s) cout << a-1 << ' ' << b << endl;
    else cout << a << ' ' << b-1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail++;
}

P dequeue(){
  P x;
  x=Q[head];
  head++;
  return x;


}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  tail=n+1;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(head!=tail){
    if(head>LEN) head=0;
    if(tail>LEN) tail=0;
    if(Q[head].t-q>0){
      u=dequeue();
      u.t=u.t-q;
      enqueue(u);
      elaps+=q;
    }else{
      u=dequeue();
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}



Measured memory_bytes: 11840
n = int(input())
s = input()
r = set()
g = set()
b = set()
for i in range(n):
    if s[i] == "R":
        r.add(i)
    if s[i] == "G":
        g.add(i)
    if s[i] == "B":
        b.add(i)
a = len(r) * len(b) * len(g)
for i in r:
    for j in b:
        k = abs(i - j)
        if i + k in g:
            a -= 1
        if i - k in g:
            a -= 1
        if j + k in g:
            a -= 1
        if j - k in g:
            a -= 1
        if (i + j) / 2 in g:
            a -= 1
print(a)

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};

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

    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];
    rep(i, n) numbers[i]--;

    UnionFind uf(n);

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.connect(x, y);
    }

    int ans = 0;
    rep(i, n) {
        int a = numbers[i];
        if (uf.is_union(i, a)) ans++;
    }
    cout << ans << endl;

}





Measured memory_bytes: 1024
import collections

def searchRoot(n):
    par = parList[n]
    if n == par:
        if len(q) > 0:
            rootIn(q,n)
        return n
    else:
        q.append(n)
        return(searchRoot(par))

def rootIn(q,root):
    while len(q) > 0:
        parList[q.popleft()] = root

n,m = list(map(int,input().split()))
q = collections.deque()

parList = [i for i in range(n+1)]

for i in range(m):
    a,b = list(map(int,input().split()))
    aRoot = searchRoot(a)
    bRoot = searchRoot(b)
    if aRoot != bRoot:
        parList[max(aRoot,bRoot)] = min(aRoot,bRoot)
    
#print(parList)

ansDic = dict()
rootSet = set()
for i in range(1,n+1):
    root = searchRoot(i)
    if root in rootSet:
        ansDic[root] += 1
    else:
        rootSet.add(root)
        ansDic[root] = 1

ans = 1
for i in rootSet:
    if ansDic[i] > ans:
        ans = ansDic[i]

print(ans)

Measured memory_bytes: 147220
import java.io.*;
import java.util.*;
class Main{
    public static void main(String args[]) throws IOException{

	double a=0;
	int i=0;
	double j=0;
	double k=0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	String delimiter = " ";
        StringTokenizer stringTokenizer = new StringTokenizer( str, delimiter );
	while(stringTokenizer.hasMoreTokens())
	{
            String current = stringTokenizer.nextToken();
	    if(i==0)a=Double.parseDouble(current);
	    i++;
	}
	j=a*2.0*Math.PI;
	k=a*a*Math.PI;
	System.out.printf("%.6f %.6f\n",k,j);
    }
}

Measured memory_bytes: 16992