akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll d=n;
    ll sum=0;
    while(d)
    {
        sum+=(d%10);
        d/=10;
    }
    if(!(n%sum))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a[10],b[10];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	for(int i=1;i<n;i++){
		while(true){
			if(a[i]>a[i+1]){
				a[i]=a[i]%a[i+1];
			}else{
				a[i+1]=a[i+1]%a[i];
			}
			if(a[i]==0||a[i+1]==0){
				a[i+1]=(a[i] > a[i+1]) ? a[i] : a[i+1];
				a[i+1]=b[i]/a[i+1]*b[i+1];
				b[i+1]=a[i+1];
				break;
			}
		}
	}
	cout<<b[n]<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=4010;
int n,K,front[N],cnt,tot,ans,dep[N];
struct node{int to,nxt;}e[N<<1];
void Add(int u,int v){e[++cnt]=(node){v,front[u]};front[u]=cnt;}
void dfs(int u,int ff)
{
	dep[u]=dep[ff]+1;
	if(dep[u]>K/2)tot++;
	for(int i=front[u];i;i=e[i].nxt)
	{
		int v=e[i].to;if(v==ff)continue;
		dfs(v,u);
	}
}
int main()
{
	n=gi();K=gi();ans=n+1;
	for(int i=1;i<n;i++){int u=gi(),v=gi();Add(u,v);Add(v,u);}
	if(K&1)
		for(int u=1;u<=n;u++)
			for(int i=front[u];i;i=e[i].nxt)
				tot=0,dep[e[i].to]=-1,dfs(u,e[i].to),dep[u]=-1,dfs(e[i].to,u),ans=min(ans,tot);
	else for(int i=1;i<=n;i++)tot=0,dep[i]=-1,dfs(i,i),ans=min(ans,tot);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, W; 
  cin >> N >> W;

  int w0;
  vector<vector<int>> vec(4);
  REP(i, N){
    int w, v;
    cin >> w >> v;
    if(i == 0) w0 = w;
    vec[w-w0].emplace_back(v);
  }

  REP(i, 4){
    sort(ALL(vec[i]), greater<>());
    vec[i].insert(vec[i].begin(), 0);
    vec[i].insert(vec[i].begin(), 0);
    FOR(j, 1, vec[i].size()) vec[i][j] += vec[i][j-1];
  }

  int ans = 0;
  REP(i, vec[0].size()-1) REP(j, vec[1].size()-1){
    REP(k, vec[2].size()-1) REP(l, vec[3].size()-1){
      if(i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3) > W) continue;
      chmax(ans, vec[0][i+1]+vec[1][j+1]+vec[2][k+1]+vec[3][l+1]);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
maxidx = A.index(max(A))
Amax = max(A)
A.remove(Amax)
A2 = max(A)

for i in range(maxidx):
  print(Amax)
print(A2)
for i in range(maxidx+1,N):
  print(Amax)

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
int matriz[201][201][201];
int gcd(int a, int b){
		if( b == 0) return a;
		return gcd(b,a%b);
}

long long int bksum(int a,int b, int c, int k){
	if(a > k || b > k || c > k ) return 0;
	if(matriz[a][b][c]) return 0;
	matriz[a][b][c] ++;
	return gcd(a,gcd(b,c)) + bksum(a+1,b,c,k) + bksum(a,b+1,c,k) + bksum(a,b,c+1,k);
}

int main(){
	long long int sum = 0;
	int k;
	cin >> k;
	sum = bksum(1,1,1,k);
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 35292
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d)


Measured memory_bytes: 9048
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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 mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll a[n],sum=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    rep(i,0,n){
        sum+=a[i];
        a[i]*=2;
    }
    ll odd[n/2+1],even[n/2];
    odd[0]=0;
    // odd[1]=a[1]-a[0];
    even[0]=a[0]-odd[0];
    rep(i,0,n-2){
        if(i%2){
            even[1+i/2]=even[i/2]+a[i+1]-a[i];
        }else{
            odd[1+i/2]=odd[i/2]+a[i+1]-a[i];
        }
    }
    ll os=0,es=0;
    rep(i,0,n/2+1){
        os+=odd[i];
    }
    rep(i,0,n/2){
        es+=even[i];
    }
    ll d=sum-os-es;
    rep(i,0,n/2+1){
        odd[i]+=d;
    }
    rep(i,0,n/2){
        even[i]-=d;
    }
    rep(i,0,n){
        if(i%2){
            printf("%lld ",even[i/2]);
        }else{
            printf("%lld ",odd[i/2]);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2816
# include<iostream>

using namespace std;
int main(){
	int n = 0;
	int a[100];
	int t[100];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		t[i] = a[i];
	}
	for (int it = n - 1; it >= 0; it--){
		cout << t[it] ;
		if (it != 0){
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

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

int main()
{
    int a,b;
    cin >> a;
    cin >> b;
    
    for (int i=0; i<= 20; i++){
        if (a*i-i+1 >= b){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}


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

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

map<int,int> m;
vector<int> v;

int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;

signed main() {
    string S, T;
    cin >> S >> T;
    S = " " + S;
    T = " " + T;
    vector<int> sumS(S.length() + 1), sumT(T.length() + 1);
    for (int i = 1; i < S.length(); i++) {
        if (S[i] == 'A') sumS[i] = sumS[i - 1] + 1;
        else sumS[i] = sumS[i - 1] + 2;
    }
    for (int i = 1; i < T.length(); i++) {
        if (T[i] == 'A') sumT[i] = sumT[i - 1] + 1;
        else sumT[i] = sumT[i - 1] + 2;
    }
    int q;
    cin >> q;
    auto judge = [&](int a, int b, int c, int d) {
        int s = sumS[b] - sumS[a - 1];
        int t = sumT[d] - sumT[c - 1];
        return s % 3 == t % 3;
    };
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << (judge(a, b, c, d) ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 2404
#include <iostream>
#include <map>

using namespace std;

int main(void)
{
    int arr_len;
    map<int, int> num_cnt;

    cin >> arr_len;

    for(int i = 0; i < arr_len; i++){
        int num;
        cin >> num;
        if(num_cnt.find(num) == num_cnt.end()){
            num_cnt[num] = 1;
        }else{
            num_cnt[num] += 1;
        }
    }

    int query_len;
    cin >> query_len;

    long long sum = 0;
    for(auto nc = num_cnt.begin(); nc != num_cnt.end(); nc++){
        sum += nc->first * nc->second;
    }

    for(int i = 0; i < query_len; i++){
        long long b, c;
        cin >> b >> c;

        if(num_cnt.find(b) != num_cnt.end()){
            sum -= b * num_cnt[b];
            sum += c * num_cnt[b];

            if(num_cnt.find(c) == num_cnt.end()){
                num_cnt[c] = num_cnt[b];
            }else{
                num_cnt[c] += num_cnt[b];
            }
            num_cnt[b] = 0;
        }

        cout << sum << endl;
    }


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long int num[86];

  num[0] = 2;
  num[1] = 1;

  for (int i = 2; i <= N; i++) {
    num[i] = num[i - 1] + num[i - 2];
  }
  cout << num[N] << endl;
  return 0;
}


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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	llong X; scanf("%lld",&X);
	llong pow5[10000];
	int M=0;
	for(llong i=0;i<10000;i++){
		pow5[i]=i*i*i*i*i;
		if( M==0 && pow5[i]>X ){
			M = i;
		}
		if( pow5[i]==X){
			printf("%lld 0",pow5[i]);
			return 0;
		}
	}
	llong A=0,B;
	int minus=M,plus=0;
	while(1){
		B = A*A*A*A*A-X;
		if( B>0 ){
			while(plus<10000){
				if( B==pow5[plus] ){
					printf("%lld %d",A,plus);
					return 0;
				}else if( B<pow5[plus] ) break;
				plus++;
			}
		}
		if( B<0 ){
			B = -B;
			while(minus>=0){
				if( B==pow5[minus] ){
					printf("%lld %d",A,-minus);
					return 0;
				}else if( B>pow5[minus] ) break;
				minus--;
			}
		}
		A++;
	}
	return 0;
}



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

int N, K;
int a[100000];
vector<int> b[100000];
int ans;

// i から出発して葉まで行く
// 根を含まない部分木の高さがK-1であればその上についている辺をカットして、高さをリセットする
int dfs(int i){
    int ret = 0;
    for(auto ch : b[i]){
        ret = max(ret, dfs(ch) + 1);
    }

    if(i==0) return ret;
    if((a[i] != 0 && ret == K-1) || (a[i] == 0 && ret == K)){
        ans++;
        ret = -1;
    }
    return ret;
}

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

	cin >> N >> K;
	ans = 0;
	cin >> a[0];
	a[0]--;
	if(a[0] != 0)
		ans++;

	for(int i=1; i<N; i++){
		cin >> a[i];
		a[i]--;
		b[a[i]].push_back(i);
	}

	dfs(0);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++){
    cin >> a[i];
  }
  vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
  vector<int> dy = {1, 0, -1, 1, -1, 1, 0, -1};
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (a[i][j] == '#') cout << '#';
      if (a[i][j] == '.'){
        int cnt = 0;
        for (int k = 0; k < 8; k++){
          if(0 <= i + dy[k] && i + dy[k] < H && 0 <= j + dx[k] && j + dx[k] < W && a[i + dy[k]][j + dx[k]] == '#')
            cnt++;
        }
        cout << cnt;
      }
    }
    cout << endl;
  }
}

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

namespace atcoder
{
    class Program
    {
        static string s;
        static int L;
        static string str1 = "dream";
        static string str2 = "dreamer";
        static string str3 = "erase";
        static string str4 = "eraser";

        public static void Main(string[] args)
        {
            s = Console.ReadLine();
            L = s.Length;

            while(true)
            {
                if (isOK(L, str1)) { L -= str1.Length; continue; }
                if (isOK(L, str2)) { L -= str2.Length; continue; }
                if (isOK(L, str3)) { L -= str3.Length; continue; }
                if (isOK(L, str4)) { L -= str4.Length; continue; }
                if (L == 0) { Console.WriteLine("YES"); break; }
                Console.WriteLine("NO"); break; 
            }

        }
        public static bool isOK(int LL, string ss)
        {
            if(ss.Length > LL) return false;

            int LLL = LL - ss.Length;
            for (int i = 0; i < ss.Length; i++)
                if (s[LLL + i] != ss[i])
                    return false;

            return true;
        }

    }

}


Measured memory_bytes: 3032
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);
        var s = Console.ReadLine();

        var a = s.Substring(0, k - 1);
        var b = s.Substring(k - 1, 1).ToLower();
        var c = s.Substring(k);
        Console.WriteLine(a + b + c);
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    printf("%d", a*b-(a+b-1));

    
    return 0;
}



Measured memory_bytes: 1684
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int count_divisor(int N) {
    int num = 0;
    for (int i = 1; i*i <= N; i++) {
        if (N%i == 0) {
            if (i*i==N) num++;
            else num += 2;
        }
    }

    return num;
}

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
   
    int cnt = 0;
    for (int i = 1; i <= N; i+=2) {
        if (count_divisor(i) == 8) cnt++;
    }

    int ans = cnt;
    cout << ans << endl;

    return 0;
}

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

using namespace std;


void solve() {
    int N; cin >> N;
    N %= 10;
    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


int main() {
    solve();
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 200000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cout << "The value of " << #val << " is = " << val << endl;
#define testing cout << "--------------------------\n";

int main() {
	IOS
	int n;
	cin>>n;
	if(n%2==0) {
		cout<<"-1\n";
		return 0;
	}
	int cur=1,nw=7%n;
	while(nw) {
		nw=(nw*10+7)%n;
		cur++;
		if(cur>1e7) {
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<cur<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int a,b,c;

int main() {
    cin >> a >> b >> c;
    int res;
    if(a==b){
        res = c;
    }else if(b==c){
        res = a;
    }else{
        res = b;
    }
    put(res);
    return 0;
}


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int len = s.size();
    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    int countC = 0;
    for(int i = 2; i < len - 1; i++){
        if(s[i] == 'C'){
            countC++;
        }
    }
    if(countC != 1){
        cout << "WA" << endl;
        return 0;
    }
    int countA = 2;
    for(int i = 0; i < len; i++){
        if(s[i] >= 'A' && s[i] <= 'Z'){
            countA--;
        }
    }
    if(countA != 0){
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;
    return 0;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}



int main(void) 
{	
	int n; cin>> n;
	cout<< 180*(n-2);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vector<bool> use(n);
	vector<vector<pi>> e(n);
	rep(i, m){
		int a, b, c; cin >> a >> b >> c; a--; b--;
		e[a].emplace_back(b, c);
		e[b].emplace_back(a, c);
	}
	auto dij = [&](const vi &s){
		vi dist(n, inf);
		priority_queue<pi> q;
		for(int i : s) q.emplace(0, i);
		while(!q.empty()){
			int c, co; tie(co, c) = q.top(); q.pop();
			if(dist[c] < -co) continue;
			dist[c] = -co;
			for(pi p : e[c]){
				int to = p.first;
				if(dist[to] > -co + p.second){
					dist[to] = -co + p.second;
					q.emplace(co - p.second, to);
				}
			}
		}
		return dist;
	};
	int mxd = -1, ans = 0;
	rep(s, n){
		vi go = dij(vi(1, s));
		int mx = *max_element(all(go));
		if(mx < mxd) continue;
		if(mx > mxd) { use.clear(); use.resize(n); }
		mxd = mx;
		
		vi far;
		rep(i, n) if(go[i] == mx) far.pb(i);
		vi come = dij(far);
		rep(i, n) if(mx == go[i] + come[i]) use[i] = 1;
	}
	rep(i, n) if(!use[i]) ans++;
	cout << ans << endl;
	rep(i, n) if(!use[i]) cout << i+1 << endl;
	return 0;
}


Measured memory_bytes: 3304
n = int(input())
st = [1,2,4]
for i in range(n-3):
    s = st[-1] + st[-2] + st[-3]
    st.append(s)
while (n != 0):
    pn = st[n-1]
    if (pn%10 == 0):
        pn //= 10
    else:
        pn = pn//10 + 1

    if (pn%365 == 0):
        pn //= 365
    else:
        pn = pn//365 + 1
    print(pn)
    n = int(input())
    st = [1,2,4]
    for i in range(n-3):
        s = st[-1] + st[-2] + st[-3]
        st.append(s)


Measured memory_bytes: 5596
n = int(input())
red  = [tuple(map(int, input().split())) for _ in range(n)]
blue = [tuple(map(int, input().split())) for _ in range(n)]
red.sort(key=lambda x:-x[1])
blue.sort()
count = 0
for xb, yb in blue:
    for i in range(n):
        if xb > red[i][0] and yb > red[i][1]:
            red[i] = (201, 201)
            count += 1
            break
print(count)


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0;i < N;i++){
    cin >> vec.at(i);
  }
  
  string s = "DENIED";
  int gusucount = 0;
  int okcount = 0;
  
  for(int i = 0;i < N;i++){
    if(vec.at(i) % 2 == 0)gusucount++;
  }
  
  for(int i = 0;i < N;i++){
    if(vec.at(i) % 2 == 0 && (vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0)){
      okcount++;
    }
  }
  
  if(gusucount == okcount)s = "APPROVED";
  
  cout << s << endl;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())

    use = ["a"]
    if N == 1:
        print("a")
        exit()
    for i in range(1,N):
        ans = []
        for st in use:
            c = 0
            for t in st:
                c = max(c,ord(t)-ord("a"))
            for j in range(c+2):
                s = chr(97+j)
                if i == N-1:
                    print(st+s)
                else:
                    ans.append(st+s)
        use = ans
   
if __name__ == "__main__":
    main()


Measured memory_bytes: 6132
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int N;
  cin >> N;
  int m = 0;
  vector <int> h(N + 1, 0);
  for (int i = 0; i < N; i++) {
	  cin >> h[i];
	  m = max(m, h[i]);
	}
  int ans = 0;
  for (int k = 0; k < m; k++) {
	  for (int i = 0; i < N; i++) {
		  if (h[i] == 0) {
			  continue;
			}
		  h[i]--;
		  if (h[i + 1] == 0) {
			  ans++;
			}
		}
	}
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  int answer = 1;
  
  for(int i = 0; i < N - 1; i++) {
    if(S.at(i + 1) != S.at(i)){
      answer ++;
    }
  }
  cout << answer <<endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 1000006;

i64 n;
i64 a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 a, b, k;
    cin >> a >> b >> k;

    i64 t = min(a, k);
    a -= t;
    k -= t;

    i64 p = min(b, k);
    b -= p;
    k -= p;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n, l;
	cin >> n >> l;
	vector<P>a(n);
	int sum(0);
	rep(i, n) {
		a[i].first = abs(i + l);
		a[i].second = (i + l);

		sum += i + l;
	}
	sort(a.begin(), a.end());
	sum -= a[0].second;
	cout << sum;
	return 0;

}

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

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

    if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int a,b;
	int ticket[4] = {6000,4000,3000,2000};
	for(int i=0;i<4;i++){
		cin >> a >> b;
		cout << ticket[a-1]*b << endl;
	}
	return 0;
}

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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int d = int.Parse(str[0]);
            int n = int.Parse(str[1]);
            if (n == 100) n++;
            int kai = n * (int)(Math.Pow(100, d));


            Console.WriteLine(kai);


        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        int MAX = 510000;
        int MOD = 998244353;

        long fac[] = new long[MAX];
        long finv[] = new long[MAX];
        long inv[] = new long[MAX];
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A = sc.nextInt();
        long B = sc.nextInt();
        long K = sc.nextLong();

        comInit(fac, finv, inv, MAX, MOD);
        long res = 0;
        for (long a = 0; a <= N; a++) {
            long rem = K - a * A;
            if (rem % B == 0) {
                long b = rem / B;
                if (b <= N) {
                    long temp = com(N, (int) a, fac, finv, inv, MAX, MOD) * com(N, (int) b, fac, finv, inv, MAX, MOD)
                            % MOD;
                    res += temp;
                    res %= MOD;
                }
            }
        }
        System.out.println(res);
    }

    private static void comInit(long[] fac, long[] finv, long[] inv, int MAX, int MOD) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;

        }
    }

    private static long com(int n, int k, long[] fac, long[] finv, long[] inv, int MAX, int MOD) {
        if (n < k) {
            return 0;
        }
        if (n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

    }
}


