akhauriyash/Code-Regression huggingface dataset:
package main

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

func solve() {
	n := getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		d := getInt()
		m[d]++

		switch i {
		case 0:
			if d != 0 {
				fmt.Fprintln(wr, 0)
				return
			}
		default:
			if d == 0 {
				fmt.Fprintln(wr, 0)
				return
			}
		}
	}

	s := make([]int, n)
	for k, v := range m {
		s[k] = v
	}

	ans := 1
	for i := 1; i < n; i++ {
		if s[i] > 0 && s[i-1] == 0 {
			ans = 0
			break
		}

		ans = (ans * pow(s[i-1], s[i])) % mod
	}
	fmt.Fprintln(wr, ans)
}

func pow(a, b int) int {
	ret := 1
	for i := 0; i < b; i++ {
		ret = (ret * a) % mod
	}
	return ret
}

// -----------------------------------------

const (
	inf = 1 << 60
	mod = 998244353
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,s,t=0;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			s=a[i-1]-a[i];
			t=t+s;
			a[i]=a[i]+s;
		}
	}
	cout<<t;
} 

Measured memory_bytes: 5112
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque


def bfs(s, flag):
    if flag:
        global check
    else:
        check = [-1] * (n + 1)
    cnt = 0
    ans = 0
    q = deque([s, cnt])
    while q:
        now = q.popleft()
        cnt = q.popleft()
        check[now] = cnt
        ans += 1
        for next in graph[now]:
            if flag:
                if check[next] > cnt + 1:
                    q.append(next)
                    q.append(cnt + 1)
            else:
                if check[next] == -1:
                    q.append(next)
                    q.append(cnt + 1)
    if flag:
        return ans
    else:
        return check


n = int(readline())
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)
check = bfs(1, False)
print('Snuke' if bfs(n, True) >= n / 2 else 'Fennec')


Measured memory_bytes: 25340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200200],prefix[200200],suffix[200200],ans,temp,n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    prefix[0]=arr[0];
    for(int i=1;i<n;i++)
        prefix[i]=prefix[i-1]+arr[i];
    suffix[n-1]=arr[n-1];
    for(int i=n-2;i>=0;i--)
        suffix[i]=suffix[i+1]+arr[i];
    ans=9999999999;
    for(int i=0;i<n-1;i++)
    {
        //cout<<prefix[i]<<" "<<suffix[i+1]<<endl;
        ans=min(ans,abs(prefix[i]-suffix[i+1]));
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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

  string S;
  cin >>S;
  
  reverse(All(S));

  vi count(2019,0);
  constexpr li mod = 2019;
  li b = 1,num,sum=0;
  for(auto&& s:S){
  	num = s-'0';
  	sum += num * b % mod;
  	sum %= mod;

  	count[sum] ++;
  	b *= 10;
  	b %= mod;
  }
  count[0]++;

  li ans =0;
  for(auto&& c:count){
  	ans += c*(c-1)/2;
  }

  cout <<ans;

}

Measured memory_bytes: 3808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	h := nextInt()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += a[i]
	}

	if h > sum {
		fmt.Printf("No")
	} else {
		fmt.Printf("Yes")
	}
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdint>
using namespace std;

const uint64_t kP = 1000000007;

uint64_t mmul(uint64_t a, uint64_t b, uint64_t p) {
  return ((a % p) * (b % p)) % p;
}

uint64_t mpow(uint64_t a, uint64_t e, uint64_t p) {
  uint64_t ret = 1;
  uint64_t m = a % p;
  while (e) {
    if (e & 1) {
      ret = (ret * m) % p;
    }
    m = (m * m) % p;
    e >>= 1;
  }
  return ret;
}

uint64_t mdiv(uint64_t a, uint64_t b, uint64_t p) {
  return ((a % p) * mpow(b % p, p - 2, p)) % p;
}

const uint64_t MAX = 100000;

