akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  int n;
  string s;
  cin >> n >> s;
  bool f = true;
  int h = n /2;
  if(n % 2 != 0) f = false;
  for(int i = 0; i < h; i++){
    if(s[i] != s[i+h]) f = false;
  }
  if(f) pri("Yes");
  else pri("No");
  return 0;
}







Measured memory_bytes: 256
N = int(input())  # 1行目のNを取得する
s = list(map(int, input().split()))  # 複数行の数値の入力を取得
count = 0
tmpListLen = len(s)
halfList = list(filter(lambda x: x % 2 == 0, s))  # 値が偶数のものだけにフィルター

while tmpListLen == len(halfList):
    count += 1
    halfList = map(lambda x: x / 2, halfList)
    halfList = list(filter(lambda x: x % 2 == 0, halfList))
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
   long long int a,b,rem,n,m,x;
    scanf("%lld%lld",&a,&b);
    n=a;
    m=b;
    while(m!=0)
    {
        rem = n%m;
        n = m;
        m = rem;
    }
    x = (a*b)/n;
    printf("%lld\n",x);
}


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

int main() {
    int N,x;
    cin >> N >>x;
    int a[N];
    rep(i,N){
        cin >> a[i];
    }
    sort(a,a+N);
    int sum=0;
    int ans=0;
    rep(i,N){
        sum+=a[i];
        if(x<sum){
            ans=i;
            break;
        }
        else{
            ans=i+1;
        }
    }
    if(x>sum) ans=N-1;
    cout << ans << endl;
}

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

