akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int gcd(int x, int y){
  int r;
  if(x<y) swap(x,y);
  while(y>0){
    r = x%y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int a,b;
  cin >>a>>b;
  cout << gcd(a,b) << endl;
}


Measured memory_bytes: 3084
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    long odd, multifour, othereven;
    foreach (e; a)
    {
        if (e % 4 == 0)
            multifour++;
        else if (e % 2 == 0)
            othereven++;
        else
            odd++;
    }
    // othereven.writeln();
    // multifour.writeln();
    // odd.writeln();
    if (othereven % 2 + odd <= multifour + 1)
        if (multifour > 0 || odd == 0)
        {
            writeln("Yes");
            return;
        }

    writeln("No");
}

Measured memory_bytes: 4148
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int ans = n;
        for(int i = 0; i <= n; i++){
            int cnt = 0;
            int t = i;
            while(t > 0){
                cnt += t % 6;
                t /= 6;
            }
            t = n-i;
            while(t > 0){
                cnt += t % 9;
                t /= 9;
            }
            ans = Math.min(ans,cnt);
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

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

    if ( a+b >= k ) {
        cout << min(a, k) << endl;
    } else {
        k -= a+b;
        cout << a-k << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
import sys
def main():
  for line in sys.stdin:
    time = int(line)
    hour = int(time/3600)
    min = int((time - hour * 3600)/60)
    sec = int((time - hour * 3600 - min * 60))
    print("{0}:{1}:{2}".format(hour, min, sec)) 

if __name__ == "__main__":
  main()

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vl factor(ll n) {
  vl res;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(n / i != i) res.push_back(n / i);
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = factor(n - 1).size() - 1;
  vl v = factor(n);
  for(auto k : v) {
    if(k == 1) continue;
    ll m = n;
    while(m % k == 0) m /= k;
    m %= k;
    if(m == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))


K, X = [int(x) for x in input().split()]

mi = max(-1000000, X - (K - 1))
ma = min(1000000, X + (K - 1))
R = list(range(mi,ma+1))
print(" ".join([str(x) for x in R]))



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <algorithm>
#include <time.h>
#define l(x) x<<1
#define r(x) ((x<<1) | 1)
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int inf = 2*(1e9) + 10;
const long long MOD = 1000000009;
const int NMAX = 1000005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};


int n;
int A[NMAX];
int main(){
    LL rs = 0;
    cin>>n;
    for(int i=0; i<n; ++i){
        int a;
        cin>>a;
        A[i] = a;
        if(a > i || A[i] - A[i-1] > 1){
            cout<<"-1";
            return 0;
        }
        if(A[i] == A[i-1] + 1){
            continue;
        } else {
            rs += A[i-1];
        }
    }
    rs+=A[n-1];
    cout<<rs<<"\n";

    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<cstring>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7;

const int maxn=105;

int num[maxn];
 
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		
	int n;
	cin>>n;
	
	for(int i=1;i<n;i++)
		cin>>num[i];
	
	ll int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		if(i==1)
			ans+=num[i];
		else if(i==n)
			ans+=num[i-1];
		else
			ans+=min(num[i-1],num[i]);
	}
	
	cout<<ans<<endl;
	
		
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
#define int ll 


ll a[100];

int32_t main(){
    IOS;
    ll i,j,k,n,m;
    cin >> n;
    fori(n) cin >> a[i];
    ll sum = 1000;
    ll num = 0;
    int valley = a[0];
    int peak = a[0];
    int maxprofit = 0;
    i=0;
    while (i < n - 1) {
        while (i < n - 1 && a[i] >= a[i + 1])
            i++;
        valley = a[i];
        num = sum/valley;
        sum -= num*valley;
        while (i < n - 1 && a[i] <= a[i + 1])
            i++;
        peak = a[i];
        sum += num*peak;
        // cout << valley <<" "<<peak<<" "<<num<<"\n";
        // maxprofit += peak - valley;
    }
    cout << sum <<"\n";

} 

Measured memory_bytes: 3692
#include <iostream>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    a=(a+11)%13; b=(b+11)%13;
    if (a>b) cout << "Alice" << endl;
    else if (a==b) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}

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

map<string,int> M;
int main(){
  int n;
  cin >> n;
  rep(i,n){
    string a;
    cin >> a;
    M[a]++;
  }
  int mx = 0;
  for(auto& it:M) mx = max(mx,it.second);
  for(auto& it:M) if(mx == it.second) cout << it.first << endl; 
  return 0;
}

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

int d[35][35];
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef pair<int,int> P;

signed main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s[i];
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#')continue;
      memset(d,-1,sizeof(d));
      d[i][j]=0;
      queue<P> que;
      que.push(P(i,j));
      while(que.size()){
        P p=que.front();que.pop();
        for(int k=0;k<4;k++){
          int x=p.first+dx[k],y=p.second+dy[k];
          if(x<0||x>=h||y<0||y>=w||~d[x][y]||s[x][y]=='#')continue;
          d[x][y]=d[p.first][p.second]+1;
          chmax(ans,d[x][y]);
          que.push(P(x,y));
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)




int main(void) {
	string S;
	cin >> S;
	int maxc = 0;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'R')
		{
			count++;
			if (maxc < count) {
				maxc = count;
			}
		}
		else {
			count = 0;
		}
	}
	cout << maxc << endl;

	return 0;
}

