akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double EPS = 1e-8;

bool is_all_same(string num){
  sort(num.begin(),num.end());
  for(int i=0;i+1<num.size();i++){
    if(num[i] != num[i+1]){
      return false;
    }
  }
  return true;
}

bool is_6174(const string& num){
  if(num[0] == '6'
     && num[1] == '1'
     && num[2] == '7'
     && num[3] == '4'){
    return true;
  }

  return false;
}

bool is_0000(const string& num){
  if(num[0] == '0'
     && num[1] == '0'
     && num[2] == '0'
     && num[3] == '0'){
    return true;
  }

  return false;
}

int main(){
  string LminusS;
  
  while(cin >> LminusS){
    if(is_0000(LminusS)) break;

    int count = INF;
    for(int round=0;round <= 1000000;round++){
      if(is_all_same(LminusS)) break;
      if(is_6174(LminusS)){
	count = round;
	break;
      }
      string smaller = LminusS;
      sort(smaller.begin(),smaller.end());
      
      string larger = LminusS;
      sort(larger.begin(),larger.end(),greater<char>());

      int num = atoi(larger.c_str()) - atoi(smaller.c_str());
      stringstream ss;
      ss << num;
      string next = ss.str();
      while(next.size() < 4) next = "0" + next;
      LminusS = next;
    }

    if(count == INF){
      printf("NA\n");
    }
    else {
      printf("%d\n",count);
    }
  }
}

Measured memory_bytes: 1256
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = H[i-1]+abs(h[i]-h[i-1])
        if H[i] > H[i-2]+abs(h[i]-h[i-2]):
            H[i] = H[i-2]+abs(h[i]-h[i-2])
print(H[N-1])


Measured memory_bytes: 13980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = Integer.parseInt(sc.next());
		final int B = Integer.parseInt(sc.next());
		int ans = A + B;
		if(A * B > ans) {
			ans = A * B;

		}
		if(A - B > ans) {
			ans = A - B;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    // maior media e menor media
    vi a(n), b(n);
    vi maior, menor; 
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i] >> b[i];
        maior.push_back(b[i]);
        menor.push_back(a[i]);
    }
    sort(all(menor));
    sort(all(maior));
    
    auto calc_med = [&] (const vi& v)
    {
        if(n % 2 == 1) return v[n / 2] * 2;
        else return (v[n / 2] + v[n / 2 - 1] );
    };
    if(n % 2 == 0) cout << calc_med(maior) - calc_med(menor) + 1 << endl;
    else cout << (calc_med(maior) / 2 - calc_med(menor) / 2) + 1 << endl;
    return 0;
}



Measured memory_bytes: 6716
n ,m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0]
B = [0]

for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])

ans, j = 0, m
for i in range(n+1):
    if A[i] > k:
        break
    else:
        while B[j] > k - A[i]:
            j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47512
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

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

	cout << fixed << setprecision(10) << (double)t / x << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
LRD = [[int(_) for _ in input().split()] for _ in range(M)]
G = {}
for l, r, d in LRD:
    l -= 1
    r -= 1
    #0-indexed
    G[l] = G.get(l, {})
    G[r] = G.get(r, {})
    G[l][r] = d
    G[r][l] = -d
INF = float('inf')
D = [INF] * N
for i in range(N):
    if i in G and D[i] == INF:
        D[i] = 0
        table = []
        while True:
            for k, v in G[i].items():
                if D[k] == INF:
                    table += [k]
                    D[k] = D[i] + v
                elif D[k] != D[i] + v:
                    print('No')
                    exit()
            if table:
                i = table.pop()
            else:
                break
print('Yes')


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

class Res
{
public:
	int score;
	string city;
};

bool cmp(Res a, Res b)
{
	if (a.city != b.city)
		return a.city < b.city;
	else
		return a.score > b.score;
}

