akhauriyash/Code-Regression huggingface dataset:
import sys
while True:
  try:
    ans=[]
    hoge=raw_input()
    hoge+="  "
    for i in range(len(hoge)-2):
      if hoge[i] == "@":
        tt = hoge[i+2]*int(hoge[i+1])
        ans.append(tt)
      else:
        if hoge[i-1] == "@" or hoge[i-2] == "@":
          continue
        else:
          ans.append(hoge[i])
    else:
      for i in range(len(ans)):
        sys.stdout.write(ans[i])
      else: print ""
  except EOFError: break

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

int main()
{   stack<int> stk;
    string num;
    int tmp1,tmp2;
    while(cin>>num) {
        if (num[0]=='+'||num[0]=='-'||num[0]=='*'){
                tmp1 = stk.top();
                stk.pop();
                tmp2 = stk.top();
                stk.pop();
                if (num[0]=='+') stk.push(tmp2 + tmp1);
                if (num[0]=='-') stk.push(tmp2 - tmp1);
                if (num[0]=='*') stk.push(tmp2 * tmp1);
            } else
                stk.push(stoi(num));
        char c=getchar();
        if(c=='\n')  break;
        }
    cout<<stk.top()<<endl;
    return 0;
}



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

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;
  cin >> n >> m;

  vector< list< pair<int,int> > > ids(m);
  while(1){
    int s,t,e;
    cin >> s >> t >> e;
    if(s==0)break;
    s--; t--;
    ids[t].push_back(make_pair(s,e));
  }

  int l;
  cin >> l;
  for(int i=0;i<l;i++){
    vector<int> c(n,0);
    for(int j=0;j<m;j++){
      int b;
      cin >> b;
      for(pair<int,int> a : ids[j])c[a.first] += a.second * b;
    }

    for(int j=0;j<n;j++)cout << c[j] << (" \n"[j==n-1]);
  }
}

Measured memory_bytes: 2844
/* 3_A_Stack_Ans.c */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
    /* topを可算してからその位置へ挿入 */
    S[++top] = x;
}

