akhauriyash/Code-Regression huggingface dataset:
time = 0
order_list = []

for i in range(5):
        order_list.append(int(input()))

#余りを利用して、9~0で表現し、大きい順にソートしている
order_list = sorted(order_list, key=lambda x: ((x-1)%10), reverse=True)

for i in order_list[0:-1]:
        if i % 10 == 0:
                time += i
        else:
                time += (int(i/10)+1)*10

print(time+order_list[-1])
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

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;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

int main() {
    ll N, M;
    cin >> N >> M;
    UF uf(N);

    rep(i, M){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }

    vc<ll> A(N);
    rep(i, N) A[uf.root(i)] = 1;

    ll sum = accumulate(all(A), 0ll);

    cout << sum - 1 << endl;
}

Measured memory_bytes: 5312
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        int result = 0;
        for (int i = 0;i<N;i++){
            if(S.charAt(i) == 'A'&&i<=N-3){
                if(S.charAt(i+1)=='B'){
                    if(S.charAt(i+2)=='C'){
                        result++;
                    }
                }
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21972
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b;
bool is[1000005];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	for(int i=1;i<=1000;i++)
	is[i*i]=true;
	cin>>a>>b;
	int len=i_s(b).length();
	a=a*pow(10,len)+b;
	if(is[a])
	cout<<"Yes";
	else
	cout<<"No";
	//system("pause");
	return 0;
}

Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize
    }
    println!("{}", (n + 1) / 2);
}


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

using namespace std;

int main(){
	int n; cin >> n;
	int bill = 1000;
	int change = 0;
	if(n == bill){
		cout << 0 << endl;
	}
	else if(n < bill){
		cout << bill -  n << endl;
	}
	else{
		while(bill < n){
			bill += 1000;
		}
		cout << bill - n << endl;
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  set<int> st;
  int j = n - 2;
  rep(i, m) {
    int a = j - i;
    int b = n - a;
    while(true) {
      a = j - i;
      b = n - a;
      if(st.count(a) || st.count(b) || (a != 1 && a == b))
        j--;
      else
        break;
    }
    st.insert(a);
    st.insert(b);
    cout << i + 1 << ' ' << j + 1 << endl;
    j--;
  }
}

Measured memory_bytes: 11992
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(15);

    int n;
    cin >> n;
    vector<long double> arr(n);
    F0R(i,n)
        cin >> arr[i];
    long double tot=0;
    F0R(i,n)
    {
        tot+=(1/arr[i]);
    }
    cout << 1/tot;

    return 0;
}


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


