akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

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

const ll mod = 1e9 + 7;


int main(){
    string S;
    cin >> S;
    int i = 0;
    int j = S.size() - 1;
    while (S[i]!='A'){
        i++;
    }
    while (S[j]!='Z'){
        j--;
    }
    cout << j - i + 1 << endl;
}


Measured memory_bytes: 640
import Data.Array.IArray
import Data.List (sort)
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

lowerBound:: (Integral i, Ix i, Ord e, IArray a e) =>
                e -> a i e -> i
lowerBound x a =
    let (b,e) = bounds a in bsearch b (e + 1)
  where
    bsearch b e
      | e == b    = b
      | x <= a!p  = bsearch b p
      | otherwise = bsearch (p + 1) e
      where p = (b + e) `div` 2

upperBound:: (Integral i, Ix i, Ord e, IArray a e) =>
                e -> a i e -> i
upperBound x a =
    let (b,e) = bounds a in bsearch b (e + 1)
  where
    bsearch b e
      | e == b    = b
      | x < a!p   = bsearch b p
      | otherwise = bsearch (p + 1) e
      where p = (b + e) `div` 2

main :: IO ()
main = do
    n <- readLn :: IO Int
    [a,b,c] <- map (map (fst . fromJust . BS.readInt) . BS.words) . BS.lines <$> BS.getContents
    let a' = listArray (0,n-1) (sort a) :: Array Int Int
    let c' = listArray (0,n-1) (sort c) :: Array Int Int
    print $ sum [ lowerBound i a' * (n - upperBound i c')
                | i <- b ]


