akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

bool isupperCase(char c){
    return (c>=65 && c<=90);
}

ll x;

ll get_ans(ll n){
    return n/x+1;
}

int main() {

    IO; 

    ll a,b;
    
    cin>>a>>b>>x;
    if(a==0){
        cout<<get_ans(b)<<endl;
        return 0;
    }
    cout<<get_ans(b)-get_ans(a-1)<<endl;
    

}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;
ll dp[55][5];  // dp[i][j]=風船をj個盛った状態でi個目の風船を受け取るまでの移動距離
int X[55], T[55];

const ll INF = 1e18;
bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    REP(i, N) { cin >> X[i] >> T[i]; }
    REP(i, N + 1) { REP(k, 4) dp[i][k] = INF; }
    dp[0][0] = 0;
    int nowt = 0;
    int nowx = 0;
    REP(i, N) {
        if (i == 0)
            nowt = 0;
        else
            nowt = T[i - 1];
        if (i == 0)
            nowx = 0;
        else
            nowx = X[i - 1];
        REP(j, 4) {
            //いったん帰る
            {
                int need = nowx * (j + 1);
                need += X[i];
                if (nowt + need <= T[i] && dp[i][j] + nowx + X[i] < dp[i + 1][1]) {
                    dp[i + 1][1] = dp[i][j] + nowx + X[i];
                }
            }

            //そのまま取りに行く
            if (j <= 2) {
                int need = abs(X[i] - nowx) * (j + 1);
                if (nowt + need <= T[i] && dp[i][j] + abs(X[i] - nowx) < dp[i + 1][j + 1]) {
                    dp[i + 1][j + 1] = dp[i][j] + abs(X[i] - nowx);
                }
            }
        }
    }
    ll ans = INF;
    REP(j, 4) {
        if (dp[N][j] < INF) {
            ans = min(ans, dp[N][j] + X[N - 1]);
        }
    }
    if (ans < INF) {
        cout << "OK"
             << " " << ans << endl;
    } else {
        cout << "NG ";
        FOR(i, 1, N + 1) {
            bool ok = false;
            REP(j, 4) {
                if (dp[i][j] < INF) ok = true;
            }
            if (!ok) {
                cout << i << endl;
                break;
            }
        }
    }
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define MAXN 100005
#define ll long long

using namespace std;
 

int dp[MAXN];
vector<int> viz[MAXN];


int dfs(int node)
{
	if(dp[node] >= 0)
		return dp[node];

	dp[node] = 0;

	int resp = 0;
	for (int i = 0; i < viz[node].size(); ++i)
	{
		resp = 1 + dfs(viz[node][i]);
		dp[node] = max(dp[node], resp);
	}

	return dp[node];
}





int main()
{

	int n, aresta;
 	cin >> n >> aresta;


 	memset(dp, -1, sizeof(dp));
 
 	int num1, num2;
 	for (int i = 0; i < aresta; ++i)
 	{
 		cin >> num1 >> num2;
 		viz[num1].push_back(num2);

 	}


 	int resp = 0;

 	for (int i = 1; i <= n; ++i)
 	{
 		resp = max(resp, dfs(i));
 	}


 	cout << resp << endl;






 
    return 0;
}

Measured memory_bytes: 11300
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


signed main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(0);


	int n; cin >> n;
	vector<int> L(n + 1);
	vector<int> R(n + 1);

	rep(i, n)cin >> L[i] >> R[i];

	//L,Rは区間[0,0]を含んでいる

	sort(ALL(R));
	sort(ALL(L), greater<int>());

	int ans = 0;
	int tmp = 0;
	rep(i, n + 1) {
		tmp += 2 * (L[i] - R[i]);
		ans = max(ans, tmp);
	}

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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vvi a(n, vi(n, 0)), dp(n, vi(n, 0));
    rep(i, n) rep(j, n) cin >> a[i][j], dp[i][j] = a[i][j];
    const long long WeightINF = numeric_limits<long long>::max()/2-1;

    rep(k, n) rep(i, n) rep(j, n){
        if(k == i || k == j || i == j || dp[i][k] == WeightINF || dp[k][j] == WeightINF) continue;
        if(dp[i][k] + dp[k][j] == a[i][j]) dp[i][j] = WeightINF;
        else if(dp[i][k] + dp[k][j] < a[i][j]){
            cout << "-1" << endl;
            return 0;
        }
    }

    ll ans = 0;
    rep(i, n) rep(j, n) if(dp[i][j] != WeightINF) ans += dp[i][j];
    cout << ans/2 << endl;
}

