akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm> 
#include <vector>

using namespace std;

int main () {
    int N;
    cin >> N;
    vector <int>a(N);
    vector <int>b(N);
    vector <int>c(N);
    for (int i = 0; i < N ; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector <vector <int> >dp(N + 1, vector<int>(3, 0));
    for (int i = 0 ; i < N ; i++)
    {
        for (int i = 0 ; i < 3 ; i++) {
        
        }
        dp[i + 1][0] = a[i] + max(dp[i][1], dp[i][2]);
        dp[i + 1][1] = b[i] + max(dp[i][0], dp[i][2]);
        dp[i + 1][2] = c[i] + max(dp[i][0], dp[i][1]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    
}


Measured memory_bytes: 6912
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::vector<int> graph[100000];
std::vector<int> block[100000];
int block_num[100000];
int friendsnum[100000];
std::vector<int> paths[100000];
bool used[100000];
bool used_now[100000];
int dfs(int v, int root)
{
    if (used[v]) { return 0; }
    used[v] = true;
    paths[root].push_back(v);
    int num = 1;
    for (auto& n : graph[v])
    {
        if (!used[n]) {
            num += dfs(n, root);
        }
    }
    return num;
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int m, k;
    in >> N >> m>>k;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        in >> a >> b; --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for (int i = 0; i < k; i++)
    {
        int a, b;
        in >> a >> b; --a; --b;
        block[a].push_back(b);
        block[b].push_back(a);
    }
    for (int i = 0; i < N; i++)
    {
        if (!used[i]) {
            friendsnum[i] = dfs(i, i);
            assert(friendsnum[i] == (int)paths[i].size());
            for (auto& v : paths[i])
            {
                friendsnum[v] = friendsnum[i];
                used_now[v] = true;
            }
            for (auto& v : paths[i])
            {
                for (auto& n : block[v])
                {
                    if (used_now[n]) {
                        ++block_num[n];
                    }
                }
            }
            for (auto& v : paths[i])
            {
                used_now[v] = false;
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        out << (friendsnum[i] - block_num[i] - (int)graph[i].size() - 1) << ' ';
    }
    out << endl;


    return 0;
}
#endif


Measured memory_bytes: 16380
n = int(input())
s = input()
R = [0 for i in range(n+1)]
G = [0 for i in range(n+1)]
B = [0 for i in range(n+1)]
R[n] = 0
G[n] = 0
B[n] = 0

for i in range(n-1, -1, -1):
    R[i] = R[i+1] + (s[i] == 'R')
    G[i] = G[i+1] + (s[i] == 'G')
    B[i] = B[i+1] + (s[i] == 'B')

sm = 0
for i in range(n):
    for j in range(i+1,n):
        nxt = j-i + j
        f = True
        if nxt >= n:
            f = False
        if s[i] == s[j]:
            continue
        if s[i] != 'R' and s[j] != 'R':
            sm += R[j+1]
            if f:
                sm -= (s[nxt] == 'R')
        if s[i] != 'G' and s[j] != 'G':
            sm += G[j + 1]
            if f:
                sm -= (s[nxt] == 'G')
        if s[i] != 'B' and s[j] != 'B':
            sm += B[j + 1]
            if f:
                sm -= (s[nxt] == 'B')
print(sm)

Measured memory_bytes: 74864
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp,ll M);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);

void solve(){
    ll n;
    cin  >> n;
    ll a[n];
    loop(i,0,n) cin >> a[i];
    ll ans=1000,st=0;
    ll cur=1000;
    bool f=0;
    loop(i,0,n){
        ll j=i;
        while(j<n && a[j]==a[i]) j++;
        j--;
        i=j;
        if(f==0){
            if(j==n-1){
                continue;
            }
            else{
                if(a[j+1]>a[j]){
                    st=cur/a[j];
                    //ans+=(cur-a[j]*st);
                    cur=cur-a[j]*st;
                    f=1;
                }
                else continue;
            }
        }
        else{
            if(j==n-1){
                cur+=st*a[j];
            }
            else{
                if(a[j]<a[j+1]){
                    continue;
                }
                else{
                    cur+=st*a[j];
                    st=0;
                    f=0;
                }
            }
        }

        
        //cout << cur << endl;
    }

    cout << cur << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    //ll cnt=1;
    while (t--){
        //cout << "Case #" << cnt << ": ";
        //cout << fixed << setprecision(10);
        solve();
        //cout << endl;
        //cnt++;
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp,ll M){
    base %= M;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % M;
        base = ((ll)base * base) % M;
        exp >>= 1;
    }
    return result%M;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

ll modInverse(ll n) { 
    return mpow(n, mod-2,mod); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

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

// dp[i][bit xor p[i]] = max(dp[i][bit xor p[i]], dp[i-1][bit] + 1)
/*
void bitDP(int n, int m, vector<int> &p) {
    vector<vector<int>> dp(n, vector<int>(1<<m, 0));
    dp[0][p[0]] = 1;
    for(int i = 1; i < n; ++i) {
        for(int bit = 0; bit < (1<<m); ++bit) {
            dp[i][bit ^ p[i]] = max(dp[i][bit ^ p[i]], dp[i-1][bit] + 1);
        }
    }
    cout << dp[n-1][0] << endl;
}
*/

int A[(1<<23)];
int B[(1<<23)];
void bitDP(int n, int m, vector<int> &p) {
    memset(A, -1, (1<<m)*sizeof(int));
    memset(B, -1, (1<<m)*sizeof(int));
    //for(int i = 0; i < (1<<m); ++i) A[i] = -1, B[i] = -1;
    int *_past = A;
    int *_current = B;
    _past[0] = 0;
    _past[p[0]] = 1;
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < (1<<m); ++j) _current[j] = _past[j];
        for(int bit = 0; bit < (1<<m); ++bit) {
            if(_past[bit] == -1) continue;
            _current[bit ^ p[i]] = max(_current[bit ^ p[i]], _past[bit] + 1);
        }
        
        swap(_past, _current);
    }
    cout << ( (_past[0] == -1) ? 0 : _past[0] ) << endl;
}

void zentansaku(int n, int m, vector<vector<int>> &b){
    int state[m];   // state[i] := i種類の材料を使った回数
    int res = 0;
    for(int bits = 0; bits < (1<<n); ++bits) {  // bit全探索
        memset(state, 0, sizeof(state));
        int tmp = 0;    // 選んだ料理レシピの数
        for(int i = 0; i < n; ++i) {
            if(1 & (bits>>i)) {
                ++tmp;
                for(int j = 0; j < m; ++j) state[j] += b[i][j];
            }
        }
        // 偶奇チェック
        bool flg = true;
        for(int i = 0; i < m; ++i) {
            if((state[i] & 1) ^ 0) { flg = false; break; }
        }
        if(flg) res = max(res, tmp);
    }
    cout << res << endl;
}

bool solve()
{
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0) return false;
    if(m < 23) 
    {   // bitDP
        vector<int> p(n, 0);
        for(int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            for(int j = 0; j < m; ++j) {
                p[i] |= (s[j] - '0') << j;
            }
            
        }
        //for(auto &x : p) cout << x << endl;
        bitDP(n, m, p);
    }
    else 
    {   // 全探索
        vector<vector<int>> b(n, vector<int>(m,0));
        for(int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            for(int j = 0; j < m; ++j) {
                b[i][j] = (s[j] - '0');
            }
        }
        zentansaku(n, m, b);
    }

    return true;
}

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


Measured memory_bytes: 35924
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] || a[i] == c[i]) {
            if (b[i] != c[i]) {
                cnt++;
            }
        } else if (b[i] == c[i]) {
            if (a[i] != b[i]) {
                cnt++;
            }
        } else {
            cnt += 2;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{

    int n;
    int a, b, c;
    
    scanf("%d", &n);
    
    while (n > 0) {
        scanf("%d %d %d", &a, &b, &c);
        
        if ((a == sqrt(b * b + c * c)) || (b == sqrt(c * c + a * a)) || (c == sqrt(a * a + b * b))) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
        n--;
    }
    
    return 0;
}

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

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i=0; i<N; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    int counter = 0;
    for (int i=0; i<N; i++) {
        x -= a.at(i);
        if (x >= 0) counter++;
        else break;
    }
    if (x > 0) counter--;
    cout << counter << endl;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,k;
    cin>>n>>k;
    vi h(n);
    forn(i,n)   cin>>h[i];
    sort(all(h));
    int mini = INT_MAX;
    forn(i,n-k+1){
        mini = min(mini,h[i+k-1]-h[i]);
    }
    cout<<mini<<endl;
    return 0;
}