Measured memory_bytes: 31100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(10010);
  for(int i=1;i<=N;i++){cin >> a[i];}
  int count=0;
  for(int i=1;i<=N;i++){
      while(a[i]%2==0){count++; a[i]=a[i]/2;}
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,x,k;
    scanf("%d%d",&a,&b);
    x=(a+b);


    if(x%2==0)
    {
        k=x/2;
        printf("%d\n",k);
    }
    else
        {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}



Measured memory_bytes: 1692
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int maxn = 6e5 + 111;
     
using namespace std;

int n, a[maxn], dp[maxn], t, q;

void solve(){    
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	dp[2] = abs(a[2] - a[1]);

	for (int i = 3; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));

	cout << dp[n];
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int a[200000];
int main(void)
{
	int n,b,i;
	ll res;
	scanf("%d",&n);
	FOR(i,0,n){
		scanf("%d",&a[i]);
		a[i]-=(i+1);
	}
	qsort(a,n,sizeof(int),comp);
	//FOR(i,0,n) printf("%d\n",a[i]);
	b=a[n/2];
	res=0;
	FOR(i,0,n){
		res+=llabs(a[i]-b);
	}
	printf("%lld\n",res);
	return 0;
}
    
    
    

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main() {
    int a,b;
    string op;
    while (true) {
        cin >> a >> op >> b;
        if (op == "?") {
            break;
        }else if(op == "/"){
            cout << a/b << endl;
        }else if(op == "*"){
            cout << a*b << endl;
        }else if(op == "+"){
            cout << a+b << endl;
        }else if(op == "-"){
            cout << a-b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3144
N = int(input())
if N < 4:
  print("No")
elif N % 4 == 0 or N % 7 == 0 or N % 11 == 0:
  print("Yes")
else:
  ans = "No"
  for _ in range(N // 4):
    if N % 7 == 0:
      ans = "Yes"
      break
    else:
      N -= 4

  print(ans)

Measured memory_bytes: 3060
#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 a, b;
    string op;
    while (1) {
        cin >> a >> op >> b;
        if (op == "?") {
            break;
        }
        else if (op == "+") {
            cout << a + b << endl;
        }
        else if (op == "-") {
            cout << a - b << endl;
        }
        else if (op == "*") {
            cout << a * b << endl;
        }
        else if (op == "/") {
            cout << a / b << endl;
        }
        else {
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 3160
toInt :: String -> Int
toInt = read :: String -> Int

sumDigits :: Int -> Int
sumDigits n
  | n == 0 = 0
  | otherwise = (mod n 10) + sumDigits (div n 10)

isHarshadNumber :: Int -> String
isHarshadNumber n
  | mod n (sumDigits n) == 0 = "Yes"
  | otherwise = "No" 

main = do
  n <- toInt <$> getLine
  putStrLn $ isHarshadNumber n


Measured memory_bytes: 508
#include <iostream>
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;

int n;
void make_group(vector<int> &group, vector< vector<int> > &g) {
  bool visited[n];
  for(int i=0;i<n;i++) visited[i] = false;
  queue<int> que;
  int count = 1;
  for(int s=0;s<n;s++) {
    if(!visited[s]) {
      visited[s] = true;
      que.push(s);
      while(!que.empty()) {
        int v = que.front(); que.pop();
        group[v] = count;
        for(int i=0;i<g[v].size();i++) {
          if(!visited[g[v][i]]) {
            visited[g[v][i]] = true;
            que.push(g[v][i]);
          }
        }
      }
    }
    count++;
  }
}

int main() {
  int m,s,t,q;
  scanf("%d %d\n",&n,&m);
  vector< vector<int> > g(n);
  vector<int> group(n,0);
  for(int i=0;i<m;i++) {
    scanf("%d %d",&s,&t);
    g[s].push_back(t);
    g[t].push_back(s);
  }

  make_group(group,g);
  // cout << group << endl;
  /*
  for(int i=0;i<n;i++) {
    printf("%d:%d\n",i,group[i]);
  }
  */

  scanf("%d",&q);
  for(int i=0;i<q;i++) {
    scanf("%d %d",&s,&t);
    if(group[s] == group[t]){
      printf("yes\n");
    }
    else {
      printf("no\n");
    }
  }
}

Measured memory_bytes: 6956
n = gets.to_s.to_i

g = Array.new(n){ [] }
(n-1).times do |i|
  a, b = gets.to_s.split.map{|t| t.to_i - 1 }
  g[a] << [b, i]
  g[b] << [a, i]
end

q = [[0, -1, -1]]

ans = Array.new(n-1)
while q[0]
  v, parent, parent_color = q.shift
  color = 0
  g[v].each do |(u, i)|
    next if u == parent
    # p [v, color] if i == 0
    color += 1
    color += 1 if color == parent_color
    # p [v, color] if i == 0
    ans[i] = color
    q << [u, v, color]
  end
end
# puts "ans"
puts ans.max, ans

Measured memory_bytes: 28284
main = do
    line<-getLine
    let n = head [read x::Int| x<- words line]
    let k = last [read x::Int| x<- words line]
    print $ length $num2kdig n k

num2kdig :: Int -> Int ->[Int]
num2kdig 0 k = []
num2kdig n k = (mod n k) : num2kdig (div n k) k


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

#define mx 10000005
#define ll long long 

int m,n,k,ii,dek;
ll xx[]={0,1,0,-1};
ll yy[]={1,0,-1,0};

void solve()
{
	scanf("%d%d%d",&n,&m,&k);
	ll dis[n+8][m+8];
	char ch[n+8][m+8];
	int x1,x2,y1,y2;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	x1--;
	x2--;
	y1--;
	y2--;
	for(int i=0;i<n;i++)
	{
          for(int j=0;j<m;j++)scanf(" %c",&ch[i][j]);
	}
	for(int i=0;i<=n+5;i++)
	{
		for(int j=0;j<=m+5;j++)dis[i][j]=mx;
	}
	queue<pair<int,int>>q;
	q.push({x1,y1});
	dis[x1][y1]=0;
	while(!q.empty())
	{
         int x=q.front().first;
         int y=q.front().second;
         q.pop();
         for(int i=0;i<4;i++)
         {
              for(int j=1;j<=k;j++)
              {
              	ll temx=x+xx[i]*j;
              	ll temy=y+yy[i]*j;
              	if(temy<0 || temy>=m || temx<0 || temx>=n || ch[temx][temy]=='@' || dis[temx][temy]<dis[x][y]+1)break;
                
                if(dis[temx][temy]>dis[x][y]+1)
                	{
                		dis[temx][temy]=dis[x][y]+1;
                q.push({temx,temy});
            }
              }
         }
	}
	if(dis[x2][y2]==mx)dis[x2][y2]=-1;
	
	printf("%lld\n",dis[x2][y2] );

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int t=1;
	//scanf("%d",&t);
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
    std::string s;
    int n, k;
  	std::cin >> n >> s >> k;
    const char& c = s[k - 1];
  	for (int i = 0; i < n; ++i) {
    	std::cout << ((s[i] != c) ? '*' : s[i]);
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int arr[100005];
int n;
int main()
{
    cin >> n;
    int x;
    int cnt=0;
    int ans=0;
    for (int i=0;i<n;i++)
    {
        cin >> x;
        if (!arr[x])
        {cnt++;
        }
        else
            continue;
        arr[x]++;
    }
    if ((n-cnt) & 1 )
    {
        cnt--;
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    }
    else if(k <= a + b){
        cout << a << endl;
    }
    else{
        cout << a - (k - a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3540
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D
# Areas on the Cross-Section Diagram
# Result:
import sys

class Stack(object):
    def __init__(self):
        self.store = []

    def push(self, val):
        self.store.append(val)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def top(self):
        if self.is_empty():
            return None
        return self.store[len(self.store) - 1]

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def to_list(self):
        return list(self.store)


### main
pools = []
s1 = Stack()
s2 = Stack()

line = sys.stdin.readline().rstrip()
area_sum = 0
idx = 0
for c in line:
    if c == '\\':
        s1.push(idx)
    elif c == '/':
        if not s1.is_empty():
            bs_idx = s1.pop()
            this_area_sum = idx - bs_idx
            area_sum += this_area_sum
            while (not s2.is_empty()) and (s2.top()[0] > bs_idx):
                this_area_sum += s2.pop()[1]
            s2.push((bs_idx, this_area_sum))
    else:
        pass
    idx += 1

print area_sum
s2_list = s2.to_list()
str = '%d' % (len(s2_list))
for e in s2.to_list():
    str += ' %d' % (e[1])
print str

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  map<int,vector<pair<int,int>>>m;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      int a;
      cin>>a;
      m[a].push_back({i,j});
    }
  }
  int N;
  cin>>N;
  vector<int>b(N);
  for(int i=0;i<N;i++)cin>>b[i];
  vector<vector<bool>>A(3,vector<bool>(3,false));
  for(int i=0;i<N;i++){
    for(auto it:m[b[i]]){
      A[it.first][it.second]=true;
    }
  }
  bool ans=false;
  for(int i=0;i<3;i++){
    bool ok=true;
    for(int j=0;j<3;j++){
      if(!A[i][j])ok=false;
    }
    ans|=ok;
  }
  for(int i=0;i<3;i++){
    bool ok=true;
    for(int j=0;j<3;j++){
      if(!A[j][i])ok=false;
    }
    ans|=ok;
  }
  bool ok=true;
  for(int i=0;i<3;i++){
    if(!A[i][i])ok=false;
  }
  ans|=ok;
  ok=true;
  for(int i=0;i<3;i++){
    if(!A[i][2-i])ok=false;
  }
  ans|=ok;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  ll H,W;
  cin >> H >> W;
  if(H==1 || W==1) {
    cout << 1 << endl;
    return 0;
  }
  ll h = (H+1)/2;
  ll w = (W+1)/2;
  ll ans = h*w;
  ans += (H-h) * (W-w);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    rep(i, min(k, n)) {
        if (s[i] >= '2') {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = s[0];
            int y = s[1];

            long ans = 0;

            if (x == 3)
            {
                ans += 100000;
            }
            else if (x == 2)
            {
                ans += 200000;
            }
            else if (x == 1)
            {
                ans += 300000;
            }
            if (y == 3)
            {
                ans += 100000;
            }
            else if (y == 2)
            {
                ans += 200000;
            }
            else if (y == 1)
            {
                ans += 300000;
            }
            if (x == 1 && y == 1)
            {
                ans +=400000;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

string N;
ll K;
ll dp[110][5][2];
int main(){
	cin >> N >> K;
	ll M = N.size();
	//dp[桁][条件][less] := 左からi桁目まで、条件やlessを満たしているかCheck!!
	dp[0][0][0] = 1;
	REP(i,0,M) {
		REP(j,0,K+1){
			REP(less,0,2) {
				ll lim = less ? 9 : N[i] - '0'; //すでにlessならその後は9まで見てよし
				REP(x, 0, lim + 1) {
					if(j + (x != 0) <= K) dp[i + 1][j + (x != 0)][less || x < lim] += dp[i][j][less];
				}
			}
		}
	}

	p(dp[M][K][1] + dp[M][K][0]);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[10000001];

int main()
{
    long long n; 
    cin>>n;
    for(int i=1; i<=n; i++)
        x[i]=1;
    for(int i=2; i<=n; i++)
        for(int j=i; j<=n; j+=i)
            x[j]++;
    long long ans=0;
    for(int i=1; i<=n; i++)
        ans+=(i*x[i]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;cin>>n;
  
  int repC = 0;
  rep(i,n) {
    int d,e; cin>>d>>e;
    
    if(d==e) {
      ++ repC;
      if (repC>=3) {
        cout<<"Yes";
        return 0;
      }
    } else {
      repC = 0;
    }
  }
  
  cout<<"No";
  
  return 0;
}

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


using namespace std;


void To_upper(string &x){
	for(int i = 0; i < x.length(); i++){
		if('a' <= x[i] && x[i] <= 'z')
			x[i] -= 32;
	}
}


int main()
{
	string T, W;

	cin >> W;
	To_upper(W);

	int count = 0;
	while(1){
		cin >> T;
		if(T == "END_OF_TEXT")
			break;

		To_upper(T);
		if(T == W)
			count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3200
def f(a,x,y):
    if 0<=x<12 and 0<=y<12 and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:f(a,x+dx,y+dy)

while 1:
    try:
        a=[list(input()) for _ in [0]*12]
        b=0
        for i in range(12):
            for j in range(12):
                if a[j][i]=='1':
                    b+=1;f(a,i,j)
        print(b);input()
    except:break  

Measured memory_bytes: 7368
def saiki(arr_lst,count,path,N):
	if len(path) == N:
		count[0] += 1
	else:
		here = path[-1]
		arrival = arr_lst[here]
		for next in arrival:
			if not next in path:
				newpath = path[:]
				newpath.append(next)
				saiki(arr_lst,count,newpath,N)


if __name__ == '__main__':
	N, M = map(int, input().split())
	arr_lst = [[]]

	for i in range(1,N+1):
		arr_lst.append([])

	for _ in range(M):
		a, b = map(int, input().split())
		arr_lst[a].append(b)
		arr_lst[b].append(a)

	count = [0]

	saiki(arr_lst,count,[1],N)

	print(count[0])

Measured memory_bytes: 73564
#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() {
    ll n, x, m, M, sum;
    cin>>n;
    m = 1000001;
    M = -1000001;
    sum = 0;
    while (n--) {
        cin>>x;
        if (x < m) m = x;
        if (x > M) M = x;
        sum += x;
    }
    cout<<m<<" "<<M<<" "<<sum<<endl;
}


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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;
#define PI 3.14159265359

int main(){
    double a,b,h,m; cin >> a >> b >> h >> m;

    double hK=30*h;
    double mK=6*m;
    hK+=0.5*m;

    double theta=abs(hK-mK);
    if(theta>180) theta=360-theta;
    //cout << theta << endl;
    theta=theta*PI/180;

    double ans=sqrt(a*a+b*b-2*a*b*cos(theta));

    printf("%.11f\n",ans);

}

Measured memory_bytes: 4216
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n].Select(_ => read()).OrderBy(p => p[0]).ToArray();
		var bs = new int[n].Select(_ => read()).OrderBy(p => p[1]).ToArray();

		var map = new int[n].Select(_ => new int[0].ToList()).ToArray();
		for (int i = 0; i < n; i++)
		{
			var p = rs[i];
			for (int j = 0; j < n; j++)
			{
				var q = bs[j];
				if (p[0] < q[0] && p[1] < q[1]) map[i].Add(j + 1);
			}
		}

		var c = 0;
		var u = new bool[n + 1];
		for (int b, i = n - 1; i >= 0; i--)
			if ((b = map[i].FirstOrDefault(j => !u[j])) > 0)
			{
				c++;
				u[b] = true;
			}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 13652
#include<iostream>


#define rep(i,a,x) for(int i=(x);i<(a);i++)
#define rrep(i,a,x) for(int i=(a);i>=(x);i--)

using namespace std;

int main(){
	int D; cin>>D;
	
	cout<<"Christmas ";
	rep(i,25,D) cout<<"Eve ";
	cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n;
    scanf("%lli%*c",&n);
    i64 *p=(i64 *)calloc(n,sizeof(i64));
    i64 m;
    scanf("%lli%*c",&m);
    i64 *a=(i64 *)calloc(m,sizeof(i64));
    for(i64 i=0LL;i<m;++i) scanf("%lli%*c",&a[i]);
    for(i64 i=0LL;i<m;++i){
        i64 b,cnt=0LL;
        for(i64 j=0LL;j<n;++j){
            scanf("%lli%*c",&b);
            if(b==a[i]) ++p[j];
            else ++cnt;
        }
        p[a[i]-1LL]+=cnt;
    }
    for(i64 i=0LL;i<n;++i) printf("%lli\n",p[i]);
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
long long n,ans,k;
int main()
{
    ans=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	if(ans<k) ans+=ans;
    	else ans+=k;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int fn = 0;
  int t = 1;
  int N_while = N;

  while(N_while > 0){
    N_while = N / t;
    fn = fn + (N_while %10);
    t = t * 10;
  }
  
  if(N %fn == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }   
}   

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

int main(){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n>k){
    cout<<(n-k)*y+k*x<<endl;
  }
  else{
    cout<<n*x<<endl;
  }
}
  
  

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int l = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int idx = -1;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] + a[i + 1] >= l) {
				idx = i;;
				break;
			}
		}
		if (idx == -1) {
			System.out.println("Impossible");
		} else {
			System.out.println("Possible");
			for (int i = 0; i < idx; i++) {
				System.out.println(i + 1);
			}
			for (int i = n - 2; i >= idx; i--) {
				System.out.println(i + 1);
			}
		}
	}
}


Measured memory_bytes: 56280
#include<cstdio>
#include<cstring>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i = 0; i < s.length(); i++){
		if(i%2 == 0) cout<<s[i];
	}
	cout<<endl;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == s[1]) cout << "Bad" << endl;
    else if (s[1] == s[2]) cout << "Bad" << endl;
    else if (s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 077
// D - 11

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

const int MAX_N = 100000;
const ll MOD = 1000000007;

int N;
int a[MAX_N + 1];
bool found[MAX_N];
int dbl_num, outer;
ll ans;

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

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x) % m;
}


int main() {

    ll all_comb, rem_comb;

    cin >> N;
    memset(found, 0, sizeof(found));
    for (int i = 0; i < N + 1; i++) {
        cin >> a[i];
        a[i]--;
        if (found[a[i]]) {
            dbl_num = a[i];
        } else {
            found[a[i]] = true;
        }
    }
    outer = 0;
    for (int i = 0; i < N + 1 && a[i] != dbl_num; i++) {
        outer++;
    }
    for (int i = N; i >= 0 && a[i] != dbl_num; i--) {
        outer++;
    }

    all_comb = N + 1;
    rem_comb = 1;
    for (int k = 1; k <= N + 1; k++) {
        ans = all_comb - rem_comb + MOD;
        ans %= MOD;
        cout << ans << endl;
        all_comb = all_comb * (N + 1 - k) % MOD * mod_inverse(k + 1, MOD) % MOD;
        rem_comb = rem_comb * max(outer - k + 1, 0) % MOD * mod_inverse(k, MOD) % MOD;
    }

    return 0;

}





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


#define endl "\n"
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    string s;
    cin >> s;
    for( int i = 0 ; s[i] ; i++ ){
        cout << 'x';
    }
    cout << endl;


	return 0;

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
	int k;
	cin>>k;
	int ans;
	if (k%2==0) ans = (k/2) * (k/2);
	else ans = ((k/2)+1) * (k/2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def S(n: int) -> int:
    """
    各桁の和を取得する.

    Args:\n
        n (int): 整数

    Returns:\n
        int: 各桁の和
    """
    return sum(map(int, str(n)))


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数(1 <= N <= 10**9)
    """
    # 求解処理
    ans = str()
    if N % S(N) == 0:
        ans = "Yes"
    else:
        ans = "No"

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d, score;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26)), pos(26);

int get_score(vector<int> t){
    vector<int> pos(26, 0);
    int ans = 0;
    rep(i, t.size()){
        int l = i + 1 - pos[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        pos[t[i]] = i+1;
    }
    rep(i, 26){
        int l = t.size() + 1 - pos[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t, pos(26, 0);
    rep(i, d){
        int max_score = -mod;
        int best_j = -1;
        rep(j, 26){
            t.push_back(j);
            int score = get_score(t);
            if(max_score < score){
                best_j = j;
                max_score = score;
            }
            t.pop_back();
        }
        t.push_back(best_j);
    }
    vector<int> ans = t;
    double start_temp, end_temp;
    clock_t start_time = clock();
    int current_max_score = get_score(t);
    while(clock() < 1950000){
        int D = rand() % d, q = rand() % 26;
        int old = t[D];
        int olds = get_score(t);
        t[D] = q;
        int score = get_score(t);
        clock_t now_time = clock();
        double temp = start_temp + (end_temp - start_temp) * (now_time - start_time) / 19000;
        double prob = exp((score - olds)/temp);

        if(chmax(current_max_score, score)){
            ans = t;
        }

        if(prob >= ((rand()%inf)/(double)inf))t[D] = old;
    }
    rep(i, d)cout << ans[i]+1 << endl;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long

using namespace std;

const int MAXN = (int) 2e5;

string str;

int fr[30];

vector <int> pos[30];

int ind[30];

int aib[MAXN + 1][2];
int n;

inline void update(int pos, bool t) {
    for(int i = pos; i <= n; i += lsb(i))
        aib[i][t]++;
}

inline int query(int pos, bool t)  {
    int ans = 0;
    for(int i = pos; i > 0; i -= lsb(i))
        ans += aib[i][t];
    return ans;
}

inline int check(int p) {
    return (query(n, 1) - query(p, 1)) - query(p - 1, 0);
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j;
    ios::sync_with_stdio(false);
    cin >> str;
    n = str.size();
    str = " " + str;
    for(i = 1; i <= n; i++) {
        str[i] -= 'a';
        fr[str[i]]++;
        pos[str[i]].push_back(i);
    }
    int cnt = 0;
    for(i = 0; i < 26; i++) {
        if(fr[i] % 2 == 1) {
            cnt++;
        }
    }
    if(cnt > 1) {
        cout << -1;
        return 0;
    }
    ll ans = 0;
    pos[29].push_back(n + 1);
    pos[29].push_back(0);
    int lim = n / 2;
    if(n % 2 == 0)
        lim--;
    for(i = 1; i <= lim; i++) {
        int ch1 = 29, ch2 = 29;
        for(j = 0; j < 26; j++) {
            if(pos[j].size() > ind[j]) {
                if(pos[j][ind[j]] < pos[ch1][ind[ch1]])
                    ch1 = j;
                if(pos[j].back() > pos[ch2].back())
                    ch2 = j;
            }
        }
        int pa = pos[ch1].back(), pb = pos[ch2][ind[ch2]];
        //printf("%c %c\n" ,ch1 + 'a',ch2 + 'a');
        if(pos[ch1].size() == 1)
            pa = -n;
        if(pos[ch2].size() == 1)
            pb = 2 * n;
        if(pa != -n)
           pa = pa + check(pa);
        if(pb != 2 * n)
           pb = pb + check(pb);
        if(pb - i < n - i + 1 - pa) {
            ans += pb - i;
            update(pos[ch2][ind[ch2]], 1);
            ind[ch2]++;
            pos[ch2].pop_back();
        }
        else {
            ans += n - i + 1 - pa;
            update(pos[ch1].back(), 0);
            ind[ch1]++;
            pos[ch1].pop_back();
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 3408
import scala.util.control.Exception._
import scala.io.StdIn.readInt
import java.io.EOFException

object Main {
    def sieve(num:Int) = {
        var p:Array[Int] = Array.fill(num+1)(1)

        p(0) = 0
        p(1) = 0
        for( i<- 4 to num by 2)
            p(i) = 0

        var i = 3
        while(i*i < num){
            if(p(i) == 1) {
                for( j<- i*i to num by i*2)
                    p(j) = 0
            }
            i += 2
        }
        for(i<-1 to num)
            p(i) = p(i)+p(i-1)
        p
    }

    def main(args: Array[String]) = {
        val p = sieve(1000000)
        ignoring(classOf[EOFException]) {
            while(true) {
                val n = readInt()
                println(p(n))
            }
        }
    }
}

Measured memory_bytes: 47764
#include <stdio.h>
struct ar {
    struct slot {
        int w, v;
    } slot[40001];
} ar[2];
int
add(struct ar *old, int w, int v, int wmax, struct ar *new)
{
    struct slot *oldp = old->slot;
    struct slot *addp = old->slot;
    struct slot *newp = new->slot;
    int current_maxv = -1;
    for (;;) {
        if (oldp->w >= 0) {
            if (addp->w >= 0) {
                int addpw = addp->w + w;
                int addpv = addp->v + v;
                if (oldp->w < addpw)
                    goto putoldp;
                else if (oldp->w > addpw)
                    goto putaddp;
                else {
                    if (oldp->v < addpv) {
                        oldp++;
                        goto putaddp;
                    } else {
                        addp++;
                        goto putoldp;
                    }
                }
            } else
                goto putoldp;
        } else {
            if (addp->w >= 0)
                goto putaddp;
            else
                break;
        }
    putoldp:
        if (current_maxv < oldp->v) {
            *newp++ = *oldp;
            current_maxv = oldp->v;
        }
        oldp++;
        continue;
    putaddp:
        {
            int addpw = addp->w + w;
            int addpv = addp->v + v;
            if (wmax < addpw)
                break;
            if (current_maxv < addpv) {
                newp->v = addpv;
                newp->w = addpw;
                current_maxv = addpv;
                newp++;
            }
            addp++;
            continue;
        }
    }
    newp->w = -1;
    newp->v = -1;
    return current_maxv;
}

int
main(void) {
    int n, wmax;
    struct ar *old = &ar[0];
    struct ar *new = &ar[1];
    old->slot[0].w = 0;
    old->slot[0].v = 0;
    old->slot[1].w = -1;

    scanf("%d%d", &n, &wmax);
    int vmax;
    int i;
    for (i = 0; i < n; ++i) {
        int wi, vi;
        scanf("%d%d", &wi, &vi);
        vmax = add(old, wi, vi, wmax, new);
        struct ar *tmp = new;
        new = old;
        old = tmp;
    }
    printf("%d\n", vmax);
    return 0;
}

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

//const int MAX_LEN = 200002;

int main()
{
int n;
cin >> n;
int c[5];
string s[n+1];
for (int i = 0; i < n; i++){
  cin >> s[i];
}
for (int i = 0; i < 5; i++){
  c[i] = 0;
}
for (int i = 0; i < n; i++)
{
  if (s[i] == "AC")
    c[0] = c[0] + 1;
  else if (s[i] == "WA")
    c[1] = c[1] + 1;
  else if (s[i] == "TLE")
    c[2] = c[2] + 1;
  else if (s[i] == "RE")
    c[3] = c[3] + 1;
}

cout << "AC x " << c[0] << endl;
cout << "WA x " << c[1] << endl;
cout << "TLE x " << c[2] << endl;
cout << "RE x " << c[3] << endl;
return 0;
}

Measured memory_bytes: 6752
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=set(a);B=set(b)
c=1;cn=0;cm=0
for k in range(m*n,0,-1):
  if k in A and k in B:
    cn+=1;cm+=1
  elif k in A:
    c*=cm;cn+=1
  elif k in B:
    c*=cn;cm+=1
  else:
    c*=cm*cn-m*n+k
  c=c%(10**9+7)
print(c)

Measured memory_bytes: 3188
let n, t = Scanf.scanf "%d %d\n" (fun x y -> x, y)

let rec read_ints accu = function
  | 0 -> List.rev accu
  | k -> read_ints ((Scanf.scanf " %d" (fun x -> x)) :: accu) (k-1)

let a = Array.of_list (read_ints [] n)
let b = Array.make n 0

let () =
  b.(n-1) <- a.(n-1);
  for i = n-2 downto 0 do
    b.(i) <- max a.(i) b.(i+1)
  done;;

let c = ref 0 in
  let max = ref (-1) in
  for i = 0 to n-1 do
    if !max < b.(i)-a.(i) then begin max := b.(i)-a.(i); c := 1 end
    else if !max = b.(i)-a.(i) then c := !c + 1
  done;
  print_int !c


Measured memory_bytes: 8704
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll com[51][51];

void set_com_table(){
  for(int i=0;i<=50;i++){
    for(int j=0;j<=i;j++){
      if(j==0 || j==i) com[i][j] = 1LL;
      else {
        com[i][j] = com[i-1][j-1] + com[i-1][j];
      }
    }
  }
}

//========================================================

int main(){
  set_com_table();
  int N,A,B;
  cin >> N >> A >> B;
  double v[N];
  for(int i=0;i<N;i++) cin >> v[i];

  sort(v,v+N);

  double sum = 0;
  for(int i=N-A ; i<N ; i++){
    sum += v[i];
  }

  double mn = v[N-A];
  int cnt = 0; //全部の中の個数
  for(int i=0;i<N;i++){
    if(v[i] == mn) cnt++;
  }
  int cntA = 0; //A個選ぶときにmnが何個使われるか
  for(int i=N-A;i<N;i++){
    if(v[i] == mn) cntA++;
  }

  ll ans = 0LL;
  if(mn == v[N-1]){
    for(int i=A;i<=min(cnt,B);i++){
      ans += com[cnt][i];
    }
  } else {
    ans += com[cnt][cntA];
  }

  printf("%.6lf\n",sum/A);
  cout << ans << endl;
  return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

int main() {
  int n, m; cin >> n >> m;
  vector<int> arr(m);
  for (int i = 0; i < m; ++i) {
    cin >> arr[i];
  }
  map<int, int> match;
  vector<int> match_nums = {2,5,5,4,5,6,3,7,6};
  for (int i = 1; i < 10; ++i) {
    match[i] = match_nums[i - 1];
  }
  vector<cpp_int> dp(n + 7, -1);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int a: arr) {
      if (dp[i] == -1) continue;
      cpp_int new_dp = dp[i] * 10 + a;
      if (dp[i + match[a]] < new_dp) dp[i + match[a]] = new_dp;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pow(ll x)
{
    ll ans=1;
    for(int i=0;i<5;i++)
        ans*=x;
    return ans;
}
int main()
{
    ll a,b;
    ll x; cin>>x;
    for(int a=-200;a<=200;a++)
    {
        for(int b=-200;b<=200;b++)
        {
            if(pow(a)-pow(b)==x)
            {
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}




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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(all(v));
  int attacker = v[0];

  while(true) {
    for (int i = 1; i < int(v.size()); i++) {
      v[i] %= attacker;
      if(v[i] == 0){
        v.erase(v.begin() + i);
        i--;
        if(v.size() == 1) {
          break;
        }
      }
    }
    if(v.size() == 1) {
      attacker = v[0];
      break;
    }
    sort(all(v));
    attacker = v[0];
  }

  cout << attacker << endl;




}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ao=(a+d-1)/d;
	int ta=(c+b-1)/b;

	cout<< (ta<=ao?"Yes":"No")<< endl;
	return 0;
}


Measured memory_bytes: 3596
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	sort.Strings(s)
	fmt.Println(strings.Join(s, ""))
}


Measured memory_bytes: 640
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int k, l, rem;
  cin >> k;
  if (k % 7 == 0)
    l = 9 * k / 7;
  else
    l = 9 * k;

  if (my::gcd(10, l) != 1) {
    cout << -1 << endl;
    return 0;
  }

  int ans;
  for (int i = 1; i <= l; i++) {
    if (i == 1)
      rem = 10 % l;
    else
      rem = (rem * 10) % l;
    if (rem == 1) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
//int mod =1000000007;
int mod =998244353;
const double PI = acos(-1);
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}com(200005);
mint choose(int n,int a){
  mint x = 1,y=1;
  rep(i,a){
    x*= n-i;
    y*= i+1;
  }
  return x/y;
}

int main(){
    ll n;cin>>n;
    vl d (n,0);
    ll m =0;
    rep(i,n){
        ll x;cin>>x;
        d[x]++;
        m=max(m,x);
        if(i==0&&x!=0){
            cout<<0<<endl;  
            return 0;
        }
    }
    if(d[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    // rep(i,m+1){
    //     if(d[i]==0){
    //         cout<<0<<endl;
    //         return 0;
    //     }
    // }
    mint ans =1;
    mint t =d[0];
    rep(i,m+1){
        if(i==0)continue;
        ans*=t.pow(d[i]);
        t=d[i];
    }
    cout<<ans.x<<endl;
}

Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
int main() {
    char x;
    cin >> x;
    if(x=='a'||x=='e'||x=='i'||x=='o'||x=='u')
        puts("vowel");
    else
        puts("consonant");







    return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n), b(n), c(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	REP(i, n)cin >> c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll ans = 0;
	REP(i, n) {
		ll x = lower_bound(ALL(a), b[i]) - a.begin(),
			y = upper_bound(ALL(c), b[i]) - c.begin();
		ans += x*(n - y);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
a = input()
ans=0
tmp=0
ren=False
for i in range(len(a)):
    if a[i] == "A" or a[i] == "T" or a[i] == "C" or a[i] == "G":
        if ren:
            tmp+=1
        else:
            ren = True
            tmp += 1
    else:
        if ren:
            ans = max(ans,tmp)
            ren = False
            tmp=0
ans = max(ans,tmp)
print(ans)
        

Measured memory_bytes: 3060
n = int(input())
li = []
for _ in range(n):
    a, b = map(int, input().split())
    li.append((a, -b, a+b))
li.sort(key=lambda x:-x[2])
ans = 0
for i in range(n):
    ans += li[i][i%2]
print(ans)

Measured memory_bytes: 25344
from collections import deque

class Edge:
    def __init__(self, fromNode, toNode, cap, rev=None):
        self.fromNode = fromNode
        self.toNode = toNode
        self.cap = cap
        self.rev = rev

class MaxFlow:
    def __init__(self, V):
        self.v = V
        self.edges = [[] for _ in range(V)]

    def addEdge(self, fromNode, toNode, cap):
        forEdge = Edge(fromNode, toNode, cap)
        backEdge = Edge(toNode, fromNode, 0)
        forEdge.rev = backEdge
        backEdge.rev = forEdge
        self.edges[fromNode].append(forEdge)
        self.edges[toNode].append(backEdge)
    
    def bfs(self, source, sink):
        self.level = [None] * self.v
        self.level[source] = 0
        que = deque()
        que.append(source)
        while que:
            node = que.popleft()
            newLevel = self.level[node] + 1
            for edge in self.edges[node]:
                if edge.cap and self.level[edge.toNode] is None:
                    self.level[edge.toNode] = newLevel
                    que.append(edge.toNode)

        return self.level[sink] is not None

    def dfs(self, node, sink, f):
        if node == sink: return f

        for edge in self.edges[node]:
            if edge.cap and self.level[edge.fromNode] < self.level[edge.toNode]:
                newFlow = self.dfs(edge.toNode, sink, min(f, edge.cap))
                if newFlow:
                    edge.cap -= newFlow
                    edge.rev.cap += newFlow
                    return newFlow

        return 0
    
    def run(self, source, sink):
        flow = 0
        INF = 10 ** 10
        while self.bfs(source, sink):
            addFlow = INF
            while addFlow:
                addFlow = self.dfs(source, sink, INF)
                flow += addFlow

        return flow

V, E = map(int, input().split())
net = MaxFlow(V)
for _ in range(E):
    u, v, c = map(int, input().split())
    net.addEdge(u, v, c)
print(net.run(0, V - 1))


Measured memory_bytes: 6396
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	
	return 0;
}

Measured memory_bytes: 256