Measured memory_bytes: 3624
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X = [int(i) for i in readline().split()]

    m = sum(X) / N
    m = round(m)

    ans = 0
    for i in X:
        ans += (i - m)**2
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;
  pair<ll, pll> v[n];
  pll vals[n];
  f0r(i, n) {
    cin >> v[i].f >> v[i].s.f >> v[i].s.s;
    vals[i] = mp(abs(v[i].s.f - v[i].s.s), i);
  }

  sort(vals, vals + n);
  reverse(vals, vals + n);
  
  ll ans = 0;
  set<ll> lv, rv;
  f0r(i, n) {
    lv.insert(-i);
    rv.insert(i);
  }
  f0r(i, n) {
    ll k = vals[i].s;
    // cout << k << endl;
    pll iv = v[k].s;
    if (iv.f > iv.s) {
      auto it = lv.lower_bound(-(v[k].f - 1));
      if (it != lv.end()) {
        lv.erase(it);
        ans += iv.f;
      } else {
        ans += iv.s;
      }
    } else {
      auto it = rv.lower_bound(v[k].f);
      if (it != rv.end()) {
        rv.erase(it);
        ans += iv.s;
      } else {
        ans += iv.f;
      }
    }
  }

  cout << ans << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 30224
import heapq

N,M= map(int,input().split())
A = list(map(lambda x: int(x)*-1,input().split()))
heapq.heapify(A)
while M:
    tmp=heapq.heappop(A)*-1
    heapq.heappush(A,tmp//2*-1)
    M -=1
print(sum(A)*-1)
    


Measured memory_bytes: 20492
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	string s, t;
	while (cin >> s >> t) {
		int ans = 0;
		for (int i = 0; i < 3; i++)
			if (s[i] == t[i])
				ans++;
		cout << ans << endl;
	}
	
}

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

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double hour = 30 * h + m/60.0 * 30;
    long double minute = m * 6;
    long double d = pow(a * a + b * b - 2 * a * b * cos(abs(hour - minute) * acos(0.0) / 90.0), 0.5);
    cout << setprecision(20) << d;
}