int main()
{
  uint64_t n, m;
  cin >> n >> m;
  uint64_t x[MAX];
  uint64_t y[MAX];
  for (uint64_t i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (uint64_t i = 0; i < m; ++i) {
    cin >> y[i];
  }
  uint64_t xx = 0;
  uint64_t yy = 0;
  for (uint64_t i = 0; i < n - 1; ++i) {
    uint64_t comb = mmul(i + 1, n - i - 1, kP);
    xx = (xx + mmul(comb, (uint64_t)(x[i+1] - x[i]), kP)) % kP;
  }
  for (uint64_t i = 0; i < m - 1; ++i) {
    uint64_t comb = mmul(i + 1, m - i - 1, kP);
    yy = (yy + mmul(comb, (uint64_t)(y[i+1] - y[i]), kP)) % kP;
  }

  cout << (xx * yy) % kP << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
ll n;
vector<string> ans;
void dfs(string s,char mx){
    if(s.size()==n){
        ans.pb(s);
        return ;
    }
    for(char c='a';c<=mx;c++){
        dfs(s+c,(c==mx)?(char)(mx+1):mx);
    }
}

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

cin>>n;
dfs("",'a');

sort(ans.begin(),ans.end());
rep(i,ans.size()){
    cout<<ans[i]<<endl;
}
// system("pause");
return 0;
}

Measured memory_bytes: 7796
import sys
from itertools import permutations

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    D = [[0] * (C + 1)]
    for _ in range(C):
        d = [0] + list(map(int, input().split()))
        D.append(d)

    grid = [[0] * (N + 1)]
    for _ in range(N):
        g = [0] + list(map(int, input().split()))
        grid.append(g)

    cost = {0: [], 1: [], 2: []}
    ans = INF
    for c in range(1, C + 1):
        cost0 = 0
        cost1 = 0
        cost2 = 0
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                if (i + j) % 3 == 0:
                    cost0 += D[grid[i][j]][c]
                elif (i + j) % 3 == 1:
                    cost1 += D[grid[i][j]][c]
                elif (i + j) % 3 == 2:
                    cost2 += D[grid[i][j]][c]

        cost[0].append((c, cost0))
        cost[1].append((c, cost1))
        cost[2].append((c, cost2))

    cost[0].sort(key=lambda x: x[1])
    cost[1].sort(key=lambda x: x[1])
    cost[2].sort(key=lambda x: x[1])

    ans = INF
    for c0, cost0 in cost[0][:3]:
        for c1, cost1 in cost[1][:3]:
            for c2, cost2 in cost[2][:3]:
                if c0 == c1 or c1 == c2 or c2 == c0:
                    continue

                tmp = cost0 + cost1 + cost2
                if tmp < ans:
                    ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44892
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice();
		int n = sc.nextInt();

		for (int i = 0; i < 6; i++) {
			dice.dc[i] = sc.nextInt();
		}

		for (int i = 0; i < n - 1; i++) {
			for (int j = 0; j < 6; j++) {
				dice.dc2[j] = sc.nextInt();
			}
			dice.check();
		}
		System.out.println(dice.result);
	}

}

class Dice {
	public int[] dc = new int[6];
	public int[] dc2 = new int[6];
	private int temp = 0;
	public String result = "Yes";

	void north() {
		temp = dc[0];
		dc[0] = dc[1];
		dc[1] = dc[5];
		dc[5] = dc[4];
		dc[4] = temp;
	}

	void south() {
		temp = dc[0];
		dc[0] = dc[4];
		dc[4] = dc[5];
		dc[5] = dc[1];
		dc[1] = temp;
	}

	void west() {
		temp = dc[0];
		dc[0] = dc[2];
		dc[2] = dc[5];
		dc[5] = dc[3];
		dc[3] = temp;
	}

	void east() {
		temp = dc[0];
		dc[0] = dc[3];
		dc[3] = dc[5];
		dc[5] = dc[2];
		dc[2] = temp;
	}

	void right() {
		temp = dc[1];
		dc[1] = dc[2];
		dc[2] = dc[4];
		dc[4] = dc[3];
		dc[3] = temp;
	}

