akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;


int main() {



	ll n;
	cin >> n;
	ll maxi = 0;
	for (ll i = 1; i*i <= n; i++)
	{
		if (i*i <= n)
		{
			maxi = i * i;
		}
	}
	cout << maxi << endl;

	return 0;


}





Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

#ifndef __has_include
#define __has_include(x) (false)
#endif

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#endif



using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T, class BinaryOperation>
constexpr T fold(std::initializer_list<T> args, T init, BinaryOperation op)
{
	return std::accumulate(args.begin(), args.end(), init, op);
}

// numeric_low
namespace numeric
{
	template<class T>
	constexpr T gcd(const T x, const T y)
	{
		if (x < 0)return gcd(-x, y);
		if (y < 0)return gcd(x, -y);
		return (!y) ? x : gcd(y, x % y);
	}

	template<class T>
	constexpr T lcm(const T x, const T y)
	{
		if (x < 0)return lcm(-x, y);
		if (y < 0)return lcm(x, -y);
		return x * (y / gcd(x, y));
	}
}

// argsからハッシュ値を作成
template <class... Args>
std::size_t hash(Args... args)
{
	return fold({ static_cast<std::size_t>(args)... }, 0_sz,
		[](std::size_t seed, std::size_t x)
	{
		// uses magic number from boost
		return seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
	});
}

template <class Begin, class End>
void printAll(Begin beginIter, End endIter, std::string delimiter)
{
	for (auto iter{ beginIter }; iter != endIter; ++iter)
	{
		std::cout << *iter;
		if (std::distance(iter, endIter) != 1)
			std::cout << delimiter;
	}
}

template <class Container>
void printAll(const Container& c, std::string delimiter)
{
	printAll(std::cbegin(c), std::cend(c), delimiter);
}

template<class T>
void printAll(const std::initializer_list<T>& ini, std::string delimiter)
{
	printAll(ini.begin(), ini.end(), delimiter);
}

using ld = long double;

template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr ll mod = 1000000007;

int main()
{
    using namespace std;

    string s, t;
    cin >> s >> t;

    map<char, char> m;

    for (int i = 0; i < s.size(); ++i)
    {
        m[s[i]] = t[i];
    }

    string s_{ s };

    for (auto& c : s_)
    {
        c = m[c];
    }

    bool overlap{ false };
    set<char> used;
    set<char> se;
    for (auto c : s)
    {
        if (used.count(c) == 0)
        {
            used.emplace(c);
            
            if (se.count(m[c]) != 0)
                overlap = true;
            else
                se.emplace(m[c]);
        }
    }

    if (s_ == t && !overlap)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}
 

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

