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

int main() {
    string s;
    cin >> s;
    vector<int> ok(4, 0);
    for (auto c : s) {
        if (c == 'N') ok[0]++;
        if (c == 'E') ok[1]++;
        if (c == 'W') ok[2]++;
        if (c == 'S') ok[3]++;
    }
    
    bool a = true, b = true;
    if (ok[0] == 0 && ok[3] != 0) a = false;
    if (ok[0] != 0 && ok[3] == 0) a = false;
    if (ok[1] == 0 && ok[2] != 0) b = false;
    if (ok[1] != 0 && ok[2] == 0) b = false;
    
    cout << ((a&&b) ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
 int a,b;
  cin>>a>>b;

  if(a%3!=0&&b%3!=0&&(a+b)%3!=0){
    cout<<"Impossible"<<endl;
  }
  else{
    cout<<"Possible"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; ++i)
        cout <<i << ' ';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  priority_queue<lli> P;
  rep(i,0,N){
    cin >> M;
    P.push(M);
  }
  rep(i,0,K){
    X=P.top();P.pop();
    P.push(X/2);
  }
  while(!P.empty()){
    sum+=P.top();P.pop();
  }
  Out(sum);
}


Measured memory_bytes: 1400
from operator import itemgetter
import copy

data = []


for n in range(int(input())):
	data.append(input().split(" "))


for n in range(len(data)):
	data[n][1] = int(data[n][1])

base = copy.deepcopy(data)

data.sort(key=itemgetter(1),reverse=True)

data.sort(key=itemgetter(0))

for n in range(len(data)):
	print(base.index(data[n])+1)

Measured memory_bytes: 3560
#include <iostream>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cstdio>
#include <bitset>
using namespace std;


int main() {
	int n,mx = 0,count = 1;
	cin >> n;

	vector<int> v(n);

	for (int i = 0; i < n; i++) cin >> v[i];

	sort(v.begin(), v.end());

	for (int i = 0; i < n; i++)
	{
		int temp = upper_bound(v.begin(), v.end(), v[i] + 2) - v.begin();
		temp--;

		if (temp - i + 1 > mx) mx = temp - i + 1;
	}

	cout << mx << endl;
	return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X){
    cin >> A[i];
  }
  REP(i, Y){
    cin >> B[i];
  }
  REP(i, Z){
    cin >> C[i];
  }
  vector<ll> AB;
  REP(i, X){
    REP(j, Y){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.rbegin(), AB.rend());
  sort(C.rbegin(), C.rend());
  vector<ll> ans;
  REP(i, min(K, X*Y)){
    REP(j, min(K, Z)){
      ans.push_back(AB[i]+ C[j]);
    }
  }
  sort(ans.rbegin(), ans.rend());
  REP(i, K){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 43368
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const ld PI = acos((ld)-1);

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	ld ang = (ld)(360 * (abs((h/12 + m/(60*12)) - m/60)));
	ang = min(ang, 360 - ang);
	ld c = sqrtl(sq(b) + sq(a) - 2 * b * a * cos((ld)(ang * (ld)(PI / 180))));
	cout << fixed << setprecision(20) << c << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4184
/* 
 * Author: Priyadarshini
 */
 
/*
 * Run in Mac using the following command:
 * g++ -std=c++14 <cpp_filename>
 * A binary will be generated. Then run:
 * ./a.out
 */
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <fstream>
#include <cstring>
 
using namespace std;
typedef long long int ll;
 
// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>
 
// Global //
 
 
// Functions //

// Main //
int main()
{
    ll a;
    cin >> a;
    cout << a * a;



 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(0, min(b, d) - max(a, c)) << endl;


  
  return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;
template<size_t SIZE, class T> inline size_t array_size(T (&arr)[SIZE]) {
    return SIZE;
}


int main() {
    int R,G,B,N;
#if LOCAL&0
  	std::ifstream in("input.txt");
  	std::cin.rdbuf(in.rdbuf());
#endif
    cin>>R>>G>>B>>N;
    auto calc = [&](int r,int g, int b){
        return (r*R+g*G+b*B==N);
    };
    int rmax = N/R;
    //int gmax = N/G+1;
    //int bmax = N/B+1;
    int ans =0;
    for (int r=0;r<=rmax;++r) {
        int rnum=r*R;
        int gmax=(N-rnum)/G;
		for(int g = 0; g <= gmax; ++g) {
            int rgnum=g*G+rnum;
            int bmax=(N-rgnum)/B;
            int rest = N-rgnum;
            if (rest >= 0 && rest%B==0) {
                //cout << r << "," << g << ","<< rest/B <<endl;
                ans += 1;//max(rest/B,1);
            }
			// for(int b = 0; b <= bmax; ++b) {
            //     int rgbnum=b*B+rgnum;
            //     ans += (rgbnum==N);
            //     //ans += calc(r,g,b);
			// }
		}
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

int s;
set<int> S;

int f(int n) {
    if (n % 2 == 1) {
        return 3 * n + 1;
    } else {
        return n / 2;
    }
}

int main() {
    scanf("%d", &s);

    S.insert(s);

    for (int i = 0; i < INF; i++) {
        s = f(s);

        if (S.count(s)) {
            printf("%d\n", i + 2);
            return 0;
        } else {
            S.insert(s);
        }
    }

    return 0;
}

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

arr = []
for t in range(n):
    s1 = []
    s2 = []
    for i in range(n):
        if i <= t:
            s1.append(w[i])
        else:
            s2.append(w[i])

    arr.append(abs(sum(s1) - sum(s2)))

print(min(arr))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1'000'000'007
#define endl '\n'
using namespace std;
int N,K;
int m[111111];
long long inv[111111];
long long fact[111111]={1};
long long infact[111111]={1};

long long init(int i){
    if(inv[i]==-1){
        inv[i] = 1LL * (MOD-MOD/i) * init(MOD%i);
        inv[i] %= MOD;
    }
    return inv[i];
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>N;
    for(int i=1;i<=N;i++){
        int x;
        cin>>x;
        if(m[x]){
            K=N-(i-m[x]);
            break;
        }
        m[x]=i;
    }
    fill(inv,inv+N+2,-1);
    inv[1]=1LL;
    for(int i=1;i<=N+3;i++)init(i);
    for(int i=1;i<=N+3;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
    }
    for(int i=1;i<=N+3;i++){
        infact[i]=infact[i-1]*inv[i];
        infact[i]%=MOD;
    }
    for(int i=1;i<=N+1;i++){
        // C(n+1,i) - C(x,i-1);
        long long a=fact[N+1]*infact[i]%MOD*infact[N+1-i]%MOD;
        if(K>=i-1){
            cout<<(a+MOD-fact[K]*infact[i-1]%MOD*infact[K-i+1]%MOD)%MOD<<endl;
        }
        else{
            cout<<a<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3968
n = int(input())
num_list = [ int(v) for v in input().split() ]

ans_list = [ 0 for i in range(10**5+2) ]

for i in num_list:
    ans_list[i] += 1
    ans_list[i+1] += 1
    ans_list[i+2] += 1

print(max(ans_list))

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(1 << n);
	for (int i = 0;i < 1 << n;++i) cin >> a[i];
	vector<pair<int,int>> mx(1 << n);
	for (int i = 0;i < 1 << n;++i) {
		vector<int> now;
		now.emplace_back(i);
		for (int j = 0;j < n;++j) {
			if (i >> j & 1) {
				int mask = i ^ (1 << j);
				now.emplace_back(mx[mask].first);
				if (mx[mask].second != -1) now.emplace_back(mx[mask].second);
			}
		}
		sort(now.begin(),now.end(),[&](int i,int j) {return a[i] > a[j];});
		now.resize(unique(now.begin(),now.end()) - now.begin());
		if ((int)now.size() == 1) mx[i] = {now[0],-1};
		else mx[i] = {now[0],now[1]};
	} 
	int ans = 0;
	for (int i = 1;i < 1 << n;++i) {
		ans = max(ans,a[mx[i].first] + a[mx[i].second]);
		//cout << mx[i].first <<" " << mx[i].second <<' ';
		cout << ans <<"\n";
	}
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	ll N, D;
	cin >> N >> D;

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x, y, ans;
int32_t main () {
    cin >> x >> y;
    int cur = x;
    ans = 1;
    while (cur * 2 <= y) {
	ans++;
	cur *= 2;
    }
    cout << ans << endl;
}


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(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> v;
  string s;
  REP(i,3){
    cin >> s;
    v.push_back(s);
  }
  int i = 0;
  while(v[i].size()!=0){
    int old = i;
    i = v[i][0] - 'a';
    v[old].erase(0,1);
  }
  cout << "ABC"[i] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,max,cnt,i;
	scanf("%d",&n);
	cnt=1;
	max=0;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a==1){
			cnt++;
		}
		if(cnt>max){
			max=cnt;
		}
		if(a==0){
			cnt=1;
		}
	}
	printf("%d\n",max);
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  string ans = "";

  while(N > 0){
    ans.insert(ans.begin(), 'a' + ((N-1) % 26));
    N = (N-1) / 26;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3616
N = int(input())
H = [int(i) for i in input().split()]

H_shifted = [0 for i in range(N)]

h_n_1 = 0
is_break = False
for i, h_i in enumerate(H):
    if h_n_1 > h_i:
        if H_shifted[i - 1] == 0:
            h_n_1 -= 1
        if h_n_1 > h_i:
            is_break = True
            break
        else:
            # ここでは同じ高さになっているはずで、これ以上下げられない
            H_shifted[i] = 1
    if h_n_1 == h_i:
        # 同じ高さになっているはずで、これ以上下げられない
        H_shifted[i] = 1
    if h_n_1 < h_i:
        # 低くできる場合にはしておく
        H_shifted[i] = 1
        h_n_1 = h_i - 1
    else:
        h_n_1 = h_i


if is_break:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 14224
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y//be careful from the multiplication while using this define 
#define TC int t;cin>>t;while(t--)
//</DEFINE>
int n, m;
vector<vector<int>>v;
//<FUNCTIONS>
//</FUNCTIONS>	
int main() {
	Fast();
	int n, cpcty;
	cin >> n >> cpcty;
	vector<vector<ll>>dp(n, vector<ll>(cpcty + 1));
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	for (int i = v[n - 1].first; i <= cpcty; i++)dp[n - 1][i] = v[n - 1].second;
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 1; j <= cpcty; j++) {
			if (j >= v[i].first)dp[i][j] = max(dp[i + 1][j - v[i].first] + v[i].second, dp[i + 1][j]);
			else dp[i][j] = dp[i + 1][j];
		}
	}
	cout << dp[0][cpcty] << endl;
}

Measured memory_bytes: 82188
// C - Green Bin
// https://atcoder.jp/contests/abc137/tasks/abc137_c
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	anagram_map := map[string]int{}
	for i := 0; i < n; i++ {
		si := nextString(sc)
		si = SortString(si)
		if _, ok := anagram_map[si]; ok {
			anagram_map[si]++
		} else {
			anagram_map[si] = 1
		}
	}

	res := 0
	for _, value := range anagram_map {
		res += (value * (value - 1)) / 2 // nC2 = (n * n-1) / 2
	}

	fmt.Println(res)
}

func SortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int intcat( int i, int j ) 
{
int k;

stringstream s;

s << i;
s << j;

s>>k;
return( k );
}

int main() {
int i;
int j;
 cin >> i >> j;
int k;
k=intcat(i,j);
 int t = 1;
 bool f = false;
 while(t*t <= k){
   if(t*t == k){
     f = true;
     break;
   }
   t++;
     
 }
 if(f)
   cout << "Yes" << endl;
 else
   cout << "No" << endl;

return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(void){
  int n,i,a;
  set<int> s;
  set<int>::iterator ite;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    ite=s.find(a);
    if (ite==s.end()) s.insert(a);
    else s.erase(a);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long double a,b;
	cin>>a>>b;
	if(b==0||a==0)
	{
		cout<<0<<endl;
		return 0;
	}
	a*=b;
	unsigned long long c=floor(a);
	cout<<c<<endl;
	return 0;
}




Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main(){
    char a[3];
    scanf("%c",&a[0]);  
    scanf("%c",&a[1]);  
    scanf("%c",&a[2]);  
    for(int i = 0; i < 3; i++){
        if(a[i] == '1')
            cout << 9;
        else
            cout << 1;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define infinity 1000000000
int max(int a,int b){
    return a>b?a:b;
}
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    int dp[n][3],a[n][3];
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
        dp[i][0]=0,dp[i][1]=0,dp[i][2]=0;
    }
    dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i][k]);
            }
        }
    }
    for(int i=0;i<3;i++)
    ans=max(ans,dp[n-1][i]);
    printf("%d",ans);
}

Measured memory_bytes: 4040
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        m: usize,
        mut e: [(usize, usize); m],
    }
    let mut cnt = vec![0; n];
    for e in e.iter_mut() {
        e.0 -= 1;
        e.1 -= 1;
        cnt[e.0] += 1;
        cnt[e.1] += 1;
    }
    let mut buf = vec![0usize; 2 * m];
    let mut buf = buf.as_mut_slice();
    let mut g = Vec::with_capacity(n);
    for c in cnt.iter() {
        let (x, y) = buf.split_at_mut(*c);
        g.push(x);
        buf = y;
    }
    for (a, b) in e {
        cnt[a] -= 1;
        g[a][cnt[a]] = b;
        cnt[b] -= 1;
        g[b][cnt[b]] = a;
    }
    let mut prev = vec![n; n];
    prev[0] = 0;
    let mut q = std::collections::VecDeque::with_capacity(n);
    q.push_back(0);
    while let Some(v) = q.pop_front() {
        for &u in g[v].iter() {
            if prev[u] == n {
                prev[u] = v;
                q.push_back(u);
            }
        }
    }
    println!("Yes");
    for p in prev.iter().skip(1) {
        println!("{}", *p + 1);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 12880
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define pb push_back
map<vector<int>,int> m;
vector<int> perm[6000];
int dp[110][6000],next[6000][110],D[110],A[110];
int N;
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)scanf("%d",&D[i]);
	for(int i=1;i<=N;i++)scanf("%d",&A[i]);
	vector<int> v;
	int cnt = 0;
	for(int i=0;i<7;i++)v.pb(i);
	do{
		perm[cnt]=v;
		m[v]=cnt++;
	}while(next_permutation(v.begin(),v.end()));
	for(int i=0;i<5040;i++)
	{
		vector<int> t;
		for(int j=0;j<8;j++)
		{
			int cnt = 0;
			vector<int> t,vec;
			for(int k=0;k<8;k++)
			{
				if(k==j)t.pb(0);
				else t.pb(perm[i][cnt++]+1);
			}
			for(int k=0;k<8;k++)
			{
				if(t[k]==7)continue;
				vec.pb(t[k]);
			}
			next[i][j]=m[vec];
		}
	}
	for(int i=1;i<N;i++)
	{
		for(int j=0;j<5040;j++)
		{
			//if(dp[i][j]!=0)cout << dp[i][j] << ' ';
			for(int k=0;k<8;k++)
			{
				int up=0;
				for(int l=k;l<7;l++)
				{
					if(i-perm[j][l]<=0)continue;
					if(abs((i-perm[j][l])-(i+1))<=D[i+1])up+=A[i+1];
				}
				for(int l=0;l<k;l++)
				{
					if(i-perm[j][l]<=0)continue;
					if(abs((i-perm[j][l])-(i+1))<=D[i-perm[j][l]])up+=A[i-perm[j][l]];
					//if(i-perm[j][l]+D[i-perm[j][l]]<=i)up-=A[i-perm[j][l]];
				}
				dp[i+1][next[j][k]]=max(dp[i+1][next[j][k]],dp[i][j]+up);
			}
		}
		//cout << endl;
	}
	int ans = 0;
	for(int i=0;i<5040;i++)ans = max(ans,dp[N][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7168
L, R = map(int, input().split())
ans = 2018
END = False

for i in range(2019):
    j = i + 1
    while j <= R-L:
        ans = min( ((L+i)*(L+j)) % 2019, ans)
        j += 1
        if ans == 0:
            END = True
            break
    if END or i > R-L:
        break

print(ans)

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

void dfs(ll x,bool a,bool b,bool c){
    if(x>n)return;
    if(a&b&c&1)ans++;
    dfs(x*10+3,1,b,c);
    dfs(x*10+5,a,1,c);
    dfs(x*10+7,a,b,1);
}

void solve() 
{
    cin>>n;dfs(0,0,0,0);cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long T1, T2, A1, A2, B1, B2;
int main() {
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    long long SA = A1*T1 + A2*T2;
    long long SB = B1*T1 + B2*T2;
    if(SA == SB) cout << "infinity";
    else if((SA > SB && A1 > B1) || (SA < SB && A1 < B1)) cout << 0;
    else {
        long long ds = abs(SA - SB);
        long long rd = abs(A1 - B1) * T1;
        long long ans = (rd / ds) * 2;
        if(rd % ds) ans++;
        cout << ans;
    }
}

Measured memory_bytes: 256
import math
INF = 1001001001
h, n = map(int, input().split())
ab = list(list(map(int, input().split())) for _ in range(n))

dp = [INF] * (h+1)
dp[0] = 0
for i in range(n):
    for j in range(h):
        nj = min(j+ab[i][0], h)
        dp[nj] = min(dp[nj], dp[j]+ab[i][1])

print(dp[h])


Measured memory_bytes: 42988
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

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

    vector<long long> v(n * 3);
    rep(i,n * 3) cin >> v[i];
    sort(all(v),greater<long long>());

    long long sum = 0;
    int c = 1;
    rep(i,n){
        sum += v[c];
        c+=2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
ans = []
for i in range(X):
	for j in range(min(Y,K//(i+1)+1)):
		for k in range(min(Z,K//((i+1)*(j+1))+1)):
			ans.append(A[i]+B[j]+C[k])

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])

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

long long tree[2005][2005];

long long N, A, B, C, D;

const int factors[] = {2, 3, 5};

map<long long, long long> m;

long long dp(long long x){
    if(x == 0){return 0;}
    if(x == 1){return D;}
    if(m.find(x) != m.end()){ return m[x]; }

    long long ans = 1LL << 61;
    if((double)x*D < 1.02e18){
        ans = min(ans, x*D);
    }
    long long prevMul2 = x/2*2;

    if((double)(x-x/2)*D < 1.03e9){
        ans = min(ans, D*abs(prevMul2-x)+min(A, (x-x/2)*D) + dp(x/2));
        if(prevMul2 != x){
            ans = min(ans, D*abs(prevMul2+2-x)+min(A, (x-x/2)*D) + dp(1+x/2));
        }
    }else{
        ans = min(ans, D*abs(prevMul2-x)+A + dp(x/2));
        if(prevMul2 != x){
            ans = min(ans, D*abs(prevMul2+2-x)+A + dp(1+x/2));
        }
    }

    long long prevMul3 = x/3*3;
    if((double)(x-x/3)*D < 1.03e9){
        ans = min(ans, D*abs(prevMul3-x)+min(B, (x-x/3)*D) + dp(x/3));
        if(prevMul3 != x){
            ans = min(ans, D*abs(prevMul3+3-x)+min(B, (x-x/3)*D) + dp(1+x/3));
        }
    }else{
        ans = min(ans, D*abs(prevMul3-x)+B + dp(x/3));
        if(prevMul3 != x){
            ans = min(ans, D*abs(prevMul3+3-x)+B + dp(1+x/3));
        }
    }

    long long prevMul5 = x/5*5;
    if((double)(x-x/5)*D < 1.03e9){
        ans = min(ans, D*abs(prevMul5-x)+min(C, (x-x/5)*D) + dp(x/5));
        if(prevMul5 != x){
            ans = min(ans, D*abs(prevMul5+5-x)+min(C, (x-x/5)*D) + dp(1+x/5));
        }
    }else{
        ans = min(ans, D*abs(prevMul5-x)+C + dp(x/5));
        if(prevMul5 != x){
            ans = min(ans, D*abs(prevMul5+5-x)+C + dp(1+x/5));
        }
    }

    return m[x] = ans;
}

int main(){
    int T;
    scanf("%d", &T);

    while(T --){
        scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);

        m.clear();
        printf("%lld\n", dp(N));
    }

    return 0;
}


Measured memory_bytes: 4520
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def euqrid(a, b):
    if a > b:
        large = a
        small = b
    else:
        large = b
        small = a

    if small == 0:
        return large
    return euqrid(small, large % small)


def calc_m(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        a = numbers.pop()
        b = numbers.pop()
        e = euqrid(a, b)
        return a * b // e
    a = numbers.pop()
    b = calc_m(numbers)
    e = euqrid(a, b)
    return a * b // e


def solve(inputs):
    clocks = inputs
    return calc_m(clocks)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(int_inputs(N))
    print(ret)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  string s;;
  cin >> s;
  int even = 0;
  int odd = 0;
  REP(i,s.size()){
    if (i%2==0){
      if (s.at(i) == '1'){
        even++;
      }
    }else{
      if (s.at(i) == '1'){
        odd++;
      }
    }
  }
  if (s.size()%2 == 0){
    int t1 = s.size()/2 - even + odd;
    int t2 = s.size()/2 - odd + even;
    cout << min(t1,t2) << endl;
  }else{
    int t1 = s.size()/2 + 1 - even + odd;
    int t2 = s.size()/2 - odd + even;
    cout << min(t1,t2) << endl;
  }
  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int mx = max(a, max(b, c));
    cout << mx*9+a+b+c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  regex re(R"([ACGT]+)");

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    smatch m;
    string sub = s.substr(i);
    regex_search(sub, m, re);

    int len = m.str().size();

    ans = max(ans, len);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
n = int(input())
a = []
b = []
for i in range(n):
  for j in range(i+1, n):
    a.append([i+1, j+1])
if n % 2 == 0:
  for i in range(len(a)):
    if a[i][0] + a[i][1] != n + 1:
      b.append(a[i])
else:
  for i in range(len(a)):
    if a[i][0] + a[i][1] != n:
      b.append(a[i])
m = len(b)
print(m)
for i in range(m):
  print(b[i][0], b[i][1])


Measured memory_bytes: 4124
#include<iostream>

using namespace std;

bool isPrime (int x) {
    for(int i=2; i*i <=x; i++) {
        if(x%i==0) return false;
    }
    return true;
}

int N;
int main () {
    cin >> N;
    long long int ans = 1;
    for(int i=2; i<=N; i++) {
        if(isPrime(i)) {
            long long int r = 1;
            for(int x=N; x/=i; r+=x);
            ans = ans * r % 1000000007;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k, l, p, q, r, s, road[200100], train[200100];
const ll INF = 1000000000000000;
map<P, ll> mp;
vector<ll> roa[200100], tra[200100];

void dfsr(ll x, ll y){
    road[x] = y;
    for (ll i = 0; i < roa[x].size(); i++){
        if (road[roa[x][i]] == INF) dfsr(roa[x][i], y);
    }
}

void dfst(ll x, ll y){
    train[x] = y;
    for (ll i = 0; i < tra[x].size(); i++){
        if (train[tra[x][i]] == INF) dfst(tra[x][i], y);
    }
}

int main(void){
    // Your code here!
    cin >> n >> k >> l;
    for (ll i = 1; i <= n; i++) road[i] = INF, train[i] = INF;
    for (ll i = 0; i < k; i++){
        cin >> p >> q;
        roa[p].push_back(q);
        roa[q].push_back(p);
    }
    for (ll i = 0; i < l; i++){
        cin >> r >> s;
        tra[r].push_back(s);
        tra[s].push_back(r);
    }
    for (ll i = 1; i <= n; i++){
        if (road[i] == INF) dfsr(i, i);
        if (train[i] == INF) dfst(i, i);
    }
    for (ll i = 1; i <= n; i++){
        mp[P(road[i], train[i])]++;
    }
    for (ll i = 1; i <= n; i++){
        cout << mp[P(road[i], train[i])] << ' ';
    }
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int MOD = 1e9+7;
void add(int &a,int b) { a = (a + b + MOD) % MOD; }

signed main(){

  int n; cin >> n;
  static int dp[101][4][4][4];
  //{A,C,G,T}
  //{" AGC","A*GC"," GAC","ACG","AG*C"}
  dp[0][0][0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        for(int l = 0; l < 4; l++){
          for(int m = 0; m < 4; m++){
            if(k == 1 && l == 2 && m == 3) continue;
            if(j == 1 && l == 2 && m == 3) continue;
            if(k == 2 && l == 1 && m == 3) continue;
            if(k == 1 && l == 3 && m == 2) continue;
            if(j == 1 && k == 2 && m == 3) continue;
            add(dp[i+1][k][l][m],dp[i][j][k][l]);
          }
        }
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
       add(ans,dp[n][i][j][k]);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N, ans;
int A[100], B[100], C[100];
int main() {
	cin >> N;
	for (int i=1; i<=N; i++) cin >> A[i];
	for (int i=1; i<=N; i++) cin >> B[i];
	for (int i=1; i<N; i++) cin >> C[i];

	for (int i=1; i<=N; i++) {
		ans += B[A[i]];
		if (i!=N && A[i+1] == A[i]+1) ans += C[A[i]];
	}

	cout << ans;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val cnt = IntArray(1000001)
    val a = readLine()!!.split(' ').map {
        val num = it.toInt()
        cnt[num]++
        num
    }.sorted()

    val max= a[a.size-1]
    var ans = n
    for (i in 0 until n) {
        if (cnt[a[i]] > 1) {
            ans -= cnt[a[i]]
        }
        if (cnt[a[i]] >= 1) {
            cnt[a[i]] = 0
            var tmp = a[i] * 2
            if (tmp <= max) {
                while (tmp <= max) {
                    if (cnt[tmp] != 0) {
                        ans -= cnt[tmp]
                        cnt[tmp] = 0
                    }
                    tmp += a[i]
                }
            }
        }
    }
    println(ans)
}


Measured memory_bytes: 78532
#include <bitset>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<bitset<1000>> white(H, bitset<1000>());
  for (size_t h = 0; h < H; ++h) {
    string cho;
    cin >> cho;
    for (size_t w = 0; w < W; ++w) {
      if (cho[w] == '1') {
        white[h].set(w);
      }
    }
  }
  int res = 100001;
  for (size_t i = 0, end = (1 << (H - 1)); i < end; ++i) {
    int d = bitset<1024>(i).count();
    vector<int> count(d + 1, 0);
    int slice = 0;
    bool impossible = false;
    for (size_t w = 0; w < W; ++w) {
      int cur_d = 0;
      vector<int> tmp_cnt(d + 1, 0);
      for (size_t h = 0; h < H; ++h) {
        if (white[h].test(w)) ++tmp_cnt[cur_d];
        if ((1 << h) & i) {
          ++cur_d;
        }
      }
      bool need_swap = false;
      for (size_t j = 0, size = d + 1; j < size; ++j) {
        if (tmp_cnt[j] > K) {
          impossible = true;
          break;
        }
        count[j] += tmp_cnt[j];
        if (count[j] > K) {
          need_swap = true;
        }
      }
      if (impossible) break;
      if (need_swap) {
        count.swap(tmp_cnt);
        ++slice;
      }
    }
    if (!impossible) {
     res = min(res, d + slice);
    }
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String x = scan.next();
		String y = scan.next();

		if (x.compareTo(y) > 0) {
			System.out.println(">");
		} else if (x.compareTo(y) < 0) {
			System.out.println("<");
		} else {
			System.out.println("=");
		}
	}

}


Measured memory_bytes: 23764
N, M, C = map(int, input().split())
B_list_str = input().split()
B_list = []
for b in B_list_str:
    B_list.append(int(b))
A_row_list = []

cnt = 0
for row in range(N):
    A_list_str = input().split()
    A_list = []
    for a in A_list_str:
        A_list.append(int(a))
    A_row_list.append(A_list)
    row_sum = 0
    for i in range(M):
        row_sum += A_list[i] * B_list[i]
    if row_sum + C > 0:
        cnt += 1
print(cnt)

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

int main(){
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  cin >> s;

  if(c<b){
    for (int i = a; i <= c-2; i++)
    {
      if(s[i]=='#'&&s[i+1]=='#'){
        cout << "No" << endl;
        return 0 ;
      }
    }
    for (int i = b; i <= d-2; i++)
    {
      if(s[i]=='#'&&s[i+1]=='#'){
        cout << "No" << endl;
        return 0 ;
      }
    }
    cout << "Yes" << endl;
    return 0 ;
  }
  else{
    for (int i = a; i <= max(c,d)-2; i++)
    {
      if(s[i]=='#'&&s[i+1]=='#'){
        cout << "No" << endl;
        return 0 ;
      }
    }
    if(c>d){
      for (int i = b; i <= d-1; i++)
      {
        if((s[i]=='.' && (s[i+1]=='.' && s[i+2]=='.')) || (s[b-1]=='.' && s[b+1]=='.')){
          cout << "Yes" << endl;
          return 0;
        }
      }
      cout << "No" << endl;
      return 0;
    }
    else{
      cout << "Yes" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  int count = 0;
  for(int i = 1; i < s.size(); i++){
    if(i >= 2 && i <= s.size() - 2){
      if(s[i] == 'C') count++;
      else if(s[i] - 'a' < 0 || s[i] - 'a' > 25){
        cout << "WA" << endl;
        return 0;
      }
      if(count > 1){
        cout << "WA" << endl;
        return 0;
      }
    }
    else{
      if(s[i] - 'a' < 0 || s[i] - 'a' > 25){
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if(count == 0){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
}

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

int dp[100010];

int main(){
    int n;
    cin>>n;
    rep(i,100010) dp[i]=INF;
    dp[0]=0;
    rep(i,100010){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(int j=1;j<100;j++){
            if(i+pow(6,j)>100000) break;
            int x=pow(6,j);
            dp[i+x]=min(dp[i+x],dp[i]+1);
        }
        for(int j=1;j<100;j++){
            if(i+pow(9,j)>100000) break;
            int x=pow(9,j);
            dp[i+x]=min(dp[i+x],dp[i]+1);
        }

    }

    //rep(i,n+1) cout<<i<<" "<<dp[i]<<endl;
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4456
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    double N;
    cin >> N;
    cout << fixed << setprecision(12) << ((N+double(int(N)%2))/2.0)/N << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define FF(i,a,b) for (int i=a;i<=b;i++)
#define F(i,b,a)  for (int i=b;i>=a;i--)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
typedef long long ll;
const int N = 100;

int n, m;
char a[N][N], b[N][N];
int main()
{
    cin>>n>>m;
    FF(i,1,n) scanf("%*c%s", a[i]+1);
    FF(i,1,m) scanf("%*c%s", b[i]+1);
    for(int i=1; i+m-1<=n; i++) for(int j=1; j+m-1<=n; j++) {
        bool flag=1;
        FF(l,1,m) FF(r,1,m) {
            if(a[i+l-1][j+r-1]!=b[l][r]) flag=0;
        }
        if(flag==1) { puts("Yes"); return 0; }
    }
    puts("No");

    return 0;
}



Measured memory_bytes: 256
var
	n,m,i,j,p,q,res:longint;
	a:array[1..30]of longint;
begin
	Readln(n,m);
	res := 0;
	for i:=1 to n do
	begin
		Read(p);
		for j:=1 to p do
		begin
			Read(q);
			a[q] := a[q] + 1;
		end;
	end;
	for i:=1 to m do
		if a[i] = n then
			res := res + 1;
	Writeln(res);
end.         


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

int main(){
  int n;
  string k;
  bool judge=true;
  int ca=0,cu=0;

  cin >> n;

  for(int i = 0;i<n;i++)
    {
      cin >> k;
      
      /* if(n%2 == 1)
	{
	  cout << "NO" << endl;
	  break;
	}
      else
      {*/
	  if(k=="A")ca++;
	  if(k=="Un")cu++;

	  if(ca < cu)
	    {
	      judge = false;
	    }
	
    }
  if(ca != cu) judge =false;
  if(judge)
    {
      cout << "YES" << endl;
    }
  else
    {
      cout << "NO" << endl;
    }
}



Measured memory_bytes: 3140
import numpy as np
n, m, x = map(int, input().split())
Book = [list(map(int, input().split())) for _ in range(n)]
cost = [0 for _ in range(2**n)]
skill = [np.zeros(m) for _ in range(2**n)]
cost2 = []
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            cost[i] += Book[j][0]
            skill[i] += np.array(Book[j])[1:m+1]
    if np.min(skill[i]) >= x:
        cost2.append(cost[i])
if cost2:
    print(min(cost2))
else:
    print(-1)

Measured memory_bytes: 27904
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    
    long int dp[N];
    int h[N];
    for(int i=0; i<N; i++) {
        cin >> h[i];
        dp[i] = 0;
    }
    
    for(int i=1; i<K; i++) {
        if(i>=N) break;
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for(int j=1; j<i; j++) {
            dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]));
        }
    }

    for(int i=K; i<N; i++) {
        if(i>=N) break;
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for(int j=1; j<K; j++) {
            dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]));
        }
    }
    
    cout << dp[N-1] << endl;

    return 0;
    
}

Measured memory_bytes: 1408
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL n;
	cin >> n;
	LL sum = 0;
	REP(i, n) {
		LL x;
		cin >> x;
		if (x % 2 == 1) {
			sum++;
		}
	}
	if (sum % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;



int main()
{

    _fastIO;

    ll a,b;

    while(cin>>a>>b){
        ll x = (a*b);
        ll y = __gcd(a,b);
        ll z = x/y;
        cout<<z<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int dataSetLows = sc.nextInt();
                for (int i = 0; i < dataSetLows; i++) {
                    String originalNum = sc.next();
                    char[] charNum = originalNum.toCharArray();

                    // asc
                    Arrays.sort(charNum);
                    int maxNum = Integer.parseInt(String.valueOf(charNum));

                    // desc
                    int minNam = Integer
                            .parseInt(String.valueOf(desc(charNum)));

                    // max-min
                    int result = minNam - maxNum;
                    System.out.println(result);
                }
            }
        } finally {
            sc.close();
        }
    }

    private static char[] desc(char[] c) {
        char[] after = new char[c.length];

        for (int i = 0; i < c.length; i++) {
            after[i] = c[c.length - (1 + i)];
        }
        return after;
    }
}

Measured memory_bytes: 25972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  cin >> n >> q;
  int a,b;
  vector<set<int> >hen(n+1);
  vector<bool>oya(n+1);
  int i;
  for(i=0;i<n-1;i++){
    cin >> a >> b;
    hen[a].insert(b);
    hen[b].insert(a);
  }
  vector<long>cnt(n+1);
  for(i=0;i<q;i++){
    cin >> a >> b;
    cnt[a] += b;
  }
  queue<int>stc;
  stc.push(1);
  int tmp = 1;
  while(!stc.empty()){
    tmp = stc.front();
    stc.pop();
    oya[tmp] = true;
    for(auto j:hen[tmp]){
      if(!oya[j]){
        stc.push(j);
        cnt[j] += cnt[tmp];
      }
    }
  }
  for(i=1;i<=n;i++){
    cout << cnt[i] << " ";
  }
}


Measured memory_bytes: 32768
<?php
// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d", $r);
echo 3 * $r * $r, PHP_EOL;


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

int main(){
  int N, M;
  cin >> N >> M;
  int A[M];
  rep(i, M) cin >> A[i];

  int sums = 0;
  rep(i, M) sums += A[i];
  cout << max(-1, N - sums) << endl;
}


Measured memory_bytes: 3684
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	ll som=0;
	if(K<=A){
		cout<<K;
	}
	else{
		som+=A;
		K-=A;
		if(K<=0){
			cout<<som;
		}
		else{
			if(K<=B){
				cout<<som;
			}
			else{
				K-=B;
				if(K<=0){
					cout<<som;
				}
				else{
					cout<<som-K;
				}
			}
		}
	}
}

Measured memory_bytes: 3640
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

x = a+v*t
y = b+w*t
if a < b:
    x = a+v*t
    y = b+w*t
    if x < y:
        print('NO')
    else:
        print('YES')
else:
    x = a-v*t
    y = b-w*t
    if x > y:
        print('NO')
    else:
        print('YES')  

Measured memory_bytes: 9200
#include<iostream>
using namespace std;
int main()
{
  int n,a,b,A,B;
  while(cin>>n,n){
    A=B=0;
    while(n-->0){
      cin>>a>>b;
      if(a>b){
	A+=a+b;
      }else if(a<b){
	B+=a+b;
      }else{
	A+=a;
	B+=b;
      }
    }
    cout<<A<<" "<<B<<endl;
  }
}

Measured memory_bytes: 0