	void check() {
		for (int i = 0; i <= 3; i++) {
			if (checkAll()) {
				break;
			}
			north();
			for (int j = 0; j <= 3; j++) {
				if (checkAll()) {
					break;
				}
				right();
			}
		}
		for (int j = 0; j <= 3; j++) {
			if (checkAll()) {
				break;
			}
			west();
			for (int i = 0; i <= 3; i++) {
				if (checkAll()) {
					break;
				}
				right();
			}
		}
		if (Arrays.equals(dc, dc2)) {
			result = "No";
		}
	}

	boolean checkAll() {
		if (dc[0] == dc2[0] && dc[1] == dc2[1] && dc[2] == dc2[2] &&
				dc[3] == dc2[3] && dc[4] == dc2[4] && dc[5] == dc2[5]) {
			return true;
		}
		return false;
	}
}



Measured memory_bytes: 28140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    set<int> s;
    bool answer = false;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        s.insert(a.at(i));
    }
    sort(a.begin(), a.end());
    if (s.size() == 3) {
        auto itr = s.begin();
        int x = *itr;
        int first_count = count(a.begin(), a.end(), *itr);
        itr++;
        int y = *itr;
        int second_count = count(a.begin(), a.end(), *itr);
        itr++;
        int z = *itr;
        int third_count = count(a.begin(), a.end(), *itr);
        if (first_count == second_count && second_count == third_count && z == (x^y)) {
            answer = true;
        }
        // print(x);
        // print(y);
        // print(x^y);
    }
    if (s.size() == 2) {
        auto itr = s.begin();
        int x = *itr;
        int first_count = count(a.begin(), a.end(), *itr);
        itr++;
        int y = *itr;
        int second_count = count(a.begin(), a.end(), *itr);
        // itr++;
        // int z = *itr;
        // int third_count = count(a.begin(), a.end(), *itr);
        if (second_count == first_count * 2 && x == 0) {
            answer = true;
        }
    }
    if (s.size() == 1) {
        auto itr = s.begin();
        int x = *itr;
        int first_count = count(a.begin(), a.end(), *itr);
        // itr++;
        // int y = *itr;
        // int second_count = count(a.begin(), a.end(), *itr);
        // itr++;
        // int z = *itr;
        // int third_count = count(a.begin(), a.end(), *itr);
        if (x == 0) {
            answer = true;
        }
    }
    if (answer) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n;
vi g[MAX_N];
int c[MAX_N];
queue<int> q;
int ans[MAX_N];

ll dfs(int u, int p) {
  ll res = 0;
  for (int v : g[u]) {
    if (v == p) continue;
    res += dfs(v,u);
    res += ans[v];
  }
  ans[u] = q.front();
  q.pop();
  return res;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n-1) {
    int a,b; cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  forn(i,n) cin >> c[i];

  sort(c,c+n);

  forn(i,n) {
    q.push(c[i]);
  }

  printf("%lld\n",dfs(0,-1));
  forn(i,n)
    printf("%d%c",ans[i], " \n"[i+1==n]);

  return 0;
}


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

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    for i in 0..n {
        print!("{}{}", s[i], t[i]);
    }
    println!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main() {
    int N;
    cin>>N;
    vector<long> A(N);
    vector<long> B(N);
    vector<long> C(N);
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    for(int i=0;i<N;++i){
        cin>>B[i];
    }
    for(int i=0;i<N;++i){
        cin>>C[i];
    }
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    long ans = 0;
    long la, ra, ma;
    long lc, rc, mc;
    long b;
    for(int i=0;i<N;++i){
        b = B[i];
        la = 0;
        ra = N-1;
        while(la < ra){
            ma = (la + ra)/2;
            if(b <= A[ma]) {
                ra = ma;
            }
            else {
                la = ma + 1;
            }
        }
        if(b<=A[la]) la--;
        if((la<0) | (N<=la))continue;
        lc = 0;
        rc = N-1;
        while(lc < rc){
            mc = (lc + rc)/2;
            if(b < C[mc]) {
                rc = mc;
            }
            else {
                lc = mc + 1;
            }
        }
        if(C[lc]<=b) lc++;
        if((lc<0) | (N<=lc))continue;
        ans += (N - lc) * (la + 1);
    }
    cout<<ans<<endl;
}


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

