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

using ld = long double;
using point = std::complex<ld>;
using polygon = std::vector<point>;

constexpr ld eps = 1e-10;
constexpr ld pi = std::acos(-1.0);

bool comp(point a, point b) {
    return std::real(a) < std::real(b) || (std::real(a) <= std::real(b) && std::imag(a) < std::imag(b));
}

std::vector<point> unique(std::vector<point> ps) {
    std::sort(std::begin(ps), std::end(ps), comp);
    std::vector<point> res;
    for(auto& p : ps) {
        if(res.empty() || abs(res.back() - p) > eps) {
            res.push_back(p);
        }
    }
    return res;
}

ld dot(point const& a, point const& b) {
    return std::real(std::conj(a) * b);
}
ld cross(point const& a, point const& b) {
    return std::imag(std::conj(a) * b);
}

int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if(cross(b, c) > eps) return 1;            // a -> b -> c : counterclockwise
    if(cross(b, c) < -eps) return -1;          // a -> b -> c : clockwise
    if(dot(b, c) < 0) return 2;                // c -> a -> b : line
    if(std::norm(b) < std::norm(c)) return -2; // a -> b -> c : line
    return 0;                                  // a -> c -> b : line
}

struct segment {
    segment() : a(0, 0), b(0, 0) {}
    segment(point a, point b) : a(a), b(b) {}
    point a, b;
};

struct line {
    line() : a(0, 0), b(0, 0) {}
    line(point a, point b) : a(a), b(b) {}
    line(segment s) : a(s.a), b(s.b) {}
    point a, b;
};


bool isis_ll(line l, line m) {
    return cross(l.b - l.a, m.b - m.a) < eps;
}

