akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int n;
int a[364364];
ll s0[114514] = {};
ll s1[114514] = {};
int main() {
	cin >> n;
	REP(i, 3 * n) {
		cin >> a[i];
	}	
	priority_queue<int, vector<int>, greater<int>> que0;
	priority_queue<int> que1;
	REP(i, n) {
		que0.push(a[i]);
		s0[0] += a[i];
	}
	FOR(i, 2 * n, 3 * n) {
		que1.push(a[i]);
		s1[n] += a[i];
	}
	ll ans = LMIN;
	for (int i = n; i <= 2 * n - 1; i++) {
		int x = que0.top();
		if (x < a[i]) {
			s0[i - n + 1] = s0[i - n] + (a[i] - x);
			que0.push(a[i]);
			que0.pop();
		}
		else s0[i - n + 1] = s0[i - n];
	}
	for (int i = 2 * n - 1; i >= n; i--) {
		int y = que1.top();
		if (y > a[i]) {
			s1[i - n] = s1[i - n + 1] + (a[i] - y);
			que1.push(a[i]);
			que1.pop();
		}
		else s1[i - n] = s1[i - n + 1];
	}
	for (int i = 0; i <= n; i++) {
		ll tmp = s0[i] - s1[i];
		if (tmp > ans)ans = tmp;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 3960
let()=
  let list = Scanf.sscanf (read_line()) "%d %d %d" (fun a b c -> a::b::c::[]) in
  let sorted_list = List.sort (fun a b -> a-b) list in
  let rec print_list li =
    match li with
    |[] -> print_string "\n";
    |h::t -> print_int h; if t <> [] then print_string " "; print_list t;
  in
  print_list sorted_list
;;


Measured memory_bytes: 2388
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 1000000007
#define pb push_back
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,l,a,b,c,q;
    cin>>n>>m>>l;
    vector<vector<pll>> adj(n+1);
    ll maxLen=0;
    vector<vector<ll>> arr1(n+1,vector<ll>(n+1,1e15)),arr2(n+1,vector<ll>(n+1));
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        if(c>l) continue;
        adj[a].pb({b,c});
        adj[b].pb({a,c});
        // maxLen=max(maxLen,c);
        arr1[a][b]=min(arr1[a][b],c);
        arr1[b][a]=min(arr1[b][a],c);
    }
    
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(arr1[i][j]>arr1[i][k]+arr1[k][j])
                arr1[i][j]=arr1[i][k]+arr1[k][j];
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(arr1[i][j]<=l) arr2[i][j]=1;
            else arr2[i][j]=n;
        }
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(arr2[i][j]>arr2[i][k]+arr2[k][j])
                arr2[i][j]=arr2[i][k]+arr2[k][j];
            }
        }
    }
    cin>>q;
    while(q--){
        cin>>a>>b;
        if(arr2[a][b]>n-1) cout<<"-1"<<endl;
        else cout<<arr2[a][b]-1<<endl;
    }   
    return 0;
}


Measured memory_bytes: 4352
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

fn main() {
    let K = rl().chars().map(|c| c as u8 - b'0').collect::<Vec<u8>>();
    let D = read!(usize);

    let N = K.len();

    // dp[i][s][less] = x
    // 上位 i 桁が確定済み
    // 確定済みの桁の総和が s (mod D)
    // less = 1 <=> K 未満であることが確定済み
    // 数字の個数が x (mod P)
    let mut dp = vec![vec![vec![0, 0]; D]; N + 1];

    dp[0][0][0] = 1;

    for i in 0..N {
        for s in 0..D {
            for d in 0..10 {
                let less = K[i] > d as u8;
                let eq = K[i] == d as u8;

                dp[i + 1][(s + d) % D][1] += dp[i][s][1];
                dp[i + 1][(s + d) % D][1] %= P;

                if less {
                    dp[i + 1][(s + d) % D][1] += dp[i][s][0];
                    dp[i + 1][(s + d) % D][1] %= P;
                }
                if eq {
                    dp[i + 1][(s + d) % D][0] += dp[i][s][0];
                    dp[i + 1][(s + d) % D][0] %= P;
                }
            }
        }

        // debug!(dp[i + 1]);
    }

    let mut x = dp[N][0][0];
    x += dp[N][0][1];
    x %= P;

    // 0 を数えてしまっているので引く
    x += P - 1;
    x %= P;

    println!("{}", x)
}


