akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b = list(map(int, input().split()))

res = "APPROVED"
## DENIED

for i in range(a):
    if b[i] % 2 == 0 and (b[i] % 3 != 0 and b[i] % 5 != 0):
        res = "DENIED"
        break
    
print(res)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> pos(200005);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        pos[a].push_back(i);
    }
    
    // 1 が存在しないとき
    if(pos[1].size() == 0){
        cout << -1 << endl;
        return 0;
    }
    
    // 現在地 : 1 の中で一番左側の位置
    int now_pos = pos[1][0];
    for(int i = 2; i < 200005; ++i){
        auto it = upper_bound(pos[i].begin(), pos[i].end(), now_pos);
        
        if(it == pos[i].end()){     // 条件を満たすものがない場合
            cout << n - (i - 1) << endl;
            return 0;
        }
        
        now_pos = *it;      // 現在地の更新
    }
}

Measured memory_bytes: 11136
data = list(input())

if (data[0] == data[1] and data[1] != data[2] and data[2] == data[3]): print("Yes")
elif (data[0] == data[2] and data[2] != data[1] and data[1] == data[3]): print("Yes")
elif (data[0] == data[3] and data[3] != data[1] and data[1] == data[2]): print("Yes")
else: print("No")

Measured memory_bytes: 3064
import sys
from io import StringIO
import unittest

def resolve():
    t = input()

    len_t = len(t)

    ans = []
    set_p = False
    # 探索
    for i in range(len_t):
        if t[i] is "?":
            if i is 0:
                ans.append("D")
            elif len_t-1 is i:
                ans.append("D")
            elif ans[i-1] is "P":
                ans.append("D")
            elif t[i+1] is "D" or t[i+1] is "?":
                ans.append("P")
            else:
                ans.append("D")
        else:
            ans.append(t[i])

    print("".join(ans))




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """PD?D??P"""
        output = """PDPDPDP"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """P?P?"""
        output = """PDPD"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """?????"""
        output = """DPDPD"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """?DDD??"""
        output = """DDDDPD"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """?DPP??P??"""
        output = """DDPPDDPDD"""
        self.assertIO(input, output)

    def test_入力例_6(self):
        input = """??????D?"""
        output = """DPDPDPDD"""
        self.assertIO(input, output)

    def test_入力例_7(self):
        input = """???????"""
        output = """DPDPDPD"""
        self.assertIO(input, output)

    def test_入力例_8(self):
        input = """??P?PP??"""
        output = """DDPDPPDD"""
        self.assertIO(input, output)

    def test_入力例_9(self):
        input = """??P?D?PP?D"""
        output = """DPDPDPDD"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 86460
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define ll long long

int main(){
    int a,b,c,five=0,seven=0;
    for(int i=0;i<3;i++){
        scanf("%d",&a);
        if(a ==5){
            five++;
        }else if(a==7){
            seven++;
        }
    }
    if(five==2 && seven==1){
        pf("YES");
    }else{
        pf("NO");
    }
    return 0;
}











Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val C = IntArray(N) { sc.next().toInt() }.sortedBy { -it }
        val q = PriorityQueue<Int> { x, y ->
            return@PriorityQueue if (y > x) 1 else -1
        }
        q.add(C[0])
        var ans = 0L
        for (i in 1 until N) {
            val m = q.first(); q.remove(m)
            ans += m
            q.add(C[i])
            q.add(C[i])
        }
        pw.println(ans)
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

#define MAX 201
int N;
ll W,w[MAX],v[MAX];
ll ans;
void dfs(vector<ll> &keys,map<ll,vector<ll>> &mp,int cur,ll score,ll curW) {
  if( cur >= (int)keys.size() ) {
    ans = max(ans,score);
    return;
  }
  dfs(keys,mp,cur+1,score,curW);
  ll key = keys[cur];
  vector<ll> vec = mp[key];
  ll b = 0, a = 0;
  rep(i,(int)vec.size()) {
    b += vec[i];
    a += key;
    if( a+curW > W ) break;
    dfs(keys,mp,cur+1,score + b,a+curW);
  }
}

void compute() {

}

