akhauriyash/Code-Regression huggingface dataset:
#coding: utf-8

inf = 1000000000


def dijkstra(s):
    d = [inf for i in range(n)]
    color = ["white" for i in range(n)]
    p = [-1 for i in range(n)]
    d[s] = 0

    while True:
        mincost = inf
        for i in range(n):
            if color[i] != "black" and d[i] < mincost:
                mincost = d[i]
                u = i
        if mincost == inf:
            break

        color[u] = "black"

        for v in range(n):
            if color[v] != "black" and mtrx[u][v] != False:
                if d[u] + mtrx[u][v] < d[v]:
                    d[v] = d[u] + mtrx[u][v]
                    p[v] = u
                    color[v] = "gray"
    return d

n = int(input())
mtrx = [[False for j in range(n)] for i in range(n)]
for i in range(n):
    data = list(map(int,input().split()))
    k = data[1]
    for num in range(k):
        mtrx[i][data[2+2*num]] = data[2+2*num+1]

d = dijkstra(0)

for i, num in enumerate(d):
    print(i,num)



Measured memory_bytes: 5732
n = int(input())
a = list(map(int, input().split()))

left = []
right = []

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            right.append(a[i])
        else:
            left.append(a[i])
    
    print(*(left[::-1]+right))
else:
    for i in range(n):
        if i % 2 == 0:
            left.append(a[i])
        else:
            right.append(a[i])
    
    print(*(left[::-1]+right))

Measured memory_bytes: 30904
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100000];

int main() {
    int n, m, v, p, l, r, mid, i;
    
    scanf("%d %d %d %d", &n, &m, &v, &p);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    reverse(a, a + n);
    
    l = p - 1, r = n, mid = (l + r) / 2;
    
    while (r - l > 1) {
        int x = a[mid] + m, c;
        long long sum;
        
        if (a[p - 1] > x) {
            r = mid;
            mid = (l + r) / 2;
            
            continue;
        }
        
        if (p - 1 + n - mid - 1 >= v - 1) {
            l = mid;
            mid = (l + r) / 2;
            
            continue;
        }
        
        c = v - 1 - (p - 1) - (n - mid - 1);
        sum = (long long)c * m;
        
        for (i = p - 1; i < mid; i++) sum -= min(m, x - a[i]);
        
        if (sum <= 0) {
            l = mid;
            mid = (l + r) / 2;
        } else {
            r = mid;
            mid = (l + r) / 2;
        }
    }
    
    printf("%d\n", l + 1);
    
    return 0;
}


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

using namespace std;
 
typedef long long ll;

