akhauriyash/Code-Regression huggingface dataset:
//3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61
//8 = 8,2*4,2*2*2
//3*3*3 == 27
//135,189,105,165,195
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N; 
    cin >> N;
    if(N >= 195){
    cout << 5 <<endl;
    }
    else if(N >= 189){
    cout << 4 <<endl;
    }
    else if(N >= 165){
    cout << 3 <<endl;
    }
    else if(N >= 135){
    cout << 2 <<endl;
    }
    else if(N >= 105){
    cout << 1 <<endl;
    }
    else {
    cout << 0 <<endl;
    }
}



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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<int> a(n+1),ans(n);
  rep(i,n) if(s[i]=='L') a[i]=1;
  int p=0,q=0;
  bool flag=false;
  rep(i,n+1){
    if(flag==false and a[i]==1){
      flag = true,q=i;
    }
    if(flag==true and a[i]==0){
      int r=q-p,l=i-q;
      ans[q-1]=(r/2+r%2)+l/2,ans[q]=r/2+(l/2+l%2);
      flag = false,p=i;
    }
  }
  rep(i,n) cout << ans[i] << ' ';
  return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;
struct line{
    ll m,c;
    ll get(ll x){ return m*x+c; }
};
ll n,c;
ll h[200005];
struct node{
    int s,e,m;
    line v;
    node *l, *r;
    node (int _s, int _e): s(_s), e(_e){
        m = (s+e)/2;
        v = line{0,INF};
        if (s != e){
            l = new node(s,m);
            r = new node(m+1,e);
        }
    }
    void up(line nv){
        //printf("adding line %lld %lld\n",nv.m,nv.c);
        if (s == e){
            if (nv.get(h[s])<v.get(h[s])) v = nv;
            return;
        }
        bool domleft = nv.get(h[s]) < v.get(h[s]);
        bool dommid = nv.get(h[m+1]) < v.get(h[m+1]);
        if (dommid){
            swap(v,nv); ///we will make nv the new line at this node
        }
        if (domleft != dommid) {///intersect at left
            l->up(nv);
        }
        else{ ///intersect at right
            r->up(nv);
        }
    }
    ll qu(int x){
        if (s == e){
            return v.get(h[x]);
        }
        if (x > m) return min(r->qu(x),v.get(h[x]));
        else return min(l->qu(x),v.get(h[x]));
    }
}*root;
ll dp[200005];
int main(){
    scanf("%lld%lld",&n,&c);
    for (int i = 1; i <= n; i++) scanf("%lld",&h[i]);
    root = new node(1,n);
    dp[1] = 0;
    root->up(line{-2ll*h[1],h[1]*h[1]});
    for (int i = 2; i <= n; i++){
        dp[i] = root->qu(i) + h[i]*h[i] + c;
        //printf("%d qu %lld + %lld + %lld\n",i,root->qu(i),h[i]*h[i],c);
        //printf("%d dp %lld\n",i,dp[i]);
        root->up(line{-2ll*h[i], dp[i]+h[i]*h[i]});
    }
    printf("%lld",dp[n]);
}


Measured memory_bytes: 31776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
bool book[1000005];
int main()
{
    ios::sync_with_stdio(false);
    ll k ; cin >> k;
    ll now = 0 , pos = -1;
    for (int i = 1 ; i <= k ; i++){
        now = now * 10 + 7;
        now %= k;
        if (now == 0) {
            pos = i;
            break;
        }
        if (book[now]) break;
        book[now] = true;
    }
    cout << pos << endl;
    return 0;
}