int main() {
  cin >> N >> W;
  map<ll,vector<ll>> mp;
  vector<ll> vec;
  rep(i,N) {
    cin >> w[i] >> v[i];
    vec.push_back(w[i]);
    mp[w[i]].push_back(v[i]);
  }
  sort(ALL(vec));
  vec.erase(unique(ALL(vec)),vec.end());
  rep(i,(int)vec.size()) {
    ll k = vec[i];
    sort(ALL(mp[k]),greater<ll>());
  }
  dfs(vec,mp,0,0,0);
  cout << ans << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#define maxn 3009
using namespace std;
typedef  long long ll;
#define N 200005
#define fr(i,x,y) for(int i=x;i<=y;i++)
int n,a[N],b[N],cnt[N];
struct node {
    int v, id;

    node() {}

    node(int v, int id) : v(v), id(id) {}

    bool operator<(const node &oth) const {
        return v < oth.v;
    }
}c[N<<1];
void doit(){
    scanf("%d",&n);
    if (n==1){
        puts("0");
        return;
    }
    int ma=-1,tt,ss,mi,maa=-1;
    fr(i,1,n){
        scanf("%d%d",&a[i],&b[i]);
        ma=max(ma,b[i]);
        ma=max(ma,a[i]);

    }
    fr(i,1,n)if (a[i]==ma||b[i]==ma){
            maa=max(maa,a[i]+b[i]-ma);
            if (a[i]+b[i]-ma==maa) tt=i;
        }
    mi=ma+1;
    fr(i,1,n)if (i!=tt){
            mi=min(mi,b[i]);
            mi=min(mi,a[i]);
            if(a[i]==mi) ss=i;
            if(b[i]==mi) ss=i;
        }
    int x,y;
    x=a[ss]+b[ss]-mi;
    y=a[tt]+b[tt]-ma;
    int o=0,gg=0;
    c[o++]=node(x,ss);
    c[o++]=node(y,tt);

    memset(cnt,0,sizeof(cnt));
    fr(i,1,n)if (i!=tt&&i!=ss){
            c[o++]=node(a[i],i);
            c[o++]=node(b[i],i);
        }
    sort(c,c+o);
    int i=0,j=0;
    cnt[c[j].id]++;
    int al=1;
    while (al<n){
        j++;
        if (!cnt[c[j].id]) al++;
        cnt[c[j].id]++;
    }
    gg=1000000008;
    while (1){
        gg=min(gg,c[j].v-c[i].v);
        int idd=c[i].id;
        i++;
        cnt[idd]--;

        if(!cnt[idd]){
            j++;
            while (c[j].id!=idd && j<o)j++;
        }

        if (j>=o) break;
    }


    ll ans2=1LL*(ma-mi)*gg;

    x=a[ss]+b[ss]-mi;
    y=a[tt]+b[tt]-ma;
    if (y<mi) swap(y,mi);
    int t1,t2;
    fr(i,1,n)if (i!=ss&&i!=tt){
            t1=max(a[i],b[i]);
            t2=min(a[i],b[i]);
            if (t2>y) y=t2;
            if (t1<x) x=t1;
        }


    ll ans1=1LL*(ma-x)*(y-mi);

    printf("%lld\n",ans1>ans2?ans2:ans1);
}

int main(){
    //while (1)
    doit();
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

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

	int N;
	cin>>N;
	vector<long long> a(N);
	for(int i = 0;i < N;i++) cin>>a[i], a[i] -= i + 1;
	sort(a.begin(),a.end());	
	long long res = LLONG_MAX;
	for(int f = max(0,N/2-1);f < min(N,N/2+2);f++) {
		long long cur = 0;
		for(int i = 0;i < N;i++) cur += abs(a[i] - a[f]);
		res = min(res,cur);
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 1792
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]

for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)
ans = 1
check = [0]*(N+1)
for i in range(1,N+1):
  st = deque([i])
  check[i] = 1
  cnt = 1
  while st:
    s = st.popleft()
    for t in l[s]:
      if check[t] == 0:
        check[t] = 1
        st.append(t)
        cnt += 1
  ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 44912
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1002;
int n;

int main()
{
    read(n);
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9) printf("hon");
    else if (n==0||n==1||n==6||n==8) printf("pon");
    else printf("bon");
    return 0;
}

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

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

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

