akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = list(input())

digit1 =[1,1,1,1,1,1,1,1,1,1]
digit2 =[1,1,1,1,1,1,1,1,1,1]
digit3 =[1,1,1,1,1,1,1,1,1,1]

array_code = []

for i in range(len(S)):
    if 1 in digit1:
        if digit1[int(S[i])]==1:
            for j in range(i+1,len(S)):
                if 1 in digit2:
                    if digit2[int(S[j])]==1:
                        for k in range(j+1,len(S)):
                            #print(S[i]+S[j]+S[k])
                            if 1 in digit3:
                                if digit3[int(S[k])] ==1:
                                    array_code.append(S[i]+S[j]+S[k])
                                    digit3[int(S[k])] = 0
                            else:
                                for l in range(10):
                                    digit3[l]=1
                                break
                        digit2[int(S[j])]=0
                else:
                    for l in range(10):
                        digit2[l]=1
                    break
                for l in range(10):
                    digit3[l] = 1
            digit1[int(S[i])]=0
    else:
        break
    for l in range(10):
        digit2[l] = 1

#print(array_code)
print(len(array_code))

Measured memory_bytes: 3444
a =input()
b = input()
ans =''
for i in range(len(a)):
    ans +=a[len(a)-1]
    for j in range(len(a)-1):
        ans+=a[j]
    if ans ==b:
        print('Yes')
        break
    elif (i+1) ==len(a):
        print('No')
    a=ans
    ans =''

Measured memory_bytes: 3060
n = gets.to_i
f = -> (a, b) { a.to_s.length < b.to_s.length ? b.to_s.length : a.to_s.length }
min_f = Float::INFINITY

1.upto(Math.sqrt(n).ceil) do |i|
  if n % i == 0
    larger_digit = f.call(i, n / i)
    min_f = larger_digit if larger_digit < min_f
  end
end

puts min_f

Measured memory_bytes: 1788
from collections import deque
def main():
  N,M,*A=map(int, open(0).read().split())
  mod=10**9+7
  dp = [0] * (N+1)
  A=deque(A+[N+1])
  tmp=A.popleft()
  dp[:2] = [1, 1 if tmp!=1 else 0]
  if tmp==1:
    tmp=A.popleft()
  for i in range(2, N+1):
    if i==tmp:
      tmp=A.popleft()
      continue
    dp[i] = (dp[i-2] + dp[i-1])%mod
  print(dp[N])
main()


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

int main() {

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
  	string col;
  	cin >> col;
  	if(col == "Y")
  	{
  		cout << "Four" << endl;
  		break;
  	}
  	else if(i == N-1)
     { cout << "Three" << endl;}
    col = "";
  }

}

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

typedef long long LL;

const int N = 200003;
int n, c[N];
vector<int> graph[N];

int clk, d[N], proc[N];

LL dp[N];