int main(){
    char s;
    cin >> s;
    if(isupper(s)) cout << "A" << endl;
    else cout << "a" << endl;
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == '0' || s[n - 1] == '1') {
        cout << -1 << "\n";
        return 0;
    }
    for (int i = 0; i < n / 2; ++i) {
        if (s[i] != s[n - i - 2]) {
            cout << -1 << "\n";
            return 0;
        }
    }
    int curr = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i-1] == '1') {
            cout << curr << " " << i+1 << "\n";
            curr = i+1;
        } else {
            cout << curr << " " << i+1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define N 
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
template<typename T>
inline void in(T &x)
{
	x=0;
	char c=getchar();
	bool fu=0;
	while(c<'0'||c>'9'){if(c=='-')fu=1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x=fu?-x:x;
}
ll a,b,c;
int main()
{
	in(a);in(b);in(c);
	if(a<0)a=-a;
	if(b<a/c)
	{
		printf("%lld\n",a-c*b);
		return 0;
	}
	b-=a/c;
	a%=c;
	if(b&1)printf("%lld\n",c-a);
	else printf("%lld\n",a);
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector <string>s(n);
    rep(i,n){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    ll ans = 1;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include<stdio.h>
#define M 100
int main() {
  int i, j, n, k, s;
  scanf ("%d", &n);
  int A[M][M],B[M][M];
  for (i = 0; i < n; i++){
    scanf("%d%d", &A[i][0], &A[i][1]);
    k = 2;
    for (j = 0; j < A[i][1]; j++){
      scanf("%d", &A[i][k]);
      k++;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      B[i][j] = 0;
      }
}
  
  for(i = 0; i < n; i++){
    k = 2;
    for(j = 0; j < A[i][1]; j++){
      s = A[i][k] - 1;
      B[i][s] = 1;
      k++;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n - 1; j++){
      printf("%d ", B[i][j]);
    }
    printf("%d", B[i][j]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

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

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int>a, pair<int,int>b) {
	if (a.first == b.first) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

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

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

using namespace std;

using ll = long long;

ll Solve() {
    string s;
    cin >> s;

    ll res = stoll(s);
    int n = s.size() - 1;
    for (int i = 1; i < 1 << n; ++i) {
        ll sum = 0, l = 0;
        for (int j = 0; j < n; ++j) {
            if (i >> j & 1) {
                sum += stoll(s.substr(l, j - l + 1));
                l = j + 1;
            }
        }
        sum += stoll(s.substr(l, (n - l + 1)));
        res += sum;
    }
    return res;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int cnt = 0;
  int left = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == '('){
      cnt++;
    }else{
      cnt--;
    }
    if(cnt < 0){
      left++;
      cnt++;
    }
  }
  string A = "";
  rep(i, left){
    A += '(';
  }
  A += S;
  cnt = 0;
  rep(i, A.size()){
    if(A[i] == '('){
      cnt++;
    }else{
      cnt--;
    }
  }
  rep(i, cnt){
    A += ')';
  }
  cout << A << endl;
}


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

int main(){
    ll n;
    cin >> n;
    ll odd = 0;
    ll even = 0;
    ll four = 0;
    rep(i,n){
        ll a;
        cin >> a;
        if(a%4==0)four++;
        else if(a%2==0)even++;
        else odd++;
    }
    bool ans = false;
    if(even==0&&odd<=four+1)ans=true;
    if(odd<=four)ans=true;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <string>
#include <numeric>
#include <algorithm>

using namespace std;

int main(){
    int n,m,ans = 0;
    string s;
    cin >> n;
    map<string,int>ma;

    for(int i = 0;i < n;i++){
        cin >> s;
        ma[s]++;
    }
    cin >> m;
    for(int i = 0;i < m;i++){
        cin >> s;
        ma[s]--;
    }

    for(auto &i:ma)
        if(ans < i.second)ans = i.second;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val l = s.length
    print((0 until (1 shl (l-1))).map{bit ->
        val ppositions = (0 until l-1).filter { bit and (1 shl it) != 0}.map{it + 1}.toMutableList().apply {
            add(0, 0)
            if(l !in this) add(this.size, l)
        }
        (0..ppositions.size-2).map{i ->
            s.substring(ppositions[i], ppositions[i+1]).toLong()
        }.sum()
    }.sum())
}

Measured memory_bytes: 31860
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<string> v(n);
	for (int i=0; i<n; ++i){
		cin >> v[i];
		sort(v[i].begin(),v[i].end());
	}
	int cnt=0;
	map<string,int> m;
	for (int i=0; i<n; ++i){
		m[v[i]]++;
	}
	for (auto i:m){
		cnt += i.second*(i.second-1)/2;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<int> x = vector<int>(26, 0);

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

    int H, W;
    cin >> H >> W;

    char c;
    rep (i, H * W)
    {
        cin >> c;
        ++x[c - 'a'];
    }

    int thres;
    bool odd;
    if ((H & 1) && (W & 1))
    {
        thres = (H - 1) * (W - 1) / 4;
        odd = true;
    }
    else if (!(H & 1) && !(W & 1))
    {
        thres = H * W / 4;
        odd = false;
    }
    else if (H & 1)
    {
        thres = (H - 1) * W / 4;
        odd = false;
    }
    else
    {
        thres = H * (W - 1) / 4;
        odd = false;
    }

    int acc = 0;
    bool ans = true;
    for (int i = 0; i < x.size() && ans; ++i)
    {
        acc += x[i] / 4;
        if (x[i] & 1)
        {
            if (!odd)
            {
                ans = false;
            }
            odd = false;
        }
    }
    if (acc < thres) ans = false;

    if (ans) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  for (int i=0; i<n; i++){
    cin >> h.at(i);
  }
  double diff=1000;
  int ans;
  for (int i=0; i<n; i++){
    if (abs(t-h.at(i)*0.006-a) < diff){
      diff = abs(t-h.at(i)*0.006-a);
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(sum(
        1
        for i in range(A, B + 1)
        if str(i) == str(i)[::-1]
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var N, M, C int
	fmt.Scan(&N)
	fmt.Scan(&M)
	fmt.Scan(&C)

	b := make([]int, M)
	for j := 0; j < M; j++ {
		fmt.Scan(&b[j])
	}

	a := make([][]int, N)
	for i := 0; i < N; i++ {
		a[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	cnt := 0
	for i := 0; i < N; i++ {
		tmp := 0
		for j := 0; j < M; j++ {
			tmp += a[i][j] * b[j]
		}
		if tmp+C > 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#                               #
    # author : samars_diary #
    # 13-09-2020 │ 12:48:09 #
#                               #

import sys, os.path

if(os.path.exists('input.txt')):
    sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=li();b=ans=0
    if 'R' not in a:
        print(b)
    else:
        for i in range(len(a)):
            if a[i]=='R': b+=1 ; ans=max(ans,b)
            else: b=0
        print(ans)
solve()

Measured memory_bytes: 9020
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  ll n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  ll cnt = 0;
  REP(i, n) {
    if (a[i] == b[i] && b[i] == c[i]) {
      continue;
    }
    if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
      cnt++;
    } else {
      cnt += 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int64>> dp(N,vector<int64>(N,INF));
    vector<int64> cumsum(N+1,0);
    REP(i,N){
        cin >> A[i];
        dp[i][i] = 0;
        cumsum[i+1] = cumsum[i] + A[i];
    }

    REP(leng,N){
        REP(l,N){
            int r = l+leng;
            if(r>=N) break;
            for(int mid=l; mid<r; mid++){
                chmin(dp[l][r], dp[l][mid] + dp[mid+1][r] + cumsum[r+1] - cumsum[l]);
            }
        }
    }
    cout << dp[0][N-1] << bn;
}

Measured memory_bytes: 1536
def honestcount(i):
    return bin(i).count("1")

def is_honest(i,j):
    return (i>>j)%2 == 1

N = int(input())

A = [0] * N
shogens=[]

for i in range(N):
    a = int(input())
    shogen=[]
    for j in range(a):
        x,y = map(int, input().split())
        shogen.append((x-1,y))
    shogens.append(shogen)
# print(shogens)

count=0
for i in range(1<<N):
    is_ok =True
    for j in range(N):
        if not is_honest(i,j):
            continue
        for x,y in shogens[j]:
            if y!=is_honest(i,x): is_ok=False
    if is_ok:
        count=max(count,honestcount(i))
print(count)


Measured memory_bytes: 3064
n = int(input())
s = input()
r,g,b = 0,0,0
for i in s:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    else:
        b += 1
ans_1 = r * g * b
ans_2 = 0
for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            continue
        k = j - i + j
        if k >= n or s[k] == s[i] or s[k] == s[j]:
            continue
        #print(i,j,k)
        ans_2 += 1

print(ans_1-ans_2)


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

using namespace std;

typedef pair<string,int> P;

bool check(string a,string b){
  for(int i = 0 ; i < 8 ; i++){
    if(b[i] != '*' && a[i] != b[i]){
      return false;
    }
  }
  return true;
}

int main(){
  int n,m;

  while(cin >> n >> m ,(n | m)){
    P a[n];  
    string b;

    for(int i = 0 ; i < n ; i++){
      cin >> a[i].first >> a[i].second;
    }

    int ans = 0;
    for(int i = 0 ; i < m ; i++){
      cin >> b;
      for(int j = 0 ; j < n ; j++){
	if(check(b,a[j].first)){
	  ans += a[j].second;
	  break;
	}
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<functional>
#define int long long
#define INF 1e+10

using namespace std;

signed main(){
    int n,m;
    int ans[110];
    int s[110];
    int p[110]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>ans[i];
    }
    int loss=0;
    for(int i=0;i<m;i++){
        loss=0;
        for(int j=0;j<n;j++){
            cin>>s[j];
            if(s[j]==ans[i]){
                p[j]++;
            }
            else loss++;
        }
        p[ans[i]-1]+=loss;
    }
    for(int i=0;i<n;i++){
        cout<<p[i]<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>

int main(){
  int n;
  while(std::cin>>n,n){
    std::vector<int> v;
    for(;n;n--){
      int i;
      std::cin>>i;
      v.push_back(i);
    }
    
    std::sort(v.begin(),v.end());
    
    std::vector<int>::iterator it = v.begin();
    long long int wtime = 0,stime = 0;
    while(it!=v.end()){
      stime += wtime;
      wtime += (*it);
      it++;
    }
    std::cout<<stime<<std::endl;
  }
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

vector<ll> RUI_SORTED(ll N, vector<ll> A)
{
    vector<ll> ret(N);
    ret[0] = A[0];
    for(ll i=1;i<N;i++)
    {
        ret[i] = ret[i-1] + A[i];
    }
    sort(ALL(ret));
    return ret;
}

ll same_numbers(ll N, vector<ll> Rui_Sorted)
{
    ll total = 0;
    map<ll,ll> number_counter;
    for(auto x : Rui_Sorted)
    {
        number_counter[x]++;
    }
    number_counter[0]++;
    for(auto x : number_counter)
    {
        total += x.second * (x.second-1) / 2;
    }
    return total;
}

int main()
{
    ll N;
    cin >> N;

    vector<ll> A(N);
    ALLIN1_NUMBER(A);

    vector<ll> Rui_sorted = RUI_SORTED(N,A);

    OUT0(same_numbers(N,Rui_sorted));

    return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n, m; cin >> n >> m;
    vec<pair<int, int>> A(m);
    loop (m, i) {
        int a, b; cin >> a >> b;
        A[i] = { b, a };
    }
    sort(A.begin(), A.end());
    int l = -1, ans = 0;
    loop (m, i) {
        if (A[i].second <= l) continue;
        ans++;
        l = A[i].first - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
int a,b,c ;
int count = 0 ;
int i ;
scanf("%d %d %d",&a,&b,&c);
for(i=a ;i<=b ;i++){
if(c%i==0) count++ ;
}
printf("%d\n",count) ;
return 0 ;
}

Measured memory_bytes: 2732
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int p[100009];
void add(int l,int r,int n){
	if(l<r) p[l]++,p[r]--;
	else{
		p[l]++;
		p[n]--;
		p[0]++;
		p[r]--;
	}
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	int m;cin>>m;
	int ans = m;
	vi v(2*n);
	rep(i,2*n) cin>>v[i];
	sort(all(v));
	int lo =0,hi = m-1;
	while(lo<hi){
		int cur = (lo+hi)/2;
		int mx = 0;
		fill(p);
		rep(i,2*n){
			int x = 0;
			int y = upper_bound(all(v),cur-v[i])-v.begin();
			if(i%2==x%2) x++;
			if(i%2==y%2) y++;
			if(x<y) add(((i+x+1)%(2*n))/2,((i+y+1)%(2*n))/2,n);
			x = lower_bound(all(v),m-v[i])-v.begin();
			y = upper_bound(all(v),cur+m-v[i])-v.begin();
			if(i%2==x%2) x++;
			if(i%2==y%2) y++;
			if(x<y) add(((i+x+1)%(2*n)+1)/2,((i+y+1)%(2*n))/2,n);
		}
		mx = p[0];
		rep(i,n) p[i+1]+=p[i],mx = max(mx,p[i+1]);
		if(mx==2*n){
			hi =cur;
		}
		else lo = cur+1;
	}
	cout<<lo;
	return 0;
}



Measured memory_bytes: 1536
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
typedef long long ll;
int nxt(int a){
    int r = 1ll;
    int ret = 0;
    while (r <= a){
        r *= 2;
        ret++;
    }
    return r;
}
main(){
    int n;
    cin >> n;
    map <int,int> b;
    vector <int> a(n);
    for (int i = 0; i < n; i++){
            cin >> a[i];
            b[a[i]]++;
    }
    sort(rng(a));
    int ans = 0;
    for (int i = n - 1; i > -1; i--){
            if(b[a[i]] == 0) continue;
        int next_2 = nxt(a[i]);
        int q = next_2 - a[i];
        b[a[i]]--;
        if (b[q] > 0){
            b[q]--;
            ans++;
        }else b[a[i]]++;
    }
    cout << ans;

}


Measured memory_bytes: 26752
table = {"rg"=>"bb", "gr"=>"bb", "gb"=>"rr", "bg"=>"rr", "br"=>"gg", "rb"=>"gg"}

until (worm = $<.gets.chomp) == "0"
  queue = [worm]
  dist = {worm => 0}
  n = worm.size
  catch :jump do
    while (worm = queue.shift)
      goal = ["r" * n, "g" * n, "b" * n]
      if goal.include?(worm)
        puts dist[worm]
        throw :jump
      else
        (n - 1).times do |i|
          tmp = worm.dup
          pair = worm[i, 2]
          next unless table[pair]
          tmp[i, 2] = table[pair]
          next if dist[tmp]
          dist[tmp] = dist[worm] + 1
          queue << tmp
        end
      end
    end
    puts "NA"
  end
end


Measured memory_bytes: 8208
#include<iostream>
#include<cmath>
 
using namespace std;
 
int main() {
	int n;
	cin >> n;
	for (int i = 0;i < 3;i++) {
		if (n / (int)pow(10, i) % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B / 2 << endl;
  } else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_b
package main

import "fmt"
import "bufio"
import "os"
import "strconv"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	H := make([]int, N)
	for i := range H {
		H[i] = NextInt()
	}

	max := 0
	ans := 0
	for _, h := range H {
		if h >= max {
			ans++
			max = h
		}
	}
	fmt.Println(ans)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String text;
        int count = 0;
        while (!(text=sc.next()).equals("END_OF_TEXT")) {
            if (text.toLowerCase().equals(word)) count++;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

#define MAX_N 55555
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N + 1];//is_prime[i]がtrueならiは素数

//n以下の素数の数を返す
void sieve(int n){
    int p=0;
    for(int i=0; i<=n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j= 2*i; j<= n; j+=i) is_prime[j] = false;
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    sieve(MAX_N);
    vector<int> ans;
    int cnt=0;
    REP(i,MAX_N){
        if(prime[i]%5==1) ans.push_back(prime[i]),cnt++;
    }
    REP(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}


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

class A {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int H = st[0];
        int A = st[1];




        Console.WriteLine((int)Math.Ceiling((double)H / A));
    }
}

Measured memory_bytes: 13396
use proconio::{fastout, input};

// 7 * 10^i はmod kで循環する
// 循環する和がkと互いに素なら任意の数が作れる
// 互いに素でないなら、有限個試せばわかる GCDを計算すれば良い？
// 循環の長さはk以下
//
// kより短く循環することはあるか？
//
// ai = ajとする (0 <= i < j < k)
// aj - ai = 0
// aj - ai = a_{j - i} * 10^i
// kと10が互いに素なら
// a_{j - i} = 0
// 同じのがあれば割り切れるのが作れる。
// k+1まであれば絶対に1つはかぶる
// k+1まで試せば良い
//
// kと10が互いに素でないなら
// kが2で割り切れる場合
// aiはすべて奇数なのでだめ
// kが5で割り切れる場合
// aiは絶対に5で割り切れない

#[fastout]
fn main() {
    input! {
        k: i64,
    }

    if k % 2 == 0 || k % 5 == 0 {
        println!("-1");
        return;
    }

    let mut a = 0;
    for i in 0..(k + 1) {
        a += 7 * pow_mod(10, i, k);
        a = a % k;

        if a % k == 0 {
            println!("{}", i + 1);
            return;
        }
    }

    println!("-1");
}

fn pow_mod(n: i64, p: i64, m: i64) -> i64 {
    if n == 0 {
        return 0;
    }
    if p == 0 {
        return 1;
    }

    if p % 2 == 0 {
        let half = pow_mod(n, p / 2, m);
        (half * half) % m
    } else {
        (pow_mod(n, p - 1, m) * n) % m
    }
}


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

using namespace std;

bool check(string s) {
    int n = s.length();
    int i = 0;
    while (1) {
        if (s[i] != s[n - 1 - i]) return false;
        if (n - (i + 1) * 2 <= 1) return true;
        i++; 
    }
}

int main() {
    string S;
    cin >> S;

    // 回文の切れ目
    int N = S.length();
    int b1 = (N - 1) / 2;
    int b2 = (N + 3) / 2;

    string s1, s2, s3;

    for (int i = 0; i < b1; i++) s1 += S[i];
    for (int i = b1; i < b2 - 1; i++) s2 += S[i];
    for (int i = b2 - 1; i < N; i++) s3 += S[i];

    bool result = check(s1) && check(s2) && check(s3) && s1 == s3;

    cout << (result ? "Yes" : "No") << endl;
    return 0;
}

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


int main() {
  string s;
  cin >> s;
  rep(i, 19){
    if(i == 5 || i == 13) cout << ' ';
    else cout << s[i];
  }
  cout << endl;
  return 0;
  
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
An = deque(map(int, input().split()))
Bn = deque(map(int, input().split()))

cnt = 0

while len(An) > 1:
    m = An.popleft()
    y = Bn.popleft()
    n = An[0]
    if y < m:
        cnt += y
    elif m <= y < m+n:
        cnt += y
        An[0] -= y-m
    else:
        cnt += m+n
        An[0] = 0
    #print(cnt)
    #print(An)
    #print(Bn)

print(cnt)
    


Measured memory_bytes: 19756
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n, m, x, y;
    scanf("%d %d %d %d", &n, &m, &x, &y);
    double s=(double)n*m/2;
    printf("%.10lf %d\n", s, (2*x==n&&2*y==m ? 1 : 0));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int kumiawase(int n, int x);
int main() {
	int n, x;
	while (1)
	{
		cin >> n >> x;
		if (n==0&&x==0)
		{
			return 0;
		}
		cout << kumiawase(n, x) << endl;
		
	}
}
int kumiawase(int n, int x) {
	int sum = 0;
	for (int i = 1; i <= n ; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			for (int ii = j+1; ii <= n; ii++)
			{
				if (i+j+ii==x)
				{
						sum = sum + 1;
				}
			}
		}
	}
	return sum;
}


Measured memory_bytes: 3100
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val match = intArrayOf(0,2,5,5,4,5,6,3,7,6)

    val dp = IntArray(n+10){-1}
    dp[0] = 0
    repeat(n) { i ->
        a.forEach { dp[i+match[it]] = Math.max(dp[i+match[it]], dp[i] + 1 ) }
    }

    var ans = ""
    var l = n
    while(ans.length<dp[n]) {
        val num = a.last { if (l-match[it]<0) false else dp[l-match[it]] == dp[l]-1 }
        ans += num
        l -= match[num]
    }
    println(ans)

}

Measured memory_bytes: 62384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  if ((a < 0 && b < 0 && (b - a) % 2 == 1) || (a > 0 && b > 0)) {
    cout << "Positive" << endl;
  } else if ((a < 0 && b < 0 && (b - a) % 2 == 0)) {
    cout << "Negative" << endl;
  } else {
    cout << "Zero" << endl;
  }
  return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

const ll MAX=1e18;

int main() {
  int n; cin>>n;
  vll a(100010);
  ll ans=1;
  rep(i,n) {
    cin>>a[i];
    if(a[i]==0) {
      cout<<0<<endl;
      return 0;
    }
  }
  rep(i,n) {
    if(ans<=MAX/a[i]) {
      ans*=a[i];
    } else {
      ans=-1;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3992
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int arr[202];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp;
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int rose = b - a + 1;
    long long int lcm = (c*d)/__gcd(c,d);
    long long int ansC, ansD, ansLCM;
    ansC = b / c - (a - 1) / c;
    ansD = b / d - (a - 1) / d;
    ansLCM = b / lcm - (a - 1) / lcm;
    printf("%lld\n",rose-ansC-ansD+ansLCM);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

const int N = 1e5 + 5;
int nxt[N][26];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s,t;
	cin >> s >> t;
	rep(i,0,26)nxt[s.length()][i] = -1;
	for(int i = int(s.length()) - 1;i >= 0;--i){
		rep(c,0,26)nxt[i][c] = nxt[i+1][c];
		nxt[i][s[i] - 'a'] = i;
	}
	ll ind = 0;
	int sind = 0,tind=0;
	while(tind < t.length()){
		int nx = nxt[sind][t[tind] - 'a'];
		if(nx == -1){
			if(sind == 0){
				ind = -1;
				break;
			}
			ind += s.length() - sind;
			sind = 0;
		}
		else{
			ind += nx - sind + 1;
			sind = (nx+1) %(s.length());
			++tind;
		}
	}
	cout << ind << '\n';
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
int main(){
  double N, M;
  cin >> N >> M;
  int A[(long)N];
  long double all=0;
  double ok;
  for(int i=0;i<N;i++){ 
    cin >> A[i];
    all+=A[i];
  }
  qsort(A , N , sizeof( int ), desc );
  ok=all/(4*M);
  for(int i=0;i<M;i++){
    if(A[i]<ok){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  
}

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


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

 vector<pair<int,int>> ab(N-1),px(Q);
 for(int i = 0;i < N-1;i++) {
   int a,b;
   cin >> a >> b;
   pair<int,int> q = make_pair(a,b);
   ab.at(i) = q;
 }

 for(int i = 0;i < Q;i++) {
   int p,x;
   cin >> p >> x;
   pair<int,int> q = make_pair(p,x);
   px.at(i) = q;
 }

 sort(ab.begin(),ab.end());
 
 long long ans[N+1] = {0};
 for(int i = 0;i < Q;i++) {
   pair<int,int> p = px.at(i);
   ans[p.first] += p.second;
 }

 

 for(int i = 0;i < N-1;i++) {
   pair<int,int> p = ab.at(i);
  //  cout << p.second << " " << p.first << endl;
   ans[p.second] += ans[p.first];
 }

 

  for(int i = 1;i <= N;i++) {
    cout << ans[i] << " ";
  }

  cout << endl;


}


Measured memory_bytes: 7040
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int r, l;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256