Measured memory_bytes: 3624
a,b = gets.split(" ")
#上から３桁の数字を取得する
#下二桁のと比較をする

a_a = a.split("")
b_a = b.split("")

a123_s = a_a[0] + a_a[1] + a_a[2]
b123_s = b_a[0] + b_a[1] + b_a[2]

a45_s = a_a[3] + a_a[4]
a21_s = a_a[1] + a_a[0]

b45_s = b_a[3] + b_a[4]
b21_s = b_a[1] + b_a[0]

#文字列を整数へ
a123_i = a123_s.to_i
b123_i = b123_s.to_i

a45_i = a45_s.to_i
a21_i = a21_s.to_i

b45_i = b45_s.to_i
b21_i = b21_s.to_i
 
ans = 0

if  a45_i <= a21_i
    ans = ans + 1
end

if  b45_i >= b21_i
    ans = ans + 1
end

ans = ans + b123_i - a123_i - 1

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-7;
const double INF = 1e12;
struct Vec {
    double x,y;
    Vec() {}
    Vec(double x, double y) { 
        this->x = x, this->y = y; 
    }
    void read() { 
        scanf("%lf %lf", &x, &y); 
    }
    void prt() {
        printf("%.9f %.9f\n", x, y); 
    }
    double len() { 
        return sqrt(x * x + y * y); 
    }
    double len2() { 
        return x * x + y * y; 
    }
    