void dfs(int cur, int par = 0) {
    int col = c[cur];
    d[cur] = 1;
    for(int child : graph[cur]) {
        if(child == par) continue;

        LL before = proc[col];
        dfs(child, cur);
        d[cur] += d[child];
        LL after = proc[col];
        LL comp = d[child] - (after-before);
        cerr << col << ' ' << comp << endl;
        
        dp[col] += comp*(comp-1)/2 + comp;
        proc[col] += comp;
    }
    proc[col]++;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> c[i];
    }
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(1);

    LL tot = (LL)n*(n-1)/2 + n;
    for(int i = 1; i <= n; ++i) {
        LL rem = n - proc[i];
        dp[i] += rem*(rem-1)/2 + rem;
        LL ans = tot - dp[i];
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 44392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[n];
		int sotoku = 0;
		int pop = 0;
		int comp = 0;


		for (int i = 0; i < n; i ++){
			p[i] = sc.nextInt();
			sotoku = sotoku + p[i];
		}

		if (sotoku % (4 * m) == 0){
			comp = sotoku / (4 * m);
		} else {
			comp = sotoku / (4 * m) + 1;
		}

		for (int point : p){
			if (point >= comp){
				pop ++;
			}
		}

		if (pop >= m){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int N=0,C=0,cake=0,p=0,ans=0;
int main(void){
	cin>>N>>C;
	for(int i=0;i<C;i++){
		cin>>p;
		cake+=p;
	}
	if(cake%(N+1)){
		cout<<cake/(N+1)+1<<endl;
	}
	else{
		cout<<cake/(N+1)<<endl;
	}
	return 0;
	
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if((a==7&&b==5&&c==5)||(a==5&&b==7&&c==5)||(a==5&&b==5&&c==7)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    map<int,int> a, b;
    rep(i,n) {
        int v;
        cin >> v;
        if (i%2) a[v]++;
        else b[v]++;
    }
    priority_queue<P> ap, bp;
    for (auto p : a) {
        ap.emplace(p.second, p.first);
    }
    for (auto p : b) {
        bp.emplace(p.second, p.first);
    }
    vector<P> x, y;
    int cnt = 2;
    while (!ap.empty() && cnt > 0) {
        auto p = ap.top();
        ap.pop();
        x.push_back(p);
        cnt--;
    }
    cnt = 2;
    while (!bp.empty() && cnt > 0) {
        auto p = bp.top();
        bp.pop();
        y.push_back(p);
        cnt--;
    }
    int ans = INF;
    rep(i,x.size())rep(j,y.size()) {
        int now = 0;
        if (x[i].second == y[j].second) {
            now = n/2 + n/2 - max(x[i].first, y[j].first);
        }
        else {
            now = n - x[i].first - y[j].first;
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8856
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[3];
    int step;
    while(cin>>a[0]>>a[1]>>a[2])
    {
        step=0;
        while(a[0]!=a[1]||a[1]!=a[2])
        {
            sort(a,a+3);
            if(a[0]==a[1])
            {
                a[0]+=1;
                a[1]+=1;
                step++;
            }
            else if(a[1]==a[2])
            {
                a[0]+=2;
                step++;
            }
            else
                {
                    a[0]+=2;
                    step++;
                }
        }
        cout<<step<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005];
int b[50010];
int main()
{
	int n;
	int num=0,sum=0;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i%2==1) b[++sum]=a[i];
	}
	sort(b+1,b+sum+1);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[num+1])
		{
			num++;
			if(i%2!=1)
				ans++;
			if(num==sum)
				break;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

const int kMaxN = 2000;
const int kMaxK = 10000;

void countingSort(int *a, int *b, int *c, int n) {
    for (int i = 0; i < kMaxK; i++)
    {
        c[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        c[a[i]]++;
    }
        
    for (int i = 1; i < kMaxK; i++) {
        c[i] = c[i] + c[i - 1];
    }

    for (int i = n - 1; i >= 0; i--) {
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }
}

int main() {
    int n;

    cin >> n;

    int *A = new int[n];
    int *B = new int[n];
    int C[kMaxK];


    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    countingSort(A, B, C, n);

    for (int i = 1; i <= n; i++) {
        if (i != n) {
            cout << B[i] << " ";
        }
        else {
            cout << B[i];
        }
    }

    cout << endl;
}

Measured memory_bytes: 18748
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    int s = 0;
    
    for (int i = 0; i < 2; i++) {
    	if (a > b) {
    		s += a--;
    	} else {
    		s += b--;
    	}
    }
    
    System.out.print(s);
    
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		String atcoder = scanner.next();
		String s = scanner.next();
		String contest = scanner.next();
		
		String a = atcoder.substring(0,1);
		String x = s.substring(0,1);
		String c = contest.substring(0,1);
		System.out.println(a + x + c);
	}
} 

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string N;
	cin >> N;
	int ans = N[0] - '0' + 9 * (N.size() - 1);
	if (count(N.begin() + 1, N.end(), '9') != N.size() - 1) {
		--ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  map<int,int> mp;
  rep(i,n) mp[a[i]+(i+1)]++;
  ll ans = 0;
  rep(i,n) ans += mp[(i+1)-a[i]];
  cout << ans;
  cout << "\n";
  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long int A,B;
	cin>>A>>B;
	if(A==B)	return cout<<1<<endl, 0;
	int d;
	for(d=59;d>=0;d--)
		if(((A>>d)&1)!=((B>>d)&1))
			break;
	long long int base = 1LL<<d;
	long long int mask = base | (base-1);
	A&=mask,B&=mask;
	long long int ans = 0;
	ans += base - A;
	long long int LB = base+A, RB = base;
	int idx;
	for(idx=0;idx<d;idx++)
		if(((1LL<<idx)|base)<=B)
			RB|=1LL<<idx;
	if(RB<LB)
		ans+=RB + 1 + base - LB ;
	else
		ans+=base;
	cout<<ans<<endl;
}


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

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

int main()
{
    int h, w, check = 0, count = 0;
    cin >> h >> w;
    string board[h];
    for (int i = 0; i < h; i++)
    {
        cin >> board[i];
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (board[i][j] == '#')
            {
                count++;
                for (int v = 0; v < 4; v++)
                {
                    const int ny = i + dy[v];
                    const int nx = j + dx[v];
                    if (ny < 0 || nx < 0 || h <= ny || w <= nx)
                        continue;
                    if (board[ny][nx] == '#')
                    {
                        check++;
                        break;
                    }
                }
            }
        }
    }

    if (count == check)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int h;
	while(cin>>h&&h){
		int board[5][h];
		rep(i,5*h) cin>>board[i%5][h-1-i/5];
		int ans=0;
		while(1){
			bool stop=1;
			for(int high=0;high<h;high++){
				int tmp=board[0][high],cnt=1;
				for(int wide=1;wide<5;wide++){
					if(board[wide][high]==tmp){
						cnt++;
						if(wide==4&&cnt>=3&&tmp!=0){
							//cout<<tmp<<" "<<cnt<<endl;
							ans+=tmp*cnt;
							cnt--;
							while(cnt>=0){
								board[wide-cnt][high]=0;
								cnt--;
							}
							stop=0;
						}
					}else{
						if(cnt>=3&&tmp!=0){
							//cout<<tmp<<" "<<cnt<<endl;
							ans+=tmp*cnt;
							while(cnt>0){
								board[wide-cnt][high]=0;
								cnt--;
							}
							stop=0;
						}else{
							tmp=board[wide][high]; cnt=1;
						}
					}
				}
			}
			if(stop) break;
			rep(i,5){
				for(int high=0;high<h-1;high++){
					for(int y=0;y<h-1;y++){
						if(board[i][y]==0){
						 	swap(board[i][y],board[i][y+1]);
						}
					}
				}
			}
			// rep(i,h){
			// 	rep(j,5){
			// 		cout<<board[j][i]<<" ";
			// 	}
			// 	cout<<endl;
			// }
		}
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>

typedef struct List {
	struct List *next;
	int x, y, dist;
} list;

int main()
{
	int i, H, W;
	char A[1002][1002];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(A[i][1]));
	for (i = 0; i <= H + 1; i++) {
		A[i][0] = '.';
		A[i][W+1] = '.';
	}
	for (i = 1; i <= W; i++) {
		A[0][i] = '.';
		A[H+1][i] = '.';
	}
	
	int j;
	list *head = NULL, *tail = NULL, data[1002][1002];
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			data[i][j].x = i;
			data[i][j].y = j;
			data[i][j].next = NULL;
			if (A[i][j] == '.') data[i][j].dist = 10000;
			else {
				data[i][j].dist = 0;
				if (head == NULL) head = &(data[i][j]);
				if (tail != NULL) tail->next = &(data[i][j]);
				tail = &(data[i][j]);
			}
		}
	}
	
	for (; head != NULL; head = head->next) {
		if (head->x > 0 && data[head->x - 1][head->y].dist == 10000) {
			data[head->x - 1][head->y].dist = head->dist + 1;
			tail->next = &(data[head->x - 1][head->y]);
			tail = tail->next;
		}
		if (head->x < H && data[head->x + 1][head->y].dist == 10000) {
			data[head->x + 1][head->y].dist = head->dist + 1;
			tail->next = &(data[head->x + 1][head->y]);
			tail = tail->next;
		}
		if (head->y > 0 && data[head->x][head->y - 1].dist == 10000) {
			data[head->x][head->y - 1].dist = head->dist + 1;
			tail->next = &(data[head->x][head->y - 1]);
			tail = tail->next;
		}
		if (head->y < W && data[head->x][head->y + 1].dist == 10000) {
			data[head->x][head->y + 1].dist = head->dist + 1;
			tail->next = &(data[head->x][head->y + 1]);
			tail = tail->next;
		}
	}
	
	int max = 0;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) if (data[i][j].dist > max) max = data[i][j].dist;
	}
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 24704
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

long long dp[50][50][2501];

int N;
vector<long long> vlist;

long long process(int max_n, int curr_n, int start_n, int max_v, int curr_v)
{
	if (curr_n >= max_n)
	{
		if (curr_v == max_v) return 1;
		return 0;
	}
	else if (start_n >= N) return 0;

	long long& ret = dp[curr_n][start_n][curr_v];
	if (ret != -1) return ret;

	ret = 0;
	for (int i = start_n; i < N; i++)
	{
		if (curr_v + vlist[i] <= max_v) ret += process(max_n, curr_n + 1, i + 1, max_v, curr_v + vlist[i]);
	}

	return ret;
}

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

	int A;
	cin >> N >> A;

	vlist.assign(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> vlist[i];
	}

	long long result = 0;
	for (int i = 1; i <= N; i++)
	{
		fill_n(&dp[0][0][0], sizeof(dp) / sizeof(long long), -1);
		result += process(i, 0, 0, i * A, 0);
	}

	cout << result;
	
	return 0;
}

