akhauriyash/Code-Regression huggingface dataset:
#include <math.h>       /* cos */
double last_turn;
#define PI 3.14159265

double walk(double go,double turn,double* x,double* y) {
			*x -= go * sin(last_turn* PI / 180.0);
			*y += go * cos(last_turn* PI / 180.0);
			return -turn; 

}
int main()
{
	double gx = 0,gy = 0,now_x = 0, now_y = 0;
	double go = 0, turn = 0;

	last_turn = 0;
	now_x = 0, now_y = 0;
	for(;;){
		go = 0, turn = 0;
		scanf("%lf,%lf",&go,&turn);
		last_turn += walk(go,turn,&now_x,&now_y);
		if(go==0 && turn==0) break;
	}

		printf("%d\n%d\n",(int)now_x,(int)now_y);
	return 0;
}

Measured memory_bytes: 660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, S;
  cin >> N >> S;
  if(N < S){
    cout << -1 << endl;
    return 0;
  }else if(N == S){
    cout << N + 1 << endl;
    return 0;
  }
  for(int b = 2; b <= (int)sqrt(N); b++){
    ll ans = 0;
    ll temp_N = N;
    while(temp_N >= b){
      ans += temp_N % b;
      temp_N /= b;
    }
    ans += temp_N;
    if(ans == S){
      cout << b << endl;
      return 0;
    }
  }
  int maxp = (sqrt(N) == floor(sqrt(N))) ? sqrt(N) - 1 : sqrt(N);
  for(int p = maxp; p >= 1; p--){
    ll b = (N - S) / p + 1;
    if(b > 1 && N / b + N % b == S){
      cout << b << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

typedef complex<double> P;

namespace std {
  bool operator<(const P& lhs, const P& rhs) {
    return (lhs.real() == rhs.real()) ? (lhs.imag() < rhs.imag()) : (lhs.real() < rhs.real());
  }
}


int main() {
  int m;
  while (cin >> m, m) {
    vector<P> asterism(m);
    for (int i = 0; i < m; ++i) {
      int x, y; cin >> x >> y;
      asterism[i] = P(x, y);
    }

    set<P> stars;
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
      int x, y; cin >> x >> y;
      stars.insert(P(x, y));
    }

    for (auto p : stars) {
      P diff = p - asterism[0];
      bool ok = true;
      for (auto q : asterism) {
        if (stars.count(q + diff) == 0) {
          ok = false;
          break;
        }
      }
      if (ok) {
        cout << diff.real() << " " << diff.imag() << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout << min(a,b) + min(c,d) << ednl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(1, n+1): a[i] += a[i-1]
for i in range(1, m+1): b[i] += b[i - 1]

ans, b_cnt = 0, m
for a_cnt in range(n+1):
    if a[a_cnt] > k: break
    while a[a_cnt] + b[b_cnt] > k: b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)


Measured memory_bytes: 40148
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll l,r,d;
    cin >> l >> r >> d;
    ll cnt = 0;
    rep1(i,100){
        if( i >= l && i <= r){
            if(i % d == 0){
                cnt++;
            }
        }
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(){
    int N,T,ans=10000000,b;
    cin >> N >> T;
    int c[N],t[N];
    for(int i=0;i<N;i++){
        cin >> c[i] >> t[i];
        if(t[i]<=T){
            b=c[i];
            ans = min(ans,b);
        }
    }
    if(ans==10000000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    int n, a, min, MAX;
    long sum=0;
    
    cin >> n;
    
    cin >> a;
    min = MAX = sum = a;
    
    for(int i=1; i < n; i++){
        cin >> a;
        if(a < min)
            min = a;
        if(MAX < a)
            MAX = a;
        sum += a;
    }
    
    cout << min << " " << MAX << " " << sum << endl;
    
    return 0;
}



Measured memory_bytes: 3092
sectional_view = input()

list_index_down = []
list_index_area_left = []
list_area = []


for index_now, mark in enumerate(sectional_view):
    if   mark == "\\":
        list_index_down += [index_now]
    elif mark == "/" and list_index_down:
        index_down_last = list_index_down.pop()
        area = index_now - index_down_last

        while ((list_index_area_left) and
               (list_index_area_left[-1] > index_down_last)):
            area += list_area.pop()
            list_index_area_left.pop()

        list_index_area_left.append(index_down_last)
        list_area.append(area)


print(sum(list_area))
print(len(list_area),*(list_area))



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

#define llint long long int

using namespace std;

int main(){
    string S, T;

    cin >> S >> T;

    int ans = 0;

    for(int i = 0; i < S.length(); i ++){
        if(S[i] != T[i]){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3848
import scala.io.StdIn

object Main extends App {

  def divisor(k: Int): Int = (1 to k).count(p => (k % p) == 0)
  
  val n = StdIn.readLine().toInt

  val r = (105 to n).filter(p => p % 2 == 1).count(f => divisor(f) == 8)

  println(r)
}


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

int main(){
	int h,w,n;
	bool field[1000][1000];
	int dp[1001][1001] = {};
	while(1){
		cin >> h >> w >> n;
		if(!h) break;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> field[i][j];
				dp[i][j] = 0;
			}
		}
		dp[0][0] = n - 1;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				dp[i][j + 1] += dp[i][j] / 2;
				dp[i + 1][j] += dp[i][j] / 2;
				if(dp[i][j] % 2 == 1){
					if(field[i][j]){
						dp[i][j + 1]++;
					}else{
						dp[i + 1][j]++;
					}
					field[i][j] = !field[i][j];
				}
			}
		}
		int x = 0,y = 0;
		while(x < h && y < w){
			if(field[x][y]) y++;
			else x++;
		}
		cout << x + 1 << " " << y + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7904
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi
#define se second
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0) 
 
using namespace std;

int main()
{
	int n, count = 0;
	
	string q, r, s, t, u,v;

	cin >> s;

	n = s.length();
	t = s;
	reverse(s.begin(), s.end());
	if(t == s)
	{
		count++;
	}
	u = t.substr(0,n/2);
	v = u;
	reverse(u.begin(), u.end());
	if (u == v)
	{
		count++;
	}
	r = t.substr(((n+3)/2)-1,n );
	q = r;
	reverse(r.begin(), r.end());
	if(r ==q)
	{
		count++;
	}
	
	if(count == 3)
	cout << "Yes" << endl;
	if (count != 3)
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

struct edge {ll to, cap, rev;};
vector<vector<edge>> G;
vector<bool> used;
ll N;

void add_edge (ll from, ll to, ll cap) {
    G[from].push_back({to, cap, (ll)G[to].size()});
    G[to].push_back({from, 0, (ll)G[from].size()-1});
}

ll dfs (ll v, ll t, ll f) {
    if (v == t) return f;
    used[v] = true;
    for (edge &e : G[v]) {
        if (!used[e.to] and e.cap > 0) {
            ll d = dfs (e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

ll max_flow (ll s, ll t, ll N) {
    ll flow = 0;
    while (true) {
        used.assign(N, false);
        ll f = dfs(s, t, inf);
        if (f == 0) return flow;
        flow += f;
    }
}

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

    ll H, W;
    cin >> H >> W;
    vector<string> a(H);
    Rep (i, H) {
        cin >> a[i];
    }

    G.assign(H+W+2, vector<edge>());

    ll s = H+W, t = H+W+1;

    Rep (i, H) {
        Rep (j, W) {
            if (a[i][j] == 'S') {
                add_edge(s, i, inf);
                add_edge(s, H+j, inf);
            }
            if (a[i][j] == 'T') {
                add_edge(i, t, inf);
                add_edge(H+j, t, inf);
            }
            if (a[i][j] == 'o') {
                add_edge(i, H+j, 1);
                add_edge(H+j, i, 1);
            }
        }
    }

    // Rep (i, H+W+2) {
    //     cout << i << ":";
    //     for (auto e : G[i]) {
    //         cout << e.to << " ";
    //     }
    //     cout << "\n";
    // }

    ll ans = max_flow(s, t, H+W+2);
    if (ans > 1e6) ans = -1;

    cout << ans << "\n";
}

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

vector<pair<int, int>> v;

bool checkres(int ord, int dig, int num){
    while(ord--) num /= 10;
    return num%10 == dig;
}

bool check(int num) {
    for(auto u: v) if(checkres(u.first, u.second, num) == 0) return 0;
    return 1;
}

int main() {
    
    int numdigs, nrest;
    cin >> numdigs >> nrest;
    
    int l, r;
    if(numdigs == 1) l = 0, r = 9;
    else if(numdigs == 2) l = 10, r = 99;
    else l = 100, r = 999;
    
    int a, b;
    
    while(nrest--){
        cin >> a >> b;
        v.push_back({numdigs-a, b});
    }
    
    while(l<=r){
        if(check(l)){
            cout << l << "\n";
            return 0;
        }
        l++;
    }
    
    cout << "-1\n";
	return 0;
}

Measured memory_bytes: 256
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007; // 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 100005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};


// Lets start ...

    

int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1,cnt=0;
    //cin>>tests;
    while(tests--){
        ll n,x,t;
        cin>>n>>x>>t;
        if(n%x==0)cout<<(n/x)*t;
        else cout<<(((n/x)+1)*t);
        ll l[n];
        //fi(i,0,n)cin>>l[i];
        
        
    }

    return 0;
    }

// Done:)




Measured memory_bytes: 3656
N, M = [int(i) for i in input().split()]
cost = 0
amount =0
dic ={}
for _ in range(N):
    a,b = [int(i) for i in input().split()]
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b

dic = sorted(dic.items())

for a,b in dic:
    if amount+b<=M:
        amount += b
        cost += a*b
    else:
        rest = M - amount
        cost += a*rest
        break

print(cost)


Measured memory_bytes: 23008
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector<ll> bukas(n, 0);
    REP(i, n-1){
        ll a; cin >> a;
        bukas[a-1] += 1;
    }
    REP(i, n){
        cout << bukas[i] << endl;
    }
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<double> pw(20);
	pw[0] = 1;
	FOR(i, 1, 20) pw[i] = pw[i - 1] / 2.0;
	double ans = 0;
	
	FOR(i, 1, n + 1)
	{
		int cnt = 0;
		while(i * (1 << cnt) < k) cnt++;
		ans += pw[cnt];
	}
	
	ans /= n;
	cout << fixed << setprecision(10) << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
N=list(input())
s=set(N)
ans=''.join(sorted(s))
all=[chr(i) for i in range(97,97+26)]
if ans=='abcdefghijklmnopqrstuvwxyz':
  print('None')
  exit()
for i in range(len(ans)):
  if ans[i]!=all[i]:
    print(all[i])
    exit()
  elif i==len(ans)-1 :
    print(all[len(ans)])
    exit()

Measured memory_bytes: 9764
#include <stdio.h>

int main(void)
{
    int card[4][13] = {};
    char symbol;
    int number;
    int n;
    int i, j;
    
    scanf("%d", &n);
    
    for(i=0; i<n*2; i++){
        scanf("%c %d", &symbol, &number);
        switch(symbol){
            case 'S':
                card[0][number-1] = 1;
                break;
            case 'H':
                card[1][number-1] = 1;
                break;
            case 'C':
                card[2][number-1] = 1;
                break;
            case 'D':
                card[3][number-1] = 1;
                break;
        }
    }
    
    for(i=0; i<4; i++){
        for(j=0; j<13; j++){
            if(card[i][j]==0){
                switch(i){
                    case 0:
                        printf("S %d\n", j+1);
                        break;
                    case 1:
                        printf("H %d\n", j+1);
                        break;
                    case 2:
                        printf("C %d\n", j+1);
                        break;
                    case 3:
                        printf("D %d\n", j+1);
                        break;
                }
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>


int main() {
	int k; std::cin >> k;
	std::string word = "ACL";
	for (auto i = 0; i < k; ++i) {
		std::cout << word;
	}
	std::cout << '\n';
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
typedef long long lint;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define all(x) (x).begin(),(x).end()
#define INF (1LL<<60)
#define MOD 1000000007
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
int main(){
    lint n;
    cin>>n;
    vector<lint> v(n);
    iota(all(v),1);
    do{
        output(v);
    }while(next_permutation(all(v)));
}


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

int main(void){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double max = 0;int sugar = 0,water = 0;
    int x[3010] = {},y[3010] = {};
    int q = 0;
    for(int i = 0;i*c <= f;i++){
        for(int j = 0;j*d <= f-i*c;j++){
            int p = i*c+j*d;
            if(p < (f/100)*e && x[p] == 0){
                q++;
                x[p] = 1;
                //cout << p << endl;
            }
        }
    }
    for(int i = 0;i*a*100 <= f;i++){
        for(int j = 0;j*b*100 <= f-i*a*100;j++){
            int k = i*a*100+j*b*100;
            if(k < f){
                y[k] = 1;
                water = k;
            }
        }
    }
    
    for(int i = 1;i <= f;i++){
        for(int j = 1;j <= f;j++){
            if(x[j] == 0 || y[i] == 0 || (i/100)*e < j || i+j >f)continue;
            double con = (double)(100*j) / (double)(j+i);
            //cout<<(double)(100*j) / (double)(j+i) << endl;
            if(max < con){
                max = con;
                water = i+j;
                sugar = j;
            }
        }
    }
    cout << water << " " << sugar;
}

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

int e_gcd (int a, int b) {
  if (a < b) return e_gcd(b,a);
  int r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int gcd (int a, int b, int c) {
  return e_gcd(e_gcd(a,b),c);
}

int main () {
  int k;
  cin >> k;
  
  long long sum = 0;
  
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int l = 1; l <= k; ++l) {
        sum += gcd(i,j,l);
      }
    }
  }
  cout << sum;
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

int main() {
    lint n, m;
    cin >> n >> m;

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;
    vector<lint> b(m);
    for(auto& elem : b)  cin >> elem;

    // 重複があるかチェック
    set<lint> as(a.begin(), a.end());
    set<lint> bs(b.begin(), b.end());
    if(as.size() < n || bs.size() < m) {
        cout << 0 << endl;
        return 0;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    mint ans = 1;    
    for(lint i=n*m; i>=1; i--) {
        // iと書かれた列がある場合
        if(as.count(i)) {
            // iと書かれた行がある場合はans *= 1
            // iと書かれた行がない場合
            if(bs.count(i) == 0) {
                // iより大の行の個数
                lint bc = b.end() - upper_bound(b.begin(), b.end(), i);
                ans *= mint(bc);
            }
        }
        // iと書かれた列がない場合
        else {
            // iと書かれた行がある場合
            if(bs.count(i)) {
                lint ac = a.end() - upper_bound(a.begin(), a.end(), i);
                ans *= mint(ac);
            }
            // iと書かれた行がない場合
            else {
                lint ac = a.end() - upper_bound(a.begin(), a.end(), i);
                lint bc = b.end() - upper_bound(b.begin(), b.end(), i);
                ans *= mint(ac) * mint(bc) - mint(n*m-i);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
int n;
char c[4005];
ll r,g,b,ans;
 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		if(c[i]=='R') r++;
		if(c[i]=='G') g++;
		if(c[i]=='B') b++;
	}
	ans=r*g*b;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(c[i]!=c[j])
			{
				int k=j+j-i;
				if(k>n) continue;
				if(c[i]!=c[k]&&c[j]!=c[k])
					ans--;
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(void){
	int a[90],b[90],ans[90],i=0,Count=0;
	char op[90];
	
	while(1){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i]=='?'){
				break;
		}
		i++;
		Count++;
	}
	
	for(i=0;i<=Count;i++){
		if(op[i]=='+'){
			ans[i]=a[i]+b[i];
		}
		else if(op[i]=='-'){
			ans[i]=a[i]-b[i];
		}
		else if(op[i]=='*'){
			ans[i]=a[i]*b[i];
		}
		else if(op[i]=='/'){
			ans[i]=a[i]/b[i];
		}
	}
	for(i=0;i<Count;i++){
		printf("%d\n",ans[i]);
	}
  
  return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3

H,W = [int(i) for i in input().split()]
S = []
S.append('.'*(W+2))
for i in range(H):
    S.append('.'+input()+'.')
S.append(['.']*(W+2))

for y in range(1,H+1):
    for x in range(1,W+1):
        if S[y][x] == '#':
            print('#',end="")
        else:
            print(S[y-1][x-1:x+2].count('#')+S[y][x-1:x+2].count('#')+S[y+1][x-1:x+2].count('#'),end="")
    print("")


Measured memory_bytes: 9088
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

ll dif(ll a,ll b)
{
ll ans=0ll;	
  while(a>0 || b>0)
  {
	  ll r1 = (a&1);
	  ll r2 = (b&1);
	  if(r1!=r2)
	  {
		ans++;  
	   }
	  a = a>>1;
	  b = b>>1;
  }
	
	
	return ans;
}



ll calc(ll n)
{
if(n==0)
{
return 0;	
}
if(n==1)
{
return 1;	
}	
ll p = n/2;
ll ans = calc(p) + n;

return ans;	
}


void solve()
{
	ll n;
	cin>>n;
	ll a[n+5];
	ll md =0;
	for(ll i=0;i<n;i++)
	{
	cin>>a[i];	
	md+=a[i];
	}
	ll c =0;
	if(md%n!=0)
	{
	c=1;	
	}
	md /= n;
	
	md+=c;
	ll ans1=0;
	ll md1=md-c;
	ll ans =0;
	
	for(ll i=0;i<n;i++)
	{
	ans += ((md-a[i])*(md-a[i]));	
	ans1 +=((md1-a[i])*(md1-a[i]));
	}
	ans = min(ans,ans1);
	cout<<ans<<endl;
	  //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{	
	solve();	
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int fun(char *,int );
int fun(char *s,int N)
{
    int i,h=0,max=0;
    for(i=0;i<N;i++)
    {
        if(s[i]=='I')
        {
            h++;
            if(h>max)
            {
                max=h;
            }
        }
        if(s[i]=='D')
        {
            h--;
        }
    }
    return max;
}
int main()
{
    char a[101];
    int n;
    scanf("%d%s",&n,a);
    printf("%d\n",fun(a,n));
    return 0;
}

Measured memory_bytes: 128
import copy
        
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

class UnionFindPathCompression():
    def __init__(self, n:int):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.size = [1]*n
        

    def find(self, x:int) -> int:
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x:int, y:int):
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.size[py] += self.size[px]
            else:
                self.parents[py] = px
                self.size[px] += self.size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1


n,m = map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
memo = 0
for i in range(m):
    ufpc = UnionFindPathCompression(n)
    ab_copy = copy.deepcopy(ab)
    ab_copy.pop(i)
    for a,b in ab_copy:
        a,b = a-1,b-1
        ufpc.union(a,b)
    for i in range(n):
        ufpc.find(i)
    check = set(ufpc.parents)
    if len(check)==1:
        memo += 1
print(m-memo)

Measured memory_bytes: 86740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
  cin>>n;
  vector<int> X = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << X.at(n-1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=1e5+10;
int n,l,q,cnt=1,dp[N][35],x[N],pw[35]={1},ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline void swp(I&a,I&b){I t=a; a=b; b=t;}
int main()
{
//	freopen("Tak and Hotels.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++) read(x[i]);
	read(l,q);
	/*for(int i=1;i<=n;i++) 
	{
		while(x[i]+l>=x[cnt]) cnt++;
		if(cnt-1>n || cnt<=i) continue;
		dp[i][0]=cnt-1;
//		printf("asd %d %d\n",i,dp[i][0]);
	}*/
	for (int i = 1; i <= n; i++) while (x[i] > x[cnt] + l) dp[cnt++][0] = i - 1;
	for(int i=1;i<=20;i++)
	{
		pw[i]=pw[i-1]<<1;
		for(int j=1;j<=n;j++)
		{
			if(dp[j][i-1]) dp[j][i]=dp[dp[j][i-1]][i-1];
		}
	}
	for(int i=1,a,b;i<=q;i++)
	{
		read(a,b);
		if(a>b) swp(a,b);
		ans=0;
		for(int j=20;j>=0;j--) if(dp[a][j] && dp[a][j]<b) a=dp[a][j], ans+=pw[j];
		printf("%d\n",ans+1);
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=200005;
long long ans=0, a[N];
int n;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n;
    rep(i, 1, n) {
        int u;
        cin >> u;
        a[i]=u-i;
    }
    sort(a+1, a+n+1);
    int pivot=a[(n+1)>>1];
    rep(i, 1, n) {
        ans+=abs(pivot-a[i]);
    }
    cout << ans;
    return 0;
}


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

typedef pair<int,int> P;

map<P,vector<P> > mp;

signed main(){
	int n,k,x = 0,y = 0,ans = 0;
	P ps[100010];
	string s;
	cin >> n >> k >> s;
	ps[0] = P(0,0);
	for(int i = 0;i < n;i++){
		if(s[i] == 'N') x--;
		else if(s[i] == 'E') y--;
		else if(s[i] == 'W') y++;
		else x++;
		ps[i + 1] = P(x,y);
	}
	for(int i = 0;i <= n;i++){
		if(ps[n].first < 0) ps[i].first *= -1;
		if(ps[n].second < 0) ps[i].second *= -1;
	}
	for(int i = 0;i <= n;i++){
		if(ps[n].first > ps[n].second) swap(ps[i].first,ps[i].second);
	}
	x = ps[n].first;
	y = ps[n].second;
	set<P> st;
	for(int i = 0;i <= n;i++) st.insert(ps[i]);
	if(ps[n] == P(0,0)){
		for(auto it = st.begin();it != st.end();it++){
			bool flag = true;
			for(int j = 0;j < 2;j++){
				for(int k = 0;k < 2;k++){
					if(!st.count(P((*it).first + j,(*it).second + k))) flag = false;
				}
			}
			if(flag) ans++;
		}
		cout << ans << endl;
		return 0;
	}
	for(auto it = st.begin();it != st.end();it++){
		int a = INF,b = INF,d;
		P p = *it;
		if(x) a = (p.first + INF * x) / x - INF;
		if(y) b = (p.second + INF * y) / y - INF;
		d = min(a,b);
		mp[P(p.first - x * d,p.second - y * d)].push_back(P(d,d + k));
	}
	for(auto it = mp.begin();it != mp.end();it++){
		P p = it->first;
		vector<P> vec;
		for(int i = 0;i < 2;i++){
			for(int j = 0;j < 2;j++){
				int nx = p.first + i,ny = p.second + j,a = INF,b = INF,d;
				if(x) a = (nx + INF * x) / x - INF;
				if(y) b = (ny + INF * y) / y - INF;
				d = min(a,b);
				if(mp.find(P(nx - x * d,ny - y * d)) == mp.end()) continue;
				for(P pp : mp[P(nx - x * d,ny - y * d)]){
					vec.push_back(P(pp.first - d,i * 2 + j + 1));
					vec.push_back(P(pp.second - d,-(i * 2 + j + 1)));
				}
			}
		}
		sort(vec.begin(),vec.end());
		int cnt[4] = {},prev;
		for(int i = 0;i < vec.size();i++){
			P pp = vec[i];
			int a = pp.first,b = pp.second;
			bool flag = true;
			for(int j = 0;j < 4;j++) if(!cnt[j]) flag = false;
			if(flag) ans += a - prev;
			prev = a;
			while(i < vec.size() && vec[i].first == a){
				if(vec[i].second > 0) cnt[vec[i].second - 1]++;
				else cnt[-vec[i].second - 1]--;
				i++;
			}
			i--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

signed main(){
    int n,a=1e9;
    cin>>n;
    int c[2][n];
    R(i,n)cin>>c[0][i];
    R(i,n)cin>>c[1][i];
    vector<vector<int>> dp(1<<n,vector<int>(51,1e9));
    dp[0][0] = 0;
    R(B,1<<n){
        int now=0,d[n];
        R(i,n)if(!(B&1<<i)) d[i] = now++;
        int cnt=n-now;
        R(i,n){
            if(B&(1 << i)) continue;
            int k=abs(i-cnt);
            R(j,c[k % 2][i]+1) dp[B|1 << i][c[k % 2][i]] = min(dp[B|1 << i][c[k % 2][i]], dp[B][j] + d[i]);
        }
    }
    R(i,51) a=min(a,dp[(1<<n)-1][i]);
    cout<<(a==1e9?-1:a);
}

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

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

    vector<int> tako(N);

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

    int result=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            result = result + tako.at(i) * tako.at(j);
        }
    }

    cout << result << endl;
}



Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,k;
    cin>>n>>k;
    if(n<=10){
        cout<<0<<endl;
        while(k--){
            for(int t=0;t<n;t++){
                cout<<t+1<<endl;
                string s;
                cin>>s;
                if(s=="Yes"){break;}
            }
        }
    }
    else{
        ll s=n-9;
        ll cnt=0;
        for(int i=0;i<9;i++){
            for(int t=0;t<s;t++){
                if(t>>i&1){cnt++;}
            }
        }
        cout<<cnt<<endl;
        for(int i=0;i<9;i++){
            for(int t=0;t<s;t++){
                if(t>>i&1){cout<<t+1<<" "<<s+i+1<<endl;}
            }
        }
        while(k--){
            ll ans=0;
            bool done=false;
            for(int i=0;i<9;i++){
                cout<<s+i+1<<endl;
                string s;
                cin>>s;
                if(s=="Yes"){done=true; break;}
                else if(s=="Near"){ans|=(1LL<<i);}
            }
            if(!done){
                cout<<ans+1<<endl;
                string s;
                cin>>s;
            }
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3308
#include<iostream>
using namespace std;
int main()
{
    int x;
    cin>>x;

    if(x>=400 && x<600) cout<<"8";
    else if(x>=600 && x<800) cout<<"7";
    else if(x>=800 && x<1000) cout<<"6";
    else if(x>=1000 && x<1200) cout<<"5";
    else if(x>=1200 && x<1400) cout<<"4";
    else if(x>=1400 && x<1600) cout<<"3";
    else if(x>=1600 && x<1800) cout<<"2";
    else if(x>=1800 && x<2000) cout<<"1";











}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    string s;
    cin>>s;
    if(s=="Sunny")
    cout<<"Cloudy";
    else if(s=="Cloudy")
    cout<<"Rainy";
    else if(s=="Rainy")
    cout<<"Sunny";
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt()*10;
int b=scan.nextInt()*10;
if((a+b)/2%10==0) {
	System.out.println((a+b)/2/10);
}
else {
	System.out.println((a+b)/2/10+1);
}
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000005],b[1000005],ans;
int main(){
    string s;
    cin>>s;
    ll n=s.length();
    for(ll i=0;i<s.length();i++){
        a[i+1]=s[i]-'0';
    }
    for(int i=0;i<=n;i++){
        b[i]=10;
    }
    int tag=0;
    for(int i=n;i>=1;i--){
        a[i]+=tag;
        if(a[i]>=b[i]-a[i]){
            ans+=b[i]-a[i];
            tag=1;
            if(a[i]==5&&a[i-1]<5) tag=0; 
        }
        else{
            ans+=a[i];
            tag=0;
        }
    }
    cout<<ans+tag<<endl;
}


Measured memory_bytes: 17028
#include<bits/stdc++.h>
using namespace std;
int main(){
  int ab,bc,ca;
  cin>>ab>>bc>>ca;
  if(ab>=bc && ab>=ca)cout<<(bc*ca)/2;
  else if(bc>=ab && bc>=ca)cout<<(ab*ca)/2;
  else if(ca>=ab && ca>=bc)cout<<(ab*bc)/2;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n+1, 1);
  vector<int> vis(n+1);
  vis[1] = 1;
  for ( int i = 1, x, y; i <= m; ++ i) {
    cin >> x >> y;
    vis[y] |= vis[x];
    ++ cnt[y];
    if( !(-- cnt[x])) {
      vis[x] = 0;
    }
  }
  int ret = 0;
  for ( int i = 1; i <= n; ++ i) {
    ret += vis[i];
  }
  cout << ret << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000

int main(void)
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char ans[4];
    printf("%c%c%c",s1[0] - ('a' - 'A'), s2[0] - ('a' - 'A'), s3[0] - ('a' - 'A') );

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=998244353 ;
const ll MAXN=1e6+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll n;
    cin >> n;
    string s;
    cin >> s;
    set < ll > r, g, b;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r.insert(i);
        else if(s[i] == 'G') g.insert(i);
        else if(s[i] == 'B') b.insert(i);
    }
    ll ans = 0;
    for(auto i : r){
        for(auto j : g){
            ll e = i, f = j;
            if(e > f) swap(e, f);
            ans += b.size();
            if(b.count(f + f - e)) ans--;
            if((e + f) % 2 == 0 && b.count((e + f) / 2)) ans--;
            if(b.count(e + e - f)) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3768
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

MOD = 10 ** 9 + 7

am = set()
for a in A:
	am |= {a}

dp = [1] + [0] * (N + 10)

for n in range(1, N + 1):
	if n in am:
		continue
	dp[n] = (dp[n - 1] + (dp[n - 2] if 2 <= n else 0)) % MOD

#print(dp)
print(dp[N])


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

int main(){
 while(true){
  int H;
  cin >> H;
  
  if(H==0) break;

  int S[H][5]; //盤面
  for(int y=0; y<H; y++){
   for(int x=0; x<5; x++){
    cin >> S[y][x];
   }
  } 

  int sco = 0; //スコア

  while(true){
   bool flag = false;
   
   //消滅
   for(int y=0; y<H; y++){
    int m = S[y][2]; //消滅の際、真ん中のマスは必ず使用される。
    if(m==0)
     continue; //このループ内の以下の部分をスキップして文の始めに戻る。
    
    if(S[y][0]==m && S[y][1]==m){ //0～2が同じ
     sco += m*3;
     S[y][0] = S[y][1] = S[y][2] = 0;
     flag = true;

     if(S[y][3]==m){ //3も同じ
      sco += m;
      S[y][3] = 0;

      if(S[y][4]==m){ //3も同じかつ4も同じ
       sco += m;
       S[y][4] = 0;
      }
     }
    }

    else if(S[y][1]==m && S[y][3]==m){ //1～3が同じ
     sco += m*3;
     S[y][1] = S[y][2] = S[y][3] = 0;
     flag = true;
  
     if(S[y][4]==m){ //4も同じ
      sco += m;
      S[y][4] = 0;
     }
    }
     
    else if(S[y][3]==m && S[y][4]==m){
     sco += m*3;
     S[y][2] = S[y][3] = S[y][4] = 0;
     flag = true;
    }
   }

   if(!flag) break; //消滅しなかった場合、落下処理を行わない。

   //落下
   for(int x=0; x<5; x++){
    for(int y=H-1; y>=0; y--){
     if(S[y][x]!=0)
      continue;
     
     for(int y2=y-1; y2>=0; y2--){ //空きより上を探す。
      if(S[y2][x]!=0){
       S[y][x] = S[y2][x];
       S[y2][x] = 0;
       break;
      }
     }
    
    }
   }
  }
  cout << sco << endl;
 }
 return 0;
}


Measured memory_bytes: 3012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int n,k,i;
  scanf("%d %d",&n,&k);
  for(i=0;n;i++){
    int a=0;
    while(n&&n>k*a){
      a++;
      n--;
    }
  }
  PRN(i);
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    bool isNine = true,isONine = true;
    for(int i = 0;i < n.size();i ++){
        if(n[i]!='9') isNine = false;
        if(n[i]!='9' && i) isONine = false;
    }
    if(isNine) cout << n.size()*9<< endl;
    else if(n.size()==1) cout << n[0] << endl;
    else if(isONine) cout << n[0]-'0'+(n.size()-1)*9 << endl;
    else cout << (n[0]-'0')-1 + (n.size()-1)*9 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(" ")))
Triger = 0
A.sort()
if N == 2:
  if A[0] == A[1]:
    print("NO")
  else:
    print("YES")
else:
  
  for i in range(1,len(A)-1):
    if A[i] == A[i-1]:
      print("NO")
      Triger += 1
      break
  if Triger == 0:
    print("YES")

Measured memory_bytes: 26808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    vector<string>s;
    for(int i=0;i<a;i++)
    {
        string str;
        cin>>str;
        s.push_back(str);
    }
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i++)
    {
        cout<<s[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 1000000;
int n, T[MAX];

void maxHeapify(int i)
{
    int l = i * 2;
    int r = i * 2 + 1;
    int large;

    if (l <= n && T[l] > T[i])
    {
        large = l;
    }
    else
    {
        large = i;
    }
    if (r <= n && T[r] > T[large])
    {
        large = r;
    }

    if (i != large)
    {
        swap(T[i], T[large]);
        maxHeapify(large);
    }
}

void buildHeap()
{
    for (int i = n / 2; i > 0; --i)
    {
        maxHeapify(i);
    }
}

int main()
{
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> T[i];
    }

    buildHeap();
    
    for (int i = 1; i <= n; ++i)
    {
        cout << " " << T[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5032
h, w, k = map(int, input().split())
c = []
ans = 0
for i in range(h):
    c.append(input())

for maskR in range(1 << h):
    for maskC in range(1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if maskR >> i & 1 == 0 and maskC >> j & 1 == 0 and c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)


Measured memory_bytes: 9188