akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> B;
    rep (i, 0, N-1) {
        int b; cin >> b;
        B.push_back(b);
    }
    reverse(B.begin(), B.end());

    vector<int> A = {B[0]};
    rep (i, 0, N-1) {
        if (i == N-2) {
            A.push_back(B[i]);
            break;
        }
        A.push_back(min(B[i], B[i+1]));
    }

    cout << accumulate(A.begin(), A.end(), 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
	string str;
	cin>>str;
	int len=str.size();
	int pos1,pos2;
	for (pos1=0;pos1<len;++pos1) {
		if (str[pos1]=='A') {
			break;
		}
	}
	for (pos2=len-1;pos2>=0;--pos2) {
		if (str[pos2]=='Z') {
			break;
		}
	}
	printf("%d",pos2-pos1+1);
	return 0;
}

Measured memory_bytes: 640
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        print(' {}'.format(i), end='')
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(' {}'.format(i), end='')
                break
            x //= 10
print()


Measured memory_bytes: 5872
#include <stdio.h>

int main() {
    int r = 0, l = 0;
    int N, M, X;
    scanf("%d %d %d", &N, &M, &X);
    int A[M];
    for (int i = 0; i < M; i++) {
        scanf("%d", &A[i]);
    }
    
    for (int i = X; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (i == A[j]) {
                r++;
                break;
            }
        }
    }
    for (int i = X; 0 < i; i--) {
        for (int j = 0; j < M; j++) {
            if (i == A[j]) {
                l++;
                break;
            }
        }
    }
    if (l < r) {
        printf("%d\n", l);
    } else {
        printf("%d\n", r);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    static const double pi = 3.141592653589793;
    int minute = h*60+m;
    double av = 1/720.0;
    double bv = 1/60.0;
    double ap = av*minute;
    double bp = bv*m;
    double rad = fabs(ap*360-bp*360);
    if(rad > 180) {
        rad = 360-rad;
    }
    rad = rad/360*2*pi;
    double ans = a*a+b*b-2*a*b*cos(rad);
    printf("%.20lf\n", sqrt(ans));
    return 0;
}

Measured memory_bytes: 4164
#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<(int)to; ++i)
#define REP(i, from, to) for(int i=from; i<=(int)to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  out << endl;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

static const int INF = INT_MAX;
static const int MAX_N = 100010;
typedef struct edge edge;
vector<vector<int> > g;
vector<int> dist_1, dist_N;
bool vis[MAX_N];
int n;
void bfs(int start, vector<int>& dist) {
  fill(all(dist), INF);
  fill(vis, vis + MAX_N, false);
  dist[start] = 0;
  queue<int> que;
  que.push(start);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    vis[now] = true;
    rep(i,0,g[now].size())
    {
      int next = g[now][i];
      if (!vis[next]) {
        dist[next] = dist[now] + 1;
        que.push(next);
      }
    }
  }
}

void solve() {
  cin >> n;
  g = vector<vector<int> >(n + 1, vector<int>());
  dist_1 = vector<int>(n + 1);
  dist_N = vector<int>(n + 1);
  rep(i,0,n-1)
  {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bfs(1, dist_1); //頂点1からの距離を求める
  bfs(n, dist_N); //頂点Nからの距離を求める
  int fennec = 0, snuke = 0;
  REP(i,1,n)
  {
    if (dist_1[i] <= dist_N[i]) {
      fennec++; //頂点iは先手が塗る
    } else {
      snuke++; //頂点iは後手が塗る
    }
  }
  cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;
}

int main() {
  solve();
}



Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <algorithm>


int main(){
    std::string s;
    std::getline(std::cin, s);
    int p = 0, k = 0;
    int l = s.length();
    if (s[0] != 'A')
        p = 1;
    for (int i = 1; i < l; i++) {
        char ch = s[i];
        if (ch == 'C') {
            if (i > 1 && i < l - 1)
                k++;
            else
                p = 1;
        }
        else if (ch < 'a' || ch > 'z')
            p = 1;
    }
    if (p == 0 && k == 1)
        std::cout << "AC";
    else
        std::cout << "WA";
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder2
{
    class Program
    {
        public static string Contest(int R)
        {
            if (R < 1200)
            {
                return "ABC";
            }
            else if (R < 2800)
            {
                return "ARC";
            }
            else
            {
                return "AGC";
            }
        }
        public static int Add(int A, int B)
        {
            int i;
            i = (A * B) - (A + B - 1);
            return i;
        }
        static void Main(string[] args)
        {
            int R = int.Parse(Console.ReadLine());
            Console.WriteLine(Contest(R));
        }
    }
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);

    vector<int> prizes(3, 0);
    vector<int> dp(3, 0);
    vector<int> next_dp(3, 0);
    for(int i = 0; i < n; i++){
        f(l, 0, 3){
            s(prizes[l]);
        }
        f(i, 0, 3){
            next_dp[i] = 0;
        }
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j!=k){
                    next_dp[j] = max(next_dp[j], dp[k] + prizes[k]);
                }
            }
        }
        dp = next_dp;
    }
    int maxx = *max_element(dp.begin(), dp.end());
    p(maxx);
    return;
}