Measured memory_bytes: 49152
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int c[4], n;
    for (auto& x : c) cin >> x; cin >> n;

    vector<pair<int, int>> p;
    for (int i = 0; i < 4; i++) p.push_back(make_pair((1 << (3 - i)) * c[i], c[i]));

    long long ans = 0;
    if (n % 2) ans += min(min(p[0].first, p[1].first), p[2].first) / 2;

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

    while (n >= 2) {
        ans += p[0].first;
        n -= 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[][] map = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().ToArray()).ToArray();
        //[x][y][深さ]
        bool[][][] isSame = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(0, n).Select(__ => new bool[n]).ToArray()).ToArray();
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int k = 0; k < n; k++)
                {
                    isSame[i][j][k] = map[i][j] == map[(i + k) % n][(n + j - k) % n];
                }
            }
        }
        bool[][] isAllSame = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(true, n).ToArray()).ToArray();
        //スタート
        for (int i = 0; i < n; i++)
        {
            //串のインデックス
            for (int j = 0; j < n; j++)
            {
                //ズラす
                for (int k = 0; k < n; k++)
                {
                    if (!isSame[(i + k) % n][k][j])
                    {
                        isAllSame[i][j] = false;
                        break;
                    }
                }
            }
        }
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (!isAllSame[(i + j) % n][n - (j + 1)]) goto end;
            }
            count++;
            end:;
        }
        Console.WriteLine(count * n);
    }
}