Measured memory_bytes: 4108
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<string>s(n);
    rep(i,n)cin >> s[i];
    vector<vector<int> > a(n,vector<int>(m));
    vector<vector<int> > b(n,vector<int>(m));
    int c = 0;
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='#'){
                c++;
                a[i][j] = c;
            }
        }
    }
    rep(i,n){
        rep(j,m){
            if(a[i][j]!=0){
                if(j!=m-1&&a[i][j+1]==0){
                    a[i][j+1] = a[i][j];
                }
            }
        }
        for(int j=m-1;j>=0;j--){
            if(a[i][j]!=0){
                if(j!=0&&a[i][j-1]==0){
                    a[i][j-1] = a[i][j];
                }
            }
        }
    }
    rep(j,m){
        rep(i,n){
            if(a[i][j]!=0){
                if(i!=n-1&&a[i+1][j]==0){
                    a[i+1][j] = a[i][j];
                }
            }
        }
        for(int i=n-1;i>=0;i--){
            if(a[i][j]!=0){
                if(i!=0&&a[i-1][j]==0){
                    a[i-1][j] = a[i][j];
                }
            }
        }
    }
    rep(i,n){
        rep(j,m){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >> (istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007

int main(){
  ini(h,w);
  rep(i,h) rep(j,w){
    ins(s);
    if(s == "snuke"){
      cout << char('A' + j);
      cout << i + 1;
      cout << endl; exit(0);
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char s[200001];//0は48
    int count=0;
    scanf("%s",s);
    for(int i=0;i<200000;i++){
        if(s[i]>='0'&&s[i]<='9')count+=s[i]-'0';
        else break;
    }
    if(count%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: f64
    }
    let mut a: f64 = 100.0;
    let mut n = 0;
    loop {
        a = (a * 1.01).floor();
        n+=1;
        if a >= x {
            break;
        }
    }
    println!("{}", n);
}


Measured memory_bytes: 2696
INF = 10**18
N, W = map(int, input().split())

dp = [[INF for i in range(10**5 + 1)] for j in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    w, v = map(int, input().split())
    for j in range(10**5 + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)
        else:
            dp[i][j] = dp[i - 1][j]

res = 0

for j in range(10**5 + 1):
    if dp[N][j] <= W:
        res = j

print(res)

Measured memory_bytes: 218588
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int L,R;
    const int MOD = 2019;
    cin >> L >> R;
    int l=L%MOD,r=(R-L)+l;
    //cout << l << " " << r << endl;
    int d[2112]={};
    for(int i=l;i<=min(r,l+MOD);i++){
        d[i%MOD]=1;
    }
    int Ans=INF;
    REP(i,MOD){
        REP(j,MOD){
            if(i<j && d[i]==1 && d[j]==1){
                Ans=min(Ans,(i*j)%MOD);
            }
        }
    }
    cout << Ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
char b(char u,int k){
  k=k%26;
  int m='z'-u;
  if(m>=k)return u+k;
  else return 'a'+(k-m-1);
}
int main(){
  string s;
  cin >> s;
  int n=s.size();
  int k;
  cin >> k;
  rep(i,n-1){
    if(s[i]=='a')continue;
    if('z'-s[i]<k){
      k-=('z'-s[i]+1);
      s[i]='a';
    }
  }
  s[n-1]=b(s[n-1],k);
  cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,a,b;
   cin>>n>>a>>b;

   cout<<(n / (a + b)) * a + min(n % (a + b), a);
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[6];
    int i,open=0;
    while(scanf("%s",s)==1)
    {
        for(i=0;s[i]!='\0';i++)
        {
            if(s[i]=='A'&&s[i+1]=='C')
            {
            printf("Yes\n");
            open=1;
            break;
            }
        }
        if(open==0)printf("No\n");
        open=0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
   string s; cin >> s;
   int x,y; cin >> x >> y;
   int n=s.length();
   s+='T';
   vector<int> gox(16100,0),goy(16100,0),gox2(16100,0),goy2(16100,0);
   int now=0;
   int cnt=0;
   while(s[now++]=='F') cnt++;
   gox[cnt+8000]=1;
   goy[8000]=1;

   bool sw=false;
   bool x2=true;
   bool y2=true;
   cnt=0;
   for(int i=now; i<n+1; i++){
       if(s[i]=='F'){
           cnt++;
           continue;
       }
       else if(sw==true){
           if(x2==true){
                rep(j,16100){
                    gox2[j]=0;
                    if(j+cnt<16100){
                        if(gox[j+cnt]==1) gox2[j]=1;
                    }
                    if(j-cnt>=0){
                        if(gox[j-cnt]==1) gox2[j]=1;
                    }
                }
                x2=false;
           }
           else{
                rep(j,16100){
                    gox[j]=0;
                    if(j+cnt<16100){
                        if(gox2[j+cnt]==1) gox[j]=1;
                    }
                    if(j-cnt>=0){
                        if(gox2[j-cnt]==1) gox[j]=1;
                    }
                }
                x2=true;
           }
           sw=false;
       }
       else{
           if(y2==true){
                rep(j,16100){
                    goy2[j]=0;
                    if(j+cnt<16100){
                        if(goy[j+cnt]==1) goy2[j]=1;
                    }
                    if(j-cnt>=0){
                        if(goy[j-cnt]==1) goy2[j]=1;
                    }
                }
                y2=false;
           }
           else{
                rep(j,16100){
                    goy[j]=0;
                    if(j+cnt<16100){
                        if(goy2[j+cnt]==1) goy[j]=1;
                    }
                    if(j-cnt>=0){
                        if(goy2[j-cnt]==1) goy[j]=1;
                    }
                }
                y2=true;
            }
            sw=true;
        }
        cnt=0;
        //cout << gox2[8001]
    }

    string ans="No";
    if(x2==true && y2==true){
        if(gox[x+8000]==1 && goy[y+8000]==1) ans="Yes";
    }
    if(x2==true && y2==false){
        if(gox[x+8000]==1 && goy2[y+8000]==1) ans="Yes";
    }
    if(x2==false && y2==true){
        if(gox2[x+8000]==1 && goy[y+8000]==1) ans="Yes";
    }
    if(x2==false && y2==false){
        if(gox2[x+8000]==1 && goy2[y+8000]==1) ans="Yes";
    }

    cout << ans << endl;
return 0;
}
/*
1 5 6 3 3 4 2 

4 6

0 2 10 12
*/

Measured memory_bytes: 3808
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll modpow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}


int main() {
    ll n, i, ans=0, tmp=0, cnt=0, k=0;
    cin >> n;
    ll a[n+1];
    a[n]=100000;
    for(i=0; i<n; i++) {
        cin >> a[i];
    }
    
    for(i=0; i<n-1; i++) {
        tmp=1;
        while(a[i]==a[i+1]) {
            tmp++;
            i++;
        }
        ans+=tmp/2;
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = -1
    aabs = 10**12
    amax = a[N-1]
    # print(a,amax)
    for i in range(N-1):
        tmp = abs(amax/2 - a[i])
        if tmp < aabs:
            aabs = tmp
            ans = i
    print(a[N-1], a[ans])

if __name__ == "__main__":
    main()


Measured memory_bytes: 14936
#include <cstdio>
#include <cstring>
#include <unordered_map>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
const int mod=1e9+7;
int n,m;
unordered_map<int,int> a;

LL C(int n,int m) {
    if (m*2>n) m=n-m;
    LL ret=1;
    for (int i=1;i<=m;i++) {
        ret*=(n-i+1)%mod;
        while (ret%i!=0) ret+=mod;
        ret/=i;
        ret%=mod;
    }
    return ret;
}

void solve(int x) {
    for (int i=2;i*i<=x;i++) {
        if (x%i==0) {
            int num=0;
            while (x%i==0) x/=i,num++;
            a[i]=num;
        }
    }
    if (x>1) a[x]++;
}

int main() {
    scanf("%d%d",&n,&m);
    solve(m);
    LL ans=1;
    for (auto i:a) {
        ans*=C(n-1+i.second,i.second);
        ans%=mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        double r = Double.parseDouble(line);
        System.out.println(String.format("%.6f %.6f", r*r*Math.PI, 2*r*Math.PI));
    }
}

Measured memory_bytes: 16916
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string a,b;
    cin>>n>>a>>b;
    for(int i=n;i>0;i--){
        if(a.substr(n-i,i)==b.substr(0,i)){
            cout<<n+(n-i)<<endl;
            return 0;
        }
    }
    cout<<n+n<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define L 100003*3
long long dis[L];

void solve(long long N, long long M, std::vector<pair<ll, ll>> Edge, vector<ll> startPos, vector<ll> endPos, long long S, long long T){
    memset(dis, -1, sizeof(dis));
    dis[S] = 0;
    queue<long long> Q;
    Q.push(S);
    while (!Q.empty()) {
        auto v = Q.front();
        Q.pop();
        auto start = startPos[v];
        auto end = endPos[v];
        //start = 0; end = M;
        if (start >= M) continue;
        for (int i = start; i < end; i++) {
            auto s = Edge[i].first;
            auto t = Edge[i].second;
            //assert(s == v);
            if (s != v) continue;
            long long& d = dis[t];
            if (d < 0) {
                Q.push(t);
                d = dis[v] + 1;
            }
        }
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]); u[i]--;
        scanf("%lld",&v[i]); v[i]--;
    }
    long long S;
    scanf("%lld",&S); S--;
    long long T;
    scanf("%lld",&T); T--;

    std::vector<long long> U(M * 3);
    std::vector<long long> V(M * 3);
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 3; j++) {
            U[i * 3 + j] = u[i] * 3 + j;
            V[i * 3 + j] = v[i] * 3 + (j + 1) % 3;
        }
    }
    
    N *= 3, M *= 3, S *= 3, T *= 3;
    vector<pair<ll, ll>> Edge(M);
    for (int i = 0; i < M; i++) {
        Edge[i] = make_pair(U[i], V[i]);
    }
    sort(Edge.begin(), Edge.end());
    vector<ll> startPos(N);
    vector<ll> endPos(N);
    for (int i = 0; i < N; i++) {
        startPos[i] = M + 1;
        endPos[i] = -1;
    }
    for (ll i = 0; i < M; i++) {
        auto s = Edge[i].first;
        startPos[s] = min(startPos[s], i);
        endPos[s] = max(endPos[s], i + 1);
    }
    solve(N, M, std::move(Edge), std::move(startPos), std::move(endPos), S, T);

    cout << (dis[T] < 0 ? -1 : dis[T] / 3) << endl;
    return 0;
}


Measured memory_bytes: 18176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
lli a[1000];
int main() {
  cin >> n; read_n(a, n);

  lli p=-1, ans = 0;
  for (lli i=0; i<n; ++i) {
    if (a[i] == p) { ++ans; p=-1; }
    else { p=a[i]; }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll A, B, C, ans=0;
    cin >> A >> B >> C;

    if(A%2!=B%2 or B%2!=C%2 or C%2!=A%2){
        if(A%2==B%2){
            A++;B++;
        }
        else if(C%2==B%2){
            C++;B++;
        }
        else {
            A++;C++;
        }
        ans++;
    }

    cout << ans + (3*max({A, B, C})-A-B-C)/2 << nl;
}


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

int main() {
    long long n;
    cin >> n;
    int ans = 0;
    vector<int> V;
    while (n) V.push_back(n % 10), n /= 10;
    reverse(V.begin(), V.end());
    int s = 0;
    for (int i = 0; i < V.size(); s += V[i++]) {
        if (V[i]) ans = max(ans, s + V[i] - 1 + 9 * ((int)V.size() - i - 1));
    }
    cout << max(ans, s) << endl;
    return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int  a[3] ;

int main() {

  int count = 0 ;
  cin >> a[0] >> a[1] >> a[2] ;
  sort(a , a+3) ;

  while(a[1] - a[0] >=2){
    a[0]+=2 ;
    count++ ;
  }
  while(a[2] -a[1] >=1){
    a[0]++, a[1]++ ;
    count++ ;
  }

  if(a[2] > a[0]) count+=2 ;

  cout << count << endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
n = int(input())
l = [input() for _ in [0]*n]
d = {}
for s in l:
  if s in d:
    d[s]+=1
  else:
    d[s]=0
m = max(list(d.values()))
ans = []
for s in d:
  if d[s] == m:
    ans.append(s)
ans.sort()
for s in ans:
  print(s)

Measured memory_bytes: 35204
#include <bits/stdc++.h>
//#define mp make_pair
using namespace std;
typedef pair<int, int> pii;

long long x, y;
long long ans;

int main() {
	cin>> x >> y;
	if(x%3 == 0 || y%3 == 0) {
		cout<< "0" << endl;
		return 0;
	}
	ans = 1e10;
	for(int a = 1; a <  x; a++) {
		long long s_a = a*y;
		long long s_b = (x - a)*floor(y/2);
		long long s_c = (x - a)*(y - floor(y/2));
		long long tmp = max(max(s_a, s_b), s_c) - min(min(s_a, s_b), s_c);
		ans = min(ans, tmp);
		if(a + 1 == x) continue;
		s_b = floor((x - a)/2)*y;
		s_c = ((x - a) - floor((x - a)/2))*y;
		tmp = max(max(s_a, s_b), s_c) - min(min(s_a, s_b), s_c);
		ans = min(ans, tmp);
	}
	swap(x, y);
	for(int a = 1; a <  x; a++) {
		long long s_a = a*y;
		long long s_b = (x - a)*floor(y/2);
		long long s_c = (x - a)*(y - floor(y/2));
		long long tmp = max(max(s_a, s_b), s_c) - min(min(s_a, s_b), s_c);
		ans = min(ans, tmp);
		if(a + 1 == x) continue;
		s_b = floor((x - a)/2)*y;
		s_c = ((x - a) - floor((x - a)/2))*y;
		tmp = max(max(s_a, s_b), s_c) - min(min(s_a, s_b), s_c);
		ans = min(ans, tmp);
	}
	cout<< ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

const int N = 300000, M = 300000, K = 300000;

int xx[K], yy[K];
int kkx[1 + N], kky[1 + M];
map<pair<int, int>, bool> mp;
int qux[N], quy[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m, k; cin >> n >> m >> k;
	for (int h = 0; h < k; h++)
		cin >> xx[h] >> yy[h];
	for (int h = 0; h < k; h++) {
		kkx[xx[h]]++, kky[yy[h]]++;
		mp[make_pair(xx[h], yy[h])] = true;
	}
	int kx = 0;
	for (int x = 1; x <= n; x++)
		kx = max(kx, kkx[x]);
	int ky = 0;
	for (int y = 1; y <= m; y++)
		ky = max(ky, kky[y]);
	int cntx = 0;
	for (int x = 1; x <= n; x++)
		if (kkx[x] == kx)
			qux[cntx++] = x;
	int cnty = 0;
	for (int y = 1; y <= m; y++)
		if (kky[y] == ky)
			quy[cnty++] = y;
	for (int hx = 0; hx < cntx; hx++)
		for (int hy = 0; hy < cnty; hy++)
			if (!mp[make_pair(qux[hx], quy[hy])]) {
				cout << kx + ky << '\n';
				return 0;
			}
	cout << kx + ky - 1 << '\n';
	return 0;
}


Measured memory_bytes: 29356
def myAnswer(N:int,A:list) -> int:
   i = 1
   counter = 0
   for a in A:
      if(a == i):
         i+=1
      else:
         counter +=1
   return counter if(1 in A) else -1


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    int n=s.size();
    int k; cin >> k;
    rep(i,min(n,k)) if(s[i]!='1') {cout<<s[i]<<endl; return 0;}
    cout<<1<<endl;

}

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

using namespace std;

int n;
typedef long long ll;



int main() {
cin>>n;
int c[n+1];
c[0]=101;
    for (int i = 1; i <= n; ++i) {
       cin>>c[i];
    }
    sort(c,c+n+1,greater<int>());
    int a=0,b=0;
    for (int j =1; j <= n; ++j) {
       if(j%2==0)b+=c[j];
       else a+=c[j];
    }
    cout<<a-b;
}

Measured memory_bytes: 256
#include <stdio.h>
     
    int main(){
        long long  a;
        long long  b;
        long long  n;
     
        scanf("%lld %lld %lld",&n,&a,&b);
        long long k=n/(a+b); //ciclosCompletos
        long long   mod=n%(a+b); //sobra
        long long nbas,res; //numero de bolas azuis q sobraram,r=resposta
     

            
        if(mod<a)
            nbas = mod;
        else
            nbas = a;
     
        res = k*a + nbas;
     
        printf("%lld",res);
     
     
     
        return 0;
     
    }

Measured memory_bytes: 128
#include <stdio.h>
#define NUM 10
#define DISP_NUM 3

int main(void){
	int i,j,k,height;
	int rank[DISP_NUM] = {0};
	for(i = 0; i < NUM; i++){
		scanf("%d",&height);
		for(j = 0; j < DISP_NUM; j++){
			if(rank[j] < height){
				for(k = DISP_NUM-1; k >= j; k--){
					rank[k] = rank[k-1];
				}
				
				rank[j] = height;
				break;
			}
		}
	}
	for(i = 0; i < DISP_NUM; i++){
		printf("%d\n",rank[i]);
	}
	return 0;
}

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

int main(){
  while(1){
    int n, m;
    cin >> n;
    if(n == 0) break;

    cin >> m;

    bool t[502][502];

    for(int i = 1; i <= n; i++){
      fill(t[i] + 1, t[i] + n + 1, false);
    }

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      t[a][b] = t[b][a] = true;
    }

    int ans = 0;

    for(int i = 2; i <= n; i++){
      //友達
      if(t[i][1]){
        ans++;
        continue;
      }

      //友達の友達
      for(int j = 2; j <= n; j++){
        if(i == j) continue;
        if(t[i][j] && t[j][1]){
          ans++;
          break;
        }
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 4e5+5;
const int MOD = 998244353; //1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a1,a2,a3;
    cin>> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22) cout << "bust\n";
    else cout << "win\n";
    return 0;
}


Measured memory_bytes: 256
import math
n, k  = map(int,input().split())
cnt = 0
for i in range(1,n+1):
    if i >= k:
        cnt += 1/n
        continue
    else:
        tmp = math.log2(k / i)
        m = math.ceil(tmp)
        #print(m)
        cnt += 1/((2**m)*n)
print(cnt)

Measured memory_bytes: 3060
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [x-1 for x in A]

town = 0
cnt = 0

# memo = []
# visited = [False] * n
# visited[0] = -1

# start = 0
# loop = 10**8
# start_cnt = 0
# for i in range(n*2):
#     town = A[town]
#     memo.append(town)
#     if visited[town] != False:
#         start_cnt = i + 1
#         loop = i - visited[town]
#         break
#     else:
#         visited[town] = i
#
# for i in range((k-start_cnt)%loop):
#     town = A[town]
#
# print(town+1)

visited = [False] * n
visited[0] = 0

for i in range(n):
    town = A[town]
    if visited[town]:
        good_town = town
        break
    visited[town] = i+1

town = good_town

for i in range(n):
    town = A[town]
    if town == good_town:
        loop = i + 1

if k >= visited[good_town]:
    k = ((k-visited[good_town])%loop)+visited[good_town]


town = 0
for i in range(k):
    town = A[town]
print(town+1)

Measured memory_bytes: 32312
#include<iostream>
using namespace std;
int N,A[100][100];
main()
{
	cin>>N;
	if(N==2)
	{
		cout<<-1<<endl;
		return 0;
	}
	if(N%2)
	{
		for(int i=1;i<=N-1;i++)A[N-1][i-1]=i;
		for(int i=1;i<=N-1;i+=2)
		{
			for(int j=1;j<i;j++)
			{
				A[i-1][j-1]=A[i][j-1]=j;
			}
			A[i-1][i-1]=i+1;
			A[i][i]=i;
			A[i-1][i]=A[i][i-1]=i+2;
			for(int j=i+2;j<=N-1;j++)A[i-1][j-1]=A[i][j-1]=j+1;
		}
	}
	else
	{
		for(int i=1;i<=N-2;i+=2)
		{
			for(int j=1;j<i;j++)
			{
				A[i-1][j-1]=A[i][j-1]=j;
			}
			A[i-1][i-1]=i+1;
			A[i][i]=i;
			A[i-1][i]=A[i][i-1]=i+2;
			for(int j=i+2;j<=N-1;j++)A[i-1][j-1]=A[i][j-1]=j+1;
		}
		for(int j=1;j<=N-3;j++)A[N-2][j-1]=A[N-1][j-1]=j;
		A[N-2][N-3]=N;
		A[N-1][N-2]=N-1;
		A[N-2][N-2]=A[N-1][N-3]=N-2;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N-1;j++)cout<<A[i][j]<<(j==N-2?"\n":" ");
	}
}


Measured memory_bytes: 256