int main() 
{
	int n;
	cin >> n;
	Res *a = new Res[n];//排完
	Res *b = new Res[n];//原序
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i].city >> a[i].score;
		b[i].city = a[i].city;
		b[i].score = a[i].score;
	}
	sort(a, a + n, cmp);
	//从排完的找原序并输出
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[i].score == b[j].score)
			{
				cout << j + 1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

char op(int x) {
    if (x > 0) {
        return '+';
    } else {
        return '-';
    }
}

int main() {
    string num;
    cin >> num;
    int32_t a = num[0] - '0', b = num[1] - '0', c = num[2] - '0', d = num[3] - '0';

    int32_t s = a;
    for (auto bb : {1, -1}) {
        int32_t s2 = s + bb * b;
        for (auto cc : {1, -1}) {
            auto s3 = s2 + cc * c;
            for (auto dd : {1, -1}) {
                auto s4 = s3 + dd * d;
                if (s4 == 7) {
                    cout << a << op(bb) << b << op(cc) << c << op(dd) << d << "=7" << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
//بسم الله الرحمن الرحيم
#include <bits/stdc++.h>
#define foro(x,y) for(long long x=1;x<y;x++)
#define forz(x,y) for(long long x=1;x<y;x++)
#define forc(x,y,z) for(int x=z;x<y;x++)
#define asc(x) x.begin(),x.end()
#define des(x) x.begin(),x.end(),greater<>()
#define pb(x) push_back(x)
#define mxll   LONG_LONG_MAX
#define mnll   LONG_LONG_MIN
#define mxi INT_MAX
#define mni  INT_MIN
#define NL cout<<endl;

using namespace std;
typedef long long besi;
typedef pair<int,int> PII;
typedef vector<long long> vll;
typedef vector<int> vin;
typedef vector<vll> vllll;
typedef vector<bool> vebu;
typedef vector<vebu> vebubu;
typedef vector<string> VS;
typedef set <long long> sl;
typedef map<long long,bool> mpl;
//typedef MII::iterator iMII;
void solve(){
	besi n,x,t;
	cin>>n>>x>>t;
	besi res = n/x;
	if(n%x!=0) res++;
	cout<<(res*t)<<endl;
}
int main(){

	besi t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
    // Backslash '\'
    


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  rep(i,h+1)rep(j,w+1) {
    if (i*j+(h-i)*(w-j) == n) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}






















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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	LL ans = s.front()==s.back();
	cout << (ans?"Yes":"No")<< endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        boolean isAns = false;
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i * j == n) {
                    isAns = true;
                    break;
                }
            }
        }

        System.out.println(isAns ? "Yes" : "No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23252
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    int x = n / 3;
    cout << x << "\n";
    return 0;
}

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

int cnt[100010];
int main() {
	int N, M; cin >> N >> M;
	for(int i=0; i<M; ++i){
	    int a, b;
	    cin >> a >> b;
	    ++cnt[a];
	    ++cnt[b];
	}
	for(int i=1; i<=N; ++i){
	    if(cnt[i]%2==1){
	        cout << "NO" << endl;
	        return 0;
	    }
	}
	cout << "YES" << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    ll n,q,a[BIG];
    ll sum;
    map <int,int> mp;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n;
    for (int i=0; i<n; i++) {
        cin >>a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    cin >>q;
    while (q--) {
        int x,y;
        cin >>x >>y;
        mp[y] += mp[x];
        sum += mp[x]*(y-x);
        mp[x] = 0;
        cout <<sum <<n1;
    }



    return 0;
}


Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

using graph = vector<vector<int>>;
using st = pair<int, int>;
int main() {
	int N, M;
	cin >> N >> M;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		G[x - 1].push_back(y - 1);
	}
	int S, T;
	cin >> S >> T;
	S--; T--;
	vector<bool> visited(N, false);
	vector<vector<bool>> vis(4, vector<bool>(N, false));
	queue<st> q;
	q.push({ S,0 });
	while (!q.empty()) {
		st now = q.front(); q.pop();
		if (now.first == T) {
			cout << now.second << endl;
			return 0;
		}
		if (visited[now.first])continue;
		visited[now.first] = true;
		//cerr << now.first << ", " << now.second << endl;
		now.second++;
		stack<st>s;
		s.push({ now.first,0 });
		
		while (!s.empty()) {
			st n = s.top(); s.pop();
			if (vis[n.second][n.first])continue;
			vis[n.second][n.first] = true;
			if (n.second == 3) {
				q.push({ n.first,now.second });
				continue;
			}
			n.second++;
			for (int k : G[n.first]) {
				s.push({ k,n.second });
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 5760
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

ll a;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a;
	if ( a >= 1200 )
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

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

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

int main(void){
    int N,M; cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << en;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
int main(){
	string s;
	cin>>s;
	if(s=="SSS"){
		cout<<0<<endl;
	}else if(s=="SSR"){
		cout<<1<<endl;
	}else if(s=="SRS"){
		cout<<1<<endl;
	}else if(s=="RSS"){
		cout<<1<<endl;
	}else if(s=="RRS"){
		cout<<2<<endl;
	}else if(s=="RSR"){
		cout<<1<<endl;
	}else if(s=="SRR"){
		cout<<2<<endl;
	}else{
		cout<<3<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	count := 0
	for i := 1; i <= n; i += 2 {
		tmp := 0
		for j := 1; j <= i; j += 2 {
			if i % j == 0 {
				tmp++
			}
		}
		if tmp == 8 {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
n = int(input())
ab = []

for i in range(n):
    ab.append(tuple(map(int, input().split())))
ab.sort(key=lambda x: x[1])

def detect():
    t = 0
    for a, b in ab:
        if t + a > b:
            return "No"
        t += a
    return "Yes"

print(detect())

Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    repX(i,N+1,1){
        if(i%3==0||i%5==0)continue;
        sum += i;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3632
n=int(input())
vv=list(map(int,input().split()))

odd=[[0,0] for _ in range(10**5+1)]
even=[[0,0] for _ in range(10**5+1)]
ev=0
od=0


for i,v in enumerate(vv):
    if i%2==0:
        ev+=1
        even[v-1][1]=v-1
        even[v-1][0]+=1
    else:
        od+=1
        odd[v-1][1]=v-1
        odd[v-1][0]+=1


even.sort()
odd.sort()

#print(odd)
#print(even)


if even[-1][1]!=odd[-1][1]:
    print(ev-even[-1][0]+od-odd[-1][0])
else:
    print(min(ev-even[-2][0]+od-odd[-1][0],ev-even[-1][0]+od-odd[-2][0]))






Measured memory_bytes: 73452
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 13:24:45 2019

@author: Yamazaki Kenichi
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
a = ['{:040b}'.format(i) for i in A]
k = '{:040b}'.format(K)
res = 0
flg = False
for i in range(40):
    counta = 0
    for elem in a:
        if elem[i] == '1':
            counta += 1
        check = True if counta<N/2 else False
    if flg:
        if check:
            res += pow(2,39-i)
        continue
    if check and k[i]=='1':
        res += pow(2,39-i)
    else:
        if k[i]=='1':
            flg = True
ans =0
for elem in A:
    ans += elem^res
print(ans)


Measured memory_bytes: 18344
#include<stdio.h>

int main(void){
    double  N=0;
    int K=0;
    int count=1;
    double answer=0;
    double temp=1.0;
    int temp2=0;
    scanf("%lf %d",&N,&K);
    double kaku[100000]={0};
    for(int i=1;i<=N;i++){
        temp2=i;
          while(1){
            if(temp2>=K){
                for(int j=1;j<count;j++){
                    temp*=0.5;
                }
                answer=1.0/N;
                kaku[i]=answer*temp;
                 break;
            }
            temp2*=2;
            count++;
            }
          count=1;
          temp=1;
        }
    answer=0;
     for(int i=1;i<=N;i++){
        answer+=kaku[i];
     }
     printf("%.12lf\n",answer);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

static int A[100000];

inline static void swap( int *a, int *b ) {
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void data_queue(int A[], int size, int val) {
    int i, n;
    A[size] = val;
    n = size;
    while ( n != 0 ) {
        i = ( n -1 ) >> 1;      // (n-1)/2：親ノードのインデックス取得
        if ( A[i] < A[n] ) {    // 親ノードより大きい場合
            swap( &A[i], &A[n] );
        }
        n = i;
    } 
}

void remove_root( int A[], int size ) {
    int i, n;
    A[0] = A[size-1];

    n=0;
    while ( 1 ) {
        i = ( n << 1 ) + 1;
        if ( i > size-1 ) break;

        if ( ( i != size-2 ) && ( A[i] < A[i+1] ) ) {
            i++;
        }
        if ( A[i] > A[n] ) {
            swap( &A[i], &A[n] );
        }
        n = i;
    }
}

int main( void ) {
    int N, M;
    int i, j;
    int tmp, idx;
    unsigned long long sum; 

    scanf("%d %d", &N, &M);
    N = N > 100000 ? 100000 : N;
    M = M > 100000 ? 100000 : M;

    for (i=0;i<N;++i) {
        scanf("%d", &tmp);
        data_queue( A, i, tmp);
    }

    for (i=0;i<M;++i) {
        tmp = A[0] >> 1;
        remove_root( A, N );
        data_queue( A, N-1, tmp );
    }

    sum = 0;
    for (i=0;i<N;++i) {
        sum += A[i];
    }
    printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 512
A, B, C, X, Y = map(int, input().split())
ans = A*X+B*Y
# ABセットを全探索する
for i in range(1, max(X,Y)+1):
    # i > Xであれば買い増す必要はないが、i < Xであれば必要なため
    ans = min(ans, A*max(X-i,0)+B*max(Y-i,0)+C*2*i)
print(ans)

Measured memory_bytes: 9076
#include<cstdio>
#include<algorithm>
#include<string.h>

using namespace std;


int W,H,res;
char l[105][105];
bool b[105][105];

void dfs(int h,int w){
  if(b[h][w]==false){
  b[h][w]=true;
  if(h-1>=0 && l[h][w]==l[h-1][w]) dfs(h-1,w);
  if(w-1>=0 && l[h][w]==l[h][w-1]) dfs(h,w-1);
  if(l[h][w]==l[h+1][w]) dfs(h+1,w);
  if(l[h][w]==l[h][w+1]) dfs(h,w+1);
  }
}
void solve(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(b[i][j]==false){
        dfs(i,j);
        res++;
      }
    }
  }
  printf("%d\n",res);
}



int main(){
  while(true){

    res=0;
    memset(l,0,sizeof(l));

    scanf("%d%d",&H,&W);
    if(H==0 && W==0) break;

    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
        b[i][j]=false;


    for(int i=0;i<H;i++){
      scanf("%s",&l[i]);
    }

    solve();
  }

  return 0;
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int ar[100000+5];
int dp[100000+5];

int main()
{
    IOS
    int n, k;
    cin >> n >> k;
    REP(i,n)
    cin>>ar[i];

    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);

    FOR(i,2,n,1)
    {
        dp[i] = dp[i-1]+abs(ar[i]-ar[i-1]);
        FOR(l, i-k, i, 1)
        {
            if(l<0) continue;
            dp[i] = min(dp[i], dp[l]+abs(ar[i]-ar[l]));
        }

    }
    cout << dp[n-1];
    
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int i,n,temp;
	int max,min,second;

	scanf("%d",&n);

	scanf("%d",&second);
	scanf("%d",&temp);
	max=temp;
	if(temp<second){
		min=temp;
	}else{
		min=second;
	}

	for(i=0;i<n-2;i++){
		scanf("%d",&temp);

		if(temp-min>max-second){
			max=temp;
			second=min;
		}


		if (temp>max){
			max=temp;
			//second=min;
		}else{

		}

		if (temp<min){
			min=temp;
		}
	}
	//printf("(%d,%d)\n",max,second);
	printf("%d\n", max-second);
}



/*
5????????????
4????????????
(4,7)???????????????min???4??¨?????????
9?????????
(4,9)????????????
13?????????
(4,13)????????????
2?????????
(2,13)????????????
5????????????????????????
7????????????????????????

??\????????????

*/

Measured memory_bytes: 1852
// at_abc149c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<math.h>
using namespace std;
bool isPrime(int cur) {
    for (int i = 2;i <=sqrt(cur);i++) {
        if (cur != i && (cur % i == 0))return false;
    }
    return true;
}
int main()
{
    int x; scanf("%d", &x);
    while (true) {
        if (isPrime(x)) {
            cout << x << "\n";
            return 0;
        }
        x++;
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

int N, h[100], c;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	bool f = true;
	while (f) {
		f = false;
		for (int i = 0; i < N; i++) {
			if (h[i]) {
				f = true;
				c++;
				for (int j = i; j < N; j++) {
					if (!h[j])break;
					h[j]--;
				}
				break;
			}
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;



int main() {
	int n, q;
	cin >> n >> q;
	
	dsu d(n);
	for (int i = 0; i < q; i++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t) {
			cout << d.same(u, v) << endl;
		}
		else {
			d.merge(u, v);
		}
	}
}

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

using namespace std;

#define ll long long

ll a[401], sum[401], dp[401][401];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    for (int i = n; i >= 0; --i) {
        for (int j = i + 2; j <= n; ++j) {
            dp[i][j] = LONG_LONG_MAX;
            for (int k = i; k++<j;) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + sum[j] - sum[i]);
            }
        }
    }
    cout << dp[0][n] << "\n";
    return 0;
}

Measured memory_bytes: 1536
import sys

m = {'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}

data = sys.stdin.readlines()
data.pop(0)
for line in data:
    v = line.rstrip()
    if not "" == v:
        m[v] += 1

for k, v in m.items():
    print(k,' x ', v)

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


int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  int x = 'a' - 1;
  for (char c : s) {
    if (c - x <= 1) {
      x = c;
    } else {
      cout << (char)(x + 1) << endl;
      return 0;
    }
  }
  if (x != 'z') {
    cout << (char)(x + 1) << endl;
  } else {
    cout << "None" << endl;
  }
  return 0;
}


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

using namespace std;

int N, M,a[51],b[51],g[51][51] = {}, ans = 0;
bool town[51], bri[51][51];

void dfs(int now_pos){
    town[now_pos] = true;
    for(int i = 1; i <= N; i++){
        if(g[now_pos][i] == 1 && !town[i]){
            dfs(i);
        }
    }
}

int main(){
    
    cin >> N >> M;
    for(int i = 1; i <= M; i++){
        cin >> a[i] >> b[i];
        g[a[i]][b[i]] = g[b[i]][a[i]] = 1;
    }
    
    for(int j = 1; j <= N; j++) town[j] = false;
    for(int i = 1; i <= M; i++){
        for(int j = 1; j <= N; j++) town[j] = false;
        g[a[i]][b[i]] = g[b[i]][a[i]] = 0;
        town[1] = true;
        dfs(1);
        for(int j = 1; j <= N; j++){
            if(!town[j])    {++ans;break;}
        }
        g[a[i]][b[i]] = g[b[i]][a[i]] = 1;
        
    }

    cout << ans << '\n';
}

Measured memory_bytes: 256
s=str(input())
n=len(s)
ans=0
i=0
while(i<n):
	if(s[i] in 'ACGT'):
		count=0
		while(i<n and s[i] in 'ACGT'):
			i+=1
			count+=1
		ans=max(ans,count)
	else:
		i+=1
print(ans)



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

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

using namespace std;

char alphabet[52];

int main(){
  int n;
  cin >> n;
  REP(counter, n) {
    string messenger; cin >> messenger;
    string message; cin >> message;
    string recon = message;
    REP(i, messenger.size()){
      char target = messenger[messenger.size()-1-i];
      if(target == 'J'){
        REP(j, message.size()) recon[j] = message[(j-1+message.size()) % message.size()];
      }else if(target == 'C'){
        REP(j, message.size()) recon[j] = message[(j+1) % message.size()];
      }else if(target == 'E'){
        REP(j, message.size()/2) swap(recon[j], recon[j+message.size()/2+message.size()%2]);
      }else if(target == 'A'){
        reverse(ALL(recon));
      }else if(target == 'P'){
        REP(j, message.size()){
          if('0' <= message[j] and message[j] <= '9'){
            int digit = message[j] - '0';
            digit = (digit - 1 + 10) % 10;
            recon[j] = digit + '0';
          }
        }
      }else if(target == 'M'){
        REP(j, message.size()){
          if('0' <= message[j] and message[j] <= '9'){
            int digit = message[j] - '0';
            digit = (digit + 1) % 10;
            recon[j] = digit + '0';
          }
        }
      }
      message = recon;
    }
    cout << message << endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

int main(){
	std::vector<int> v;

	for (int i = 0; i < 2; i++) {
		int a;
		std::cin >> a;
		v.push_back(a);
	}
	std::string str;

	std::sort(v.begin(), v.end());

	for (int i = 0; i < v[1]; i++) {
		str += std::to_string(v[0]);
	}
	

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;

template<class T>inline void read(T &res)
{
	char ch;
	for(;!isdigit(ch=getchar()););
	for(res= ch-'0';isdigit(ch=getchar());res=res*10+ch-'0');
}
int n;
LL dp[maxn][3],val[maxn];
char op;

int main()
{
	scanf("%d",&n);
	dp[0][0] = 0;
	dp[0][1] = dp[0][2] = -0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		read(val[i]);
		if(i<n) while((op = getchar())!='-'  && op!='+');
		dp[i][0] = max(dp[i-1][0] + val[i] , max(dp[i-1][1] - val[i] , dp[i-1][2] + val[i]));
		dp[i][1] = max(dp[i-1][1] - val[i] , dp[i-1][2] + val[i]);
		dp[i][2] = dp[i-1][2] + val[i];
		if(op=='-')
		{
			for(int j=2;j>0;j--) dp[i][j] = dp[i][j-1];
			dp[i][0] = -0x3f3f3f3f3f3f3f3f;
		}
	}
	printf("%lld\n",max(dp[n][0] ,max( dp[n][1] , dp[n][2])));
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {

	int a, b, c, tmp;

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

	if (a > b) {
		tmp = b; b = a; a = tmp;
	}
	if (b > c) {
		tmp = c; c = b; b = tmp;
	}
	if (a > b) {
		tmp = b; b = a; a = tmp;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;

}


Measured memory_bytes: 2744
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(string input; (input = Console.ReadLine()) != "-1 -1 -1";) {
                var score = input.Split();
                int m = int.Parse(score[0]), f = int.Parse(score[1]), r = int.Parse(score[2]);
                int mf = m + f;
                Console.WriteLine(((m | f) == -1 || mf < 30) ? "F" : mf < 50 ? (r < 50 ? "D" : "C") : mf < 65 ? "C" : mf < 80 ? "B" : "A");
            }
        }
    }
}

Measured memory_bytes: 9344
class Main{

    public void solve(){

    		for(int i = 1;i < 10; i++){
    		    for(int j = 1; j < 10; j++){
    		    	int product = i * j;
        	     	System.out.println(i+"x"+j+"="+product);
    		    }
        	}
        }



    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 16852
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,X,Y = IL()

ans = 0
if C*2 < A+B:
  ans += C*2 * min(X, Y)
  num = 0
  if X < Y:
    num = (Y - X)*B
    num = min(num, (Y - X)*C*2)
  else:
    num += (X - Y)*A
    num = min(num, (X - Y)*C*2)
  ans += num
  print(ans)
else:
  print(A*X + B*Y)

Measured memory_bytes: 38256
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1][1]>=l[1]:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
n=int(input())
f=lambda x,y:(x,int(y))
A=[f(*input().split())for _ in[0]*n]
B=A[:]
k(A,0,n-1)
print(['Not s','S'][A==d(B)]+'table')
for e in A:print(*e)


Measured memory_bytes: 20204
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 3588
# 方針はb以下の条件にあったものからa - 1以下の条件にあったものを引く
# 最小公倍数を使って引きすぎたものを置換

# greatest common divisor
# gcd はユークリッドの互除法をつかって再帰の形で求められる
def gcd(x,y):
  if y == 0: return x
  return gcd(y,x%y)

# least common multiple
# // を使った除算で小数点を省ける
def lcm(e,f):
  return e * f // gcd(e,f)
a,b,c,d = map(int,input().split())

all = b - (b // c) - (b // d) + (b // lcm(c,d))
to_a = (a - 1) - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm(c,d))
print(str(all - to_a))


Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int n, a[100];
	int ans = 0;

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

	int flag = true;
	while (flag){
		flag = false;
		for (int j = n - 1; j >= 1; j--){
			if (a[j] < a[j - 1]){
				swap(a[j], a[j - 1]);
				flag = true;
				ans++;
			}
		}
	}

	for (int i = 0; i < n; i++){
		cout << a[i];
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3088
def calc_n_range(a):
    min_n = max_n = 2

    for curr_a in reversed(a):
        min_n = ((min_n + curr_a - 1) // curr_a) * curr_a
        if min_n > max_n:
            return None
        max_n = max_n - max_n % curr_a + curr_a - 1

    return min_n, max_n


def main():
    input()
    a = list(map(int, input().split()))

    n_range = calc_n_range(a)
    if n_range:
        print(*n_range)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
n, k, s = map(int, input().split())

if s != 10 ** 9:
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            print(s+1, end=" ")

else:
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            print(s-1, end=" ")
        


Measured memory_bytes: 4212
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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


signed main() {
	ll n, k;
	cin >> n >> k;

	vector<int>d(k);

	rep(i, k)cin >> d[i];

	ll ans = n;
	ll tmp;

	bool a = 1;
	

		
	rep(i, 6) {
		if (a) { tmp = ans; }
		rep(j, k) {
			if (tmp % 10 == d[j]) {
				ans++;
				a = 1;
				i = 0;
				break;
			}
			else {
				a = 0;
			}
		}
		tmp /= 10;
		if (tmp == 0&& !a) {
			cout << ans << endl;
			return 0;
		}
	}


}

Measured memory_bytes: 256
/*
[abc130] A - Rounding
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int X, A;

ll solve() { return X < A ? 0 : 10; }

int main() {
    cin >> X >> A;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

ll polje[2024];
const int mod=2019;

int main () {
	string s;
	cin>>s;
	int t=1;
	int br=0;
	polje[0]=1ll;
	for(int i=s.length()-1;i>=0;i--){
		int k=s[i]-'0';
		br=(t*k+br)%mod;
		t=(t*10)%mod;
		polje[br]++;
	}
	ll sol=0ll;
	for(int i=0;i<2019;i++){
		sol+=(polje[i]*(polje[i]-1ll))/2ll;
	}
	cout<<sol;



return 0;
}



Measured memory_bytes: 3772
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
l = [int(input()) for i in range(5)]

t = 0
lmin = min(l)
print(math.ceil(N/lmin)+4)

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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N - K) {
        if (A[i] < A[i + K]) cout << "Yes\n";
        else cout << "No\n";
    }
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long 
#define F first
#define final 100000000
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
 
int main()
{
  ll a;
  cin >> a;
  ll ans = a + a*a + a*a*a;
  cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    private static int count1(String[] sh, int h, int w) {
        if (h < 0 || w < 0 || sh.length <= h || sh[0].length() <= w) {
            return 0;
        }
        String x = sh[h].substring(w, w+1);
        return x.equals("#") ? 1 : 0;
    }

    private static int count8(String[] sh, int h, int w) {
        String x = sh[h].substring(w, w+1);
        if (x.equals("#")) {
            return -1;
        }
        return count1(sh, h-1, w-1) + count1(sh, h-1, w) + count1(sh, h-1, w+1) +
               count1(sh, h  , w-1)                      + count1(sh, h  , w+1) +
               count1(sh, h+1, w-1) + count1(sh, h+1, w) + count1(sh, h+1, w+1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] sh = new String[h];
        for (int i = 0; i < h; i++) {
            sh[i] = sc.next();
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int x = count8(sh, i, j);
                System.out.print(x == -1 ? "#" : x);
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 23760
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int n,t,e;
bool check(int x){
    int cnt = 1;
    int y = x;
    vector<int> data;
    reps(i,t-e,t+e+1)data.push_back(i);
    int len = data.size();
    while(true){
        if(y > data[len-1])break;
        rep(i,len)if(y == data[i])return true;
        cnt++;
        y=x*cnt;
    }
    return false;
}
int main(){
    scanf("%d%d%d",&n,&t,&e);
    bool f = false;
    rep(i,n){
        int x;
        scanf("%d",&x);
        if(check(x)){
            printf("%d\n",i+1);
            f = true;
            break;
        }
    }
    if(!f)printf("-1\n");
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= b)
    cout << a << endl;
  else
    cout << a-1 << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect
n, d, a = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(n)])
X, H = zip(*XH)
K = [-(-i//a) for i in H]
L = [0]*(n+2)
ans = 0
for i in range(n):
  L[i+1] += L[i]
  s = max(K[i]-L[i+1], 0)
  ans += s
  L[i+1] += s
  L[bisect.bisect_right(X, X[i]+2*d)+1] -= s
print(ans)


Measured memory_bytes: 144756
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
/*!* [modint] *!*/
/*+* 剰余環整数 *+*/
struct int_m;
int_m invmod(int_m);
int_m powmod(int_m, i64);
struct int_m {
    static i64 m;
    i64 v;
    int_m() {}
    int_m(i64 x) { v = (x % m + m) % m; }
    int_m operator+(const int_m &y) const { return v + y.v > m ? v + y.v - m : v + y.v; }
    int_m operator-(const int_m &y) const { return v - y.v < 0 ? v - y.v + m : v - y.v; }
    int_m operator*(const int_m &y) const { return (v * y.v) % m; }
    bool operator==(const int_m &y) const { return v == y.v; }
    bool operator!=(const int_m &y) const { return v != y.v; }
    void operator+=(const int_m &y) { *this = *this + y; }
    void operator-=(const int_m &y) { *this = *this - y; }
    void operator*=(const int_m &y) { *this = *this * y; }
    friend istream &operator>>(istream &ist, int_m &m) { ist >> m.v; return ist; }
    friend ostream &operator<<(ostream &ost, int_m m) { ost << m.v; return ost; }
    int_m operator^(const i64   &y) const {
        int_m v = 1; int p = y;
        for (int_m b = *this; p > 0; p >>= 1, b *= b) if (p & 1) v *= b;
        return v;
    }
    void operator^=(const i64   &y) { *this = *this ^ y; }
    // for prime mod
    int_m operator/(const int_m &y) const { return *this * (y ^ (m - 2)); }
    void operator/=(const int_m &y) { *this = *this / y; }
};
i64 int_m::m;

int main() {
    int_m::m = 1e9 + 7;
    int N;
    cin >> N;
    int_m X = 0;
    int_m Y = 0;
    for(int i = 0; i < N; i++) {
        i64 A;
        cin >> A;
        X += A;
        Y += A * A;
    }
    int_m ans = (X * X - Y) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620