Measured memory_bytes: 54976
import math
N,K = map(int,input().split())

sum_pro = 0 
for i in range(N):
  i_ = i+1
  if(i_ < K):
   p_i = math.ceil(math.log2(K/i_))
   sum_pro += (1/(2**p_i))*(1/N)
  else:
   sum_pro += 1/N
                
print(sum_pro)

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

#define cn count;
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	ll x,a;
	cin>>x>>a;
	(x<a)?cout<<"0\n":cout<<"10\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

int N,M,flag=0;

int main(){
    cin>>N>>M;
    N++;
    int a[M],b[M],onetoany[N],togoal[N];
    rep(i,N){
        onetoany[i]=0;
        togoal[i]=0;
    }
    rep(i,M){
        cin>>a[i]>>b[i];
        if(a[i]==1){
            onetoany[b[i]]=1;
        }
        if(b[i]==N-1){
            togoal[a[i]]=1;
        }
    }
    rep(i,N){
        if(onetoany[i]==1){
            if(togoal[i]==1){
                flag=1;
                break;
            }
        }
    }
    if(flag){
        out("POSSIBLE");
    }
    else{
        out("IMPOSSIBLE");
    }
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
#define ll long long
using namespace std;
int n;
double sum;
int main()
{
	//fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		double x;
		cin>>x;
		sum+=(double)(1/x);
	}
	printf("%.10f\n",1/sum);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int MAX=0;
    int p,q;
    scanf("%d",&p);
    bool check = true;
    for(int i=1;i<N;i++){
        scanf("%d",&q);
        if(q>MAX)
            MAX = q;        
        if(MAX-q>1){
            check = false;
            break;
        }
    }
    
    if(check){
        printf("Yes");
    } else
        printf("No");
}

Measured memory_bytes: 128
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define INF 1e10+7
using namespace std;
typedef double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>ii;
const int MAXN=200011;
int cases;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c-b>a)
        cout<<"dangerous"<<endl;
    else if(c<=b)
        cout<<"delicious"<<endl;
    else
        cout<<"safe"<<endl;

    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int N;
