akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

bool isok(int n,map<int,bool> &mp){
	while(n!=0){
    	if (mp[n%10]==true){
        	return false;
        }
        n/=10;
    }
  return true;
}

int main(){
  	int n,k;
  	cin>>n>>k;
  	map<int,bool> mp;
  	for (int i=0;i<k;i++){
    	int t;
      	cin>>t;
      	mp[t]=true;
    }
  	int ans=n;
 	while (isok(ans,mp)==false) ans++;
  	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
D, N = map(int, input().split())
if D == 0:
    if N % 100 == 0:
        N += 1
    print(N)
else:
    ans = 100 ** D * N
    if ans % (100 ** (D + 1)) == 0:
        print(100 ** D * N + 100 ** D)
    else:
        print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ll long long
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void  solve(){
  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  vector<ll> dp(60,0);

  rep(i,0,n){
    ll t=a[i];
    for(int j=0;j<50;j++){
         dp[j]+=t%2;
         t/=2;
    }
  }

  ll num=0LL,ans=0LL;
  rrep(j,59,0){
    ll c=dp[j];
    if(c<n-c){
      ll temp=num+(1LL<<j);
      if( temp<=k){
        num= temp;
        ans+=((n-c)*(1LL<<j));
      }
      else ans+= (c*(1LL<<j));
    }
    else ans+= (c*(1LL<<j));
  }

  cout<<ans;
}
int main(){
    optimizeIO();
    solve();
}


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

class dictionaryOrder {
public:
  bool operator()(const string& left, const string& right){
    int n = (left.length()<right.length())?left.length():right.length();
    for(int i=0;i<n;i++){
      if(left[i]!=right[i]) return left[i]<right[i];
    }
    return left.length()<right.length();
  }
};

int main(){
  int n,l;
  cin >> n >> l;
  string s[100];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }

  sort(s,s+n,dictionaryOrder());

  for(int i=0;i<n;i++){
    cout << s[i];
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll LCD(ll a,ll b){
	if(a<b) swap(a,b);
	while(b){
		ll t = a%b;
		a = b;
		b = t;
	}
	return a;
}
int main(){
	int n;
	cin>>n;
	vector<ll>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	ll lcm = 1;
	for(int i=0; i<n; i++){
		ll lcd = LCD(arr[i],lcm);
		lcm = lcm*(arr[i]/lcd);
	}
	cout<<lcm;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{int N,M; cin >> N >> M;
 vector<pair<int,int>> X(M);
 for(int i = 0; i < M; i++)
 {cin >> X[i].first >> X[i].second;}
 
 
 sort(X.begin(),X.end());
 
 int count = 0; int anchor = 0;
 
for(int i = 0; i < M; i++)
{if(anchor < X[i].first){count++; anchor = X[i].second - 1;}
 else{anchor = min(anchor,X[i].second - 1);}}
 
 cout << count << endl;
 
 return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			map.put(a[i], i+1);
		}
		Arrays.sort(a);

		StringBuilder ans = new StringBuilder();
		for (Integer i : a) {
			ans.append(map.get(i));
			ans.append(" ");
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 66556
fun main(arr:Array<String>) {
    var abc = readLine()!!.split(" ").map { it.toInt() }.sorted().toMutableList()
    val adda = abc.last() - abc.first()
    val addb = abc.last() - abc[1]
    var ans = Math.min(adda, addb)
    val tmp = Math.max(adda, addb) - ans
    if(tmp % 2 != 0) {
        ans+=2
    }
    ans += tmp / 2
    println(ans)

}


Measured memory_bytes: 37752
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		15										// 最大配列数
#define D_SCORE_MAX		50										// 最大得点数

// 内部構造体 - 得点情報
typedef struct Score {
	int miNo1, miNo2;											// 位置
	int miDF;													// 差
	int miScore;												// 得点
} Score;

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数
static int siMax;												// 最大値
static Score sz1Score[D_SCORE_MAX];								// 得点情報
static int siSCnt;												// 得点情報数
static int siSCore;												// 最大得点

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大得点 - 更新
int
fUpScore(
)
{
	int i;

	// 得点 - 取得
	int liSum = 0;
	for (i = 0; i < siSCnt; i++) {
		if (si1Array[sz1Score[i].miNo2] - si1Array[sz1Score[i].miNo1] == sz1Score[i].miDF) {
			liSum += sz1Score[i].miScore;
		}
	}

	// 最大得点 - 更新
	if (siSCore < liSum) {
		siSCore = liSum;
	}

	return 0;
}

// 配列 - セット
int
fSetArray(
	int piANo					// <I> 配列番号
)
{
	int i;

	if (piANo > siACnt) {
		fUpScore();
		return 0;
	}

	for (i = si1Array[piANo - 1]; i <= siMax; i++) {
		si1Array[piANo] = i;
		fSetArray(piANo + 1);
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	siSCore = 0;

	// 配列数・最大値・得点情報数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d", &siACnt, &siMax, &siSCnt);

	// 得点情報 - 取得
	for (i = 0; i < siSCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d%d%d", &sz1Score[i].miNo1, &sz1Score[i].miNo2, &sz1Score[i].miDF, &sz1Score[i].miScore);
	}

	// 配列 - セット
	si1Array[0] = 1;
	fSetArray(1);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", siSCore);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e18;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

int A[100100];
vpi B,C;
int N;


int main(){
  cin >> N;
  for (int i=0;i<N;++i)cin>>A[i];
  B.resize(100100); C.resize(100100);
  for (int i=0;i<100100; ++i)B[i] = C[i] = mp(N/2,i);
  for (int i=0;i<N;i = i+2){
    B[A[i]].f --;
    //cout<<"Change " << i << " to " << B[i].f << '\n';
  }
  for (int i=1;i<N;i = i+2){
    C[A[i]].f--;
    //cout<<"Change " << i << " to " << B[i].f << '\n';
  }
  sort(ALL(B));
  sort(ALL(C));
  if (B[0].s == C[0].s)cout<<min(B[0].f+C[1].f, B[1].f+C[0].f);
  else cout<<B[0].f+C[0].f;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int h[] = getIntArray(n);
		int cnt = 0;
		int max = 0;
		for ( int i = 0 ; i < n-1 ; i++ ) {
			if ( h[i] >= h[i+1] ) {
				cnt++;
			} else {
				if ( max < cnt ) {
					max = cnt;
				}
				cnt = 0;
			}
		}
		if ( max < cnt ) {
			max = cnt;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 45268
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

signed main() {
    int H, W, N;
    cin >> H >> W >> N;
    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];

    int grid[H][W];
    int ptr = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int y = i;
            int x = i % 2 == 0 ? j : W - 1 - j;
            grid[y][x] = ptr + 1;
            a[ptr]--;
            if (a[ptr] == 0) ptr++;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << grid[i][j];

            if (j == W - 1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
	int i,n;
	char moji[110];
	int count[100];
	for(i=0;i<100;i++){
		count[i]=0;
	}
	scanf("%s",moji);
	for(i=0;moji[i]!='\0';i++){
		n = moji[i] - 'a';
		//printf("%d\n",n);
		count[n]++;
	}
	i=0;
	while(i<100){
		//printf("count[%d]=%d\n",i,count[i]);
		if(count[i]%2==1){
			printf("No\n");
			break;
		}

		i++;
	}
	if(i==100){
		printf("Yes\n");
	}
	return 0;
}

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

namespace ABC
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var a = Console.ReadLine ().Split().Select(x=>long.Parse(x)).ToArray();
			long result = 0;
			if (a [0] % 2 == 0 || a [1] % 2 == 0 || a [2] % 2 == 0)
				result = 0;
			else
				result = Math.Min (Math.Min (a [0] * a [1], a [1] * a [2]),a [2] * a [0]);

			Console.WriteLine (result);
				
		}
	}
}


Measured memory_bytes: 3032
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

string S;

int main() {
  io();
  
  cin >> S;
  int i = 0, k = S.size() - 1, count = 0;
  while(i <= k) {
    if(S[i] != S[k]) ++count;
    ++i; --k;
  }
  
  cout << count;
  
  return 0;
}

Measured memory_bytes: 256
//Author - Soumik Roy
//Date & Time - August 29, 2020 6:00 PM
//Problem name - A - Don't be late
//Problem url - https://atcoder.jp/contests/abc177/tasks/abc177_a
//Time limit - 2000 ms
//Memory Limit - 1024 MB    

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dir[]={0,1,0,-1,1,0,-1,0};
void solve()
{
	ll d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	lli cub1[MaxN],cub2[MaxN];
	lli vis1[MaxN],vis2[MaxN];
	vector < pair <lli,lli> > val1,val2;
	void solve(){
		lli N,i,j,res=0,p=0,q=0,r1=1e9,r2=1e9;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>arr[i];
			if(i%2==0){
				cub1[arr[i]]+=1;
				p+=1;
			}
			else cub2[arr[i]]+=1,q+=1;
		}
		for(i=0;i<N;i++){
			if(i%2==0){
				if(vis1[arr[i]])continue;
				vis1[arr[i]]=1;
				r1=min(p-cub1[arr[i]],r1);
				val1.push_back(mp(p-cub1[arr[i]],arr[i]));
			}
			else {
				if(vis2[arr[i]])continue;
				vis2[arr[i]]=1;
				r2=min(q-cub2[arr[i]],r2);
				val2.push_back(mp(p-cub2[arr[i]],arr[i]));
			}
		}
		sort(val1.begin(),val1.end());
		sort(val2.begin(),val2.end());
		if(val1[0].snd!=val2[0].snd)cout<<val1[0].fst+val2[0].fst;
		else {
			if(val1.size()==1&&val2.size()==1){
				cout<<N/2;
			}
			else cout<<min(val1[0].fst+val2[1].fst,val1[1].fst+val2[0].fst);
		}
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 8180
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x))
#define setNeg1(x) memset((x),255,sizeof(x))
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<int,ll> pii;
int n,m,res;
vector<pii> g[100005];
pii p[100005];
bool vis[100005];
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i].X;
		if(vis[u]){
			if(p[x].X+p[u].X==0){
				if(p[x].Y+p[u].Y!=g[x][i].Y){
					cout<<"0\n";
					exit(0);
				}
			}
			else{
				ll diff=g[x][i].Y-(p[x].Y+p[u].Y);
				if(p[x].X<0)diff=-diff;
				if(diff<2 || diff&1 || (res && (diff>>1)!=res)){
					cout<<"0\n";
					exit(0);
				}
				else res=diff>>1;
			}
		}
		else{
			p[u]=pii(-p[x].X,g[x][i].Y-p[x].Y);
			dfs(u);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		ll c;
		cin>>u>>v>>c;
		g[u].push_back(pii(v,c));
		g[v].push_back(pii(u,c));
	}
	p[1]=pii(1,0);
	dfs(1);
	if(!res){
		ll lb=2e9,ub=0;
		for(int i=1;i<=n;i++){
			if(p[i].X<1)lb=min(lb,p[i].Y-1);
			else ub=max(ub,1-p[i].Y);
		}
		cout<<max(0ll,lb-ub+1)<<endl;
	}
	else{
		for(int i=1;i<=n;i++){
			if(p[i].X*res+p[i].Y<=0){
				cout<<"0\n";
				return 0;
			}
		}
		cout<<"1\n";
	}
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n; cin >> n; int cnt = 0;
	string ans;
	if (n == 0) ans = "0";
	while (n != 0) {
		ans += to_string(abs(n%2));
		if (n % 2) {
			n -= pow(-1,cnt%2);
		}
		n /= 2;
		cnt++;
	}
	reverse(ALL(ans));
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

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

int main() {
	int n, need;
	cin >> n >> need;
	int64_t x[n], y[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	int64_t ans = numeric_limits<int64_t>::max();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					int count = 0;
					for (int m = 0; m < n; m++) {
						if (x[i] <= x[m] && x[m] <= x[j] && y[k] <= y[m] && y[m] <= y[l]) {
							count++;
						}
					}
					if (need <= count) {
						ans = min(ans, (max(x[i], x[j]) - min(x[i], x[j])) * (max(y[k], y[l]) - min(y[k], y[l])));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def cut_vertices(E, s):
    N = len(E)
    preorder = [-1] * N # a dfs preordering of each vertex
    lowpt = [N] * N # for finding a cut-vertex
    cut_vertex = [False] * N
    root_children = 0 # #(children of the root in the dfs search tree)
    stack = [(s, -1, 0)] # (vertex, parent, status)
    pre_num = 0 # current preordering
    while stack:
        v, p, st = stack.pop()
        if st == 0 and preorder[v] < 0: # visited v for the first time
            preorder[v] = pre_num
            lowpt[v] = pre_num
            pre_num += 1
            n_children = 0
            for u in E[v]:
                if preorder[u] >= 0:
                    if u != p: # the edge (v, u) is a back edge, which is not in dfs search tree
                        lowpt[v] = min(lowpt[v], preorder[u])
                    continue
                if n_children == 0:
                    stack += [(v, p, 2), (u, v, 0)]
                    n_children += 1
                else:
                    stack += [(v, p, 1), (u, v, 0)]
                    n_children += 1
            if n_children == 0: # v is a leaf of the dfs search tree
                lowpt[p] = min(lowpt[p], lowpt[v])
                if lowpt[v] >= preorder[p] != 0: cut_vertex[p] = True
                elif preorder[p] == 0: root_children += 1
        elif st == 0 and preorder[v] >= 0: # the edge (v, p) is a back edge
            continue
        elif st == 1: # now searching
            continue
        else: # search finished
            if p != -1:
                lowpt[p] = min(lowpt[p], lowpt[v])
                if lowpt[v] >= preorder[p] != 0: cut_vertex[p] = True
                elif preorder[p] == 0: root_children += 1
            else:
                if root_children >= 2: cut_vertex[v] = True
    return cut_vertex

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    s, t = map(int, input().split())
    E[s].append(t); E[t].append(s)
temp = cut_vertices(E, 0)
cut_vs = [v for v in range(N) if temp[v]]
if cut_vs: print(*cut_vs, sep='\n')


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

int main(){
  int n;
  vector<int> v(100010);

  vector<int> cnt1(100010, 0), cnt2(100010, 0);

  cin >> n;
  for(int i=0; i<n; i++){
    cin >> v[i];
    if(i % 2 == 0){
      cnt1[v[i]]++;
    } else {
      cnt2[v[i]]++;
    }
  }

  int max1 = 0, max2 = 0;
  for(int i=0; i<=100000; i++){
    max1 = max(max1, cnt1[i]);
    max2 = max(max2, cnt2[i]);
  }

  int maxn1, maxn2;
  for(int i=0; i<=100000; i++){
    if(cnt1[i] == max1) maxn1 = i;
    if(cnt2[i] == max2) maxn2 = i;
  }

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

  int max1_2 = cnt1[1], max2_2 = cnt2[1];

  if(maxn1 != maxn2){
    cout << n - max1 - max2 << endl;
  } else {
    cout << n - max1 - max(max1_2, max2_2) << endl;
  }
}
  
  

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

int main() {
	int n;
	cin>>n;
	int ara[200000];
	for (int i=0;i<n;i++){
		cin>>ara[i];
	}
	long long int s=0;
	int prev=ara[0];
	for (int i=1;i<n;i++){
		if (ara[i]<prev){
			s=s-ara[i]+prev;
			//prev=ara[i]
		}
		else{
			prev=ara[i];
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 4372
N, M = map(int, input().split())
H = list(map(int, input().split()))
edges = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

def dfs(u, p=-1):
    for v in edges[u]:
        if v == p:
            continue
        if H[u] <= H[v]:
            return False
        dfs(v, u)
    return True

ans = 0
for i in range(N):
    if dfs(i, -1):
        ans += 1
print(ans)

Measured memory_bytes: 93832
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, M, R;
ll d[222][222];
vector<ll> r;


int main(void) {
    cin >> N >> M >> R;
    ll i, j, k;
    
    for(i=0; i<R; i++) {
        ll t;
        cin >> t;
        t--;
        r.pb(t);
    }
    
    for(i=0; i<N; i++)
        for(j=0; j<N; j++)
            d[i][j]=(i==j ? 0 : INF);
    
    for(i=0; i<M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    
    for(k=0; k<N; k++)
        for(i=0; i<N; i++)
            for(j=0; j<N; j++)
                chmin(d[i][j], d[i][k]+d[k][j]);
    
    ll ans=INF;
    for(k=0; k<40320; k++) {
        ll t=0;
        for(i=0; i<R-1; i++)
            t+=d[r[i]][r[i+1]];
        
        chmin(ans, t);
        next_permutation(r.begin(), r.end());
    }
    
    pt(ans);
}


Measured memory_bytes: 640
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) begin(c), end(c)
#define tr(i,c) for(auto i=begin(c);i!=end(c);i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

static int swap_count;

void selectionSort(vi& A, int N) {
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minj]) minj = j;
    }
    if (i != minj) {
      swap(A[i], A[minj]);
      swap_count++;
    }
  }
}

int main(int argc, char **argv)
{
  int N;
  cin >> N;
  vi A(N);
  for (auto& a:A) {
    cin >> a;
  }
  selectionSort(A, N);
  string sp = "";
  for (auto& a:A) {
    cout << sp << a;
    sp = " ";
  }
  cout << endl;
  cout << swap_count << endl;
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char> > c(h, vector<char>(w));
  REP(i, h) REP(j, w) cin >> c[i][j];
  int ans = 0;
  REP(i, 1 << h){
    REP(j, 1 << w){
      vector<vector<char> > tmp = c;
      int cnt = 0;
      REP(y, h){
        REP(x, w){
          if(i & (1 << y)){
            tmp[y][x] = '$';
          }
          if(j & (1 << x)){
            tmp[y][x] = '$';
          }
        }
      }
      REP(y, h){
        REP(x, w){
          if(tmp[y][x] == '#') cnt++;
        }
      }
      if(cnt == k){
        ans++;
      }
    }
  } 
  cout << ans << endl;
}

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

int main(){
    int a; bool b[3]; for(int i=0;i<3;i++) b[i]=false;
    for(int i=0;i<2;i++){ cin>>a; b[a-1]=true;}
    for(int i=0;i<3;i++){ if(!b[i]){cout<<i+1; return 0;}}
    return 0;
}


Measured memory_bytes: 256
#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;
typedef long long ll;

int main() {
	
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int max_x = -1001, min_y = 1001;
	rep(i, n){
		int x;
		cin >> x;
		if(max_x < x) max_x = x;
	}
	rep(i, m){
		int y;
		cin >> y;
		if(min_y > y) min_y = y;
	}
	bool is_war = true;
	for(int z = x + 1; z <= y; z++){
		if(max_x < z && min_y >= z){
			is_war = false;
		}
		if(!is_war) break;
	}
	if(is_war){
		puts("War");
	}else{
		puts("No War");
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int digitsum(string s){
  int len = s.size();
  int dsum = 0;
  for (int i = 0; i < len; i++) dsum += s[i] - '0';
  return dsum;
}

int main(){
	int a = 1;
  	string s;
  	while(a){
      cin >> s;
      if (s == "0") a = 0;
      else {
          cout << digitsum(s) << endl;
      }
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int a,b;
  cin>>a>>b;
  cout<< max(a-2*b,0)<<endl;
}




Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  string s;
  cin >> s;
  int ans = 0;
  s += "S";
  int cur = 0;
  fore(i, 0, SZ(s)) {
    if (s[i] == 'R') {
      cur++;
      ans = max(ans, cur);
    } else {
      cur = 0;
      ans = max(ans, cur);
    }
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int gcd(vector<int> a) {
	int ans = a[0];
	for (int i = 1; i < a.size(); i++) {
		ans = gcd(ans, a[i]);
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = gcd(a);
	cout << ans << endl;

	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("transposition-115.txt","r",stdin)
#define OUT freopen("dichromatic.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define SZ(v) ((int)v.size())
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

#define maxn 300005
#define mod 1000000007LL

typedef pair<i64,i64> pii ;
typedef  long long int T ;

char s[maxn] ;
int dp[maxn] ;

int main()
{
    int n ;
    scanf("%s",s) ;

    n = strlen(s) ;

    i64 ans = 0LL ;

    for(int i=n-1 ; i>=0 ; i--)
    {
        if( s[i]=='A' )
        {
            dp[i] = dp[i+1] ;
            ans += dp[i] ;
        }
        if( s[i]=='B' && s[i+1]=='C' )
        {
            dp[i] = dp[i+2] + 1;
        }
    }

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

    return 0 ;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 20:37:55 2019

@author: avina
"""

l,r = map(int, input().split())
k = 2020

for i in range(l,r+1):
   for j in range(i+1,r+1):
       k = min(k, (i*j)%2019)
       if k == 0:
           print(k)
           exit()
print(k)

Measured memory_bytes: 3060
import Data.List
import Text.Printf

main = do
  s <- getLine

  let ans = solve s

  if ans == [] then
    print $ -1
    else
    mapM_ (\(a,b) -> printf "%d %d\n" a b) ans

solve s
  | length s == 2 = if s == "10" then [(1,2)] else []
  | otherwise = if last s == '0' && head s == '1' && last (init s) == '1' then
                  if isPalindrome (init s) then
                    aux 1 1 (fst $ splitAt (length s`div`2) (init s))
                  else
                    []
                else
                  []
  where
    aux root cur [] = [(root,i) | i<-[cur+1..length s]]
    aux root cur (x:xs) = if x == '1' then (root,cur+1) : aux (cur+1) (cur+1) xs else (root,cur+1) : aux root (cur+1) xs

isPalindrome xs = xs == reverse xs


Measured memory_bytes: 10748
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	int t,s,d;
	int cnt;

	while(1){
		cin>>n>>m;
		if(n+m==0) break;

		map<int,pair<int,int> > mp;
		vector<bool> v(n);

		for(int i1=0;i1<n;i1++) v[i1]=false;
		v[0]=true;

		for(int i1=0;i1<m;i1++){
			cin>>t>>s>>d;
			mp[t]=make_pair(s-1,d-1);
		}

		cnt=1;
		for(map<int,pair<int,int> >::iterator it=mp.begin();it!=mp.end();it++){
			if(v[(*it).second.first] && !v[(*it).second.second]) {
				v[(*it).second.second]=true;
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 2452
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
string s;

void solve(){
	int ctr = 0, ctw = 0;
	cin >> n >> s;
	for(int i = 0; i < n; i++) ctr += (s[i] == 'R');
	int ans = ctr;
	for(int i = 0; i < n; i++){
		if(s[i] == 'W') ctw++;
		if(s[i] == 'R') ctr--;
		ans = min(ans,ctw+ctr-min(ctw,ctr));
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

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

using namespace std;

vector<int64_t> nums;
using It = decltype(nums.begin());
vector<It> sorted_its;
set<It> seen;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  nums.reserve(N + 4);
  nums.emplace_back();
  for (int i = 1; i <= N; ++i) {
    int n;
    cin >> n;
    nums.emplace_back(n);
    sorted_its.push_back(nums.end() - 1);
  }

  sort(sorted_its.begin(), sorted_its.end(),
       [](auto&& a, auto&& b) { return *a > *b; });

  int64_t result = 0;

  for (auto&& it : sorted_its) {
    auto r1_it = seen.upper_bound(it);
    It left1, left2, right1, right2;
    if (r1_it == seen.end()) {
      right1 = nums.end();
      right2 = nums.end();
    } else {
      right1 = *r1_it;
      auto r2_it = next(r1_it);
      right2 = r2_it == seen.end() ? nums.end() : *r2_it;
    }
    if (r1_it == seen.begin()) {
      left1 = nums.begin();
      left2 = nums.begin();
    } else {
      auto l1_it = prev(r1_it);
      left1 = *l1_it;
      left2 = l1_it == seen.begin() ? nums.begin() : *prev(l1_it);
    }
    result += *it * ((left1 - left2) * (right1 - it) +
                     (right2 - right1) * (it - left1));
    seen.emplace(it);
  }

  cout << result << endl;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli m, d;
    cin2(m, d);

    lli ans = 0;
    REPE(i, 1, m) {
        REPE(j, 1, d) {
            lli x = j /10;
            lli y = j %10;
            if (x <= 1 || y <= 1)
                continue;
            if (x * y == i)
                ans++;
        }

    }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

/*キューの使い方はこれを見る*/
int main() {
    ll k;
    cin >> k;
    queue<ll> que;
    FOR(i, 1, 9) que.push(i);//1〜9を先に格納
    REP(i, k-1) {//k-1番目までを捨てる操作
        ll s = que.front();//先頭にアクセス
        que.pop();//先頭を削除
        for (int j = -1; j <= 1; ++j) {
            ll add = (s % 10) + j;
            if (add >= 0 && add <= 9) que.push(s * 10 + add);//後ろに追加
        }
    }
    cout << que.front() << endl;//先頭がk番目
}

Measured memory_bytes: 1792
# 写経AC
import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError
from scipy.spatial.distance import cosine

def solve(n, pts):
    ans = np.zeros(n)

    try:
        # 凸包
        hull = ConvexHull(pts)
    except QhullError: # 与えられた点が一直線に並ぶ場合
        # 左端の穴
        ans[pts.index(min(pts))] = 0.5
        # 右端の穴
        ans[pts.index(max(pts))] = 0.5
        return ans

    # 凸包の頂点数
    L = hull.vertices.shape[0]

    for i,v in enumerate(hull.vertices):
        # 時計回り
        prv = hull.vertices[(i - 1) % L]
        # 反時計回り
        nxt = hull.vertices[(i + 1) % L]

        # arccos(コサイン距離) -> 角度
        deg = np.arccos(1 - cosine(hull.points[prv] - hull.points[v], hull.points[nxt] - hull.points[v]))

        ans[v] = (np.pi - deg) / (2 * np.pi)

    return ans

def main():
    N = int(input())
    XY = [[int(i) for i in input().split()] for _ in range(N)]
    print(*solve(N, XY), sep="\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 24436
from itertools import accumulate
from bisect import bisect_left
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
I = [0] * (N+1)
J = [0] * (N+1)
for i in range(N): I[bisect_left(B, A[i]+1)] += 1
I = list(accumulate(I))
for i in range(N): J[bisect_left(C, B[i]+1)] += I[i]
print(sum(accumulate(J[:-1])))

Measured memory_bytes: 24772
n = int(input())
l = [int(i) for i in input().split()]
sorted_l = sorted(l)
flag = 0

for num, s_num in zip(l, sorted_l):
  if num != s_num:
    flag += 1

if flag == 0 or flag == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
s_li = list(input())
n = len(s_li)
ans = []
if "A" in s_li or "C" in s_li or "G" in s_li or "T" in s_li:
    co = 0
    for s in s_li:
        if s in ["A","C","G","T"]:
            co += 1
        else:
            ans.append(co)
            co = 0
    ans.append(co)
else:
    ans.append(0)
print(max(ans))


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
int a,b;
int main(void)
{
    cin >> a >> b ;
    int res = 0;
    res = a;
    if(b < a)res -= 1;
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}

const LL MAX = 1e18;

inline LL minMult(LL x, LL n) { return n * (x / n + (x % n == 0 ? 0 : 1)); }

void solve(long long N, std::vector<long long> A){
    EACH(a, A) {
        if (a == 0) {
            cout << "0" << endl;
            return;
        }
    }
    LL p = 1;
    EACH(a, A) {
        if (MAX / p < a) {
            cout << "-1" << endl;
            return;
        }
        p *= a;
    }
    cout << p << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,k,c=0;
  cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;--i) {
    if(a%i==0 && b%i==0)
      c++;
    if(c==k) {
      cout<<i;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


int popcount32(unsigned int x) {
	x = x - ((x >> 1) & 0x55555555);
	x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
	x = (x + (x >> 4)) & 0x0F0F0F0F;
	x = x + (x >> 8);
	x = x + (x >> 16);
	return x & 0x0000003F;
}


int n;
int x[15], y[15], p[15];

long long calc(int yb, int xs, int xg) { // (xs,xg)
	long long s = 0;

	rep(i, n) {
		if (xs < x[i] && x[i] < xg) {
			long long mi = min(xg - x[i], x[i] - xs);
			mi = min(mi, llabs(x[i]));
			mi = min(mi, llabs(y[i]));
			rep(j, n) if(yb >>j&1){
				mi = min(mi, llabs(y[i] - y[j]));
			}
			s += mi * p[i];
		}
	}
	return s;
}


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



	
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i] >> p[i];

	tuple<int, int, int> t[15];
	rep(i, n)t[i] = make_tuple(x[i], y[i], p[i]);
	sort(t, t + n);
	rep(i, n)tie(x[i], y[i], p[i]) = t[i];


	long long ans[31];
	rep(i, 31)ans[i] = 1LL << 60;

	long long inf = 1LL << 60;
	int mask = (1 << n) - 1;
	rep(yb, 1 << n) {
		long long dp[15][16];
		rep(i, n)rep(j, n + 1)dp[i][j] = inf;
		rep(j, n)if ((yb >> j & 1) == 0)dp[j][1] = calc(yb, -INF, x[j]);


		long long cost[15][15];
		rep(i, n)for (int k = i + 1; k < n; k++)
			if((yb >> i & 1) == 0 && (yb >> k & 1) == 0) cost[i][k] = calc(yb, x[i], x[k]);

		rep(i, n) for (int j = 1; j < n; j++) if(dp[i][j] != inf){
			for (int k = i + 1; k < n; k++) if ((yb >> k & 1) == 0) {
				dp[k][j + 1] = min(dp[k][j + 1], dp[i][j] + cost[i][k]);
			}
		}

		int pop = popcount32(yb);
		ans[pop] = min(ans[pop], calc(yb, -INF, INF));
		rep(i, n) for (int j = 1; j <= n; j++) {
			ans[pop + j] = min(ans[pop + j], dp[i][j] + calc(yb, x[i], INF));
		}
	}


	for (int i = 0; i <= n;i++) {
		cout << ans[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> k >> n;
    if (k > 10)k = 10;
    cout << n + 100 * (10 - k) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;

  string str;
  for(int i=0; i<H+2; i++){
    cout << '#';
    if(i==0 || i==H+1){
      int n=0;
      while(n<W){
        cout << '#';
        n++;
        }
    }
    else{
      cin  >> str;
      cout << str;
    }
    cout << '#'<< endl;
  }
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(){
	int i,x[10000],y[10000],n;

	for(i=1;i<=10000;i++){
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]==0&&y[i]==0){
			break;
		}
	}

	n=i;

	for(i=1;i<n;i++){
		if(x[i]>y[i]){
			printf("%d %d\n",y[i],x[i]);
		}else{
			printf("%d %d\n",x[i],y[i]);
		}
	}


	return 0;
}



Measured memory_bytes: 2072
n = int(input())
li = list(map(int,input().split()))
y = [0]*10**5
for i in li:
    y[i-1] += 1
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]
x = sum(li)
#print(y)
for i in range(q):
    b = bc[i][0]
    c = bc[i][1]
    d = y[b-1]
    e = y[c-1]
    y[b-1] = 0
    y[c-1] = d+e
    x = x + (c-b) * d
    print(x)
    #print(y)

Measured memory_bytes: 32620