akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,k,next[N];
char s[N];
long long l,r,ans[256];

void solve(long long m,long long t){
	if (m<=n){
		for (int i=1;i<=m;i++) ans[s[i]]+=t;
		return;
	}
	long long a0=1,b0=0,a1=1,b1=1;
	while (a1*k+b1*(n-k)<=m){
		a1+=a0;a0=a1-a0;
		b1+=b0;b0=b1-b0;
	}
	for (int i=1;i<=k;i++) ans[s[i]]+=t*a0;
	for (int i=k+1;i<=n;i++) ans[s[i]]+=t*b0;
	solve(m-a0*k-b0*(n-k),t);
}

long long read(){
	long long x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	scanf(" %s",s+1);n=strlen(s+1)/2;
	l=read();r=read();
	for (int i=2,j=0;i<=n;i++){
		while (j&&s[i]!=s[j+1]) j=next[j];
		next[i]=(j+=(s[i]==s[j+1]));
	}
	k=n-next[n];solve(l-1,-1);solve(r,1);
	for (int i='a';i<='z';i++)
		printf((i!='z')?"%lld ":"%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1404
#include <cstdio>
#include <algorithm>
bool map[25][25];
int n, m;

int qx[1000], qy[1000], h = 0, t = 0;
int ds[25][25];

void push(int x, int y, int d)
{
	qx[t] = x, qy[t] = y;
	ds[x][y] = d;
	t++;
}

int dis(int a, int b, int c, int d)
{
	for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) ds[i][j] = -1;
	h = t = 0;
	qx[t] = a, qy[t] = b, t++, ds[a][b] = 0;
	while (true)
	{
		int x = qx[h], y = qy[h]; h++;
		if (x <= 0 || x > n || y <= 0 || y > m) continue;
		if (!map[x][y]) continue;
		if (x == c && y == d) return ds[c][d];
		if (ds[x-1][y] == -1) push(x-1, y, ds[x][y]+1);
		if (ds[x+1][y] == -1) push(x+1, y, ds[x][y]+1);
		if (ds[x][y-1] == -1) push(x, y-1, ds[x][y]+1);
		if (ds[x][y+1] == -1) push(x, y+1, ds[x][y]+1);
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { char c = '\0'; while (c != '.' && c != '#') c = getchar(); map[i][j] = c=='.'; }
	int ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			for (int x = 1; x <= n; x++)
				for (int y = 1; y <= m; y++)
				{
					if (!map[i][j] || !map[x][y] || (i == x && j == y)) continue;
					ans = std::max(ans, dis(i, j, x, y));
				}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

for _ in range(N):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(room[i][j][k]), end="")
        print()
    if i!=3:
        print("####################")


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i,a[n],s=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
	}
	sort(a,a+n);
	if(s%10==0)
	{
		for(i=0;i<n;i++)
		{
			s=s-a[i];
			if(s%10!=0)
			{
				cout<<s<<endl;
				return 0;
			}
			else
			{
				s=s+a[i];
			}
		}
	}
	else
	{
		cout<<s<<endl;
		return 0;
	}
	cout<<0<<endl;
	
	
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int N,X,Y;
	cin >> N >> X >> Y;
	--X;--Y;
	vector<int>ans(N);
	REP(i,N){
		FOR(j,i + 1,N){
			int t = j - i;
			CHMIN(t,1 + abs(j - X) + abs(i - Y));
			CHMIN(t,1 + abs(j - Y) + abs(i - X));
			++ans[t];
		}
	}
	REP(i,N)if(i)out(ans[i]);
}

Measured memory_bytes: 256
def main(n,x):
    ret=1
    mod=10**9+7
    stc=[]
    for y in x:
        if 2*(len(stc)+1)-1<=y:
            stc.append(y)
        else:
            ret*=len(stc)+1
            ret%=mod
    for i in range(len(stc)):
        ret*=i+1
        ret%=mod
    return ret