    Vec operator +(const Vec& o)const { 
        return Vec(x + o.x, y + o.y); 
    }
    Vec operator -(const Vec& o)const { 
        return Vec(x - o.x, y - o.y); 
    }
    Vec operator *(const double& k)const { 
        return Vec(k * x, k * y); 
    }
    double operator *(const Vec& o)const {
        return x * o.x + y * o.y; 
    }
    double operator ^(const Vec& o)const {
        return x * o.y - y * o.x; 
    }
    Vec rotate(double ang){ 
        return Vec(x * cos(ang) - y * sin(ang), x * sin(ang) + y * cos(ang)); 
    }
    Vec change(double l) { 
        if(len() < EPS) return *this; 
        return (*this) * (l/len()); 
    }
};


struct Line {
    Vec A1, A2;
    Line() {}
    Line(Vec A1, Vec A2) {
        this->A1 = A1, this->A2 = A2;
    }
    double len() {
        return (A2-A1).len();
    }
    double Len2() {
        return (A2-A1).len2();
    }
};


double disToLine(Vec P, Line L) {
    return abs((P-L.A1)^(L.A2-L.A1)) / L.len();
}
Vec projection(Vec P, Line L) {
    double shadowLen = (P - L.A1) * (L.A2 - L.A1);
    return L.A1 + (L.A2-L.A1).change(shadowLen);
}

bool onseg(Vec P, Line L) {
    if(disToLine(P, L) > EPS) return 0;
    return (P-L.A1) * (P-L.A2) <= 0;
}

Vec Lineintersect(Line L1, Line L2) {
    // 0 ~ (L2.A1 - L1.A1) ^ (L2.A2 - L1.A1);
    // 1 ~ (L2.A1 - L1.A2) ^ (L2.A2 - L1.A2);
    double F0 = (L2.A1 - L1.A1) ^ (L2.A2 - L1.A1);
    double F1 = (L2.A1 - L1.A2) ^ (L2.A2 - L1.A2);
    if (abs(F1 - F0) < EPS) return Vec(INF, INF);
    return L1.A1 + (L1.A2 - L1.A1) * (- F0 / (F1 - F0));
}

Vec Segintersect(Line L1, Line L2) {
    Vec P = Lineintersect(L1, L2);
    if (P.x == INF) return P;
    if (onseg(P, L1) && onseg(P, L2)) return P;
    return Vec(INF, INF);
}

bool disToSeg(Vec P, Line L) {
    double ans = min((P-L.A1).len(), (P-L.A2).len());
    ans = min(ans, (P - projection(P,L)).len());
    return ans;
}