bool isis_ls(line l, segment s) {
    return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(line l, point p) {
    return (std::abs(cross(l.b - p, l.a - p)) < eps);
}

bool isis_sp(segment s, point p) {
    return (std::abs(s.a - p) + std::abs(s.b - p) - std::abs(s.b - s.a) < eps);
}

bool isis_ss(segment s, segment t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0
        && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

point proj(line l, point p) {
    long double t = dot(p - l.a, l.a - l.b) / std::norm(l.a - l.b);
    return l.a + t * (l.a - l.b);
}

point is_ll(line s, line t) {
    point sv = s.b - s.a, tv = t.b - t.a;
    assert(cross(sv, tv) != 0);
    return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

point is_ss(segment s1, segment s2) {
    assert(isis_ss(s1, s2));
    point sv = s1.b - s1.a, tv = s2.b - s2.a;
    if(cross(sv, tv) == 0) {
        if(std::abs(s1.a - s2.a) < eps || std::abs(s1.a - s2.b) < eps) {
            return s1.a;
        } else {
            return s1.b;
        }
    } else {
        return is_ll(line(s1), line(s2));
    }
}

using namespace std;

int main() {
    int q;
    cin >> q;
    while(q--) {
        vector<segment> segs(2);
        for(int i = 0; i < 2; ++i) {
            ld x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            segs[i] = segment(point(x1, y1), point(x2, y2));
        }
        auto ans = is_ss(segs[0], segs[1]);
        cout << fixed << setprecision(10) << real(ans) << ' ' << imag(ans) << endl;
    }
}



Measured memory_bytes: 3356
def main():
    A, B = list(input().split())

    count = 0
    for i in range(int(A), int(B)+1):
        I = str(i)
        if (I[0] == I[-1]) and (I[1]==I[-2]):
            count += 1
    return count

if __name__ == '__main__':
    print(main())

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	vector<int> A(N);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}
	sort(A.begin(),A.end());

	if(A.front() == A.back()){
		if(A.front() == N - 1){
			puts("Yes");
		}
		else if(A.front() >= 1 && A.front() <= N / 2){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
	else if(A.front() + 1 == A.back()){
		int x = count(A.begin(),A.end(),A.front());
		int y = count(A.begin(),A.end(),A.back());
		if(y <= 1){
			puts("No");
		}
		else{
			int lo = 1,hi = y / 2;
			if(lo + x <= A.back() && A.back() <= hi + x){
				puts("Yes");
			}
			else{
				puts("No");
			}
		}
	}
	else{
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){

  int H, W, i, j;
  while(1){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0){
      break;
    }
    for(i = 0; i < H; i++){
      for(j = 0; j < W; j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string Solve(const string &a, const string &b)
{
    string res = "";
    for (size_t i = 0; i < max(a.size(), b.size()); i += 1) {
        if (i < a.size()) {
            res.push_back(a[i]);
        }
        if (i < b.size()) {
            res.push_back(b[i]);
        }
    }
    return res;
}

int main()
{
    string a, b;
    getline(cin, a);
    getline(cin, b);

    auto res = Solve(a, b);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
result = [-1]*n
ans = 0
for el in sc:
    s = el[0]
    c = el[1]
    if s==1 and c==0 and n != 1:
        ans = -1
        break
    elif result[s-1] == -1 or result[s-1] == c:
        result[s-1] = c
    else:
        ans = -1
        break
if ans == -1:
    print(ans)
else:
    if result[0] == -1:
        result[0] = 1
    for i in range(1, len(result)):
        if result[i] == -1:
            result[i] = 0
    i = 0
    for el in result[::-1]:
        ans += el*(10**i)
        i += 1
    if ans == 1 and len(sc) == 0:
        ans = 0
    print(ans)


Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    split_A = sum(A[:i+1])
    split_B = sum(B[(N-i)*-1::])
    total = split_A + split_B
    if total > ans:
        ans = total
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
#define sz(x) ((int)x.size())

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
const int N = 1e5+5;
typedef vector<int> vi;

 
int32_t main()
{
   string s;
   cin >> s;
   if(s.size() == 2)
   {
      if(s[0] == s[1])
         cout << "1 2";
      else
         cout <<"-1 -1";
      return 0;
   }
   for(int i = 0; i + 2 < sz(s); i++)
   {
      string p;
      p += s[i]; p += s[i+1]; p += s[i+2];
      for(int j = 0; j < 26; j++)
         if(count(p.begin(), p.end(), ('a'+j)) >= 2)
         {
            cout << i + 1<<" "<<i + 3;
            exit(0);
         }
   }
   cout <<"-1 -1";
   return 0;
}

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 31;

void solve() {
	string s;
	cin >> s;
	vector<int> a(s.size());
	for (int i = 0; i < s.size(); i++) a[i] = s[i] - '0';

	int k;
	cin >> k;
	int n = s.size();
	vector<vector<vector<int>>> dp(2, vector<vector<int>>(k + 1, vector<int>(n)));
	if (k) {
		dp[1][1][0] = 1;
		dp[0][1][0] = a[0] - 1;
	}
	dp[0][0][0] = 1;

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[0][j][i] += dp[0][j][i - 1] + (j ? dp[0][j - 1][i - 1] * 9 + dp[1][j - 1][i - 1] * max(0LL, a[i] - 1) : 0) + (a[i] ? dp[1][j][i - 1] : 0);
			dp[1][j][i] = a[i] ? (j ? dp[1][j - 1][i - 1] : 0) : dp[1][j][i - 1];
		}
	}
	cout << dp[0][k][n - 1] + dp[1][k][n - 1];
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n;
    cin >> n;
    vector< i_i > input(n, i_i(0, 0));
    vi ans(n, 0);
    rep(i, n) {
        cin >> input[i].first;
        input[i].first *= -1;
        input[i].second = i;
    }
    sort(all(input));

    rep(i, n) {
        input[i].first *= -1;
    }
  
    //rep(i, n) cout << input[i].first << " " << input[i].second << endl;

    int add = input[0].second, ptr = 0;
    Rep(i, n) {
        if (input[ptr].first != input[i].first) {
            ans[add] += (input[ptr].first - input[i].first) * i;
            ptr = i;
            add = min(add, input[i].second);
        }
    }
    ans[add] += (input[ptr].first - 0) * n;

    rep(i, n) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3456
unittest
{
	assert( [ "8 3 4" ].parse.expand.solve == 4 );
	assert( [ "8 0 4" ].parse.expand.solve == 0 );
	assert( [ "6 2 4" ].parse.expand.solve == 2 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nab = input.front.split.to!( long[] );
	return tuple( nab[ 0 ], nab[ 1 ], nab[ 2 ] );
}

auto solve( long n, long a, long b )
{
	auto g = ( a + b );
	auto c = n / g;
	auto r = n % g;
	return a * c + min( a, r );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              300005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main(){
    Fast;
    int a,b,c, i,j, n,m,t, cs=1;
    
    cin>>a;
    cout<<(a)+(a*a)+(a*a*a)<<endl;




    return 0;
}



Measured memory_bytes: 3644
# coding: utf-8
# Your code here!
s = input()
a = s[::-1]
if s == a:
    t = s[0:(len(s)-1)//2]
    b = t[::-1]
    if t == b:
        u = s[(len(s)+3)//2-1:]
        c = u[::-1]
        if u == c:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")
#print(a,b,u,c)


Measured memory_bytes: 38384
#!/usr/bin/env python3
import sys


def solve(c: "List[str]"):
    return c[0][0] + c[1][1] + c[2][2]


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [next(tokens) for _ in range(3)]  # type: "List[str]"
    print(solve(c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3060
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

    int n;
	cin >> n;
    
    int array[n];
    for(int i = 0; i< n; i++)
    {
        cin >> array[i];
    }
    
    int max1 = INT_MIN;
    int max2 = INT_MIN;
    int indexMax1 = -1;
    int indexMax2 = -1;
    
    for(int i = 0; i< n; i++)
    {
        if(array[i] > max1)
        {
            max2 = max1;
            max1 = array[i];
            
            indexMax2 = indexMax1;
            indexMax1 = i;
        }
        
        else if(array[i] > max2)
        {
            max2 = array[i];
            indexMax2 = i;
        }
    }
    
//    printf( "max1 = %d\tmax2 = %d\tindexMax2 = %d\n" , max1 , max2 , indexMax2);
    
    for(int i = 0; i< n; i++)
    {
        if(indexMax1 != i)
        {
            cout << max1 << endl;
        }
        else{
            cout << max2 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int D;cin>>D;
    if(D==25) cout<<"Christmas"<<endl;
    else if(D==24) cout<<"Christmas Eve"<<endl;
    else if(D==23) cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef long long ll;

int main(void) {
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - b - a;
    if (4 * a * b < d * d && d > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque

n, m = list(map(int, input().split()))
root_dict = {}

for _ in range(m):
    a, b = list(map(int, input().split()))
    if a not in root_dict:
        root_dict[a] = deque([b])
    else:
        root_dict[a].append(b)
    if b not in root_dict:
        root_dict[b] = deque([a])
    else:
        root_dict[b].append(a)

visited = [1] + [-1] * (n-1)

done = deque([1])

while done:
    x = done.popleft()
    while root_dict[x]:
        i = root_dict[x].popleft()
        if visited[i-1] < 0:
            visited[i-1] = x
            done.append(i)

if -1 in visited:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(visited[i])


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

int main(){
  int n;
  cin>>n;
  ll ans =0;
  rep(i,n){
    if((i+1)%3!=0){
      if((i+1)%5!=0)
        ans+=(i+1);
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#define N 100000

int main(void){
    int n,k;
    int h[N];
    int i;
    int count = 0;
    
    scanf("%d %d", &n, &k);
    
    for(i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    
    for(i = 0; i < n; i++){
        if(h[i] >= k){
            count++;
        }
    }
    
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 512
N=int(input())
from math import floor
a=floor(N**(1/2))
i=1
summ=0
for i in range(1,a+1):
    if N%i==0:
        b=N//i
        if b>i:
            summ=summ+(b-i)*2-1
    else:
        b=N//i
        summ=summ+(b-i+1)*2-1
    i+=1
print(summ)

Measured memory_bytes: 9444
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 3005;
int n,S; 
int a[MAXN];

int dp[MAXN][MAXN][2];
const int MOD = 998244353;

int rec(int idx,int sum,int flag){
    if(idx == n+1) return 0;

    int &ans = dp[idx][sum][flag];

    if(ans != -1) return ans;

    ans = 0;

    ans = (ans + rec(idx+1,sum,flag));

    if(flag == 0){
        int n_S = sum + a[idx];
        if(n_S < S) ans = (ans + (idx*rec(idx+1,n_S,1))%MOD)%MOD;
        if(n_S == S) ans = (ans + (idx*(n-idx+1))%MOD)%MOD; 
    }else {
        int n_S = sum + a[idx];
        if(n_S < S) ans = (ans + rec(idx+1,n_S,flag)%MOD)%MOD;
        if(n_S == S) ans = (ans + (n-idx+1)%MOD)%MOD; 
    }

    return ans;
}

void solve(){
    cin>>n>>S;

    FOR(i,1,n) cin>>a[i];

    MINUS(dp);

    cout<<rec(1,0,0)<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
#define ll long long
#define fr(i, l, r) for(int i = l;i < r;i++)

using namespace std;

const int N = 200001;
const ll OO = 1e13;
ll tr[3][4 * N];
ll lz[4 * N];

void init(int in, int l, int r){
  if(l == r){
    fr(i, 0, 3)
      tr[i][in] = 1e13 + 1ll * (i - 1) * l;
    return;
  }
  int m = (l + r) / 2;
  init(in * 2, l, m);
  init(in * 2 + 1, m + 1, r);
  fr(i, 0, 3)
    tr[i][in] = min(tr[i][2 * in], tr[i][2 * in + 1]);
}

void push(int in, int l, int r){
  fr(i, 0, 3)
    tr[i][in] += lz[in];
  if(l != r){
    lz[2 * in] += lz[in], lz[2 * in + 1] += lz[in];
  }
  lz[in] = 0;
}

void ass(int in, int l, int r, int j, ll v){
  push(in, l, r);
  if(l > j || r < j)
    return;
  if(l == r){
    fr(i, 0, 3)
      tr[i][in] = v + 1ll * l * (i - 1);
    return;
  }
  int m = (l + r) / 2;
  ass(in * 2, l, m, j, v);
  ass(in * 2 + 1, m + 1, r, j, v);
  fr(i, 0, 3)
    tr[i][in] = min(tr[i][2 * in], tr[i][2 * in + 1]);
}

struct MnRes{
  ll mn[3];
  MnRes(){
    mn[0] = mn[1] = mn[2] = OO;
  }
  MnRes(ll a, ll b, ll c){
    mn[0] = a, mn[1] = b, mn[2] = c;
  }
  void upd(const MnRes& ot){
    fr(i, 0, 3)
      mn[i] = min(mn[i], ot.mn[i]);
  }
};


MnRes get(int in, int l, int r, int s, int e){
  push(in ,l, r);
  if(l > e || r < s)
    return MnRes();

  if(l >= s && r <= e){
    return MnRes(tr[0][in], tr[1][in], tr[2][in]);
  }
  int m = (l + r) / 2;
  MnRes res = get(2 * in, l, m, s, e);
  res.upd(get(2 * in + 1, m + 1, r, s, e));
  return res;
}

void add(int in, int l, int r, int s, int e, ll v){
  push(in, l, r);
  if(l > e || r < s)
    return;
  if(l >= s && r <= e){
    lz[in] += v;
    push(in, l, r);
    return;
  }
  int m = (l + r) / 2;
  add(2 * in, l , m, s, e, v);
  add(2 * in + 1, m + 1, r, s, e, v);
  fr(i, 0, 3)
    tr[i][in] = min(tr[i][2 * in], tr[i][2 * in + 1]);
}
int n, q, a, b;
//
//void print(int in = 1, int l = 0, int r = n -1){
//  push(in, l, r);
//  printf("l= %d, r= %d, tr[0]= %lld, tr[1]= %lld, tr[2]= %lld, lz[0]= %lld, lz[1]= %lld, lz[2]= %lld\n", l, r, tr[0][in], tr[1][in], tr[2][in], lz[0][in], lz[1][in], lz[2][in]);
//  if(l == r){
//    return;
//  }
//  int m = (l + r) / 2;
//  print(2 * in, l, m);
//  print(2 * in + 1, m + 1, r);
//}

int x[N];

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n >> q >> a >> b;
  a--, b--;
  fr(i, 0, q){
    cin >> x[i];
    x[i]--;
  }
  init(1, 0, n - 1);
//  print();
  ass(1, 0, n - 1, a, abs(b - x[0]));
//  print();
  ass(1, 0, n - 1, b, abs(a - x[0]));
  for(int i = 1;i < q;i++){
    // calc dp[i][x[i]]
    MnRes r1 = get(1, 0, n - 1, 0, x[i]);
    MnRes r2 = get(1, 0, n - 1, x[i], n - 1);
    ll val = min(x[i] + r1.mn[0], r2.mn[2] - x[i]);
    add(1, 0, n - 1, 0, n - 1, abs(x[i] - x[i -1]));
    ass(1, 0, n - 1, x[i - 1], val);
//    print();
//    cout << endl;
  }
//  print();
  cout << get(1, 0, n - 1, 0, n - 1).mn[1] << endl;
//  cout << get(1, 0, n - 1, 0, n - 1).mn[1];
}


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

#define rep(n)      for (int i = 0; i < n; ++i)
#define rep2(n)     for (int j = 0; j < n; ++j)
#define mp          make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

int main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    set<string> items;
    string item;
    rep(n) {
        cin >> item;
        items.insert(item);
    }
    
    cout << items.size() << "\n";
    
    return 0;
}


Measured memory_bytes: 19236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> imos(n+1, 0);
  rep(i, k){
    rep(j, n+1){
      imos.at(j) = 0;
    }
    rep(j, n){
      int l = max(0, j - a.at(j));
      int r = min(n, j + a.at(j)+1);
      imos.at(l)++;
      imos.at(r)--;
    }
    int now = 0;
    bool f = false;
    rep(i, n){
      now += imos.at(i);
      a.at(i) = now;
      if(a.at(i) != n) f = true;
    }
    if(f == false) break;
  }
  rep(i, n){
    if(i != 0) cout << " ";
    cout << a.at(i);
  }
  cout << endl;
  return 0;
}

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

string s;

inline void work(){
	cin >> s;														//è¾“å…¥ä¸€ä¸ªå­—ç¬¦ä¸²
	if (s.size() == 6 && s[2] == s[3] && s[4] == s[5]) puts("Yes");	//å¦‚æžœè¿™ä¸ªå­—ç¬¦ä¸²ç¬¦åˆæ¡ä»¶å°±è¾“å‡ºYes
	else puts("No");												//å¦åˆ™è¾“å‡ºNo
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x3 = x2 - (y2 - y1);
        int y3 = y2 + x2 - x1;
        int x4 = x1 - (y2 - y1);
        int y4 = y1 + x2 - x1;
        System.out.print(x3 + " " + y3 + " " + x4 + " " + y4);

    }
}

Measured memory_bytes: 39884
from bisect import *

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
D = {}
for i in range(M) :
    p, y = L[i]
    if p not in D :
        D[p] = [y]
    else :
        D[p].append(y)

for p in D :
    D[p] = sorted(D[p])

for i in range(M) :
    p, y = L[i]
    ind = bisect_left(D[p], y)
    res = str(p).zfill(6) + str(ind+1).zfill(6)
    print(res)


Measured memory_bytes: 42140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[] heights = new int[n];
            int[] dp = new int[n];

            for (int i = 0; i < n; i++) {
                heights[i] = in.nextInt();
                dp[i] = Integer.MAX_VALUE;
            }

            dp[0] = 0;

            for (int i = 0; i < n; i++) {
                int[] stones = {i + 1, i + 2};
                for (int j : stones) {
                    if (j < n) {
                        int cost = Math.abs(heights[j] - heights[i]);
                        dp[j] = Math.min(dp[j], dp[i] + cost);
                    }
                }
            }

            out.println(dp[n - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int Money(int X){
  int money=0;
  if(X==1){
    money+=300000;
  }else if(X==2){
    money+=200000;
  }else if(X==3){
    money+=100000;
  }
  
  return money;
}
int main(){
  int X,Y;
    int money=0;
  cin>>X>>Y;
  money=Money(X)+Money(Y);
  if(money==600000){
    money=1000000;
  }
  cout<<money<<endl;
  return 0;

}

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

bool isprime(int n) {
  if (n==1)
    return false;
  else {
    bool ok = true;
    for (int i=2; i*i<=n; i++) {
      if (n%i==0) {
        ok = false;
        break;
      }
    }
    return ok;
  }
}

int main() {
  int x;
  cin >> x;
  for (int i=x; i<=200000; i++) {
    if (isprime(i)) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using i64 = long long;
using B = std::bitset<701>;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> g(n), cg(n, std::vector<int>(n));
    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        cg[a][b] = cg[b][a] = 1;
    }

    for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
        if (cg[i][j]) continue;
        g[i].push_back(j);
        g[j].push_back(i);
    }

    std::vector<int> c(n);
    std::vector<std::pair<int, int>> w;
    for (int i = 0; i < n; i++) {
        if (c[i]) continue;

        std::deque<int> q { i };
        c[i] = 1;
        int o = 0, e = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop_front();

            if (c[v] == 1) o++;
            else e++;

            for (int to : g[v]) {
                if (c[to]) {
                    if (c[to] == c[v]) {
                        std::cout << -1 << std::endl;
                        return 0;
                    }
                } else {
                    c[to] = 3 - c[v];
                    q.push_back(to);
                }
            }
        }

        w.emplace_back(o, e);
    }

    B dp;
    dp[w.front().first] = 1;
    dp[w.front().second] = 1;
    for (int i = 1; i < w.size(); i++) {
        dp = (dp << w[i].first) | (dp << w[i].second);
    }

    int ret = n * n;
    for (int i = 1; i <= n; i++) {
        if (!dp[i]) continue;
        int tmp = i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2;
        ret = std::min(ret, tmp);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 5120
a, b, m = input().split(" ")
rei_list = []
den_list = []
war_list = []
rei_list = list(map(int,input().split(" ")))
den_list = list(map(int,input().split(" ")))

for i in range(int(m)):
    kar = list(map(int,input().split(" ")))
    war_list.append(kar)

ned_list=[]
ned_list.append(min(rei_list)+min(den_list))

for i in range(int(m)):
    x = war_list[i][0]
    y = war_list[i][1]
    z = war_list[i][2]
    ned_list.append(rei_list[x-1] + den_list[y-1] - z)
    
print(min(ned_list))

Measured memory_bytes: 42528
using System;

public class Program{
    public static void Main(){
        string input1=Console.ReadLine();
        int N=int.Parse(input1);
        int[] NumArr=new int[N];
        for(int i=0;i<N;i++) {
            string input2=Console.ReadLine();
            NumArr[i]=int.Parse(input2);
        }
        
        int[] num=new int[110];
        for(int i=0;i<N;i++) {
            num[NumArr[i]]++;
        }
        
        int count=0;
        for(int i=1;i<=100;i++) {
            if(num[i]>0) {
                count++;
            }
        }
        Console.WriteLine(count);
    }
    
}


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

using int64 = long long;

int BitCnt(int b) {
  int n = 0;
  for (; b; b &= b - 1)
    ++n;
  return n;
}

int main() {
  int n;
  cin >> n;
  vector<int> fs(n);
  for (int i = 0; i < n; ++i) {
    int f = 0;
    for (int j = 0; j < 10; ++j) {
      f <<= 1;
      char c;
      cin >> c;
      f += c - '0';
    }
    fs[i] = f;
  }

  vector<vector<int>> ps(n, vector<int>(11, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> ps[i][j];
    }
  }

  int64 max_profit = -10000000000;
  for (int t = 1; t < (1 << 10); ++t) {
    int64 profit = 0;
    for (int i = 0; i < n; ++i) {
      int b = BitCnt(t & fs[i]);
      profit += ps[i][b];
    }
    max_profit = max(max_profit, profit);
  }
  cout << max_profit << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll A, B, C;
  cin>>A>>B>>C;
  ll K;
  cin>>K;
  ll Cou=0;
  while(A>=B){
    Cou++;
    B*=2;
  }
  while(B>=C){
    Cou++;
    C*=2;
  }
  Yes(Cou<=K);
  return 0;
} 

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

#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define INF 1e9 + 7

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	unsigned long long arr[3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr+3);
	if (arr[2]%2==0) {
		cout << 0 << endl;
	}
	else {
		cout << arr[0] * arr[1] << endl;
	}
	return 0;
}

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

graph = [[False] * N for _ in range(N)]
for a, b in edges:
    graph[a - 1][b - 1] = True
    graph[b - 1][a - 1] = True

def dfs(v):
    visited[v] = True
    for v2 in range(N):
        if not graph[v][v2]:
            continue
        if visited[v2]:
            continue
        dfs(v2)
    
ans = 0
for a, b in edges:
    graph[a - 1][b - 1] = False
    graph[b - 1][a - 1] = False
    visited = [False] * N
    
    dfs(0)
    # print(visited)
    
    bridge = False
    for i in range(N):
        if visited[i] == False:
            bridge = True
    if bridge:
        ans += 1
        
    graph[a - 1][b - 1] = True
    graph[b - 1][a - 1] = True
    
print(ans) 

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
main(){
  string ans[]={"Audrey wins.","Fabre wins."};
  int te;
  cin>>te;
  string line;
  getline(cin,line);
  while(te--){
  getline(cin,line);
  bool cnt = 0;
  int t=1;
  int length = line.size();
  for(int i=0;i<line.size();i++)line[i]-='0';
  while(length >1){
    if ( cnt == 0)cnt=1;
    else cnt = 0;
    int a =line[length-1],b=line[length-2];
    if (a+b <10){
      line[length-2]=a+b;
      length--;
    }
    else {
      line[length-1]=(a+b)%10;
      line[length-2]=1;
    }

    if ( length==1)break;


  }

  cout << ans[cnt] << endl;
}
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

N = int(input())
W = list(map(int, input().split()))

s = sum(W)
tmp = 0
diff = s
for x in W:
    tmp += x
    if diff > abs(tmp - (s-tmp)): diff = abs(tmp - (s-tmp))
    if tmp > s/2: break

print(diff)

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

int main() {
  
  int N, K;
  int length = 0;

  cin >> N >> K;
  
  vector<int> l(N);

  for (int i = 0; i < N; i++) cin >> l.at(i);  
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  for (int i = 0; i < K; i++) length += l.at(i);

  cout << length << endl;
  
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const c = input[2]

    for(let i = 1; i <= a * b; i++){
        if(a * i % b === c){
            console.log('YES')
            return
        }
    }
    console.log('NO')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	if(a == 0){
		cout << 0 << endl;
	}else if(b == 0){
		cout << n << endl;
	}else{
		ll cnt = (ll)n /(a + b);
		ll ans = cnt * a + min((n % (a + b)), a);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int l=0,r=s.length()-1;
    int len=s.length();
    int ans=0;
    while(l<r){
        if(s[l]==s[r]){
            l++;
            r--;
        }
        else if(s[l]=='x'&&s[r]!='x'){
            ans++;
            l++;
        }
        else if(s[l]!='x'&&s[r]=='x'){
            ans++;
            r--;
        }
        else {
            cout<<-1<<endl;
            return;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
from math import sqrt
n = int(input())
start = int(sqrt(n) // 1)
low_share = 0

for i in range(start,0,-1):
    if n % i == 0:
        low_share = i
        break

high_share = int(n/low_share)
ans = len(str(high_share))
print(ans)

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

using namespace std;

int main () {
	int n, e;
	cin >> n;
	vector<pair<int, int>> x(n);
	for (int i = 0; i < n; i++) {
		cin >> e;
		x[i] = make_pair(e, i);
	}
	sort(x.begin(), x.end(), [](const pair<int, int> &p1, const pair<int, int> &p2) {
		return (p1.first < p2.first);
	});
	int nb2 = n / 2;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		if (i < nb2)
			b[x[i].second] = x[nb2].first;
		else
			b[x[i].second] = x[nb2 - 1].first;
	}
	for (int i = 0; i < n; i++) {
		cout << b[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		//入力された値がdoubleのとき
		//入力された値を半径とした円の面積と円周を出力する
		if(sc.hasNextDouble()){
			double r = sc.nextDouble();
			double menseki = Math.PI * r * r;
			double ensyuu = Math.PI * r * 2;
			
			System.out.printf("%.6f %.6f\n", menseki, ensyuu);
		}
	}
}



Measured memory_bytes: 28280
n, k = map(int, input().split())
A = list(map(int, input().split()))

B = []
for i in range(n):
    B.append(A[i])
    s = A[i]
    for j in range(i+1, n):
        s += A[j]
        B.append(s)
        
res = 0
for i in range(42):
    p = res + 2**(41-i)
    cnt = 0
    for b in B:
        if p == p&b:
            cnt += 1
    if cnt >= k:
        res = p
print(res)

Measured memory_bytes: 28796
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define ft first
#define sd second
#define pb push_back
#define mp(x,y) make_pair(x,y)
//#define int LL
using namespace std;
//const int N   = ;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,n) for (int i=1;i<=n;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,x,t;
char s[200000+2];
signed main()
{
	scanf("%s",s+1);
	int sum=0,n=strlen(s+1);
	rep(i,n)
	sum+=s[i]-'0';
	printf("%s",sum%9==0?"Yes":"No");
	return 0;
}



Measured memory_bytes: 3896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

  int N; cin >> N;
  set<int>s;
  vector<int> v(N); rep(i, 0, N){ cin >> v[i];s.insert(v[i]); }
  cout<<s.size()<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys 
sys.setrecursionlimit(2147483647)

INF = float("inf")

memo = [float("inf")]*100005

def rec(n):
    if n==0:
        return 0
    if memo[n]!=float("inf"):
        return memo[n]
    res = float("inf")
    val = 1
    while val<=n:
        res = min(res,rec(n-val)+1)
        val*=6
    
    val = 1
    while val<=n:
        res = min(res,rec(n-val)+1)
        val*=9
    memo[n]=res
    return memo[n]

dp = [INF]*100005

def morau_dp():
    #min(dp[n-x]+1....)
    N = int(input())
    dp[0]=0
    for i in range(1,N+1):
        val = 1
        while val<=N:
            dp[i]=min(dp[i],dp[i-val]+1)
            val*=6
        
        val = 1
        while val<=N:
            dp[i] = min(dp[i],dp[i-val]+1)
            val*=9

    print(dp[N])


def kubaru_dp():
    #dp[i]+1, dp[i]+6, dp[i]+9....
    N = int(input())
    dp[0]=0
    for i in range(0,N):#配るDPの場合，ループは初期値０から直前N-1まで（貰うDPと1スライドする）
        val = 1
        while (i+val)<=N:
            dp[i+val] = min(dp[i+val],dp[i]+1)
            val*=6

        val = 1
        while (i+val)<=N:
            dp[i+val] = min(dp[i+val],dp[i]+1)
            val*=9
    print(dp[N])


if __name__ == "__main__":
    # N = int(input())
    # print(rec(N))
    # morau_dp()
    kubaru_dp()

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

void swap(char &a,char &b){
	char temp=a;
	a=b;
	b=temp;
}

int main(){
	string s;
	getline(cin,s);
	unsigned int len=s.length();
	for(unsigned int i=0;i<len/2;i++)
		swap(s[i],s[len-i-1]);
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
vector<ll> a(1001,1);

void soinsu(ll n){
  for(ll i=2;i*i<=n;i++){
    if(n%i)continue;
    while(n%i==0){
      n/=i;
      a[i]++;
    }
  }
  if(n!=1)a[n]++;
}

int main(){
  int n; cin>>n;
  ll ans=1;
  // rep(i,n){
  //   soinsu(i+1);
  // }
  for(int i=1;i<n;i++)
  soinsu(i+1);
  // cout<<a[i]<<endl;

  rep(i,a.size()){
    ans*=a[i];
    ans%=mod;
    // if(i<=30)
    // cout<<i<<" "<<a[i]<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, s int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
		s += as[i]
	}

	var sum int
	ans := math.MaxInt32
	for _, a := range as {
		sum += a
		ans = min(ans, abs(sum-(s-sum)))
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 6496
#include <iostream>
using namespace std;
#define is_uruu main

int is_uruu() {
	int n,maxv=-1000000000;
	cin >> n;
	int R[n];
	for(int i=0;i<n;i++)cin >> R[i];
	
	int minv=R[0];
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}
	
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3916
// بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيم
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define el cout << '\n';
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const int mx= 1e5+5 ;

int a[mx][4] ,dp[mx][4] , n; 

int solve(int k,int activities)
{
    if(k==n )return 0 ;

    if(dp[k][activities] != -1)return dp[k][activities] ;
    
    int res = 0 ;

    for (int i =1; i <=3 ; i++)
    {
        if(i!=activities)

        res = max(res , a[k][i] + solve(k+1 , i)) ;
    }
    return dp[k][activities]=res ;
}

int main()
{
    IOS

    cin >> n;
    
    memset(dp , -1 , sizeof dp) ;

    for (size_t i = 0; i < n; i++)

    cin >> a[i][1] >> a[i][2] >> a[i][3];

    cout << solve(0,0) ; 

    el
}

Measured memory_bytes: 14504
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int a, b, c; std::cin >> a >> b >> c;
  int v = std::min(a + b, a + c);
  std::cout <<  std::min(v, b + c) << std::endl;
}


Measured memory_bytes: 256
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n;
	cin >> n;
	cout << 8 - ((n - 400) / 200);
}


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

int main() {
    /* Input */
    int N, M;
    cin >> N >> M;
    vector<long int> H(N);
    rep(i, N) cin >> H.at(i);

    vector<long int> max_hights(N);
    rep(i, N) max_hights.at(i) = 0;

    vector<int> A(M); 
    vector<int> B(M);
    rep(i, M) cin >> A.at(i) >> B.at(i);

    /* Main Logic */
    int nice = 0;
    long int max_height = 0;
    rep(i, M) {
        max_hights.at(A.at(i) - 1) = max(max_hights.at(A.at(i) - 1), H.at(B.at(i) - 1));
        max_hights.at(B.at(i) - 1) = max(max_hights.at(B.at(i) - 1), H.at(A.at(i) - 1));
    }

    rep(i, N) if (max_hights.at(i) < H.at(i)) nice++;

    /* Output */
    cout << nice << endl;

    return 0;
}

Measured memory_bytes: 5592
h, w = gets.split(' ').map(&:to_i)

a = ''
1.upto(h) do |l|
  i = gets.split(' ').index('snuke')
  unless i.nil?
    c = ('a'[0].ord + i).chr.upcase
    a = "#{c}#{l}"
  end
end
puts a


Measured memory_bytes: 1788
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

def gcd(A,B):
    if B>A:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

N = int(input())
A = list(map(int, input().split()))

L = A[:]
for i in range(1,N):
    L[i] = gcd(L[i],L[i-1])

R = A[:]
for i in range(N-2,-1,-1):
    R[i] = gcd(R[i],R[i+1])

ans = max(L[N-2],R[1])
for i in range(1,N-1):
    ans = max(ans, gcd(L[i-1],R[i+1]))

print(ans)

Measured memory_bytes: 23132