n=int(input())
#a=list(input())
#a=list(map(int,input().split()))
#b=list(map(int,input().split()))
#ab=[list(map(int,input().split())) for _ in range(n)]
#n,k,q=map(int,input().split())
x=list(map(int,input().split()))
print(main(n,x))


Measured memory_bytes: 90788
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int h,w; cin>>h>>w;
    char a[h][w];
    long long int dp[h][w];
 
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
           cin>>a[i][j];
        }
    }
 
 
   for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#')dp[i][j]=0;
            else if(i==0&&j==0)dp[i][j]=1;
            else if(i==0)dp[i][j]=dp[i][j-1]%1000000007;
            else if(j==0)dp[i][j]=dp[i-1][j]%1000000007;
            
            else dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;//左からと上から
          
        }
    }
 
    cout<<dp[h-1][w-1]<<endl;
}


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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    char a, b;
    cin >> a >> b, cout << (a == b ? 'H' : 'D') << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed

main :: IO ()
main = do
  n <- readLn :: IO Int
  hs <- listArray (1,n) . map read . words <$> getLine :: IO (UArray Int Int)
  print $ solve hs n ! n

solve :: UArray Int Int -> Int -> UArray Int Int
solve hs n = runSTUArray $ do
  dp <- newArray (1,n) 0
  forM_ [1..n] $
    \x -> case x of
      1 -> writeArray dp 1 0
      2 -> writeArray dp 2 $ abs $ (hs!2) - (hs!1)
      _ -> do
        a <- liftM2 (+) (readArray dp (x-1)) (return . abs $ hs!x - hs!(x-1))
        b <- liftM2 (+) (readArray dp (x-2)) (return . abs $ hs!x - hs!(x-2))
        writeArray dp x $ min a b
  return dp

Measured memory_bytes: 16764
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

ll dp[3100][3100] = {0};

int main(void){
    int n, t;
    cin >> n >> t;
    vector<pair<int,int>> f(n);
    for(int i = 0; i < n; i++){
        pair<int,int> tmp;
        cin >> tmp.first >> tmp.second;
        f[i] = tmp;
    }

    sort(f.begin(), f.end());

   
    vector<ll> notchosen(n);

    for(int i = 0; i < n; i++){
        for(int j = 0; j < t; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            notchosen[i] = dp[i][j] + f[i].second;
            if(j - f[i].first >= 0){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - f[i].first] + f[i].second);
                //cout << "here" << endl;
                //cout << dp[i + 1][j] << "," << dp[i][j - f[i].first] + f[i].second<< endl;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, notchosen[i]);
    }

    cout << ans << endl;



}

Measured memory_bytes: 73984
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s,t;cin>>s>>t;
  print(t+s);
  return 0;
}

Measured memory_bytes: 256
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n, m;

void Input() {
	cin >> n >> m;
}
const ll mx = 1e5 + 5;

vll a[mx];
ll vis[mx], dis[mx], in[mx];

void dfs(ll s) {
	assert(!vis[s]);
	vis[s] = 1;
	for (auto it : a[s]) {
		dis[it] = max(dis[it], dis[s] + 1);
		in[it]--;
		if (in[it] == 0)dfs(it);
	}
}

void Solve() {
	while (m--) {
		ll u, v;
		cin >> u >> v;
		a[u].pb(v);
		in[v]++;
	}
	for (ll i = 1; i <= n; i++) {
		if (!vis[i] and !in[i]) {
			dfs(i);
		}
	}
	ll ans = 0;
	for (auto it : dis)ans = max(it, ans);
	cout << ans;

}

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

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	vector<pair<pair<string, int>, int>> sp(N);
	
	rep(i, N){
		int a;
		string s;
		cin >> s >> a;
		sp[i] = make_pair(make_pair(s, -a), i+1);
	}
	
	sort(sp.begin(), sp.end());
	
	rep(i, N)
		cout << sp[i].second << endl;
	
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val graph = Array(n + 1) { mutableListOf<Pair<Int, Int>>() }

    repeat(n - 1) {
        val (u, v, w) = readLine()!!.split(' ').map { it.toInt() }
        graph[u].add(v to w)
        graph[v].add(u to w)
    }

    val ans = IntArray(n + 1)

    fun dfs(u: Int, d: Int, p: Int) {
        for ((v, w) in graph[u]) {
            if (v == p) continue
            ans[v] = (d + w) % 2
            dfs(v, ans[v], u)
        }
    }

    dfs(1, 0, 0)

    println(ans.slice(1..n).joinToString("\n"))
}