vector<long long> A;
/*
bool solve(int m){
    for(int i = m; i < N; i++){
        if(A[i] % 2 == 1)return 0;
        else {
            for(int j = i; j < N; j++){
                A[j] -= A[i];
                if(A[j] == 0)m=j+1;
            }
            return solve(m);
        }
    }
    return 1;

}*/

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    cin >> N;
    A = vector<long long>(N);
    rep(i, N)cin >> A[i];
    rep(i, N){
        if(A[i]%2 == 1){
            cout << "first" << "\n";
            return 0;
        }
    }
    cout << "second" << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

/*

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;cin>>n;
    if((n%1000) == 0)cout<<"0\n";
    else
         cout<< 1000 - (n%1000)<<"\n";
    return 0;
}
*/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;cin>>n;
    std::map<std::string, int> mp;
    string s;
    for (int i = 0; i < n; ++i)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC"<<" x "<<mp["AC"]<<"\n";
    cout<<"WA"<<" x "<<mp["WA"]<<"\n";
    cout<<"TLE"<<" x "<<mp["TLE"]<<"\n";
    cout<<"RE"<<" x "<<mp["RE"]<<"\n";
    return 0;
}



Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >>y2;
  int s1,s2;
  if((s1 = x1*y1 )>(s2=x2*y2)){
    cout << s1 <<endl;
  }else{
    cout << s2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] arr = new int[n][2];

      long sumA = 0;
      for(int i = 0; i < n; i++) {
        arr[i][0] = sc.nextInt();
        sumA += arr[i][0];
      }

      long sumB = 0;
      for(int i = 0; i < n; i++) {
        arr[i][1] = sc.nextInt();
        sumB += arr[i][1];
      }

      if(sumA < sumB) {
        System.out.println(-1);
        return;
      }

      Arrays.sort(arr, (a1, a2) -> (a1[0] - a1[1]) - (a2[0] - a2[1]));
      int cnt = 0;
      long diffSum = 0;
      for(int i = 0; i < n; i++) {
        if(arr[i][0] >= arr[i][1]) break;
        cnt++;
        diffSum += arr[i][1] - arr[i][0];
      }
    
      for(int i = n - 1; i >= 0 && diffSum > 0; i--) {
        diffSum -= (arr[i][0] - arr[i][1]);
        cnt++;
      }
      System.out.println(cnt);
  }
}


Measured memory_bytes: 92640
import math
import copy
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(str, input().split())
inputlist = list(n)

ansZero = 0
ansOne = 0

flg = False
for i in range(len(n)):
    if flg:
        if inputlist[i]=="0":
            ansZero+=1
    else:
        if inputlist[i]=="1":
            ansZero+=1
    flg = not flg

flg = True
for i in range(len(n)):
    if flg:
        if inputlist[i]=="0":
            ansOne+=1
    else:
        if inputlist[i]=="1":
            ansOne+=1
    flg = not flg

ans = min(ansZero, ansOne)

print(ans)

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

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

    for ( int i = 105; i <= N; i += 2 ) {
        int cnt = 0;
        for ( int j = 1; j <= i; j++ ) {
            if ( i % j == 0 ) {
                cnt++;
            }
        }
        if ( cnt == 8 ) {
            ans++;
        }
    }

    cout << ans << endl;
    return ( 0 );
}


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

using namespace std;

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int

string a, b, c = "", d;

void init()
{
	cin >> a >> b;
	int la = a.size();
	int lb = b.size();
	int sub = la + lb;
	//cout << a[0] << b[0];
	for (int i = 0; i < lb; ++i)
	{
		cout << a[i] << b[i];
	}
	if(la > lb) {
		cout << a[la - 1];
	}

}

int main()
{

	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("ouTtput.txt","w",stdout);
	#endif

	init();

	return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, n);
  vector<int> v(n);
  rep(i, n) {
    IN(v[i]);
  }

  sort(all(v));

  double norm;
  rep(i, n-1) {
    if (!i) {
      norm = ((double)v[i] + (double)v[i+1]) / 2.0;
    }
    else {
      norm = (norm + (double)v[i+1]) / 2.0;
    }
  }

  Float(12);
  OUTL(norm);
  return 0;
}


Measured memory_bytes: 256
from sys import exit, stdin
N = int(stdin.readline().rstrip())
V = sorted(int(_) for _ in stdin.readline().rstrip().split())
ans = 0
for i in range(1, N):
    if i == 1:
        ans = (V[i] + V[i-1]) / 2
    else:
        ans = (ans + V[i]) / 2
print(ans)

Measured memory_bytes: 3060
n,a,b,c = map(int,input().split())

s = []