class CVacation {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CVacation solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3616
using System;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int t,x;
        t = int.Parse(s[0]);
        x = int.Parse(s[1]);
        double ans;
        ans = t*1.0/x;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
class dice:
	def __init__(self,data):
		self.faces = data
	
	def turn(self,direction):
		if direction == 'N':
			idx = [1,5,2,3,0,4]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'E':
			idx = [3,1,0,5,4,2]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'W':
			[self.turn('E') for i in range(3)]
		elif direction == 'c':
			self.turn('N')
			self.turn('W')
			self.turn('S')

def min_side(dice):
	num = [int(''.join([str(i) for i in dice.faces]))]
	for o in 'cccWcccEcccNcccWcccWccc':
		dice.turn(o)
		num.append(int(''.join([str(i) for i in dice.faces])))
	return min(num)

if __name__ == '__main__':
	from itertools import combinations
	n = int(input())
	dices = []
	for i in range(n):
		dices.append(dice([int(s) for s in input().split()]))
	ans = True
	mins1 = [min_side(d) for d in dices]
	mins2 = list(set(mins1))
	if len(mins1) == len(mins2):
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 7828
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, P = MAP()

print((3*A + P )//2)

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

using namespace std;

int main(){
	int a[3];
	int A,B;
	A = B = 0;
	for(int i=0 ; i<3 ; i++){
		cin>>a[i];
		if(a[i] == 5)A++;
		else if(a[i] == 7)B++;
	}
	if(A == 2 && B == 1)printf("YES\n");
	else printf("NO\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> data(3 * n);
    for (auto &v : data)
        cin >> v;
    vector<LL> pre{0};
    priority_queue<LL, vector<LL>, greater<LL> > pq1;
    LL sum = 0;
    for (int i = 0 ; i < 3 * n ; i++) {
        pq1.push(data[i]);
        sum += data[i];
        if (pq1.size() > n)
            sum -= pq1.top(), pq1.pop();
        pre.push_back(sum);
    }
    reverse(data.begin(), data.end());
    vector<LL> suf{0};
    priority_queue<LL> pq2;
    sum = 0;
    for (int i = 0 ; i < 3 * n ; i++) {
        pq2.push(data[i]);
        sum += data[i];
        if (pq2.size() > n)
            sum -= pq2.top(), pq2.pop();
        suf.push_back(sum);
    }
    reverse(suf.begin(), suf.end());
    LL ans = -INF;
    for (int i = n ; i <= 2 * n ; i++) {
        ans = max(ans, pre[i] - suf[i]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 15588
l = [list(map(int, input().split())) for i in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
c = [[False, False, False], [False, False, False], [False, False, False]]
ans = False
for k in range(n):
    for i in range(3):
        for j in range(3):
            if m[k] == l[i][j]:
                c[i][j] = True
for i in range(3):
    ans = ans or c[i].count(True) == 3
    ans = ans or [c[0][i], c[1][i], c[2][i]].count(True) == 3
ans = ans or [c[0][0], c[1][1], c[2][2]].count(True) == 3
ans = ans or [c[2][0], c[1][1], c[0][2]].count(True) == 3
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  rep(i, 3) {
    cout << s[i];
  }
  cout  << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;

#define int long long int
#define mod 1000000007
#define p push
#define pb push_back
#define mp make_pair
#define f first
#define s second

unordered_map <int, int> M;
vector <int> vs;

signed main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);

		int n, i, x, u = 0, v = 0;
	 	vector <int> :: iterator it;

		cin >> n;

		for(i = 0; i < n; i++)
			{
				cin >> x;
				if(!M[x]) vs.pb(x);
				M[x]++;
			}

		sort(vs.begin(), vs.end(), greater <int> ());

		for(it = vs.begin(); it != vs.end(); it++)
			{
				x = *it;

				if(M[x] >= 2)
					{
						if(!u) u = x, M[x]-=2;;
					}

				

				if(M[x] >= 2)
					{
						if(!v) v = x;
					}
			}

		cout << u * v;
		return 0;
	}


Measured memory_bytes: 5148
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for(int i = 1;i <= N;i++){
            a[i] = sc.nextLong();
        }
        long[] s = new long[N+1];
        s[0] = 0;
        for(int i = 1;i <= N;i++){
            s[i] = s[i-1] + a[i];
        }
        HashMap<Long,Long> map = new HashMap<Long,Long>();
        for(int i = 0;i <= N;i++){
            if(map.containsKey(s[i])){
                map.put(s[i],map.get(s[i])+1L);
            }
            else{
                map.put(s[i],1L);
            }
        }
        long count = 0;
        for(Long key : map.keySet()){
            long value = map.get(key);
            if(value >= 1){
                count += value * (value-1) / 2;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 94364
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;

int main() {
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  long long ans=0;
  if (a <= k) {
    ans += a;
  }
  else {
    ans += k;
  }
  k -= a;
  k -= b;
  if (0 < k) {
    ans -= k;
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a >= b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> T(N), A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> T.at(i);
  }
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> H(N, -1);
  H.front() = T.front();
  for (ll i = 1; i < N; i++)
  {
    if (T.at(i - 1) != T.at(i))
      H.at(i) = T.at(i);
  }

  /*
  for (ll i = 0; i < N; i++)
  {
    cerr << H.at(i) << endl;
  }
  */

  if (H.back() != -1 && H.back() != A.back())
    FINALANS(0);
  H.back() = A.back();
  for (ll i = N - 2; i >= 0; i--)
  {
    if (H.at(i) != -1 && H.at(i) > A.at(i))
      FINALANS(0);
    if (A.at(i) != A.at(i + 1))
      H.at(i) = A.at(i);
  }

  /*
  for (ll i = 0; i < N; i++)
  {
    cerr << H.at(i) << endl;
  }
  */

  ll ans = 1;
  for (ll i = 0; i < N; i++)
  {
    if (H.at(i) == -1)
    {
      ans *= min(T.at(i), A.at(i));
      ans %= MOD;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
def Sieve(n): #n以下の素数全列挙(O(nloglogn)) retは素数が入ってる。divlisはその数字の素因数が一つ入ってる

    ret = []
    divlis = [-1] * (n+1) #何で割ったかのリスト(初期値は-1)
    
    flag = [True] * (n+1)
    flag[0] = False
    flag[1] = False

    ind = 2
    while ind <= n:

        if flag[ind]:
            ret.append(ind)

            ind2 = ind ** 2

            while ind2 <= n:
                flag[ind2] = False
                divlis[ind2] = ind
                ind2 += ind

        ind += 1

    return ret,divlis
        

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

nums,divs = Sieve(max(A)+1)

dic = {}

for i in range(N):

    na = A[i]
    ss = {}

    while True:

        if divs[na] > 0:
            if divs[na] not in ss:
                ss[divs[na]] = 0

            ss[divs[na]] += 1
            na = na // divs[na]

        else:
            if na not in ss:
                ss[na] = 0
            
            ss[na] += 1
            break

    for j in ss:
        if j not in dic:
            dic[j] = ss[j]
        else:
            dic[j] = max(dic[j],ss[j])

lcm = 1
#print (dic)

for i in dic:
    lcm *= pow(i,dic[i],mod)

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],mod-2,mod)
    ans %= mod
print (ans)

Measured memory_bytes: 64380
D, G = map(int, input().split(" "))
PC = [list(map(int, input().split(" "))) for _ in range(D)]

min_count = 10**18
for i in range(1<<D):
    # print(bin(i)[2:])
    count = 0
    point = 0
    top_zero = None
    for j, (p, c) in enumerate(PC):
        if (i>>j)%2:
            count += p
            point += 100*(j+1)*p + c
        else:
            top_zero = j
    if top_zero != None:
        for j in range(PC[top_zero][0]-1):
            # print(j, top_zero, point)
            if point >= G:
                break
            point += 100*(top_zero+1)
            count += 1
    # print("count:", count)
    if point >= G:
        min_count = min(min_count, count)

print(min_count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, m;
    cin >> n >> m;
    char c[51];
    REP(i, n) cin >> c[i];
    if(c[m-1] == 'A') c[m-1] = 'a';
    else if(c[m-1] == 'B') c[m-1] = 'b';
    else c[m-1] = 'c';
    REP(i, n) cout << c[i];
    cout << endl;
}


Measured memory_bytes: 256
s = gets.chomp
switch = false
c = (s.size)/2
if s == s.reverse &&
    s.slice(0,c)   == s.slice(0,c).reverse &&
    s.slice(c+1,c) == s.slice(c+1,c).reverse
  switch = true
end

if switch
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14380
import itertools

N, M, X = map(int, input().split())
ca_array = []
for i in range(N):
  ca_array.append(list(map(int, input().split())))

resultMoneyArray = []

for c in itertools.product([False, True], repeat=N):
  tmpMoney = 0
  m_array = [X for i in range(M)]
  for j in range(N):
    if c[j]:
      for k in range(M):
        m_array[k] -= ca_array[j][k+1]
      tmpMoney += ca_array[j][0]
      
  if sum(x > 0 for x in m_array) == 0:
    resultMoneyArray.append(tmpMoney)

if len(resultMoneyArray) == 0:
  print(-1)
else:
  print(min(resultMoneyArray))

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

int main(void){
    int A, B;
    cin >> A >> B;
    int resAmin = A*100/8+(A%2==0?0:1);
    int resAmax = (A+1)*100/8-(A%2==0?0:1);
    int resBmin = B*10;
    int resBmax = (B+1)*10-1;
    if(max(resAmin, resBmin) > min(resAmax,resBmax)){
        cout << -1 << endl;
    }else{
        cout << max(resAmin, resBmin) << endl;
    }
    return 0;
}

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

#define int long long int
#define ull unsigned long long int
#define for0(i, n) for (int i = 0; i < (int)(n); i++) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); i++) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; i--) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; i--) // reverse 1 based


#define pb push_back
#define fi first
#define se second


#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef double ld;

//-------------------------------------------------------------------------------END----------------------------------------------------------------------------------//



bool inc(vi vec){
    for1(i,vec.size()-1){
        if(vec[i]<vec[i-1])return 0;
    }
    return 1;
}


void solve(){
    int a;cin>>a;
    if(a==1)cout<<0;
    else if(a==0)cout<<1;
}


int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout << fixed;
    //int tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}



Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

      if(a+b+c >= 22){
        System.out.println("bust");
      }else{
		System.out.println("win");
      }
	}
}

Measured memory_bytes: 35580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N){
  long double n=(long double)N,x=(long double)(N/2+N%2);
  long double ans = x/n;
  cout<<setprecision(1000)<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, ans = 0;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]), ans ^= a[i];
  for(i = 0; i < n; ++i) printf("%lld ", ans ^ a[i]);
  return 0;
}

Measured memory_bytes: 4080
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    SP = []
    for i in range(N):
        s, p = readline().rstrip().split()
        SP.append((s, int(p), i+1))
    SP.sort(key=itemgetter(1), reverse=True)
    SP.sort(key=itemgetter(0))
    for i in range(N):
        print(SP[i][2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
string s;
bool iscat(int l,int r){
  if( l >= r ) return true;
  if( s[l] != 'm' || s[r] != 'w' ) return false;
  int rec = 0;
  for(int i = l + 1 ; i < r ; i++ ){
    if( rec == 0 && s[i] == 'e' ) return iscat(l+1,i-1) && iscat(i+1,r-1);
    else if(s[i] == 'm') rec++;
    else if(s[i] == 'w') rec--;
    if( rec < 0 ) return false;
  }
}
int main(){
  cin >> s;
  cout << (iscat(0,s.size()-1) ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int N, X;
int m[1001];
int n;

void solve() {

    cin >> N >> X;

    n = N;

    for (int j = 0; j < N; j++) {
        cin >> m[j];
        X -= m[j];
    }

    sort(m, m + N);

    n += X / m[0];

    cout << n << endl;
}
int main() {
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int N;

	cin >> N;

	for(int i=0;i<=7;i++){
		for(int j=0;j*7<=N;j++){
			if(i*4 + j*7 == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;


	return 0;
}



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

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

int main(){
	std::string s;
	std::cin >> s;
	if(s == "RSR" || s == "SRS" || s == "RSS" || s == "SSR"){
		std::cout << 1 << std::endl;
	}else if(s == "RRS" || s == "SRR"){
		std::cout << 2 << std::endl;
	}else if(s == "RRR"){
		std::cout << 3 << std::endl;
	}else{
		std::cout << 0 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n;
  cin>>n;
  int mi=0,ans=0;
  rep(i,n) {
    int a,b;
    cin>>a>>b;
    if(mi<a) {
      mi=a;
      ans=a+b;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
vector <int> n;

int main(){
	string s;
	int n,ma=-1;
	map <string,int> a;
	vector <string> b,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		a[s]++;
		if(a[s]==1){
			b.push_back(s);
		}
		ma=max(ma,a[s]);
	}
	for(int i=0;i<b.size();i++){
		if(a[b[i]]==ma){
			c.push_back(b[i]);
		}
	}
	sort(c.begin(),c.end());
	for(int i=0;i<c.size();i++){
		cout<<c[i]<<endl;
	}
	return 0;
}


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

int main(){
	string unko;
	while(getline(cin,unko)){
		for(int i=0;i<26;i++){
			for(int j=0;j<unko.size();j++){
				if(unko[j]>='a' && unko[j]<='z'){
					unko[j]++;
					if(unko[j]>'z')unko[j]='a';
				}
			}
			if(unko.find("the")!=-1||unko.find("this")!=-1||unko.find("that")!=-1)cout<<unko<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 25;
int dist[100][11];

struct State {
	int v, c, d;
	bool operator <(const State& x) const {
		return d > x.d;
	}
};

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

	int c, n, m, s, g;
	while(cin >> c >> n >> m >> s >> g, n) {
		s--, g--;

		vector<P> G[100];
		for(int i = 0; i < m; i++) {
			int a, b, f;
			cin >> a >> b >> f;
			a--, b--;
			G[a].push_back({ b, f });
			G[b].push_back({ a, f });
		}

		fill((int*)begin(dist), (int*)end(dist), INF);
		dist[s][c] = 0;
		priority_queue<State> q;
		q.push({ s, c, 0 });
		while(q.size()) {
			int v = q.top().v, rem = q.top().c, d = q.top().d;
			q.pop();
			if(dist[v][c] < d) continue;
			for(auto e : G[v]) {
				int cost[2] = { e.second, e.second / 2 };
				for(int i = 0; i < 2; i++) {
					int u = e.first;
					if(rem == 0 && i == 1) continue;
					if(dist[u][rem - i] > d + cost[i]) {
						dist[u][rem - i] = d + cost[i];
						q.push({ u, rem - i, d + cost[i] });
					}
				}
			}
		}

		int ans = 1e9;
		for(int i = 0; i <= c; i++) {
			ans = min(ans, dist[g][i]);
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
using namespace std;
int main(){

  long long n,a,i=0;
  cin>>n;
  a=sqrt(n);
  for(;a;a--) if(n%a==0) break;
  n/=a;
  for(;n;i++) n/=10;
  cout<<i<<endl;

  return 0;

}











Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    vector<int> a(9);
    for(int i = 0;i < 9;i ++) cin >> a.at(i);
    int n; cin >> n;
    vector<int> b(n);
    for(int i = 0;i < n;i ++) cin >> b.at(i);

    vector<int> c(9);
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < 9;j ++){
            if(b.at(i) == a.at(j)) c.at(j) = 1;
        }
    }

    if(c.at(0) + c.at(1) + c.at(2) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(3) + c.at(4) + c.at(5) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(6) + c.at(7) + c.at(8) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(0) + c.at(3) + c.at(6) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(1) + c.at(4) + c.at(7) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(2) + c.at(5) + c.at(8) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(0) + c.at(4) + c.at(8) == 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(c.at(2) + c.at(4) + c.at(6) == 3){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

}







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

using ll=long long;



void solve(){
    int n;
    vector<int> a(4);
    cin>>n;
    a[0]=n/1000;
    a[1]=(n%1000)/100;
    a[2]=(n%100)/10;
    a[3]=n%10;

    if(a[0]==a[1]&&a[1]==a[2] || a[1]==a[2]&&a[2]==a[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
#define N 10003

int n,m;
char a[20][2];
string dp[N];
int val[10]={6,2,5,5,4,5,6,3,7,6};

void Max(string &x,string y) {
	if(x.size()<y.size()||(x.size()==y.size()&&x<y))
		x=y;
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%s",a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(i>=val[a[j][0]-'0']) {
				if(dp[i-val[a[j][0]-'0']]==""&&i-val[a[j][0]-'0']!=0)
					continue;
				Max(dp[i],a[j][0]+dp[i-val[a[j][0]-'0']]);
			}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 32384
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int main()
{
	int T, P, R, A, B, C; char M[8];

	while (true)
	{
		scanf("%d", &T);
		scanf("%d", &P);
		scanf("%d", &R);

		if (T == 0 && P == 0 && R == 0) { break; }

		vector<int> S(T, 0);

		vector<vector<int> > W(T, vector<int>(P, 0));

		for (int i = 0; i < R; i++)
		{
			scanf("%d", &A);
			scanf("%d", &B);
			scanf("%d", &C);
			scanf("%s", M);

			if (M[0] == 'W')
			{
				W[A - 1][B - 1] += 1;
			}
			else
			{
				S[A - 1] += (1000000 - W[A - 1][B - 1] * 1200 - C);
			}
		}

		vector<int> Q(T); iota(Q.begin(), Q.end(), 1);

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (S[i] < S[j] || (S[i] == S[j] && Q[i] > Q[j]))
				{
					swap(S[i], S[j]); swap(Q[i], Q[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			printf("%d %d %d\n", Q[i], (S[i] + 999999) / 1000000, (1000000 - S[i] % 1000000) % 1000000);
		}
	}

	return 0;
}

Measured memory_bytes: 3284
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

vector<int> primes;

int check2(int i, int j) {
    vector<int> arr;
    arr.push_back(i);
    arr.push_back(j);
    sort(arr.begin(), arr.end());
    int ans = 0;
    if (arr[0] >= 2 && arr[1] >= 24) ans++;
    if (arr[0] >= 4 && arr[1] >= 14) ans++;
    if (arr[0] >= 14) ans++;
    if (arr[0] >= 24) ans++;
    return ans;
}

int check3(int i, int j, int k) {
    vector<int> arr;
    arr.push_back(i);
    arr.push_back(j);
    arr.push_back(k);
    sort(arr.begin(), arr.end());
    if (arr[0] <= 1 || arr[1] <= 3) return 0;
    if (arr[0] <= 3) return 1;
    else return 3;
}

int main() {
    int N;
    scanf("%d", &N);

    bool isprime[101];
    isprime[0] = false;
    isprime[1] = false;
    for (int j = 2; j <= 100; j++) {
        isprime[j] = true;
    }
    for (int k = 2; k <= 100; k++) {
        if (isprime[k]) {
            int temp = k * 2;
            while (temp <= 100) {
                isprime[temp] = false;
                temp += k;
            }
        }
    }
    for (int j = 2; j <= 100; j++) {
        if (isprime[j]) primes.push_back(j);
    }
    int count[primes.size()];
    for (int i = 0; i < primes.size(); i++) {
        int c = 0;
        for (int j = primes[i]; j <= 100; j = j * primes[i]) {
            for (int k = 1; k <= N; k++) {
                if (k % j == 0) c++;
            }
        }
        count[i] = c;
    }
    int ans = 0;
    for (int i = 0; i < primes.size(); i++) {
        if (count[i] >= 74) ans++;
        for (int j = i + 1; j < primes.size(); j++) {
            ans += check2(count[i], count[j]);
            for (int k = j + 1; k < primes.size(); k++) {
                ans += check3(count[i], count[j], count[k]);
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

int main() {
    string str;
    int q;
    cin >> str >> q;
    REP(i, q) {
        string c;
        cin >> c;
        int a, b, l;
        cin >> a >> b;
        l = b - a + 1;
        if (c == "print") cout << str.substr(a, l) << endl;
        else if (c == "reverse") {
            string tmp = str.substr(a, l);
            reverse(tmp.begin(), tmp.end());
            str.replace(a, l, tmp);}
        else if (c == "replace") {
            string p;
            cin >> p;
            str.replace(a, l, p);}
    }
}

Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  string s,t;
  cin>>s>>t;
  int sl,tl;
  sl=s.length();tl=t.length();
  vector<string> ans;
  if(sl>=tl)
  {
    for(int i=0;i<=sl-tl;i++)
    {
      string tmp=s;
      int flag=1;
      for(int j=0;j<sl;j++)
      {
        if(i<=j && j<i+tl)
        {
          if(tmp[j]=='?'){tmp[j]=t[j-i];}
          if(tmp[j]!=t[j-i])flag=0;
        }
        else
        {
          if(s[j]=='?')tmp[j]='a';
        }
      }
      if(flag)ans.push_back(tmp);
    }
  }
  sort(all(ans));
  if(ans.size()==0)cout<<"UNRESTORABLE";
  else cout<<ans[0];
  cout<<endl;



  return 0;

}


Measured memory_bytes: 384
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

const int N = 100000 + 5000;
LL arr[N];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m; cin >> n >> m;

    for (int i = 1; i <= m; i++){
    	int l, r; cin >> l >> r;
    	arr[l]++;
    	arr[r + 1]--;
    }
    for (int i = 1; i <= N; i++)
    	arr[i] = arr[i] + arr[i - 1];

    int ans = 0;
    for (int i = 1; i <= N; i++){
    	if (arr[i] == m)
    		ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/perl
#abc082_d.pl
#Mon Feb  5 21:33:51 2018
#

use warnings;
use strict;

my $s = <STDIN>;
chomp $s;
my @ss = split("T",$s);

my $temp = <STDIN>;
chomp $temp;
my @temps = split(" ",$temp);

my $x = $temps[0];
my $y = $temps[1];

my $axis = 1;
my @xdir;
my @ydir;

my $xstart = 0;
my $xindex = 0;

my @letters = split ("",$s);
if ($letters[0] eq "F"){
	$xstart = length($ss[0]);
}

my $xtotal = 0;
my $ytotal = 0;

foreach (@ss){
	if ($axis == 1){
		push (@xdir, length($_));
		$xtotal = $xtotal + length($_);
	}else{
		push (@ydir, length($_));
		$ytotal = $ytotal + length($_);
	}
	$axis = $axis * (-1);
}

my @xleft;
my @yleft;

foreach (@xdir){
	push (@xleft,$xtotal-$_);
	$xtotal = $xtotal - $_;
}

foreach (@ydir){
	push (@yleft,$ytotal-$_);
	$ytotal = $ytotal - $_;
}


my %xmem;
my %ymem;

my $xflag;
if (!exists $xdir[0] || $xdir[0] eq ""){
	if ($x == 0){
		$xflag = 1;
	}else{
		$xflag = 0;
	}
}else{
	$xflag = &xsearch($xstart,$xindex);
}

my $yflag;
if (exists $ydir[0]){
	$yflag = &ysearch(0,-1);
}else{
	if ($y == 0){
		$yflag = 1;
	}else{
		$yflag = 0;
	}
}

#print $xflag,"\t",$yflag,"\n";

if ($xflag == 1 && $yflag == 1){
	print "Yes\n";
}else{
	print "No\n";
}

sub xsearch{
	my $pos = $_[0];
	my $index = $_[1];

	if (exists $xmem{$pos}{$index}){
		return 0;
	}

	if ($index == $#xdir){
		if ($pos == $x){
			return 1;
		}else{
			return 0;
		}
	}

	if (abs($x-$pos) > $xdir[$index+1]+$xleft[$index+1]){
		return 0;
	}

	if (&xsearch($pos+$xdir[$index+1],$index+1)){
		return 1;
	}elsif (&xsearch($pos-$xdir[$index+1],$index+1)){
		return 1;
	}else{
		$xmem{$pos}{$index} = 0;
		return 0;
	}
}

sub ysearch{
	my $pos = $_[0];
	my $index = $_[1];

	if (exists $ymem{$pos}{$index}){
		return 0;
	}

	if ($index == $#ydir){
		if ($pos == $y){
			return 1;
		}else{
			return 0;
		}
	}

	if (abs($y-$pos) > $ydir[$index+1]+$yleft[$index+1]){
		return 0;
	}

	if (&ysearch($pos+$ydir[$index+1],$index+1)){
		return 1;
	}elsif (&ysearch($pos-$ydir[$index+1],$index+1)){
		return 1;
	}else{
		$ymem{$pos}{$index} = 0;
		return 0;
	}
}

Measured memory_bytes: 120320
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

bool ok [11];
int n,k;
bool gd(int m)
{
    while(m>0)
    {
        if(ok[m%10]==true) return false;
        m/=10;
    }
    return true;
}

int main()
{
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        int s; cin>>s; ok[s]=true;
    }
    while(1)
    {
        if(gd(n)) {cout<<n; return 0;}
        n++;
    }
    return 0;
}


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

int main(){
    long long L,R;
    cin >> L >> R;
    long long ans = 2000000000;
    for(long long i=L;i<=R;i++){
        for(long long j=L;j<=R;j++){
            if(i==j) continue;
            if(i%2019==0||j%2019==0){
                cout << 0 << endl;
                return 0;
            }
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools


def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist


def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper])


def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair))


if __name__ == '__main__':
    main()

Measured memory_bytes: 16168
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		long A = nextLong();
		long B = nextLong();

		long n = gcd(A,B);

		int sum = 1;
		for(int i=2;i<=Math.sqrt(n);i++) {
			if(n%i==0) {
				sum++;
				while(n%i==0) {
					n/=i;
				}
			}
		}
		if(n>1)sum++;
		out.println(sum);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
/**
 *    author:  tourist
 *    created: 26.11.2019 09:30:33       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  double p;
  cin >> p;
  p *= 0.01;
  if (x % 2 == 1) {
    cout << fixed << setprecision(17) << (x + 1) / 2 / p << '\n';
  } else {
    cout << fixed << setprecision(17) << x / 2 / p << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__ << endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


struct BIT{
 int n;
 int MAX;
 vector<ll> bit;
 BIT(){}
 BIT(int _n){
   n = _n;
   MAX = n +2;
   bit.resize(n+10,0);
 }
 
 ll query(int x){
   ll r=0;
   while(x>0){
     r+=bit[x];
     x-=(x&-x);
   }
   return r;
 }
 
 ll query(int l,int r){
   return query(r) - query(l-1);
 }
 
 void update(int x,ll val){
   while(x<MAX){
     bit[x]+=val;
     x+=(x&-x);
   }
 }

   
};


vector<pii> P;

bool ok(int x){
  
  int it=0;
  sort(all(P));
  for(int i=0;i<sz(P);i++){
   // cout << P[it].ff<<" "<<P[i].ff<<endl;
    while(it < i and P[it].ff + x <= P[i].ff){
      return true;
    }
  }
  sort(all(P),[&](pii a,pii b){
    return a.ss < b.ss;
  });
  it =0;
  for(int i=0;i<sz(P);i++){
   // cout << P[it].ss + x<<" "<<P[i].ss << endl;
    while(it < i and P[it].ss + x <= P[i].ss){
      return true;
    }
  }
  return false;
}
const int N = 200100;
int x[N],y[N];
int32_t main(){
  fastio;
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> x[i] >> y[i];
    P.pb(pii(x[i] + y[i],x[i] - y[i]));
  }
  sort(all(P));
  int l = 0 ,r = 1e10;
  
  int ans = l;
  while(l<=r){
    int mid = (l+r)/2;
    if(ok(mid)){
      ans = mid;
      l = mid + 1;
    }else r = mid - 1;
  }
  cout << ans << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

s = {}
for i in range(n):
    a, b=input().split()
    if a in s:
        s[a].append((i+1, int(b)))
    else:
        s[a]=[(i+1, int(b))]

for key in sorted(s):
    for i, score in sorted(s[key], key=lambda t:~t[1]):
        print(i)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n, C; cin >> n >> C;
  vector<pair<int,pair<int,int>>> cst;
  vector<vector<int>> CT(C,vector<int>(100010, 0));
  int s, t, c;
  rep(i,n) {
    cin >> s >> t >> c;
    CT[c-1][s]++;
    CT[c-1][t+1]--;
  };
  rep(i,C){
    rep(j,100010){
      if(j==0) continue;
      CT[i][j] = CT[i][j-1]+CT[i][j];
    }
    //rep(j,10) {cout << CT[i][j] <<" "; cout << endl; }
    int st=0;
    rep(j,100010){
      if(st==0 && CT[i][j]==1) st = j;
      if(st!=0 && CT[i][j]==0) {
        cst.pb({i, {st, j-1}});
        st = 0;
      }
    }
  }
  for(auto x:cst) {
    //cout << x.first << " " << x.second.first << " " << x.second.second << endl;
  }
  vector<int> time(100010, 0);
  rep(i,sz(cst)){
    time[cst[i].second.first-1]++;
    time[cst[i].second.second]--;
  }
  rep(i,sz(time)){
    if(i==0) continue;
    time[i] = time[i-1]+time[i];
  }
  int ans = 0;
  rep(i,sz(time)){
    ans = max(ans, time[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13688