struct Polygon {
    int n; 
    vector<Vec> v;
    void read() {
        scanf("%d", &n);
        for(int i=0;i<n;i++){
            Vec tmp; tmp.read();
            v.push_back(tmp);
        }
    }
    double getArea() {
        double ans=0;
        for(int i=0;i<n;i++){
            ans=ans+(v[i]^v[(i+1)%n]);
        }
        return abs(ans/2);
    }
} poly;

int main(){
    poly.read();
    printf("%.1f\n", poly.getArea());
}



Measured memory_bytes: 3248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       String S = sc.next();
       String T = sc.next();
       if(T.equals(S)){
               System.out.println("Yes");
               return;
           }
       for(int i=0;i<S.length();i++){
           String U = S.substring(i,S.length())+S.substring(0,i);
           //System.out.println(U);
           if(T.equals(U)){
               System.out.println("Yes");
               return;
           }
       }
       System.out.println("No");
    }
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

vector<ll> frequencies(const string &s) {
    vector<ll> frequencies(26, 0);
    for (char c: s) {
        ++frequencies[c - 'a'];
    }
    return frequencies;
}

ll solve(const string &s, const string &t) {
    int N = s.size();
    auto s_freq = frequencies(s);
    auto t_freq = frequencies(t);

    vector<vector<int>> next(26, vector<int>(N, -1));
    ll k = 0;
    REP(i, 26) {
        if (t_freq[i] > 0) {
            if (s_freq[i] > 0) {
                char c = 'a' + i;
                int j = find(all(s), c) - s.begin();
                REP(_, N) {
                    if (s[j] == c) {
                        next[i][j] = 0;
                    } else {
                        next[i][j] = next[i][(j + 1) % N] + 1;
                    }
                    j = (j + N - 1) % N;
                }
            } else {
                return -1;
            }
        }
    }

    ll result = 0;
    int p = N - 1;
    for (char c: t) {
        int i = c - 'a';
        ++result;
        p = (p + 1) % N;
        result += next[i][p];
        p = (p + next[i][p]) % N;
    }
    return result;
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << solve(s, t) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X;
    cin >> X;
    if (X < 500)
    {
        cout << (X / 5) * 5 << endl;
    }
    else
    {
        ll c = X % 500;
        cout << (X / 500) * 1000 + (c / 5) * 5 << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  vector<int> abc(3); REP(i, 3) cin >> abc[i];
  sort(ALL(abc));
  cout << (abc[0] + abc[1] == abc[2] ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       string s;
       cin>>s;
       ll i,a=0,b=0;
       for(i=0;i<s.length();i++)
       {
           if(s[i]=='A')
            a++;
           else
            b++; 
       }      
       if(a&&b)
        cout<<"Yes\n";
       else
        cout<<"No\n"; 
   }
}

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

using namespace std;

int main(){

  long long int n;
  cin >>n;

  vector<int> f;

  long long int m;
  m=n;
  for(int i=2;i*i<n;i++){
    if(m%i==0){
      f.push_back(i);
      m=m/i;
      i--;
    }
    if(m==1)break;
  }

  if(m!=1)f.push_back(m);

  cout << n << ":";
  for(int i=0;i<f.size();i++){
    cout << " " << f[i];
  }
  cout << endl;

}


Measured memory_bytes: 3160
get_string(String) :-
  current_input(Input),
  read_string(Input, '\n', '', _, String).

get_number(Number) :-
  get_string(String),
  number_string(Number, String).

dp([], -1000000000000, -1000000000000, -1000000000000, 0, -1000000000000, -1000000000000).
dp([XS|TL], A, B, C, D, E, F) :-
  number_string(X, XS),
  dp(TL, A1, B1, C1, D1, E1, F1),
  A is D1 + X,
  B is E1 + X,
  C is F1 + X,
  D is A1,
  E is max(B1, D1),
  F is max(C1, E1).

main :-
  get_number(N),
  get_string(S),
  split_string(S, ' ', '', L),
  dp(L, A, B, C, D, E, F),
  (N mod 2 =:= 0 ->
    X is max(B, D);
    X is max(C, E)),
  write(X).

Measured memory_bytes: 74160
N = gets.to_i

def head(n)  # 最高位の数を求める
  return n.to_s[0].to_i
end

def size(n)  # 桁数を求める
  return n.to_s.length
end

def sum(n)  # 各桁の数の総和を求める
  return n.to_s.split("").inject(0){ |acc, item| acc + item.to_i }
end

# 最高位の数を 1 減らし、下位の数をすべて 9 にした数
d = ((head(N) - 1).to_s + "9" * (size(N) - 1)).to_i

# 大きい方が答え
puts [sum(N), sum(d)].max

Measured memory_bytes: 1788
//#define DEBUG
#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 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))

#define fi first
#define sc second 
#define pb push_back


#ifdef DEBUG
    #define dbg(s) {s;}
    #define PRELUDE
#endif

#ifndef DEBUG 
    #define PRELUDE { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define dbg(s)
    #define endl "\n"
#endif

#define int ll
#define i32 int32_t

#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).

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

// To remove randomization use 0 below:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

inline ld rf() { // from [0, 1]
    return uniform_real_distribution<ld>(0, 1)(rng);
}

ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

void solve()
{
    string s;
    cin>>s;

    int n = s.length();
    if(n%2==1)
    {
        cout<<"No"<<endl;
        return;
    }
    for(int i=0;i<n;i++)
    {
        if(i%2==0 && s[i]!='h')
        {
            cout<<"No"<<endl;
            return;
        }
        if(i%2==1 && s[i]!='i')
        {
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);
    
    PRELUDE;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int N = Integer.parseInt(lines[0]);
		int D = Integer.parseInt(lines[1]);

		int num = 2*D + 1;
		int ans = N / num;
		if(N % num == 0) {
			System.out.println(ans);
		}else {
			System.out.println(ans + 1);
		}
	}

}


Measured memory_bytes: 35712
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	X, Y, A, B, C := getInt(), getInt(), getInt(), getInt(), getInt()
	p := make([]int, A)
	q := make([]int, B)
	r := make([]int, C)

	for i := 0; i < A; i++ {
		p[i] = getInt()
	}
	for i := 0; i < B; i++ {
		q[i] = getInt()
	}
	for i := 0; i < C; i++ {
		r[i] = getInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	sumP := 0
	for i := 0; i < X; i++ {
		sumP += p[i]
	}
	sumQ := 0
	for i := 0; i < Y; i++ {
		sumQ += q[i]
	}

	ans := sumQ + sumP
	for i := 0; i < C; i++ {
		ans0 := ans
		if X != 0 {
			ans0 = ans - p[X-1] + r[i]
		}
		ans1 := ans
		if Y != 0 {
			ans1 = ans - q[Y-1] + r[i]
		}
		if ans0 > ans1 {
			if ans0 > ans {
				X--
				ans = ans0
			}
		} else {
			if ans1 > ans {
				Y--
				ans = ans1
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 6016
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    s=input()
    t=input()
    if s==t[::-1]:print("YES")
    else:print("NO")

main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n,W;
    cin >> n >> W;
    vector<int> w(n);
    vector<ll> v(n);
    rep(i,n) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(n,vector<ll>(W*2+1,0LL));
    rep(i,W){
        dp[0][w[0]+i] = v[0];
    }
    rep(i,n-1){
        rep(oldW,W+1){
            dp[i+1][oldW] = max(dp[i+1][oldW],dp[i][oldW]);
            int newW = oldW + w[i+1];
            dp[i+1][newW] = max(dp[i+1][newW],dp[i][oldW] + v[i+1]);
        }
    }
    cout << dp[n-1][W];
    
}


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

char grid[60][60];
int H, W;
bool flag;

int main(){
  cin >> H >> W;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++) {
      cin >> grid[i][j];
    }
  }


  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++) {
      if(grid[i][j] == '#' && grid[i-1][j] != '#' && grid[i+1][j] != '#' && grid[i][j-1] != '#' && grid[i][j+1] != '#' ) flag = true;
    }
  }
  if(!flag){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,a,b,c,d[205][205]={},ans=INF,r,R[10]={},cnt;
  cin >> n >> m >> r;
  for(int i=0; i<r; i++) {
    cin >> R[i];
    R[i]--;
  }
  sort(R,R+r);
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(i!=j) {
        d[i][j]=INF;
      }
    }
  }
  for(int i=0; i<m; i++) {
    cin >> a >> b >> c;
    a--,b--;
    d[a][b]=d[b][a]=c;
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
        if(i!=j&&i!=k&&j!=k) {
          d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
        }
      }
    }
  }
  do{
    cnt=0;
    for(int i=0; i<r-1; i++) {
      cnt+=d[R[i]][R[i+1]];
    }
    ans=min(ans,cnt);
  }while(next_permutation(R,R+r));
  cout << ans << endl;
}



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

typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (int i = 1; i <= n; i++)
        a[i - 1] = (ll) i;
    transform(a, a+n, a, [k, n](ll x) {
            ll rem_a = x % k, rem_b = (k + (k - x) % k) % k;
            if (rem_a == rem_b) {
                ll t = (n + rem_a) / k;
                return t * t;
            }
            return 0LL;
            });
    cout << accumulate(a, a+n, 0LL) << endl;
	return 0;
}


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

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

const int MOD = 1000000007;
const int MAX = 200000;

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

Measured memory_bytes: 3632
a = input()
b = input()
c = input()
ac = 0
bc = 0
cc = 0
curr = 'a'
while ac <= len(a) and bc <= len(b) and cc <= len(c):
    if curr == 'a':
        if ac == len(a):
            print("A")
            break
        curr = a[ac]
        ac += 1
    elif curr == 'b':
        if bc == len(b):
            print("B")
            break
        curr = b[bc]
        bc += 1
    elif curr == 'c':
        if cc == len(c):
            print("C")
            break
        curr = c[cc]
        cc += 1


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
ans = 1
max = 10 ** 18
if a.count(0):
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > max:
            print(-1)
            exit()
    else:
        print(ans)


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

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

bool check(int x, int y){
	return x >= 0 && x < 12 && y >= 0 && y < 12 && maze[x][y] == 1;
}
void dfs(int x, int y){
	
	maze[x][y] = 0;
	for(int i = 0; i < 4; ++i){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(check(nx, ny))
			dfs(nx, ny);
	}
}