Measured memory_bytes: 35796
n = int(input())
d, x = map(int, input().split())
a_list = []
for _ in range(n):
    a_list.append(int(input()))
    
# print(f"{n} {d} {x}")
# print(a_list)

ans = 0
for a in a_list:
    ans += 1
    ans += (d - 1) // a
    
print(ans + x)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
long long int printDivisors(long long int n) 
{ 
    long long int minAns = 1000000000005;
    for (long long int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                minAns = min(minAns, 2*abs(i-1));//printf("%d ", i); 
  
            else 
                minAns = min(minAns, abs(i-1)+abs(n/i-1));//printf("%d %d ", i, n/i); 
        } 
    }
    return minAns;
}
int main()
{
  long long int n;
  cin >> n;
  cout << printDivisors(n) << endl;
}

Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input().strip()) - 1])


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int main(void){
  int n;
  cin >> n;
  LL a[n];
  bool odd_flag = false;
  int cnt = 0;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) odd_flag = true;
  }

  while(!odd_flag) {
    cnt ++;
    for (int i = 0; i < n; i++) {
      a[i] /= 2;
      if (a[i] % 2 == 1) {
        odd_flag = true;
        break;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    cout << (A - B) * ((K % 2) ? -1 : 1) << endl;
}


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

int main()
{
    int k,n,a[200005],d,i,max;
    scanf("%d %d",&k,&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    max=-1;
    for(i=1;i<=n-1;i++)
    {
        d=a[i+1]-a[i];
        if(d>max)
        {
            max=d;
        }
    }
    d=k-a[n]+a[1];
    if(d>max)
    {
        max=d;
    }
    printf("%d\n",k-max);
}

Measured memory_bytes: 1024
#include "stdio.h"
#include "algorithm"
using namespace std;
int num[100050];
main()
{
    int n,k,mi=1,ma=100000;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {scanf("%d",&k);num[k]++;}
    while(mi<ma)
    {
        while((num[mi]==0||num[mi]==1)&&mi<ma) mi++;
        while((num[ma]==0||num[ma]==1)&&ma>mi) ma--;
        if(ma==mi) break;
        num[mi]--;num[ma]--;n-=2;
    }
    if(num[mi]%2==1&&mi==ma) n-=(num[mi]-1);
    else if(mi==ma) {n--;n-=(num[mi]-1);}
    printf("%d",n);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] r = new int[15][10];

		int info_num = sc.nextInt();
		for (int input_n = 0; input_n < info_num; input_n++) {

			int building = sc.nextInt() - 1;
			int floor = sc.nextInt() - 1;
			int room = sc.nextInt() - 1;
			int value = sc.nextInt();

			r[building * 4 + (floor)][room] += value;
		}

		for (int tate = 0; tate < 4; tate++) {
			for (int k = 0; k < 3; k++) {
				for (int j = 0; j < 10; j++) {

					System.out.print(" " + r[tate * 4 + k][j]);
				}
				System.out.println("");

			}
			if (tate != 3)
				System.out.println("####################");
		}

	}
}



Measured memory_bytes: 29836
#include<iostream>

using namespace std;

int main() {
	int nMoney1, nMoney5, nMoney10, nMoney50, nMoney100, nMoney500;

	cin >> nMoney1 >> nMoney5 >> nMoney10 >> nMoney50 >> nMoney100 >> nMoney500;

	nMoney5 *= 5;
	nMoney10 *= 10;
	nMoney50 *= 50;
	nMoney100 *= 100;
	nMoney500 *= 500;

	if ((nMoney1 + nMoney5 + nMoney10 + nMoney50 + nMoney100 + nMoney500) >= 1000)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int BE(int b,int e){
    int r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}



signed main(void){
    int N;
    int A[114514];
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    
    int inv[114514]={};
    int invsum[114514]={};
    REP(i,N+2){
        if(i==0)continue;
        inv[i]=BE(i,MOD-2);
    }
    REP(i,N+1){
        invsum[i+1]=invsum[i]+inv[i+1];
    }
    int Ans=0;
    REP(i,N){
        int sum=0;
        sum+=invsum[i+1];
        sum+=invsum[N-i];
        sum-=1;
        sum=(sum+MOD)%MOD;
        sum=(sum*A[i])%MOD;
        Ans=(sum+Ans)%MOD;
    }
    REP(i,N+1){
        if(i==0)continue;
        Ans=(Ans*i)%MOD;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> like(M, 0);

  rep(i, N)
  {
    int K;
    cin >> K;
    rep(j, K)
    {
      int a;
      cin >> a;
      a--;
      like[a]++;
    }
  }

  int sum = 0;
  rep(i, M)
  {
    if (like[i] == N)
      sum++;
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
	int x, y;
	while (cin >> x >> y, x, y) {
		char r[105][105];
		bool f[105][105];
		for (int i = 0;i < x;i++) {
			for (int j = 0;j < y;j++) {
				cin >> r[i][j];
				f[i][j] = false;
			}
		}

		int px = 0;
		int py = 0;
		int flg = 1;
		f[0][0] = true;

		while (1) {
			char a = r[px][py];
			if (a == '>') {
				py++;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else if(a=='<'){
				py--;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else if (a == 'v') {
				px++;
				if (f[px][py] == true) {
					flg =0 ;
					break;
				}
				else { f[px][py] = true; }
			}
			else if (a == '^') {
				px--;
				if (f[px][py] == true) {
					flg = 0;
					break;
				}
				else { f[px][py] = true; }
			}
			else { break; }
		}
		if (flg == 0)cout << "LOOP" << endl;
		else { cout << py << ' ' << px << endl; }

	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vl sumL(n+1,-1),sumR(n+1,-1);
    ll cnt1=0,cnt2=0;
    for(int i=0;i<n&&cnt1<k;){
        if(s[i]=='o'){
            cnt1++;
            sumL[i+1]=cnt1;
            i+=c+1;
        }
        else i++;
    }
    reverse(s.begin(),s.end());
    for(int i=0;i<n&&cnt2<k;){
        if(s[i]=='o'){
            cnt2++;
            sumR[i+1]=cnt2;
            i+=c+1;
        }
        else i++;
    }
    reverse(s.begin(),s.end());
    rep(i,n+1){
        if(sumR[i]>=0)sumR[i]=k-sumR[i]+1;
    }
    vi ans;
    rrep(i,n){
        if(sumL[i]!=-1&&sumR[n+1-i]!=-1&&sumL[i]==sumR[n+1-i]) ans.push_back(i);
    }
    rep(i,(int)ans.size()) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 5752
n = int(input())

ans = ""

i = 0
base = 1
while(n != 0):
    if(n % (base*2) == 0):
        ans += "0"
    else:
        ans += "1"
        n -= base
    i += 1
    base *= -2

if(ans == ""):
    ans = "0"

print(ans[::-1])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
int h, w, k;
char c[50][50], cp[50][50];
void copy() {
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cp[i][j] = c[i][j];
		}
	}
	return;
}
bool drop() {
	bool r = 0, r1 = 0;
	do {
		r1 = 0;
		for (int i = h - 1; i > 0; i--) {
			for (int j = 0; j < w; j++) {
				if (cp[i][j] == '.') {
					cp[i][j] = cp[i - 1][j];
					cp[i - 1][j] = '.';
					if (cp[i][j] != '.') { r = 1; r1 = 1; }
				}
			}
		}
	} while (r1);
	return r;
}
int chain() {
	int r = 0;
	for (int i = 0; i < h; i++) {
		int l = 0;
		for (int j = 0; j < w; j++) {
			if (j&&cp[i][j] == cp[i][j - 1])l++;
			else {
				if (l >= k && cp[i][j - 1] != '.') {
					for (int p = 0; p < l; p++) {
						r += cp[i][j - 1 - p] - '0';
						cp[i][j - 1 - p] = '.';
					}
				}
				l = 1;
			}
		}
		if (l >= k && cp[i][w - 1] != '.') {
			for (int p = 0; p < l; p++) {
				r += cp[i][w - 1 - p] - '0';
				cp[i][w - 1 - p] = '.';
			}
		}
		l = 1;
	}
	return r;
}
signed main() {
	cin >> h >> w >> k;
	int ans = 0;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cin >> c[i][j];
	for (int i = 1; i < h; i++)for (int j = 0; j < w; j++) {
		copy();
		cp[i][j] = '.';
		int p = 1, sum = 0;
		bool b = 1;
		do {
			b = drop();
			sum += chain()*p;
			p *= 2;
		} while (b);
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

int main(){
	int places = 0;
	for(int i = 0;i < 3;i++){
		char c;
		scanf("%c", &c);
		int a = atoi(&c);
		if(a) places++;		
	}
	printf("%d\n", places);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int getdigit(int n)
{
	int ans = 0;
	while(n > 0){
		ans++;
		n /= 10;
	}
	return ans;
}

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(getdigit(i) % 2 == 1) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int a, b; cin >> a >> b;
	b = b / gcd(a, b); a = b;
	int c = 1;
	for (int i = 2; i*i <= a; i++) {
		if (b%i == 0)c *= i;
		while (b%i == 0)b /= i;
	}
	if (b != 1)c *= b;
	cout << c << endl;
}

Measured memory_bytes: 3052
D,N = map(int,input().split())
A = [int(i) for i in range(1,100)] + [101]
B = [int(i*100) for i in range(1,100)] + [10100]
C = [int(i*10000) for i in range(1,100)] + [1010000]

if D == 0:
	print(A[N-1])
elif D == 1:
	print(B[N-1])
else:
	print(C[N-1])

Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int[][] map;
    static int[][] label;


    static ArrayList<String> list;

    static int M;
    static int N;
    static int T;
    static int P;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String a = scanner.next();
        String b = scanner.next();

        if(a.charAt(0) == b.charAt(0)){
            System.out.println("=");
        }else if(a.charAt(0) < b.charAt(0)){
            System.out.println("<");
        }else{
            System.out.println(">");
        }

    }



}


Measured memory_bytes: 23764
function Main(input) {
    var firstLine = input[0].split(/\s/);
    var N = parseInt(firstLine[0], 10);
    var M = parseInt(firstLine[1], 10);
    var H = input[1].split(/\s/).map(h => parseInt(h, 10));
    var AB = input.slice(2).map(ab => {
        var s = ab.split(/\s/);
        return {
            A: s[0],
            B: s[1]
        };
    });
    var list = new Array(N);
    list.fill(true);

    for (var i = 0; i < M; i++) {
        list[AB[i].A - 1] = list[AB[i].A - 1] && H[AB[i].A - 1] > H[AB[i].B - 1];
        list[AB[i].B - 1] = list[AB[i].B - 1] && H[AB[i].B - 1] > H[AB[i].A - 1];
    }

    var result = 0;
    for (var i = 0; i < N; i++) {
        if (list[i]) {
            result++;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 79604
//09, 02, 2019, 10:14:31 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll k, a, b;

    cin >> k >> a >> b;

    if(b <= a + 2LL || (a - 1LL) >= k){
        cout << 1LL + k << endl;
    }else{
        k -= (a - 1LL);
        ll have = a;
        ll add = 0LL;
        // cout << k << endl;

        if(k & 1LL){
            k--;
            add = 1LL;
        }
        // cout << add << endl;

        cout << (k / 2LL) * (b - a) + add + a << endl;
    }

    return 0;
}

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

#define fr first
#define sc second
//#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define forn(i, b, n) for (int i = b; i < n; ++i)
#define endl '\n'

using namespace std;
const int MAXN = 1e5 + 2, INF = 1e9 + 9, MOD = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
vi g[MAXN], p(MAXN);
vector<char> usd(MAXN);
vi ans, ans1;

void dfs(int v) {
    usd[v] = 1;
    ans.pb(v);
    for (int i : g[v]) {
        if (!usd[i]) {
            dfs(i);
            return;
        }
    }
}

void dfs1(int v) {
    usd[v] = 1;
    ans1.pb(v);
    for (int i : g[v]) {
        if (!usd[i]) {
            dfs1(i);
            return;
        }
    }
}

main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    forn(i, 0, m) {
        int a, b;
        cin >> a >> b, --a, --b;
        g[a].pb(b), g[b].pb(a);
    }
    dfs(0);
    for (int i : g[0]) {
        if (!usd[i]) {
            dfs1(i);
            break;
        }
    }
    reverse(all(ans1));
    for (int i : ans)
        ans1.pb(i);
    cout << ans1.size() << endl;
    for (int i : ans1)
        cout << i + 1 << ' ';
}


Measured memory_bytes: 10492
#include <stdio.h>

int main(){

int n,i,a;
long long sum=0,max=0,min=0;

scanf("%d",&n);

for(i=0;i<n;i++){
scanf("%d",&a);
if(i==0){
min = a;
max = a;
}
sum=sum+a;
if(max<a)
max=a;
if(min>a)
min=a;
}
printf("%lld %lld %lld\n",min,max,sum);
return 0;
}


Measured memory_bytes: 2748