akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;
int main() {
    int X;
    cin >> X;
    int div = X / 100;
    int count = div;
    int mod = X % 100;
    if (div == 0) {
        cout << "0" << endl;
    } else if (mod > div * 5) {
        cout << "0" << endl;
    } else if (mod == 0 || 5 >= mod) {
        cout << "1" << endl;
    } else {
        cout << "1" << endl;
    }

    return 0;
}

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

uint64_t cnt[100002LL];

int main() {
  uint64_t N;
  cin >> N;
  for (uint64_t i = 0LL; i < N; i++) {
    uint64_t x;
    cin >> x;
    cnt[x]++;
  }
  priority_queue<uint64_t> q;
  for (uint64_t i = 1LL; i < 100001LL; i++) {
    q.push(cnt[i-1] + cnt[i] + cnt[i+1]);
  }
  cout << q.top() << endl;
}

Measured memory_bytes: 2168
#include<iostream>
using namespace std;
typedef long long int ll;
ll a[109];
int n;
ll f(int x)
{
    ll val=0;
    for(int i=1;i<=n;i++) val+=(x-a[i])*(x-a[i]);
    return val;
}
int main()
{
   ll sum=0;
    cin>>n;
    for(int i=1;i<=n;i++) { cin>>a[i] ; sum+=a[i] ;}
    cout<< min(f(sum/n),f(sum/n+1));
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N + 1);
  data.at(0) = 3;
  long ans = 1, a;
  for(int i = 0; i < N; i++){
    cin >> a;
    ans *= data.at(a);
    data.at(a)--;
    data.at(a + 1)++;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {s: String, t: String};
    if t.starts_with(&s) {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main()
{
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> sum(N);
    for(int i = 1;i < N;i++){
        sum[i] = sum[i - 1] + (S[i - 1] == 'A' && S[i] == 'C');
    }
    while(Q--){
        int l, r;
        cin >> l >> r; --l, --r;
        printf("%d\n", sum[r] - sum[l]);
    }
    return 0;
}


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

#define ll long long int

vector<vector<int>> groups;
vector<bool> visited;

void dfs(int x,int &size)
{
    if(visited[x]) return ;
    visited[x] = true ;
    size++;
    for(int next : groups[x])
        dfs(next,size);
    return ;
}
int solvere()
{
    int n,p,i,x,y;
    cin>>n>>p;
    visited.resize(n+1,false),groups.resize(n+1);
    for(i=0;i<p;i++)
    {
        cin>>x>>y;
        groups[x].push_back(y);
        groups[y].push_back(x);
    }
    int ans=0,size;
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            size = 0;
            dfs(i,size);
            ans=max(ans,size);
        }
    }
    cout<<ans<<endl;
    return 0;    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    int t=1;
    //cin>>t;
    while(t--)
    solvere();
    return 0;
}