Measured memory_bytes: 4740
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	std::string str;
	int okada[200003];
	int a = 0,b = 0, count = 0;
	std::cin >> a>>b;
	if (b >= a) {
		std::cout << a<<std::endl;
	}
	else {
		std::cout << a - 1<<std::endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

int main()
{
    ll n, k, a, b;
    cin >> n >> k;
    if (n < k)
    {
        a = n;
        b = abs(a - k);
    }
    else
    {
        a = n % k;
        b = abs(a - k);
    }

    cout << min(a, b) << endl;
    return 0;
}


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

#define L 50

int main() {
	static int aa[26];
	static char cc[L + 1];
	int n, c, l;

	scanf("%d", &n);
	memset(aa, L + 1, sizeof aa);
	while (n--) {
		static char s[L + 1];
		static int kk[26];
		int i;

		scanf("%s", s);
		l = strlen(s);
		memset(kk, 0, sizeof kk);
		for (i = 0; i < l; i++)
			kk[s[i] - 'a']++;
		for (c = 0; c < 26; c++)
			if (aa[c] > kk[c])
				aa[c] = kk[c];
	}
	l = 0;
	for (c = 0; c < 26; c++)
		while (aa[c]--)
			cc[l++] = c + 'a';
	printf("%s\n", cc);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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



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

int main() {
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  
  if(S == U){
    cout << A-1 << " " << B << endl;
  }
  
  else{
    cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int i;
	for(i=0;i<k;i++){
		if(i%2==0){
			if(a%2==1){
				a--;
			}
			b=b+a/2;
			a=a/2;
		}else{
			if(b%2==1){
				b--;
			}
			a=a+b/2;
			b=b/2;
		}
	}
	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

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

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	map<ll, ll> ma;
	rep(i, n) {
		ll temp;
		cin >> temp;
		ma[-temp]++;
	}
	ll a = 0;
	for (auto itr : ma) {
		if (itr.second >= 2) {
			if (a != 0) {
				cout << a * (-itr.first);
				return 0;
			}
			else {
				if (itr.second >= 4) {
					cout << itr.first*itr.first;
					return 0;
				}
				else {
					a = (-itr.first);
				}
			}
		}
	}
	cout << 0;
	
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    int ans=0;
    for(int i=2;i<=sqrt(n);i++){
        int x=0;
        while(n%i==0){
            n/=i;
            x++;
        }
        for(int i=1;x>=i;i++){
            x-=i;
            ans++;
        }
    }
    if(n>1)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int n; cin >> n;
	ll sum = 0;
	vector<ll> x(n);
	rep(i, n) {
		cin >> x[i];
		sum += x[i];
	}
	sum /= n;
	ll s1 = sum + 1;
	ll s2 = sum - 1;
	ll y = 0, z = 0, e = 0;

	rep(i, n) {
		y += pow(sum - x[i], 2);
		z += pow(s1 - x[i], 2);
	}
	if (y < z) {
		cout << y << endl;
	}
	else
	cout << z << endl;
	return 0;
}

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


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

    ll max = 0;
    ll x;
    if(n >= b){
        x = b - 1;
    }
    else{
        x = n;
    }
    while(x <= n){
        ll Ax = a * x;
        ll value = Ax / b - a*(x/b);
        if(value > max){
            max = value;
        }
        break;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3636
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const C = input[2]
    const X = input[3]

    let count = 0
    for(let a = 0; a <= A; a++){
        for(let b = 0; b <= B; b++){
            for(let c = 0; c <= C; c++){
                let sum = a * 500 + b * 100 + c * 50
                if(sum === X) count++
            }
        }
    }
    console.log(count)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int a[105], dp[105][maxn];

void add(int& a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

void sub(int& a, int b) {
    a -= b;
    if (a < 0) a += mod;
}

int main() {
    int n, k;
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    REP(i, n + 1) dp[i][0] = 1;
    REP(i, k + 1) dp[0][i] = 1;
    REPP(i, 1, n + 1) REPP(j, 1, k + 1) {
        add(dp[i][j], dp[i][j - 1]);
        add(dp[i][j], dp[i - 1][j]);
        sub(dp[i][j], j > a[i - 1] ? dp[i - 1][j - a[i - 1] - 1] : 0);
    }
    int ans = dp[n][k];
    sub(ans, dp[n][k - 1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
const int mod1 = 1000000007;
const int mod2 = 998244353;

int main()
{
	optimize
	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
	#endif

    int n,k;
    cin>>n>>k;
    vector<int>p(n);
    forn(i,n) cin>>p[i];
    vector<int>c(n);
    forn(i,n) cin>>c[i];

    vector<lli>rep(n);
    vector<lli>repv(n);
    lli ans = LLONG_MIN;
    forn(i,n)
    {
    	int j = i;
    	int cnt = 0;
    	lli t = 0LL;
    	// set<int>prev;
    	vector<int>prev(n, 0);
    	while(prev[j] == 0)
    	{
    		t += c[j];
    		cnt++;
    		if(cnt <= k)
    			ans = max(ans, t);
    		// prev.insert(j);
    		prev[j] = 1;
    		j = p[j]-1;
    	}
    	// debug(cnt);
    	// if(cnt+1<=k)
    	// 	ans = max(ans, t + c[i]);
    	rep[i] = (lli)cnt;
    	repv[i] = t;
    }

    // debug(ans);
    forn(i,n)
    {
    	// debug(rep[i]);
    	if(k < rep[i] || repv[i]<0)
    		continue;
    	lli t = repv[i]*(k/rep[i]-1);
    	// debug(t);
    	ans = max(ans, t);
    	int x = i;
    	forn(tt,k%rep[i]+rep[i])
    	{
    		t += c[x];
    		ans = max(ans, t);
    		x = p[x]-1;
    	}
    }

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

Measured memory_bytes: 3708
s=list(input())
n=len(s)
ans=[0]*n

f=0
for i in range(n):
    if s[i]=='R':
        f+=1
    else:
        if f>0:
            ans[i-1]+=(f+1)//2
            ans[i]+=f//2
            f=0
f=0
for i in range(n):
    if s[n-1-i]=='L':
        f+=1
    else:
        if f>0:
            ans[n-i]+=(f+1)//2
            ans[n-1-i]+=f//2
            f=0

for i in range(n-1):
    print(ans[i],end=' ')
print(ans[n-1])


Measured memory_bytes: 5552
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e6 + 5;

int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		int n, k;
		cin >> n >> k;
		lli a[n];
		for(int i=0;i<n;i++) cin >> a[i];
		sort(a, a+n);
		lli ans = 0;
		for(int i=0;i<k;i++) ans+=a[i];
		cout << ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

#define ARR_MAX 100000
#define BUF_SIZE (ARR_MAX*12)

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array_half(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        arr[i] /= 2;
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

// assume that a <= b
uint64_t gcd(uint64_t a, uint64_t b) {
    if(a==0) return b;
    return gcd(b%a, a);
}

int desc(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main(void) {
    int size, ulimit;
    int arr[ARR_MAX];
    get_int2(&size, &ulimit);
    fget_array_half(arr, size);
    int i;
    qsort(arr, size, sizeof(int), desc);

    uint64_t res = arr[0];
    int prev = arr[0];
    for(i = 1; i < size; i++) {
        int cur = arr[i];
        if(cur == prev) continue;
        // ensure that arr[i] <= res
        uint64_t g = gcd(cur, res);
        res = (res/g)*cur; // calc lcm
        prev = cur;
        // too big..
        if(res > ulimit) break;
    }
#ifdef DEBUG
    printf("ans: %llu(lcm)*(odd number)\n", res);
#endif
    if(res > ulimit) { printf("0\n"); return 0; }
    for(i = 0; i < size; i++) {
        int m = res / arr[i];
        // if even, No answer
        if(!(m%2)) { printf("0\n"); return 0; } 
    }
    uint64_t div = (uint64_t)ulimit/res;
    // answer should be integer
    printf("%d\n", (int)(div+1)/2);
    return 0;
}

Measured memory_bytes: 1788
#include <fstream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXF = 3000;

bool water[1 + MAXF], sugar[1 + MAXF];

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int a, b, c, d, e, f;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    for (int i = 0; i * a * 100 <= f; i++)
        for (int j = 0; i * a * 100 + j * b * 100 <= f; j++)
            water[i * a * 100 + j * b * 100] = true;
    for (int i = 0; i * c <= f; i++)
        for (int j = 0; i * c + j * d <= f; j++)
            sugar[i * c + j * d] = true;
    int x = a * 100, y = 0;
    for (int i = 100; i <= f; i += 100)
        for (int j = 1; i + j <= f; j++)
            if ((i / 100) * e >= j && water[i] && sugar[j] && i * y < j * x) {
                x = i;
                y = j;
            }
    printf("%d %d\n", x + y, y);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
    while(1){
        int n,s,w,q;
        cin >> n >> s >> w >> q;
        if(n == 0) break;
        
        vector<lli> a(n);
        int g = s;
        for(int i=0; i<n; i++) {
            a[i] = (g/7) % 10;
            if( g%2 == 0 ) { g = (g/2); }
            else           { g = (g/2) ^ w; }
        }

        lli ans = 0;
        if(q==2 or q==5){
            vector<vector<lli>> dp(n+1, vector<lli>(q, 0));
            lli nzcnt = 0;
            for(int i=0; i<n; i++){
                if(a[i] != 0) nzcnt++;
                if(a[i]%q == 0) ans+=nzcnt;
            }
        }else{
            a.push_back(0);
            reverse(a.begin(), a.end());
            vector<lli> acc(n+1, 0);
            lli pow10 = 1;
            for(int i=0; i<n; i++){
                acc[i+1] = (acc[i] + pow10*a[i+1]) %q;
                pow10 = 10*pow10 %q;
            }
            map<lli, lli> subs;
            for(int i=0; i<n+1; i++){
                if(a[i] != 0){
                    ans += subs[acc[i]];
                }
                subs[acc[i]]++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll factorial(int a){
    ll num = 1;
    rep(i, 1, a+1){
        num *= i;
        num %= mod;
    }
    return num;
}
int main(){
    int n, m;
    cin >> n >> m;
    if(n == m){
        ll ans = 2*(factorial(n)*factorial(m)%mod);
        ans %= mod;
        cout << ans << endl;
        return 0;
    }
    int p = max(n, m);
    int q = min(n, m);
    if(p-q>1){
        cout << 0 << endl;
        return 0;
    }else{
        ll ans = (factorial(n)*factorial(m)%mod);
        cout << ans << endl;
        return 0;
    }
}

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

int main(){
    string S;
    cin>>S;
    ll res=0;
    ll length=S.size();
    for(ll i=0;i<length;i++){
        if(S[i]!=S[length-1-i])res++;
    }
    cout<<res/2;
    return 0;
}

Measured memory_bytes: 3556
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

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

  int res = 0;
  rep(i, n - 2) res += min(b[i], b[i + 1]);
  res += b[0] + b[n - 2];

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>

std::string s, t;

int dp[3001][3001];

int lcs(int i, int j) {
  if (i == s.length()) return 0;
  if (j == t.length()) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  if (s[i] == t[j])
    return dp[i][j] = 1 + lcs(i+1, j+1);
  return dp[i][j] = std::max(lcs(i+1, j), lcs(i, j+1));
}

int main() {
  std::memset(dp, -1, sizeof(dp));
  std::cin >> s >> t;
  int i = 0, j = 0;
  std::string result;
  while (i < s.length() && j < t.length()) {
    if (s[i] == t[j]) {
      result += s[i];
      ++i; ++j;
    } else {
      const auto c0 = lcs(i+1, j);
      const auto c1 = lcs(i, j+1);
      if (c0 >= c1) ++i;
      else ++j;
    }
  }
  std::cout << result << '\n';
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);







int b[22],a;

int main()
{
//    FAST();

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

    int i,j,m,n,c,ans=0;
    S("%d %d %d",&n,&m,&c);
    for(i=1;i<=m;i++)
    {
        S("%d",&b[i]);
    }
    int cnt;
    for(i=1;i<=n;i++)
    {
        cnt=c;
        for(j=1;j<=m;j++)
        {
            S("%d",&a);
            cnt+=(a*b[j]);
        }
        if(cnt > 0)
        {
            ans++;
        }
    }
    P("%d",ans);
    return 0;
}







LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a + 3);
	int ans = 1000000;
	for(int x = -100; x <= 100; x++){
		int tmp = 0;
		for(int i = 0; i < 3; i++){
			if(a[i] > x){
				tmp += a[i] - x;
			}else{
				tmp += (x - a[i] + 1)/2 + ((x^a[i])&1);
			}
		}
		ans = min(ans, tmp);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
char S[300000];
int arr[300000];
int main(){
  int i, j, k, res, tmp;
  rd(N);
  rd(S);
  arr[0] = 0;
  for(i=0;i<N;i++){
    arr[i+1] = arr[i];
    if(S[i]=='#'){
      arr[i+1]++;
    }
  }
  res = 1073709056;
  for(i=0;i<N+1;i++){
    tmp = arr[i] + (N-i) - (arr[N]-arr[i]);
    chmin(res, tmp);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190309-1 [beta]

// --- original code ---
// int N;
// char S[300000];
// int arr[300000];
// {
//   int i, j, k;
//   int res, tmp;
//   rd(N,S);
// 
//   arr[0] = 0;
//   rep(i,N){
//     arr[i+1] = arr[i];
//     if(S[i]=='#') arr[i+1]++;
//   }
// 
//   res = int_inf;
//   rep(i,N+1){
//     tmp = arr[i] + (N-i) - (arr[N]-arr[i]);
//     res <?= tmp;
//   }
//   wt(res);
// }


Measured memory_bytes: 1280
//55
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>

using namespace std;

int n;
string na[1000],su[1000];
int d[1000],dd[1000];
map<string,int> m;
vector<int> ds[1000];
bool p[1000];
int cut[1000];

int dfs(int x){
  if(p[x])return 0;
  int s=p[m[su[x]]]?d[x]-dd[x]:0;
  p[x]=true;
  for(int i=0;i<ds[x].size();i++){
    s+=dfs(ds[x][i]);
  }
  return s;
}

bool cmp(int a,int b){
  return cut[a]>cut[b];
}

int main(){
  while(cin>>n,n){
    m.clear();
    for(int i=0;i<n;i++){
      cin>>na[i]>>d[i]>>su[i]>>dd[i];
      m[na[i]]=i;
    }
    for(int i=0;i<n;i++){
      ds[i].clear();
    }
    for(int i=0;i<n;i++){
      ds[m[su[i]]].push_back(m[na[i]]);
    }
    for(int i=0;i<1000;i++){
      fill(p,p+n,false);
      cut[i]=dfs(i);
    }
    deque<int> ef(n);
    for(int i=0;i<n;i++){
      ef[i]=i;
    }
    sort(ef.begin(),ef.end(),cmp);
    bool done[1000]={};
    int a=0;
    for(int i=0;i<n;i++){
      for(int nt=0;nt<n;nt++){
	if(!done[nt]){
	  if(done[m[su[nt]]]){
	    a+=dd[nt];
	    done[nt]=true;
	    goto next;
	  }
	}
      }
      while(done[ef[0]]){
	ef.pop_front();
      }
      a+=d[ef[0]];
      done[ef[0]]=true;
    next:
      ;
    }
    cout<<a<<endl;
  }
  return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    int n;
    int m;
    int sum=0;
    vector<int>C(N);
    for(int i=0;i<N;i++){
        C.at(i)=0;
    }
    for(int i=0;i<N;i++){
        cin>>n;
        for(int j=0;j<n;j++){
            cin>>m;
            C.at(m-1)=1;
        }
    }
    for(int i=0;i<N;i++){
        if (C.at(i)==0){
            sum++;
        }
    }
    cout<<sum<<endl;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    set<int> st;
    REP(i, n) {
        if (i != 0 && s[i] != s[i - 1]) {
            st.emplace(max(i, n - i));
        }
    }

    cout << (sz(st) == 0 ? n : *(st.begin())) << EOL;
}


Measured memory_bytes: 2128
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;


const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}



ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}




int main(){
ll k;cin>>k;
if(k%7 == 0){k/=7;}

if(gcd(10,k)!=1){cout<<-1;return 0;}


ll ans = 1;
ll v = 1%k;
while(v){
	v = (v*10 + 1)%k;
	ans++;
}


cout<<ans<<endl;













}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;


int main(void){

	int N; cin >> N;
	map<string, int> mp;

	REP(i,N){
		string s; cin >> s;
		mp[s]++;
	}

	vector<pair<int, string>> v;
	for(auto a:mp){
		v.push_back(make_pair(-a.second, a.first));
	}

	SORT(v);

	int tmp = v.front().first;

	REP(i,v.size()){
		if(tmp == v[i].first) cout << v[i].second << endl;
		else break;
	}


	return 0;

}


Measured memory_bytes: 29172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

class BMaximumDifference {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        int A[N];
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        int max = *max_element(A, A + N);
        int min = *min_element(A, A + N);

        out << max - min;
    }
};


int main() {
	BMaximumDifference solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
var
  n, digits: Integer;
  measure: String;

begin
  read(n);

  n := n mod 10;

  if (n = 0) or (n = 1) or (n = 6) or (n = 8) then
  begin
    measure := 'pon';
  end

  else if n = 3 then
  begin
    measure := 'bon';
  end

  else
  begin
    measure := 'hon';
  end;


  write(measure);

end.

Measured memory_bytes: 1312
#include<stdio.h>
#include<string.h>

int main(void)
{
  int n,q;
  scanf("%d%d",&n,&q);

  char s[n];
  scanf("%s",s);

  int ans[n+1];
  ans[0]=0;

  for(int i=0; i<n; i++){
    if( (i<n-1) && (s[i]=='A' && s[i+1]=='C')){
      ans[i+1]=ans[i]+1;
    }else{
      ans[i+1] = ans[i];
    }
  }

/*  for(int i=0; i<n; i++){
    printf("%d ",ans[i]);
  }*/

  int l,r;
  for(int i=0; i<q; i++){
    scanf("%d%d",&l,&r);
    printf("\n%d",ans[r-1]-ans[l-1]);
  }

//    printf("\n%d",ans[7]-ans[3]);


  return 0;
}


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

int n;
vector <int> b;
vector <int> res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int num; scanf("%d", &num);
        b.push_back(num);
    }
    for (int i = n; i >= 1; i--) {
        int pnt = int(b.size()) - 1;
        while (pnt >= 0 && b[pnt] != pnt + 1) pnt--;
        if (pnt < 0 || pnt + 1 > i) { printf("-1\n"); return 0; }
        res.push_back(pnt + 1);
        b.erase(b.begin() + pnt);
    }
    for (int i = int(res.size()) - 1; i >= 0; i--)
        printf("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
scores = [K for _ in range(N)]
c = Counter(A)
for i in range(1, N + 1):
    scores[i - 1] -= Q - c[i]

for score in scores:
    if score > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15064
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, a, b;
	scanf("%d", &n);
	P edges[n];
	std::vector<int> links[n];
	REP(i, 0, n-1){
		scanf("%d %d", &a, &b);
		edges[i] = P(a-1, b-1);
		links[a-1].push_back(b-1);
		links[b-1].push_back(a-1);
	}
	int c[n];
	REP(i, 0, n) scanf("%d", &c[i]);
	std::sort(c, c+n, std::greater<int>());

	std::queue<int> que;
	int pos = 0, sum = 0, used[n] = {}, num[n];
	que.push(0);
	while(!que.empty()){
		int from = que.front();
		que.pop();
		if(used[from]) continue;
		used[from] = true;
		sum += c[pos];
		num[from] = c[pos++];
		for(int next: links[from]){
			if(used[next]) continue;
			que.push(next);
		}
	}
	
	printf("%d\n", sum-num[0]);
	REP(i, 0, n) printf("%d ", num[i]);
	return 0;
}



Measured memory_bytes: 4640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        Console.WriteLine("ABC"+Console.ReadLine());
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092