Measured memory_bytes: 98744
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func match(a, b byte) bool {
	if a == 0 {
		return true
	}
	if a == b || a == '?' || b == '?' {
		return true
	}
	return false
}

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

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

func conv(a []byte) string {
	var s string
	for _, v := range a {
		if v != 0 {
			s += string(v)
		} else {
			s += "."
		}
	}
	return s
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

func out2(s []string, x, y int) {
	out(s[0])
	for i := 0; i < x; i++ {
		fmt.Print(" ")
	}
	out(s[1])
	for i := 0; i < y; i++ {
		fmt.Print(" ")
	}
	out(s[2])
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	S := make([]string, 3)
	for i := 0; i < 3; i++ {
		S[i] = getString()
	}

	x := []int{0, 1, 2}

	const SIZE = 2020
	var judge [3][3][SIZE]bool

	ans := 100100
	for {
		s := []string{S[x[0]], S[x[1]], S[x[2]]}
		pat := [][]int{{0, 1}, {0, 2}, {1, 2}}
		for p := 0; p < 3; p++ {
			i := pat[p][0]
			j := pat[p][1]

			for k := 0; k < len(s[i]); k++ {
				flg := true
				for ni := k; ni < len(s[i]); ni++ {
					nj := ni - k
					if nj >= len(s[j]) {
						break
					}
					if s[i][ni] == '?' || s[j][nj] == '?' {
						continue
					}
					if s[i][ni] != s[j][nj] {
						flg = false
					}
				}
				judge[i][j][k] = flg
				//out(i, j, s[i][k:], s[j], judge[i][j][k])
			}
		}

		var f = func(i, j, k int) bool {
			if k >= len(s[i]) {
				return true
			}
			return judge[i][j][k]
		}

		for i := 0; i < SIZE; i++ {
			for j := 0; j < SIZE; j++ {
				if !f(0, 1, i) {
					continue
				}
				if !f(1, 2, j) {
					continue
				}
				//out2(s, i, i+j)
				if !f(0, 2, i+j) {
					continue
				}
				//out2(s, i, i+j)
				//out(len(s[0]), len(s[1])+i, len(s[2])+i+j)
				n := max(len(s[0]), max(len(s[1])+i, len(s[2])+i+j))
				ans = min(ans, n)
			}
		}
		if nextPermutation(sort.IntSlice(x)) == false {
			break
		}
	}

	out(ans)
	/*
		s := make([]string, 3)
		for i:= 0; i < 3; i++  {
			s[i] := getString()
		}
	*/

}


Measured memory_bytes: 640
using System;
class aizu{
    public static int Main(){
        int i;
        int[] n = new int[10];
        string[] str = new string[100];
        str = Console.ReadLine().Split(' ');
        for(i=0;i<5;i++)
           n[i] = int.Parse(str[i]);
        if(n[2]<0 || n[3]<0 || n[2]+n[4]>n[0] || n[3]+n[4]>n[1])
            Console.WriteLine("No");
        else
            Console.WriteLine("Yes");
        return 0;
    }
}

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

int main(){
long long int K;
long long int N;
long long int x;
cin >> K >> N;
vector<int> vec(N);
for(int i = 0; i < N; i++){
  cin >> vec.at(i);
}
 vector<int> def; 
  def=vec;
for(int i = 0; i < N; i++){
  if(i==0){
    def.at(i)=K-vec.at(N-1)+vec.at(i);
  }else{
    def.at(i)=vec.at(i)-vec.at(i-1);
    }
  }
vector<int> srt(N);
  srt = def;
sort(srt.begin(), srt.end());

  cout << K-srt.at(N-1);
  
}

Measured memory_bytes: 2688
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 400000
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<ll, vector<ll > > max_pq;
typedef priority_queue<ll, vector<ll> , greater<ll >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
double ar[ 2000 ];
double t,a;
ll n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> t >> a;
    for ( ll i = 1; i <= n; i ++)
        cin >> ar[i];
    double ans = INT_MAX;
    ll kaun = 0;
    for ( ll i = 1; i <= n; i ++)
    {
        double val = fabs(t-ar[i]*0.006-a);
        if ( val < ans )
            ans = val,kaun = i;
    }
    cout << kaun;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  cout << s.rfind("Z")-s.find("A")+1<<endl;
  return 0;
}


