akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (int (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= int(n); ++(i))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define pb emplace_back
#define mp make_pair
#define getchar_unlocked getchar
# define TMP template<typename
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
inline void uin(ulli &n){
    register ulli c=gc();
    n=0;
    while(c<'0'||c>'9')
    c=gc();
    while(c<='9'&&c>='0'){
    n=n*10+c-'0';
    c=gc();}
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    string s;
    cin >> s;
    bool v=0;
    int len = 0 , mx = 0;
    fri(i,0,s.length()){
        if(s[i] == 'A' && v==0){
            len = i;
            v = 1;
        }
        if(s[i] == 'Z' && v){
            mx = max(mx , (i-len+1) );
        }
    }
    cout << mx;
}

// HASFJGHOGAKZZFEGA





















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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define ll long long int

int main() {

	IOS

	int n, m;
	cin >> n >> m;

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

	double at_least = (double) sum / (4*m);
	// sort(a, a+n, greater<int>());

	for (int i = 0; i < n; i++) {
		if (double(a[i]) >= at_least)
			m--;

		if (m == 0)
			break;
	}

	cout << (m == 0 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int c[26];

int main(void) {
    char ch;
    while( scanf( "%c", &ch ) != EOF ) {
        if( 'a' <= ch && ch <= 'z' ){
            c[ ch - 'a' ]++;
        } else if( 'A' <= ch && ch <= 'Z' ) {
            c[ ch - 'A' ]++;
        }
    }
    for( int i = 0; i < 26; i++ ){
        printf( "%c : %d\n", 'a' + i, c[i] );
    }
    return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B;
  cin >> A >> B;
  int ans = 1;
  int count = 0;
  if(B==1)
  {
    cout << 0 << endl;
    return 0;
  }
  for(int i=0;i<30;i++)
  {
    if(ans<B)
    {
      ans += A-1;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
       x=n%10;
   if(x==2 || x==4 || x==5 || x==7 || x==9 )
    cout<<"hon"<<endl;
    else if(x==0 || x==1 || x==6 || x==8 )
    cout<<"pon"<<endl;
   else if(x==3  )
    cout<<"bon"<<endl;

   return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >>m;
    int a,b;
    vector<pair<int,int> > v;
    for (int i;i<n;i++){
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    int drink = 0;
    long long cost = 0;
    long long  move;
    for (int i=0;i<n;i++){
        //cout << v[i].first << " " << v[i].second << endl;
        move = min(v[i].second,(m-drink));
        cost += move * v[i].first;
        drink += move;
        //cout << cost << "  " << drink << endl;
        if (drink==m)break;
    }
    cout << cost << endl;

}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<deque>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<stack>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn =1200100;
typedef pair<ll,ll>p1;
typedef pair<pair<ll,ll>,ll>p2;
map<pair<pair<ll,ll>,ll>,ll>m1;
map<pair<ll,ll>,ll>m2;
const int MOD = 1e9;
const int N=351;
const int inf = 1000010;
typedef pair<char, int> PAIR;
map<string,int>mm;
ll a[maxn];
ll dp[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
	
		int ans = h/a;
		if(h%a != 0) {
			ans++;
		}
		
		System.out.println(ans);
		
	}
	
	
	

}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	int ans = 0;

	if (x <= 3) {
		ans += (4 - x) * 100000;
	}
	if (y <= 3) {
		ans += (4 - y) * 100000;
	}

	if (x == 1 && y == 1) {
		ans += 400000;
	}

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


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

bool compare(int a,int b){
  return a<b;//ascending
} 

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


    int d,t,s;
    cin>>d>>t>>s;
    int D=s*t;
    if((D)>=d){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }


  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, a, b; cin >> n >> a >> b;
    vint p(n);
    rep(i, n) cin >> p[i];
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    rep(i, n) {
        if(p[i] <= a) cnt1++;
        else if(p[i] <= b) cnt2++;
        else cnt3++;
    }
    cout << min({cnt1, cnt2, cnt3}) << endl;
    return 0;
}


Measured memory_bytes: 256
import fractions

A = list(map(int, input().split())) 
a = A[0]
b = A[1]
c = A[2]
d = A[3]
aa = a-1
all = b-aa
cdiv = b//c - aa//c
ddiv = b//d - aa//d
cd_lcm = c*d // (fractions.gcd(c,d))

cddiv = b//cd_lcm - aa//cd_lcm

print(all-cdiv-ddiv+cddiv)

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

// int型からstring型に変換する(非負整数)
string to_s(int n){
	string s;
	do{
		s.push_back( (n%10)+'0' );
		n /= 10;
	}while( n != 0 );
	reverse( s.begin() , s.end() );
	return s;
}

// string型からint型に変換する(非負整数)
int to_i(string s){
	int n = 0;
	for(int i=0 ; i < s.size() ; i++ ){
		n = (n * 10) + s[i] - '0';
	}
	return n;
}

int main(){
	string N;
	while( cin >> N, N != "0000" ){
		if( N[0] == N[1] && N[1] == N[2] && N[2] == N[3] ){
			cout << "NA" << endl;
		}else{
			int ans = 0;
			while( N != "6174" ){
				string L = N, S = N;
				sort(L.rbegin(), L.rend());
				sort(S.begin(), S.end());
				N = to_s(to_i(L) - to_i(S));
				while( N.size() < 4 ) N = "0" + N;
				ans++;
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1220
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
      int n;
      Scanner sc=new Scanner(System.in);
      n=sc.nextInt();
      int a[]=new int[n];
      long sum=0;
      for(int i=0;i<n;i++)
      a[i]=sc.nextInt();
      for(int i=0;i<n-1;i++)
      for(int j=i+1;j<n;j++)
      sum+=(a[i]*a[j]);
      System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    std::sort(D.begin(), D.end());
    int u = 1, l = 0, d = 1;
    ll ans = 1;
    int i = 1;
    while (i < N) {
        l = 0;
        while (D[i] == d) {
            l++;
            i++;
        }
        if (l == 0) {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * modpow(u, l, MOD_BIG2)) % MOD_BIG2;
        d++;
        u = l;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        if(a==b) System.out.println(c);
        else if(b==c) System.out.println(a);
        else System.out.println(b);


    }
}


Measured memory_bytes: 21844
using System;

namespace _052_FactorialII
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				int n = int.Parse (Console.ReadLine ());

				if (n == 0)
				{
					break;
				}

				int digitCount = 0;

				for (int lp = 5; lp <= n; lp += 5)
				{
					int tmp = lp;

					while (tmp % 5 == 0)
					{
						tmp /= 5;
						digitCount++;
					}
				}

				Console.WriteLine (digitCount);
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n, m) for (int i = n; i < (int) m; i++)

using namespace std;

vector<int> a;
int N;

int culc(int x)
{
	int res = 0;
	rep(i, N) res += (a[i] - x) * (a[i] - x);
	return res;
}

int main()
{
	cin >> N;
	a.resize(N);
	rep(i, N) cin >> a[i];
	int res = 1e9;
	reps(i, -100, 101) {
		res = min(res, culc(i));
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3

a, b, c, d, e, f = map(int, input().split())

amax = f // (a * 100)
bmax = f // (b * 100)

maxd = 0
maxw = min(a, b) * 100
maxs = 0
for i in range(amax + 1):
    for j in range(bmax + 1):
        if i == j == 0:
            continue
        w = i * a + j * b
        if w * 100 > f:
            continue
        cmax = (f - w * 100) // c
        dmax = (f - w * 100) // d
        for k in range(cmax + 1):
            for l in range(dmax + 1):
                s = k * c + l * d
                if w * e < s:
                    break
                if f < w * 100 + s:
                    break
                div = s / (w * 100 + s)
                if maxd < div:
                    maxw = w * 100 + s
                    maxs = s
                    maxd = div

print(maxw, maxs)


Measured memory_bytes: 3064
#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};

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  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;
  }
  // for prime mod
  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; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  vector<mint> dp(s + 3010, 0);
  mint ans = 0;
  rep(i, n) {
    dp[0] += 1;
    for(int j = s; j >= 0; j--) dp[j + a[i]] += dp[j];
    ans += dp[s];
  }
  cout << ans << endl;
}

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

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

int H, W;
string s[105];

int dp[105][105];
void dfs(int h, int w, int c) {
    if (dp[h][w] > c) dp[h][w] = min(dp[h][w], c);
    else return;

    rep(dir, 2) {
        int nh = h + dx[dir];
        int nw = w + dy[dir];

        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;

        if (s[h][w] == '.' && s[nh][nw] == '#') {
            dfs(nh, nw, c+1);
        } else {
            dfs(nh, nw, c);
        }
    }
}

int main(){
    cin >> H >> W;
    rep(i, H) cin >> s[i];

    rep(i, H)rep(j, W) dp[i][j] = 1001001001;
    if (s[0][0] == '.') dfs(0, 0, 0);
    else dfs(0, 0, 1);
    cout << dp[H-1][W-1] << endl;
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int>x(n), y(n), h(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> y[i] >> h[i];
	}
	for(int i = 0; i <= 100; ++i){
		for(int j = 0; j <= 100; ++j){
			int th = 1234567890;
			int dh = 0;
			for(int k = 0; k < n; ++k){
				dh = max(dh, th - abs(x[k] - i) - abs(y[k] - j) - h[k]);
			}
			th -= dh;
			for(int k = 0; k < n; ++k){
				if(h[k] != max(0, th - abs(x[k] - i) - abs(y[k] - j))) goto END;
			}
			cout << i << " " << j << " " << th << "\n";
			return 0;
		END:;
		}
	}
	
	cout << "Fuck you\n";
	
	return 0;
}



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;

int N,L;

int main()
{
    cin >> N >> L;
    int minv = inf;
    int tot = 0;
    int ate = 0;
    _for(i,0,N){
        int aji = L + i;
        if(abs(aji) < minv){
            minv = abs(aji);
            ate = aji;
        }
        tot += aji;
    }
    cout << tot - ate <<endl;

    return 0;
}

Measured memory_bytes: 256
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

int f (int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, res = 1e9;
	cin >> n;
	for (int i = 1; i < n; i++)
		res = min(res, f(i) + f(n - i));
	cout << res << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,bl,ans=0;
	cin >> n;
	cin >> bl;
	ans = bl;
	for(int i = 2; i < n; i++){
		int t;
		cin >> t;
		ans += min(bl,t);
		bl = t;
	} 
	ans += bl;
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

struct BIT {
    private:
    vector<ll> bit;
    ll N;

    public:
    BIT(ll size) {
        N = size;
        bit.resize(N + 1);
    }

    // 一点更新です
    void add(ll a, ll w) {
        for (ll x = a; x <= N; x += x & -x) bit[x] += w;
    }

    // 1~Nまでの和を求める。
    ll sum(ll a) {
        ll ret = 0;
        for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
};

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<P> tmp(n);
    REP(i, n) {
        cin >> a[i];
        tmp[i].first = a[i], tmp[i].second = i;
    }
    sort(ALL(tmp));
    REP(i, n) {
        a[tmp[i].second] = i+1;
    }

    int ans = 0;
    REP(i, n) {
        if(i % 2 == 0) {
            if(a[i] % 2 != 1) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"600
300
220
420
" => r"520",

r"555
555
400
200
" => r"755",

r"549
817
715
603
" => r"1152"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
        c: i32,
        d: i32
    }

    (cmp::min(a, b) + cmp::min(c, d)).to_string()
}


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

int main(){
	int n,sum=0;
	std::cin>>n;

	std::vector<int> v(n);
	for (int& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			sum += v[i] * v[j];
		}
	}

	std::cout<<sum<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
ll dp[3009][3009],b[3009][3009];
void best(ll x,ll y)
{
    if(x==s.size()||y==t.size())
        return void(dp[x][y]=0);
    ll &r=dp[x][y];
    if(r!=-1)
        return;
    best(x+1,y);
    best(x,y+1);
    if(s[x]==t[y])
    {
        best(x+1,y+1);
        r=dp[x+1][y+1]+1;
        b[x][y]=2;
        return;
    }
    if(dp[x+1][y]>dp[x][y+1])
    {
        r=dp[x+1][y];
    }
    else
    {
        r=dp[x][y+1];
        b[x][y]=1;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    memset(dp,-1,sizeof dp);
    best(0,0);
    ll x=0,y=0;
    while(x<s.size()&&y<t.size())
    {
        if(s[x]==t[y])
            cout<<s[x];
        if(b[x][y]==2)
            x++,y++;
        else if(b[x][y])
            y++;
        else
            x++;
    }
    return 0;
}


Measured memory_bytes: 145360
/*
 * atcoder/dp/g2.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100010;
int n, m;
vector<int> G[MAX];

vector<int> dp(MAX, -1);
vector<bool> visited(MAX, false);

int dfs(int v) {
  int &cc = dp[v];
  if (visited[v] && cc == -1) {
    // loop
    return -1;
  }
  if (~cc) return cc;
  visited[v] = true;
  int res = 0;
  for (auto&& u: G[v]) {
    int ret = dfs(u);
    if (ret == -1) return -1;
    chmax(res, ret + 1);
  }

  return cc = res;
}

void solve() {
  int a,b;
  cin >> n >> m;
  loop(i,0,m) {
    cin >> a >> b;
    a--;b--;
    G[b].push_back(a);
  }

  int res = 0;
  loop(i,0,n) {
    int ret = dfs(i);
    if (ret == -1) { cout << -1 << endl; return; }
    chmax(res, ret);
  }

  cout << res << endl;
}


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

const int MAX = 1e6+10;
int cnt[MAX];

int main(){
    int n; scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= 1000000; i++){
        for (int j = 1; j<=1000000 && i*j<=1000000; j++){
            cnt[i*j]++;
        }
    }
    for (int i = 1; i <= n-1; i++){
        ans += cnt[n-i];
    }
    printf("%d\n", ans);
    return 0;
}


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


int H1, H2, M1, M2, K;
int main() {
    
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int ans = 0;
    if (H1 * 60 + M1 < H2 * 60 + M2) ans = (H2 * 60 + M2) - (H1 * 60 + M1) - K;
    else ans = ((H2 + 24) * 60 + M2) - (H1 * 60 + M1) - K;
    if (ans < 0)ans = 0;
    
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3632
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    a_list = list(filter((1).__ne__, a_list))

    if 0 in a_list:
        print('0')
        return

    result = 1

    for a in a_list:
        result = result * a

        if result > 10**18:
            print('-1')
            return

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21720
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    int a[100005];
    int b[100005];
    int c[100005];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    ll ans=0;
    for(int i=0; i<n; i++){
        int x=b[i];
        long long k1=lower_bound(a,a+n,x)-a;
        long long k2=n-(upper_bound(c,c+n,x)-c);
        ans += k1*k2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4740
n = gets.chomp.to_i
hn = gets.chomp.split(" ").map(&:to_i)

cnt = [0] * n

(1..n-1).each do |i|
	i = n - 1 - i
	cnt[i] += (cnt[i+1] + 1) if hn[i] >= hn[i+1]
end

puts cnt.max

Measured memory_bytes: 10500
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn z_algorithm(s: &[char]) -> Vec<usize> {
    let n = s.len();
    let mut prefix = vec![0; n];
    prefix[0] = n;
    let mut i = 1;
    let mut j = 0;
    while i < n {
        while i + j < n && s[j] == s[i + j] {
            j += 1;
        }
        prefix[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while i + k < n && k + prefix[k] < j {
            prefix[i + k] = prefix[k];
            k += 1;
        }
        i += k;
        j -= k;
    }
    prefix
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut s: chars,
    }
    let mut ans = 0usize;
    for i in 0..n {
        let z = z_algorithm(&s[i..]);
        let m = (1..n-i).map(|k|min(k, z[k])).max().unwrap_or(ans);
        ans = max(ans, m);
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4476
#include <iostream>
#include <string>
using namespace std;
int main(){

	string r;
	cin>>r;
	int n,count1=0,count2=0;
	cin>>n;
	string rings;
	for(int i=0;i<n;i++){
		cin>>rings;
		rings=rings+rings;
		count1=rings.find(r);
		if(count1==string::npos){}
		else{
			count2++;
		}
	}
	cout<<count2<<endl;

return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 int main() {
	int X,t;
   cin>>X>>t;
   if(X>=t){ cout<<X-t;}
   else{cout<<0;}
  
   }
	

Measured memory_bytes: 256
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int N,M;
char A[55][55],B[55][55];

int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%d", &N, &M);
    for(int i=0;i<N;i++) scanf("%s", &A[i]);
    for(int i=0;i<M;i++) scanf("%s", &B[i]);
    bool now = false;
    for(int i=0;i<N&&!now;i++)
    {
        int index = i,j=1, loc = strstr(A[index], B[0])-A[index];
        if(loc<0) continue;
        else now = true, index++;
        for(j;j<M&&now;j++)
        {
            int cnt = strstr(A[index],B[j])-A[index];
            if(cnt>=0)
            {
                while(cnt!=loc && cnt<N && cnt>=0)
                {
                    cnt = strstr(A[index]+cnt+1, B[j]) - A[index];
                }
                if(cnt==loc) index++;
                else now = false;
            }
            else now = false;
        }
        if(j!=M) now = false;
    }
    if(now) puts("Yes");
    else puts("No");
    system("pause");
}


Measured memory_bytes: 504
import java.util.*
fun getValue(from:Int, to:Int) : Long{
    var result = 0L
    repeat(36){
        if(35 - it <= to && 35 - it >= from){
            result = result.shl(1) or 0
        }
        else {
            result = result.shl(1) or 1
        }
    }
    return result
}

fun getVertical(column : Int, h : Int, w : Int) : Long {
    var result =0L
    repeat(h*w){
        val modValue = it % w
        if(modValue == column){
            result  = result.shl(1) or 0
        }
        else {
            result = result.shl(1) or 1
        }
    }
    return result
}

fun countOne(value : Long) : Int {
    var result = 0
    var countValue = value

    while(countValue > 0){
        val checkValue = countValue.and(1L)
        if(checkValue > 0){
            result += 1
        }
        countValue = countValue.shr(1)
    }
    return result
}

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val H = reader.nextInt()
    val W = reader.nextInt()
    val K = reader.nextInt()
    var value = 0L

    repeat(H){
        val line = reader.next()
        line.forEach {
            value = value.shl(1).or(if(it == '.') 0 else 1)
        }
    }

    //println(value)
    var results = mutableListOf<Long>()
    results.add(value)
    repeat(H){
        val value = getValue(it*W, it * W + W - 1)
        val changed = results.map { it.and(value) }
        results.addAll(changed)
    }
    //println(results)
    repeat(W){
        val value = getVertical(it, H, W)
        //println(value)
        val changed = results.map{it.and(value)}
        results.addAll(changed)
    }

    //println(results)
    //println(results.filter { countOne(it) == K })
    println(results.filter { countOne(it) == K }.size)
}

Measured memory_bytes: 37488
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a[305][305];
int cnt[305];
bool f[305];

int main(){
	int n, m;
	
	cin >> n >> m;
	
	REP(i,n){
		REP(j,m){
			cin >> a[i][j];
		}
	}
	
	int mi = n;
	
	REP(i,m){
		
		REP(j,m){
			cnt[j] = 0;
		}
		
		REP(j,n){
			REP(k,m){
				if (f[a[j][k]-1] == 0){
					cnt[a[j][k]-1]++;
					break;
				}
			}
		}
		
		int ma = 0;
		int ma_n;
		
		REP(j,m){
			if (ma <= cnt[j]){
				ma_n = j;
				ma = cnt[j];
			}
		}
		
		f[ma_n] = 1;
		
		mi = min(mi,ma);
	}
	
	cout << mi << endl;
	
	return 0;
}

Measured memory_bytes: 640
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a>>b>>c;
    if(abs(a-b)>abs(c-a)) cout<<"B"<<endl;
    else cout<<"A"<<endl;
    return 0;
}


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

using namespace std;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

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

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	vector<int> a(M), b(M);

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	int bridge = 0;

	for (int j = 0; j < M; j++) {
		UnionFind tree(N);
		bool ok = true;
		for (int i = 0; i < M; i++) {
			if (i != j) tree.unite(a[i], b[i]);
		}
		for (int i = 0; i < N - 1; i++) {
			if (tree.root(i) != tree.root(i + 1)) ok = false;
		}
		if (!ok) bridge++;
	}

	cout << bridge << endl;


	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> vec(n);
    rep(i,n){
        cin >> a.at(i);
        vec.at(a.at(i)-1) = i+1;
    }
    rep(i, n){
        cout << vec.at(i) << ' ';
    }
    return 0;
}


Measured memory_bytes: 4052
#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() {
    string s;
    cin >> s;

    int count1=0, count2=0;
    rep(i, s.size()) {
        if ((i%2)!=(s.at(i)-'0')) count1++;
        if (((i+1)%2)!=(s.at(i)-'0')) count2++; 
    }

    if (count1<count2) cout << count1 << endl;
    else    cout << count2 << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;

int main() {
    int d, l, dp[10005];
    cin >> d >> l;
    fill(dp,dp+d+1,IINF);
    dp[0] = 0;
    for(int i=0;i<d;i++){
        dp[i+1] = min(dp[i+1],dp[i]+1);
        if(i+l<=d) dp[i+l] = min(dp[i+l], dp[i]+1);
    }
    cout << dp[d] << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N;
        int D = 0;
            cin >> N;
        vector<int> p(N);
            for(int i = 0; i < N; i++){
                
                cin >> p.at(i);
                
                if(p.at(i) == i + 1){
                    
                }else{
                    D += 1;
                }
            }
                //cout << D;
                if(D <= 2){
                    cout << "YES";
                }else{
                    cout << "NO";
                }
    return 0;}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k; cin>>k;
  if (gcd(k, 10) != 1) {
    cout << -1 << endl;
  } else {
    int ans = 1;
    int m = 7 % k;
    while (m%k != 0) {
      m = (m*10+7) % k;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    v.at(a)++; v.at(b)++;
  }
  rep(i, n){
    if(v.at(i) % 2 == 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3732
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
#define _CRT_SECURE_NO_WARNINGS
int N,Z,W;
int a[2010];
int ans = 0;
int dp[2010][2002][2] = {};
int Score(int now,int p,bool Xturn) {
	if (dp[now][p][Xturn]!=-1) {
		return dp[now][p][Xturn];
	}
	int r;
	if (Xturn) {
		r = 0;
		for (int i = 1; i <= N - now; i++) {
			r = max(r, Score(now + i,now+i-1,false));
		}
		r = max(r, abs(a[N] - a[p]));
	}
	else {
		r = 1000000010;
		for (int i = 1; i <= N - now; i++) {
			r = min(r, Score(now + i, now + i - 1, false));
		}
		r = min(r, abs(a[N] - a[p]));
	}
	return dp[now][p][Xturn]=r;
}
int main() {

	scanf("%d %d %d", &N,&Z,&W);
	for (int i = 1; i <= N;i++) {
		scanf("%d",&a[i]);
		for (int j = 1; j <=N+1 ;j++) {
			dp[j][i][0] = -1;
			dp[j][i][0] = -1;
		}
	}
	ans = abs(W-a[N]);
	for (int i = 1; i <= N-1;i++) {
		ans = max(ans,Score(1+i,i,false));
	}
	printf("%d\n",ans);
	return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const int N = 1e7 + 15;
int A[N];

 //m*(m+floor(n/m))*(floor(n/m)+1-m) - (floor(sqrt(n)))

int32_t main(){
	A[0] = 0, A[1] = 1;
	int n; cin >> n;
	for(int i = 2; i <= n; i++){
		A[i] += 1;
		for(int j = 1; i * j <= n; j++){
			A[i * j] += 1;
		}
	}
	
	for(int i = 1; i <= n; i++) A[i] = i * A[i] + A[i - 1];
	cout << A[n];
		
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    vector<ll> b(n, 0);

    vector<pair<ll, ll>> diff;

    REP(i, n) {
        cin >> a[i] >> b[i];
        diff.push_back(make_pair(b[i], a[i]));
    }

    sort(ALL(diff));


    ll time = 0;

    REP(i, n){
        if (time+diff[i].second > diff[i].first){
            cout << "No" << endl;
            return 0;
        }
        time += diff[i].second;
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 10588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n,k;
  cin >> n >> k;
  vector<int> h(n+k);
  rep(i,n){
    cin >> h[i];
  }
  vector<int> dp(n+k,1001001001);
  rep(i,k){
    dp[i] = abs(h[i]-h[0]);
  }
  rep(i,n-1){
    rep1(j,k){
      int way = dp[i] + abs(h[i+j]-h[i]);
      dp[i+j] = min(way,dp[i+j]);
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


template <class T, class U>
ll euclid_gcd(T a, U b){
    if(a < b)return euclid_gcd(b,a);
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}


int main(){
    ll n,m; cin >> n >> m;
    string s;cin >> s;
    string t;cin >> t;
    ll g = euclid_gcd(n,m);
    string s_c, t_c;
    for(int i = 0; i < n; i += n/g)s_c += s[i];
    for(int i = 0; i < m; i += m/g)t_c += t[i];
    debug(s_c);debug(t_c);
    cout << (s_c == t_c ? n*(m/g) : -1) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
	int x[3];

	scanf("%d", &x[0]);
	scanf("%d", &x[1]);
	scanf("%d", &x[2]);

	int tmp;

	if (x[0] >= x[1]) {
		tmp = x[0];
		x[0] = x[1];
		x[1] = tmp;
	}

	if (x[0] >= x[2]) {
		tmp = x[0];
		x[0] = x[2];
		x[2] = tmp;
	}

	if (x[1] >= x[2]) {
		tmp = x[1];
		x[1] = x[2];
		x[2] = tmp;
	}

	printf("%d\n", x[0] + x[1]);
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    int rem;
    rem = a%x;
    if(rem != 0){
        a += x-(a%x);
    }
    rem = b%x;
    if(rem != 0){
        b -= b%x;
    }
    if(a > b){
        cout << 0;
    }
    else{
        cout << (b-a)/x +1;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let t:String = read();
    let mut s = s.chars().collect::<Vec<char>>();
    s.sort();
    let mut t = t.chars().collect::<Vec<char>>();
    t.sort_by(|a, b| b.cmp(a));
    if s < t {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2160
r1,c1,r2,c2 = map(int,input().split())

n = [1]*(r2+c2+3)
mod = 10**9 + 7
for i in range(r2+c2+2):
    n[i+1] = (n[i]*((i+1)%mod))%mod

def calc(r,c):
    x = n[r+c]%mod
    y = (n[r]*n[c])%mod
    return (x*(pow(y,mod-2,mod)%mod))%mod

ans = calc(r2+1,c2+1)-calc(r2+1,c1)-calc(r1,c2+1)+calc(r1,c1)
ans %= mod

print(ans)

Measured memory_bytes: 82164