for i in range(n):
    tmp_s = input()
    s.append(tmp_s)

ans = []

for i,val in enumerate(s):
    if val == 'AB':
        if a == b == 0:
            print('No')
            exit(0)
        elif a < b or (a == b and i != n-1 and 'A' in s[i+1]):
            ans.append('A')
            a += 1
            b -= 1
        else:
            ans.append('B')
            a -= 1
            b += 1

    elif val == 'BC':
        if b == c == 0:
            print('No')
            exit(0)
        elif b < c or (b == c and i != n-1 and 'B' in s[i+1]):
            ans.append('B')
            b += 1
            c -= 1
        else:
            ans.append('C')
            b -= 1
            c += 1
    else:
        if c == a == 0:
            print('No')
            exit(0)
        elif c < a or (c == a and i != n-1 and 'C' in s[i+1]):
            ans.append('C')
            c += 1
            a -= 1
        else:
            ans.append('A')
            c -= 1
            a += 1
        
        

print('Yes')
print(*ans,sep='\n')

Measured memory_bytes: 18556
import math
while True:
    try:
        x=float(input())
        h=float(input())
        if x==0 and h ==0:
            break
        y=h**2+(x/2)**2
        y=math.sqrt(y)
        S=x**2+4*x*y/2
        print "{0:.6f}".format(S)
    except:
        break

Measured memory_bytes: 4388
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }

  def mycomb[T](n: Int, l: List[T]): List[List[T]] =
    n match {
      case 0 => List(List())
      case _ => for(el <- l;
                sl <- mycomb(n-1, l dropWhile { _ != el } ))
                yield el :: sl
  }
  
  def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)
}

object Main extends App {
  import Helpers._

  val Array(s, w) = readIntLine

  println(if (s <= w) "unsafe" else "safe")
}



Measured memory_bytes: 54728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

int main(){
	ll h, w; cin >> h >> w;
	vector<string> a(h); rep(i, h) cin >> a[i];
	rep(i, h){
		if (i == 0){
			rep(j, w + 2) cout << "#";
			cout << endl;
		}
		cout << "#" << a[i] << "#";
		cout << endl;
		if (i == h - 1) rep(j, w + 2) cout << "#";
	}cout << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        d: i32,
        t: i32,
        s: i32,
    }
    let ans = if d <= t * s {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main() {
  int N, D;
  cin >> N >> D;
  int hito = D + 1;
  int ans = 1;
  while(hito <= N) {
    if(hito + D >= N) {
      break;
    }
    ans++;
    hito += D + D + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    
    if((a%3 == 0)||(b%3 == 0)||((a+b)%3 == 0))
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }

}

Measured memory_bytes: 1676
N = int(input())
minmum = 10**5
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N):
    j = N - i
    min_sum = digitSum(i) + digitSum(j)
    if min_sum < minmum:
        minmum = min_sum

print(minmum)

Measured memory_bytes: 3060
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var NA = Console.ReadLine().SplittedStringToInt32List();
        var N = NA[0];
        var A = NA[1];
        var xn = Console.ReadLine().SplittedStringToInt32List();
        var dp = new long[N + 1,N * 50 + 10, N + 10]; //dp:=i番目まで選んだときの総和がjになるk枚選んだときの通り
        dp[0, 0, 0] = 1;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N * 50 + 10; j++)
            {
                for (int k = 0; k <= N + 5; k++)
                {
                    if (j - xn[i] >= 0 && k - 1>=0)
                        dp[i + 1, j,k] = dp[i, j,k] + dp[i, j - xn[i],k - 1];
                    else
                        dp[i + 1, j,k] = dp[i, j,k];
                }
                
            }
        }
        BigInteger count = 0;
        for (int i = 0; i < N * 50 + 10; i++)
        {
            for (int j = 1; j <= N + 7; j++)
            {
                var num = dp[N, i, j];
                if (i % j == 0 && i / j == A)
                    count += num;
            }
        }
        Console.WriteLine(count);

        Console.ReadLine();
        
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



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