int main() {
	while(1){
		string s;
		for(int i = 0; i < 12; ++i){
			cin >> s;
			for(int j = 0; j < 12; ++j)
				maze[i][j] = s[j] - '0';
		}
		if(cin.eof())
			break;
			
		int ans = 0;
		for(int i = 0; i < 12; ++i){
			for(int j = 0; j < 12; ++j){
				if(maze[j][i] == 1){
					dfs(j, i);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <map>
#include <cstring>
using namespace std;

int main()
{
    map<char, map<char, string> > data;
    data['1']['T'] = "a"; data['1']['L'] = "i"; data['1']['U'] = "u"; data['1']['R'] = "e"; data['1']['D'] = "o";
    data['2']['T'] = "ka"; data['2']['L'] = "ki"; data['2']['U'] = "ku"; data['2']['R'] = "ke"; data['2']['D'] = "ko";
    data['3']['T'] = "sa"; data['3']['L'] = "si"; data['3']['U'] = "su"; data['3']['R'] = "se"; data['3']['D'] = "so";
    data['4']['T'] = "ta"; data['4']['L'] = "ti"; data['4']['U'] = "tu"; data['4']['R'] = "te"; data['4']['D'] = "to";
    data['5']['T'] = "na"; data['5']['L'] = "ni"; data['5']['U'] = "nu"; data['5']['R'] = "ne"; data['5']['D'] = "no";
    data['6']['T'] = "ha"; data['6']['L'] = "hi"; data['6']['U'] = "hu"; data['6']['R'] = "he"; data['6']['D'] = "ho";
    data['7']['T'] = "ma"; data['7']['L'] = "mi"; data['7']['U'] = "mu"; data['7']['R'] = "me"; data['7']['D'] = "mo";
    data['8']['T'] = "ya";                        data['8']['U'] = "yu";                        data['8']['D'] = "yo";
    data['9']['T'] = "ra"; data['9']['L'] = "ri"; data['9']['U'] = "ru"; data['9']['R'] = "re"; data['9']['D'] = "ro";
    data['0']['T'] = "wa";                        data['0']['U'] = "nn";                        data['0']['D'] = "wo";
    
    string in;
    cin >> in;
    for (int i = 0; i < in.size() / 2; i++) {
        cout << data[in[i * 2]][in[i * 2 + 1]];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1200
def solve():

    mini = 10**9
    combs = getcombs(n)
    for com in combs:
        skill = [0] * m
        price = 0
        for i in range(n):
            if int(com[i]):
                price += c[i]
                addvec(skill, a[i])
                if min(skill) >= x:
                    mini = min(mini, price)
    if mini!=10**9:
        print(mini)
    else:
        print(-1)
    return


def getcombs(n):
    combs = []
    for i in range(2**n):
        combs.append(format(i, '#0{}b'.format(n+2))[2:])
    return combs






def addvec(a,b):
    for i in range(len(a)):
        a[i] += b[i]


#s= input()
n,m, x = [int(i) for i in input().split(" ")]
c = []
a = []
for _ in range(n):
    read = [int(i) for i in input().split(" ")]
    c.append(read[0])
    a.append(read[1:])
solve()


Measured memory_bytes: 69192
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;

//----***型定義***----
using ll = long long;
using P = pair<ll,ll>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<ll>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期化時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int main(){
  ll N;cin>>N;
  ll c;
  for(ll a=1;a<=3600;a++){
    for(ll b=1;b<=a;b++){
      auto p=4*a*b-N*a-N*b;
      auto q=N*a*b;
      if((p>0)&&(q%p==0)){
        c=q/p;
        print(a,b,c);
        re 0;
      }
    }
  }

}


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

int main()
 {
	//code
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n;
    cin>>n;
    if(n==2){
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
 else   if(n==1){
        cout<<"Hello World"<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
def is_ok(arg):
    global K
    return r[arg] >= K
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N, K = map(int, input().split())
A = [0] * 10**5
for _ in range(N):
    a, b = map(int, input().split())
    A[a-1] += b
r = [A[0]]
for i in range(10**5-1):
    r.append(r[i] + A[i+1])
print(meguru_bisect(-1, 10**5)+1)


Measured memory_bytes: 81644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, p;
    cin >> a >> p;
    cout << (3*a + p) / 2 << endl;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

def createFacArr(n, mod):
    fac = [0] * n
    finv = [0] * n
    inv = [0] * n
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, n):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    return fac, finv, inv

def comb(n ,k, mod, fac, finv, inv):
    '''
    二項係数の計算
    '''
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

def main():
    if (X + Y) % 3 != 0:
        return 0
    # 移動回数を求める
    m = (2 * X - Y) // 3
    n = X - 2 * m
    fac, finv, inv = createFacArr(10**6*2, MOD)
    return comb(m+n, n, MOD, fac, finv, inv)

print(main())


Measured memory_bytes: 85488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M;
int a[55], b[55], c[55], d[55];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) cin >> a[i] >> b[i];
    for(int i = 1; i <= M; i++) cin >> c[i] >> d[i];
    for(int i = 1; i <= N; i++) {
        int ans = 1;
        for(int j = 2; j <= M; j++) {
            if(abs(a[i] - c[ans]) + abs(b[i] - d[ans]) > abs(a[i] - c[j]) + abs(b[i] - d[j])) ans = j;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long answer=n-1;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0&&i+(n/i)-2<answer){
      answer=i+(n/i)-2;
    }
  }
  cout<<answer<<endl;

  
  return 0;
}

Measured memory_bytes: 256
//無心でDPします
#include <iostream>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (i = 0; i < n; i++)
#define repn(i, m, n) for (i = m; i < n; i++)
#define int long long
using namespace std;

int INF = 1e+12;
int n, m;
int a[500];
int ra[501];
double dp[501][501];	//dp[pos][cnt] = max

signed main() {
	int i, j, k;
	
	cin >> n >> m;
	rep(i, n) cin >> a[i];
	rep(i, n) ra[i + 1] = ra[i] + a[i];
	
	rep(i, n + 1) rep(j, m + 1) dp[i][j] = -INF;
	
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, m) {
			repn(k, i + 1, n + 1) {
				double high = (ra[k] - ra[i]) / (double)(k - i);
				dp[k][j + 1] = max(dp[k][j + 1], dp[i][j] + high);
			}
		}
	}
	
	//rep(i, n + 1) { rep(j, m + 1) cout << dp[i][j] << " "; cout << endl; }
	printf("%.14f\n", dp[n][m]);
	return 0;
}


Measured memory_bytes: 5184
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string a, b, c, d;
    cin >> a >> b;
    c = a + b;
    d = c;
    reverse(c.begin(), c.end());
    if (c == d) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

// https://atcoder.jp/contests/abc177/editorial/82

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<long long,long long>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int H,W;cin>>H>>W;
    vvi A(H,vi(W));
    vector<bool> H_ok(H,false),W_ok(W,false);
    for(int h=0;h<H;h++){
        string S;cin>>S;
        for(int w=0;w<W;w++){
            A[h][w]=S[w];
            if(S[w]=='#'){
                H_ok[h]=true;W_ok[w]=true;
            }
        }
    }
    for(int h=0;h<H;h++){
        if(!H_ok[h])continue;
        for(int w=0;w<W;w++){
            if(!W_ok[w])continue;
            cout<<(char)A[h][w];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

bool isPrime(int x) {
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;

	int i = 3;
	while (i <= sqrt(x)) {
		if (x % i == 0)
			return false;
		i += +2;
	}
	return true;
}

int main() {

	int n;
	scanf("%d", &n);
	int x[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]);
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (isPrime(x[i]))
			++cnt;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main()
{
  char ch;
  
  while(1){
    int sum=0;
    while(1){
      scanf("%c",&ch);
      if(ch=='\n') break;
      else sum +=(int)ch-'0';
    }
    if(sum==0) break;
    else printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<lli, lli> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

lli a[4], ans;
map<pair<ii, lli>, bool> m;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> a[1] >> a[2] >> a[3];
	sort(a + 1, a + 3 + 1);
	while(a[1] % 2 == 0 && a[2] % 2 == 0 && a[3] % 2 == 0) {
		if(m[mp(mp(a[1], a[2]), a[3])] == 1) {
			cout << "-1";
			return 0;
		}
		m[mp(mp(a[1], a[2]), a[3])] = 1;
		ans++;
		lli aa = a[1], bb = a[2], cc = a[3];
		a[1] = bb / 2 + cc / 2;
		a[2] = aa / 2 + cc / 2;
		a[3] = aa / 2 + bb / 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = True
  else:
    print('No')
    exit()

print('Yes')


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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int n, k, ans=1;
	cin>>n>>k;
	while(n--)
		ans = min(2*ans, ans+k);
	cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 100005
using namespace std;
typedef pair<int, int> P;
long long ans;

int h, w, wh[405][405], dx[] = {0,0,-1,1}, dy[] = {1,-1,0,0};
char s[405];

int main(){
  scanf("%d %d\n", &h, &w);
  for(int i = 0; i < h; i++){
    scanf("%s", s);
    for(int j = 0; j < w; j++) wh[i][j] = s[j] == '.';
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(wh[i][j] == 2) continue;
      stack<P> st;
      long long nm[2] = {};
      st.push(P(i, j));
      while(!st.empty()){
        P it = st.top(); st.pop();
        for(int k = 0; k < 4; k++){
          int x = it.first + dx[k], y = it.second + dy[k];
          if(0 <= x && x < h && 0 <= y && y < w && wh[x][y] + wh[it.first][it.second] == 1){
            st.push(P(x,y));
          }
        }
        nm[wh[it.first][it.second]]++;
        wh[it.first][it.second] = 2;
      }
      ans += nm[0]*nm[1];
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 2176
import re

while 1:
    s=raw_input()
    if(s=='.'):
        break
#   s = re.sub('[^][()]', '', s)
    after=''
    needed=['(',')','[',']']
    for c in s:
        if(c in needed):
            after+=c
    s=after
    while (1):
        tmp=s
#       s = re.sub('\[\]', '', s)
#       s = re.sub('\(\)', '', s)
        s=s.replace('[]','')
        s=s.replace('()','')
        if (tmp==s):
            break
    if(not s):
        print 'yes'
    else:
        print 'no'

Measured memory_bytes: 4232