#define mod 1000000007

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long int
#define vi vector<int>
#define vli vector<long int>
#define vlli vector<long long int >
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define frr(i,a,b) for(i=a;i<b;i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define fbb(i,a,b) for(i=a;i>b;i--)

#define pr_vec(i,a,b,v) for(i=a;i<b;i++) cout<<v[i]<<" ";
#define in_arr(i,n,v) for(i=0;i<n;i++) cin>>v[i];
int gcd(int a,int b){
    if(a<b) swap(a,b);
    if(b==0) return a;
   
    else return gcd(a%b,b);
 }
 bool f1( pair<pair<string,int>,int> p1, pair<pair<string,int >,int> p2){
         if(p1.ft.ft==p2.ft.ft) return p1.ft.sd>p2.ft.sd;
         else return p1<p2;
 }
 
int main()
{
    ll n,i,j;
    cin>>n;
    ll temp=n;
    vector<string> v;
    vector<int> y;
    vector<pair<pair<string,int>,int >>b;
    frr(i,0,n){
      ll x;
      string r;
      cin>>r;
      cin>>x;
       b.pb(mp(mp(r,x),i+1));
    }
    sort(b.begin(),b.end(),f1);
    
    frr(i,0,n){
      cout<<b[i].sd<<endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int maxs = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

typedef long long ll;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

ll fact[maxs];
ll ifact[maxs];

void pre(){

    fact[0] = ifact[0] = 1;
    for(int i=1;i<maxs;i++){
        fact[i] = (fact[i-1]*i)%mod;
        ifact[i] = inv(fact[i]);
    }

}

ll ncr(ll n,ll r){
    ll tmp = (fact[n]*ifact[r])%mod;
    tmp = (tmp*ifact[n-r])%mod;
    return tmp;
}

void solve(){

    ll n;
    cin >> n;
    if(n==1){
        cout << 0;
        return;
    }
    ll ans=0;
    for(int i=2;i<=n;i++){
        ll tmp = ncr(n,i);
        ll tmp2 = (tmp*(fast(2,i) - 2))%mod;
        ll rem = n-i;
        ll rem2 = fast(8,rem);
        ans += (tmp2*rem2)%mod;
        ans %= mod; 
    }
    cout << ans;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    pre();
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

int cnt_digit(ll N)
{
    int digit = 0;
    while (N > 0)
    {
        digit++;
        N /= 10;
    }

    return digit;
}

void solve(long long N)
{
    int ans = cnt_digit(N);

    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            ll B = N / i;

            int cur = max(cnt_digit(i),cnt_digit(B));

            ans = min(ans,cur);
        }
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
struct bfs{
    int n;
    int l;
};
int main(){
    int n,a,m,temp,ans[101];
    bool graph[101][101];
    bfs t,b;
    queue<bfs> q;
    scanf("%d",&n);
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            graph[i][j]=false;
        }
        ans[i]=-1;
    }
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&m);
        for(int j=0;j<m;j++){
            scanf("%d",&temp);
            graph[a][temp]=true;
        }
    }
    t.n=1;
    t.l=0;
    q.push(t);
    while(!q.empty()){
        t=q.front();
        q.pop();
        if(ans[t.n]==-1)ans[t.n]=t.l;
        else continue;
        t.l++;
        b=t;
        for(int i=1;i<=n;i++){
            if(graph[t.n][i]){
                b.n=i;
                q.push(b);
            }
        }
    }
    for(int i=1;i<=n;i++){
        printf("%d %d\n",i,ans[i]);
    }
}

Measured memory_bytes: 2748
s = input()
k = int(input())
n = len(s)
dp = [[[0] * (k + 1) for i in range(2)] for i in range(n + 1)]
dp[0][0][0] = 1