Measured memory_bytes: 20264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[27][102];
string s[3];
int main() {
	ll n,ans=0;
	cin>>n>>s[0]>>s[1]>>s[2];
	for(int i=0;i<n;i++){
		ll sum=0;
		for(int j=0;j<3;j++){
			ll now=s[j][i]-'a';
			a[now][i]++;
			sum=max(sum,a[now][i]);
		}
		ans+=3-sum;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//ITP1_8_C_19140837_Ojima_Yukiya.cpp
//提出日 2020/6/17 wednesday
//プログラミング基礎演習2 CS 第６回課題 ITP1_8_C
//学修番号 19140837　小島優希也
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    vector<int> vec(26, 0);
    while (true) {
        string s;
        getline(cin, s);
        if (s == "") break;
        else {
            for (int e : s) {
                for (int i = 0; i < 26; i++) {
                    if (e == i + 65) {
                        vec.at(i)++;
                        break;
                    }
                    if (e == i + 97) {
                        vec.at(i)++;
                        break;
                    }
                }
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << (char)(i + 97) << " : " << vec.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @author wuyue
 *
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		if (n == 1 || m == 1) {
			System.out.println(1);
			return;
		}
		if (m % 2 == 0 ) {
			System.out.println(n * (m/2));
		} else {
			if (n%2==0) {
				System.out.println(m*(n/2));
			} else {
				System.out.println(m*(n/2) + m/2 +1);
			}
		}
		
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll dp[110][110];

int main() {
    ll N;
    cin >> N;
    vll p;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if(i == 0) p.emplace_back(a);
        p.emplace_back(b);
    }

    rep(i, 110) rep(j, 110) dp[i][j] = INF;
    rep(i, 100) dp[i][i] = 0;

    for(ll l = 2; l <= N; l++) rep(i, N-l+1) {
        ll j = i + l - 1;
        for(ll k = i; k < j; k++) chmin(dp[i][j], dp[i][k] + dp[k+1][j] + p[i] * p[k+1] * p[j+1]);
    }
    cout << dp[0][N-1] << endl;
}



Measured memory_bytes: 3236
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4,avx2,abm,fma")
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-11;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);

	string s;
	cin >> s;
	deque<char> res;
	for(char c : s) {
		res.push_back(c);
	}

	int m;
	cin >> m;
	bool rev = false;
	for(int i=0; i<m; i++) {
		int t;
		cin >> t;
		if(t == 1) {
			rev ^= 1;
		} else {
			int f; char c;
			cin >> f >> c;
			f = (f-1) ^ rev;
			if(f == 0) {
				res.push_front(c);
			} else {
				res.push_back(c);
			}
		}
	}

	if(rev) {
		while(!res.empty()) {
			cout << res.back();
			res.pop_back();
		}
	} else {
		while(!res.empty()) {
			cout << res.front();
			res.pop_front();
		}
	}
	cout << nl;

	return 0;
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n, m, k; cin >> n >> m >> k;

	bool ans = false;

	rep(i, n+1){
		rep(j, m+1){
			ll res = 0;
			res += i * j;
			res += (n - i) * (m - j);
			if(res == k) ans = true;
		}
	}

	if(ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A);
  for (int i = 0; i < A; i++){
    cin >> p[i];
  }
  vector<int> q(B);
  for (int i = 0; i < B; i++){
    cin >> q[i];
  }
  vector<int> r(C);
  for (int i = 0; i < C; i++){
    cin >> r[i];
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());
  while (p.size() > X){
    p.pop_back();
  }
  while (q.size() > Y){
    q.pop_back();
  }
  /*
  for (int i = 0; i < p.size(); i++){
    cout << p[i] << ' ';
  }
  cout << endl;
  for (int i = 0; i < q.size(); i++){
    cout << q[i] << ' ';
  }
  cout << endl;
  for (int i = 0; i < r.size(); i++){
    cout << r[i] << ' ';
  }
  cout << endl;
  */  
  int colorcount = 0;
  while (1){
    //cout << p.size() << ' ' << q.size() << ' ' << colorcount << endl;
    if (colorcount >= r.size()){
      break;
    }
    if (p.size() > 0 && q.size() > 0){
      if (p.back() < q.back() && p.back() < r[colorcount]){
        p.pop_back();
        colorcount++;
      } else if (q.back() < r[colorcount]){
        q.pop_back();
        colorcount++;
      } else {
        break;
      }
    } else if (p.size() > 0){
      if (p.back() < r[colorcount]){
        p.pop_back();
        colorcount++;
      } else {
        break;
      }
    } else if (q.size() > 0){
      if (q.back() < r[colorcount]){
        q.pop_back();
        colorcount++;
      } else {
        break;
      }
    } else {
      break;
    }
  }
  long long ans = 0;
  for (int i = 0; i < p.size(); i++){
    ans += p[i];
  }
  for (int i = 0; i < q.size(); i++){
    ans += q[i];
  }
  for (int i = 0; i < colorcount; i++){
    ans += r[i];
  }
  cout << ans;
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdint.h>
#include <limits.h>
#include <utility>

using namespace std;

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

  bool flag = false;
  
  for (int a=0; a<= N/4 && !flag; ++a) {
    int residue = N - a*4;
    flag = (residue%7==0);
  }

  cout << (flag? "Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
  long long n;
  cin >> n;
  long long a,b;
  cin >> a >> b;
  vector<long long> h(n);
  for(long long i = 0;i < n;i++) cin >> h[i];
  long long s = 0;
  long long e = 2000000000/b;
  a -= b;
  while(e-s > 1){
    long long m = (s+e)/2;
    long long bb = m*b;
    long long count = 0;
    for(long long i = 0;i < n;i++){
      if(h[i] > bb){
        count += (h[i]-bb)/a;
        if((h[i]-bb)%a) count++;
      }
    }
    if(count > m){
      s = m;
    }
    else{
      e = m;
    }
  }
  cout << e << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    unordered_map<int, int> mp;
    rep(i, n) {
        int d;
        cin >> d;
        mp[d]++;
    }
    int m;
    cin >> m;
    rep(i, m) {
        int t;
        cin >> t;
        if (!mp.count(t) || mp[t] == 0) {
            cout << "NO" << endl;
            return 0;
        } else {
            mp[t]--;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 8520
from collections import Counter

N = int(input())
A = tuple(map(int, input().split(' ')))

counter = Counter(A)

patterns = 0
for value in counter.values():
    if value >= 2:
        patterns += value * (value - 1) // 2

for a in A:
    ans = patterns
    if counter[a] >= 2:
        ans -= counter[a] * (counter[a] - 1) // 2
    if counter[a] >= 3:
        ans += (counter[a] - 1) * (counter[a] - 2) // 2
    print(ans)


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

int main(){
  int a, b, c;
  
  cin >> a >> b >> c;
  
  if(a == c){
    cout << "YES" << endl;
  } else if(c - a > 0 && c - a < b){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin >>n;
  int arr[n+10];
  for(int  i = 0 ;  i<n ; i++) cin >>arr[i];
  sort(arr , arr + n);
  int ans = abs(arr[n-1] - arr[0]);
  cout<<ans;
}

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

vector<P> prime_factorize(int n) {
    vector<P> res;
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
  int n;
  ll mod = 1e9+7;
  cin >> n;
  vector<int>cnt(1e3+1,0);
  rep(i,1,n+1){
    vector<P>f = prime_factorize(i);
    rep(j,0,f.size()) cnt[f[j].first] += f[j].second;
  }
  ll ans = 1;
  rep(i,1,1e3+1) if(cnt[i] != 0) ans = (ans*(cnt[i]+1))%mod;
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int a,b,k;
int main()
{
	cin>>a>>b>>k;
	if(a+k-1<b-k+1)
	{
		for(int i=a;i<a+k;i++)
		{
			cout<<i<<endl;
		}
		for(int i=b-k+1;i<=b;i++)
		{
			cout<<i<<endl;
		}
	}
	else
	{
		for(int i=a;i<=b;i++)
		{
			cout<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

all_sum = sum(l)


minabs = float('INF')
a=all_sum
b=0
for i in range(n-2,-1,-1):
    a-=l[i+1]
    b+=l[i+1]

    target = abs(a-b)
    if(target<minabs):
        minabs=target
print(minabs)

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
int main()
{

    vector<int> v = {500, 100, 50};
    vector<int> c(3);
    for(int i = 0; i < 3; i++)
    {
        cin >> c[i];
    }
    int x;
    cin >> x;

    int count = 0;
    for(int i = 0; i <= c[0]; i++)
    {
        for(int j = 0; j <= c[1]; j++)
        {
            for(int k = 0; k <= c[2]; k++)
            {
                if(i * v[0] + j * v[1] + k * v[2] == x) count++;
            }
        }
    }
    cout << count << endl;
}




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

int main(void){
  string S;
  cin>>S;
  
  size_t size=S.length();
  if(S[size-1] == 's'){
   S=S+'e'; 
  }
  S=S+'s';
  cout<<S<<endl;
  return 0; 
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
BCList = list()

for x in range(M):
    BC = tuple(map(int, input().split()))
    BCList.append(BC)

BCList.sort(key=lambda x:x[1], reverse=True)
BCList.append((0,0))
i = 0
j = 0
answer = 0
count = 0

while count < N:
    if A[i] > BCList[j][1]:
        answer += A[i]
        i += 1
        count += 1
        continue
    if N - count < BCList[j][0]:
        answer += BCList[j][1] * (N-count)
        count += (N-count)
    else:
        answer += BCList[j][1] * BCList[j][0]
        count += BCList[j][0]
        j += 1

print(answer)

Measured memory_bytes: 22444
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

func Solve(){
  var K int
  NextInt(&K)
  A := make([]int, 0)
  for i := 1; i < 10; i++ {
    A = append(A, i)
  }
  for i := 0; len(A) < K; i++ {
    a := A[i]
    b := a % 10
    if 0 < b { A = append(A, a * 10 + b - 1) }
    A = append(A, a * 10 + b)
    if b < 9 { A = append(A, a * 10 + b + 1) }
  }
  fmt.Println(A[K - 1])
}

func main() {
  Solve()
  Output()
}

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

namespace abc059_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            string y = Console.ReadLine();
            if (x.Length == y.Length)
            {
                if (x == y) { Console.WriteLine("EQUAL"); }
                else
                {
                    for (int i = 0; i < x.Length; i++)
                    {
                        int a = int.Parse(x.Substring(i, 1));
                        int b = int.Parse(y.Substring(i, 1));
                        if (a > b) { Console.WriteLine("GREATER"); break; }
                        else { Console.WriteLine("LESS"); break; }
                    }
                }
            }
            else if (x.Length > y.Length)
            {
                Console.WriteLine("GREATER");
            }
            else { Console.WriteLine("LESS"); }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
int main(void) {
  int N, W;
  cin >> N >> W;
  vector<ll> wList, vList;
  rep(i, 1, N) {
    int wTmp, vTmp;
    cin >> wTmp >> vTmp;
    wList.push_back(wTmp);
    vList.push_back(vTmp);
  }

  vector<vector<ll>> dp(N + 10, vector<ll>(W + 10, 0));
  rep(i, 0, N) {
    rep(w, 0, W) {
      if (w >= wList[i])
        dp[i + 1][w] = max(dp[i][w], dp[i][w - wList[i]] + vList[i]);
      else
        dp[i + 1][w] = dp[i][w];
    }
  }

  // rep(i, 0, N) {
  //   rep(w, 0, W) { cout << dp[i][w] << " "; }
  //   cout << endl;
  // }
  cout << dp[N][W] << endl;

  return 0;
}


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

constexpr double EPS = 1e-10;
constexpr int COUNTER_CLOCKWISE = 1;
constexpr int CLOCKWISE = -1;
constexpr int ONLINE_BACK = 2;
constexpr int ONLINE_FRONT = -2;
constexpr int ON_SEGMENT = 0;

bool equals(double a, double b) { return (abs(a - b) < EPS); }

struct V2 {
	double x, y;
	V2(double x = 0, double y = 0) : x(x), y(y) {}

	V2 operator + (V2 p) const { return (V2(x + p.x, y + p.y)); }
	V2 operator - (V2 p) const { return (V2(x - p.x, y - p.y)); }
	V2 operator * (double r) const { return (V2(x * r, y * r)); }
	V2 operator / (double r) const { return (V2(x / r, y / r)); }

	double norm() const { return (sqrt(sqrNorm())); }
	double sqrNorm() const { return (x*x + y*y); }

	bool operator < (const V2 &p) const {
		return (x != p.x ? x < p.x : y < p.y);
	}
	bool operator == (const V2 &p) const {
		return (equals(x, p.x) && equals(y, p.y));
	}

	V2 rotate90() const { return (V2(y, -x)); }
	V2 normalized() const { return (*this / norm()); }

	double dot(const V2 &p) const { return (x*p.x + y*p.y); }
	double cross(const V2 &p) const { return (x*p.y - y*p.x); }
	double arg() const { return (atan2(y, x)); }
};

struct Line {
  V2 p1, p2;
  Line () {}
  Line (V2 p1, V2 p2) : p1(p1), p2(p2) {}
};

using Segment = Line;

double getDistanceLP(Line l, V2 p) {
  auto res = (abs((l.p2-l.p1).cross(p-l.p1) / (l.p2-l.p1).norm()));
  //cout << "a" << endl;
  //cout << res << endl;
  return res;
}

double getDistanceSP(Segment s, V2 p) {
  if ((s.p2-s.p1).dot(p-s.p1) < 0.0) return ((p-s.p1).norm());
  if ((s.p1-s.p2).dot(p-s.p2) < 0.0) return ((p-s.p2).norm());
  return (getDistanceLP(s, p));
}

int main() {
  int n;
  cin >> n;
  vector<pair<double, Segment>> circles(n);
  for (int i = 0; i < n; i++){
    double r, x1, y1, x2, y2;
    cin >> r >> x1 >> y1 >> x2 >> y2;
    circles[i] = (make_pair(r, Segment(V2(x1, y1), V2(x2, y2))));

  }
  vector<bool> dp(1 << n, false);
  dp[0] = true;
  int res = 0;
  for (int i = 1; i < dp.size(); i++){
    bool flag = false;
    int popcnt = 0;
    //from i - (1 << j) -> i
    for (int j = 0; j < n; j++){
      if (((i >> j) & 1) != 1) continue;
      popcnt++;
      if (flag || !dp[i - (1 << j)]) continue;
      //colision check
      for (int k = 0; k < n; k++){
        if (j == k) continue;
        auto r1 = circles[j].first;
        auto r2 = circles[k].first;
        auto distance = getDistanceSP
          (
           circles[j].second,
           ((i >> k) & 1) == 1 ?
           circles[k].second.p2 :
           circles[k].second.p1
           );
        //cout << distance << endl;
        if (distance < r1 + r2) goto dame;
      }
      //cout << "remove: " << j << endl;
      flag = true;
    dame:;
    }
    if (!flag) continue;
    //cout << i << endl;
    dp[i] = true;
    res = max(res, popcnt);
  }
  cout << res << endl;
}



Measured memory_bytes: 3232
#include<stdio.h>
#include<math.h>
#include<algorithm>

int main() {
	int n, x;
	while (1) {
		
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) {
			break;
		}

		
		int m = 0;
		for (int a = 1; a <= n; a++) {
			for (int b = 1; b < a; b++) {
				for (int c = 1; c < b; c++) {
					if (a + b + c == x) {
						m++;
					}
				}
			}
		}
		printf("%d\n", m);
	}
return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main() {
  char c; cin >> c;
  if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout <<
								   "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
// ABC144-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n,k;
    string t;
    map<char,ll> get={{'r',2},{'s',0},{'p',1}};
    cin>>n>>k;
    vector<bool> get_s(n,false);
    vector<ll> score(3);
    rep(i,3) cin>>score[i];
    cin>>t;
    ll total=0;
    rep(i,n){
        if(i<=k-1){
            total+=score[get[t[i]]];
            get_s[i]=true;
        }else{
            if(t[i]==t[i-k]){
                if(get_s[i-k]) continue;
                get_s[i]=true;
                total+=score[get[t[i]]];
            }else{
                total+=score[get[t[i]]];
                get_s[i]=true;
            }
        }
    }
    cout<<total<<endl;
    return 0;
}

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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e5 + 5);
const int inf = (1e9 + 7);

int n,w;
int a[N],b[N];
int dp[102][N];

main () {
    cin >> n >> w;

    for (int i = 1; i <= n; i ++) {
        cin >> a[i] >> b[i];
    }
    memset(dp,0x3f3f3f3f,sizeof(dp));

    for (int i = 1; i <= n; i ++)
        dp[i][0] = 0;

    dp[1][b[1]] = a[1];

    for (int i = 2; i <= n; i ++) {
        for (int j = b[i]; j < N; j ++) {
            dp[i][j] = min(dp[i][j],dp[i - 1][j - b[i]] + a[i]);
        }
        for (int j = 1; j < N; j ++) {
            dp[i][j] = min(dp[i][j],dp[i - 1][j]);
        }
    }
    for (int i = N - 1; i >= 1; i --) {
        if (dp[n][i] <= w) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 80128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] card = new int[3][3];
        int[][] hit = new int[3][3];
        for (int i =0;i<3;i++){
            for(int j = 0;j<3;j++){
                card[i][j] = sc.nextInt();
                hit[i][j] = 0;
            }
        }
        int n = sc.nextInt();
        for (int k =0; k<n;k++){
            int b = sc.nextInt();
            for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                    if(card[i][j] == b){
                        hit[i][j]= 1;
                    }
                }
            }
        }
        int flag=0;
        for (int i=0;i<3;i++){
            if(hit[i][0] == 1 && hit[i][1] == 1 && hit[i][2] == 1) {
                flag = 1;
            }
            if(hit[0][i] ==1 && hit[1][i] == 1 && hit[2][i] == 1) {
                flag = 1;
            }
        }
        if (hit[0][0] == 1 && hit[1][1] == 1 && hit[2][2] == 1) {
            flag = 1;
        }
        if (hit[2][0] == 1 && hit[1][1] == 1 && hit[0][2] == 1) {
            flag =1;
        }
        if (flag == 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int cnt;
int m;
vector<int> v;
	
void insertionSort(int A[], int n, int g) {
	int i,j,tmp;
	for (i = g;i < n;i++) {
		tmp = A[i];
		j = i - g;
		while (j >= 0 && A[j] > tmp) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = tmp;
	}
}

void shellSort(int A[], int n) {
    cnt=0;
    int val=1;
    do{
        v.push_back(val);
        val=val*3+1;
        m++;
    }while(val<n);
	for(int i = 0;i < m;i++)
		insertionSort(A, n, v[m-1-i]);
}

int main() {
	int A[1000000];
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) cin >> A[i];
	shellSort(A, n);
	
	cout << m << endl;
	for (int i = 0;i < m;i++) {
		if (i) cout << " ";
		cout << v[m - 1 - i];
	}
	cout << endl<<cnt<<endl;
	for (int i = 0;i < n;i++) cout << A[i] << endl;

    return 0;
}

Measured memory_bytes: 6960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

template <class T>
class CuSum {
private:
	vector<T> cusum;
	void init(vector<T> &vec) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }

public:
	CuSum(vector<T> &vec) : cusum(vec.size() + 1) { init(vec); }
	T query(int l, int r /*[l, r) */) { return cusum[r] - cusum[l]; }
};

int main() {

	cin.tie(0);

	int N;
	cin >> N;

	vector<int> S(N);
	char tmp;
	
	for (int i = 0; i < N; i++) {

		cin >> tmp;
		if (tmp == '.') S[i] = 0;
		else S[i] = 1;
	}

	CuSum<int> cul(S);
	int ans = INF, changes;
	for (int i = 0; i < N; i++) {

		changes = cul.query(0, i) + (N - 1 - i - cul.query(i + 1, N));
		ans = min(ans, changes);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
    int number;
    scanf("%d",&number);
    double kazu[number];
    double kazuneo[number];
    double goukei;
    for(int i=0;i<number;i++){
        scanf("%lf",&kazu[i]);
        kazuneo[i]=1/kazu[i];
        goukei+=kazuneo[i];
    }
    printf("%lf",1/goukei);
    return 0;
}

Measured memory_bytes: 128
def solve():
    h, w = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(h)]
    ans = []
    for i in range(h):
        for j in range(w):
            if l[i][j] % 2:
                if j == w-1:
                    if i == h-1:
                        continue
                    else:
                        l[i+1][j] += 1
                        ans.append('{} {} {} {}'.format(i+1, j+1, i+2, j+1))
                else:
                    l[i][j+1] += 1
                    ans.append('{} {} {} {}'.format(i+1, j+1, i+1, j+2))
    print(len(ans))
    for i in ans:
        print(i)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16380
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    ll sum = accumulate(all(a),0LL);
    map<int,int> mp;
    rep(i,n) mp[a[i]]++;
    int q;
    cin >> q;
    rep(_,q) {
        int b,c;
        cin >> b >> c;
        sum += ll(c-b)*mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << " \n";
    }
}

Measured memory_bytes: 8004
#include<bits/stdc++.h>
#define st first
#define nd second 

using  namespace std;
using pii = pair<int, int>;
using ll = long long;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	printf("%d", n * (n-1) / 2 + m * (m-1)/2);

}

Measured memory_bytes: 256
S = list(input())
Q = int(input())
Qu= [list(input().split()) for _ in range(Q)]

r = 0

B = []
A = []

for i in range(Q):
  if int(Qu[i][0]) == 1:
    r = 1 - r
  else:
    F = int(Qu[i][1])
    C = Qu[i][2]
    F -= 1
    if F == r:
      B.append(C)
    else:
      A.append(C)

if r == 0:
  B.reverse()
  print("".join(B + S + A))
else:
  A.reverse()
  S.reverse()
  print("".join(A + S + B))


Measured memory_bytes: 36608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 998244353;


int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	vector<int>v(N);
	map<int,int>mp;
	for(int i=0;i<N;++i){
		cin>>v[i];
		mp[v[i]]++;
	}

	bool ok=false;
	if(N%3==0){
		if(mp.size()==1){
			if(v[0]==0)ok=true;
		}else if(mp.size()==2){
			bool aok=true;
			vector<int>nums(2);
			for(auto m:mp){
				if(m.first==0){
					if(m.second==N/3)continue;
				}else{
					if(m.second==N/3*2)continue;
				}
				aok=false;
			}

			ok|=aok;
		}else if(mp.size()==3){
			bool aok=true;
			vector<int>nums;
			for(auto m:mp){
				nums.push_back(m.first);
				if(m.second!=N/3)aok=false;
			}
		
			if((nums[0] ^ nums[1])!=nums[2])aok=false;

			ok|=aok;
		}
	}
	if(mp[0]==N)ok=true;
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}	

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define Mod 1000000007ll
#define Val(x) (((long long)x) % Mod)
using namespace std;
int n,x,y,z;
vector<int> states[10];
void build(int state,int sum) {
	if(sum > 7)	return;
	if(sum > 0)
		states[sum].emplace_back(state);
	for(int i=1;i<=7;i++)
		build((state<<i) | (1<<(i-1)),sum + i);
}
bool ban[1<<17];
int dp[45][1<<17];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> x >> y >> z;
	
	build(0,0);
	for(int X : states[x])
		for(int Y : states[y])
			for(int Z : states[z])
				ban[(X<<(y+z)) | (Y<<z) | Z] = true;
	
	int full = (1<<(x+y+z)) - 1;
	dp[0][0] = 1;
	for(int i=1;i<=n;i++)
		for(int state=0;state<=full;state++)
			if(!ban[state] && dp[i-1][state] != 0)
				for(int j=1;j<=10;j++) {
					int nxt_state = ((state<<j) | (1<<(j-1))) & full;
					dp[i][nxt_state] = Val(dp[i][nxt_state] + dp[i-1][state]);
				}
	int ans = 1;
	for(int i=1;i<=n;i++)
		ans = Val(ans * 10);
	for(int state=0;state<=full;state++)
		if(!ban[state])
			ans = Val(ans - dp[n][state]);
	ans = Val(ans + Mod);
	cout << ans << endl;
	return 0;
}

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

const int mod=1e9+7;
const int maxn=2e5+100;

int a[maxn];

int main()
{
    /*
    int n,k;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int tot=unique(a,a+n)-a;
    if(tot==n)
        printf("YES\n");
    else
        printf("NO\n");*/
    string s[3];
    cin>>s[0]>>s[1];
    int x,y;
    cin>>x>>y;
    cin>>s[2];
    if(s[1]==s[2])
        y--;
    if(s[0]==s[2])
        x--;
    cout<<x<<" "<<y;
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A, B, M;
int main() {
  cin >> A >> B >> M;
  int a[A], b[B];
  int minA = 1e9;
  int minB = 1e9;
  for (int i = 0; i < A; i++) {
    cin >> a[i];
    minA = min(minA, a[i]);
  }
  for (int i = 0; i < B; i++) {
    cin >> b[i];
    minB = min(minB, b[i]);
  }
  int ans = minA + minB;

  int x, y, c;
  for (int i = 0; i < M; i++) {
    cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
# 1 "j.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "j.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "j.cpp" 2

long long n;
long double dp[(long long)3e2+1][(long long)3e2+1][(long long)3e2+1];

long double solve(long long a, long long b, long long c){
    long double &res = dp[a][b][c];
    if(res + 1e-9 < 0){
        res = n;
        if(a)
            res += a*solve(a-1, b+1, c);
        if(b)
            res += b*solve(a, b-1, c+1);
        if(c)
            res += c*solve(a, b, c-1);
        res /= (a + b + c);
    }
    return res;
}

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    long long a = 0, b = 0, c = 0;
    for(long long i=0; i<n; ++i){
        long long x;
        cin >> x;
        if(x == 3)
            a++;
        else if(x == 2)
            b++;
        else
            c++;
    }
    for(long long i=0; i<3e2+1; ++i){
        for(long long j=0; j<3e2+1; ++j){
            for(long long k=0; k<3e2+1; ++k)
                dp[i][j][k] = -1;
        }
    }
    dp[0][0][0] = 0;
    cout << fixed << setprecision(15) << solve(a, b, c) << "\n";
    return 0;
}


Measured memory_bytes: 426368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll n;
    cin >> n;
    long double ans = 1;
    int flag = 0;
    vector<long double> data(n);
    rep(i, n)
    {
        cin >> data[i];
    }
    sort(data.begin(), data.end());
    rep(i, n)
    {

        ans *= data[i];
        if (ans > 1000000000000000000)
        {
            flag = 1;
            cout << "-1" << endl;
            break;
        }
    }
    if (flag == 0)
    {
        cout << (ll)ans << endl;
    }
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
void meal(int x,int a,int b){
       if(abs(x-a)<abs(x-b)){
        cout<<"A"<<endl;
       }
       if(abs(x-b)<abs(x-a)){
        cout<<"B"<<endl;
       }
}
int main(){
   int x,a,b;
   cin>>x>>a>>b;
   meal(x,a,b);
   return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){
    ll a, b;
    cin >> a >> b;
    if (b % a == 0){
        cout << a+b << endl;
    }else{
        cout << -a+b << endl;
    }
    return 0;
}

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int N;

    cin >> N;

    string s;
    while(N){
        if(N % 2){
            s += '1';
            N--;
        }else{
            s += '0';
        }
        N /= (-2);
    }
    reverse(s.begin(),s.end());

    if(s == "") cout << 0 << endl;
    else cout << s << endl;

    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

bool a[100][100];

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    int n,m,i,j;
    cin >> n >> m;
    for (i,0,n)
    {
        cin >> s;
        for (j,0,m)
            a[i][j]=(s[j]-'.');
    }
    int dp[100][100];
    dp[0][0]=a[0][0];
    for (i,1,n)
    {
        dp[i][0]=dp[i-1][0];
        if (a[i][0] && !a[i-1][0])
            dp[i][0]++;
    }
    for (j,1,m)
    {
        dp[0][j]=dp[0][j-1];
        if (a[0][j] && !a[0][j-1])
            dp[0][j]++;
    }
    for (i,1,n)
        for (j,1,m)
    {
        int q = dp[i-1][j];
        if (a[i][j] && !a[i-1][j])
            q++;
        int p = dp[i][j-1];
        if (a[i][j] && !a[i][j-1])
            p++;
        dp[i][j]=min(q,p);
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define reps(i,s,n) for(long long i=s;i<n;i++)
using namespace std;
const long long mod = (long long)(1E9) + 7LL;
long long dgtdp(int k, bool t, int md, int& d, string& s, vector<vector<vector<long long>>>& memo) {
	if (memo[k][t][md] != -1) return memo[k][t][md];
	if (k == s.size()) return md == 0;
	int x = s[k] - '0';
	int lim = (t) ? x : 9;
	long long ret = 0;
	for (int i = 0; i <= lim; i++) {
		ret += dgtdp(k + 1, t and (i == lim), (md + i) % d, d, s, memo);
		ret %= mod;
		memo[k][t][md] = ret;
	}
	return ret;
}

int main(void) {
	string s;
	int d;
	cin >> s >> d;
	vector<vector<vector<long long>>> memo(s.size() + 1, vector<vector<long long>>(2, vector<long long>(d, -1LL)));
	cout << (dgtdp(0, true, 0, d, s, memo)+mod - 1)%mod << endl;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
constexpr int IINF = numeric_limits<int>::max();
constexpr long LINF = numeric_limits<long>::max();
constexpr int MOD = (int) 1e9 + 7;
// constexpr int MOD = 998244353;

int main(){
    int n;
    cin >> n;
    long ans = 0;
    for (size_t i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let l = s.len();
    let c = s.chars().filter(|&x| x == '0').count();
    println!("{}", 2 * std::cmp::min(l- c, c));
}


Measured memory_bytes: 2264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

string S, T;
int N;

bool sub(int k) {
	rep(i, N) {
		if (S.at(i) != T.at((i + k) % N)) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> S >> T;
	N = S.size();
	bool f = false;
	rep(k, N) {
		if (sub(k)) {
			f = true;
			break;
		}
	}
	Yn(f);
}

Measured memory_bytes: 256