#define LARGE 1000000007
int cnt[30] = {0};

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

    for(int i = 0; i < n; i++)
    {
        cnt[s[i] - 'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 30; i++)
    {
        ans = (ans * (cnt[i] + 1)) % LARGE;
    }
    cout << ans - 1<< endl; 
}

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

char s[3], t;
int c;

int main(){
	c = 0;
	for (int i = 0; i < 3; ++i) cin >> s[i];
	for (int i = 0; i < 3; ++i){
		cin >> t;
		if (s[i] == t) c++;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    private int N;
    private char[] C;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        C = sc.NextCharArray();


        int cntW = 0;
        int cntR = 0;
        for (int i = 0; i < N; i++)
        {
            if (C[i] == 'W') cntW++;
            else cntR++;
        }

        int ans = cntR;
        int tmpW = 0;
        int tmpR = 0;
        for (int i = 0; i < N; i++)
        {
            if (C[i] == 'W') tmpW++;
            else tmpR++;

            int ww = tmpW;
            int rr = cntR - tmpR;
            ans = Math.Min(ans, Math.Max(ww, rr));
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 28648
#include<stdio.h>
int main()
{
	int i, j,x;
	scanf("%d",& x);
	for(i=0;i<10;i++)
		for (j = 0; j < 10; j++)
		{
			if (i * j == x)
				goto loop1;
		}
loop1:	if (i < 10)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        ArrayList<String> strs = new ArrayList<String>(Arrays.asList("SUN","MON","TUE","WED","THU","FRI","SAT"));
        System.out.println(7-strs.indexOf(a));
    }
}



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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << A[k - 1] << '\n';
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	d := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &d[i])
	}

	var sum int = 0
	for i := 0; i < N; i++ {
		for j := i; j < N; j++ {
			if i != j {
				sum = sum + d[i]*d[j]
			}
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> box(h,vector<char>(w));
  int ans = 0;
  rep(i,h) {
    rep(j,w) cin >> box[i][j];
  }
  for (int i = 0; i < (1<< h); i++) {
    bitset<6> biti(i);
    for (int j = 0; j < (1<< w); j++) {
      bitset<6> bitj(j);
      int cnt = 0;
      rep(k,h) {
        rep(l,w) {
          if(biti.test(k) && bitj.test(l) && box[k][l] == '#') cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, b;
    cin >> a >> b;

    cout << a * b << "\n";

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll sum = 0;
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    sum += min(K,A);
    K-=min(K,A);
    K-=min(K,B);
    sum-=min(K,C);
    cout << sum << "\n";
}

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

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int h=arr[i]+arr[j];
            int k=lower_bound(arr.begin(),arr.end(),h)-arr.begin();
            ans+=((k-1)-j);
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static TreeSet<Integer> all = new TreeSet<>();
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextLine().charAt(0) - '0';
		int[] base = new int[n];
		for (int i = 0; i < n; i++) {
		    base[i] = i + 1;
		}
		make(0, 0, base, n);
		int x = 0;
		char[] input = sc.nextLine().toCharArray();
		for (int i = 0; i < input.length; i += 2) {
		    x *= 10;
		    x += input[i] - '0';
		}
		Integer before = all.lower(x);
		if (before != null) {
		    System.out.println(toString(before,n));
		}
		System.out.println(input);
		Integer next = all.higher(x);
		if (next != null) {
		    System.out.println(toString(next, n));
		}
	}
	
	static void make(int value, int mask, int[] base, int size) {
	    if (mask == (1 << size) - 1) {
	        all.add(value);
	        return;
	    }
	    value *= 10;
	    for (int i = 0; i < size; i++) {
	        if ((mask & (1 << i)) != 0) {
	            continue;
	        }
	        make(value + base[i], mask | (1 << i), base, size);
	    }
	}
	
	static char[] toString(int x, int size) {
	    char[] ans = new char[size * 2 - 1];
	    Arrays.fill(ans, ' ');
	    int idx = ans.length - 1;
	    for (int i = 0; i < size; i++) {
	        ans[idx] = (char)(x % 10 + '0');
	        x /= 10;
	        idx -= 2;
	    }
	    return ans;
	}
}



Measured memory_bytes: 50112
Imports System.Collections
        Imports System.Collections.Generic
        Imports System.Linq
        Imports System.xml
        Imports System.xml.Linq
         
        Module Module1
          public sub main()
            
            dim N as string = Console.ReadLine()    
        IF N.indexof("7") > -1 then
          console.writeLine("Yes")
        else 
          console.writeLine("No")
        end if
     
              
          end sub 
        End Module

Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
#define pb push_back

int main(void)
{
    ll a,b;
	cin >> a >> b;
	ll ans = b;
	vi v(a);
	for(int i = 0;i<a;i++) cin >> v[i];
	for(int i = 0;i<a-1;i++)
	{
		if(v[i+1]-v[i]>=b) ans+=b;
		else ans+= v[i+1]-v[i];
	}
	cout << ans << endl;
   	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    cout << n/(a+b)*a+min(a,n%(a+b)) << endl;
}


Measured memory_bytes: 3612
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    if(n<1200) cout << "ABC" << ln;
    else cout << "ARC" << ln;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    # 1-indexに
    a = [0] + list(map(int, input().split()))
    c = [0 for _ in range(n + 1)]

    # See
    # https://www.youtube.com/watch?v=-o4r74eJzV4
    # 全体の計算量は，O(N^2)のようにみえて，O(NlogN)
    # 箱iの番号が大きいものから見る
    for i in range(n, 0, -1):
        # ボールの個数の和を0で初期化
        ball_count = 0

        # iの倍数の箱を順番に見る
        # ループの範囲を[2 * i, n]として，i個飛ばしで
        for j in range(2 * i, n + 1, i):
            # mod2は，xor（排他的論理和）を使うと言い換えるとスマートに記述できる．
            # ただし，演算の順序に注意が必要
            ball_count ^= c[j]

        # i個ずつみた後の合計(mod2)とa[i]を比べる
        c[i] = a[i] ^ ball_count

    # 出力
    # ボールが入っている箱の個数とその番号
    ans = [index for index, ci in enumerate(c) if ci == 1]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

int main(){
  int i,j;ll cnt=0;
  int n;ll x;
  cin>>n>>x;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll b[n-1];
  for(i=0;i<n-1;i++)b[i]=a[i]+a[i+1];
  for(i=0;i<n-1;i++){
    if(b[i]>x){
      cnt+=min(a[i+1],b[i]-x);
      b[i+1]-=min(a[i+1],b[i]-x);
      b[i]-=min(a[i+1],b[i]-x);
    }
  }
  for(i=0;i<n-1;i++){
    if(b[i]>x){
      cnt+=b[i]-x;
    }
  }
  cout<<cnt<<endl;
}

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

int main() {
    size_t n;
    cin >> n;
    unordered_set<int> as;
    for (size_t i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (as.count(x)) {
            cout << "NO" << endl;
            return 0;
        }
        as.insert(x);
    }

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


Measured memory_bytes: 8520
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	ll n, a[200001], b, ans=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		a[i]-=i+1;
	}
	sort(a, a+n);
	b=a[n/2];
	for(int i=0; i<n; i++){
		a[i]-=b;
		ans+=abs(a[i]);
	}
	cout << ans << endl;

	return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int A, B;
   cin >> A >> B;
   cout << max(A + B, max(A - B, A * B)) << endl;
   return;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


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

vector<long int> a[200005];
bool vis[200005]={0};
long int temp=0;

void dfs(long int x)
{
    vis[x]=1;
    temp++;
    for(long int i=0;i<a[x].size();i++)
    {
        if(vis[a[x][i]]==0)
        {
            dfs(a[x][i]);
        }
    }
}

int main()
{
    long int n,m;
    cin>>n>>m;
    long int aa,bb;
    map<pair<long int,long int>,int>mp;
    bool b[n+1]={0};
    while(m--)
    {
        cin>>aa>>bb;
        b[aa]=1;
        b[bb]=1;
        if(mp[{aa,bb}]==0 && mp[{bb,aa}]==0)
        {
            mp[{aa,bb}]=1;
            mp[{bb,aa}]=1;
            a[aa].push_back(bb);
            a[bb].push_back(aa);
        }
    }
    long int ans=0;
    for(long int i=1;i<=n;i++)
    {
        if(vis[i]==0 && b[i]!=0)
        {
            temp=0;
            dfs(i);
            ans=max(ans,temp);
        }
    }
    if(ans==0)
    ans=1;
    cout<<ans<<endl;
}

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

using namespace std;

const int N = 100;
char g[N + 10][N + 10];

int main () {

    int a, b;
    cin >> a >> b;
    int n = N;
    for(int i = 0; i < n / 2; ++i) {
        for(int j = 0; j < n; ++j) {
            g[i][j] = '.';
        }
    }
    for(int i = n / 2; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            g[i][j] = '#';
        }
    }

    for(int i = 1; i < a; ++i) {
        g[n - 1 - (i / 50) * 2][(i % 50) * 2] = '.';
    }

    for(int i = 1; i < b; ++i) {
        g[(i / 50) * 2][(i % 50) * 2] = '#';
    }
    cout << "100 100" << endl;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cout << g[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(b<=a+w && b >= a-w){
        cout << 0 << endl;
    }else{
        cout << min(abs(b-(a+w)), abs(a-(b+w))) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i,ans=0;
  for(i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a {111, 222, 333, 444, 555, 666, 777, 888, 999};
  for (int e: a) {
    if (n <= e) {
      cout << e;
      break;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
Lall = input()
L_l = Lall.split()
L_l_spl = [int(n) for n in L_l]
L = sorted(L_l_spl)
c=0
for x in range(N-2):
  for y in range(x+1,N-1):
    if L[x] == L[y]:
      pass
    else:
      for z in range(y+1,N):
        if L[z] == L[y]:
          pass
        else:
          xy = L[x] + L[y]
          zint = L[z]
          if zint < xy:
            c = c + 1
print(c)

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    char c = s[n/2];
    int ans = n / 2;
    for (int i=0; i<=n/2; i++)
    {
        if (c == s[(int)ceil((double)i+n/2.0 - 0.5)] &&  c == s[floor(-(double)i+n/2.0 - 0.5)])
        {
            ans++;
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,sum=0,k,i,j;
    // cin>>T;
    while(T--)
    {
        n=5;
        ll a[n],rnd[n],di[n];
        FOR(i,0,n)
        {
            cin>>a[i];
            if(a[i]%10==0)
                rnd[i]=a[i];
            else
                rnd[i] = (10- a[i]%10) + a[i]; 
            sum += rnd[i];
        }
        ll ans = sum;
        FOR(i,0,n)
        {   
            di[i] = sum + a[i]-rnd[i];
            if(ans>di[i])
                ans=di[i];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    h, w, n = map(int, input().split())
    xy = [tuple(map(int, input().split())) for _ in range(n)]
    miny = [float("inf") for _ in range(h + 1)]
    for x, y in xy:
        miny[x - 1] = min(miny[x - 1], y - 1)
    miny[h] = 0
    
    tmpx, tmpy = 0, 0
    while tmpx < h:
        if miny[tmpx + 1] <= tmpy:
            break
        elif miny[tmpx + 1] == tmpy + 1:
            tmpx += 1
        else:
            tmpx += 1
            tmpy += 1
    
    print(min(tmpx + 1, h))


if __name__ == '__main__':
    main()


Measured memory_bytes: 42524
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,e,f,g,h,r,w,l,num,ans,sum,ok,ng,mid;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;
//string s;

int main(){
	cin >> n >> k;
	if(k*2-1 <=  n){
		p("YES");
	}else{
		p("NO");
	}
	return 0;
}

Measured memory_bytes: 25088
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int top, s[101];

void push(int x){
    top += 1;
    s[top] = x;
}

int pop(){
    top -= 1;
    return s[top + 1];
}

int main(){
    int a, b, x;
    int top = 0; 
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[top] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[top] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        }else if(s[top] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    
    return 0;
}


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

#define ll long long int
#define vi vector<int> 

ll permut(int a){
    ll prod=1;
    for(int i=1;i<=a;i++){
        prod*=i;
    }
    
    return prod;
}


int main() {
   string s;
   string t;
   cin >> s >>t;
   cout << t<<s;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main()
{
  int a, b;
  cin >> a >> b;
  cout << a * b;

  return 0;
}

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

bool isp(int n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  for (int i = 3; i <= (int)sqrt(n); i += 2) if (n % i == 0) return false;
  return true;
}

int main() {
  int N = 1e5 + 1;
  vector<int> V(N);
  for (int i = 1, cnt = 0; i < N; i++) {
    if (!((i + 1) % 2) && isp(i) && isp((i + 1) / 2)) cnt++;
    V.at(i) = cnt;
  }
  int Q;
  cin >> Q;
  for (int l, r; cin >> l >> r;) cout << V.at(r) - V.at(l - 1) << "\n";
}

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

int main(){
  int N;
  cin >> N;
  vector<int> button_number(N,0);
  for(int i=0;i<N;i++){
    cin >> button_number.at(i);
  }
  
  int count = 0;
  for(int i=0;i<N;i++){
    if(button_number.at(i) == 2){
      count++;
      break;
    }else if(count == N){
      count = -1;
      break;
    }else{
      i = button_number.at(i)-2;
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const long long  mod = 1e14 ;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
typedef unsigned long long ull;
//unordered_map<int,int>mp;
//int need[MAXN];
//map<int,int>mp;
//TLE了 可能思路：每个数*一个数的形式 判断所得的num 然后与n比较 
//这道题注意点：O() 在数据范围小的情况下 尽量开普通数组 然后 是unordered_map（查找快，无序） 最后是map
//自己老是习惯开map 然后tle 不知所措 
ll a[MAXN],b[MAXN];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n;
	ll ans=0;
	ll max1=0,min1=INF;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	    scanf("%lld %lld",&a[i],&b[i]);
		max1=max(max1,b[i]);
		min1=min(min1,a[i]);
	} 
	sort(a+1,a+1+n);
	sort(b+1,b+1+n,cmp);
	if(n%2)  printf("%lld\n",b[(n+1)/2]-a[(n+1)/2]+1);
	else printf("%lld\n",b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1]+1);
	return 0;
} 

Measured memory_bytes: 6888
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 500005;
const ll lmod = 1e9+7;

int dp[MAX_N];

int main(){
  int N;
  string S;
  cin >> N >> S;
  fill(dp,dp+N,0);
  S = "0" + S + "0";
  REP(i,1,N+1){
    dp[i+1] = max(dp[i],dp[i+1]);
    if(S[i-1]=='1'&&S[i]=='0'&&S[i+1]=='1'){
      int a,b;
      a = i-1;
      b = i+1;
      while(1){
        if(S[a]=='0') break;
        dp[i+1] = max(dp[i+1],dp[a-1]+i-a);
        a--;
      }
      while(1){
        if(S[b]=='0') break;
        dp[b] = max(dp[b],dp[i-2]+b-i);
        b++;
      }
    }
  }
  // rep(i,N+2) cout << dp[i] << ",";
  // cout << "" << endl;
  // rep(i,N+2) cout << S[i] << ",";
  // cout << "" << endl;
  cout << dp[N+1] << endl;
  return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  print((n - 1) * (m - 1));
}

Measured memory_bytes: 256
# ABC 62, B - picture frame
h, w = map(int, input().split(' '))
P = []
for i in range(h):
    tmp = list(input())
    tmp.insert(0, '#')
    tmp.append('#')
    P.append(tmp)



line = ['#']*(w+2)
P.insert(0, line)
P.append(line)

for row in P:
    print(''.join(row))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define MOD (ll)(1e9+7)
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){

	fastcin
		
	ll n, k, ans = 0;
	cin >> n >> k;
	
	ll sum[n+1];
	
	memset(sum, 0, sizeof sum);
	
	for(int i=1; i<=n; i++) sum[i] += sum[i-1] + i;
	
	
	for(int i=k; i<=n+1; i++){
		
		ll s = sum[i-1];
		ll x = sum[n], y;
		
		(i == n+1) ? y = 0 : y = sum[n-i];
		
		ll b = x-y;
		
		ans += (b-s+1)%MOD;
	}
	
	cout << ans%MOD << endl;
	
	
	return 0;
}


Measured memory_bytes: 5172
import java.util.Scanner;

/**
 * Slimes
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            char[] S = sc.next().toCharArray();

            int ans = 0;
            char c = ' ';
            for (int i = 0; i < N; i++) {
                if (c != S[i]) {
                    c = S[i];
                    ans++;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b;
    vector<int> urban(a);
    for(int i=0;i<2*b;i++){
        cin >> c;
        urban[c-1] += 1;
    }
    for(int i=0;i<a;i++){
    cout << urban[i] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 100009
#define mod 1000000007
#define med 998244353
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LONG_MAX
#define err return 0
#define cn continue
#define bre break

string s;
bool one=0;
bool two=0;

bool is(char a,char b)
{
	int isi = (a-'0')*10+ (b-'0');
	if(isi>=13||isi<=0)
		return 0;
	return 1;
}

int32_t main()
{
	IOS;
	cin>>s;
	if(is(s[2],s[3]))
	{
		one=1;
	}
	if(is(s[0],s[1]))
	{
		two=1;
	}
	if(one==1&&two==1)
	{
		cout<<"AMBIGUOUS"<<endl;
		err;
	}
	if(one==1)
	{	
		cout<<"YYMM"<<endl;
		err;
	}
	if(two==1)
	{
		cout<<"MMYY"<<endl;
		err;
	}	
	cout<<"NA"<<endl;
}	


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.Split.Long;
            var A = line[0] - 1;
            var B = line[1];
            var C = line[2];
            var D = line[3];
            var CD = C * D / Gcd(C, D);

            var AC = A / C;
            var AD = A / D;
            var ACD = A / CD;

            var BC = B / C;
            var BD = B / D;
            var BCD = B / CD;

            return B - A - ((BC + BD - BCD) - (AC + AD - ACD));
        }
        long Gcd(long a, long b) => b > a ? Gcd(b, a) : (b == 0 ? a : Gcd(b, a % b));

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    int N;
    cin >>N;
    vl A(N);
    rep(i,N){
        cin >>A[i];
        A[i]=A[i]-i-1;
    }
    sort(all(A));
    ll b=A[N/2];
    ll ans=0;
    rep(i,N) ans+=abs(A[i]-b);
    cout <<ans<<endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// Greatest Common Divisor 最大公約数
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

// least common multiple 最小公倍数
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}
int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll a = (B/C)-((A-1)/C);
    ll b = (B/D)-((A-1)/D);
    ll l = lcm(C, D);
    ll c = (B/l)-((A-1)/l);
    cout << (B-A+1) - (a + b - c) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    double n;
    int eve = 0;
    int odd = 0;
    double t = 0;
    
    scanf("%lf", &n);

    if (n < 0 || n > 100) {
        puts("error");
        return 0;
    }

    for (int k = 1; k <= n; k++) {
        if (k%2 == 1) {
            odd++;
        } else {
            eve++;
        }
    }
    t = odd/n;

    printf("%.10f\n", t);

}

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

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x,y = LI()
    if x < 0:
        if y < 0:
            if x < y:
                print(y-x)
            else:
                print(x-y+2)
        else:
            if abs(x) < y:
                print(y-abs(x)+1)
            else:
                print(-y-x+(y>0))
    else:
        if y < 0:
            if x < abs(y):
                print(abs(y)-x+1)
            else:
                print(x+y+1)
        else:
            if x < y:
                print(y-x)
            else:
                print(x-y+(x>0)+(y>0))
    return

#B
def B():

    return

#C
def C():
    a = LI()
    if a[0] > 0 and a[3] > 0 and a[4] > 0:
        print(max(2*(a[0]//2)+a[1]+2*(a[3]//2)+2*(a[4]//2), 2*((a[0]-1)//2)+a[1]+2*((a[3]-1)//2)+2*((a[4]-1)//2)+3))
    else:
        print(2*(a[0]//2)+a[1]+2*(a[3]//2)+2*(a[4]//2))
    return

#D
def D():
    n = I()
    x = LI()
    f = [(x[i],i) for i in range(n)]
    f.sort()
    b = []
    for xi,i in f:
        b += [i+1]*i
    for xi,i in f:
        b += [i+1]*(n-i-1)
    ans = []
    l = 0
    for xi,i in f:
        while len(ans)+1 < xi:
            if l == len(b):
                break
            ans.append(b[l])
            l += 1
        ans.append(i+1)
    for i in range(l,len(b)):
        ans.append(b[i])
    f = [0]*n
    for i in range(len(ans)):
        ai = ans[i]-1
        if f[ai] == ai:
            if i+1 != x[ai]:
                print("No")
                return
        f[ai] += 1
    print("Yes")
    print(*ans)
    return

#E
def E():

    return

#F
def F():

    return

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


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

class UnionFind{
private:
    vector<int> p,s;
public:
	UnionFind(){}
	UnionFind(int N){
		p = s = vector<int>(N+1,0);
		for(int i=1;i<=N;i++){
			p[i] = i; s[i] = 1;
		}
	}
	int find(int x){
		if(p[x]==x) return x;
		else return p[x] = find(p[x]);
	}
	void unite(int x,int y){
		x = find(x); y = find(y);
		if(x==y) return;
		if(s[x]>s[y]){
			p[y] = x;
			s[x] += s[y];
		}else{
			p[x] = y;
			s[y] += s[x];
		}
	}
	bool is_same_set(int x,int y) {return find(x)==find(y);}
	int size(int x) {return s[find(x)];}
};

int N,M;
int checked[1000010] = {};
int main(){
    cin >> N >> M;
    UnionFind uf(N);
    int x,y,z;
    for(int i=0;i<M;i++){
        cin >> x >> y >> z;
        uf.unite(x,y); 
    }
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(!checked[uf.find(i)]){
            ans++;
            checked[uf.find(i)] = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
K = int(input())
last_ind = 0
li =[1,2,3,4,5,6,7,8,9]
length =0
while K>len(li):
    new_li = li[length:len(li)]
    length = len(li)
    for l in new_li:
        matsubi = int(list(str(l))[-1])
        if matsubi == 0:
            li.append(int(str(l)+str(matsubi)))
            li.append(int(str(l)+str(matsubi+1)))
        elif matsubi == 9:
            li.append(int(str(l)+str(matsubi-1)))
            li.append(int(str(l)+str(matsubi)))
        else:
            li.append(int(str(l)+str(matsubi-1)))
            li.append(int(str(l)+str(matsubi)))
            li.append(int(str(l)+str(matsubi+1)))
        if len(li)>K:
            break
        
print(li[K-1])

Measured memory_bytes: 7384
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();
		String ans = "No";
		if(a < b && b < c) ans = "Yes";
		System.out.println(ans);
	}
}



Measured memory_bytes: 26196
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b,n;cin >> a >> b >> n;
    int q = min(n,b-1);
    cout << a*q/b << endl;
    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<int>v;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        if(x!=i+1)
            cnt++;
    }
    if(cnt<=2)
        cout<<"YES";
    else
        cout<<"NO";

}


Measured memory_bytes: 3640
from collections import defaultdict, deque
import bisect
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def d(n):
    divisors = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    A = [
        int(input())
        for _ in range(N)
    ]

    res = [A[-1]]  # 4,5,9,,,
    for ai in reversed(A[:-1]):
        if ai >= res[-1]:
            res.append(ai)
            continue
        ind = bisect.bisect_right(res, ai)
        res[ind] = ai
    print(len(res))


if __name__ == '__main__':
    main()


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

int main() {
  int N, A, B, C, D;
  string s;
  cin >> N >> A >> B >> C >> D >> s;
  A--; B--; C--; D--;
  
  int dotsq = 0;
  int rocksq = 0;
  bool b = false;
  bool P = true;
  for (int i = A; i < max(C,D); i++) {
    if (s[i] == '.') {
      if (i >= B-1 && i <= D+1) dotsq += 1;
      rocksq = 0;
    }
    if (s[i] == '#') {
      dotsq = 0;
      rocksq += 1;
    }
    if (dotsq > 2) b = true;
    if (rocksq > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  if (C > D && !b) P = false;
  
  if (P) cout << "Yes" << endl;
  else cout << "No" << endl;
 }


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  set<int>s;
  for(int i = 1; i <= n; i++)
    s.insert(i);
  for(int i = 1 ; i <= k ; i++)
  {
    int d;
    cin >> d;
    for(int j = 0 ; j < d; j++)
    {
      int a;
      cin >> a;
      if(s.find(a) != s.end()) 
        s.erase(a);
    }
  }
  cout << (s.size()) << endl;
  return 0;
}

Measured memory_bytes: 3644