Measured memory_bytes: 720
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 300000

	char sInput[MAX_STRING+1]="";


int main() {
//	char* psInput;
	char sInput2[30]="";

	int i=0;
	int j=0;
	int nMin=999999;
	int nLen=0;
	int nMismatch=0;
	char cCorrect=' ';

	// read line 1
	gets(sInput2);
	nLen = atoi(sInput2);

	// read line 2
	gets(sInput);

	//first callenge
	i=0;
	for(j=1;j<nLen;j++){
		if ('W'!=sInput[j]){
			nMismatch++;
		}
	}
	if(nMin>nMismatch){
		nMin=nMismatch;
	}
	//2nd case or lator
	for (i=1;i<nLen;i++){
		// 今着目しているマスをリーダーにするので、そこの判定をなかったことにする
		if(sInput[i]!='W'){
			nMismatch--;
		}
		// 前のマスの判定を再計算する
		if(sInput[i-1]!='E'){
			nMismatch++;
		}
		if(nMin>nMismatch){
			nMin=nMismatch;
		}

	}

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

    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
	vector<int> W, K;
	int dommy;
	for (int i = 0; i < 10; ++i) {
		cin >> dommy;
		W.push_back(dommy);
	}
	sort(W.begin(), W.end(), greater<int>());
	for (int i = 0; i < 10; ++i) {
		cin >> dommy;
		K.push_back(dommy);
	}
	sort(K.begin(), K.end(), greater<int>());
	int Wpoint = 0, Kpoint = 0;
	for (int i = 0; i < 3; ++i) {
		Wpoint += W[i];
	}
	for (int i = 0; i < 3; ++i) {
		Kpoint += K[i];
	}
	cout << Wpoint << ' ' << Kpoint << endl;
	return 0;
}

Measured memory_bytes: 3068
import sys


def option_index(blist):
  option_num = -1 
  option_i = None
  for i in range(len(blist)):
    if i + 1 == blist[i]:
      if option_num < blist[i]:
        option_i = i 
        option_num = blist[i]
  return option_i

N = int(sys.stdin.readline())
blist = list(map(int, sys.stdin.readline().split()))
ans = []
while len(blist)>0:
  result = option_index(blist)
  if result is not None:
    ans = [blist[result]] + ans
    blist.pop(result)
  else:
    print(-1)
    exit()