int main(void)
{
	double x, y;
	double meter;
	double angle, radian, temp;
	
	angle = x = y = 0;
	
	while (1){
		scanf("%lf%*c%lf", &meter, &temp);
		
		if (meter == 0 & temp == 0){
			printf("%d\n%d\n", (int)x, (int)y);
			break;
		}
		
		x += meter * sin(angle * M_PI / 180);
		y += meter * cos(angle * M_PI / 180);
		angle += temp;
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
	int i,N,ans=0,nn;
	scanf("%d",&N);
	nn=N;

	for(i=0;i<10;i++){
		ans+=nn%10;
		nn/=10;
	}

	if(N%ans==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
word={}
for i in range(n):
    new=input()
    if new in word:
        word[new]+=1
    else:
        word[new]=1
m=int(input())
for i in range(m):
    new=input()
    if new in word:
        word[new]-=1
    else:
        word[new]=-1
        
print(max(0,max(word.values())))

Measured memory_bytes: 3060
#include<cstdio>
const int N=2E5+10;
int n,h;
int a[N],p[N];
inline int gw(int x,int mod){
//	printf("%d %d\n",x,mod);
	if(!x) return 0;
	if(p[x]>=mod){
		p[x]-=mod;
		p[x-1]++;
		return gw(x-1,mod);
	}
	return 1;
}
inline int ck(int x){
	int now=0;
	for(int i=1;i<=n;i++) p[i]=0;
	for(int i=1;i<=n;i++){
		if(a[i]>n){
			now=a[i];
			continue;
		}
		if(a[i]>now){
			for(int i=1+now;i<=a[i];i++) p[i]=0;
			now=a[i];
		}else{
			p[now=a[i]]++;
			if(!gw(now,x)) return 0;
		}
	}
	return 1;
}
int main(){
//	freopen("C.in","r",stdin);
//	freopen("bl.out","w",stdout);
//	printf("1");return 0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	h=2;
	for(int i=3;i<=n;i++){
		if(a[i]>a[h]&&a[h]>a[h-1]) a[h]=a[i];
		else a[++h]=a[i];
	}
	n=h;if(n==2&&a[n]>a[n-1]){printf("1");return 0;}
	int l=2,r=n,res=1;
	while(l<=r){
		int mid=l+r>>1;
		if(ck(mid)){
			res=mid;
			r=mid-1;
		}else l=mid+1;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1664
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 3000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000 * 1ll * 10000000 * 1ll * 1000;
const ld pi = acosl(-1.0);

int k;
bool hap[N];

void input() {
    cin >> k;
}

void solve(int testId) {
    int cur = 7 % k;
    for (int i = 1; ; i++) {
        if (hap[cur] == true) {
            break;
        }
        if (cur == 0) {
            cout << i << endl;
            return;
        }
        hap[cur] = true;
        cur = (cur * 10 + 7) % k;
    }
    cout << -1 << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


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

int n,q;
int A[100000];

void update(int i, int x) {
	A[i] = x;
}
void find(int s, int t) {
	int min;
	if(s>t){
	    swap(s,t);
	}
	if(s==t){
	    cout<<A[s]<<endl;
	    return;
	}
	min = A[s];
	for (int i = s;i < t + 1;i++) {
		if (min > A[i]) {
			min=A[i];
		}
		
	}
	cout << min << endl;
}
int main() {
	cin >> n >> q;
	int com, x, y;
	for (int i = 0;i < n;i++) {
		A[i] = (2147483647);
	}
	for (int i = 0;i < q;i++) {
		cin >> com >> x >> y;
		if (com == 0) {
			update(x, y);
		}
		else {
			find(x, y);
		}
	}
	return 0;
}



Measured memory_bytes: 3480
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}

// vi adj[1000000];


void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-1,flag=0,count=0;
    string S,T,U;
    // int a,b;
    cin>>n;
    vi a(n+1),b(n+1);
    set<int> A,B;
    map<int,int> aa,bb;
    rep(i,1,n+1) 
    {
        cin>>t;
        a[i]=i-t;
        A.insert(a[i]);
        aa[a[i]]++;
        b[i]=i+t;
        B.insert(b[i]);
        bb[b[i]]++;
    }
    for(auto x:A)
    {
        count+=bb[x]*aa[x];
    }
    cout<<count;

}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 57984
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;cin>>n>>m;
  int res=0;
  vector<vector<int>>edge(n,vector<int>(n));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    edge[a][b]=1;
    edge[b][a]=1;
  }
  function<void(int,int)> dfs=[&](int now,int f){
    if(f==(1<<n)-1){
      res++;
      return ;
    }
    bitset<10>tf=f;
    rep(i,n){
      if(tf[i])continue;
      if(!edge[now][i])continue;
      dfs(i,f+(1<<i));
    }
  };
  dfs(0,1);
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256