Measured memory_bytes: 45308
import java.net.StandardSocketOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_300().doIt();
	}
	class Test_300{
		void doIt() {
			int sx = sc.nextInt();
			int sy = sc.nextInt();
			int tx = sc.nextInt();
			int ty = sc.nextInt();
			Pos p1 = new Pos(tx - sx,ty - sy); //"RU"
			Pos p2 = new Pos(tx - sx,ty - sy); //"LD"
			Pos p3 = new Pos(tx - sx + 1,ty - sy + 1); //"LD"
			Pos p4 = new Pos(tx - sx + 1,ty - sy + 1); //"RU"
			
			for(int i = 0;i < p1.y;i++)System.out.print("U");
			for(int i = 0;i < p1.x;i++)System.out.print("R");
			
			for(int i = 0;i < p2.y;i++)System.out.print("D");
			for(int i = 0;i < p2.x;i++)System.out.print("L");
			
			System.out.print("L");
			for(int i = 0;i < p3.y;i++)System.out.print("U");
			for(int i = 0;i < p3.x;i++)System.out.print("R");
			System.out.print("D");
			
			System.out.print("R");
			for(int i = 0;i < p4.y;i++)System.out.print("D");
			for(int i = 0;i < p4.x;i++)System.out.print("L");
			System.out.println("U");
		}
	}
	class Pos{
		int x;
		int y;
		public Pos(int x,int y) {
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 25280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    vector<int> vec {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << vec[k-1] << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    string ans;
    if ((Y-2*X)%2 == 0 && 0 <= (Y-2*X)/2 && (Y-2*X)/2 <= X){
        ans = YES;
    }
    else
    {
        ans = NO;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


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


void solve() {
  int A,B;
  cin >> A >> B;

  cout << (3*A+B)/2 << "\n";
}

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


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_h

#include <bits/stdc++.h>

using namespace std;

int main () {
    int m, n;
    cin >> m >> n;
    vector<string>grid(m);

    for(auto &x: grid)
        cin >> x;
    #define mod 1000000007
    vector<vector<int>>dp(m, vector<int>(n, 0));

    dp[0][0] = 0;
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            if(grid[i][j] == '#')
                dp[i][j] = 0;
            else {
                if(i == 0 and j == 0)
                    dp[i][j] = 1;
                else if(i > 0 and j == 0)
                    dp[i][j] = dp[i-1][j];
                else if(j > 0 and i == 0)
                    dp[i][j] = dp[i][j-1];
                else
                    dp[i][j] = (dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
            }
        }
    }
    cout << dp[m-1][n-1] << endl;
    return 0;
}

Measured memory_bytes: 5248
#include<iostream>
using namespace std;
int main(){
    int k, x;
    cin >> k >> x;
    
    for(int i(-1000000); i<=1000000; i++){
        if(i > x-k && i < x+k){
            cout << i << " ";
        }
    }
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")

#define n 6
bool win[n][n][n][4]; 

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

	long long d, t, s, i, j, k;
	cin >> d >> t >> s;
	if (s * t >= d) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define ll long long

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

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

const ll INF = 1LL << 60;
const ll MAX = 100100;
const ll MAX_N = 100100;
const ll MAX_M = 100100;

int main() {
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) {
        cout << -1 << endl;
    } else {
        cout << A * B << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int64_t amaririyou(int64_t L, int64_t R) {
    int64_t mod_l = L % 2019;
    int64_t mod_r = R % 2019;

    int64_t min_ = INT64_MAX;
    if (R - L >= 2019 || mod_r <= mod_l) {
        return 0;
    } else {
        for (int i=mod_l; i<mod_r; i++) {
            for (int j=i+1; j<=mod_r; j++) {
                int64_t num = i * j % 2019;
                if (min_ > num) {
                    min_ = num;
                }

                if (min_ == 0) {
                    break;
                }
            }

            if (min_ == 0) {
                break;
            }
        }
        return min_;
    }
}

int64_t gutyokukai(int64_t L, int64_t R) {
    int64_t min_ = INT64_MAX;
    for (int64_t i=L; i<R; i++) {
        int64_t l = i % 2019;
        for (int64_t j=i+1; j<=R; j++) {
            int64_t r = j % 2019;
            int64_t num = l * r % 2019;
            if (min_ > num) {
                min_ = num;
            }

            if (min_ == 0) {
                cout << i << endl;
                cout << j << endl;
                return min_;
            }
        }
    }

    return min_;
}

int main()
{
    int64_t L, R;
    cin >> L >> R;
    cout << amaririyou(L, R) << endl;

    return 0;
}

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

#define TR 100000

int l[TR];
using namespace std;
vector<int> h;


int solve(int p) {
	if(p == 0)
		return 0;
	if(p < 0)
		return 10000000;
	if(l[p] != -1)
		return l[p];
	l[p] = min(abs(h[p] - h[p - 1]) + solve(p - 1), abs(h[p] - h[p - 2]) + solve(p - 2));
	return l[p];

}

int main() {
	int n;
	cin >> n;
	memset(l, -1, TR * sizeof(int));
	for(int i = 0, tmp ; i < n ; i++) {
		cin >> tmp;
		h.push_back(tmp);
	}
	solve(n - 1);
	cout << l[n - 1] << endl;
}

Measured memory_bytes: 3448
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N >> K;
    vector< pair<ll, ll> > in;
    for (int i = 0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        in.push_back(make_pair(a, b));
    }
    
    sort(in.begin(), in.end());

    vector< pair<ll, ll> >::iterator itr = in.begin();
    ll cnt = 0;    
    while (true) {
        //cout << (*itr).first << endl;
        cnt += (*itr).second;
        if (cnt >= K)
            break;
        ++itr;
    }

    cout << (*itr).first << endl;
    //cout << fixed << setprecision(10) << M_PI * (double)rad << endl;

    return 0;
}

Measured memory_bytes: 2420
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nas = lambda: stdin.readline().split()
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
aced = [0] * n
pens = [0] * n
for i in range(m):
    p, s = nas()
    p = int(p)
    if s == "AC":
        aced[p-1] = 1
    else:
        if not aced[p-1]:
            pens[p-1] += 1
print(sum(aced), sum(pens[_] for _ in range(n) if aced[_]))


Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
ll a[maxx];

int main() {
	while(cin >> n && n) {
		ll ans = 0;
		memset(a, 0, sizeof(a));
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		int l = 1, r = n;
		ans = a[n] - a[1];
		for(int i = 2; i <= n / 2; i++) {
			int dd = a[n - i + 1] - a[l];
			int pp = a[r] - a[i];
			ans += dd + pp;
			l++;
			r--;
		}
		if(n & 1) {
			int x = a[r] - a[n / 2 + 1];
			int y = a[n / 2 + 1] - a[l];
			ans += max(x, y);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
long long modpow(long long a, long long n, long long mod=2019){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main(){
	string s;
	map<int, int> dis;
	cin >>s;
	dis[0]++;
	ll ans  = 0LL;
	int cnt = 0;
	rrep(i, s.size()) { 
		cnt +=(s[i]-'0')*modpow(10,s.size()-i-1);
		cnt %= 2019;
		dis[cnt]++;
	//	clog << cnt << endl;
	}
	repi(itr, dis) { //clog << itr->F << " " << itr->S << endl;
		ans += (ll)(itr->S) * (itr->S - 1) / 2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3748
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut seq = vec![0; n];
    let mut cnts = vec![0; 50];;
    for i in 0..n {
        seq[i] = read::<usize>();
        for j in 0..50 {
            cnts[j] += (seq[i] >> j) & 1;
        }
    }
    let mut upper = true;
    let mut x = 0;
    for i in (0..50).rev() {
        let bit = 1 << i;
        if bit > k || (upper && (bit & k) == 0) {
            continue;
        }
        if cnts[i] >= (n + 1) / 2 {
            upper = false;
        } else {
            x |= bit;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        ans += seq[i] ^ x;
    }
    println!("{}", ans);
}


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

int main() {
    ll N,i,r=20,t;
    cin >> N;

    for(i=1; i*i<=N; i++) {
        if(N%i == 0)
            t = max(to_string(i).size(), to_string(N/i).size());
        r = min(r,t);
    }
        
    cout << r << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		long inf = (long) Math.pow(10, 11);
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int Q = sc.nextInt();
		long[] s = new long[A+2];
		s[0] = -inf;
		s[A+1] = inf;
		for(int i = 1; i < A+1; i++) s[i] = sc.nextLong();
		long[] t = new long[B+2];
		t[0] = -inf;
		t[B+1] = inf;
		for(int i = 1; i < B+1; i++) t[i] = sc.nextLong();
		long[] x = new long[Q];
		for(int i = 0; i < Q; i++) x[i] = sc.nextLong();
		for(int i = 0; i < Q; i++) {
			int b = Math.abs(Arrays.binarySearch(s, x[i])) - 1;
			int d = Math.abs(Arrays.binarySearch(t, x[i])) - 1;
			long res = inf;
			for(int j = b-1; j <= b; j++) {
				for(int k = d-1; k <= d; k++) {
					long d1 = Math.abs(s[j]-x[i]) + Math.abs(s[j]-t[k]);
					long d2 = Math.abs(t[k]-x[i]) + Math.abs(s[j]-t[k]);
					res = Math.min(res,  Math.min(d1, d2));
				}
			}
			System.out.println(res);
		}
	}

}


Measured memory_bytes: 101736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ,k ;
  cin >> n >> k;
  vector<int>l(n);
  for( int i = 0;i<n ; i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans = 0 ;
  for(int i = 0 ; i<k;i++){
    ans += l.at(i);
  }
  cout << ans << endl;
}

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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 300
#define MAXS 90000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 998244353;

ll dp[MAXN+5][2*MAXS+305]; 

int32_t main()
{
    #ifdef DEBUG
    //freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n; 
    vector<int> nums(n);
    int sum = 0; 
    for0(i,n) {
        read(nums[i]);
        sum += nums[i]; 
    }
    
    ms(dp,0);
    for (int d=0; d<=sum; d++)
        dp[n][d+MAXS] = 1; 
    
    for (int i=n-1; i>=0; i--) {
        for (int d=-sum; d<=sum; d++) {
            if (d+nums[i]+MAXS <= 2*MAXS and d-nums[i]+MAXS >= 0)
                dp[i][d+MAXS] = (dp[i+1][d+nums[i]+MAXS] + 2*dp[i+1][d-nums[i]+MAXS]) % MOD; 
        }
    }
    
    ll tot = 1; 
    for0(i,n)
        tot = (tot*3) % MOD;     
    ll bad = dp[0][0+MAXS];
    
    ms(dp,0);
    dp[n][0+MAXS] = 1; 
    
    for (int i=n-1; i>=0; i--) {
        for (int d=-sum; d<=sum; d++) {
            if (d+nums[i]+MAXS <= 2*MAXS and d-nums[i]+MAXS >= 0)
                dp[i][d+MAXS] = (dp[i+1][d+nums[i]+MAXS] + dp[i+1][d-nums[i]+MAXS]) % MOD; 
        }
    }
    ll equal = dp[0][0+MAXS];
    
    prl(bad) 
    prl(tot)
    prl(equal) 
    ll ans = tot - 3*bad + 3*equal; 
    cout<<pmod(ans,MOD)<<endl; 
    
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)

#define rep(i,n) REP(i,0,n)

int main() {
  
  string s;
  while(cin >> s) {
    if(s == "#") break;
    reverse(s.begin(), s.end());
    
    int a = 0;
    int n = 0;
    rep(i, s.size()) {
      if(s[i] == 'n') {
        a *= 2;
        if(n) { a -= 90; }
        if(n) { n <<= 1; }
        else { n = 1; }
        //   cerr << "north " << a << "/" << n << endl;
      }
      if(s[i] == 'w') {
        a *= 2;
        a += 90;
        if(n) { n <<= 1; }
        else { n = 1; }
        //    cerr << "west " << a << "/" << n << endl;
      }
    }
    
    int g = __gcd(a, n);
    if(g == 0) { cout << 0 << endl; }
    else {
      cout << a/g;
      if(n/g > 1) { cout << "/" << n/g; }
      cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
	{
		cout<<1<<endl;
	}
	if(b==0)
	{
		cout<<2<<endl;
	}
	if(c==0)
	{
		cout<<3<<endl;
	}
	if(d==0)
	{
		cout<<4<<endl;
	}
	if(e==0)
	{
		cout<<5<<endl;
	}
	return 0;
}

Measured memory_bytes: 3584
package main
import (
  "fmt"
  "sort"
)
var x []int
func main() {
  x = primes(100000)
  var n int
  fmt.Scan(&n)
  a := make([]int,n+1)
  for i:=n;i>-1;i-- { fmt.Scan(&a[i]) }
  set := make(map[int]struct{})
  for i:=0;i<len(x);i++ {
    if x[i] > n { break }
    set[x[i]] = struct{}{}
  }
  g := abs(a[n])
  for i:=0;i<n;i++ { g = gcd(g,abs(a[i])) }
  f := factors(g)
  for i:=0;i<len(f);i++ { set[f[i]] = struct{}{} }
  p := []int{}
  for k,_ := range set { p = append(p,k) }
  sort.Ints(p)
  Outer:
  for j:=0;j<len(p);j++ {
    if a[0]%p[j] != 0 { continue }
    b := make([]int,n+1)
    for i:=0;i<n+1;i++ {
      b[i] = a[i]%p[j]
      if b[i] < 0 { b[i] += p[j] }
    }
    for i:=n-p[j]+1;i>0;i-- {
      b[i] = (b[i]+b[i+p[j]-1])%p[j]
    }
    for i:=0;i<p[j];i++ {
      if i > n { break }
      if b[i] != 0 { continue Outer }
    }
    fmt.Println(p[j])
  }
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}
func gcd(x,y int) int {
  if x < y { return gcd(y,x) }
  if y == 0 { return x }
  return gcd(y,x%y)
}
func primes(n int) []int {
  m := make([]bool,n+1)
  for i:=2;i<n+1;i++ { m[i] = true }
  for i:=2;i<n+1;i++ {
    if !m[i] { continue }
    for j:=2*i;j<n+1;j+=i { m[j] = false }
  }
  p := []int{}
  for i:=0;i<n+1;i++ {
    if m[i] { p = append(p,i) }
  }
  return p
}
func factors(n int) []int {
  k := 0
  f := []int{}
  for {
    m := n
    for i:=k;i<len(x);i++ {
      if n%x[i] != 0 { continue }
      f = append(f,x[i])
      n /= x[i]
      k = i
      break
    }
    if n == 1 { break }
    if n == m { f = append(f,n);break }
  }
  return f
}

Measured memory_bytes: 7572
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    vector<ll> sum(N+1);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum[i+1] = (sum[i] + a[i]) % M;
    }

    map<ll, ll> mp;
    for (int i = 0; i < N+1; i++) mp[sum[i]]++;

    ll ans = 0;
    for (int i = 0; i < N; i++) ans += (mp[sum[i]]--) - 1;
    cout << ans << '\n';
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000
ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}

int main(){
   IOS;
//ll t;t=1;//cin>>t;
ll n;cin>>n;
ll dp[n+1];
for(ll i=0;i<=n;i++) dp[i]=0;
dp[0]=1;
dp[1]=0;
dp[2]=0;
for(ll i=3;i<=n;i++){
    for(ll j=0;j<i-2;j++){
        dp[i]=(dp[i]+dp[j])%mod;
    }
}
cout<<dp[n]%mod<<"\n";
return 0;    
}

Measured memory_bytes: 3664
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<pair<ll, ll>> a;
ll d;
map<ll, ll> mp;
ll dfs(ll n){
    if(mp.count(n))return mp[n];
    ll res = 1LL<<60;
    for(auto x : a){
        if(n % x.second == 0){
            res = min(res, dfs(n / x.second) + x.first);
        }else{
            res = min(res, dfs((n + (x.second - n % x.second))/x.second) + d * (x.second - n % x.second) + x.first);
            res = min(res, dfs((n +  - n % x.second)/x.second) + d * (n % x.second) + x.first);
        }
    }
    
    
    if((long double)n * (long double)d < res){
        res = n  * d;
    }
    return mp[n] = res;
}
int main(){
    int t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        a.clear();
        ll b[3];
        rep(i,3)cin >> b[i];
        a.emplace_back(b[0], 2);
        a.emplace_back(b[1], 3);
        a.emplace_back(b[2], 5);
        cin >> d;
        mp.clear();
        mp[0] = 0;
        mp[1] = d;
        cout << dfs(n) << endl;
    }
}


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

int main(){
  int N; cin >> N;
  string s,t; cin >> s >> t;
  string ans;
  for(int i=0; i<=N; i++){
    ans=s.substr(0,i)+t;
    if(ans.substr(0,N)==s&&ans.substr(i,N)==t){
      break;
    }
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse = True)

cnt = 0

for i in range(0, n-2):
    t = l[i]
    for b in range(i+1, n-1):
        s = l[b]
        if (t != s):
            for k in range(b+1, n):
                a = s + l[k]
                if(a > t and s != l[k]):
                    cnt += 1

print(cnt)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

int main(){
    ll k;
    cin >> k;
    queue<ll>q;
    for(ll i=1;i<10;i++){
        q.push(i);
    }
    queue<ll>ans;
    while(!q.empty()){
        ll now = q.front();q.pop();
        ans.push(now);
        if(ans.size()>1e6)break;
        int k = now%10;
        for(ll i=-1;i<=1;i++){
            if(k+i>=0&&k+i<=9){
                q.push(now*10+k+i);
            }
        }
    }
    rep(i,k-1){
        ans.pop();
    }
    ll res = ans.front();
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 24192
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int p[14][14] = {0};
  int x,y,size;
  char ten,tenten;
 back:;
  while( cin >> x >> ten >> y >> tenten >> size ){
    x += 2;
    y += 2;
    switch(size){
    case 3:
      p[x-2][y]++;
      p[x+2][y]++;
      p[x][y-2]++;
      p[x][y+2]++;
    case 2:
      p[x+1][y+1]++;
      p[x-1][y-1]++;
      p[x+1][y-1]++;
      p[x-1][y+1]++;
    case 1:
      p[x][y+1]++;
      p[x][y-1]++;
      p[x-1][y]++;
      p[x+1][y]++;
      p[x][y]++;
    }
  }
  
  int cnt = 0;
  int m = 0;
  for( int i = 2 ; i < 12 ; i++ ){
    for( int j = 2 ; j < 12 ; j++ ){
      if( p[i][j] == 0 ) cnt++;
      m = max( m , p[i][j] );
      //  cout << " " << p[i][j] << " ";
    }
    //cout << endl;
  }
  cout << cnt << endl << m << endl;
  return 0;
}

Measured memory_bytes: 1160
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

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


using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;

//#define int ll


const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[7][7],x;
bool mark[7][7];
main() {
  file("threesum");
  ios;
  fo(i,1,3,1) fo(j,1,3,1) cin>>a[i][j];
  int m;
  cin>>m;
  while (m--) {
    cin>>x;
    fo(i,1,3,1) fo(j,1,3,1) {
      if (a[i][j]==x) mark[i][j]=1;
    }
  }
  fo(i,1,3,1) fo(j,1,3,1) a[i][j]=mark[i][j];
  if (a[1][1]==a[1][2] and a[1][2]==a[1][3] and a[1][1]==1||
      a[2][1]==a[2][2] and a[2][2]==a[2][3] and a[2][1]==1||
      a[3][1]==a[3][2] and a[3][3]==a[3][2] and a[3][1]==1||
      a[1][1]==a[2][2] and a[2][2]==a[3][3] and a[1][1]==1||
      a[1][3]==a[2][2] and a[2][2]==a[3][1] and a[1][3]==1 ||
      mark[1][1] and mark[2][1] and mark[3][1] ||
      mark[1][2] and mark[2][2] and mark[3][2] ||
      mark[1][3] and mark[2][3] and mark[3][3]) cout<<"Yes";
        else cout<<"No";
  cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
  return 0;
}
/**

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

string to_six(string a) {
	if (a.length() < 6) {
		string tmp = "";
		for (int i = 0; i < 6 - a.length(); i++) {
			tmp += "0";
		}
		a = tmp + a;
	}
	return a;
}

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

	vector<vector<pair<int, int> > > cities(N); //cities[x].(y,z) 県x y年誕生のz市
	vector<string> ans(M);
	for (int i = 0; i < M; i++) {
		int P, Y;
		cin >> P >> Y;
		P--;
		cities[P].push_back(pair<int, int>(Y, i));
	}
	for (int i = 0; i < N; i++) {
		sort(cities[i].begin(), cities[i].end());
	}

	for (int i = 0; i < N; i++)for (int j = 0; j < cities[i].size(); j++) {
		ans[cities[i][j].second] = to_six(to_string(i+1)) + to_six(to_string(j+1));
	}

	for (int i = 0; i < M; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

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; }

using ll = long long;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> field(H,vector<char>(W));
  int cntw=0,cntb=0;
  rep(i,H) {
    rep(j,W){
      char c;
      cin>>c;
      if(c=='.')cntw++;
      if(c=='#')cntb++;
      field[i][j]=c;
    }
  }
  vector<vector<bool>> seen(H,vector<bool>(W,false));
  queue<pair<int,int>> bfs;
  vector<vector<int>> len(H,vector<int>(W,0));
  bfs.push(make_pair(0,0));
  seen[0][0]=true;
  while((int)bfs.size()!=0){
    auto xy = bfs.front();
    bfs.pop();
    seen[xy.first][xy.second]=true;
    rep(i,4){
      int nx=xy.first+dx[i];
      int ny=xy.second+dy[i];
      if(nx>=H||nx<0||ny>=W||ny<0) continue;
      if(field[nx][ny]=='#')continue;
      if(seen[nx][ny])continue;
      seen[nx][ny]=true;
      bfs.push(make_pair(nx,ny));
      len[nx][ny]=len[xy.first][xy.second]+1;
    }
  }
  if(!seen[H-1][W-1]) cout<<-1<<endl;
  else{
    cout<<H*W-len[H-1][W-1]-cntb-1<<endl;
  }
}
    
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define sharp 1
#define dot 0

int H;
int W;
int matrix[52][52] = {};

bool dfs(int now_y, int now_x){
    // 隣がいればfalse, いなければtrue
    for (int i = -1; i <= 1; i++){
        for (int j = -1; j <= 1; j++){
            if ((i + j) % 2 != 0){
                if (matrix[now_y + i][now_x + j] == sharp){
                    return false;
                }
            }
        }
    }
    return true;
}

bool is_solve(){
    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            if (matrix[i][j] == sharp){
                if (dfs(i, j)){
                    // 隣がいなかったとき
                    return false;
                }
            }
        }
    }
    return true;
}

int main(){
    cin >> H >> W;
    for (int i = 0; i <= H; i++){
        for (int j = 0; j <= W; j++){
            if ((i == 0) || (j == 0)){
                matrix[i][j] = 0;
            }else{
                char str;
                cin >> str;
                if (str == '#'){
                    matrix[i][j] = sharp;
                }else{
                    matrix[i][j] = dot;
                }
            }
        }
    }
    // for (int i = 0; i <= H + 1; i++){
    //     for (int j = 0; j <= W + 1; j++){
    //         cout << matrix[i][j]<< " ";
    //     }
    //     cout << endl;
    // }
    if (is_solve()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    // for (int i = 0; i <= H + 1; i++){
    //     for (int j = 0; j <= W + 1; j++){
    //         cout << matrix[i][j]<< " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
/*
Till the roof comes off, till the lights go out
Till my legs give out, canâ��t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>


#define ll long long
#define X real()
#define Y imag()
#define f first
#define s second
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define lngth(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)

using namespace std;

const int N=200005;
typedef pair<ll,int>ii;
typedef pair<ii,int>event;
typedef complex<double>point;
const double EPS = 1e-9;
const int INF=100000;

const double PI = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int n,m,a[N],d[N],c[N],mx[N],sol[N];
vector<int>adj[N];
bool v[N][12];
void bfs(int node,int dep,int col){
   if(mx[node]>dep)return;
   queue<int>q;
   q.push(node);
   q.push(dep);
   v[node][dep]=1;
  if(mx[node]==-1)
   sol[node]=col;
   mx[node]=dep;
   while(q.size()){
        node=q.front();
        q.pop();
        dep=q.front();
        q.pop();
        if(!dep)continue;
        for(int i=0;i<adj[node].size();i++){
            int to=adj[node][i];
            if(mx[to]>=dep-1)continue;
           if(mx[to]==-1)
            sol[to]=col;
            mx[to]=dep-1;
            q.push(to);
            q.push(dep-1);
        }
   }
}
int main()
{
    //freopen("test.in","r",stdin);
   //freopen("output.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(mx,-1,sizeof(mx));
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++)
        scanf("%d%d%d",&a[i],&d[i],&c[i]);
    memset(sol,0,sizeof(sol));
    for(int i=q-1;i>-1;i--){
        bfs(a[i],d[i],c[i]);
    }
    for(int i=1;i<=n;i++)cout<<sol[i]<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

double p[305][305][305], e[305][305][305];

int main()
{
	#ifdef DGC
		freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	
	vector<int> a(3);
	for (int i = 0, x; i < n; ++i)
	{
		cin >> x;
		++a[x-1];
	}

	p[a[0]][a[1]][a[2]] = 1;
	
	for (int k = n; k >= 0; --k)
		for (int j = n; j >= 0; --j)
			for (int i = n; i >= 0; --i)
				if (p[i][j][k] > 0)
				{
					double z = 1 - (double)(n-i-j-k) / n;
					double _z = 1 / z; // probability of move
					z = 1 / (z * z); // expected value of move

					if (i > 0)
					{
						e[i-1][j][k] += (e[i][j][k] * _z + p[i][j][k] * z) * i / n;
						p[i-1][j][k] += p[i][j][k] * _z * i / n;
					}
					if (j > 0)
					{
						e[i+1][j-1][k] += (e[i][j][k] * _z + p[i][j][k] * z) * j / n;
						p[i+1][j-1][k] += p[i][j][k] * _z * j / n;
					}
					if (k > 0)
					{
						e[i][j+1][k-1] += (e[i][j][k] * _z + p[i][j][k] * z) * k / n;
						p[i][j+1][k-1] += p[i][j][k] * _z * k / n;
					}
				}

	cout << setprecision(20) << fixed << e[0][0][0] << "\n";

	return 0;
}


Measured memory_bytes: 438528
h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0 for _ in range(checker+1)]

        for j in range(w):
            num = i
            p = 0
            nex = [0 for _ in range(checker+1)]
            for m in range(h):
                nex[p] += s[m][j]
                p += num%2
                num = num >> 1          
            if max(nex)>k:
                x = 10**5
                break

            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))

Measured memory_bytes: 50140
#include<iostream>
using namespace std;
int main(void){
    long long n,t,a,T=1LL,A=1LL,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>a;
        m=max((T+t-1LL)/t,(A+a-1LL)/a);
        T=t*m;A=a*m;
    }
    cout<<T+A<<endl;
    return 0;
}

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

using namespace std;

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

typedef long long lint;

const lint INF = 1e18 + 9LL;

struct edge {
    int A, B;
    lint C;
};

int N, M;
lint T;
lint dist[2509];

vector<edge> edges;

int main() {
    scanf("%d%d%lld", &N, &M, &T);
    rep(i, M) {
        int A, B;
        lint C;
        scanf("%d%d%lld", &A, &B, &C);
        edges.push_back({A, B, T - C});
    }
    rep(i, N) dist[i + 1] = INF;
    dist[1] = 0LL;
    rep(i, N - 1) {
        rep(j, M) {
            edge e = edges[j];
            if (dist[e.A] != INF && dist[e.B] > 1LL * dist[e.A] + 1LL * e.C) {
                dist[e.B] = 1LL * dist[e.A] + 1LL * e.C;
            }
        }
    }
    rep(i, N - 1) {
        rep(j, M) {
            edge e = edges[j];
            if (dist[e.A] != INF && dist[e.B] > dist[e.A] + e.C) {
                dist[e.B] = -INF;
            }
        }
    }
    if (dist[N] == -INF) printf("-1\n");
    else printf("%lld\n", max(0LL, -dist[N]));
}


Measured memory_bytes: 512