print("\n".join(map(str,ans)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e18;
const int INF=1e18;

int32_t main(){
	IOS;
	int n,w;
	cin>>n>>w;
	pair<int,int> p[n];
	int sum=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		p[i]={x,y};
 		sum+=y;
	}
	sort(p,p+n);
	int dp[sum+1];
	for(int i=0;i<=sum;i++) dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=sum;j>=p[i].ss;j--){
			dp[j]=min(dp[j],dp[j-p[i].ss]+p[i].ff);
		}
	}
	int ans;
	for(int i=0;i<=sum;i++){
		if(dp[i]<=w){
			ans=i;
		}
	}
	cout<<ans<<endl;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main(){
    ll x;
    cin >> x;
    ll cnt = 0;
    ll a = 100;
    while (a<x) {
        cnt++;
        a *= 1.01;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		String S = sc.next();
		
		sc.close();
		
		StringBuffer ans = new StringBuffer();
		
		int pass = 0;
		int irank = 0;
		
		for(int i=0;i<N;i++) {
			char x = S.charAt(i);
			if(x == 'a') {
				if(pass < A+B) {
					pass++;
					ans.append("Yes\r\n");
				}else {
					ans.append("No\r\n");
				}
			}else if(x == 'b') {
				irank++;
				if(pass < A+B && irank <= B) {
					pass++;
					ans.append("Yes\r\n");
				}else {
					ans.append("No\r\n");
				}
			}else {
				ans.append("No\r\n");
			}
		}
		
		out.print(ans.toString());

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 28648
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[210000], b[210000], c, dist[110000], T[110000], cnt, U[110000];
vector<pair<int, int> >x[110000], y[110000]; bool used[210000];
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		x[a[i]].push_back(make_pair(b[i], i));
		x[b[i]].push_back(make_pair(a[i], i));
	}
	fill(dist, dist + n + 1, 999999); dist[1] = 0;
	queue<int> Q; Q.push(1);
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (pair<int,int> i : x[a1]) {
			if (dist[i.first] > dist[a1] + 1) {
				dist[i.first] = dist[a1] + 1;
				Q.push(i.first);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (pair<int, int> j: x[i]) {
			if (dist[i] < dist[j.first]) {
				y[i].push_back(j);
				T[j.first]++;
			}
		}
	}
	for (int i = 0; i < q; i++) {
		scanf("%d", &c); c--;
		queue<pair<int, int> > Q1;
		int ss = -1;
		if (dist[a[c]] < dist[b[c]])ss = b[c];
		if (dist[a[c]] > dist[b[c]])ss = a[c];
		if (ss >= 1 && U[ss] == 0 && used[c] == false) {
			Q1.push(make_pair(ss, c));
			while (!Q1.empty()) {
				int a1 = Q1.front().first, a2 = Q1.front().second; Q1.pop();
				if (U[a1] == 1 || used[a2] == true) continue; T[a1]--; used[a2] = true;
				if (T[a1] != 0) continue; cnt++; U[a1] = 1;
				for (pair<int, int> j: y[a1]) {
					if (U[j.first] == 0) Q1.push(j);
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 20052
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))

#%%
d = defaultdict(lambda: 0)
for key in A:
    d[key] += 1

#%%
# それぞれのkeyのnC2
cmb = dict()
cmb2 = dict()
for k in d.keys():
    cmb[k] = d[k] * (d[k] - 1) // 2
    cmb2[k] = (d[k] - 1) * (d[k] - 2) // 2

#%%
ans_d = dict()
s = sum(cmb.values())
for k in d.keys():
    ans_d[k] = s - cmb[k] + cmb2[k]
#%%
for a in A:
    print(ans_d[a])


Measured memory_bytes: 46792
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



int main()
{
	int N;
	cin >> N;
	vi L(N);
	cin >> L;

	sortall(L);

	int sum = 0;
	
	for (int i = 0; i < N - 1; i++) {
		sum += L[i];
	}

	yn(sum > L[N - 1]);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, K;
int d[100];
int A[100][100];

void solve() {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool flag = false;
    for (int j = 0; j < K; j++) {
      for (int k = 0; k < d[j]; k++) {
        if (A[j][k] == i+1) {
          flag = true;
        }
      }
    }
    if (!flag) { ans++; }
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A[i][j];
    }
  }
  solve();
  return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

void panic() {
  cout << "No" << endl;
  exit(0);
}

void Main() {
  int n = read<int>();

  vpii X(n);

  rep(i, n) {
    X[i].fst = read<int>() - 1;
    X[i].snd = i;
  }
  sort(all(X));

  //cout << "X:"; rep(ii,sz(X)) cout << ' ' << X[ii]; cout << endl;

  vi ans(n * n, -1);
  rep(i, n) {
    int idx = X[i].fst;
    int x = X[i].snd;
    ans[idx] = x;
    int lef = x;
    //_p("x: %d, idx: %d, lef: %d\n", x, idx, lef);
    rep(j, idx) {
      if (lef == 0) break;
      if (ans[j] == -1) {
        ans[j] = x;
        lef--;
      }
    }
    if (lef) panic();
  }

  rep(i, n) {
    int idx = X[i].fst;
    int x = X[i].snd;
    int rig = n - x - 1;
    //_p("x: %d, idx: %d, rig: %d\n", x, idx, rig);
    rep(j, idx + 1, n*n) {
      if (rig == 0) break;
      if (ans[j] == -1) {
        ans[j] = x;
        rig--;
      }
    }
    if (rig) panic();
    //cout << "ans:"; rep(ii,sz(ans)) cout << ' ' << ans[ii]; cout << endl;
  }

  cout << "Yes" << endl;
  rep(i, n*n) {
    _p(i+1<n*n?"%d ":"%d\n", ans[i] + 1);
  }
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll d;
    cin >> d;
    vector<ll> c(26);
    for(i = 0;i < 26;++i){
        cin >> c.at(i);
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    for(i = 0;i < d;++i){
        rep(j,26){
            cin >> s.at(i).at(j);
        }
    }
    for(i = 0;i < d;++i){
        ll tmp = -1e9;
        ll ind = -1;
        rep(j,26){
            if(chmax(tmp, s.at(i).at(j))) ind = j;
        }
        cout << ind+1 << endl;
    }


    return 0;
}

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

typedef struct {double x,y;}Point;

void koch(int n,Point a,Point b){
  if(n==0) return;

  Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,b.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2056
def examA():
    N, M = LI()
    if N==M:
        print("Yes")
    else:
        print("No")
    return

def examB():
    A, B = LI()
    if A>B:
        ans = str(B)*A
    else:
        ans = str(A)*B
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 3572
#include<cstdio>
#include<algorithm>
#define INF 1000000000000000000
using namespace std;
int main(){
    int n;
    long long a[400],sum[401]={},dp[400][400]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        sum[i+1]=sum[i]+a[i];
    }
    for(int i=1;i<n;i++){
        for(int j=0;j+i<n;j++){
            dp[j][i+j]=INF;
            for(int k=j;k<i+j;k++){
                dp[j][i+j]=min(dp[j][i+j],dp[j][k]+dp[k+1][i+j]);
            }
            dp[j][i+j]+=sum[i+j+1]-sum[j];
        }
    }
    printf("%lld\n",dp[0][n-1]);
}

Measured memory_bytes: 1536
#include <stdio.h>
int main(void)
{
    int a,b,c,i,count=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2696
def solve():
    s = input()
    t = input()
    s_l, t_l = len(s), len(t)
    e = [s[i:i+s_l] for i in range(0, s_l-t_l+1)]
    ans = min([sum(i != j for i, j in zip(k, t)) for k in e])
    print(ans)


def main():
    t = 1
    while t > 0:
        solve()
        t -= 1


main()

Measured memory_bytes: 9428
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VI e[100000], visit;

bool check(VI ans){
    for (auto p : e[ans[0]]){
        if (!visit[p]) return false;
    }
    for (auto p : e[ans[ans.size()-1]]){
        if (!visit[p]) return false;
    }
    return true;
}

void output(VI ans){
    cout << ans.size() << endl;
    REP(i,ans.size()){
        if (i > 0) printf(" ");
        printf("%d", ans[i]+1);
    }
    cout << endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    while (m--){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    int s = 0;
    REP(i,n){
        if (e[i].size() == 1) s = i;
    }

    VI ans;
    visit.resize(n);
    while (1){
        ans.push_back(s);
        visit[s] = 1;
        bool found = false;
        for (auto next : e[s]){
            if (visit[next]) continue;
            found = true;
            s = next;
        }
        if (!found) break;
    }

    if (check(ans)){
        output(ans);
        return 0;
    }

    while (1){
        ans.clear();
        visit.clear();
        visit.resize(n);
        s = rand() % n;
        while (1){
            ans.push_back(s);
            visit[s] = 1;
            bool found = false;
            for (auto next : e[s]){
                if (visit[next]) continue;
                found = true;
                s = next;
            }
            if (!found) break;
        }

        if (check(ans)){
            output(ans);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 6400
H,W=map(int,input().split())
lines=[]
for i in range(H):
    lines.append(input().strip())

chars=dict()
for line in lines:
    for c in line:
        if c not in chars:
            chars[c]=0
        chars[c]+=1

def judge(H,W,chars):
    #両方奇数
    if H%2+W%2==2:
        ones=1
        twos=(H+W-2)//2
    #両方偶数
    elif H%2+W%2==0:
        ones=0
        twos=0
    elif H%2==1:
        ones=0
        twos=W//2
    else:
        ones=0
        twos=H//2
    for c in chars:
        if ones<0 or twos<0:
            return False
        chars[c]%=4
        if chars[c]==0:
            continue
        if chars[c]==2:
            twos-=1
        elif chars[c]==3:
            twos-=1
            ones-=1
        else:
            ones-=1
    return True

if judge(H,W,chars):
    print("Yes")
else:
    print("No")

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

long long N, A, B;
vector<long long> H;

// T 回で全ての魔物を消し去ることが可能か判定
bool check(long long T) {
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    long long a = max(0LL, H.at(i) - B * T);
    cnt += (a + (A - B) - 1) / (A - B); 
  }
  return cnt <= T;
}

int main() {
  cin >> N >> A >> B;
  H.resize(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  int left = 0, right = 1000000001;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (check(mid)) right = mid;
    else left = mid;
  }
  cout << right << endl;
}

Measured memory_bytes: 4000
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
const ll MOD (1e9+7);
const ll INF (2e9);
const int MAX_N (200001);

int main(void) {
    char *s=new char[100005];
    cin>>s;
    int g=0,p=0;
    for(int i=0;s[i]!='\0';i++){
        (s[i]=='g'?g++:p++);
    }
    cout<<(g-p)/2<<endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(ll  i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e18 + 1;

ll n, m;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, k, t, x, y, z,  N;
	cin >> n >> m >> x;
	map<ll, ll, greater<ll>> r;
	map<ll, ll, greater<ll>> c;
	map<pair<ll, ll>, ll> el;
	rep(i, x) {
		cin >> y >> z;
		r[y]++;
		c[z]++;
		el[ {y, z}] = 1;
	}
	set < pair<ll, ll>, greater<pair<ll, ll>>> row, col;
	for (auto u : r) {
		row.insert({u.se, u.fi});
	}
	for (auto u : c) {
		col.insert({u.se, u.fi});
	}
	ll mx1 = (*row.begin()).fi;
	ll mx2 = (*col.begin()).fi;
	ll flg = 0;
	for (auto r1 : row) {
		if (r1.fi < mx1)
			break;
		for (auto c1 : col) {
			if (c1.fi < mx2) {
				break;
			}
			if (el[ {r1.se, c1.se}] == 0) {
				flg = 1;
				break;
			}
		}
		if (flg)
			break;
	}

	if (flg) {
		cout << mx1 + mx2;
	}
	else
		cout << mx1 + mx2 - 1;


	return 0;
}

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

int main(){
	string s,t;
	cin >> s >> t;
	
	bool ok = false;
	if(s==t) ok = true;
	rep(i,s.size()){
		char temp = s[s.size()-1];
		for (int j = s.size()-1; j > 0 ; --j) {
			s[j] = s[j-1];
		}
		s[0] = temp;
		if(s==t) ok = true;
	}
	
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<long long int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	int rec = 0;
	for (int i = N - 1; i  > 0; i--) {
		if (H[i] == H[i - 1] - 1) {
			H[i - 1] = H[i];
		}
		else if (H[i] >= H[i - 1]) {

		}
		else {
			rec++;
			break;
		}
	}
	if (rec == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main(void)
{
	long long n;
	cin >> n;

	long long c = 1;
	string s = "abcdefghijklmnopqrstuvwxyz";
	string ans;
	for (int i = 0; ; i++) {
		if (i == 0) {

		}
		long long m = n/c;
		if (m == 0)
			break;
		ans.push_back(s[((m-1)%26)]);
		if (m%26 == 0)
			n -= 26*c;
		else
			n -= (m)%26*c;
		c *= 26;

	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    cout<<n/3<<endl;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  if(A < 6)cout << 0 << endl;
  else if(A < 13 && A >= 6)cout << B/2 << endl;
  else if(A >= 13) cout << B << endl;
  

  return 0;
}

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

ans = 0

for index, a in enumerate(A):
  if index == 0:
    if a > x:
      ans += abs(x - a)
      A[index] = x
    continue

  if a + A[index-1] > x:
    ans += abs(x - (a + A[index-1]))
    A[index] = x - A[index-1]

print(ans)

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

long long n,m;
char str[200005];
int arr[200005];
long long MOD=1000000007;

int main(){
	scanf("%lld%lld",&n,&m);scanf("%s",str);
	for(int i=0;i<m;i++){
		if(str[i]=='R')arr[i]=0;
		else arr[i]=1;
	}
	bool all[2];all[0]=all[1]=1;
	for(int i=0;i<m;i++)all[arr[i]^1]=0;
	if(all[0]||all[1]){
		long long dp[2][n];memset(dp,0,sizeof(dp));
		dp[0][0]=1;dp[1][0]=0; //start with red (or blue if everything is blue)
		for(int i=1;i<n;i++){
			dp[0][i]=dp[0][i-1]+dp[1][i-1];
			dp[1][i]=dp[0][i-1];
			dp[0][i]%=MOD;dp[1][i]%=MOD;
		}
		long long ans=(dp[0][n-1]+dp[1][n-1])%MOD; //end with red or blue
		memset(dp,0,sizeof(dp));
		dp[0][0]=0;dp[1][0]=1; //start with blue
		for(int i=1;i<n;i++){
			dp[0][i]=dp[0][i-1]+dp[1][i-1];
			dp[1][i]=dp[0][i-1];
			dp[0][i]%=MOD;dp[1][i]%=MOD;
		}
		ans+=dp[0][n-1];ans%=MOD;ans+=MOD;ans%=MOD; //only end with red
		printf("%lld",ans);
		return 0;
	}
	if(n%2!=0){printf("0");return 0;}
	long long s=0,l=n-1;
	for(int i=0;i<m;i++){
		long long cur=0;
		while(i+cur<m&&arr[i+cur]==arr[0])cur++;
		if(s==0)s=(cur%2==0?cur+1:cur);
		else if(i+cur<m&&cur%2!=0)l=min(l,cur);
		i+=cur;
	}
	long long mxl=min((s==0?MOD:s),l);
	//comments: wlog red is first
	//can ignore last segment of red
	n/=2; mxl/=2; //remove the ones that are different parity from blue
	long long dp[100100],pref[100100];
	memset(dp,0,sizeof(dp));memset(pref,0,sizeof(pref));
	//i segments on a line, first and last are blue, max mxl consecutive reds
	//blues may be consecutive because the reds in between were removed
	dp[0]=pref[0]=0;dp[1]=pref[1]=1;
	for(long long i=2;i<=n+10;i++){
		dp[i]=pref[i-1]-pref[max(0LL,i-(mxl+2))];
		dp[i]%=MOD;dp[i]+=MOD;dp[i]%=MOD;
		pref[i]=dp[i]+pref[i-1];
		pref[i]%=MOD;pref[i]+=MOD;pref[i]%=MOD;
	}
	long long ans=0;
	for(long long i=2;i<=mxl+2;i++){
		ans+=((i-1LL)*dp[n-i+2])%MOD;
		ans%=MOD;
	}
	ans+=MOD;ans%=MOD;
	printf("%lld",(ans*2LL)%MOD);
}


Measured memory_bytes: 4352
import scala.math.{min, max, sqrt}

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextLong

    var minDigit = n.toString.length
    var i = 1L
    while(i <= sqrt(n)){
      if(n % i == 0) {
        minDigit = min(minDigit, max(i.toString.length, (n / i).toString.length))
      }
      i += 1
    }

    println(minDigit)
  }
}


Measured memory_bytes: 25636