int main() {
  int n;
  cin>>n;
  map<int, vector<int>> m;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    m[a].push_back(i);
  }
  set<int> s;
  for (auto e: m) {
    set<int> t;
    for (int idx: e.second) {
      if (s.empty()) {
        t.insert(idx);
        continue;
      }
      auto it = s.upper_bound(idx);
      if (it == s.begin()) {
        t.insert(idx);
      } else {
        --it;
        s.erase(it);
        t.insert(idx);
      }
    }
    for (int i: t) {
      s.insert(i);
    }
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 15616
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto A = RD!ulong;
	auto B = RD!ulong;
	auto C = RD!ulong;
	auto X = RD!ulong;
	auto Y = RD!ulong;
	
	ulong ans;
	auto xy = min(X, Y);
	ans += min(C * xy * 2, (A + B) * xy);

	ulong cost;
	if (X > Y) cost = A;
	else	   cost = B;
	auto q = max(X, Y) - min(X, Y);
	ans += min(C * q * 2, cost * q);

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int A, B, K;//こっちが与えられる方
	int i;//気持ち悪いけどループ用にもう一回宣言
	scanf("%d %d %d", &A, &B, &K);

	if ((B - A + 1) <= 2 * K) {//全部出力しないといけない場合
		for (A; A <= B; A++) {
			printf("%d\n", A);
		}
	}
	else {
		for (i = 1; i <= K; i++) {//Aの方の値をK回出力
			printf("%d\n", A);
			A++;
		}

		B -= K-1;
		for (i = 1; i <= K; i++) {
			printf("%d\n", B);
			B++;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int H, W, h, w; cin >> H >> W >> h >> w;
    H -= h; W -= w;
    cout << H * W << endl;

    return 0;
}


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

int main(){
    int n, l;
    cin >> n >> l;
    int com = n * (n - 1) / 2 + l * n;
    int ans = 0;
    int tmp;
    for (int i = 0; i < n; i++){
        tmp = 0;
        for (int j = 0; j < n; j++){
            if (i != j) tmp += l + j;
        }
        if (abs(com - tmp) < abs(com - ans)) ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// #include<bits/stdc++.h>
#include<vector>
#include<iostream>
using namespace std;
// #pragma GCC optimize("-O3")

#ifndef ConanYu
#define CPPIO
#endif
#ifdef CPPIO
#define endl "\n"
#endif

#define push_back emplace_back
template<typename T>
class List : public vector<T>
{
public:
//  new
    template<typename... U>
    List(const U &... tail) : vector<T>(0)
    {
        pb(tail...);
    }

//  push_back
    void pb() {}
    template<typename... U>
    void pb(const T & head, const U &... tail)
    {
        this->push_back(head);
        pb(tail...);
    }

//print
    void print()
    {
        const int LEN = this->size();
        for (int i = 0; i < LEN; i++)
        {
            cout << (*this)[i] << (i == LEN - 1 ? '\n' : ' ');
        }
    }
};


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

pll exgcd(const long long x, const long long y)
{
    if (!y)
    {
        return make_pair(1, 0);
    }
    pll cur = exgcd(y, x % y);
    return make_pair(cur.second, cur.first - (x / y) * cur.second);
}

const long long __mod__ = 998244353;
long long mmod()
{
    return 1LL;
}
template <typename T, typename ...U>
long long mmod(const T &head, const U &... tail)
{
    return (head * mmod(tail...)) % __mod__;
}

long long mod(long long x, long long p = __mod__)
{
    return ((x % p) + p) % p;
}

void print() {}
template <typename T, typename... U>
void print(const T &head, const U &... tail)
{
    cout << head << (sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

#ifdef ConanYu
#define debug(...) print(__VA_ARGS__)
#else
#define debug(...) 0
#endif

inline long long fmul(long long a, long long c, const long long& Mod)
{
    a %= Mod, c %= Mod ;
    return (a * c - (long long)(((long double) a * c + 0.5) / Mod) * Mod) % Mod ;
}

long long gcd(long long x, long long y)
{
    return y == 0 ? x : gcd(y, x % y);
}

void solve();
int main()
{
#ifdef ConanYu
    freopen("test.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // freopen("2.in", "r", stdin);
    // freopen("2.out", "w", stdout);
    clock_t st = clock();
#endif

#ifdef CPPIO
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif

    solve();

#ifdef ConanYu
    clock_t ed = clock();
    cerr << "time: " << ((ed - st) * 1.0 / CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}

// *********************************************************************************************************

ll a[3333];
void solve()
{
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    cout << (sum - n) << endl;
}


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

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

  int a, b, c;
  cin >> a >> b >> c;

  if (a + b + c >= 22) cout << "bust\n";
  else cout << "win\n";

  return (0);
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, M, A[9][9];
//---------------------------------------------------------------------------------------------------
int check(int y) {
    int win = 0, non = 0;
    rep(x, 0, N) {
        if (A[y][x] == 1) win++;
        else if (A[y][x] < 0 and y != x) non++;
    }
    return win <= (N - 1) / 2 and (N - 1) / 2 <= win + non;
}
//---------------------------------------------------------------------------------------------------
int ans = 0;
void dfs(int cu) {
    int x = cu % N;
    int y = cu / N;

    if (cu == N * N) {
        ans++;
        return;
    }

    if (x == y or 0 <= A[y][x]) {
        if (check(y)) dfs(cu + 1);
        return;
    }
    
    A[y][x] = 1; A[x][y] = 0;
    if(check(y)) dfs(cu + 1);

    A[y][x] = 0; A[x][y] = 1;
    if (check(y)) dfs(cu + 1);

    A[y][x] = A[x][y] = -1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> N) {
        if (N == 0) return;
        cin >> M;
        rep(i, 0, N) rep(j, 0, N) A[i][j] = -1;
        rep(i, 0, M) {
            int a, b; cin >> a >> b;
            a--; b--;
            A[a][b] = 1;
            A[b][a] = 0;
        }

        ans = 0;
        dfs(0);
        printf("%d\n", ans);
    }
}




Measured memory_bytes: 3156
#include <iostream>


int main()
{
	std::string today;
	std::cin >> today;

	int nextSunday = 0;

	if ("SUN" == today)
	{
		nextSunday = 7;
	}
	else if ("MON" == today)
	{
		nextSunday = 6;
	}
	else if ("TUE" == today)
	{
		nextSunday = 5;
	}
	else if ("WED" == today)
	{
		nextSunday = 4;
	}
	else if ("THU" == today)
	{
		nextSunday = 3;
	}
	else if ("FRI" == today)
	{
		nextSunday = 2;
	}
	else
	{
		nextSunday = 1;
	}
	std::cout << nextSunday << std::endl;
}



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

int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;

    vector<bool> ten(10, false);
    vector<bool> hundred(100, false);
    vector<bool> thousand(1000, false);

    for(int i = 0; i < n - 2; i++){
        if(ten[s[i] - '0']) continue;
        else ten[s[i] - '0'] = true;
        for(int j = i + 1; j < n - 1; j++){
            if(hundred[(s[i] - '0') * 10 + s[j] - '0']) continue;
            else hundred[(s[i] - '0') * 10 + s[j] - '0'] = true;
            for(int k = j + 1; k < n; k++){
                int num = (s[i] - '0') * 100 + (s[j] - '0') * 10 + s[k] - '0';
                if(!thousand[num]){
                    thousand[num] = true;
                    ans++;
                } 
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    
    int ans = 0;
    rep(i, n){
        ans += max(0, v[i] - c[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    while(true){
        val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
        if (a == 0 && b == 0) return
        println((b - a).let{
            "${(it % 500) / 100} " +
                    "${(it % 1000) / 500} " +
                    "${it / 1000}"
        })
    }
}


Measured memory_bytes: 32148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}
int main(void){
  int n,k,h[100000],i,ans=1000000000;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&h[i]);
  qsort(h,n,sizeof(int),int_sort);
  for(i=0;i<n-k+1;i++)if(h[i+k-1]-h[i]<ans)ans=h[i+k-1]-h[i];
  printf("%d",ans);
  return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> vec(N, 0);
    for (int i = 0; i < N; i++) {
        vec.at(i) = i+1;
    }

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

    int pidx = 1;
    int qidx = 1;
    do {
        if (p != vec) {
            pidx++;
        } else {
            break;
        }
    } while (next_permutation(vec.begin(), vec.end()));

    sort(vec.begin(), vec.end());
    do {
        if (q != vec) {
            qidx++;
        } else {
            break;
        }
    } while (next_permutation(vec.begin(), vec.end()));

    cout << abs(pidx - qidx) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.time.Instant;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        Instant start = Instant.now();

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.parseInt(reader.readLine());
        int[][] points = new int[count][count];
        for (int i = 0; i < count; ++i) {
            String[] parts = reader.readLine().split(" ");
            for (int j = 0; j < count; ++j) {
                points[i][j] = Integer.parseInt(parts[j]);
            }
        }

//        System.out.println(Instant.now().toEpochMilli() - start.toEpochMilli());

        List<Integer> groups = new ArrayList<>();
        groups.add(0);
        long[] groupScores = new long[1 << count];

        for (int i = 0; i < count; ++i) {
            List<Integer> newGroups = new ArrayList<>(groups.size() * 2);
            for (int group : groups) {
                long score = groupScores[group];
                for (int j = 0; j < i; ++j) {
                    if ((group & (1 << j)) != 0) {
                        score += points[i][j];
                    }
                }
                int newGroup = group | (1 << i);
                groupScores[newGroup] = score;
                newGroups.add(group);
                newGroups.add(newGroup);
            }
            groups = newGroups;
        }

//        System.out.println(Instant.now().toEpochMilli() - start.toEpochMilli());

        ArrayDeque<Step> steps = new ArrayDeque<>(1 << count);
        steps.add(new Step(0, 0, 0));
        long[] splitScores = new long[1 << count];

        while (!steps.isEmpty()) {
            Step step = steps.removeFirst();
            int shifted = 1 << step.pos;
            int firstCool = step.first | shifted;
            int secondCool = step.second | shifted;
            int groupBoth = firstCool | step.second;

            splitScores[groupBoth] = Math.max(
                    splitScores[groupBoth],
                    Math.max(
                            groupScores[firstCool] + splitScores[step.second],
                            groupScores[step.first] + splitScores[secondCool]
                    ));

            if (step.pos + 1 < count) {
                steps.addLast(new Step(step.first, step.second, step.pos + 1));
                steps.addLast(new Step(firstCool, step.second, step.pos + 1));
                if (step.first != 0) {
                    steps.addLast(new Step(step.first, secondCool, step.pos + 1));
                }
            }
        }

//        System.out.println(Instant.now().toEpochMilli() - start.toEpochMilli());

        System.out.println(splitScores[(1 << count) - 1]);
    }

    public static class Step {
        int first;
        int second;
        int pos;

        public Step(int first, int second, int pos) {
            this.first = first;
            this.second = second;
            this.pos = pos;
        }
    }
}


Measured memory_bytes: 456084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
const long mod=998244353;
const long N=1e5+5;
int size[N];
int Arr[N];
int power[N];




int main()
{
  
       

    ll a,b;
    cin >> a>>b;
    if(b>=a)
      cout <<"unsafe";
    else cout <<"safe";

    

     return 0;
}
 

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
char s[10];
cin>>s;
int i,flag=0;
for(i=0;i<6;i++){
if(s[2]==s[3]&&s[4]==s[5])
{
flag=1;
break;
}
}
if(flag==1)
cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>

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

     char s[h][w+1];

     for(int i = 0; i < h; i++)
          scanf("%s", &s[i][0]);

     for(int i = 0; i < h; i++)
          for(int j = 0; j < w; j++)
               if(s[i][j] == '.')
               {
                    int score = 0;
                    if(i - 1 > -1)
                         if(s[i-1][j] == '#') score++;
                    if(j - 1 > -1)
                         if(s[i][j-1] == '#') score++;
                    if(i + 1 < h)
                         if(s[i+1][j] == '#') score++;
                    if(j + 1 < w)
                         if(s[i][j+1] == '#') score++;
                    if(i - 1 > -1 && j - 1 > -1)
                         if(s[i-1][j-1] == '#') score++;
                    if(i + 1 < h && j + 1 < w)
                         if(s[i+1][j+1] == '#') score++;
                    if(i - 1 > -1 && j + 1 < w)
                         if(s[i-1][j+1] == '#') score++;
                    if(i + 1 < h && j - 1 > -1)
                         if(s[i+1][j-1] == '#') score++;
                    s[i][j] = score + 48;
               }

     for(int i = 0; i < h; i++)
          printf("%s\n", s[i]);

     return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

vector<string> A;
int H, W, K, dist[820][820], dinf=1e6;
queue<pair<int, int>> q;

void bfs(){
	while(q.size()>0){
		int s=q.front().first, t=q.front().second;
		q.pop();
		if(dist[s][t]>=K) break;
		if(s>0){
			if(dist[s-1][t]==dinf && A[s-1][t]=='.'){
				dist[s-1][t]=dist[s][t]+1;
				q.push(make_pair(s-1, t));
			}
		}
		if(s+1<H){
			if(dist[s+1][t]==dinf && A[s+1][t]=='.'){
				dist[s+1][t]=dist[s][t]+1;
				q.push(make_pair(s+1, t));
			}
		}
		if(t>0){
			if(dist[s][t-1]==dinf && A[s][t-1]=='.'){
				dist[s][t-1]=dist[s][t]+1;
				q.push(make_pair(s, t-1));
			}
		}
		if(t+1<W){
			if(dist[s][t+1]==dinf && A[s][t+1]=='.'){
				dist[s][t+1]=dist[s][t]+1;
				q.push(make_pair(s, t+1));
			}
		}
	}
}

int main() {
	cin >> H >> W >> K;
	A.resize(H);
	for(int i=0; i<H; ++i){
		cin >> A[i];
		for(int j=0; j<W; ++j){
			if(A[i][j]=='S'){
				dist[i][j]=0;
				q.push(make_pair(i, j));
			}
			else dist[i][j]=dinf;
		}
	}
	bfs();
	int ans=dinf;
	for(int i=0; i<H; ++i){
		for(int j=0; j<W; ++j){
			if(dist[i][j]<=K){
				int mn=min({i, H-1-i, j, W-1-j});
				ans=min(ans, 1+(mn+K-1)/K);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
import numpy as np

import heapq
N = int(input())
a = list(map(int, input().split()))
ra = -np.array(a[::-1])

def serchPop(alst):
    h = []
    total = []
    sum = 0
    for i in range(2 * N):
        heapq.heappush(h, alst[i])
        sum += alst[i]
        if i >= N:
            tmp = heapq.heappop(h)
            sum -= tmp

        if i >= N - 1:
            total.append(sum)

    return total

ans = -10 ** 20
ltotal = serchPop(a)
rtotal = serchPop(ra)
for i in range(N + 1):
    ans = max(ans, ltotal[i] + rtotal[N - i])

print(ans)

Measured memory_bytes: 46172
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,Y;
    cin >> N >> Y;
    int cnt[3] = {};
    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= N;j++){
            if(N - i - j < 0)break;
            if(10000*i + 5000*j + 1000*(N-i-j) == Y){
                cout << i << " " << j << " " << (N-i-j) << endl;
                return 0;
            }
        }
    }   
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
using namespace std;
int max(int x, int y) {
	if (x > y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}


int A,B,N,M,stu[50][2],point[50][2],mini[50],ans[50];
bool match[100001];


int main(){
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> stu[i][0] >> stu[i][1];
		mini[i] = 1000000000;
	}
	for (int i = 0; i < M; i++) {
		cin >> point[i][0] >> point[i][1];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (abs(stu[i][0] - point[j][0]) + abs(stu[i][1] - point[j][1]) < mini[i]) {
				mini[i] = abs(stu[i][0] - point[j][0]) + abs(stu[i][1] - point[j][1]);
				ans[i] = j+1;
			}
		}
	}
		for (int i = 0; i < N; i++) {
			cout << ans[i] << endl;
		}
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c, k;

	cin >> a >> b >> c;
	cin >> k;

	int max = std::max({a, b, c});
	int ans = max * pow(2, k) + a + b + c - max;

	cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>l(n); for(auto&&i:l)cin>>i;
	int ans=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				if(l.at(i)==l.at(j)||l.at(j)==l.at(k)||l.at(k)==l.at(i))continue;
				int mx=max({l.at(i),l.at(j),l.at(k)}),sum=l.at(i)+l.at(j)+l.at(k);
				if(sum-mx>mx)++ans;
			}
		}
	}
	cout<<ans<<"\n"s;
}


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

#include <algorithm>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <string>

using namespace std;

#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 INF 1 << 29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

/* template end */

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

  int h, w;
  cin >> h >> w;

  string table[h];
  bool check[h][w];
  vector<int> wv(w);
  for (int i = 0; i < h; i++) {
    bool t = true;
    cin >> table[i];
    for (int j = 0; j < w; j++) {
      if (table[i][j] == '#') {
        t = false;
      }
      wv[j] += table[i][j] == '.' ? 1 : 0;
      check[i][j] = true;
    }
    if (t) {
      for (int j = 0; j < w; j++) {
        check[i][j] = false;
      }
    }
  }

  for (int i = 0; i < w; i++) {
    if (wv[i] == h) {
      for (int j = 0; j < h; j++) {
        check[j][i] = false;
      }
    }
  }

#if DEBUG
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << check[i][j] << ' ';
    }
    cout << endl;
  }

  cout << "** RESULT **" << endl; // debug
#endif

  for (int i = 0; i < h; i++) {
    bool f = false;
    for (int j = 0; j < w; j++) {
      if (check[i][j]) {
        cout << table[i][j];
        f = true;
      }
    }
    if (f) {
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int n = sc.nextInt();
		int x = sc.nextInt();
		int l[] = new int[n + 1];
		l[0] = 0;
		for(int i = 1; i <= n; i++) {
			l[i] = sc.nextInt();
			l[i] += l[i - 1];
		}
		int cnt = 0;
		for(int i = 0; i <= n; i++) {
			if(l[i] <= x)cnt++;
			else break;
		}
		System.out.println(cnt);
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 25300
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, u, v;
std::vector<ll> G[100010];
ll dist[2][100010];
bool leaf[100010];

void dfs( ll v, ll idx, ll d = 0, ll p = -1 ) {
  dist[idx][v] = d;

  for( auto u : G[v] ) if( u != p ) {
    dfs( u, idx, d+1, v );
  }

  if( G[v].size() == 1 )
    leaf[v] = true;
  
  return;
}

int main()
{
  std::cin >> N >> u >> v;
  --u; --v;

  rep( i, N-1 ) {
    ll A, B;
    std::cin >> A >> B;
    --A; --B;
    G[A].emplace_back( B );
    G[B].emplace_back( A );
  }

  dfs( u, 0 );
  dfs( v, 1 );

  ll ans = 0;

  rep( i, N ) if( leaf[i] && dist[0][i] < dist[1][i] ) {
    chmax( ans, dist[1][i]-1 );
  }

  std::cout << ans << std::endl;

  return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	string S;cin >> S;

	ll cl{0}, cr{0};

	for (auto &e : S)
	{
		if (e == '(')
		{
			++cr;
		}
		else
		{
			if (cr == 0) ++cl;
			else --cr;
		}
	}

	string res;
	REP(i, cl) res += '(';
	res += S;
	REP(i, cr) res += ')';
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            for(int j=i+1;j<s.size();j++){
                if(s[j]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 256
import numpy as np
n, W = map(int, input().split())

dp = [10**10]*(10**5)
dp = np.array(dp)

for _ in range(n):
    w, v = map(int, input().split())
    np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])
    np.minimum(w, dp[:v], out=dp[:v])
    
#print(dp[:101])
#print(dp[91])
value = 10**5
for i in dp[::-1]:
    if i <= W:
        print(value)
        exit()
    value -= 1



Measured memory_bytes: 15964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin>>A>>B;

    cout << A*B << endl;



    



}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 2e5+12;
//indexed_set s;

int n,m;
ll a[MAXN], b[MAXN], k;
ll firstPref[MAXN], secondPref[MAXN];

int main() {

    NoType;

    cin >> n >> m >> k;
    firstPref[0] = 0;
    secondPref[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        firstPref[i] = firstPref[i - 1] + a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        secondPref[i] = secondPref[i - 1] + b[i];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        int l = 1;
        int r = m;
        if (firstPref[i] > k) break;
        int cur = 0;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (firstPref[i] + secondPref[mid] <= k) cur = mid, l = mid + 1;
            else if (firstPref[i] + secondPref[mid] > k) r = mid - 1;
        }
        ans = max(ans, i + cur);
    }

    cout << ans;

return 0;
}


Measured memory_bytes: 9840
#include <iostream>
#include <vector>

using namespace std;

int back(int t){
    while(t >= 10) t /= 10;
    return t;
}

int main(){
    int N;
    while(cin >> N){
        vector<vector<long long>> cnt(10, vector<long long>(10, 0));
        for(int i=1;i<=N;i++){
            ++cnt[back(i)][i%10];
        }
        long long res = 0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                res += cnt[i][j] * cnt[j][i];
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005];
ll dp[105][105];
char s[100005];

int main(){
    cin>>n>>m;
	if(n<=8 && m<=8){
		p("Yay!");
	}else{
		p(":(");
	}
		
	return 0;

}

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

int main() {
    int N, R;
    cin >> N >> R;
    int inrate;
    if (N >= 10) inrate = R;
    else inrate = R + 100*(10-N);
    cout << inrate << endl;
    return 0;
}

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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

int N, a[102], D[102], cnt[102];
#define Error return puts("Impossible"), 0

int main() {
  scanf("%d", &N);
  foru(i, 1, N) scanf("%d", &a[i]);
  sort(a + 1, a + N + 1);
  if (a[1] != (a[N] + 1) / 2) Error;
  foru(i, 1, N) cnt[a[i]]++;
  ford(i, a[N], a[1] + 1) if (cnt[i] < 2) Error;
  if (cnt[a[1]] != (a[N] % 2) + 1) Error;
  puts("Possible");
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "akasaka" ].parse.expand.solve == "Yes" );
	assert( [ "level" ].parse.expand.solve == "No" );
	assert( [ "atcoder" ].parse.expand.solve == "No" );
}



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 s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto ba = 0L;
	auto na = s.length.signed;
	foreach( i; ba .. ba + na / 2 )
	{
		if( s[ i ] != s[ ba + na - 1 - i ] ) return "No";
	}
	auto bb = 0L;
	auto nb = ( s.length.signed - 1 ) / 2;
	foreach( i; bb .. bb + nb / 2 )
	{
		if( s[ i ] != s[ bb + nb - 1 - i ] ) return "No";
	}
	auto bc = ( s.length.signed + 3 ) / 2 - 1;
	auto nc = s.length.signed - bc;
	foreach( i; bc .. bc + nc / 2 )
	{
		if( s[ i ] != s[ bc + nc - 1 - i ] ) return "No";
	}
	return "Yes";
}


Measured memory_bytes: 256
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

void Read(int &p)
{
	p=0;
	int f=1;
	char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9')
		p=p*10+c-'0',c=getchar();
	p*=f;
}

const int MAXN=1000+24;
int N,x[MAXN],y[MAXN],r[MAXN],vis[MAXN];
double Dis[MAXN];
#define ids(i,j) max(0.0,sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j])

bool inq[MAXN];
int showup[MAXN];
int Spfa()
{
	int s=1,t=2;
    queue<int>Q;
    for(int i=1;i<=N;i++) Dis[i]=(i==s)?0:4000000000.0;
    Q.push(s),inq[s]=1,showup[s]++;

    int p;

    while(!Q.empty())
    {
        p=Q.front(),Q.pop(),inq[p]=0;
        for(int i=1;i<=N;i++)
            if(Dis[i]>ids(p,i)+Dis[p])
            {
                Dis[i]=ids(p,i)+Dis[p];
                if(!inq[i])
                {
                    Q.push(i),inq[i]=1,showup[i]++;
                    if(showup[i]>N) return -1;
                }
            }
    }
    if(Dis[t]==4000000000.0) return -2;
    return Dis[t];
}
int main()
{
	Read(x[1]); Read(y[1]); Read(x[2]); Read(y[2]);
	Read(N),N+=2;
	for(int i=3;i<=N;i++)
		Read(x[i]),Read(y[i]),Read(r[i]);
	Spfa();
	printf("%.10lf",Dis[2]);
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	A=list(map(int,input().split()))
	
	ans=[0]*(n)
	ans[0]=sum(A)-2*sum(A[1::2])
	for i in range(1,n):
		ans[i]=2*A[i-1]-ans[i-1]
	print(*ans)
	
	
	





if __name__ == '__main__':
	main()


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  i64 N = input(), A = input(), B = input();

  i64 ans = A * (N / (A + B));
  ans += min(N % (A + B), A);

  cout << ans << endl;
}

signed main(int argc, char *argv[]) { solver(); }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
// ll mod=1000000007;
// ld pi = 3.14159;
map <ll,ll> umap;
ll primeFactors(ll n)  
{  
    ll count=0;
    ll temp=0;
    ll temp2=1;
    while (n % 2 == 0)  
    {  
        temp++;
        if(temp==temp2){
            temp2++;
            count++;
            temp=0;
        }
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        temp=0;
        temp2=1;
        while (n % i == 0)  
        {  
            temp++;
        if(temp==temp2){
            temp2++;
            count++;
            temp=0;
        }
            n = n/i;  
        }  
    }   
    if (n > 2)  
        count++;
    return count;
} 



int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,t1,i,j,k,temp,temp2,n,m,x,y,z,sum=0,o;
    // cin >> t;
    // while(t--){
    ld a,b;
    cin >> n;
    sum = primeFactors(n);
    cout << sum;
}

Measured memory_bytes: 3696
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String S = sc.next();
        sc.close();
        final int A = Integer.parseInt(S.substring(0, 1));
        final int B = Integer.parseInt(S.substring(1, 2));
        final int C = Integer.parseInt(S.substring(2, 3));
        final int D = Integer.parseInt(S.substring(3, 4));

        for (int i=0; i<2; i++) {
            for (int j=0; j<2; j++) {
                    for (int k=0; k<2; k++) {
                        int sum = A;
                        StringBuilder sb = new StringBuilder(A + "+2+3+4=7");
                        if (i==0) {
                            sum += B;
                            sb.replace(1, 3, "+" + B);
                        } else {
                            sum -= B;
                            sb.replace(1, 3, "-" + B);
                        }
                        if (j==0) {
                            sum += C;
                            sb.replace(3, 5, "+" + C);
                        } else {
                            sum -= C;
                            sb.replace(3, 5, "-" + C);
                        }
                        if (k==0) {
                            sum += D;
                            sb.replace(5, 7, "+" + D);
                        } else {
                            sum -= D;
                            sb.replace(5, 7, "-" + D);
                        }
                        if (sum==7) {
                            System.out.println(sb);
                            return;
                        }
                }
            }
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

#define MOD 1000000007

using namespace std;

typedef long long int64;



int main(void){
    int64 N,M;
    cin>>N>>M;

    vector<int64> a(M+2);
    vector<int64> step(N+2);

    int64 ans=1;

    a[0]=-1;
    for(int64 i=1;i<=M;i++){
        cin>>a[i];
    }
    a[M+1]=N+1;

    // for(int64 i=1;i<=M+1;i++){
    //     if(a[i]-a[i-1]<=1){
    //         cout<<0<<endl;
    //         return 0;
    //     }
    // }
    step[0]=0;
    step[1]=step[2]=1;

    

    for(int64 i=3;i<=N+1;i++){
        step[i]=(step[i-1]+step[i-2])%MOD;
    }
    
    if(M==0){
        cout<<step[N+1]<<endl;
        return 0;
    }

    for(int64 i=1;i<=M+1;i++){
        ans=(ans*(step[a[i]-a[i-1]-1]))%MOD;    
    }

    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b,x; cin >> a >> b >> x;
    int ans = INF;
    int offset = 1000;
    vector<int>memo(500000,INF);
    function<int(int,int)>dfs = [&](int tans, int tnum) -> int{
        if(tnum<=0){cmin(ans, tans); return 0LL;}
        memo[tnum + offset] = tans;
        if(memo[tnum-1000 + offset] > tans+a)
            dfs(tans+a,tnum-1000);
        if(memo[tnum-500 + offset] > tans+b)
            dfs(tans+b,tnum-500);
        return 0LL;
    };
    dfs(0,x);
    cout << ans << endl;
}





Measured memory_bytes: 6800
from operator import itemgetter
import heapq

N, M = map(int, input().split())

A = []
for i in range(N):
  X = list(map(int, input().split()))
  A.append([X[0], -X[1]])
  
A = sorted(A, key=itemgetter(0,1), reverse=False)
#print(A)
# days, values(minus, asc)

Q = []
heapq.heapify(Q)
ans = 0
x = 1
i = 0
while x <= M:
  # A0がxである要素をキューに追加
  if i < N and A[i][0] == x:
    heapq.heappush(Q, A[i][1])
    i += 1
    continue
  else:
    # 最小値（マイナスかけて最大）を答えに追加して、1日進める
    if len(Q) > 0:
      ans += heapq.heappop(Q) * (-1)
    x += 1
      
print(ans)
  

Measured memory_bytes: 28992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int ans=0,num;
    char s[100];
    scanf("%s",&s);
    for(int i=0;i<100;i++){
        if(!('a'<=s[i]&&'z'>=s[i])){
            num=i-1;
            break;
        }
        if(i==99)num=i;
    }
    for(int i=0;i<((num+1)%2==0?(num+1)/2:num/2);i++){
        if(s[i]!=s[num-i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

int main() {
    int a,b,c,sum=0;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b)
        sum++;
    if(b==c)
        sum++;
    if(a==c)
        sum++;
    if(sum==1)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,bool> mp;
int n,a[14],ans[52],c;

int cal(){
  int res=0;
  for(int i=1;i<13;i++)res=res*5+a[i];
  return res;
}

bool dfs(int s,int d){
  if(!d)return 1;
  int y=cal();
  if(mp.count(y))return mp[y];
  for(int i=13;i>0;i--){
    if(a[i]&&(s-i)%i==0){
      ans[d-1]=i;
      a[i]--;
      if(dfs(s-i,d-1))return mp[y]=1;
      a[i]++;
    }
  }
  return 0;
}

int main(){
  while(cin>>n,n){
    memset(a,0,sizeof(a));
    mp.clear();
    c=0;
    for(int i=0,b;i<n;i++)scanf("%d",&b),a[b]++,c+=b;
    if(dfs(c,n)){
      for(int i=0;i<n;i++){
	if(i)printf(" ");
	printf("%d",ans[i]);
      }
    }else printf("No");
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3064