Measured memory_bytes: 4572
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
 
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  
  vector<ll> a(n+1),b(m+1);
  a[0]=0; 
  b[0]=0;
  for(int i=1;i<n+1;i++) cin>>a[i];
  for(int i=1;i<n+1;i++) a[i]=a[i-1]+a[i];
  for(int i=1;i<m+1;i++) cin>>b[i];
  for(int i=1;i<m+1;i++) b[i]=b[i-1]+b[i];
  
  int ans=0;
  int j=m;
  rep(i,n+1){
    if(a[i]>k) break;
    while(b[j]>k-a[i] && j>=1){
      j--;
    }
    ans=max(ans,(i+j));
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main() 
{
    int n, x, y, z, i;
    scanf("%d", &n);
    
    set<int> s;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        
        if(x == 0)
        {
            s.insert(y);
            printf("%d\n", (int)s.size());
        }
        else if(x == 1)
        {
            printf("%d\n", (int)s.count(y));
        }
        else if(x == 2)
        {
            s.erase(y);
        }
        else if(x == 3)
        {
            scanf("%d", &z);
            
            auto L = s.lower_bound(y);
            auto R = s.upper_bound(z);
            
            while(L != R)
            {
                printf("%d\n", *L);
                L++;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 12552
#include <stdio.h>

int main()
{
	int a,b,c,d,n,kai;
	while(scanf("%d",&n)!=EOF){
	kai=0;
	for(a=0;a<10;a++)for(b=0;b<10;b++)for(c=0;c<10;c++)for(d=0;d<10;d++)if(n==a+b+c+d)kai++;
	printf("%d\n",kai);
	}
	return 0;
}

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

#define ll long long

ll gcd(ll a, ll b) {
   if (a < b) { // aの方が大きくなるようにする
      swap(a, b);
   }
   ll k = a % b;
   while (k) {
      a = b;
      b = k;
      k = a % b;
   }
   return b;
}

ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;
}

int main() {
   int n;
   cin >> n;

   ll ans = 1;
   for (int i = 0; i < n; i++) {
      ll t;
      cin >> t;
      ans = lcm(ans, t);
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	} else if (a > b) {
		return gcd(b, a%b);
	} else {
		return gcd(a, b%a);
	}
}

int main(void) {
	int x, y;
	scanf("%d %d", &x, &y);

	printf("%d\n", gcd(x, y));

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
    int n;
    cin >> n;
    int a,ans;
    for(int i=0;i<n;i++){
        if(i==0){cin >> ans;continue;}
        scanf("%d",&a);
        ans = gcd(a,ans);
    }
    cout << ans <<endl;
    return 0;
}

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

#define vpp vector<pair<int,int>>
#define ll long long int
#define ull unsigned long long
#define ld long double
#define fi(i,a,b) for(ll i=a;i<b;i++)
#define fj(j,a,b) for(ll j=a;j<b;j++)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define mpi map<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define pb push_back
#define MOD 1000000007
#define ub upper_bound
#define lb lower_bound
#define itr(v) for(auto it:v)
#define all(v) v.begin(),v.end()  
#define w(t)  int t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fast_pow(ll k, ll p)
{
if (p == 0)
        return 1;
 
    ll P = fast_pow(k, p/2);
    P = (P * P) % MOD;
 
    if (p % 2 == 1)
        P = (P * k) % MOD;
 
    return P;
}
ll invmod(ll a,ll m)
{
    return fast_pow(a,m-2);
}

bool isPrime(ll n) 
{ 
   
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
       if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
ll nextPowerOf2(ll n)
{
    n>>=1;
    ll count = 0;

    if (n && !(n & (n - 1)))
        return n;

    while( n != 0)
    {
        n >>= 1;
        count += 1;
    }

    return 1 << count;
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
  
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 


//////////////////////*********CODE***********/////////////////////
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') c++;
    }
    int ans=0;
    for(int i=0;i<c;i++){
           if(s[i]!='R') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int M, W;
vector<int> a, b;
int dp[1<<12][1<<12];
int calc(int s, int t)
{
    int k = abs(a[s] - b[t]);
    return k * (k - 30) * (k - 30);
}
int dfs(int wbit, int mbit, int pos)
{
    if(pos >= W) return 0;
    if(dp[wbit][mbit] != -1) return dp[wbit][mbit];
    int res = dfs(wbit, mbit, pos + 1);
    if(mbit & (1<<pos))
    {
        for(int i = 0; i < W; i++)
        {
            if(not (wbit & (1<<i)) or a[i] == b[pos]) continue;
            res = max(res, dfs(wbit & ~(1<<i), mbit & ~(1<<pos), pos + 1) + calc(i, pos));
        }
    }
    return dp[wbit][mbit] = res;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> M >> W, M or W)
    {
        memset(dp, -1, sizeof(dp));
        a.resize(M);
        b.resize(W);
        for(int i = 0; i < M; i++) cin >> a[i];
        for(int i = 0; i < W; i++) cin >> b[i];
        if(M > W)
        {
            swap(M, W);
            swap(a, b);
        }
        int ans = 0;
        for(int bit = 0; bit < (1<<W); bit++)
        {
            if(__builtin_popcount(bit) != M) continue;
            ans = max(ans, dfs((1<<M) - 1, bit, 0));
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 68696
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator - () {
		x = (-x % Mod + Mod) % Mod;
	}
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator ++ () {
		*this += 1;
	}
	void operator ++(int) {
		operator++();
	}
	void operator -= (const mll& a) {
		if ((x += Mod - a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator - (const mll& a) const {
		mll ans = *this;
		ans -= a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	bool operator < (const mll& a) {
		return this->x < a.x;
	}
	void pow(long long n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % Mod;
			xx = xx * xx % Mod;
			n >>= 1;
		}
	}
	mll inv() {
		long long a = x, b = Mod, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= Mod;
		if (u < 0) u += Mod;
		a = u;
		return mll(a);
	}
};

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), [](const long long& a, const long long& b) {return abs(a) > abs(b); });
	mll ans = 1;
	long long MinusMin = -pow(10, 9) - 1, PlusMin = pow(10, 9) + 1;
	long long MinusMax = 0, PlusMax = 0;
	int num = 0;
	bool plus = true;
	for (int i = 0; i < N; i++) {
		if (num < K) {
			if (A[i] == 0) break;
			if (A[i] < 0) {
				MinusMin = A[i];
				plus = 1 - plus;
			}
			if (A[i] > 0) PlusMin = A[i];
			ans *= A[i];
			num++;
		}
		else {
			if (plus) break;
			if (A[i] < 0) MinusMax = min(MinusMax, A[i]);
			if (A[i] > 0) PlusMax = max(PlusMax, A[i]);
			if (MinusMax < 0 && PlusMax > 0) break;
		}
	}
	if (num < K) { //どうあがいても0
		cout << 0 << endl;
		return 0;
	}
	if (N == K) { //それ以外ない
		cout << ans.x << endl;
		return 0;
	}
	if (plus) { //積がプラス
		cout << ans.x << endl;
		return 0;
	}
	if (PlusMin < pow(10, 9) + 1 || PlusMax > 0) { //積にプラスが含まれているか、それ以外にプラスがある
		mll buf = 0;
		//積にプラスが含まれていれば
		if (PlusMin < pow(10, 9) + 1) {
			mll m = PlusMin;
			buf = ans * m.inv() * MinusMax;
		}
		mll m = MinusMin;
		ans = ans * m.inv() * PlusMax;
		if (PlusMin < pow(10, 9) + 1 && MinusMax * MinusMin > PlusMax * PlusMin) ans = buf;
	}
	if (PlusMax == 0 && PlusMin == pow(10, 9) + 1) { //積にもそれ以外にもプラスがない
		//負数を絶対値小さい順にかける
		ans = 1ll;
		for (int i = N - 1; i >= N - K; i--) {
			ans *= A[i];
		}
	}
	cout << ans.x << endl;
}

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

int solve(int x0, int c0, int s0, int f0) {
  int ret;
  if (x0 <= s0)
    ret = s0 + c0;
  else
    ret = (((x0 - 1) / f0 + 1) * f0 + c0);
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1), ans(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  ans[n - 1] = 0;

  for (int j = 0; j < n - 1; j++) {
    int x = 0;
    for (int i = j; i < n - 1; i++) {
      x = solve(x, c[i], s[i], f[i]);
    }
    ans[j] = x;
  }

  for (auto&& w : ans) cout << w << endl;
}

Measured memory_bytes: 256
/* 
 * Project: M-SOLUTIONS プロコンオープン 2020 B - Magic 2
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/25
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int a, b, c;
int k;

void solve() {

    if (c > b && b > a) {
        printf("Yes\n");
        return;
    }

    int cnt = 0;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while (b >= c) {
        c *= 2;
        cnt++;
        if (cnt > k) {
            printf("No\n");
            return;
        }
    }
    if (cnt <= k) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &k);

    solve();

}

Measured memory_bytes: 3144
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(int[]);

  auto c = new int[](9);
  foreach (ai; a) ++c[min(8, ai/400)];

  auto r = c[0..8].count!"a>0";
  if (r == 0)
    writeln(1, " ", c[8]);
  else
    writeln(r, " ", r + c[8]);
}


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

#define int 		long long
#define vi 			vector <int>
#define si 			set <int>
#define pii 		pair<int,int>
#define fr(n) 		for(__typeof(n) i=0;i<n;i++)
#define rep(i,a,b) 	for(__typeof(b) i=a;i<b;i++)
#define repi(i,b,a) for(__typeof(a) i=b;i>=a;i--)
#define tr(a) 		for(auto it=a.begin();it!=a.end();it++)
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define FAST 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r,w;
	vi red;
	r=w=0;
	fr(n)
	{
		if(s[i]=='R')
		{
			r++;
			red.pb(i);
		}
		else
		{
			w++;
		}
	}
	int ans=0;
	fr(red.size())
	{
		if(red[i]>=r)
			ans++;
	}
	cout<<ans;
}

signed main()
{
	FAST
	int test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	cerr<<endl<<"Time elapsed : "<<time_passed<<endl;
	return 0;
}

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

using namespace std;

const int maxn = 1e2 * 2 + 20;
int n = 0 , a[maxn] , g = 0;
int main()
{
	cin >> n;
	for (int i = 0; i < n * 2; i++)
	{
		cin >> a[i];
	}
	sort (a , a + n * 2);
	for (int i = 0; i < n * 2 - 1; i += 2)
	{
		g += min (a[i] , a[i+1]);
	}
	cout << g;
	return 0;
}


Measured memory_bytes: 256
program abc171
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,cnt(0:30)=0
    integer(int32), allocatable:: a(:),b(:)

    read*, n
    allocate(a(n),b(n))
    read*, a(:)


    do i=1,n
        do j=0,30
            if (btest(a(i),j)) cnt(j)=cnt(j)+1
        end do
    end do

    do i=1,n
        do j=0,30
            if (mod(cnt(j),2) == 0 .neqv. btest(a(i),j)) then
                a(i)=ibclr(a(i),j)
            else
                a(i)=ibset(a(i),j)
            end if
        end do
    end do

    print'(*(i0,1x))', a(:)
end program abc171

Measured memory_bytes: 6176
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int w, a, b;
  scanf("%d%d%d", &w, &a, &b);
  printf("%d\n", max(0, abs(a-b)-w));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, x;
    char c;
    cin >> n;
    vector<int> S(14), H(14), C(14), D(14);
    for (int i = 0; i < n; i ++){
        cin >> c >> x;
        if (c == 'S'){
            S[x] = 1;
        }else if (c == 'H'){
            H[x] = 1;
        }else if (c == 'C'){
            C[x] = 1;
        }else{
            D[x] = 1;
        }
    }
    for (int i = 1; i < 14; i++){
        if (S[i] == 0){
            cout << "S " << i << endl;
        }
    }
    for (int i = 1; i < 14; i++){
        if (H[i] == 0){
            cout << "H " << i << endl;
        }
    }
    for (int i = 1; i < 14; i++){
        if (C[i] == 0){
            cout << "C " << i << endl;
        }
    }
    for (int i = 1; i < 14; i++){
        if (D[i] == 0){
            cout << "D " << i << endl;
        }
    }
}


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

int cnt[4];

/* prototype declaration */
void init();
void count();
int bloodtype(char *type);

int main(int argc, const char *argv[])
{
	init();
	count();

	return 0;
}

void init()
{
	int i;
	for(i=0; i<4; i++) cnt[i] = 0; 
}

void count()
{
	int i, num;
	char blood[2];

	while(scanf("%d,%s", &num, blood)!=EOF) cnt[bloodtype(blood)]++;
	
	for(i=0; i<4; i++) printf("%d\n", cnt[i]);
}

int bloodtype(char *type)
{
	int i, n = 0, len = strlen(type);

	for(i=0; i<len; i++)
		n += type[i];
	
	switch(n){
	case 'A':
		return 0;
	case 'B':
		return 1;
	case 'A'+'B':
		return 2;
	case 'O':
		return 3;
	default:
		return -1;
	}	
}

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n, 0);
  for(ll i = 0; i < n; i++) cin >> a[i];

  bool ok = true;
  for(ll i = 0; i < n; i++){
    if(a[i] % 2 == 0){
      if(a[i] % 3 == 0 || a[i] % 5 == 0){
        continue;
      }else{
        ok = false;
      }
    }
  }

  if(ok == false){
    cout << "DENIED" << endl;
  }else{
    cout << "APPROVED" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
ans = []

for i in range(n):
    for j in range(len(b), 0, -1):
        if j == b[j-1]:
            b = b[0:j-1] + b[j:n]
            ans.append(j)
            break

if len(ans) == n:
    ans.reverse()
    for item in ans:
        print(item)
else:
    print(-1)



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

int main(){
  string in;
  getline(cin,in);
  for(int i=0;i<in.size();i++){
    if(islower(in[i])) in[i] = toupper(in[i]);
  }
  cout << in << endl;
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int n;
    string s;
    int ans=1;
    cin >> n >> s;

    if(n%2==1) ans=0;
    else{
        rep(i,n/2) {
            if(s[i]==s[n/2+i]) continue;
            else {
                ans=0;
                break;
                }
        }

    }
    if(ans) cout << "Yes";
    else cout<< "No";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7728
def divisor(n):
    res = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            res.append(i)
            if i**2 == n:
                continue
            res.append(n//i)
    return res
n = int(input())
res = divisor(n)
ans = len(divisor(n-1))-1
for r in res:
    if r == 1:
        continue
    tmp = n
    while tmp%r==0:
        tmp//=r
    if tmp%r == 1:
        ans+=1
print(ans)

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

int main() {
    int num;
    set<int> s;
    for (int i = 1; i <= 3; i++) {
        cin >> num;
        s.insert(num);
    }
    if (s.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","r",stdin)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int a[200000+10],ex[200000+10];
int main(){
//	FREO;
	int n;
	cin>>n;
	rep(i,n) cin>>a[i],ex[i]=1;
	sort(a,a+n);
	LL is=1;
	while(is<=2000000000) is<<=1;
	int res=0;
	for(is;is>=1;){
		int r=n-1;
		rb(l,0,n-2){
			if(!ex[l]) continue; 
			r=max(r,l+1);
			while((a[r]+a[l]>is||!ex[r])&&r>=0) r--;
			if(r<=l) break;
			if(a[r]+a[l]==is){
				ex[r]=ex[l]=0;
				res++;
				continue;
			}
		}
		is>>=1;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll ans1= min(n,m);
    ll ans2= max(n,m);
    REP(i,ans2) cout << ans1;
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y;
}

Measured memory_bytes: 256
constexpr bool isDebugMode = true;
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

ll ope(ll s, ll t){
    return s + t;
}

ll s(){
    return 0LL;
}

int main(){
    ll N, Q; cin >> N >> Q;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    segtree<ll, ope, s> seg(a);
    rep(i, Q){
        ll q, a, b; cin >> q >> a >> b; 
        if(!q) seg.set(a, seg.get(a) + b);
        else pt(seg.prod(a, b));
    }

    return 0;
}

Measured memory_bytes: 16396
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n,q;
    cin>>n;
    q=n;
    int t;
    map<int,int> dd;
    n--;
    while(n--){
    	cin>>t;
    	dd[t]++;
    }
    for(int i=1;i<=q;i++){
    	cout<<dd[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12904
from functools import reduce
# python > pypy
MOD = 10**9 + 7
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

def gcd_list(numbers):
    return reduce(gcd, numbers)

def lcm_list(numbers):
    return reduce(lcm, numbers)

n = int(input())
a = list(map(int, input().split()))

lcm_ = lcm_list(a)
b = list(map(lambda x: lcm_//x, a))
ans = 0
for i in range(len(b)):
    ans += b[i]
print(ans%MOD)


Measured memory_bytes: 263140
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n;
	scanf("%d", &n);

	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}

	int length = 1;
	int V[n];
	V[0] = A[0];
	for (int i = 1; i < n; ++i) {
		if (A[i] > V[length - 1]) {
			V[length++] = A[i];
		} else {
			int l = 0;
			int r = length;
			while (l < r) {
				int mid = (l + r) / 2;
				if (V[mid] < A[i]) {
					l = mid + 1;
				} else {
					r = mid;
				}
			}
			V[r] = A[i];
		}
	}
	cout << length << endl;
	return 0;
}

Measured memory_bytes: 3904
def test():

	nq = list(map(int,input().split()))
	n = nq[0]
	q = nq[1]

	task_queue = []
	output_queue = []
	for i in range(n):
		inputs = input().split()
		task = []
		task.append(inputs[0])
		task.append(int(inputs[1]))
		task_queue.append(task)

	time = 0
	while task_queue:

		current = task_queue.pop(0)
		if current[1] > q:
			current[1] -= q
			task_queue.append(current)
			time += q
		elif current[1] == q:
			time += q
			current[1] = time
			output_queue.append(current)
		else:
			time += current[1]
			current[1] = time
			output_queue.append(current)

	for i in range(n):
		print(f"{output_queue[i][0]} {output_queue[i][1]}")

if __name__ == "__main__":
	test()



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

int main(){
    ll A,B,N;
    std::cin >> A >> B >> N;
    
    ll maxX = std::min<ll>(B-1, N);

    std::cout << A*(maxX)/B;

    return 0;
}




Measured memory_bytes: 3600
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto s = readln.splitter.map!(to!int);
  immutable h = s.front; s.popFront();
  immutable w = s.front; s.popFront();
  immutable k = s.front; s.popFront();
  auto a = new char[][](h, w);
  auto d = new int[h];
  foreach (j; 0 .. h) {
    auto t = readln;
    foreach (i; 0 .. w) {
      a[j][i] = t[i];
      if (t[i] == '#') {
        ++d[j];
      }
    }
  }
  int o;
  auto b = new int[][](h, w);
  for (int j = 0; j < h; ) {
    int j1 = j;
    while (j < h && d[j] == 0) ++j;
    int j2 = j;
    while (j2 + 1 < h && d[j2+1] == 0) ++j2;
    ++j2;
    //[j1, j2)
    for (int i = 0; i < w; ) {
      int i1 = i;
      while (i < w && a[j][i] == '.') ++i;
      int i2 = i;
      while (i2 + 1 < w && a[j][i2+1] == '.') ++i2;
      ++i2;
      assert (j1 != j2);
      assert (i1 != i2);
      ++o;
      debug stderr.writefln ("[%d, %d) x [%d, %d)", j1, j2, i1, i2);
      foreach (y; j1 .. j2) {
        foreach (x; i1 .. i2) {
          assert (!b[y][x]);
          b[y][x] = o;
        }
      }
      i = i2;
    }
    j = j2;
  }
  assert (o == k);
  foreach (j; 0 .. h) {
    writefln ("%(%s %)", b[j]);
  }
}



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

int main(){
    long long int a;
    string b;
    cin >> a >> b;
    long long int b1 = (b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    cout << (a*b1)/100 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;
int n;
ll a[2][10010];
ll dp[2][10010];
ll f(int i,int j){
    if(i == 1 && j== n-1){
        return a[i][j];
    }
    if(dp[i][j] != -1)return dp[i][j];
    ll r =-1e15;
    if(!i){
        r = max(r,f(i+1,j));
    }
    if(j+1 < n){
        r = max(r,f(i,j+1));
    }
    return dp[i][j] = r+a[i][j];
}

int main()  {
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0 ;i <2 ;i ++)
        for(int j=0 ;j <n ;j ++)cin>>a[i][j];
    cout<<f(0,0)<<endl;
    return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // 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; }

int main(void)
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<char, ll> mp;
    for (auto c : s)
        mp[c]++;
    mint ans = 1;
    for (auto x : mp)
        ans *= x.second + 1;
    ans -= 1;
    cout << ans << endl;
}

Measured memory_bytes: 512
s = str(input())
n = len(s)
dp = [[0]*2 for _ in range(n+1)]
dp[0][1] = 1
for i in range(n):
    p = int(s[i])
    dp[i+1][0] = min(dp[i][1]+10-p,dp[i][0]+p)
    dp[i+1][1] = min(dp[i][1]+10-p-1,dp[i][0]+p+1)
print(dp[-1][0])

Measured memory_bytes: 170040
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d; n--;
	ll dif = d - c; ll y = b - a;
	bool f = false;
	for (ll i = (ll)0; i <= n; i++) {
		ll x = c * ((ll)2 * i - n);
		if (y <= x + dif*i && y >= x + dif * (i - n))f = true;
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

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

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

    if ((A == B && B == C) || (A != B && B != C && A != C)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
if __name__ == '__main__':
    A, B, K = map(int, input().split())

    answer = []
    for i in range(K):
        n = A + i
        if n <= B:
            answer.append(n)
        m = B - i
        if A <= m:
            answer.append(m)
    answer = sorted(list(set(answer)))

    for i in range(len(answer)):
        print(answer[i])



Measured memory_bytes: 3060
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if A < 10 and B < 10:
    print(A * B)
else:
    print(-1)


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

int main(void){
 int n;
 cin >> n;
 vector<int>d(n);
for(int i = 0;i  < n;i++){
  cin >> d[i];
 }
 sort(d.begin(),d.end());
 int ans = n;
for(int i = 0;i  < n;i++){
  if(d[i] == d[i+1]){
    ans--;
  }
 }
cout << ans <<endl;
}



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

int main(){
  int h, w;
  while(cin>>h>>w, h){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
    int a;
    cin >> a;
    vector<vint> judge(a,vint(a,-1));
    rep(i,a){
        int b;
        cin >> b;
        rep(j,b){
            int c,d;
            cin >> c >> d;
            --c;
            judge.at(i).at(c) = d;
        }
    }
    int ans = 0;
    rep(i,1<<a){//00000000~11111111までを考えている
        bool ok = true;
        vint d(a,0);
        rep(j,a){
            if(i>>j&1)
                d.at(j) = 1;//この中にはiが入る
        }
        rep(j,a){//iが正しいか捜索
            if(d.at(j)){//もしiのj番目が1ならj番目の人間が正しいことになる
            //それならばj番目が言っていることと答えはあっていないとおかしいよね
                rep(s,a){
                	if(judge.at(j).at(s) == -1) continue;
                	if(judge.at(j).at(s) != d.at(s)) ok = false;
                }
            }
        }
        if(ok)
          ans = max(ans,__builtin_popcount(i));
    }
    cout << ans << endl;
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

string X;

signed main(){
    string S,T;
    cin>>S>>T;
    X=S;

    rep(i,2){
        int a=0,b=0;
        bool ok=true;
        rep(j,X.size()){
            if(j%2==0){
                while(a<S.size()&&S[a]!=X[j])a++;
                if(a>=S.size())ok=false;
                a++;
            }
            else{
                while(b<T.size()&&T[b]!=X[j])b++;
                if(b>=T.size())ok=false;
                b++;
            }
        }
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
        swap(S,T);
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main(){
  int a,b,day,A,B,bell;
  cin >> day;
  cin >> a >> b >> A >> B;
  while(a>0 || b>0){
    a=a-A;
    b=b-B;
    day--;
  }
  cout << day << endl;
}

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

X=int(input())

S=[0]*200

A=0
B=0
for i in range(200):
    S[i]=i**5

for i in range(200):
    for j in range(200):
        if S[i] + S[j] == X:
            A=i
            B=-j 
            break
        if S[i] - S[j] == X:
            A=i
            B=j
            break

print("{} {}".format(A,B))

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    LL n, ans = 0;
    cin >> n;
    for (LL i = 0; i < 100000; i++) {
        if (i*i > n) {
            cout << ans << endl;
            return 0;
        }
        ans = i * i;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
x = input()
l = len(x)

if l == 6:
    print(1)
    sys.exit(0)
elif l <= 2:
    print(0)
    sys.exit(0)
else:
    top = int(x[0:l-2])
    left = int(x[l-2:])
    if top * 5 < left:
        print(0)
    else:
        print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(0); cin.tie(NULL);
typedef long long ll;
using namespace std;


int main(){
    fastIO
    
    ll k,x,c;
    cin>>k;
    x = 7;
    c=0;
    bool found = false;
    while(c<=k){
        c++;
        if(x%k==0){
            found = true;
            break;
        }
        x = (x*10+7)%k;
    }
    if(found) cout<<c;
    else cout<<-1;
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
 
int main(){
	long long int a, b, n;
	cin >> a>>b>>n;
	if(b>n){
		cout<<a*n/b<<endl;
		return 0;
	}else {
		long long kotae=a*(b-1)/b;
    	cout<<kotae<<endl;
        return 0;
	}
	return 0;
}

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

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

	char mae, ato;
	int N = S.size();
	int count = 0;
	for (int i=0; i<N/2; i++) {
		mae = S.at(i);
		ato = S.at(N-1-i);
		if (mae!=ato){
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 400 + 5;
const int mod = 1e9 + 7;
ll dp[maxn][maxn] , mi[maxn][maxn] , temp[maxn][maxn];
//dp[i][j][k]代表前i个位置，总共j个糖果,最后一个物品选k次的总和
pair<int,int> a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n , c; cin >> n >> c;
    for (int i = 1 ; i <= n ; i++)
        cin >> a[i].first;
    for (int i = 1 ; i <= n ; i++)
        cin >> a[i].second;
    dp[0][0] = 1;
    for (int i = 1 ; i <= n ; i++){
        memset(temp , 0 , sizeof temp);
        for (int j = 0 ; j <= c ; j++){
            for (ll k = a[i].first ; k <= a[i].second ; k++){
                if (j != 0)
                    temp[j][k] = (dp[i - 1][j]%mod + temp[j - 1][k] * k%mod)%mod;
                else
                    temp[j][k] = dp[i - 1][j]%mod;
            }
            ll res = 0;
            for (ll k = a[i].first ; k <= a[i].second ; k++){
                res = (res + temp[j][k]) %mod;
            }
            dp[i][j] = res;
        }
    }
    cout << dp[n][c] << endl;
    return 0;
}

/*
2 3
1 2
1 2
*/


Measured memory_bytes: 6216
/* Ahmed Maher ( Acro_14 ) */
#include <bits/stdc++.h>
typedef long long ll;
const ll oo = 0x3f3f3f3f;
int const N = 1e5+5;
using namespace std;
//string alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//string BN(ll x){bool f=0;string Bn;int i=62;while(i--){if ((ll)x & (1LL << i)){Bn+='1';f=1;}else{if(f)Bn+='0';}}return Bn;}//Decimal to Binary converter
 int n = N;
int ans[664580];
int *Seive(){
    vector<bool> good(n);
    for(int i = 1; i < n; i++){
        good[i] = true;
    }
    good[1] = false;
    for(ll i = 2; i < n; i++){
        if(good[i]){
            // i = 1e7
            for(ll j = 1LL * i * i; j < n; j += i){
                good[j] = false;
            }
        }
    }
    int j=0;
    for(int i = 1; i < n; i++){
        if(good[i]){
           ans[j]=i;
           j++;
        }
    }
    return ans;
/*to print */
//    int *p;
//    p=Seive();
//      for(int i=0;i<10e7;i++){
//      cout << *(p + i) << endl;
//      system("pause");
//   }
/*end of print*/
}

int main()
{
    int *p,arr[N];
    p=Seive();
    for(int i=0;i<N;i++)arr[i] = *(p + i);
    int x;
    cin>>x;
        for (int i=0;i<N;i++){
            if (arr[i]>x && arr[i-1]<x){cout<<arr[i]<<endl;break;}
            else if (arr[i]==x){cout<<x<<endl;break;}
        }
}

//       int anss[t+1];
//            anss[j]=ans;
//     for(int j=1;j<=t;j++) printf("Case %d: %d\n",j,anss[j]);


Measured memory_bytes: 4032
H, W = map(int,input().split(' '))
S = []
for i in range(H):
  S.append(input())
for j in range(H):
  answer = list(S[j])
  for k in range(W):
    cnt = 0
    if S[j][k] == '#':
      pass
    if S[j][k] == '.':
      if j-1 >= 0:
        if k-1 >= 0:
          if S[j-1][k-1] == '#':
            cnt += 1
        if S[j-1][k] == '#':
          cnt += 1
        if k+1 <= W-1:
          if S[j-1][k+1] == '#':
            cnt += 1
      if k-1 >= 0:
        if S[j][k-1] == '#':
          cnt += 1
      if k+1 <= W-1:
        if S[j][k+1] == '#':
          cnt += 1
      if j+1 <= H-1:
        if k-1 >= 0:
          if S[j+1][k-1] == '#':
            cnt += 1
        if S[j+1][k] == '#':
          cnt += 1
        if k+1 <= W-1:
          if S[j+1][k+1] == '#':
            cnt += 1
      answer[k] = str(cnt)
  print(''.join(answer))

Measured memory_bytes: 9256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

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

  int q;
  cin >> q;
  int l[q], r[q];
  for(int i = 0; i < q; i++){
    cin >> l[i] >> r[i];
  }

  bool tab[MAX_N + 1];
  fill(tab, tab + (MAX_N + 1), true);
  tab[0] = tab[1] = false;
  for(int i = 2; i <= MAX_N; i++){
    if(tab[i]){
      for(int j = 2; i * j <= MAX_N; j++){
        tab[i * j] = false;
      }
    }
  }
  set< int > primes;
  for(int i = 2; i <= MAX_N; i++){
    if(tab[i]) primes.insert(i);
  }

  int sum[MAX_N + 1];
  fill(sum, sum + (MAX_N + 1), 0);
  for(int i = 0; i <= MAX_N; i++){
    if(i % 2 != 1) continue;
    if(primes.find(i) != primes.end() &&
      primes.find((i + 1) / 2) != primes.end()){
      sum[i] = 1;
    }
  }

  for(int i = 0; i <= MAX_N; i++){
    sum[i] += sum[i - 1];
  }

  string ans;
  for(int i = 0; i < q; i++){
    ans += to_string(sum[r[i]] - sum[l[i] - 1]);
    ans += "\n";
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 2948
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int A[100010], deg[100010];
vector<int> G[100010];
map<int, map<int, int> > m;

void dfs(int x, int par=-1) {
    int sum = 0, rec = -1;
    bool leaf = true;
    rep(i,0,G[x].size()) {
        int to = G[x][i];
        if(to == par) {
            rec = i;
            continue;
        }
        leaf = false;
        dfs(to, x);
        // printf("add: %lld -> %lld (cost: %lld)\n", x, to, m[to][x]);
        sum += m[to][x];
    }
    if(leaf) {
        int to = G[x][0];
        // printf("leaf: cur = %lld, to = %lld, cost = %lld\n", x, to, A[x]);
        m[x][to] = m[to][x] = A[x];
    }
    else if(rec != -1) {
        // printf("A[%lld] = %lld, sum = %lld\n", x, A[x], sum);
        int to = G[x][rec];
        // printf("etc: cur = %lld, to = %lld, cost = %lld\n", x, to, 2 * A[x] - sum);
        m[x][to] = m[to][x] = 2 * A[x] - sum;
    }
}

signed main() {
    cin >> N;
    rep(i,0,N) {
        cin >> A[i];
    }
    rep(i,0,N-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }

    dfs(0);

    bool ok = true;
    rep(i,0,N) {
        if(deg[i] == 1) {
            // leaf
            int to = G[i][0];
            // printf("leaf (%lld): cost = %lld, A = %lld\n", i, m[i][to], A[i]);
            if(m[i][to] != A[i]) ok = false;
        }
        else {
            int sum = 0;
            for(auto c : G[i]) sum += m[i][c];
            if(sum % 2 || sum / 2 != A[i]) ok = false;
            for(auto c : G[i]) {
                // printf("(%lld, %lld): sum = %lld, cost = %lld\n", i, c, sum, m[i][c]);
                if(m[i][c] < 0) ok = false;
                if(m[i][c] * 2 > sum) ok = false;
            }
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 38528