akhauriyash/Code-Regression huggingface dataset:
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC110D
long long gya(long long a) { //逆元を求める
  long long m=1000000007, b=m, u=1, v=0, c, t;
  while(b){
    t=a/b; //何これ
    a-=t*b, u-=t*v; //何これ
    c=a, a=b, b=c, c=u, u=v, v=c; //swap
  }
  return (u+m)%m;
}
long long com(long long b, long long d) { //bCd
  int i, mod=1000000007;
  long long ret=1, re2=1;
  for(i=1; i<=d; i++)
    ret=ret*(b-d+i)%mod, re2=re2*i%mod;
  return ret*gya(re2%mod)%mod;
}
int main(void) {
  long long n, m, k, i, cou=0, tmp, size=1000, memo[size], sum=1,mod=1e9+7;
  scanf("%lld %lld", &n, &m);
  int sqm=sqrt(m);

  for(i=0; i<size; i++)
    memo[i]=0;

  for(i=2; i<=sqm; i++){

    while(m%i==0){
      m/=i;
      memo[cou]++;
    }
    if(memo[cou]!=0) cou++;
    if(m==1) break;
  }
  if(m>sqm) memo[cou++ ]++;

  for(i=0; i<cou; i++){
    sum=sum*com(n-1+memo[i], memo[i])%mod;
    //printf("memo[%lld]=%lld\n", i, memo[i]);
   // printf("sum=%lld\n", sum);
  }
  printf("%lld", sum);
  return 0;
}

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

long long hasil[100005][5];

int main () {
	int n;
	scanf("%d", &n);
	
	long long data[n + 1][5];
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld %lld", &data[i][1], &data[i][2], &data[i][3]);
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < 4; j++) {
			for(int k = 1; k < 4; k++) {
				if(k != j) {
					if((hasil[i][j] == 0) || (hasil[i][j] < hasil[i-1][k] + data[i][j])) hasil[i][j] = hasil[i-1][k] + data[i][j];
				}
			}
		}
	}
	
	int tmp = 1;
	for(int i = 1; i < 4; i++) {
		if(hasil[n][i] > hasil[n][tmp]) tmp = i;
	}
	swap(hasil[n][1], hasil[n][tmp]);
	printf("%lld\n", hasil[n][1]);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
pll po[5252];

ll dp[5252];

int main(){
  const ll INF = 12521830252125ll;
  scanf("%d",&n);
  REP(i,n)scanf("%lld%lld",&po[i].first,&po[i].second);
  REP(i,n+1)dp[i] = INF;
  dp[0] = 0ll;
  sort(po,po+n,[&](pll a, pll b){
    return a.first+a.second < b.first+b.second;
  });
  REP(i,n)FORR(j,0,n){
    if(dp[j]<=po[i].first){
      CHMIN(dp[j+1], dp[j]+po[i].second);
    }
  }
  int ans = 0;
  REP(i,n+1)if(dp[i]!=INF)ans=i;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 384
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         char[] arr = infile.readLine().toCharArray();
         char[] copy = new char[arr.length];
         int N = arr.length;
         for(int i=0; i < N; i++)
            copy[i] = arr[i];
         for(int i=0; i < N; i++)
            if(arr[i] == '?')
               arr[i] = 'D';
         System.out.println(arr);
      }
   }