int pop() {
    /* topが指していた要素を返しtopの位置を一つ下げる */
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char com[100];

    while(scanf("%s", com) != EOF) {
        if (com[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if (com[0] == '-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if (com[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(com));
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2088
import sys

input = sys.stdin.readline

def checkSpell(s, t):
    return s == t

def main():
    n = int(input())
    s = input()
    t = input()
    for i in range(n):
        ans = 0
        for j in range(n):
            if s[i] == t[j]:
                while checkSpell(s[i], t[j]):
                    ans += 1
                    i += 1
                    j += 1
                    if i == n or j == n:
                        print(n*2 - ans)
                        sys.exit()
    print(n*2)

if __name__ == '__main__':
    main()

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

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


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

using namespace std;

char stem[300];

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n==0) break;

    char step[300];
    int i;
    for(i=0;i<2*n;i+=2) cin >> stem[i] >> stem[i+1];
    
    int j, flag = 0, flagl = 0, flagr = 0, ans=0;
    for(j=0;j<n;j++){
      if(stem[2*j]=='l'){
	if(stem[2*j+1]=='u') flagl = 1;
	else if(stem[2*j+1]=='d') flagl = 0;
	else printf("e1\n");
      }
      if(stem[2*j]=='r'){
	if(stem[2*j+1]=='u') flagr = 1;
	else if(stem[2*j+1]=='d') flagr = 0;
	else printf("e2\n");
      }
      if(flag == 0){
	if(flagl==1&&flagr==1){
	  ans++;
	  flag=1;
	}
      }
      if(flag == 1){
	if(flagl==0&&flagr==0){
	  ans++;
	  flag=0;
	}
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}



Measured memory_bytes: 3184
bingo = [[0]*3 for i in range(3)]
for i in range(3): bingo[i][0:3] = map(int,input().split())

for i in range(int(input())):
  bn = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == bn: bingo[j][k] = -1

if (bingo[0][0] == -1 and bingo[0][1] == -1 and bingo[0][2] == -1) or \
   (bingo[1][0] == -1 and bingo[1][1] == -1 and bingo[1][2] == -1) or \
   (bingo[2][0] == -1 and bingo[2][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][0] == -1 and bingo[2][0] == -1) or \
   (bingo[0][1] == -1 and bingo[1][1] == -1 and bingo[2][1] == -1) or \
   (bingo[0][2] == -1 and bingo[1][2] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int R, C; cin >> R >> C;
		if (!R)break;
		vector<vector<int>>field(R, vector<int>(C));
		for (int i = 0; i < R; ++i) {
			for (int j = 0; j < C; ++j) {
				int a; cin >> field[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < (1 << R); ++i) {
			bitset<10>bs(i);
			for (int r = 0; r < R; ++r) {
				if (bs[r]) {
					for (int c = 0; c < C; ++c) {
						field[r][c] = !field[r][c];
					}
				}
			}
			int sum = 0;
			for (int c = 0; c < C; ++c) {
				int anum = 0;
				for (int r = 0; r < R; ++r) {
					if (field[r][c])anum++;
				}
				sum += max(anum, R - anum);
			}
			ans = max(ans, sum);
			for (int r = 0; r < R; ++r) {
				if (bs[r]) {
					for (int c = 0; c < C; ++c) {
						field[r][c] = !field[r][c];
					}
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const long long M = (1LL << 32);

long long encode(string s){
    long long res = 0;
    rep(i,s.size()){
        res *= 16;
        if(s[i] >= 'a' && s[i] <= 'z'){
            res += 10 + s[i] - 'a';
        }else{
            res += s[i] - '0';
        }
    }
    return res;
}

int log16(long long n){
    int res = 0;
    while(n > 0){
        n /= 16;
        res++;
    }
    return res - 1;
}

string encode(long long n){
    if(n == 0) return "0";
    string str;
    int len = static_cast<int>(log16(n));
    long long K = 1;
    rep(i,len) K*=16;
    rep(i,len + 1){
        if(n / K == 0) str+= '0';
        else{
            if(n / K > 9) str += 'a' + (n / K - 10);
            else str+= ('0' + n / K);
        }
        n%=K; K/=16;
    }
    return str;
}

bool getBit(long long num, int i){
    return ((num & (1 << i)) != 0);
}

int main(){
    long long t;
    cin >> t;

    while(t--){
        vector<long long> a;
        long long s;
        rep(i,9){
            string x;
            cin >> x;
            if(i == 8) s = encode(x);
            else a.emplace_back(encode(x));
        }

        long long k = 1;
        long long ans = 0;
        rep(i,32){
            long long sum = accumulate(all(a), 0LL) % M;
            if(getBit(sum,i) ^ getBit(s,i)){
                ans += 1LL << i;
                rep(j,8)  a[j] ^= 1LL << i;
            }
            //show(ans)
        }
        cout << encode(ans % M) << endl;
    }
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2000005;
int fac[maxn],facinv[maxn];
const int f[4][2]={{0,0},{1,0},{1,1},{0,1}},w[4]={1,-1,1,-1};
int a[20][2];
const int mod=1e9+7;
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
inline void prprpr(){
	fac[0]=1;
	rep(i,1,2000000)fac[i]=1ll*fac[i-1]*i%mod;
	facinv[2000000]=powmod(fac[2000000],mod-2);
	per(i,1999999,0)facinv[i]=1ll*facinv[i+1]*(i+1)%mod;
}
inline int calc(int x,int y){
	return 1ll*fac[x+y]*facinv[x]%mod*facinv[y]%mod;
}
inline void add(int &x,int y){
	y=(y+mod)%mod;
	x=((x+y)>=mod?(x+y-mod):(x+y));
}
inline int get(int x0,int y0,int x1,int y1){
	int res=0;
	rep(i,a[2][0],a[3][0]){
		add(res,1ll*calc(i-x0,a[2][1]-1-y0)*calc(x1-i,y1-a[2][1])%mod*(-i-a[2][1])%mod);
		add(res,1ll*calc(i-x0,a[3][1]-y0)*calc(x1-i,y1-a[3][1]-1)%mod*(i+1+a[3][1])%mod);
	}	
	rep(i,a[2][1],a[3][1]){
		add(res,1ll*calc(a[2][0]-1-x0,i-y0)*calc(x1-a[2][0],y1-i)%mod*(-i-a[2][0])%mod);
		add(res,1ll*calc(a[3][0]-x0,i-y0)*calc(x1-a[3][0]-1,y1-i)%mod*(i+1+a[3][0])%mod);
	}
	return res;
}
int main(){
	prprpr();
	rep(i,0,1)rep(j,0,5)read(a[j][i]);
	rep(i,0,1)rep(j,0,1)a[j][i]--;
	int ans=0;
	rep(i,0,3)rep(j,0,3) 
		add(ans,get(a[f[i][0]][0]+f[i][0],a[f[i][1]][1]+f[i][1],a[4+f[j][0]][0]+f[j][0],a[4+f[j][1]][1]+f[j][1])*w[i]*w[j]%mod);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16000
#include<stdio.h>
int main(void)
{
    char s[100000];
    int n,i=0;
    scanf("%d%s",&n,s);
    while(s[i]!='\0'){
        s[i]='A'+(s[i]-'A'+n)%26;
        i++;
    }
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
# Useful data structures
from collections import Counter

# For sys.std*, sys.argv etc...
import sys

# For cases when input tokens are spread unevenly over many lines.
# This provides methods for reading tokens of various types.
class BufferedTokenizer:
    pass

def read_ints():
    return [int(token) for token in input().split()]

def read_tokens():
    return input().split()

def main():
    N = read_ints()[0]
    votes = Counter(input() for _ in range(N))
    best = votes.most_common(1)[0][1]
    for vote in sorted(v[0] for v in votes.most_common() if v[1] == best):
        print(vote)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43476
red, green, blue = map(int, input().split())
K = int(input())
res = 'No'
cnt = 0

# green > a に必要な回数を消費
while green <= red:
    green *= 2
    cnt += 1
# blue > green に必要な回数を消費
while blue <= green:
    blue *= 2
    cnt += 1

# 結果を判定
if cnt <= K:
  res = 'Yes'

print(res)


Measured memory_bytes: 9160
#include <cstdio>
#include <iostream>
#include <set>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int n,num[100005],ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
        if(num[i]==i) ans++;
    }
    if(!ans){
        cout<<0<<endl;
        return 0;
    }
    ans=0;
    for(int i=1;i<=n;i++){
        if(num[i]==i){
            ans++;
            swap(num[i],num[i+1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
LL f(LL a, LL b) {
	if (b%a == 0) {
		return 2 * (b / a)*a - a;
	}
	return 2 * (b / a)*a + f(b%a, a);
}
int main() {
	LL N, X;
	cin >> N >> X;
	LL a = X, b = N - X;
	if (a > b) swap(a, b);
	cout << N + f(a, b) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;



namespace Test
{
    class MainClass
    {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            int n = int.Parse(s);
            int sn = 0;
            for (int i = 0; i < s.Length; i++) {
                sn += s[i] - '0';
            }
            if (n % sn == 0) {
                Console.WriteLine("Yes");
            }
            else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <set>


int main() {
    int N;
    std::cin >> N;

    std::set<std::string> gacha;
    for (int i = 0; i < N; i++) {
        std::string str;
        std::cin >> str;
        gacha.insert(str);
    }
    std::cout << gacha.size() << std::endl;
}


Measured memory_bytes: 19180
#include <iostream>


using namespace std;


bool** VV;
int num_vertex;
int num_edge;
bool* is_visited;


bool is_reached_all_nodes( int size ) {
    for ( int i = 0; i < size; i++ ) {
        if ( !is_visited[ i ] ) { return false; }
    }
    return true;
}


int trace( int previous, int current ) {
    if ( is_visited[ current ] ) { return 0; }

    is_visited[ current ] = true;
    if ( is_reached_all_nodes( num_vertex ) ) {
        is_visited[ current ] = false;
        return 1;
    }
    
    int result = 0;
    for ( int next = 0; next < num_vertex; next++ ) {
        if ( previous == next ) { continue; }
        
        if ( VV[ current ][ next ] ) {
            result += trace( current, next );
        }
    }

    is_visited[ current ] = false;
    return result;
}


int main() {
    cin >> num_vertex >> num_edge;

    is_visited = new bool[ num_vertex ];
    
    VV = new bool*[ num_vertex ];
    for ( int i = 0; i < num_vertex; i++ ) {
        VV[ i ] = new bool[ num_vertex ];
    }

    for ( int i = 0; i < num_edge; i++ ) {
        int a, b;
        cin >> a >> b;
        VV[ a - 1 ][ b - 1 ] = true;
        VV[ b - 1 ][ a - 1 ] = true;
    }

    cout << trace( -1, 0 ) << endl;
    
    delete[] is_visited;

    for ( int i = 0; i < num_vertex; i++ ) {
        delete[] VV[ i ];
    }
    delete[] VV;
    
    return 0;
}


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

int main(){

	string s, t ;
	cin >> s >> t ;

	int cnt = 0 ;
	for(int i = 0 ; i < s.size() ; i++){
		cnt += (s[i] != t[i]) ;
	}

	cout << cnt << endl ;

	return 0;
}

Measured memory_bytes: 3912
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	ll mod = 1e9 + 7;
	ll n;
	cin >> n;
	map<ll, ll> mp;
	for (int i = 1; i <= n; i++) {
		int unko = i;
		for (int j = 2; j <= i; j++) {
			while (unko % j == 0) {
				unko /= j;
				mp[j]++;
			}
		}
	}
	ll ans = 1;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans *= it->second  + 1;
		ans %= mod;
	}
	dump(ans);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();

    int i = 0;
    int cnt = 0;
    while (i != -1) {
      i = s.indexOf("ABC");
      if (i == -1) {
        break;
      }
      cnt++;
      s = s.substring(i + 3);
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	static int K;
	static String S;
	static int s;
	static String x;
	public  static void main(String[]args) {
		Scanner sc= new Scanner(System.in);
		K=sc.nextInt();
		S=sc.next();
		s=S.length();
		if(K>=s) {
			System.out.println(S);
		}
		else {
			x=S.substring(0,K);
			System.out.println(x+"...");
		}
	}
}

Measured memory_bytes: 38576
#include <iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	if(N%(N/100000000+N/10000000%10+N/1000000%10+N/100000%10+N/10000%10+N/1000%10+N/100%10+N/10%10+N%10)==0){
		cout<<"Yes";
	}
	else{
		cout<<"No"<<endl;
	}
	/*for(int i=0;i<;i++){
		
	}*/
}

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

struct point {
  int x;
  int y;
};

class LessX {
public:
  bool operator()(const struct point & Left, const struct point & Right) const {
      return Left.x < Right.x;
  };
};

class GreaterY {
public:
  bool operator()(const struct point & Left, const struct point & Right) const {
      return Left.y > Right.y;
  };
};

int main(){
  int n;
  cin >> n;
  struct point red[100];
  struct point blue[100];
  for(int i=0;i<n;i++){
    cin >> red[i].x >> red[i].y;
  }
  for(int i=0;i<n;i++){
    cin >> blue[i].x >> blue[i].y;
  }

  sort(blue,blue+n,LessX());
  sort(red,red+n,GreaterY());

  int flag[100];
  for(int i=0;i<n;i++){
    flag[i]=1;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(blue[i].x>red[j].x&&blue[i].y>red[j].y&&flag[j]){
        flag[j]=0;
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;


  return 0;
}


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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int  A, B,cnt = 0;
	int tmp=1;
	i_cin2(A, B);

	while(tmp<B) {
		tmp--;
		tmp += A;
		cnt++;
	}

	i_cout(cnt);
	return 0;

}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var ans = true;
            if (S[0] != 'A') ans = false;
            if (!char.IsLower(S[1])) ans = false;
            var cHas = false;
            for (var i = 2; i < S.Length - 1; i++)
            {
                if (!char.IsLower(S[i]))
                {
                    if (S[i] == 'C' && !cHas) cHas = true;
                    else ans = false;
                }
            }
            if (!cHas) ans = false;
            if (!char.IsLower(S[S.Length - 1])) ans = false;

            Console.WriteLine(ans ? "AC" : "WA");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

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

    int result=0;
    result += B;
    if(C>A+B+1)result += A+B+1;
    else result += C;

    cout << result << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n;
    cin>>n;
    ll ans=LLINF;
    for(ll i=1;i*i<=n;i++){
        if(n%i!=0) continue;
        string s=to_string(i),t=to_string(n/i);
        chmin(ans,max((ll)s.size(),(ll)t.size()));
    }
    cout<<ans<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

int main(void){
  int x0=0,x1,y0=0,y1;
  int x,y,a,n;

  scanf("%d %d %d",&x1,&y1,&n);

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&x,&y,&a);
    if(a==1)
      x0 = max(x0,x);
    if(a==2)
      x1 = min(x1,x);
    if(a==3)
      y0 = max(y0,y);
    if(a==4)
      y1 = min(y1,y);
  }
  printf("%d\n",(y1-y0)*(x1-x0)>0&&(y1-y0)>0&&(x1-x0)>0?(y1-y0)*(x1-x0):0);

  return 0;
}
      


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
 char s[11],c[11];
 int i,j=0;
 scanf("%s",s);
 for(i=0;i<strlen(s);i++){
  if(s[i]!='B') c[j++]=s[i];
  else{
   if(j>0) c[--j]='\0';
   else c[j]='\0';
  }
 }
 c[j]='\0';
 printf("%s",c);
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]==',')
		{
			cout<<" ";
		}
		else
			cout<<a[i];
	}
	return 0;
}



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

int Board[102][102];    //Board[j, x, w][i, y, h]
bool isOK;              //迷路がOKかNGか
int xs, ys, xg, yg;     //StartとGoalの座標

void DFS(int c, int x, int y){
    if(Board[x][y] != c){
        return;
    }
    else if(x==xg && y==yg){
        isOK = true;    //Goalなら迷路はOK
        return;
    }

    Board[x][y] = 0;

    DFS(c, x+1, y  );
    DFS(c, x  , y+1);
    DFS(c, x-1, y  );
    DFS(c, x  , y-1);
}



int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        
        isOK = false;               //初期値をNGに
        for(int i=1;i<=100;i++){     //Boardの初期化
            for(int j=1;j<=100;j++)
                Board[j][i] = -1;
        } 
        cin >> xs >> ys >> xg >> yg;

        int n, c, d, x, y;
        cin >> n;
        for(int t=0;t<n;t++){
            cin >> c >> d >> x >> y;
            int wb = 2+(!d*2);      //d=0なら横長
            int hb = 2+(d*2);       //d=1なら縦長
            for(int i=0;i<hb;i++){
                for(int j=0;j<wb;j++)
                    Board[x+j][y+i] = c;
            }
        }

        DFS(Board[xs][ys], xs, ys);

        if(isOK)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;

    }

    return 0;
}



Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>]
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main(){
ll x,y,z;cin>>x>>y>>z;
x-=z;
cout<<max(0ll,x/(y+z));

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,k,i,j;
  cin >> n >> k;
  double ans=0;
  for(i=1;i<=n;i++){
    double ans1=1;
    j=i;
    while(j<k){
      ans1*=1/(double)2;
      j=j*2;
    }
    ans+=1/(double)n*ans1;
  }
  printf("%.12lf\n",ans);
}

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

using namespace std;

int64_t solve(int64_t n, const std::array<int64_t, 5>& ps) {
  auto fewPeople = true;
  int64_t minimum = INT64_MAX;
  for (int i = 0; i < ps.size(); ++i) {
    auto const p = ps[i];
    minimum = std::min(p, minimum);
    if (p < n) {
      fewPeople = false;
    }
  }
  if (fewPeople) {
    return 5;
  }

  int64_t const ret = (n + minimum - 1) / minimum + 4;
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::array<int64_t, 5> ps;
  for (auto& p : ps) {
    std::cin >> p;
  }
  std::cout << solve(n, ps) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    string s;
    cin >> s;
    if(s == "SUN")  cout << 7 << endl;
    if(s == "MON")  cout << 6 << endl;
    if(s == "TUE")  cout << 5 << endl;
    if(s == "WED")  cout << 4 << endl;
    if(s == "THU")  cout << 3 << endl;
    if(s == "FRI")  cout << 2 << endl;
    if(s == "SAT")  cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

/**
 * C
 */
fn main() {
    let n: i64 = {
        let mut  s = String::new();
        stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };

    if n % 2 == 0 { // nが偶数
        let h = n / 2;
        let w = n;
        let l = n;
        println!("{} {} {}", h, w, l)
    } else { // nが奇数
        let mut w = 0;
        let mut h = 0;
        let mut l = 0;
        'outer: for i in 1..3501 {
            'inner: for j in 1..3501 {
                if (4*i*j-n*j-n*i == 0) { continue 'inner ; }
                w = n*i*j / (4*i*j-n*j-n*i);
                h = i;
                l = j;
                if (n*i*j % (4*i*j-n*j-n*i) == 0 && w > 0) {
                    break 'outer
                }
            }
        }
        println!("{} {} {}", h, w, l)
    }


}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
    using namespace std;
    int main(){
      ios_base::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
      int a,b,c;
      cin>>a>>b>>c;
      cout<<c<<" "<<a<<" "<<b<<endl;
      return 0;
    } 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t dceil(int64_t, int64_t);
int64_t dfloor(int64_t, int64_t);

int64_t dceil(int64_t x, int64_t y)
{
    if (y < 0) {
        return dceil(-x, -y);
    }
    if (x < 0) {
        return -dfloor(-x, y);
    }
    return (x + y - 1) / y;
}

int64_t dfloor(int64_t x, int64_t y)
{
    if (y < 0) {
        return dfloor(-x, -y);
    }
    if (x < 0) {
        return -dceil(-x, y);
    }
    return x / y;
}

int main()
{
    int64_t x;
    cin >> x;

    int64_t r1 = dceil(x - 6, 11) * 2 + 1;
    int64_t r2 = dceil(x, 11) * 2;
    cout << min(r1, r2) << endl;

    return 0;
}

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

const int mod = 1e9 + 7;

long long bp(long long a, int n) {
	if(n == 0) return 1;
	if(n & 1) return a * bp(a % mod, n - 1) % mod;
	return bp(a * a % mod, n / 2) % mod;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n], b[n], cnt[n + 1] = {0};
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
		cnt[b[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		if(cnt[i] > n) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	reverse(b, b + n);
	for(int i = 0; i < n; i++) {
		if(a[i] == b[i]) {
			for(int j = 0; j < n; j++) {
				if(b[j] != a[i] and a[j] != b[i]) {
					swap(b[i], b[j]);
					break;
				}
			}
		}
	}
	for(int i = 0; i < n; i++) cout << b[i] << ' ';
	return 0;
}


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

typedef long long ll;

ll A, B, C, K;

int main() {
	scanf("%lld%lld%lld%lld", &A, &B, &C, &K);

	ll res = (K % 2 ? B - A : A - B);
	printf("%lld\n", res);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int N = 1e4 + 10;
int n, m;
ll a[N], b[N];

int main()
{
	int i;

	scanf("%d", &n);

	for (i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
	}
	for (i = 1; i <= n; ++i) {
		scanf("%lld", &b[i]);
	}

	ll keep = 0;
	for (i = 1; i <= n; ++i) {
		if (a[i] > b[i]) {
			keep += a[i] - b[i];
		}
		else {
			keep -= (b[i] - a[i]) / 2;
		}
	}

	if (keep > 0) printf("No\n");
	else printf("Yes\n");
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

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

    int sum = n + n * n + n * n * n;
    cout << sum << endl;
}

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

using namespace std;

int main(){
  int n;
  int max = 0;
  cin >> n;

  vector<int> h(n+1);

  for(int i=1;i<=n;i++)
  {
    cin >> h[i];

    if (max - h[i] > 1){
      cout << "No" << endl;
      return 0;
    }
    if(max <= h[i]) max = h[i];

  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
vector<vector<int>>s(100030);
vector<vector<int>>sb(100030);
int tomodati[100030] = {};
int seen[100030] = {};
int namaes[100030] = {};
int main() {
	vector<int>s = { 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 };
	int k;
	cin >> k;
	cout << s[k-1];
}


Measured memory_bytes: 4992
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    s = 0
    for i in a:
        s ^= (i%2)
    if s:
        print("NO")
    else:
        print("YES")
    return

#B
def B():
    n = I()
    a = LI()
    m = n*(n+1)>>1
    s = sum(a)
    if s%m:
        print("NO")
        return
    k = s//m
    b = [k+a[i-1]-a[i] for i in range(n)]
    s = 0
    for i in b:
        if i%n or i < 0:
            print("NO")
            return
        s += i//n
    if s == k:
        print("YES")
    else:
        print("NO")
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 59632
n = int(input())
map_list = [[-1 for i in range(n)] for i in range(n)]

for i in range(n):
    m = int(input())
    for j in range(m):
        x,y = map(int,input().split())
        map_list[i][x-1]=y
ans=0
for i in range(2**n):
    honest = [0 for i in range(n)]
    for j in range(n):
        if (i>>j)&1:
            honest[j]=1
    flag=True
    for j in range(n):
        if honest[j]:
            for k in range(n):
                if map_list[j][k]==-1:continue
                if map_list[j][k]!=honest[k]:flag=False
    if flag:
        ans=max(ans,honest.count(1))
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<ll> A(n);
  for (auto &x : A)
    cin >> x;
  sort(A.rbegin(), A.rend());
  ll ans = 0, tot = n - 1;
  for (int i = 0; i < n && tot > 0; i++) {
    int thistot = min(tot, 2LL);
    if (i == 0)
      thistot = 1;
    ans = ans + thistot * A[i];
    tot -= thistot;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4760
ans = 0

n,k = map(int,input().split())
prob = 1/n

for i in range(1,n+1):
	
	num = i
	count = 0
	while(i < k):
		i = i*2
		count += 1

	prob2 = pow(2,count)

	an = (1 / prob2)
	# print(prob2)
	ans += an

ans = ans * prob
print(ans)

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

int res[10000];
int table[10][10];

int check(int n){
	int d = n / 1 % 10;
	int c = n / 10 % 10;
	int b = n / 100 % 10;
	int a = n / 1000 % 10;
	int r1 = table[0][a];
	int r2 = table[r1][b];
	int r3 = table[r2][c];
	int r4 = table[r3][d];
	return r4;
}

bool f(int n){
	vector<int> a(5);
	a[4] = n / 1 % 10;
	a[3] = n / 10 % 10;
	a[2] = n / 100 % 10;
	a[1] = n / 1000 % 10;
	a[0] = n / 10000 % 10;
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 10; j++){
			if(a[i] == j) continue;
			vector<int> b = a;
			b[i] = j;
			int m = b[0] * 1000 + b[1] * 100 + b[2] * 10 + b[3];
			if(table[res[m]][b[4]] == 0){
				return false;
			}
		}
	}
	for(int i = 0; i < 4; i++){
		if(a[i] == a[i + 1]) continue;
		vector<int> b = a;
		swap(b[i], b[i + 1]);
		int m = b[0] * 1000 + b[1] * 100 + b[2] * 10 + b[3];
		if(table[res[m]][b[4]] == 0){
			return false;
		}
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> table[i][j];
		}
	}

	for(int i = 0; i < 10000; i++){
		res[i] = check(i);
	}

	int ans = 0;
	for(int i = 0; i < 10000; i++){
		if(!f(i * 10 + res[i])) ans++;
	}
	cout << ans << endl;
}

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

					#define F first
					#define S second
					#define N 222222
					#define M 1000000007
					#define pb push_back
					#define cend(s) return cout << s, 0
					using namespace std;
					typedef long long ll;
					typedef vector<int> vi;

					int main()
					{
						string s;
						int k = 0, t = 0;
						cin >> s;
						for(int i = 0; i < 3; i++)
							if(s[i] == 'R')
								k++;
							else t = max(k, t), k = 0;
                      	t = max(t, k);
						cout << t;		
					}


Measured memory_bytes: 3540
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static List<int[]>[] g;
	private static int[] vs;
	private static boolean[] visited;

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

		visited = new boolean[n];
		vs = new int[n];
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < m; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			int d = sc.nextInt();
			g[l].add(new int[]{r, d});
			g[r].add(new int[]{l, -d});
		}

		for (int i = 0; i < n; i++) {
			if (visited[i]) continue;
			if (!dfs(i, 0)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	private static boolean dfs(int v, int x) {
		if (visited[v]) {
			return vs[v] == x;
		}
		visited[v] = true;
		vs[v] = x;
		for (int i = 0; i < g[v].size(); i++) {
			int[] a = g[v].get(i);
			if (!dfs(a[0], vs[v] + a[1])) {
				return false;
			}
		}
		return true;
	}
}


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

int main() {
  int N,flag=0;
  cin >> N;
  for(int i=9;i>0;i--){
    if(N%i==0 && N/i<=9){
      cout << "Yes" << endl;
      flag=1;
      break;
    }
  }
  if(flag==0){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,total=0;
  cin>>a>>b>>c;
  int x;
  cin>>x;
  int n_500=10*a,n_100=2*b,n_50=c;
  int given=x/50;
  if(a*500+b*100+c*50<x||x==0){
    cout<<"0\n";
  }
  else{
    if(n_500>=given&&x%500==0)
      total++;
    if(n_100>=given&&x%100==0)
      total++;
    if(n_50>=given&&x%50==0)
      total++;
    int i,j,k;
    for(i=10;i<=n_500;i+=10){
        for(j=2;j<=n_100;j+=2){
          if(i+j==given){
            total++;
            break;
          }
        }
    }
    //cout<<total<<"\n";
    for(i=10;i<=n_500;i+=10){
        for(j=1;j<=n_50;j+=1){
            if(i+j==given){
                total++;
                break;
            }
        }
    }
    //cout<<total<<"\n";
    for(i=2;i<=n_100;i+=2){
        for(j=1;j<=n_50;j+=1){
            if(i+j==given){
            total++;
            break;
            }
        }
    }
    //cout<<total<<"\n";
    for(i=10;i<=n_500;i+=10){
    	for(j=2;j<=n_100;j+=2){
    		for(k=1;k<=n_50;k+=1){
    			if(i+j+k==given){
    				total++;
    				break;
    			}
    		}
    	}
    }
    cout<<total<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll a, b, n; cin >> a >> b >> n;
	if( n >= b ){
		cout << (a*(b-1))/b << endl;
	} else cout << (a*n/b) - a*(n/b) << endl;
}

Measured memory_bytes: 3632
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA(-1);
	
	auto list = new long[][](65, N);
	foreach (i; 0..N)
	{
		list[0][i] = A[i];
	}

	foreach (i; 1..65)
	{
		foreach (j; 0..N)
		{
			auto mid = list[i-1][j];
			list[i][j] = list[i-1][mid];
		}
	}
	debug writeln(list);

	long pos;
	foreach (i; 0..64)
	{
		auto bit = 1L << i;
		if (K & bit)
		{
			pos = list[i][pos];
			debug writeln("pos:", pos);
		}
	}

	writeln(pos+1);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 111160
from collections import deque
N, M = map(int, input().split())
X = [[] for x in range(N+1)]
for m in range(M):
    A, B = map(int, input().split())
    X[A].append(B)
    X[B].append(A)

Q = deque()
Q.append(1)

D = [-1]*(N+1)
D[0] = 0
D[1] = 0
while Q:
    v = Q.pop()
    for i in X[v]:
        if D[i] == -1:
            D[i] = v
            Q.appendleft(i)
if -1 in D:
    print('No')
else:
    print('Yes')
    print(*D[2:])

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

#define int long long
const int INF = 1e15;
const int NO = 1e9;

int dp[1001][1<<12];
int N, M;
vector<int> A, B;
vector<int> C;

int dfs(int m, int b) {
  if ( b == (1<<N)-1 ) return 0;
  if ( m == M ) return NO;
  if ( dp[m][b] != INF ) return dp[m][b];

  int ret = dfs(m+1, b);
  int nxt = b | C[m];  

  ret = min(ret, dfs(m+1, nxt)+A[m]);

  return dp[m][b] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  fill_n(*dp, 1001*(1<<12), INF);

  cin >> N >> M;
  A = B = vector<int>(M);
  C = vector<int>(M);  
  for ( int i = 0; i < M; i++ ) {
    cin >> A[i] >> B[i];
    int b = 0;    
    for ( int j = 0; j < B[i]; j++ ) {
      int c;
      cin >> c;
      b |= (1LL<<(c-1));      
    }
    C[i] = b;    
  }

  int ans = dfs(0, 0);
  if ( ans >= NO ) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 32384
def main():
    n = int(input().strip())

    cnt = 0
    for i in range(1, n+1, 2):
        m = i
        li = []
        for j in range(1, n+1, 2):
            if m % j == 0:
                li.append(j)

        if len(li) == 8:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40304