int main() {
  int n;cin>>n;
  vector<int> w(n);
  int cnt=0;
  rep(i,n){
    cin>>w[i];
    cnt+=w[i];
  }
  int l=0,ans=1e9;
  rep(i,n-1){
    l+=w[i];
    int r=cnt-l;
    ans=min(ans,abs(l-r));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
ld r;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>r;
	cout<<fixed<<setprecision(10)<<2*acos(-1)*r<<endl;
	return 0;
}


Measured memory_bytes: 3808
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

int main() {
    lli n, m;
    scanf("%lld%lld", &n, &m);
    if (n == 1 && m == 1) puts("1");
    else if (n == 1 || m == 1) printf("%lld\n", n + m - 3);
    else printf("%lld\n", (n - 2) * (m - 2));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAXN 200010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
    ios_base::sync_with_stdio(false);
    int n, x, pos = 0, pulo, ans = -1;

    cin >> n >> x;

    for (int i=1; i<=n; i++){
        cin >> pulo;
        pos += pulo;
        if (pos > x){
            cout << i << endl;
            ans = i;
            break;
        }
    }

    if (ans == - 1){
        cout << n+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000, MAX_M = 200000;
int N, M;
int L[MAX_M], R[MAX_M], D[MAX_M];

                            
struct edge { int to, cost; };
const int MAX_V = MAX_N+1, INF = 10000010;


vector<edge> G[MAX_V];
ll d[MAX_V];

void rec(int v) {
  for (int i = 0; i < G[v].size(); ++i) {
    edge e = G[v][i];
    if (d[e.to] < INFLL) continue;
    d[e.to] = d[v] + e.cost;
    rec(e.to);
  }
}

int main() {
  cin >> N >> M;
  rep(i, M) cin >> L[i] >> R[i] >> D[i];

  rep(i, M) {
    G[L[i]].push_back((edge){R[i], D[i]});
    G[R[i]].push_back((edge){L[i], -D[i]});
  }

  fill(d, d+N+1, INFLL);
  for (int i = 1; i <= N; ++i) {
    if (d[i] == INFLL) {
      d[i] = 0; rec(i);
    }
  }

  rep(i, M) {
    if (d[R[i]]-d[L[i]] != D[i]) {
      cout << "No" << endl; return 0;
    }
  }

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


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

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            count++;
        }
    }
    cout << count << endl;

}


Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    ll n;
    ll sum = 0;
    cin >> n;
    vector<int> a(n);
    for (ll i = 0; i < n; i++) {
        a[i] = i+1;   
    }
    for (ll i = 0; i < n; i++) {
        if (a.at(i) % 3 == 0 || a.at(i) % 5 == 0) continue;
        else sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 7216
<?php
fscanf(STDIN, "%d", $first);

$checkList[$first] = 0;
$new = $first;
while(true)
{
  $new = calc($new);
  if( isset($checkList[$new]) )
  {
    echo count($checkList)+1;
    break;
  }
  
  $checkList[$new] = 0;
}

function calc( $num )
{
  if( $num%2 == 0 ) { return $num/2; }
  
  return 3*$num+1;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    vector<string> w(n);
    set<string> s;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        s.insert(w[i]);
    }
    bool flag = true;
    if (s.size() < n) flag = false;
    for (int i = 1; i < n; i++) {
        int l = w[i - 1].size();
        if (w[i - 1][l - 1] != w[i][0]) {
            flag = false;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 410000;

int n,m;
char str[maxn];
char s[maxn];
int pos[maxn];

int main()
{
	scanf("%s",str); n=strlen(str);
	m=0; for(int i=0;i<n;i++) if(str[i]!='x') pos[m]=i,s[m++]=str[i];
	if(!m) return puts("0"),0;
	
	for(int i=0;i<m;i++) if(s[i]!=s[m-i-1]) return puts("-1"),0;
	int ans=0;
	int lai=0,laj=n-1,j=m-1;
	for(int i=0;i<=j;i++,j--)
	{
		int x=pos[i]-lai,y=laj-pos[j];
		if(x!=y) ans+=abs(x-y);
		lai=pos[i],laj=pos[j];
	}
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(){
  int trainNum, trainStock[100], trainCout=0;
  while(scanf("%d", &trainNum) != EOF){
    if(trainNum != 0){
      trainStock[trainCout] = trainNum;
      trainCout += 1;
    }else{
      printf("%d\n", trainStock[trainCout-1]);
      trainStock[trainCout-1] = 0;
      trainCout -= 1;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 1 << 16;
const int LOGN = 19;

int n, m, k;
int a[50];

void solve(int test)
{
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> c;
  int64 ans = 0;
  for (int i = 0; i <= min(n, k); ++i) {
    for (int l = 0; l <= i; ++l) {
      int r = i - l;
      priority_queue<int, vector<int>, greater<int>> q(greater<int>(), c);
      for (int j = 0; j < l; ++j) {
        q.push(a[j]);
      }
      for (int j = 0; j < r; ++j) {
        q.push(a[n - 1 - j]);
      }
      for (int j = 0; j < k - i && !q.empty() && q.top() < 0; ++j) {
        q.pop();
      }
      int64 mx = 0;
      while (!q.empty()) {
        mx += q.top();
        q.pop();
      }
      ans = max(ans, mx);
    }
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
    
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }

  int count_max = 0;
  int count = 0;
  
  
  for(int i = 0; i < N-1; i++){
    if (H.at(i) >= H.at(i+1)){
      // cout<< H.at(i) << ">=" << H.at(i+1) << endl;
      count +=1;
      // cout<< count << endl;
      if (count > count_max){
        count_max = count;
        // cout<< "max; " << count_max << endl;
      }
    }
    else{
      //cout<< H.at(i) << "<" << H.at(i+1) << endl;
      if (count > count_max){
        count_max = count;
        // cout<< "max; " << count_max << endl;
      }
      count = 0;
      // cout<< count << endl;
    }
  }  
  
cout << count_max << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    ll k;cin>>k;
    for(ll i=0;i<min((ll)s.size(),k);i++)if(s[i]>='2')return cout<<s[i] , 0;
    cout<<"1";
}





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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

string s;

void init()
{
	cin >> s;
}

void solve()
{
	char ans[2] = {'1', '9'};
	rep(i, 3) cout << ans[s[i] == '1'];
	cout << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			long[] sum = new long[n + 1];
			sum[0] = 0L;
			Map<Long, Long> map = new HashMap<>();
			map.put(0L, 1L);
			IntStream.rangeClosed(1, n).forEach(i -> {
				sum[i] = (sum[i - 1] + scanner.nextLong()) % m;
				map.put(sum[i], map.getOrDefault(sum[i], 0L) + 1L);
			});
			System.out.println(
					map.entrySet().stream().mapToLong(entry -> entry.getValue() * (entry.getValue() - 1) / 2).sum());
		}
	}
}


Measured memory_bytes: 63028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = int.Parse(s.Split(' ')[i]);
        }

        //カウンタ
        int counter = 0;

        //検証
        for (int i = 0; i < N; i++) {
            //未ソートの部分の中での最小値インデックス
            int minI = i;

            for (int j = i; j < N; j++) {
                if (A[j] < A[minI]) {
                    minI = j;
                }

            }
            //交換
            if (minI != i) {
                counter++;
            }
            int temp = A[i];
            A[i] = A[minI];
            A[minI] = temp;



        }

        Console.WriteLine(string.Join(" ", A));
        Console.WriteLine(counter);

    }
}


Measured memory_bytes: 17992
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){
    double a,b,t;
    cin >> a >> b >> t;

    cout << b*floor(t/a) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    char a[n][n];
    for(int i=0;i<n;i++)cin >> a[i];
    char b[m][m];
    for(int i=0;i<m;i++)cin >> b[i];

    bool flg = false;
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            if(a[i][j]==b[0][0]){
                flg = true;
                for(int k=0;k<m;k++){
                    for(int l=0;l<m;l++){
                        if(a[i+k][j+l]!=b[k][l]){
                            flg = false;
                            break;
                        }
                    }
                }
            }
            if(flg){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}


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

int main() {
    int n, k; cin >> n >> k;

    if(n%k==0) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n-1) {
        if (a[i] == i +1) {
            int tmp = a[i];
            a[i] = a[i+1];
            a[i+1] = tmp;
            ans++;
        }
    }
        if (a[n-1] == n) {
            int tmp = a[n-1];
            a[n-1] = a[0];
            a[0] = tmp;
            ans++;
        }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int k;
int cnt = 0;
ll dfs(int num, ll b = -1) {
    if (num == 0) {
        ++cnt;
        return b;
    }
    if (b == -1) {
        reps(i, 9) {
            auto val = dfs(num - 1, i);
            if (cnt == k) return val;
        }
    }
    else {
        ll c = b % 10;
        ll val = 0;
        if (c > 0) val = dfs(num - 1, 10 * b + c - 1);
        if (cnt == k) return val;
        val = dfs(num - 1, 10 * b + c);
        if (cnt == k) return val;
        if (c < 9) val = dfs(num - 1, 10 * b + c + 1);
        if (cnt == k) return val;
    }
    return b;
}

void solve() {
    cin >> k;
    int idx = 1;
    ll ans = 0;
    while (cnt != k) { ans = dfs(idx); ++idx; }
    cout << ans << endl;
}

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


Measured memory_bytes: 384
def solve(n, s):
    i = 0
    v_or_h = []
    cmb = 1
    while i < n:
        # a
        # a
        if s[0][i] == s[1][i]:
            v_or_h.append('v')
            i += 1
        # aa
        else:
            v_or_h.append('h')
            i += 2

    length = len(v_or_h)

    for j in range(length):
        if v_or_h[j] == 'v':
            if j == 0:
                cmb *= 3
            else:
                if v_or_h[j-1] == 'v':
                    cmb *= 2
                else:
                    pass
        else:
            if j == 0:
                cmb *= 6
            else:
                if v_or_h[j-1] == 'v':
                    cmb *= 2
                else:
                    cmb *= 3

    return cmb % 1000000007


if __name__ == '__main__':
    n = int(input())
    s = []
    for _ in range(2):
        s.append(input())
    print(solve(n, s))


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

template <typename T>
class Fenwick {
public:
    vector<T> Fenw;
    int n;

    Fenwick(int _n) : n(_n) {
        Fenw.resize(n);
    }

    void modify(int x, T v) {
        while (x < n) {
            Fenw[x] += v;
            x |= (x + 1);
        }
    }

    T get(int x) {
        T v{};
        while (x >= 0) {
            v += Fenw[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<Fenwick<int>> cnt(26, Fenwick<int>(n + 1));
    for (int i = 0; i < n; ++i) {
        cnt[s[i] - 'a'].modify(i + 1, 1);
    }
    while (q--) {
        int typ;
        cin >> typ;
        if (typ == 1) {
            int i;
            char c;
            cin >> i >> c;
            cnt[s[i - 1] - 'a'].modify(i, -1);
            s[i - 1] = c;
            cnt[s[i - 1] - 'a'].modify(i, 1);
        } else {
            int l, r;
            cin >> l >> r;
            int total = 0;
            for (auto &f : cnt) {
                total += (f.get(r) - f.get(l - 1) > 0);
            }
            cout << total << "\n";
        }
    }
    return 0;
}



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

int main(){
    int N,ans=0;
    string A,B,C;
    cin >> N >> A >> B >> C;

    if(A == B && A == C){
        ans = 0;
    }else{
        for(int i = 0;i < N;i++){
            if(A.at(i) == B.at(i) && A.at(i) != C.at(i)){
                C.at(i) = A.at(i);
                ans++;
            }
            else if(A.at(i) != B.at(i) && A.at(i) == C.at(i)){
                B.at(i) = A.at(i);
                ans++;
            }
            else if(B.at(i) == C.at(i) && A.at(i) != C.at(i)){
                A.at(i) = B.at(i);
                ans++;
            }else if(A.at(i) == B.at(i) && A.at(i) == C.at(i)){
                continue;
            }
            else{
                B.at(i) = A.at(i);
                ans++;
                C.at(i) = A.at(i);
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
   while(1){
       int m, f, r;
       cin>>m>>f>>r;
       if(m == -1 && f == -1 && r == -1) break;
      
       string gread;
       if(m == -1 || f ==-1) gread ="F";
       else if(m+f >= 80) gread ="A";
       else if(m+f >=65 ) gread = "B"; 
       else if(m+f >=50)  gread = "C";
       else if(r >= 50) gread = "C";
       else if(m+f >=30) gread = "D";
       else gread = "F";
    
    cout<<gread<<endl;
   }
    return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long a,b;
int k;
int main()
{
    scanf("%lld%lld%d",&a,&b,&k);
    for(int i=0;i<k;i++)
    {
        if(i%2==0)
        {
            if(a%2!=0) a--;
            a=a/2;
            b=b+a;
        }
        else
        {
            if(b%2!=0) b--;
            b=b/2;
            a=a+b;
        }
    }
    printf("%lld %lld\n",a,b);
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    vector<int> a(n);
    inc(i, 0, n) cin >> a[i];
    if(k == 2){
        cout << n-1 << endl;
    }else{
        if(n%(k-1) > 1){
            cout << n/(k-1)+1 << endl;
        }else{
            cout << n/(k-1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

void printArray(int var[], int num) {
    int i;
    for (i = 0; i < num; i++) {
        if (i > 0) printf(" ");
        printf("%d", var[i]);
    }
    printf("\n");
}

void insertionSort(int var[], int num) {
    int i, j, v;
    for (i = 1; i < num; i++) {
        v = var[i];
        j = i - 1;
        while(j >= 0 && v < var[j]) {
            var[j + 1] = var[j];
            var[j] = v;
            j--;
        }
        printArray(var, num);
    }
}

int main(void) {
    int num, i, j;
    
    scanf("%d", &num);
    int var[num];
    for (i = 0; i < num; i++) scanf("%d", &var[i]);

    printArray(var, num);
    insertionSort(var, num);
}


Measured memory_bytes: 2676
import re
s=input().replace("?",".")
t=input()
for i in range(len(s)-len(t),-1,-1):
    if re.match(s[i:i+len(t)],t):
        s=s.replace(".","a")
        print(s[:i]+t+s[i+len(t):])
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 38544
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int a,b;
    char n;
    while(cin>>a>>n>>b){
        if(n=='+')cout<<a+b<<endl;
        if(n=='-')cout<<a-b<<endl;
        if(n=='*')cout<<a*b<<endl;
        if(n=='/')cout<<a/b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3076
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
from bisect import bisect_right
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    # B = [int()] * (M)  # type: "List[int]"
    # C = [int()] * (M)  # type: "List[int]"
    L = [[0, 0]for i in range(M)]
    for i in range(M):
        L[i][0] = int(next(tokens))
        L[i][1] = int(next(tokens))

    # write code
    A.sort()
    L.sort(key=lambda x: x[1], reverse=True)
    # print(L)
    index = [0]*M
    for i in range(M):
        index[i] = bisect_right(A, L[i][1] - 1)
    # print(index)
    changed = 0
    for i in range(M):
        if index[i] > changed:
            A[changed:min(index[i], changed + L[i][0])] = [L[i]
                                                           [1]]*(min(index[i], changed + L[i][0])-changed)
            changed = min(index[i], changed + L[i][0])
        else:
            continue
    # print(A)
    print(sum(A))


Measured memory_bytes: 31064
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long solve(long long n, long long x, long long m, long long k, vector<long long> &d){
    vector<long long> dd(d.size());
    for(int i=0; i<d.size(); i++) dd[i] = d[i] % m;

    long long a = 0;
    for(int i=0; i<k; i++){
        if(dd[i] != 0) continue;
        long long cnt = (n-1+(k-1-i))/k;
        a += cnt;
    }
    long long a1 = x;
    long long an = x;
    for(int i=0; i<k; i++){
        long long cnt = (n-1+(k-1-i))/k;
        an += cnt * dd[i];
    }
    long long b = an/m - a1/m;
    return n - 1 - a - b;
}

int main(){
    long long k, q;
    cin >> k >> q;
    vector<long long> d(k);
    REP(i, k) cin >> d[i];
    REP(i, q){
        long long n, x, m;
        cin >> n >> x >> m;
        cout << solve(n, x, m, k, d) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1010];
int main() {
    int n,k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int ans = 0;
    for (int i = 0; i < k; i++) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll modinv(ll a){
  ll b = mod,u = 1,v = 0,t;
  while(b){
    t = a/b;
    a -= t*b;swap(a,b);
    u -= t*v;swap(u,v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}
int main(){
  ll X,Y,l,i;scanf("%lld%lld",&X,&Y);
  if((X+Y)%3 != 0){
    printf("0\n");return 0;
  }
  l = (X+Y)/3;
  X -= l;Y -= l;
  if(X < 0 || Y < 0){
    printf("0\n");return 0;
  }
  ll B[X+Y+1];B[0] = B[1] = 1;
  for(i=2;i<=X+Y;i++) B[i] = B[i-1]*i%mod;
  printf("%lld\n",B[X+Y]*modinv(B[X])%mod*modinv(B[Y])%mod);
}

Measured memory_bytes: 8936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rItr(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define Itr(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define setp(n) fixed << setprecision(n)
#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define All(a) (a.begin()),(a.end())
#define rAll(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll h(n);
	ll m=0,ans=0;
	rep(i,n){
		cin>>h[i];
		m=max(m,h[i]);
	}
	rep(i,m){
		ll left=0, right;
		rep(j,n){
			if (h[j]==0){
				right=j-1;
				if (left<=right) ans++;
				left=j+1;
			}else{
				h[j]-=1;
			}
		}
		if (left<=n-1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int dp[1<<16];

int main(){
  int n;
  int t[16][17];
  int s;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      for(int j=0;j<=n;j++)cin >> t[i][j];
    }
    s = 1<<n;

    for(int i=0;i<s;i++)dp[i] = (1<<31) - 1;
    dp[0] = 0;

    for(int i=1;i<s;i++){
      for(int j=0;j<n;j++){
	if( (i>>j) & 1 ){
	  int tmp = t[j][0];
	  for(int k=0;k<n;k++){
	    if( j!=k && ((i>>k) & 1) )tmp = min(tmp,t[j][k+1]);
	  }
	  dp[i] = min(dp[i] , dp[i - (1<<j)] + tmp);
	}
      }
    }

    cout << dp[s - 1] << endl;
  }
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int t = 0;
  if(b < c || d < a) {
    t = 0;
  } else if(a <= c && b <= d) {
    t = b - c;
  } else if(a <= c && d <= b) {
    t = d - c;
  } else if(c <= a && b <= d) {
    t = b - a;
  } else if(c <= a && d <= b) {
    t = d - a;
  }
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;
 
    public static void main ( String [] args ) throws IOException
    {
    new Main().cal();
    }
 
  
    private void cal() throws IOException 
    {
    int N = Integer.parseInt(br.readLine());
    int [] nums = new int[N];
     
    for(int i = 0; i < N; i++)
        nums[i] = Integer.parseInt(br.readLine());
 
    int count = 0;
    for(int n : nums)
        if ( isPrime(n) ) count++;
 
    System.out.println(count);
 
    }
 
    private boolean isPrime(int n) {
    if ( n == 2 ) return true;
    else if ( n % 2 == 0 ) return false;
    else if ( n < 9 ) return true;
    else if ( n % 3 == 0 ) return false;
    else {
        for(int i = 5; i * i <= n; i+=6) {
        if ( n % i == 0 ) return false;
        else if ( n % (i+2) == 0 ) return false;
        }
        return true;
    }
 
 
    }
 
}

Measured memory_bytes: 29888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}


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

int main(void){
    int n;
    cin >> n;

    int a[n], max[2] = {0, 0};
    rep(i, n){
        cin >> a[i];
        if(a[i] >= max[0]){
            max[1] = max[0];
            max[0] = a[i];
        }else if(a[i] > max[1]){
            max[1] = a[i];
        }
    }

    rep(i, n){
        if(a[i] == max[0])
            cout << max[1] << endl;
        else
            cout << max[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned uint;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, int> pll;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 Rand(seed);
uniform_int_distribution<ll> range(0, 1ll << 32);
inline void ucin() {
   ios::sync_with_stdio(0); cin.tie(0);
}

const int N = 4e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
   int ans = 1;
   for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
      if(b & 1) ans = (ll) ans * a % mod;
   return ans;
}
int n, a[N];
int main() {
   scanf("%d", &n); int c = 0;
   rep(i, 1, n) {
      scanf("%d", a + i);
      if(i % 2 == 1 && a[i] % 2 == 1) {
         c ++;
      }
   }
   printf("%d\n", c);
   return 0;
} 


Measured memory_bytes: 3256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(input().split())
    return li

# --------------------------------------------

dp = None

def main():
    R = int(input())
    G = int(input())
    diff = G - R

    print(R+diff*2)

main()


Measured memory_bytes: 5056
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22056
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n;
    string s;
    int r = 0;
    int g = 0;
    int b = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        s.push_back(c);
        if (c == 'R') {
            r += 1;
        } else if (c == 'G') {
            g += 1;
        } else {
            b += 1;
        }
    }

    long ans = (long)r * g * b;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = j + j - i;
            if (!(k < (int)s.length())) continue;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans -= 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
using namespace std;

int main(){
    int a, b, c, cnt;
    scanf("%d %d %d\n", &a, &b, &c);
    if(a > b){
        cnt = 0;
    } else {
        if(a * c > b){
            cnt = b / a;
        } else {
            cnt = c;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

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

    cout << (k / 2) * ((k + 2 - 1) / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
INF=10**9+7
n=int(input())
s1=input()
s2=input()
ans=1
v=0
h=0
i=0
while i!=n:
    if v==0 and h==0:
        if s1[i]==s2[i]:
            ans=3
            v=1
            i=i+1
        else:
            ans=3*2
            h=1
            i=i+2
    elif v==1:
        if s1[i]==s2[i]:
            ans=(ans*2)%INF
            i=i+1
        else:
            ans=(ans*2)%INF
            v=0
            h=1
            i=i+2
    elif h==1:
        if s1[i]==s2[i]:
            v=1
            h=0
            i=i+1
        else:
            ans=(ans*3)%INF
            i=i+2
print(ans)


Measured memory_bytes: 38484
N = int(input())
sqn = int(N**0.5//1)
#print(sqn)
for n in range(sqn):
    sqt = sqn-n
    div = N/sqt
    if div%1 == 0:
        ans = sqt+N/sqt-2
        intans = int(ans)
        print(intans)
        exit()
    else:
        pass    
      

Measured memory_bytes: 3060
import java.util.Scanner;

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

		String S = scan.next();

		int sashihiki = 0;
		int n = S.length();
		int[] Srow = new int[n];
		String[] hugou = new String[n-1];

		for (int i = 0; i < n; i++) {
			Srow[i] = Integer.parseInt(S.substring(i, i+1));
		}

		for (int bit = 0; bit < Math.pow(2, n-1); bit++) {

			sashihiki = Srow[0];

			for (int shift = 0; shift < n-1; shift++) {		//全ビット探索：1が+に対応

				if ((1&bit>>shift) == 1) {
					sashihiki += Srow[shift+1];
					hugou[shift] = "+";
				} else {
					sashihiki -= Srow[shift+1];
					hugou[shift] = "-";
				}

			}

			if (sashihiki == 7) {
				break;
			}

		}


		if (sashihiki == 7) {

			for (int op = 0; op < n; op++) {
				System.out.print(Srow[op]);
				if (op < n-1) {
					System.out.print(hugou[op]);
				}
			}

			System.out.println("=7");

		} else {

			System.out.print("ないです");

		}

	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int H1,M1,H2,M2,K,t1,t2,t;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	t1 = H1*60+M1;
	t2 = H2*60+M2;

	// cout << t1 << " " << t2 << endl;
	// cout << (1440-t2)+t1 << endl;

	if(t2 >= t1)
		t = (int)(t2-t1);
	else
		t = (int)((1440-t1)+t2);

	cout << t-K << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<int> h(n + 1), ac(n + 1);
	for (int i = 0; i < n; i++) cin >> h[i];
	h[n] = 1e9 + 1;
	for (int i = n - 1; i >= 0; i--) {
		if (h[i] >= h[i + 1]) ac[i] += ac[i + 1] + 1;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)ans = max(ans, ac[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(A * N, B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int v,n,i,j,A[100];
int count=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
 scanf("%d",&A[i]);}

for(j=0;j<n;j++){
 for(i=n-1;i>j;i--){
  if(A[i]<A[i-1]){
    v=A[i];
    A[i]=A[i-1];
    A[i-1]=v;
    count++;
   }
 }
}
 for(i=0;i<n;i++){
 if(i==n-1)printf("%d\n",A[i]);
 else printf("%d ",A[i]);
}
printf("%d\n",count);

return 0;
}

Measured memory_bytes: 1800