# dp[i][j][k] i:桁数 j:smallフラグ 1はsmall確定、0はsと同じ値 k:ゼロ以外の数字を使った回数
for i in range(n):
    for j in range(2):
        for l in range(k + 1): #lはK+1(つまりk)までの範囲にしても問題なし。下でl<kするから
            c = int(s[i])
            if j == 1:  # small確定の場合
                dp[i + 1][j][l] += dp[i][j][l]  # 0
                if l < k:  # まだ使えるなら、   ※比較する変数注意！
                    dp[i + 1][j][l + 1] += dp[i][j][l] * 9  # 1~9を使う
            else:  # j==0のとき
                if c == 0:
                    # cが0のときは0しか選べなく、small確定できない
                    dp[i + 1][0][l] += dp[i][j][l]
                else:
                    dp[i + 1][1][l] += dp[i][j][l]  # Cより小さい0を使う→small確定
                    if l < k: #※比較する変数注意！
                        dp[i + 1][1][l + 1] += dp[i][j][l] * \
                            (c - 1)  # c以外の数字を使う、small確定
                        dp[i + 1][0][l + 1] += dp[i][j][l]  # cを使う、small確定できない
print(dp[n][1][k]+dp[n][0][k])


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/
/****** define variable start ******/
string s;
/******* define variable end *******/
ll solve() {
	cin >> s;
	if(s.substr(2, 1) == s.substr(3, 1) && s.substr(4, 1) == s.substr(5, 1)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return (int)end_solve;
}


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

int main(void)
{
	ll n,i;
	cin>>n;
	ll H[n];
	for(i=0;i<n;i++)
	cin>>H[i];
	
	vector <ll> dp(n,0);

	dp[0]=0;
	dp[1]=abs(H[0]-H[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
	}
	
	
	
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll n, k;
    cin >> n >> k;
    ll g[n];
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        g[i] = a - 1;
    }
    int idx = 0, s = 0, t = 0, cnt = 0;
    vector<ll> v;
    bool nums[n + 1] = {};
    while (1) {
        if (cnt > 0 && nums[idx]) {
            for (int i = 0; i < n; i++) {
                if (idx == v[i]) {
                    s = i;
                    break;
                }
            }
            t = v.size() - 1;
            break;
        }
        v.push_back(idx);
        nums[idx] = true;
        idx = g[idx];
        cnt++;
    }
    if (k < s) {
        cout << v[k] + 1 << endl;
    } else {
        k -= s;
        k %= (t - s + 1);
        cout << v[s + k] + 1 << endl;
    }
}

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

const int N = 2e5 + 5;
typedef long long ll;

ll n, a[N], sum[N], ans = 1LL << 62;

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

Measured memory_bytes: 3328
#include <stdio.h>

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}node;