int main() {
    int x, y; cin >> x >> y;
    {
        int ans, ax = abs(x), ay = abs(y);
        if (ax == ay) ans = x != y;
        if (ax < ay) ans = ay - ax + (x < 0) + (y < 0);
        if (ax > ay) ans = ax - ay + (x > 0) + (y > 0);
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
        string s,t;
        cin >> s >> t;

        if( s == t.substr(0,t.size()-1)){
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
        return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int n,m;

int main()
{
  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int N;
 cin>>N;
 vector<int>p(N);
 for(int i=0;i<N;i++){
     cin>>p[i];
 }
 sort(p.begin(),p.end());
 p[N-1]/=2;
 int sum=0;
 for(int i=0;i<N;i++){
     sum+=p[i];
 }
 cout<<sum<<endl;
 return 0;}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

map<char,int>mc;
int decode(string str){
	int res=0;
	int tmp=1;
	REP(i,SZ(str)){
		if(str[i]>='0'&&str[i]<='9'){
			tmp=(unsigned int)(str[i]-'0');
		}else{
			res+=tmp*mc[str[i]];
			tmp=1;
		}
	}
	return res;
}

string encode(int sum){
	string res="";
	if(sum>=1000){
		if(sum/1000==1)res+='m';
		else res+=(toString((int)(sum/1000))+'m');
		sum%=1000;
	}
	if(sum>=100){
		if(sum/100==1)res+='c';
		else res+=(toString((int)(sum/100))+'c');
		sum%=100;
	}
	if(sum>=10){
		if(sum/10==1)res+='x';
		else res+=(toString((int)(sum/10))+'x');
		sum%=10;
	}
	if(sum==1)res+='i';
	else if(sum>=2)res+=(toString(sum)+'i');
	return res;
}
int main(){
	int N;
	cin>>N;
	mc.insert(MP('m',1000));
	mc.insert(MP('c',100));
	mc.insert(MP('x',10));
	mc.insert(MP('i',1));
	REP(T,N){
		string s1,s2;
		cin>>s1>>s2;
		cout<<encode(decode(s1)+decode(s2))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int n, m, q;
    cin >> n >> m >> q;
    using P = pair<int, int>;
    vector<P> vp(m);
    rep(i, 0, m) {
        cin >> vp[i].first >> vp[i].second;
    }
    sort(all(vp));
    vector<vector<int> > memo(n + 1, vector<int>(n + 1));

    for (int i = 1; i <= n; ++i) {
        vector<int> rs;
        for (auto e : vp) {
            if (e.first >= i) {
                rs.push_back(e.second);
            }
        }
        for (auto e : rs) {
            memo[i][e]++;
        }
//        for (int j = n; j > 0; --j) {
//            memo[i][j - 1] += memo[i][j];
//        }
        for(int j = 1; j < n; ++j){
            memo[i][j + 1] += memo[i][j];
        }
    }

    while(q--){
        int p,q;
        cin >> p >> q;
        cout << memo[p][q] << endl;
    }

    return 0;
}


Measured memory_bytes: 4648
# ABC075/B
h, w = map(int, input().split())
S = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        cnt = 0
        if S[i][j] == '.':
            for di in (-1, 0, 1):
                for dj in (-1, 0, 1):
                    if 0 <= i + di < h and 0 <= j + \
                            dj < w and S[i + di][j + dj] == '#':
                        cnt += 1
            S[i][j] = str(cnt)
    print(''.join(S[i]))


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
typedef long long ll;
 
const int MAX_SIZE = 1e5 + 10;
 
vector<int> graph[MAX_SIZE];
vector<bool> visited(MAX_SIZE);
 
ll dfs(int a)
{
	visited[a] = true;
        ll s = 0;
	for(auto &u : graph[a])
	{
		if(!visited[u])
		{
			s ^= (dfs(u) + 1);
		}
	}
	return s;
}
 
int main()
{
	int N;
	cin >> N;
	int x, y;
	for(int i = 1; i < N; i++)
	{
		cin >> x >> y;
		graph[x].pb(y);
		graph[y].pb(x);
		visited[x] = false;
		visited[y] = false;
	}
	ll s = dfs(1);
	if(s == 0)
		cout << "Bob" << endl;
	else
		cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 10368
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 1
count = 0

n,p=map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

P=prime_factor(p)
for pi,amount in P:
    ans*=pi**(amount//n)
    # print((amount//n),pi)
print(ans)
        
# print(P)


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

int helper(string s1 , string s2 , int **dp)
{
    int l1 = (int)s1.size();
    int l2 = (int)s2.size() ;

    for(int i = 1 ; i<= l1 ; i++)
    {
        for(int j = 1 ; j<=l2 ; j++)
        {
            if(s1[i-1] == s2[j-1])
            {
                dp[i][j] = dp[i-1][j-1] +1;
            }
            else
            {
                dp[i][j] =max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }
    int i =l1;
    int j = l2 ;
    string sol ="";
    while (i > 0 && j >0)
    {
        if(dp[i][j] == dp[i-1][j])
        {
            i-=1;
        }
        else if(dp[i][j] == dp[i][j-1])
        {
            j-=1;
        }
        else
        {
            i-=1;
            j-=1;
            sol +=s1[i];
        }
    }
    for(int i = sol.size()-1 ; i>=0 ; i--)
    {
        cout<<sol[i];
    }
    return dp[l1][l2] ;
}

int lcs(string s1 , string s2)
{
    int l1 = (int)s1.size();
    int l2 = (int)s2.size();
    int **dp = new int*[l1 +1];
    for(int i = 0 ; i<= l1 ; i++)
    {
        dp[i] = new int[l2 +1];
        for(int j = 0 ; j<= l2 ; j++)
        {
            dp[i][j] = 0 ;
        }
    }
    return helper(s1 , s2 , dp);
}
int main(){
string s1 , s2 ;
cin>>s1>>s2;
int ans = lcs(s1 , s2) ;

return 0;
}


Measured memory_bytes: 35456
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
cost = []
for i in range(len(A)-1):
    cost.append(abs(A[i]-A[i+1]))
a = sum(cost)
for i in range(1,N+1):
    print(a-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 14048
//itp1_topic3_c

#include <bits/stdc++.h>

using namespace std;


  int main(){

	while(1){

	int x, y;

	cin>>x>>y;

	if(x == 0 && y == 0)	break;


	if(x>y) swap(x,y);

	cout<<x<<" "<<y<<endl;

	}

	return 0;

}





Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m,o;
  cin >> n;
  m = n;
  o = n;
  int sum = 0;
  vector<int> a;

  
  
  int i = 0;
  while(1){
    
    if(m % -2 == 0){
      a.push_back(0);
      m /= -2;
      
    }
    else{
      a.push_back(1);
      m--;
      m /= -2;
      int b = pow(-2,i);
      sum += b;
    }
    
    //cout << sum << endl;

    if(sum == o){
      break;
    }
    
    i++;
  }
  
  int m1 = a.size();
  reverse(a.begin(),a.end());
  REP(i,m1) cout << a[i];
  
  
}


Measured memory_bytes: 4020
n, k = map(int, input().split())
p = 0
pp = 1 / n

for i in range(1, n + 1):
    if k < i:
        p += pp
    else:
        c = 0
        b = i
        while b < k:
            b = b * 2
            c += 1
        p += pp * (0.5 ** c)

print(p)


Measured memory_bytes: 3064
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 1000005
int fun(int a,int b){
    if(a!=b) return abs(a-b);
    return a;
}
int main()
{
    int i,n,t;
    queue<int>q;
    scanf("%d",&n);
    for(i=0;i<(1<<n);++i){
        scanf("%d",&t);
        q.push(t);
    }
    int a,b;
    while(q.size()>1){
        a=q.front();
        q.pop();
        b=q.front();
        q.pop();
        int t=fun(a,b);
        q.push(t);
    }
    cout<<q.front()<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i = 1;i <= (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

//入力はすべて正とする //素数判定o(√n) 
bool is_prime(int n) {//素数判定o(√n)
    for (int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return n!=1;//1の場合は例外
}

vector<int> divisor(int n){//約数の列挙o(√n)
    vector<int> res;
    for(int i=1;i*i<=n;i++) {
        if(n%i == 0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
        }
    }
    return res;
} 

map<int,int> prime_factor(int n){//素因数分解o(√n)
    map<int,int>res;    
    for(int i=2;i*i<=n;i++) {
        while (n%i==0) { 
            ++res[i];
            n/=i;
        }
    }
    if (n!=1)res[n]=1;
    return res;
}
*/
/*--------------------------------------------*/

bool is_prime(int n) {//素数判定o(√n)
    for (int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return n!=1;//1の場合は例外
}

vector<int> divisor(int n){//約数の列挙o(√n)
    vector<int> res;
    for(int i=1;i*i<=n;i++) {
        if(n%i == 0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
        }
    }
    return res;
} 

map<int,int> prime_factor(int n){//素因数分解o(√n)
    map<int,int>res;    
    for(int i=2;i*i<=n;i++) {
        while (n%i==0) { 
            ++res[i];
            n/=i;
        }
    }
    if (n!=1)res[n]=1;
    return res;
}
int main(){
    int n;cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i+=2){
        //cout<<is_prime(i)<<endl;
        vec k=divisor(i);
        //rep(i,k.size())cout<<k[i]<<" ";
        if(k.size()==8)cnt++;
        //cout<<prime_factor(i)<<endl;
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 256
def my_print(s: str, args: [int]) -> str:
    return s[int(args[0]): int(args[1]) + 1]


def my_reverse(s: str, args: list) -> str:
    start = int(args[0])
    end = int(args[1]) + 1
    to_reverse_string = s[start:end]
    return s[:start] + to_reverse_string[::-1] + s[end:]


def my_replace(s: str, args: list) -> str:
    start = int(args[0])
    end = int(args[1]) + 1
    return s[:start] + args[2] + s[end:]


def resolve():
    s = input()
    n = int(input())

    for _ in range(n):
        f, *args = input().split()

        if f == 'print':
            print(my_print(s, args))
        if f == 'reverse':
            s = my_reverse(s, args)
        if f == 'replace':
            s = my_replace(s, args)


resolve()


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int> C(26, 0);
	int res = 0;
	for (int i = 0; i < N; i++) {
		C[S[i] - 'a']++;
	}
	res = 1;
	for (int i = 0; i < 26; i++) {
		res = (res * (C[i] + 1)) % MOD;
	}
	res--;
	if (res < 0)res += MOD;

	cout << res << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();
        int w = sc.nextInt();
        
          if(s>w){
            System.out.println("safe");
          }else{
            System.out.println("unsafe");
          };
    }
}


Measured memory_bytes: 27032
#include<iostream>
using namespace std;
int main(){
  int x;
  cin>>x;
  int left=0;
  int right=x;
  int mid=(left+right)/2;
  while(left<=right&&(x<mid*100||mid*105<x)){
    if(mid*100>x){
      right=mid-1;
    }else if(mid*105<x){
      left=mid+1;
    }
    mid=(left+right)/2;
  }
  if(right<left){
    cout<<0<<endl;
  }else{
    cout<<1<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,x = inpl()

if a*a*b == x:
    print(0)
    quit()
if x/(a**2*b) <= 0.5:
    tmp = ((2*x)/(a*b)) / b
    atan1 = math.degrees(math.atan(tmp))
    print(90-atan1)
else:
    c = 2*(b-x/(a*a))
    tmp = a/c
    atan1 = math.degrees(math.atan(tmp))
    print(90-atan1)


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


void solve(long long a, long long b, long long x){
    long long res = b/x - (a%x == 0 ? a/x - 1 : a/x);
    cout << res << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);
    solve(a, b, x);
    return 0;
}


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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

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

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

#define int ll

void solve() {
        int n;
        cin >> n;
        set<int> s;
        FOR(i,0,n) {
        	int temp;
        	cin >> temp;
        	s.insert(temp);
        }
        if(SZ(s) == n) {
        	cout << "YES" << endl;
        }
        else {
        	cout << "NO" << endl;
        }
}


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

using namespace std;

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

#define ll long long

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

	bool ret = false;
	if (s[0] == 'A') {
		int C = 0;
		Rep (i, 2, s.length() - 1)
			if (s[i] == 'C')
				C++;
		if (C == 1) {
			rep (i, s.length()) {
				ret = true;
				if (isupper(s[i]) && s[i] != 'A' && s[i] != 'C') {
					ret = false;
					break;
				}
			}
		}
	}
	if (ret)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
}



Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;

int main(void) {
	string s[8] = { " ","SAT","FRI","THU","WED","TUE","MON" ,"SUN"};
	string a;
	cin >> a;
	int i = 0;
	while (true) {
		if (s[i] == a) {
			cout << i << endl;
			return 0;
		}
		i++;
	}
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

ll ans=0,n;

ll fun(ll i,ll x,ll y,ll z){
 if(i>n) return 0;
  else if(x>=1&&y>=1&&z>=1) ans++;
  fun(10*i+3,x+1,y,z);
  fun(10*i+5,x,y+1,z);
  fun(10*i+7,x,y,z+1);
 return 0;
}

int main(){
 cin>>n;
  fun(3,1,0,0); fun(5,0,1,0); fun(7,0,0,1);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define lREP(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

int main(){
  int N;
  cin >> N;
  int A[N+1];
  A[0] = 0;
  lREP(i,N) cin >> A[i];

  sort(A, A+N+1);
  int ans = 0;
  bool odd = true;
  REP(i,N){
    if(A[i] == A[i+1]) { odd ^= 1; ans += (odd ? 1 : -1); }
    else { ans += 1; odd = true; }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
/**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200002;
const int mod = 1000000000007ll;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, a[maxn], ssum[maxn], minav, maxav;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    cin >> n;

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

    for(int i=n; i>=0; i--)
        ssum[i] = ssum[i+1] + a[i];

    bool can = 1;
    int ans = 0;
    minav = 0, maxav = 1;
    for(int i=0; i<=n; i++){
        cin >> a[i];
        if( a[i] >= minav && a[i] <= maxav ){
            maxav -= a[i];
            ans += a[i];
            ans += min( maxav , ssum[i+1] );
        }
        else{
            can = 0;
        }
        if( maxav < 100000000000000ll )
            maxav *= 2;
    }

    if( can ) cout << ans << '\n';
        else cout << -1 << '\n';

    return 0;
}


Measured memory_bytes: 5148
import sys
h, w = map(int, input().split())
grid = [['.' for i in range(w + 2)]]
for i in range(h):
    row = input()
    grid.append('.' + row + '.')
grid.append(['.' for i in range(w + 2)])

for i in range(1,h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            if '#' not in (grid[i-1][j], grid[i+1][j], grid[i][j-1], grid[i][j+1]):
                print('No')
                sys.exit()
print('Yes')


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

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

    int CA = 0;
    int PN = 0;

    vector<int> submit(M);
    vector<string> judge(M);

    vector<int> clear(N,0);
    vector<int> penalty(N,0);
    
    rep(i,M){
      cin >> submit.at(i);
      cin >> judge.at(i);
      // 未クリア問題をACしたら
      if( judge.at(i) == "AC" && clear.at(submit.at(i)-1) == 0){
        CA++; // 正解数 Correct Answer 足す
        clear.at(submit.at(i)-1) = 1; // 提出した番号のクリアフラグ
      } else if( judge.at(i) == "WA" && clear.at(submit.at(i)-1) == 0 ){ // WA
        penalty.at(submit.at(i)-1)++; // 提出した番号のペナ回数
      }
    }

    // penalty計算
    rep(i,N){
      if( (clear.at(i) != 0 ) && (penalty.at(i)) != 0 ){
        PN += penalty.at(i);
      }
    }

    cout << CA << " " << PN << endl; 

}


Measured memory_bytes: 6912
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    tmp = []
    for i in range(M):
        p = P[i]
        y = Y[i]
        tmp.append([i, p, y, ''])
    tmp.sort(key=lambda x: x[2])
    count = [0] * (N + 1)
    for t in tmp:
        p = t[1]
        count[p] += 1
        t[3] = '%06d%06d' % (p, count[p])
    tmp.sort(key=lambda x: x[0])
    for t in tmp:
        print(t[3])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }


    int maxv = -1000000000;
    int minv = r[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, r[i]-minv);
        minv = min(minv, r[i]);
    }
    cout << maxv << endl;

    return 0;
}





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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i<n; i++){
        int a;
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

const int L = 4000;
const int K = 1'000'000 / L;
int A1[L], B1[L], am, bm, ac, bc, mi, sum;
pair<int, int> A2[K], B2[K];
int main() {
	until(getchar_unlocked() == '\n') { }
	while(true) {
		char c = getchar_unlocked();
		if(c == '(' || c == ')') {
			sum += (c == '(' ? +1 : -1);
			setmin(mi, sum);
		} else {
			int a = -mi, b = sum - mi;
			if(a <= b) { if(a < L) { A1[a] += sum; setmax(am, a + 1); } else { A2[ac++] = { a, sum }; } }
			else       { if(b < L) { B1[b] += sum; setmax(bm, b + 1); } else { B2[bc++] = { b, sum }; } }
			mi = 0, sum = 0;
			if(c == EOF) { break; }
		}
	}
	sort(A2, A2 + ac);
	sort(B2, B2 + bc);
	inc(i, am) {
		setmin(mi, sum - i);
		sum += A1[i];
	}
	inc(z, ac) { auto [i, Ai] = A2[z];
		setmin(mi, sum - i);
		sum += Ai;
	}
	dec(z, bc) { auto [i, Bi] = B2[z];
		sum += Bi;
		setmin(mi, sum - i);
	}
	dec(i, bm) {
		sum += B1[i];
		setmin(mi, sum - i);
	}
	puts(mi >= 0 && sum == 0 ? "Yes" : "No");
}


Measured memory_bytes: 3648
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    long a = sc.nextInt();
    long b = sc.nextInt();
    long c = sc.nextInt();
    long d = sc.nextInt();

    long[] s = new long[4];
    s[0] = a*c;
    s[1] = a*d;
    s[2] = b*c;
    s[3] = b*d;

    long ans = s[0];
    for(int i = 0; i < 4; i++) {
      if(ans < s[i]) ans = s[i];
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35652
k, n = map(int, input().split())
ai = list(map(int, input().split()))

dists = []

last = -1
for a in ai:
    if last < 0:
        last = a
        continue
    
    dists.append(a - last)
    last = a

dists.append(k - last + ai[0])

print(k - max(dists))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

const ll LUN_MAX = 3234566667;
ll k;
vector<ll> lunlun;

void dfs(ll v){
    if(v <= LUN_MAX){
        lunlun.push_back(v);
        int below = v%10;

        dfs(v*10 + below);
        if(below > 0)dfs(v*10 + below-1);
        if(below < 9)dfs(v*10 + below+1);
    }
}

int main(){
    cin >> k;

    for(int i = 1; i <= 9; ++i){
        dfs(i);
    }

    sort(ALL(lunlun));

    cout << lunlun[k-1] << endl;
}

Measured memory_bytes: 1400
N=int(input())
A=[]
ans=1
for i in range(N):
    Xi,Li=map(int,input().split())
    A.append([Xi-Li,Xi+Li])
A.sort(key=lambda x:x[1])

def interf(A1,A2):
    if A1[1]>A2[0]:
        return 1
    else:
        return 0
    
pre=A[0]
for i in range(1,N):
    if interf(pre,A[i])==0:
        ans+=1
        pre=A[i]
print(ans)

Measured memory_bytes: 21344
N,M = map(int,input().split())
lr = []
left,right = map(int,input().split())
for i in range(1,M):
    l,r = map(int,input().split())

    if left < l:
        left = l
    if right > r:
        right = r

if right >= left:
    print(right-left+1)
else:
    print(0)


Measured memory_bytes: 45288
;;; Utils

(defmacro read-numbers-to-list (size)
  `(progn
     (when (not (integerp ,size))
       (error "Size must be integer."))
     (when (< ,size 0)
       (error "Size must be plus or zero."))
     (loop repeat ,size collect (read))))



(defmacro read-numbers-to-array (size)
  `(progn
     (when (not (integerp ,size))
       (error "Size must be integer."))
     (when (< ,size 0)
       (error "Size must be plus or zero."))
     (make-array ,size :initial-contents (read-numbers-to-list ,size))))

(defmacro read-numbers-to-board (row-size column-size)
  (let ((board (gensym))
        (r (gensym))
        (c (gensym)))
    `(let ((,board (make-array '(,row-size ,column-size))))
       (dotimes (,r ,row-size)
         (dotimes (,c ,column-size)
           (setf (aref ,board ,r ,c) (read))))
       ,board)))


(defmethod make-cumlative-sum ((sequence list))
  (labels ((inner (sequence &optional (acc '(0)))
             (if (null sequence)
                 (reverse acc)
                 (inner (rest sequence) (cons (+ (first sequence)
                                                 (first acc))
                                              acc)))))
    (inner sequence)))


(defmethod make-cumlative-sum ((sequence array))
  (declare (type (simple-array fixnum) sequence))
  (the array
       (let* ((n (length sequence))
              (acc (make-array (1+ n) :element-type 'integer :initial-element 0)))
         (loop for i below n do
              (setf (aref acc (1+ i)) (+ (aref sequence i)
                                         (aref acc i)))
            finally
              (return acc)))))




(defmethod princ-for-each-line ((sequence list))
  (labels ((inner (sequence)
             (if (null sequence)
                 (fresh-line)
                 (progn
                   (fresh-line)
                   (princ (first sequence))
                   (inner (rest sequence))))))
    (inner sequence)))

(defmethod princ-for-each-line ((sequence array))
  (dotimes (i (length sequence))
    (fresh-line)
    (princ (aref sequence i)))
  (fresh-line))


(defmacro with-buffered-stdout (&body body)
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))




;;; Write code here


(defun solve (n a)
  (let ((left (make-array (1+ n)))
        (right (make-array (1+ n))))
    (dotimes (i n)
      (setf (aref left (1+ i))
            (gcd (aref left i)
                 (aref a i))))
    (dotimes (i n)
      (setf (aref right (- n i 1))
            (gcd (aref right (- n i))
                 (aref a (- n i 1)))))
    (reduce #'max (loop for i below n collect
                       (gcd (aref left i)
                            (aref right (1+ i)))))))



(defun main ()
  (let* ((n (read))
         (a (read-numbers-to-array n)))
    (format t "~a~%" (solve n a))))

(main)


Measured memory_bytes: 79188
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A >= 13) {
			System.out.println(B);
		} else if (A >= 6 && A <= 12) {
			System.out.println(B / 2);
		} else {
			System.out.println("0");
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int dp[3001][3001];
int pre[3001][3001];
int main() {
	string s, t; cin >> s >> t;
	memset(pre, 0xff, sizeof(pre));
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			dp[i][j] = s[i] == t[j];
			if (i > 0 and dp[i - 1][j] > dp[i][j]) {
				dp[i][j] = dp[i - 1][j];
				pre[i][j] = 0;
			}
			if (j > 0 and dp[i][j - 1] > dp[i][j]) {
				dp[i][j] = max(dp[i][j], dp[i][j - 1]);
				pre[i][j] = 1;
			}
			if (i > 0 and j > 0 and s[i] == t[j]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
				pre[i][j] = 2;
			}
		}
	}
	int i = s.size() - 1, j = t.size() - 1;
	string lcs;
	while (1) {
		if (pre[i][j] == -1) {
			if (s[i] == t[j]) lcs.push_back(s[i]);
			break;
		}
		else if (pre[i][j] == 0) i--;
		else if (pre[i][j] == 1) j--;
		else if (pre[i][j] == 2) {
			lcs.push_back(s[i]);
			i--, j--;
		}
	}
	reverse(lcs.begin(),lcs.end());
	cout << lcs << endl;
}


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

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] ds = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                ds[i] = int.Parse(words[i]);
            }
        }

        int answer = 0;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                answer += ds[i] * ds[j];
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140