akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
#include<climits>
using namespace std;

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

    if(N >= M){
        cout << 0 << endl;
        return 0;
    }

    vector<int> Xs(M);
    for(int i = 0; i < M; ++i){
        cin >> Xs[i];
    }
    sort(Xs.begin(), Xs.end());

    vector<int> dists(M - 1);
    for(int i = 0; i < M - 1; ++i){
        dists[i] = Xs[i + 1] - Xs[i]; 
    }

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

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s, t;
  cin >> s >> t;
  for(int i=0; i<s.length(); i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3592
import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    ans = 0
    for i in range(n):
        ans += a[i] - 1
    print(ans)

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 9964
#include<stdio.h>
int main() {
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if(-100 <= x <= 100 && -100 <= y <= 100 && 0 < W <= 100 && 0 < H <= 100 && 0 < r <= 100){
    if(x-r < 0 || W < x+r || y-r < 0 || H < y+r){
      printf("No\n");
    }
    else{
      printf("Yes\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string w, t;
    int cnt=0;
    cin>>w;
    for (int i=0; i<w.size(); i++)
    {
        if (w[i]>='A' && w[i]<='Z') w[i]-='A'-'a';
    }
    while (1)
    {
        cin>>t;
        if (t=="END_OF_TEXT") break;
        for (int i=0; i<t.size(); i++)
        {
            if (t[i]>='A' && t[i]<='Z') t[i]-='A'-'a';
        }
        if (t==w) cnt++;
    }
    cout<<cnt<<'\n';
    return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
void solve();
typedef long long ll;
int main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  solve();
  return 0;
}

void solve()
{
  int n, k;
  cin >> n >> k;
  int* arr = new int[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  ll* dp = new ll[n];
  dp[0] = 0;
  for (int i = 1; i < n; i++)
  {
    int min = INT_MAX;
    ll current = INT_MAX;
    for (int j = 1; j <= k; j++)
    {
      if (i - j < 0)
        break;
      else
      {
        current = abs(arr[i] - arr[i - j]) + dp[i - j];
        if (current < min)
          min = current;
      }
    }
    dp[i] = min;
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
//Linear Approximation

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    rep(i,0,n)a[i]-=i+1;
    sort(range(a));
    int t=a[n/2];
    rep(i,0,n)a[i]=abs(a[i]-t);
    cout<<accumulate(range(a),0LL)<<nnn;
    return 0;
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

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

			int ans = 0;
			if (n % (2*d+1) != 0) {
				ans = (n / (2*d+1)) + 1;
			} else {
				ans = n / (2*d+1);
			}
			System.out.println(ans);
	}

}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();
		char[] C = sc.next().toCharArray();
		int a = 0,b = 0,c = 0;
		char point = 'a';
		while(true) {
			if(point == 'a') {
				if(!hasNext(A, a)){
					System.out.println('A');
					break;
				}
				point = A[a];
				a++;
			}else if(point == 'b') {
				if(!hasNext(B, b)){
					System.out.println('B');
					break;
				}
				point = B[b];
				b++;
			}else {
				if(!hasNext(C, c)){
					System.out.println('C');
					break;
				}
				point = C[c];
				c++;
			}

		}

	}

	public static boolean hasNext(char[] ary,int point){
		if(ary.length == point) return false;
		return true;
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()

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

int main()
{
	int INF = 1001001001;
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m);
	vector<vector<int>> c(m, vector<int>());
	rep(i, m)
	{
		cin >> a[i] >> b[i];
		rep(j, b[i])
		{
			int x; cin >> x;
			c[i].push_back(x);
		}
	}

	vector<vector<int>> dp(m + 1, vector<int>(pow(2, n), INF));
	dp[0][0] = 0;
	rep(i, m)
	{
		int tmp = 0;
		for (int x : c[i])tmp += (1 << (x - 1));
		rep(j, pow(2, n))
		{
			chmin(dp[i + 1][j], dp[i][j]);
			chmin(dp[i + 1][j|tmp], dp[i][j] + a[i]);
		}
	}
	if (dp[m][pow(2, n) - 1] == INF)cout << -1 << endl;
	else cout << dp[m][pow(2, n) - 1] << endl;
}

Measured memory_bytes: 16384
N = int(input())
H = list(map(int, input().split()))
ans = 0
result = 0

for i in range(N-1):
    if H[i] >= H[i+1] and i == N-2:
        ans += 1
        if result < ans:
            result = ans
    elif H[i] >= H[i+1]:
        ans +=1
    else:
        if result < ans:
            result = ans
        ans = 0

print(result)

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int a[2000000],b[10001],n;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		b[a[i]]++;
		}
    int t=0;
    for(int i=0;i<=10000;i++){
        while(b[i]>=1)
        {
            a[t++]=i;
            b[i]--;
        }
    }
    for(int i=0;i<n;i++){
		if(i==n-1){
    		cout<<a[i]<<endl;
		}else{
			cout<<a[i]<<" ";
		}
	}
	return 0;
}


Measured memory_bytes: 10940
#include <iostream>
#include <string>

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

    int ans = 0;

    int n;
    std::cin >> n;
    while (n--) {
        std::string t;
        std::cin >> t;
        t += t;

        for (int i = 0; i < (int)t.length(); ++i) {
            if (t.substr(i, s.length()) == s) {
                ++ans;
                break;
            }
        }
    }

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

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

    solve();

    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }; } fast_ios_;