main(){
  int i,g;
  node N[250];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&N[i].key);
    N[i].parent = 0;
    N[i].left = 0;
    N[i].right = 0;
  }
  for(i=1;i<=g;i++){
    if(i>1)N[i-1].parent = N[i/2-1].key;
    if((i*2)<=g)N[i-1].left = N[i*2-1].key;
    if((i*2+1)<=g)N[i-1].right = N[i*2].key;
  }

  for(i=0;i<g;i++){
    printf("node %d: key = %d, ",i+1,N[i].key);
    if(N[i].parent!=0)printf("parent key = %d, ",N[i].parent);
    if(N[i].left!=0)printf("left key = %d, ",N[i].left);
    if(N[i].right!=0)printf("right key = %d, ",N[i].right);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	LL a,b;
	scanf("%lld %lld",&a,&b);
	LL x,y;
	double c;
	c=(double)a/(double)b;
	x=a/b;
	y=a%b;
	printf("%lld %lld %.8lf\n",x,y,c);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n;
string s;
bool isSubsequence(string &t, int i, int j) {
    if (j == 3) return true;
    if (i == n) return false;
    if (s[i] == t[j]) {
        return isSubsequence(t, i + 1, j + 1);
    } else {
        return isSubsequence(t, i + 1, j);
    }
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    cin >> n >> s;
    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                string t = "";
                t += i + '0';
                t += j + '0';
                t += k + '0';
                //cout << t << endl;
                if (isSubsequence(t, 0, 0)) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 100000;
int c,n;
int main()
{
    scanf("%d",&c);
    scanf("%d",&n);
    printf("%d\n",n*2-c);
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
list = list(map(int, input().split()))

list.sort(reverse=True)
all = 0
for j in list:
    all += j

max = all/(M*4)
result = True

for i in range(M):
    if list[i] < max:
        result = False

if result == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    char x,y;
    cin>>x>>y;
    if(x>y) cout<<">"<<endl;
    else if(x<y) cout<<"<"<<endl;
    else  cout<<"="<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n = 0, i = 0, sum = 0, result = 0;
    int *p = NULL;
    scanf("%d", &n);
    p = (int)calloc(n, sizeof(int));
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }
    for (i = 0; i < n; i++)
    {
        sum += p[i];
    }
    for (i = 0; i < n; i++)
    {
        sum -= p[i];
        result += p[i] * sum;
    }
    printf("%d", result);
}

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

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 
# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define UB upper_bound 

const int MAXN = 1e5 + 10;
int a[MAXN];
bool b[MAXN];

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, m;
	cin >> n >> m;
	fill(a, a + n, 1);
	b[0] = 1;
	while (m --)
	{
		int x, y;
		cin >> x >> y;
		x --, y --;
		a[x] --, a[y] ++;
		b[y] |= b[x];
		b[x] &= (bool)a[x];
	}

	int ans = 0;
	for (int i = 0; i < n; i ++)
		ans += b[i];
	cout << ans << endl;

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	priority_queue<ll, vector<ll>, greater<ll>>d,t;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		d.push(x);
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		ll x;
		cin >> x;
		t.push(x);
	}
	while (t.size() >= 1) {
		if (d.top() < t.top())d.pop();
		else if (d.top() == t.top()) {
			d.pop();
			t.pop();
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;

}

Measured memory_bytes: 4848
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    { 
        static List<int> TopologicalSort(int N, List<int>[] g, int[] into)
        {
            List<int> L = new List<int>();
            Stack<int> st = new Stack<int>();

            for(int i = 1; i <= N; i++)
            {
                if(into[i] == 0)
                {
                    st.Push(i);
                }
            }

            while (st.Count != 0)
            {
                int from = st.Pop();
                L.Add(from);
                foreach (int to in g[from])
                {
                    into[to]--;
                    if (into[to] == 0)
                    {
                        st.Push(to);
                    }
                }

            }
            
            return L;
        }


        static int Solve(int N, List<int>[] g, int[] into)
        {
            List<int> L = TopologicalSort(N, g, into);
            int[] dp = new int[N + 1];

            int max_length = 0;

            foreach(var from in L)
            {
                foreach(var to in g[from])
                {
                    dp[to] = Math.Max(dp[to], dp[from] + 1);
                    max_length = Math.Max(max_length, dp[to]);
                }
            }

            return max_length;
        }
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            List<int>[] g = new List<int>[N + 1];
            int[] into = new int[N + 1];

            for(int i = 1; i <= N; i++)
            {
                g[i] = new List<int>();
            }
            
            for(int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]);
                g[x].Add(y);
                into[y]++;
            }

            Console.WriteLine(Solve(N, g, into));
        }
    }
}

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; --i) {
        if (a % i == 0 && b % i == 0) {
            --k;
            if (k == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
    assert(false);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
int r[3];
int vis[3];
int rec(int n,int depth){
    if (depth == 3){
        if (n % 4 == 0 )return 1;
        else return 0;
    }
    for (int i = 0;i < 3;i++){
        if (vis[i]) continue;
        vis[i] = 1;
        if (rec(n * 10 + r[i],depth + 1)) return 1;
        vis[i] = 0;
    }
    return 0;
}
int main(){

    cin >> r[0] >> r[1] >> r[2];
    if ((r[0] * 100 + r[1] * 10 + r[2]) % 4 ==0 ){
        cout << "YES\n";
    } else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

class DisjointSet {
  public:
    vector<ll> rank, p;

    DisjointSet() {}
    DisjointSet(ll size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      rep(i, size) makeSet(i);
    }

    void makeSet(ll x) {
      p[x] = x;
      rank[x] = 0;
    }

    bool same(ll x, ll y) {
      return find_set(x) == find_set(y);
    }

    void unite(ll x, ll y) {
      link(find_set(x), find_set(y));
    }

    void link(ll x, ll y) {
      if (rank[x] > rank[y]) {
        p[y] = x;
      } else {
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
    }

    ll find_set(ll x) {
      if (x != p[x]) {
        p[x] = find_set(p[x]);
      }
      return p[x];
    }
};

void solve() {
  ll n, q; cin >> n >> q;
  
  DisjointSet ds = DisjointSet(n);

  rep(i, q) {
    ll c, x, y; cin >> c >> x >> y;
    if (c == 0) ds.unite(x, y);
    else outl(ds.same(x, y));
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18 + 5;

int n, k;
ll ans = INF;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<pair<ll, ll>> a(n);
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        x[i] = a[i].first, y[i] = a[i].second;
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = (x[n - 1] - x[0]) * (y[n - 1] - y[0]);

    for (int xi = 0; xi < n; xi++) {
        for (int xj = xi + 1; xj < n; xj++) {
            for (int yi = 0; yi < n; yi++) {
                for (int yj = 0; yj < n; yj++) {
                    int num = 0;
                    ll lx = x[xi], rx = x[xj];
                    ll by = y[yi], uy = y[yj];

                    for (int i = 0; i < n; i++) {
                        if (a[i].first >= lx && a[i].first <= rx && a[i].second >= by && a[i].second <= uy) num++;
                    }

                    if (num >= k) {
                        ans = min(ans, (rx - lx) * (uy - by));
                    }
                }
            }
        }
    }
    
    cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 0; i < (ll)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    ll n, k;
    cin >> n >> k;

    n = n % k;

    if(k == 1) cout << 0 << endl;
    else if(abs(k - n) < k/2) cout << abs(k - n) << endl;
    else cout << n << endl;
 
    return 0;
}

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

using namespace std;

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

int main(void){
    int n;
    cin >> n;
    vector<int> m;
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        m.push_back(k);
    }
    int length = m.size();
    while(length != 1){
        m.push_back(gcd(m[0],m[1]));
        m.erase(m.begin());
        m.erase(m.begin());
        length--;
    }
    cout << m[0] << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main() {
	cin>>s1>>s2;
	for(int i=0; i<min(s1.size(),s2.size()); i++) 
		putchar(s1[i]),putchar(s2[i]);
	for(int i=min(s1.size(),s2.size()); i<max(s1.size(),s2.size()); i++) 
		putchar(s1.size()>s2.size()?s1[i]:s2[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#include<set>
#include<cstdio>

const long long int MOD=1e9+7;

using namespace std;

int main(){
    double n, a[109];
    cin >> n;
    for(int i=0;i<n;i++){
        double tmp;
        cin >> tmp;
        a[i] = 1.0/tmp;
    }
    double sm=0.0;
    for(int i=0;i<n;i++){
        sm+=a[i];
    }
    printf("%.6f\n", 1.0/sm);
}



Measured memory_bytes: 256
using System;

namespace AtCoder.BeginnersSelections
{
    class Test
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            str = str.Replace(" ", "");
            int rgb = int.Parse(str);

            if (rgb % 4 == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Split(' ');
		int a = int.Parse(line[0]);
		int b = int.Parse(line[1]);

		if((a*b)%2 == 0){
			Console.WriteLine("Even");
		} else {
			Console.WriteLine("Odd");
		}
	}                                                                                                                                                                       
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>

#include<iostream>
#include<queue>


using namespace std ;


#define y .first
#define x .second


pair< int ,int > p ,cpy ;


char route[ 1000 ][ 1000 + 1 ] ;

int came[ 1000 ][ 1000 ] ;


bool check( pair< int ,int > now,int h,int w ) ;

#define size sizeof came


int mx[] = { 1 ,0 ,0 ,-1 } ;
int my[] = { 0 ,1 ,-1 ,0 } ;


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

	char end = '0' + n ,cheese = '1' ;

	scanf( "%c" ,&route[ 0 ][ 0 ] ) ;

	int i ,j ;
	for( i = 0 ; i < h ; ++i )
	{
		for( j = 0 ; j <= w ; ++j )
		{
			scanf( "%c" ,&route[ i ][ j ] ) ;

			if( route[ i ][ j ] == 'S' )
			{
				p y = i ;
				p x = j ;
			}
		}
	}

	int ans = 0 ;
	
	do
	{
		queue< pair< int ,int > > que ;

		memset( came ,0 ,size ) ;

		while( route[ p y ][ p x ] != cheese )
		{
			int i ;
			for( i = 0 ; i < 4 ; ++i )
			{
				cpy y = p y + my[ i ] ;
				cpy x = p x + mx[ i ] ;

				if( route[ cpy y ][ cpy x ] != 'X' && check( cpy ,h ,w ) == true )
				{
					came[ cpy y ][ cpy x ] = came[ p y ][ p x ] + 1 ;

					que.push( cpy ) ;
				}
			}

			came[ p y ][ p x ] = 1 ;

			p = que.front() ;

			que.pop() ;
		}

		++cheese ;

		ans += came[ p y ][ p x ] ;

	}while( cheese <= end ) ;

	printf( "%d\n" ,ans ) ;


	return 0 ;
}


bool check( pair< int ,int > now ,int h ,int w )
{
	if( now y >= h || now x >= w || now y < 0 || now x < 0 )
		return false ;

	else if( came[ now y ][ now x ] > 0 )
		return false ;

	return true ;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    int64_t n_r = 0, n_g = 0, n_b = 0;
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == 'R')
        {
            n_r++;
        }
        if (s.at(i) == 'G')
        {
            n_g++;
        }
        if (s.at(i) == 'B')
        {
            n_b++;
        }
    }

    int64_t res = n_r * n_g * n_b;
    for (int skip = 0; skip <= n / 2; skip++)
    {
        for (int i = 0; i < n; i++)
        {
            int j = i + skip;
            int k = j + skip;
            if (k >= n)
            {
                break;
            }
            if (s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i))
            {
                res--;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{

    lint s;

    scanf("%lld", &s);

    lint thr = 1e9;

    if (s <= thr)
    {
        printf("%lld %lld %lld %lld %lld %lld", 0ll, 0ll, s, 0ll, 0ll, 1ll);
    }
    else
    {
        lint bc = (thr - s % thr) % thr;
        lint a = thr;
        lint d = (s + bc) / thr;
        lint b = 1;
        lint c = bc;
        printf("%lld %lld %lld %lld %lld %lld\n", 0ll, 0ll, a, b, c, d);
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			if(a >= h && b >= w) yono++;
		}
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 30840
#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)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

string s; cin >> s;
int n = s.size();
string ans;
for(int i=0; i<n; i++) {
if(s[i] == 'B'){if(!ans.empty()) ans = ans.substr(0, ans.size() - 1);}
else ans += s[i];
}cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool check(string s){
    rep(i,s.size()-1){
        if(s[i+1]!='9'){
            return false;
        }
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    if(s.size() == 1){
        cout << s[0] << endl;
    }
    else if(check(s)){
        cout << (s.size()-1)*9 + s[0] - '0' << endl;
    }
    else{
        cout << (s.size()-1)*9 + s[0] - '0' - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    string T;
    cin >> S >> T;
    int len_S = S.size();
    int len_T = T.size();
    vector<string> ans(0);
    rep(i,len_S - len_T + 1){
        int count = 0;
        rep(j,len_T){
            if (S[i + j] == T[j] || S[i + j] == '?'){
                count++;
            }
        }
        if (count == len_T){
            string ans_sub = "";
            rep(j,len_S){
                if (i <= j && j < i + len_T){
                    ans_sub += T.substr(j - i, 1);
                }
                else{
                    if (S[j] == '?') ans_sub += "a";
                    else ans_sub += S.substr(j,1);
                }
            }
            ans.push_back(ans_sub);
        }
    }
    sort(all(ans));
    if (ans.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << ans[0] << endl;
}


Measured memory_bytes: 256