Measured memory_bytes: 36820
#include<bits/stdc++.h>
using namespace std;
char a[101];
int n,now,ans;
int main()
{
    scanf("%d%s",&n,a+1);
    for(int i=1;i<=n;i=-~i)
    {
        if(a[i]=='I')
			now=-~now;
        else
			--now;
        ans=max(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main()
{
    ll n, k;
    cin >> n >> k;
    vl p(n, 0);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    ll ans = 0;
    rep(i, k)
    {
        ans += p[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3632
N, k = map(int, input().split())                                                                               
s = input()
l, accum = len(s), []
zeros, ones = [], []
if s[0] == '0':
    ones = [0]
i = 0
while i < l:
    ch = s[i]
    if ch == '0':
        count = 0
        while i < l and s[i] == ch:
            count += 1
            i += 1
        zeros.append(count)
    elif ch == '1':
        count = 0
        while i < l and s[i] == ch:
            count += 1
            i += 1
        ones.append(count)
mx = sum(zeros[:k]) + sum(ones[:k+1])
ones+=[0]
for i in range(1, len(zeros)): zeros[i] += zeros[i-1]
for i in range(1, len(ones)): ones[i] += ones[i-1]
for i in range(1, len(zeros)-k+1):
    mx = max(zeros[k+i-1] + ones[k+i] - zeros[i-1] - ones[i-1], mx)
print(mx)

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

using namespace std;

using ll = long long;

int main() {
    string s;
    cin >> s;
    bool flag = true;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R' && (i & 1)) {
            flag = false;
            break;
        }
        if (s[i] == 'L' && (i % 2) == 0) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 10



int main(void){
    int n;
    int tall[200005];
    long long total=0;
    scanf("%d",&n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d",&tall[i]);
    }

    for (int i = 0; i < n-1; i++)
    {
        if(tall[i] > tall[i+1]){
            total += tall[i] - tall[i+1];
            tall[i+1] += tall[i] - tall[i+1];
        }
    }

    printf("%lld\n",total);




    return 0;
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
using namespace std;
#define _turbo                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
const int limn = 1e2 + 2;
const int limw = 1e5 + 2;
pair<int, int> tab[limn];
long long dp[limw];
int main()
{
    _turbo;
    int n,w;
    cin >> n>>w;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        tab[i] = {a, b};
    }


    for (int i = 0; i < n; i++)
    {
        for (int j = w; j > 0; j--)
        {
            if (j - tab[i].first >= 0)
            {
                dp[j] = max(dp[j], dp[j - tab[i].first] + tab[i].second);
            }
        }
    }
    //for (int i = 0; i <= w; i++)
    //    cout << i << ": " << dp[i] << "\n";
    cout<<dp[w];
    return 0;
}


Measured memory_bytes: 1024
/*
susheel_7
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

int main(){
    ll n;
    cin>>n;
    double ans,ans1;
    ans=ceil((n)/1.08);
    //cout<<ans<<endl;
    ans1=(ans*1.08);
   // cout<<ans<<" "<<ans1<<endl;
    if(n==(int)ans1)
    cout<<ans;
    else
    cout<<":(";
    return 0;
}

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

#define ll long long 

int main() {
  ll N, M;
  cin >> N >> M;
  
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1) {
    cout << M-2 << endl;
  } else if (M == 1) {
    cout << N-2 << endl;
  } else {
    cout << (N-2) * (M-2) << endl;
  }
}

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

int main(){
  int a, b;
  while(cin >> a >> b) {
    int sum, count;
    count = 0;
    sum = a + b;
    for(int i=sum;i>0;i = i/10){
      count++;
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 3000
#include <iostream>
#include <map>

using namespace std;

map<int, int> probs; // (difficulty, count)
int n, m;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        int d;
        cin >> d;
        probs[d]++;
    }

    cin >> m;

    for(int i = 0; i < m; i++) {
        int t;
        cin >> t;
        if(probs[t]) {
            probs[t]--;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int main(void){
    long long max = 0,ans = 0;
    int i = 0, n, num;

    scanf("%d",&n);
    
    while(i<n){
        scanf("%d",&num);
        if(num>max){
            max = num;
        }else{
            if(i!=0){
                ans += (max-num);
            }
        }
        i++;
    }

    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 1708
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
using namespace std;
int n,a[MAXN+5],cnt[MAXN+5];
int main()
{
	scanf("%d",&n);
	int x,maxval=-1;
	bool legal=true;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		cnt[x]++;
		maxval=max(maxval,x);
	}
	int mid=(maxval+1)/2;
	for(int i=mid-1;i>=1;i--)
		if(cnt[i]!=0)
		{
			legal=false;
			break;
		}
	for(int i=maxval;i>=mid+1;i--)
		if(cnt[i]<2)
		{
			legal=false;
			break;
		}
	if(maxval%2==1&&cnt[mid]!=2)
		legal=false;
	if(maxval%2==0&&cnt[mid]!=1)
		legal=false;
	if(legal==false)
		printf("Impossible\n");
	else
		printf("Possible\n");
	return 0;
}

Measured memory_bytes: 128
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region GCD
ll gcd(ll a, ll b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return (a*b) / gcd(a, b);
}
#pragma endregion

int main()
{
	ll n, m; cin >> n >> m;
	string s, t; cin >> s >> t;
	if (s[0] != t[0])
	{
		cout << -1 << endl;
	}
	else if (gcd(n, m) == 1)
	{
		cout << (ll)n * m << endl;
	}
	else
	{
		int nd = n / gcd(n, m);
		int md = m / gcd(n, m);
		string a = "", b = "";
		for (int i = nd; i < n; i += nd)a += s[i];
		for (int i = md; i < m; i += md)b += t[i];
		if (a == b)cout << lcm(n, m) << endl;
		else cout << -1 << endl;
	}
}

Measured memory_bytes: 512
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bits/stdint-intn.h>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Boost
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>

#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;

constexpr int64_t MOD = 1000000007;

vector<int64_t> divisor(const int64_t &_n) {
  vector<int64_t> head, tail;
  for (int64_t i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n)
        tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

int64_t kadanes(const vector<int64_t> &_ls) {
  int64_t highestMax = 0, currentMax = 0, length = _ls.size();
  for (int64_t i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

void execution();

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  // cout<<fixed<<setprecision(20);

  execution();
  return 0;
}

//--------------------------------------------------------------
void execution() {
  int n;
  cin>>n;


  int ans=0;
  for(int a=1;a<n;a++){
    for(int b=1;b<n;b++){
      if(n <= a*b){
        break;
      }else{
        ans++;
      }
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3196
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let ans = n % 2 == 0 && (0..n / 2).all(|i| s[i] == s[i + n / 2]);

    println!("{}", if ans { "Yes" } else { "No" });
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < b; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  cout << "NO" << '\n';
}


Measured memory_bytes: 3648
# @author 

import sys

class AFrog1:
    def solve(self):
        n = int(input())
        h = [int(_) for _ in input().split()]
        dp = [0] * (n + 1)
        dp[1] = abs(h[1] - h[0])
        for i in range(2, n):
            dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
        print(dp[n - 1])

solver = AFrog1()
input = sys.stdin.readline

solver.solve()


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

int main(void) {
    vector<vector<int>> a(3, vector<int>(3));
    vector<vector<bool>> flag(3, vector<bool>(3, false));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) {
                    flag[j][k] = true;
                }
            }
        }
    }
    bool ans = false;
    ans |= (flag[0][0] & flag[0][1] & flag[0][2]);
    ans |= (flag[1][0] & flag[1][1] & flag[1][2]);
    ans |= (flag[2][0] & flag[2][1] & flag[2][2]);
    ans |= (flag[0][0] & flag[1][0] & flag[2][0]);
    ans |= (flag[0][1] & flag[1][1] & flag[2][1]);
    ans |= (flag[0][2] & flag[1][2] & flag[2][2]);
    ans |= (flag[0][0] & flag[1][1] & flag[2][2]);
    ans |= (flag[2][0] & flag[1][1] & flag[0][2]);
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int ch(int n) {
	return (n * (n - 1)) / 2;
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << ch(n) + ch(m);
	return 0;
}


Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
   "strings"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
	n := nextString()
	m := nextString()
	mLength := len(m)
	result := "No"
	if strings.Contains(n, m) {
		result = "Yes"
	} else {
      for i := 1; i < mLength; i++ {
        mPrefix := m[:i]
        mSuffix := m[i:]
          if strings.HasPrefix(n, mSuffix) && strings.HasSuffix(n, mPrefix) {
		    result = "Yes"
		    break
          }

      }
    }

	fmt.Println(result)
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;

int main(){
    ll a,b;
    cin>>a>>b;
    if(a>b){
        ll tmp = a;
        a = b;
        b = tmp;
    }
    if((b-a)%2==1){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    ll tmp = (b-a)/2;
    ll ans = b - tmp;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N, K; cin >> N >> K; 
	long long ans = 0; 
	long long P = 1000000007; 
	for(long long i = K; i <= N+1; i++){
		ans += i * (N - i + 1) + 1; ans %= P; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3632
h,w = map(int, input().split())
S = ['.' + input() + '.' for _ in range(h)]
S.insert(0,'.'*(w+2))
S.append('.'*(w+2))

for r in range(1, h+1):
    for c in range(1, w+1):
        if S[r][c] == '.':
            count = 0
            count += S[r-1][c-1:c+2].count('#')
            count += S[r][c-1:c+2].count('#')
            count += S[r+1][c-1:c+2].count('#')
            print(count, end='')
        else:
            print('#', end='')
    print()


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

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

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
bool is_runrun(ll x){
  ll num=x%10;
  x/=10;
  while(x>0){
    if(abs(x%10-num)>1)return false;
    num=x%10;
    x/=10;
  }
  return true;
}
ll nketame(ll x,ll n){
  ll tmp=1;
  REP(n){
    tmp*=10;
  }
  return (x/tmp)%10;
}
ll next(ll prev){
  ll n=0,tmp=1;
  while(true){
    ll cur=nketame(prev,n);
    if(cur!=9){
      prev+=tmp;
      prev=prev/tmp*tmp;
      ++cur;
      for(ll i=tmp/10;i>0;i/=10){
        cur=(cur>0?cur-1:0);
        prev+=cur*i;
      }
      if(is_runrun(prev)){
        return prev;
      }
    }
    tmp*=10;
    ++n;
  }
}
void solve(long long K){
  ll now=0;
  REP(K){
    now=next(now);
  }
  cout<<now<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 505;

int n;
ll k;
ll a[MAX_N];
ll b[MAX_N];

bool check(ll x)
{
	for (int i = 0; i < n; i++)
	{
		b[i] = a[i] % x;
		if (b[i] < 0)
			b[i] += x;
	}
	sort(b, b + n);

	ll res = 0;
	for (int i = 0, j = n - 1; i <= j; i++)
	{
		ll y = b[i];
		res += y;
		b[i] = 0;

		while (true)
		{
			if (y < x - b[j])
			{
				b[j] += y;
				break;
			}
			else
			{
				y -= (x - b[j]);
				b[j] = 0;
				j--;
			}
		}
	}
	return res <= k;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	ll sum = 0, res = -1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		if (i == 0)
			res = a[i];
		else
			res = __gcd(res, a[i]);
	}

	for (ll i = 1; i * i <= sum; i++)
		if (sum % i == 0)
		{
			if (i > res && check(i))
				res = i;
			ll j = sum / i;
			if (j != i && j > res && check(j))
				res = j;
		}
	cout << res << endl;
}

Measured memory_bytes: 256
from collections import deque
queue = deque(input())
q = int(input())
li = [list(input().split()) for _ in range(q)]

flag = 1
for i in range(q):
    if int(li[i][0]) == 1:
        flag *= -1
        continue

    if int(li[i][1]) == 1:
        if flag == 1:
            queue.appendleft(li[i][2])
        else:
            queue.append(li[i][2])
    else:
        if flag == 1:
            queue.append(li[i][2])
        else:
            queue.appendleft(li[i][2])

if flag == 1:
    print("".join(queue))
else:
    ans = list(queue)
    print("".join(ans[::-1]))


Measured memory_bytes: 36724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int[] li = new int[s.length];
        for(int i = 0; i < s.length; i++){
            li[i] = Character.getNumericValue(s[i]);
        }
        for(int i = 0; i < 2; i++){
            int tmp1 = i == 0 ? li[0] + li[1] : li[0] - li[1];
            for(int j = 0; j < 2; j++){
                int tmp2 = j == 0 ? tmp1 + li[2] : tmp1 - li[2];
                for(int k = 0; k < 2; k++){
                    int chk = k == 0 ? tmp2 + li[3] : tmp2 - li[3];
                    if(chk == 7){
                        String op1 = i == 0 ? "+" : "-";
                        String op2 = j == 0 ? "+" : "-";
                        String op3 = k == 0 ? "+" : "-";
                        System.out.println(li[0] + op1 + li[1] + op2 + li[2] + op3 + li[3] +  "=7");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 23508
#include <stdio.h>

int main() {
    int a[3], b[3], table[4][4] = {0}, cnt[4] = {0}, even[2] = {0};
    for (int i = 0; i < 3; i++) {
        if (scanf("%d %d%*c", &a[i], &b[i]) == -1) return -1;
        table[a[i]-1][b[i]-1] = 1;
        table[b[i]-1][a[i]-1] = 1;
    }
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            if (table[i][j] == 1) cnt[i]++;
    for (int i = 0; i < 4; i++) {
        if (cnt[i] % 2 == 0) even[0]++;
        else even[1]++;
    }
    
    if (even[0] == 4 || (even[1] == 2 && even[0] == 2)) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
from sys import setrecursionlimit
setrecursionlimit(10**8)
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def roots(self):  # すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i == x]

N,M = map(int,input().split())
uf = UnionFind(N+1)
for i in range(M):
    a,b = map(int,input().split())
    uf.unite(a,b)
ans = len(uf.roots())-2
print(ans)
    







    







Measured memory_bytes: 76500
#include <bits/stdc++.h>
 
using namespace std;
 
struct Trie{
  bool l;
  Trie *next[4];
 
  Trie(){
    l = false;
    fill(next,next+4,(Trie *)0);
  }
 
  int c(char ch){
    if(ch == 'A'){ return 0; }
    if(ch == 'C'){ return 1; }
    if(ch == 'G'){ return 2; }
    if(ch == 'T'){ return 3; }
    return -1;
  }
 
  void insert(char *s){
    Trie *t = this;
    for(int i = 0 ; i < (int)strlen(s) ; i++){
      int v = c(s[i]);
      if(!t->next[v]){
        t->next[v] = new Trie;
      }
      t = t->next[v];
    }
    t->l = true;
  }
 
  bool find(char *s){
    Trie *t = this;
    for(int i = 0 ; i < (int)strlen(s) ; i++){
      int v = c(s[i]);
      if(!t->next[v]){ return false; }
      t = t->next[v];
    }
    return t->l;
  }
};

int main(){
  int N;
  char c[7],str[13];
  Trie t;
  scanf("%d",&N);
  while(N--){
    scanf("%s%s",c,str);
    if(strcmp(c,"find") == 0){
      printf("%s\n",t.find(str) ? "yes" : "no");
    }else{
      t.insert(str);
    }
  }
  return 0;
}

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

using namespace std;

int main()

{

    char instr[100]={0};
	int n;
	cin>>n;
    int  c;

    
	cin>>c;
    cin>>instr;

	
    for(int i=0;i<strlen(instr);i++)
	{
	
         if(i+1==c)
	{
	
            instr[i]+=32;
            break;
}
}	

	cout<<instr<<endl;
  

    return 0;

 
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
h,w=map(int,input().split())
A=[[False]*(w+2) for _ in range(h+2)]
chk,chk2=[],[]
for i in range(h):
  s=input()
  for j in range(w):
    A[i+1][j+1]=(s[j]==".")
    if s[j]=="#":
      chk.append((i+1,j+1))
ans=0
d=((1,0),(0,1),(-1,0),(0,-1))
while chk:
  for cx,cy in chk:
    for dx, dy in d:
      if A[cx+dx][cy+dy]==True:
        chk2.append((cx+dx,cy+dy))
        A[cx+dx][cy+dy]=False
  if chk2:
    ans+=1
  chk=chk2
  chk2=[]
print(ans)

Measured memory_bytes: 105084
keylist = [
   [],
   ['.', ',', '!', '?', ' '],
   ['a', 'b', 'c'],
   ['d', 'e', 'f'],
   ['g', 'h', 'i'],
   ['j', 'k', 'l'],
   ['m', 'n', 'o'],
   ['p', 'q', 'r', 's'],
   ['t', 'u', 'v'],
   ['w', 'x', 'y', 'z']
]
for i in range(int(input())):
   output = ''
   for item in input().split('0'):
      if item == '':
         continue
      output += keylist[int(item[0])][len(item) % len(keylist[int(item[0])]) - 1]
   print(output)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    vec<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(i == a[a[i]])
        {
            ans++;
        }
    }
    ans /= 2;
    cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main()
{
	bool card[100001],white;
	int n,k,in,repos,cnt,maxcnt;

	cin >> n >> k;

	while(n && k){
		for(int i = 0; i <= n; i++){
			card[i] = false;
		}

		for(int i = 0; i < k; i++){
			cin >> in;
			card[in] = true;
		}

		white = card[0];
		cnt = 0; maxcnt = 0;
		for(int i = 1; i <= n; i++){
			if(card[i]){
				cnt++;
			}
			else if(!card[i] && white){
				repos = i;
				cnt++;
				white = false;
			}
			else{
				maxcnt = max(maxcnt,cnt);
				cnt = 0;
				white = card[0];
				if(white){
					i = repos;
				}
			}
		}
		maxcnt = max(maxcnt,cnt);

		cout << maxcnt << endl;

		cin >> n >> k;
	}
	return 0;
}

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

int main(){
  string A;
  cin >> A;
  for(int i=0;i<A.size();i++){
    A.at(i)='x';
  }
  cout<<A<<endl;
}
 
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string.h>

using namespace std;

using ll = long long;

int N, A[200005], S[200005];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  int res = 0;
  for (int i = 1; i <= N; i++) {
    if (S[A[i] - 1]) {
      S[A[i]] = S[A[i] - 1] + 1;
    } else {
      S[A[i]] = 1;
    }
    res = max(res, S[A[i]]);
  }
  printf("%d\n", N - res);
  return 0;
}


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

int main(){
    int X,Y; cin >> X >> Y;
    int ans=0;
    
    if(X==1) ans+=300000;
    if(X==2) ans+=200000;
    if(X==3) ans+=100000;
    if(Y==1) ans+=300000;
    if(Y==2) ans+=200000;
    if(Y==3) ans+=100000;
    
    if(X==1 && Y==1) ans+=400000;
    cout << ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007

ll a,p;


int main(){
  cin >> a >> p;
  cout << (3*a+p)/2 << endl;
}


Measured memory_bytes: 256
q=int(input())
l=[0]*q;r=[0]*q
for i in range(q):
  l[i],r[i]=map(int,input().split())

def eratosthenes(n):
  a=[i for i in range(2,n+1)]
  prime=[]
  while True:
    p=min(a)
    if p**2>n:
      break
    prime.append(p)
    i=0
    while i<len(a):
      if a[i]%p==0:
        a.pop(i)
        continue
      i+=1
  for i in a:
    prime.append(i)
  return prime

ans=[0]*(10**5+1)
flag=[0]*(10**5+1)
for i in eratosthenes(10**5):
  flag[i]=1
cnt=0
for i in range(1,10**5+1):
  if flag[i]==1 and flag[(i+1)//2]==1:
    cnt+=1
  ans[i]=cnt
for i in range(q):
  print(ans[r[i]]-ans[l[i]-1])

Measured memory_bytes: 16560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	int s[100];
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s, s + n);
	if (sum % 10 == 0) {
		for (int i = 0; i < n; i++) {
			if ((sum - s[i]) % 10 != 0) {
				cout << sum - s[i] << endl;
				return 0;
			}
		}
		sum = 0;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,n,k,data[10000];
	for(i=2;i<10000;i++){
		data[i]=1;
	}
	for(i=2;i*i<10000;i++){
		if(data[i]==1){
			for(k=i*i;k<=10000;k+=i){
				data[k]=0;
			}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=n;n>=3;i--){
			if(data[i]==1&&data[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 636
import sys

x, n = map(int, input().split())
pn = list(map(int, sys.stdin.readline().rstrip().split()))

if x not in pn:
    print(x)
    exit(0)

for i in range(1,100):
    if x-i not in pn:
        print(x-i)
        exit(0)
    elif x+i not in pn:
        print(x + i)
        exit(0)

Measured memory_bytes: 9136
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

list<int> adjList[N];
vector<int> vis(N);

int dfs(int nd) {
	vis[nd] = true;

	int ans = 1;

	for (int &i : adjList[nd]) {
		if (!vis[i]) ans += dfs(i);
	}

	return ans;
}

void solve() {
	int n; cin >> n;
	int m; cin >> m;

	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		adjList[a].pb(b);
		adjList[b].pb(a);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!vis[i])
			ans = max(ans, dfs(i));
	}

	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 28272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double p = 100000;
		int n = s.nextInt();
		for(int i = 0; i < n; ++i) {
			p *= 1.05;
			p = Math.ceil(p / 1000) * 1000;
		}
		System.out.println((int)p);
	}
}

Measured memory_bytes: 17164
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector< vector<int> > A(2,vector<int>(N));
	for(int i=0;i<2;++i){
		for(int j=0;j<N;++j){
			cin >> A[i][j];
		}
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		int res = 0;
		for(int ue=0;ue<=i;++ue){
			res += A[0][ue];
		}
		for(int sita=i;sita<N;++sita){
			res += A[1][sita];
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int T[5];
  int max=10,max1;
  rep(i, 5){
    cin >> T[i];
    if(max>T[i]%10&&T[i]%10!=0){
    max=T[i]%10;
      max1=i;
    }
  }
  rep(i, 5){
  if(max1!=i&&T[i]%10!=0){
  T[i]+=10-T[i]%10;
  }
  }
  int ans=0;
  rep(i, 5){
  ans+=T[i];
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 0; i < n; i++) {
      BigInteger bi = sc.nextBigInteger().add(sc.nextBigInteger());
      System.out.println(bi.toString().length() > 80 ? "overflow" : bi.toString());
    }
  }
}

Measured memory_bytes: 12000
# a - b < c
# b - a < c
# a + b > c

import bisect

n = int(input())

l = sorted([int(li) for li in input().split()])
#print(l)

ret = 0

for i in reversed(range(0, n)):
  for j in reversed(range(0, i)):
    k = bisect.bisect_left(l, l[i] + l[j])
    k = n - k
    ret += (n - 1 - i) - k

print(ret)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

static const double PI = 3.141592653589793238;


int main(){
  double a, b, x;
  cin >> a >> b >> x;
  if(x == a*a*b){
    cout << 0 << endl;
    return 0;
  }

  if (2*x == a*a*b){
    cout << 45 << endl;
    return 0;
  }

  if(2*x < a*a*b){
    //x < a*a*b*1/2 (半分以下のとき)
    double y = 2*x/(a*b);
    //double th = arctan(y/b);
    //y/b = 2*x/a
    double th_rad = 2*x/(a*b*b);
    //cout << th_rad << endl;
    double th = atan(th_rad);
    //cout << th << endl;
    cout << setprecision(12) <<90-th*180.0/PI<< endl;
    return 0;
  }

  //x > a*a*b*1/2 (半分以下のとき)
  if(2*x > a*a*b){
    x -= a*a*b;
    //double y = 2*x/(a*a);
    //double th_rad = arctan(a/y);
    double th_rad = (a*a*a)/(2*x);
    //double th_rad = (2*x)/(a*a*a);

    double th = atan(th_rad);
    //cout << th << endl;
    cout << setprecision(12) <<90+th*180.0/PI<< endl;
    return 0;
}



  return 0;

}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    double t,x;cin>>t>>x;
    cout<<fixed<<setprecision(20)<<t/x<<endl;
}

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

static const size_t n_max = 40;
static int A[n_max], B[n_max], C[n_max], c;

void rec(size_t l, size_t i, size_t j) {
  switch (l) {
    case 0:
      break;
    case 1:
      C[c++] = A[i];
      break;
    default:
      // locate the root of this subtree
      size_t k = std::find(B + j, B + j + l, A[i]) - (B + j);
      rec(k, i + 1, j);
      rec(l - k - 1, i + k + 1, j + k + 1);
      C[c++] = A[i];
      break;
  }
}

int main() {
  size_t n;
  scanf("%zu\n", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%d", A + i);
  for (size_t i = 0; i < n; i++)
    scanf("%d", B + i);
  rec(n, 0, 0);
  for (size_t i = 0; i < n - 1; i++)
    printf("%d ", C[i]);
  printf("%d\n", C[n-1]);
  return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
double a[10001];
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
int main() {
  __fastio;
  int n; cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  double sum = 0.0;
  for(int i=0; i<n; i++) {
    sum += (double)(1/a[i]);
  }
  cout << setprecision(9) << (1/sum) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer num[] = new Integer[N];
        int alice = 0;
        int bob = 0;
        for(int i=0;i<N;i++){num[i]=sc.nextInt();}
        Arrays.sort(num);
        for(int i=N-1;i!=-1;i--){
            if(i%2==0){alice+=num[i];}
            else{bob+=num[i];}
        }
        System.out.println(Math.abs(alice-bob));
    }
}

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

int main(){
    int k,t; cin >> k >> t;
    int a[t], ma = INT_MIN;
    for(int i = 0; i < t; i++){
        cin >> a[i];
        ma = max(ma, a[i]);
    }
    cout << max(ma -1 - (k-ma), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
nm = list(map(int, input().split()))
ships = []
for i in range(nm[1]):
    ships.append(list(map(int, input().split())))

first = []
second = []

for i in ships:
    if(i[0] == 1):
        first.append(i[1])
    if(i[1] == nm[0]):
        second.append(i[0])

if(len(set(first) & set(second)) > 0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 61116
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int aBuf = 0;
		int bBuf = 0;
		boolean[] bool_1 = new boolean[n];
		boolean[] bool_n = new boolean[n];
		for(int i=0; i < n; i++) {
			bool_1[i] = false;
			bool_n[i] = false;
		}
		for(int i=0; i < m; i++) {
			aBuf = sc.nextInt();
			bBuf = sc.nextInt();
			if(aBuf==1) bool_1[bBuf] = true;
			else if(bBuf==n) bool_n[aBuf] = true;
		}
		int possible = 0;
		for(int i=0; i < n; i++) {
			if(bool_1[i] && bool_n[i]) possible = 1;
		}
		if(possible==1) System.out.println("POSSIBLE");
		else System.out.println("IMPOSSIBLE");
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }
    int ans = 0;
    rep(i, n) {
        if (d.same(0, i)) continue;
        d.merge(0, i);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    
    int dp1[n],dp2[n],dp3[n];
    dp1[0]=a[0];
    dp2[0]=b[0];
    dp3[0]=c[0];
    int dp[n];
    dp[0]=max(a[0],max(b[0],c[0]));
    for(int i=1;i<n;i++)
    {
        dp1[i]=max(dp2[i-1],dp3[i-1])+a[i];
        dp2[i]=max(dp1[i-1],dp3[i-1])+b[i];
        dp3[i]=max(dp1[i-1],dp2[i-1])+c[i];
    }
    int ans=max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
    cout<<ans;
    
    
	return 0;
}


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

#define int long long

vector<pair<int, int> > graph[100010];
bool visited[100010] = {};
int dist[100010];
int n, m;

bool dfs(int i, int cost){
    if(visited[i]){
        return dist[i] == cost;
    }

    visited[i] = true;
    dist[i] = cost;

    for(int j = 0;j < graph[i].size();j++){
        if(!dfs(graph[i][j].first, cost + graph[i][j].second)){
            return false;
        }
    }

    return true;
}

signed main(){
    cin >> n >> m;

    int l, r, d;
    for(int i = 0;i < m;i++){
        cin >> l >> r >> d;
        l--;
        r--;
        graph[l].push_back(make_pair(r, d));
        graph[r].push_back(make_pair(l, -d));
    }

    for(int i = 0;i < n;i++){
        if(!visited[i]){
            if(!dfs(i, 0)){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 16512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	long long int N;
	long long int a,b; 
	while( scanf("%lld",&N) != EOF )
	{
		a=sqrt(N);
		b=a*a;
		printf("%lld\n",b);
	}
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val K = readInt()

    val que = ArrayDeque<Long>()
    que.addAll((1L..9L).toList())
    var t = 0
    while (true) {
        t++
        val q = que.pop()
        if (t == K) {
            println(q)
            return
        }
        val run = q % 10
        if (run > 0) que.add(10 * q + run - 1)
        que.add(10 * q + run)
        if (run < 9) que.add(10 * q + run + 1)
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

ll N, M;

ll gcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

int main() {

    cin >> N >> M;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        if(t % 2 == 1){
            cout << 0 << endl;
            return 0;
        }
        vec.push_back(t);
    }

    sort(vec.begin(), vec.end());
    
    vector<ll > B;

    for(ll i = 0; i < N; i++){
        B.push_back(vec[i] / 2);
    }

    ll LCM = 0;
    for(ll i = 0; i < N; i++){
        if(i == 0){
            LCM = B[i];
            continue;
        }
        LCM = lcm(LCM, B[i]);
        //Mを超えたらそもそも成り立たないしオーバーフローの可能性あるので
        //LCMは0で答えも0
        if(LCM > M){
            LCM = 0;
            break;
        }
        //cout << LCM << endl;
    }    

    //cout << LCM << endl;

    if(LCM == 0){
        cout << 0 << endl;
    }else{

        for(ll i = 0; i < N; i++){
            if(LCM / B[i] % 2 == 0){
                cout << 0 << endl;
                return 0;
            }
        }

        //奇数倍のみが答えを満たす
        ll kisu = M / LCM;
        //偶数倍の個数は奇数倍から引いておく
        ll gusu = M / (LCM * 2);

        if(kisu - gusu < 0){
            cout << 0 << endl;
        }else{
            cout << kisu - gusu << endl;
        }
        
        
    }
}

Measured memory_bytes: 2548