int main()
{
  int n,k;
  double log2;
  log2=log(2.);

  cin>>n>>k;
  int j,b;
  double a,ans;
  for(int i=n;i>0;i--){
    j=log((k-1.+1.e-10)/i)/log2+1;
    j=max(0,j);
    if(i==n){
      a=pow(0.5,j);
      ans=a;
      b=j;
    }else if(j==b){
      ans+=a;
    }else{
      a=pow(0.5,j-b)*a;
      ans+=a;
      b=j;
    }
  }
  cout<<ans/n<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#define INF (1 << 30)
using namespace std;

int main() {
    int N, K, min_ans = INF;
    cin >> N >> K;
    for (int i = 0; i < (1 << N); i++) {
        int ans = 1;
        for (int j = 0; j < N; j++) {
            if (((i >> j) & 1) == 0) ans *= 2;
            else ans += K;
        }
        min_ans = min(min_ans, ans);
    }
    cout << min_ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int cnt = 0;
            Set<Integer> set = new HashSet<>();
            for (int i = 105; i <= N; i += 2) {
                set.clear();
                for (int j = 1; j <= i; j++) {
                    if (i % j == 0) {
                        set.add(j);
                        set.add(i / j);
                    }
                }
                if (set.size() == 8) cnt++;
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll X[200010],D[200010];
ll dp[200010] = {};
vector<ll> tree[200010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    // set<ll> ss;
    // ss.insert(1);
    // ss.insert(3);
    // ss.insert(5);
    // ss.insert(6);
    // auto itt = ss.lower_bound(7);
    // print(*itt);
    

    rep(i,0,N) cin >> X[i] >> D[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back({X[i],D[i]});
    sort(lp.begin(), lp.end());

    rep(i,0,N){
        X[i] = lp[i].first;
        D[i] = lp[i].second;
    }
    set<ll> st;
    map<ll,ll> mp;
    rep(i,0,N){
        st.insert(X[i]);
        mp[X[i]] = i;
    }
    bool check[200010] = {};
    rrep(i,N-1,0){
        ll res = 1;
        ll lv = X[i]+1;
        ll rv = X[i]+D[i];
        auto iter = st.lower_bound(lv);
        while(iter != st.end()){
            ll v = *iter;
            // print(v);
            if(v >= rv) break;
            res *= dp[mp[v]] + 1;
            res %= MOD;
            iter = st.erase(iter);
            
        }
        dp[i] = res;
    }
    ll ans = 1;
    for(auto &e: st){
        ans *= dp[mp[e]]+1;
        ans %= MOD;
    }
    print(ans);

}


Measured memory_bytes: 35564
#include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		ans_a = ans_b = 0;
		while (n){
			scanf("%d %d", &a, &b);
			
			if (a > b){
				ans_a += (a + b);
			}
			else if (a < b){
				ans_b += (a + b);
			}
			else {
				ans_a += a;
				ans_b += b;
			}
			
			n--;
		}
		printf("%d %d\n", ans_a, ans_b);
	}
	
	return (0);
}

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

int main() {
  int N, i, sum;
  cin >> N;
  for (i = 0;i < N;i++) {
    int l, r, num;
    cin >> l >> r;
    num = r - l + 1;
    sum += num;
  } 
  cout << sum << endl;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,c,k,n=0;
    cin>>a>>b>>c>>k;
    while(b<=a)b<<=1,n++;
    while(c<=b)c<<=1,n++;
    cout<<(n<=k?"Yes\n":"No\n");

    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    String res = new String("No");
    for (int i = 0; i < 3; i++) {
      int tmp = n.charAt(i) - '0';
      if (tmp == 7) res = new String("Yes");
    }
    System.out.println(res);
    sc.close();
  }
}

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

int main()
{
    int k;
    int ans = 0;
    cin >> k;
    for (int a = 1; a < k + 1; a++)
    {
        for (int b = 1; b < k + 1; b++)
        {
            for (int c = 1; c < k + 1; c++)
            {
                ans += __algo_gcd(a, __algo_gcd(b, c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3160
import math

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

H,N = splitintinput()
A = listintinput()

if H > sum(A):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 14012
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int H, W;
vector<string> fi;

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

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];

    // 多点をスタートとして扱う
    vector<vector<int> > dist(H, vector<int>(W, -1));
    using pint = pair<int,int>;
    queue<pint> que;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') {
                dist[i][j] = 0;
                que.push(pint(i, j));
            }
        }
    }

    // BFS
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        for (int dir = 0; dir < 4; ++dir) {
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            res = max(res, dist[i][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct edge{int to, cost;};

const int MAX_V = 1e5;
vector<edge> es[MAX_V];
vector<int> d(MAX_V, inf);

void add_edge(int from, int to, int cost){
    es[from].emplace_back((edge){to, cost});
}

void dijkstra(int s){
    d[s] = 0;
    queue<pii> que;
    que.push(pii(d[s], s));
    while(!que.empty()){
        pii p = que.front();
        que.pop();
        int i = p.second;
        if(p.first > d[i]) continue;
        for(auto &e: es[i]){
            if(d[e.to] > d[i]+e.cost){
                d[e.to] = d[i]+e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

int main(){
    int K;
    cin >> K;
    rep(i, K){
        add_edge(i, (i+1)%K, 1);
        add_edge(i, (i*10)%K, 0);
    }
    dijkstra(1);
    cout << d[0]+1 << endl;
}

Measured memory_bytes: 6400
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] timevals = new int [n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			timevals[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int [] t = new int [m];
		int [] l = new int [m];
		for (int j = 0; j < m; j++) {
			t[j] = sc.nextInt();
			l[j] = sc.nextInt();
		}
		for(int k = 0; k < m; k++) {
			int p = t[k];
			int x = l[k];
			int sub = timevals[p - 1];
			timevals[p - 1] = x;
			for (int val : timevals) {
				count += val;
			}
			timevals[p - 1] = sub;
			System.out.println(count);
			count = 0;
		}
	}
}


Measured memory_bytes: 36360
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	a = String["hi","hihi","hihihi","hihihihi","hihihihihi"]
	f = 0
	for i in 1:5
		if a[i]==s
			f = 1
		end
	end
	println(f==1?"Yes":"No")
end

main()

Measured memory_bytes: 163012
def push(x, top, S):
      S.append(x)
      top = top + 1

def pop(top):
      del S[top-1]
      top = top - 1

if __name__ == "__main__":
      stdin = input()
      stdin = stdin.split()
      n = len(stdin)
      S = []
      top = len(S)
      for i in range(0, n):
            if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
      print(S[top])

Measured memory_bytes: 7760
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

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

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

using namespace std;

typedef long long ll;

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

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

    ll N,A,B,C,D;
    scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
    ll goal = fabs(A-B);
    N -= 1;
    string ans = "NO";

    for (ll pairs=0; pairs<N/2; pairs++) {
        ll range = pairs*(D-C);
        ll n = N-2*pairs;
        ll low_goal = goal-range;
        ll high_goal = goal+range;
        ll low_poss = C*n;
        ll high_poss = D*n;
        //pr(pairs) pr(low_goal) pr(high_goal) pr(low_poss) pr(high_poss) nl
        if (low_poss <= low_goal && low_goal <= high_poss ||
            low_poss <= high_goal && high_goal <= high_poss ||
            low_goal <= low_poss && high_poss <= high_goal) {
            ans = "YES";
            break;
        }
    }

    /*while (N > 0) {
        pr(N) pr(goal) nl
        if (N%2 == 0 && (N/2)*(D-C) >= goal) {
            ans = "YES";
            break;
        }
        else if (N%2 == 1){
            ll dif = max(C, min(D, goal));
            goal = fabs(goal-dif);
        }
        else if (N%2 == 0) {
            ll dif = max(2*C, min(2*D, goal));
            goal = fabs(goal-dif);
            N--;
        }
        N--;
    }
    if (goal == 0)
        ans = "YES";*/

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int power_two(int N) {
    int sum = 1;
    for (int i = 0; i < N; i++) {
        sum *= 2;
    }
    return sum;
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int>K(10);
    vector<vector<int>>S(10, vector<int>(10));
    for (int i = 0; i < M; i++) {
        cin >> K.at(i);
        for (int j = 0; j < K.at(i); j++) {
            cin >> S.at(i).at(j);
        }
    }
    vector<int>P(10);
    for (int i = 0; i < M; i++) {
        cin >> P.at(i);
    }
    int ans = 0;
    vector<int>Light(10);
    vector<bool>Push(10, false);
    for (int i = 0; i < power_two(N); i++) {
        bool check = true;
        fill(Light.begin(), Light.end(), 0);
        fill(Push.begin(), Push.end(), false);
        for (int j = 0; j < M; j++) {
            int num = 0;
            for (int k : S.at(j)) {
                if ((i >> k) & 1) num++;
            }
            if (num % 2 != P.at(j)) check = false;
        }
        if (check) ans++;
    }
    cout << ans << endl;
}

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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    }
    else {
        if (z->key < y->key) y->left = z;
        else y->right = z;
    }
}

Node *find(Node *u, int k) {
    while (u != NIL && u->key != k) {
        u = (u->key < k ? u->right: u ->left);
    }
    return u;
}

Node *treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node *treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    x = (y->left != NIL ? y->left : y->right);

    if (x != NIL) x->parent = y->parent;

    if (y->parent == NIL) root = x;
    else if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;

    if (y != z) z->key = y->key;

    free(y);
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(void) {
    int n, i, k;
    string com;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &k);
            insert(k);
        }
        else if (com == "find") {
            scanf("%d", &k);
            Node *x = find(root, k);
            if (x != NIL) printf("yes\n");
            else printf("no\n");
        }
        else if (com == "delete") {
            scanf("%d", &k);
            treeDelete(find(root, k));
        }
        else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 20008
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++ )
   {
       cin>>a[i];
   }
   if(n%2!=0){cout<<"0";}
   else
   {
       sort(a,a+n);
       cout<<(a[n/2]-a[n/2 -1]);
   }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;

#define endl '\n'

int h[N],dp[N];

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	ll n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, A, B; cin >> N >> A >> B;
    int ans_min = 0, ans_max = min(A, B);
    if (A + B > N) ans_min = max((N - max(A, B)), min(A, B)) - min((N - max(A, B)), min(A, B));
    printf("%d %d\n", ans_max, ans_min);
}

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

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<ll> x(n), y(n), z(n);
  for(int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i) >> z.at(i);
  
  vector<ll> a(n), b(n), c(n), d(n);
  for(int i = 0; i < n; i++){
    a.at(i) = x.at(i) + y.at(i) + z.at(i);
    b.at(i) = -x.at(i) + y.at(i) + z.at(i);
    c.at(i) = x.at(i) - y.at(i) + z.at(i);
    d.at(i) = x.at(i) + y.at(i) - z.at(i);
  }
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  
  ll ans, a2, b2, c2, d2;
  ans = a2 = b2 = c2 = d2 = 0;
  for(int i = 0; i < m; i++){
    a2 += a.at(i);
    b2 += b.at(i);
    c2 += c.at(i);
    d2 += d.at(i);
  }
  ans = max({abs(a2), abs(b2), abs(c2), abs(d2)});
  
  a2 = b2 = c2 = d2 = 0;
  for(int i = n - 1; i >= n - m; i--){
    a2 += a.at(i);
    b2 += b.at(i);
    c2 += c.at(i);
    d2 += d.at(i);
  }
  ans = max({ans, abs(a2), abs(b2), abs(c2), abs(d2)});
  
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := ""
	for N != 0 {
		if N%2 == 0 {
			ans = "0" + ans
		} else {
			N--
			ans = "1" + ans
		}
		N /= -2
	}

	if ans == "" {
		ans = "0"
	}

	fmt.Println(ans)
}


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

using namespace std;
#define BUF (1000)
#define ll long long 

ll n,k;
ll ans = 0;
int main(void){

	cin >> n >> k;

	ll m = n/k;
	ll m_=0;
	if(k%2==0) m_=n/(k/2)-m;
	cout << m*m*m + m_*m_*m_<< endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
x = 0
a = 0
idx = 0

for i in range(N):
    if S[i] == "W":
        x += 1
    else:
        x -= 1

    if x < a:
        a = x
        idx = i

w = S[0:idx].count("W")
e = S[idx + 1 : N].count("E")
print(w + e)



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll        = long long;
using P         = pair<int, int>;
const double PI = acos(-1);

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double x  = double(H * 60 + M) / 720 * 2 * PI;
    double tx = double(M) / 60 * 2 * PI;
    double ph = A * cos(x), qh = A * sin(x);
    double pm = B * cos(tx), qm = B * sin(tx);
    double dx = ph - pm, dy = qh - qm;
    double ans = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 4132
if __name__ == '__main__':
    N, M = [int(v) for v in input().split()]

    if N == 1 and M == 1:
        print(1)
        exit(0)

    if N == 1 or M == 1:
        print(max(N - 2, M - 2))
        exit(0)

    n_tails = (N - 2) * (M - 2)
    print(n_tails)


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll a,b;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		string s;
		cin>>s;
		cout<<s<<"\n"<<s<<"\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	cin>>A[1]>>A[2]>>A[3];
	sc(n);
	fu(i,0,min(oo,n)){
		fu(j,0,min(oo,n)){
			if(i*A[1]+A[2]*j<=n and (n-i*A[1]-A[2]*j)%A[3]==0)ans++;
		}
	}
	pr(ans);
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
inputstring = input()
firststring = list()
secondstring = list()
count = 0
if len(inputstring) % 2 != 0:
    lenfirst = int((len(inputstring) - 1) / 2)
    for i in range (0, lenfirst):
        firststring.append(inputstring[i])
    lensecond = int((len(inputstring) + 3) / 2)
    lensecond = lensecond - 1
    for i in range (lensecond, len(inputstring)):
        secondstring.append(inputstring[i])
    for i in range (0, lenfirst):
        if firststring[i] == secondstring[i]:
            count = count + 1
        else:
            count = 0
    if count == lenfirst:
        print("Yes")
    else:
        print("No")
else:
    print()


Measured memory_bytes: 3064
#include <iostream>

int main(){
   int N;
   std::string S;
   std::cin >> N >> S;

   if(N%2!=0) {
      std::cout << "No" << std::endl;
      return 0;
   }

   for(int i=0; i<N/2; ++i){
      if(S[i]!=S[i+N/2]) {
	 std::cout << "No" << std::endl;
	 return 0;
      }
   }
   std::cout << "Yes" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

char mp[222][222];

ll b_flg[222][2];

ll cal(ll N, ll x){
    vector<ll>dep(N + 1, -1);
    dep[x] = 1;
    ll t = x;
    queue<ll>Q;
    Q.push(x);
    while(!Q.empty()){
        ll idx = Q.front();
        Q.pop();
        if(dep[idx] > dep[t])t = idx;
        rep1(to, N){
            if(mp[idx][to] == '0')continue;
            if(dep[to] < 0){
                dep[to] = dep[idx] + 1;
                Q.push(to);
            }
        }
    }
    return dep[t];
}

int main(){

    ll N;
    cin >> N;
    rep1(i, N)rep1(j, N)cin >> mp[i][j];
    queue<P>Q;
    Q.push(P(1, 0));
    b_flg[1][0] = 1;
    while(!Q.empty()){
        ll idx = Q.front().first;
        ll b = Q.front().second;
        ll nxt_b = 1 ^ b;
        Q.pop();
        rep1(to, N){
            if(mp[idx][to] == '0')continue;
            if(b_flg[to][nxt_b] == 0){
                b_flg[to][nxt_b] = 1;
                Q.push(P(to, nxt_b));
            }
        }
    }
    rep1(i, N)if(b_flg[i][0] && b_flg[i][1]){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rep1(i, N)chmax(ans, cal(N, i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define MAX 100

void swap(int *num1, int *num2) {
  int tmp = *num1;
  *num1 = *num2;
  *num2 = tmp;
}

int bubble_sort(int array[], int size) {
  int swap_count = 0;

  for(int i = 0; i < size - 1; i++) {
    for(int j = size - 1; j > i; j--) {
      if (array[j - 1] > array[j]) {
        swap(&array[j - 1], &array[j]);
        swap_count++;
      }
    }
  }

  return swap_count;
}

void print_array(int array[], int size) {
  for (int i = 0; i < size; i++) {
      printf("%d", array[i]);
    if (i != size - 1) {
      printf(" ");
    }
  }
}

int main() {
  int size;
  int array[MAX];
  int swap_count;

  scanf("%d\n", &size);
  for (int i = 0; i < size; i++) {
    scanf("%d", &array[i]);
  }

  swap_count = bubble_sort(array, size);
  print_array(array, size);

  printf("\n");
  printf("%d\n", swap_count);
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define N 10010
using namespace std;
struct no{
    int to, cost;
};
vector<no> G[N];
int n;
int X[N], Y[N];
int d[N], used[N];
void init(){
    memset(d, 0, sizeof(d));
    fill(used, used+N, false);
}
void dfs(int u){
    used[u] = true;
    for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i].to;
        if(!used[v]){
            d[v] = d[u] + G[u][i].cost;
            dfs(v);
        }
    }
}
int findMax(int a[]){
    int maxi = 0, maxv = 0;
    for(int i = 0; i < n; i++) if(a[i] > maxv) {maxv = a[i]; maxi = i;}
    return maxi;
}
void solve(){
    init();
    dfs(0);
    int x = findMax(d);

    init();
    dfs(x);
    for(int i = 0; i < n; i++) X[i] = d[i];
    int y = findMax(d);

    init();
    dfs(y);
    for(int i = 0; i < n; i++) Y[i] = d[i];
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n-1; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    solve();
    for(int i = 0; i < n; i++){
        printf("%d\n", max(X[i], Y[i]));
    }
    return 0;
}


Measured memory_bytes: 4316
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int fa[1005];
int val[1005];
int n;
int v[1005];
int dp[1005][5005];
int tmp[5005];
vector<int>son[1005];
void dfs(int now)
{
	dp[now][0]=0;
	for(int i=0;i<son[now].size();i++)
	{
		dfs(son[now][i]);
		for(int i=0;i<=val[now];i++)
			tmp[i]=dp[now][i];
		memset(dp[now],23,sizeof(dp[now]));
		for(int j=val[now];j>=0;j--)
		{
			if(j>=val[son[now][i]])	dp[now][j]=min(dp[now][j],tmp[j-val[son[now][i]]]+dp[son[now][i]][val[son[now][i]]]);
			if(j>=dp[son[now][i]][val[son[now][i]]])	dp[now][j]=min(dp[now][j],tmp[j-dp[son[now][i]][val[son[now][i]]]]+val[son[now][i]]);
		}
	}
	for(int i=1;i<=val[now];i++)
		dp[now][i]=min(dp[now][i-1],dp[now][i]);
}
int main()
{
	read(n);
	memset(dp,23,sizeof(dp));
	for(int i=2;i<=n;i++)
	{
		read(fa[i]);
		son[fa[i]].push_back(i);
	}
	for(int i=1;i<=n;i++)
		read(val[i]);
	dfs(1);//cout<<dp[1][val[1]]<<endl;
	if(dp[1][val[1]]<=123456)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 19968
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int mod=1000000007,INF=1099999999999999999;



long long int res=0,n,m,a[200005],sum=0,tmp=1;
string str;
char ch;
int main() {
	cout << fixed << setprecision(10);
	cin>>str;
	
		string memo="8";
	for(int i=0;i<str.length();i++){
		
		if(str.substr(i,1)!=memo){res++;memo=str.substr(i,1);}
		else if(i<str.length()-1){res++;memo=str.substr(i,2);i++;}
		//cout<<memo<<endl;
		
	}
	cout<<res;




} 


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <ctime>
#include <cstdlib>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1010 , P = 1e9 + 7;
int Pow(int x,ll t){int r=1;for(;t;t>>=1,x=1ll*x*x%P)if(t&1)r=1ll*r*x%P;return r;}
int n,m,black,lr,ud;
ll K;
char s[N][N];
 
int main(){
    scanf("%d%d%lld",&n,&m,&K);
    rep(i,0,n) scanf("%s",s[i]);
    rep(i,0,n) rep(j,0,m) black += s[i][j] == '#';
    rep(i,0,n) lr += s[i][0] == '#' && s[i][m-1] == '#';
    rep(i,0,m) ud += s[0][i] == '#' && s[n-1][i] == '#';
    K--;
    if(K<=0||(lr*ud>0)) printf("%d\n",1);
    else {
        int out = lr+ud , in = 0;
        if(lr) rep(i,0,n) rep(j,1,m) in += s[i][j] == '#' && s[i][j-1] == '#';
        else if(ud) rep(i,1,n) rep(j,0,m) in += s[i-1][j] == '#' && s[i][j] == '#';
        int ans = Pow(black,K) , del = ((Pow(black,K) - Pow(out,K))%P+P)%P;
        del = 1ll*del*Pow(black-out,P-2)%P*in%P;
        ans -= del;if(ans < 0) ans += P;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1280
n = int(input())

def f(a, b):
  return max(len(str(a)), len(str(b)))

n2 = int(n ** 0.5)
ans = 10 ** 11

for i in range(1, n2+1):
  if n % i == 0:
    t = n // i
    ans = min(ans, f(i, t))

print(ans)

Measured memory_bytes: 3060
def main():
    X = int(input())
    if X < 100:
        print(0)
    elif 2000 <= X:
        print(1)
    else:
        a = X // 100
        b = a * 5
        if X % 100 <= b:
            print(1)
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def zeros(h,*w): return [[0] * w[0]  for _ in range(h)] if w else [[0] * h  for _ in range(h)]

n,W = map(int, input().split())

dp = zeros(n+1,W+1)

for i in range(n):
  w,v = map(int, input().split())
  for j in range(W+1):
    dp[i+1][j] = dp[i][j]
  for j in range(W+1):
    if j+w <= W:
      dp[i+1][j+w] = max(dp[i+1][j+w], dp[i][j]+v)

ans = max( dp[n] )

print(ans)

Measured memory_bytes: 119916
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,m,dist[1010][1010] , dx[]={1,0,-1,0}, dy[]={0,1,0,-1}, vis[1010][1010] ;
string s[1010];

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   cin >> n >> m;
   priority_queue<pair< int, pi>> q;
   for(int i=1;i<=n;i++){
      cin >> s[i];
      s[i] = " "+s[i];
      for(int j = 1;j<=m;j++){
         if(s[i][j]=='#'){dist[i][j] = 0;q.push( { 0, {i, j} } );}
         else dist[i][j] = inf;
      }
   }

   while(!q.empty()){
      pi p = q.top().second;
      q.pop();
      int x = p.fs;
      int y = p.sc;
      if(vis[x][y])continue;
      vis[x][y]=1;
      for(int i=0;i<4;i++){
         int l = x+dx[i];
         int r = y+dy[i];
         if(l<1 || l>n || r>m || r<1 )continue;
         if(s[l][r]=='#')continue;
         if( dist[l][r] > dist[x][y]+1 ){
            dist[l][r] = dist[x][y]+1;
            q.push( { -dist[l][r], { l, r } } );
         }
      }
   }
   int ans = 0;
   for(int i=1;i<=n;i++){
      for(int j = 1;j<=m;j++){
         ans = max(ans, dist[i][j]);
      }
   }
   cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 41576
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

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


Measured memory_bytes: 384
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif (m == -1 or f == -1) or m+f < 30:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    vector<int> pos, neg;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a < 0) neg.push_back(-a);
        else pos.push_back(a);
    }

    long long ret = 1;
    if (k == n) {
        for (int i : pos)
            ret = ret * i % MOD;
        bool sgn = true;
        for (int i : neg) {
            ret = ret * i % MOD;
            sgn ^= 1;
        }
        if (!sgn)
            ret = ret * (MOD - 1) % MOD;
    } else if (pos.empty()) {
        if (k % 2) {
            ret = MOD - 1;
            sort(neg.begin(), neg.end());
        } else
            sort(neg.rbegin(), neg.rend());
        for (int i=0; i<k; i++)
            ret = ret * neg[i] % MOD;
    } else {
        sort(pos.rbegin(), pos.rend());
        sort(neg.rbegin(), neg.rend());
        int i = min((int) pos.size(), k), j = k - i;
        if (j % 2)
            i--, j++;
        while (j + 2 <= neg.size() && i >= 2 && (long long) neg[j] * neg[j+1] > (long long) pos[i-1] * pos[i-2])
            i -= 2, j += 2;
        for (int l=0; l<i; l++)
            ret = ret * pos[l] % MOD;
        for (int l=0; l<j; l++)
            ret = ret * neg[l] % MOD;
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 4376