akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int len = s.length();
        int streakLeft = 0;
        int streakRight = 0;
        int firstL = 0;
        int[] result = new int[len];
        for(int i=0; i<len; i++) {
            char c = s.charAt(i);
            char next = (i==len-1 ? 'R' : s.charAt(i+1));
            if(c=='R' && next=='L') {
                firstL = i+1;
            }
            if(c=='L' && next=='R') {
                streakRight = i;
                parseStreak(s, streakLeft, streakRight, firstL, result);
                streakLeft = i+1;
            }
        }
        for(int i=0; i<len-1; i++) {
            System.out.print(result[i]);
            System.out.print(" ");
        }
        System.out.println(result[len-1]);
    }
    private static void parseStreak(String s, int streakLeft, int streakRight, int firstL, int[] result) {
        int streakLength = streakRight - streakLeft + 1;
        int even = streakLength / 2; // round down
        int odd = even + (streakLength%2 == 1 ? 1 : 0);
        int r = even;
        int l = odd;
        if((firstL - streakLeft) % 2 == 1) {
            r = odd;
            l = even;
        }
        for(int i=streakLeft; i<=streakRight; i++) {
            if(i==firstL-1) {
                result[i] = r;
            }
            else if(i==firstL) {
                result[i] = l;
            }
            else {
                result[i] = 0;
            }
        }
    }
}


Measured memory_bytes: 45452
n = gets.chomp.to_i

h = Hash.new{|h,k| h[k] = Hash.new(0)}

1.upto(n) do |i|
  h[i.to_s[-1].to_i][i.to_s[0].to_i] += 1
end

ans = 0
1.upto(9) do |i|
  1.upto(9) do |j|
    ans += h[i][j] * h[j][i]
  end
end

p ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
const int N=100005;
using namespace std;
int n,tot,sg[N],head[N];
struct Edge{int u,v,next;}G[N<<1];
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
inline void addedge(int u,int v){
	G[++tot].u=u;G[tot].v=v;G[tot].next=head[u];head[u]=tot;
	G[++tot].u=v;G[tot].v=u;G[tot].next=head[v];head[v]=tot;
}
inline int dfs(int u,int f){
	sg[u]=0;
	for(int i=head[u];i;i=G[i].next){
		int v=G[i].v;if(v==f)continue;
		sg[u]=sg[u]^(dfs(v,u)+1);
	}
	return sg[u];
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		addedge(u,v);
	}
	dfs(1,0);
	if(sg[1])puts("Alice");else puts("Bob");
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 998244353;
ll ans = 1;
int a[maxn],n;

ll gcd(ll x,ll y){ 
	if ( !y ) return x;
	return gcd(y,x % y);
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a + 1,a + n + 1);
	rep(i,1,n) ans = ans * gcd(a[i],i - 1) % mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD (int)1e9+7
#define ll long long int
using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<bool> dp(k+1,false);
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0&&dp[i-a[j]]==false)
            {
                dp[i]=true;
            }

        }
        
    }
    cout<<(dp[k]?"First":"Second")<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}

signed main()
{
  int N, x; cin >> N >> x;
  vec<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }

  SORT(a);

  int ans = 0;
  rep(i, 0, N) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }

  if (x != 0 && ans == N) {
    ans = N-1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int a[5];
    int b;

    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    int min = 123;
    int min_index = 0;
    for (int i = 0; i < 5; i++) {
        if ((a[i] % 10) != 0 && (a[i] % 10) < min) {
            min = a[i] % 10;
            min_index = i;
        };
    }

    int res = 0;

    for (int i = 0; i < 5; i++) {
        if (i == min_index) {
            continue;
        }
        res += a[i];
        if (a[i] % 10 != 0) {
            res += 10 - (a[i] % 10);
        }
    }

    res += a[min_index];

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  string s1, s2;
  cin >> s1;
  cin >> s2;
  ok = false;
  s = s1;
  rep(i, s1.length()) {
	s = s[s1.length() - 1];
	s += s1.substr(0, s1.length()-1);
	s1 = s;
	if (s == s2) ok = true;
  }

  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <set>
#include <queue>

int main(void){
    Cin(int, n);
    Cin(string, s);
    
    for(char c0 : {'S', 'W'}) for(char c1 : {'S', 'W'}){
        string ans {c0, c1};
        for(int i = 2; i < n; i ++){
            ans += ((ans[i-2] == 'W') ^ (ans[i-1] == 'W') ^ (s[i-1] == 'x')) ? 'W' : 'S';
        }
        if((ans[n-1] == 'W') ^ (ans[  0] == 'W') ^ (ans[1] == 'W') ^ (s[  0] == 'x')) continue;
        if((ans[n-2] == 'W') ^ (ans[n-1] == 'W') ^ (ans[0] == 'W') ^ (s[n-1] == 'x')) continue;
        Cout(ans);
        return 0;
    }
    Cout(-1);
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int ba = sc.nextInt();
		int bb = sc.nextInt();
		int count = 0;
		if (ba > bb) {
			count += ba;
			ba--;
		} else {
			count += bb;
			bb--;
		}

		if (ba > bb) {
			count += ba;
			ba--;
		} else {
			count += bb;
			bb--;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b,c=0,d=10000000,e,f,g,h,n,m,mx=0,x,y;
  cin>>n;
  rep(i,0,n){
    cin>>a;
    while(1){
      if(a%2==0){
        c++;
        a/=2;
      }
      else break;
    }
    d=min(d,c);
    c=0;
  }
  co(d);
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int a[n];
  cin>>a[0];
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(a[i]==a[i-1]){
      a[i]=0;
      c++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
num = input()
l =[]

for i in range(num):
   l.append(int(raw_input()))

max = l[1] - l[0]
small = l[0]
for i in range(1, num):
   if small > l[i]:
      small = l[i]
   elif max < l[i] - small:
      max = l[i] - small
print max

Measured memory_bytes: 18916
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		char messengers[7];
		char message[26];
		cin >> messengers;
		cin >> message;
		int messengersNum = strlen(messengers);
		int messLen = strlen(message);
		for (int j = messengersNum - 1; j >= 0; j--)
		{
			char c = messengers[j];
			if (c == 'J')
			{
				char tmp = message[messLen - 1];
				for (int k = messLen - 1; k - 1 >= 0; k--)
				{
					message[k] = message[k - 1];
				}
				message[0] = tmp;
			}
			else if (c == 'C')
			{
				char tmp = message[0];
				for (int k = 0; k + 1 < messLen; k++)
				{
					message[k] = message[k + 1];
				}
				message[messLen - 1] = tmp;
			}
			else if (c == 'E')
			{
				if (messLen % 2 == 0)
				{
					int range = messLen / 2;
					for (int k = 0; k + range< messLen; k++)
					{
						char tmp = message[k];
						message[k] = message[k + range];
						message[k + range] = tmp;
					}
				}
				else
				{
					int range = messLen / 2 + 1;
					for (int k = 0; k  + range < messLen; k++)
					{
						char tmp = message[k];
						message[k] = message[k + range];
						message[k + range] = tmp;
					}
				}
			}
			else if (c == 'A')
			{
				for (int k = 0; k < messLen - k; k++)
				{
					char tmp = message[k];
					message[k] = message[messLen - 1 - k];
					message[messLen - 1 - k] = tmp;
				}
			}
			else if (c == 'P')
			{
				for (int k = 0; k< messLen; k++)
				{
					if (message[k] >= '0' && message[k] <= '9')
					{
						message[k]--;
						if (message[k] < '0')
						{
							message[k] = '9';
						}
					}
				}
			}
			else if (c == 'M')
			{
				for (int k = 0; k< messLen; k++)
				{
					if (message[k] >= '0' && message[k] <= '9')
					{
						message[k]++;
						if (message[k] > '9')
						{
							message[k] = '0';
						}
					}
				}
			}
		}

		cout << message << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N + 1);
    vector<vector<int>> dist(N, vector<int>(N, inf));
    for (int i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        for (int j = 0; j < N; j++) {
            if (temp[j] == '1') {
                dist[i][j] = 1;
                G[i].push_back(j);
            }
        }
    }
    vector<int> bipartite(N + 1, -1);
    bool flag = false;
    function<void(int, int)> check = [&](int next, int count) {
        if (bipartite[next] != -1) {
            if (bipartite[next] != count) flag = true;
            return;
        }
        bipartite[next] = count;
        for (auto i : G[next]) check(i, count ^ 1);
    };
    check(0, 0);
    if (flag) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) dist[i][i] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, *max_element(dist[i].begin(), dist[i].end()));
    cout << ans + 1 << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

#define INF (1LL<<62)

using namespace std;

typedef long long ll;


int main(void){
  
  int a,b,c,d,e;
  while(cin >> a >> b >> c >> d >> e,(a||b||c||d||e)) {
    ll na,nb,nc;
    cin >> na >> nb >> nc;
    
    ll ans=INF,n=na+nb+nc, tna=na,tnb=nb,tnc=nc;
    ll acnt=0,bcnt=0,ccnt=0;
    
    for(int r=0;r<=n;r++){

      if(ccnt<nc && ccnt<r && tnc)tnc--,ccnt++;
      else if(bcnt<nb && bcnt+ccnt<r && tnb)tnb--,bcnt++;
      else if(acnt<na && acnt+bcnt+ccnt<r && tna)tna--,acnt++;

      if(r>=d)ans=min(ans,tna*a+tnb*b+tnc*c+r*e);
      else if(r<d && d*e<(a*acnt+b*bcnt+c*ccnt))ans=min(ans,tna*a+tnb*b+tnc*c+d*e);
      else ans=min(ans,na*a+nb*b+nc*c);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1164
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf 
count = 0; pro = 1

n, k = map(int, input().split())
A=[]; B=[]
x=list(map(int,input().split()))
for i in range(n-(k-1)):
    candi = max(abs(x[i+k-1]),abs(x[i]))
    if x[i+k-1]*x[i]<0:
        candi += 2*min(abs(x[i+k-1]), abs(x[i]))

    ans = min(ans, candi)
print(ans)


Measured memory_bytes: 15324
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;
int dp[20][20];
int k,flag;
int dfs(int x,int y){
	int &ans=dp[x][y];
	if(~ans)return ans;
	if(y==1)return ans=1;
	ans=dfs(x,y-1);
	if(x+1<10)ans+=dfs(x+1,y-1);
	if(x-1>=0)ans+=dfs(x-1,y-1);
	return ans;
}
void work(int x,int y){
	if(y==1&&k==1){
		printf("%d",x);
		return ;
	}
	if(k>dfs(x,y)){
		k-=dfs(x,y);
		if(x==9)work(!flag,y+1);
		else work(x+1,y);
	}
	else {
		flag=1;
		printf("%d",x);
		if(x)work(x-1,y-1);
		else work(0,y-1);
	}
}
void solve(){
	scd(k);
	mst(dp,-1);
	work(1,1);
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
import fractions

N,X = map(int, input().split())
x = list(map(int, input().split()))

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

for i in range(len(x)):
    x[i] = abs(x[i]-X)

print(gcd_list(x))



Measured memory_bytes: 16192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x[4],y[4],t;
	cin>>x[0]>>y[0]>>x[1]>>y[1];
	t=y[1]-y[0];
	x[2]=x[1]-t;x[3]=x[0]-t;
	t=x[1]-x[0];
	y[2]=y[1]+t;
	y[3]=y[0]+t;
	cout<<x[2]<<" "<<y[2]<<" ";
	cout<<x[3]<<" "<<y[3];
	return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  string s;
  cin >> s;

  int ans = 1;
  REP(i, s.size()){
    if(i%2 == 0 && s[i] == 'L') ans = 0;
    if(i%2 == 1 && s[i] == 'R') ans = 0;
  }

  if(ans) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(long long X){
    while(1){
        bool flag = true;
        for(int i=2; i*i<X;i++){
            if(X%i==0) flag=false;
        }    
        if(flag){
            cout<<X<<endl;
            break;
        } else X++;
    }
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
def abc082_c():
    from collections import Counter

    _ = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a_count = Counter(a)

    for num in a_count:
        if num <= a_count[num]:
            ans += (a_count[num] - num)
        else:
            ans += a_count[num]

    print(ans)


abc082_c()

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

using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAXN 201010
typedef long long int ll;
typedef pair<int, int> pii;

int main(){
	int v[5];
	int ans = 1010101010, aux;
	cin >> v[0] >> v[1] >> v[2];
	
	sort(v, v + 3);
	do
	{
		int aux = abs(v[1] - v[0]) + abs(v[2] - v[1]);
		ans = min(ans, aux);
	} while (next_permutation(v, v + 3));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int S, h, m, s;
    
    scanf("%d", &S);
    
    if (S >= 3600) {
        for (h = 0; S >= 3600; h++) {
            S -= 3600;
        }
    } else {
        h = 0;
    }
    
    if (S >= 60) {
        for (m = 0; S >= 60; m++) {
            S -= 60;
        }
    } else {
        m = 0;
    }
    
    s = S;
    
    printf("%d:%d:%d\n", h, m, s);
}



Measured memory_bytes: 2140
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn solve(y: i32, x: i32, map: &mut Vec<Vec<i32>>, cnt: usize, sy: i32, sx: i32) -> i32 {
    let h = map.len() as i32;
    let w = map[0].len() as i32;
    if cnt == 0 {
        if sy == y || x == sx {
            return 1
        } else {
            return 0
        }
    }

    let mut ans = 0;
    let dx = [0, 1, 0, -1];
    let dy = [1, 0, -1, 0];
    for d in 0..4 {
        let mut ny = y;
        let mut nx = x;
        loop {
            ny += dy[d]; nx += dx[d];
            if ny < 0 || ny >= h || nx < 0 || nx >= w {
                break;
            }
            let ny = ny as usize;
            let nx = nx as usize;
            if map[ny][nx] == 1 {
                map[ny][nx] = -1;
                ans += solve(ny as i32, nx as i32, map, cnt - 1, sy, sx);
                map[ny][nx] = 1;
                break;
            }
        }
    }
    ans
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let (m, n): (usize, usize) = (sc.read(), sc.read());
        if (m, n) == (0, 0) {
            break;
        }
        let mut map: Vec<Vec<i32>> = vec![vec![0; m]; n];
        let mut cnt = 0;
        let (mut sy, mut sx) = (0, 0);
        for i in 0..n {
            for j in 0..m {
                map[i][j] = sc.read();
                if map[i][j] == 2 {
                    sy = i as i32; sx = j as i32;
                }
                if map[i][j] == 1 {
                    cnt += 1;
                }
            }
        }
        let cnt = cnt;

        println!("{}", solve(sy, sx, &mut map, cnt, sy, sx));
    }
}


Measured memory_bytes: 5032
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

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

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

int main() {
    ll N, T, ans = 1;
    cin >> N;
    REP(i, N) {
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<int,int> P;
typedef complex<double> CP;
typedef long long ll;


int sti[40][10];
int n,m,h,d;
char t;
int hor[40][11];
vector <P> vec;

void swap(int a,int b,int c){
	int t;
	t=sti[c][a];
	sti[c][a]=sti[c][b];
	sti[c][b]=t;
	return;
}

int main(){
	while(cin>>n,n){
		cin>>m>>h>>d;
		rep(i,n){
			sti[0][i]=i;
		}
		rep(i,d){
			rep(j,n){
				sti[i+1][j]=sti[i][j];
			}
			
			rep(j,n-1){
				cin>>t;
				hor[i+1][j]=t-'0';
				if(t-'0'==1){
					swap(j,j+1,i+1);
				}
			}
		}
		bool f=false;
		rep(i,n){
			if(sti[d][i]==m-1&&i==h-1){
				cout<<0<<endl;
				f=true;
			}
		}
		
		rep(i,d){
			rep(j,n-1){
				if(j==0){
					if(hor[i+1][j]==0&&hor[i+1][j+1]==0){
						vec.PB(P(i+1,j));
					}
				}
				else if(j==n-2){
					if(hor[i+1][j-1]==0&&hor[i+1][j]==0){
						vec.PB(P(i+1,j));
					}
				}
				else if(hor[i+1][j-1]==0&&hor[i+1][j]==0&&hor[i+1][j+1]==0){
					vec.PB(P(i+1,j));
				}
			}
		}
		/*
		rep(i,d+1){
			rep(j,n){
				cout<<sti[i][j]<<" ";
			}
			cout<<endl;
		}
		cout<<endl;
		*/
		//cout<<sti[d][h-1]<<" "<<m-1<<endl;
		rep(i,vec.size()){
			int a=vec[i].F,b=vec[i].S;
			//cout<<a<<" "<<b<<"    "<<sti[a][b]<<" "<<sti[a][b+1]<<endl;
			if(sti[a][b+1]==sti[d][h-1]&&sti[a][b]==m-1||sti[a][b]==sti[d][h-1]&&sti[a][b+1]==m-1){
				cout<<a<<" "<<b+1<<endl;
				f=true;
				break;
			}
		}
		if(!f) cout<<1<<endl;
		vec.clear();
		//cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
map<ll,ll> bag,keep;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,W;cin>>n>>W;
bag[0]=0;
vector<ll> w(n),v(n);
for(int i=0;i<n;i++)cin>>w[i]>>v[i];
for(int i=0;i<n;i++){
    for(auto p: bag){
    if(p.fi+w[i]>W)continue;
   keep[p.fi+w[i]]=max(bag[p.fi+w[i]],p.se+v[i]);
  }
 for(auto p: keep){
   bag[p.fi]=p.se;
 }
 keep.clear();
}
ll ans=0;
for(auto p: bag){
  //cout<<p.fi<<" "<<p.se<<endl;
  chmax(ans,p.se);
}
cout<<ans<<endl;
}


Measured memory_bytes: 896
#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>;


int main() {
    vector<vector<int>> A(3, vector<int> (3));
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b[i];

    rep(i, 3) rep(j, 3) rep(k, N) {
        if (A[i][j] == b[k]) A[i][j] = 0;
    }

    bool ok = false;
    rep(i, 3) {
        if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) ok = true;
        if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) ok = true;
    }
    if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) ok = true;
    if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) ok = true;
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long d = n%k;
        System.out.println(Math.min(d, k-d));
        sc.close();

    }

}


Measured memory_bytes: 21716
#! python3
# print_a_frame.py

while True:
    H, W = [int(x) for x in input().split(' ')]
    if H == 0 and W == 0: break

    for i in range(H):
        if i == 0 or i == H-1:
            print('#'*W)
        else:
            print('#' + '.'*(W-2) + '#')

    print('')



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

using namespace std;

int b[111111];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		b[i + 1] = (b[i] + a) % m;
	}
	sort(b, b + n + 1);
	long r = 0;
	m = 1;
	for (int i = 0; i < n; i++) {
		if (b[i] != b[i + 1])
			m = 0;
		r += m++;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    rep(i,5) {
        if (a[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3552
/*
  Contest 116
  B - Collatz Problem
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    int s = 0;
    std::cin >> s;
    std::unordered_map<int, bool> dict;
    dict[s] = true;
    int count = 1;
    while (1) {
        if (s & 1)
            s = (3 * s) + 1;
        else
            s >>= 1;
        ++count;
        if (dict.find(s) != dict.end()) {
            std::cout << count << std::endl;
            return 0;
        }
        dict[s] = true;
    }

    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = 0;
            int input_num = int.Parse(Console.ReadLine());
            char[] char_num = input_num.ToString().ToCharArray();

            foreach(var x in char_num)
            {
                num += (int)x - (int)'0';
            }

            if (input_num % num == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}


Measured memory_bytes: 13140
n,l=map(int,input().split())

aji = [l+i for i in range(n)]
ans = None
sa=10**10
for i in range(n):
    sa_tmp=abs(aji[i])
    if sa>sa_tmp:
        sa=sa_tmp
        ans=sum(aji)-aji[i]
print(ans)


Measured memory_bytes: 9124
a = 5.times.map { gets.to_i }.sort_by { |aa| i = aa.to_s[-1].to_i; i == 0 ? 10 : i }

ans = a[0]
1.upto(4) do |i|
  ans += a[i]
  ii = a[i].to_s[-1].to_i
  if ii > 0
    ans += 10 - ii
  end
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int N=100005;
int n,L,a[N];
void work(int x) {
	puts("Possible");
	for(RI i=1;i<x;++i) printf("%d\n",i);
	for(RI i=n-1;i>x;--i) printf("%d\n",i);
	printf("%d\n",x);
}
int main()
{
	n=read(),L=read();
	for(RI i=1;i<=n;++i) a[i]=read();
	for(RI i=1;i<n;++i)
		if(a[i]+a[i+1]>=L) {work(i);return 0;}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 1152
/**
 * @author khokharnikunj8
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class AACOrWA {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        out << (n == m ? "Yes" : "No") << "\n";
    }
};


int main() {
    AACOrWA solver;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
l, r = map(int, input().split())

mod = 2019

ans = 2222

if (r - l) // mod > 0:
	ans = 0

else:
	ans = 2020
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			ans = min(ans, (i % mod) * (j % mod) % mod)

print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int left;
  left = A+B;
  
  int right;
  right = C+D;
 
  if (left == right) {
    cout << "Balanced" << endl;
  }else if(left > right){
    cout << "Left" << endl;
  }else{
     cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>
#include <numeric>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    int a;
    int b;
    int i;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.a) == (riRight.a)){
            return riLeft.b < riRight.b;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.a) < (riRight.a);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}

//int n;
////int dat[2*10000000];
////int dat2[2*10000000];
//int dat[10];
//int dat2[10];
//
//void init(int n_){
//    n=1;
//    while(n<n_)n*=2;
//    for(int i=0;i<2*n-1;i++){
//        dat[i]=0;
//        dat2[i]=0;
//    }
//}
//
//void initset(int k,int a){
//    k+=n-1;
//    dat[k]=a;
//    while(k>0){
//        k=(k-1)/2;
//        dat[k]=dat[k*2+1]+dat[k*2+2];
//    }
//}
//
////[a,b)の間を[l,r]区間で比較しアップデート
////引数のindexに注意
////nは固定。initで計算すみ
////update2(L[i],R[i]+1,0,0,n,D[i]);
//void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
//    if(r<=a || b<=l)return;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=v*(r-l);
//        return;
//    }else{
//        update2(a,b,k*2+1,l,(l+r)/2,v);
//        update2(a,b,k*2+2,(l+r)/2,r,v);
//        return;
//    }
//}
//
//int query(int a,int b,int k,int l,int r){
//    if(r<=a || b<=l)return 0;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=0;
//        return dat[k];
//    }
//    else{
//        int vl=query(a,b,k*2+1,l,(l+r)/2);
//        int vr=query(a,b,k*2+2,(l+r)/2,r);
//        return vl+vr;
//    }
//}



//void printb(unsigned int v) {
//    unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
//    do putchar(mask & v ? '1' : '0');
//    while (mask >>= 1);
//}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs("a.txt");//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s,t;
    cin>>s>>t;
    

    cout << t+s << endl;
    //ここまで
    //cout << "ans" << endl;
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}


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

int num_digits(ll x) {
  int cnt = 0;
  while (x != 0) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

bool is_integer(double x) {
  return x == floor(x);
}

int main() {
  ll n;
  cin >> n;
  ll Max_div;
  for (ll i = 1LL; i*i <= n; i++) {
    if (is_integer((long double)n/i)) {
      Max_div = i;
    }
  }
  cout << max(num_digits(Max_div), num_digits(n/Max_div)) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int a[N];

int main()
{
	int n; scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < n; i++) scanf("%d", a+i), sum ^= a[i];
	for (int i = 0; i < n; i++) printf("%d ", sum ^ a[i]);
	return 0;
}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    int a[n+2]={0};
    for(int i=0;i<n;i++)
      cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
from scipy.sparse import*;N,M,*A=map(int,open(0).read().split());g=csr_matrix(([1]*M,(A[::2],A[1::2])),shape=(N+1,N+1)).tolil();c=0
for a,b in zip(*g.nonzero()):g[a,b]=0;n,_=csgraph.connected_components(g);c+=n!=2;g[a,b]=1
print(c)

Measured memory_bytes: 13800
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/

int main()
{
    long long int A, B, N;

    scanf("%lld%lld%lld", &A, &B, &N);

    long long int x = MIN(B - 1, N);

    printf("%lld", (A*x)/B - A*(x/B));
}

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[364364]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n%2==0){
        for(int i=n-1;i>=1;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=0;i<n-1;i+=2){
            cout<<a[i];
            if(i==n-2){
                cout<<endl;
            }else{
                cout<<" ";
            }
        }
    }else{
        for(int i=n-1;i>=0;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=1;i<n-1;i+=2){
            cout<<a[i];
            if(i==n-2){
                cout<<endl;
            }else{
                cout<<" ";
            }
        }
    }
}   





Measured memory_bytes: 3584
A, B, C = map(int, input().split())
K = int(input())

while A >= B:
    B *= 2
    K -= 1
    if K < 0:
        print("No")
        exit()
while B >= C:
    C *= 2
    K -= 1
    if K < 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;

int inf = 1e9;

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

  ll n, m;
  cin >> n >> m;

  int a, b, c;
  vvi d(n, vi(n, inf)), e(n, vi(n, -1));

  REP(i, n) d[i][i] = 0;
  REP(i, m){
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = d[b][a] = c;
    e[a][b] = e[b][a] = c;
  }

  REP(k, n){
    REP(i, n){
      REP(j, n){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 0;
  REP(i, n){
    REP(j, n){
      if(d[i][j] < e[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int x, a, b;
  	cin >> x >> a >> b;
	int temp = x-a;
  	cout << temp%b << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}


#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }


// ---- ----

int n, k;
bool ans = true;
vector<int> vec[100000];
bool has[100000];
int mi[100000];
int ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		if(has[x] && (mi[x] - mi[y]) % 2 == 0) { ans = false; }
		setmax(mi[x], mi[y] - 1);
		setmin(ma[x], ma[y] + 1);
		has[x] = true;
		if(mi[x] > ma[x]) { ans = false; }
	}
}

void dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && i : vec[node]) {
		if(i != pre) {
			dfs(i, node);
			prod(node, i);
		}
	}
}

int main() {
	// scanf("%d", &n);
	reader(&n);
	inc(i, n - 1) {
		int a, b;
		//scanf("%d%d", &a, &b);
		reader(&a, &b);
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	fill(mi, mi + n, -1000000);
	fill(ma, ma + n,  2000000);
	// scanf("%d", &k);
	reader(&k);
	inc(j, k) {
		int v, p;
		// scanf("%d%d", &v, &p);
		reader(&v, &p);
		v--;
		mi[v] = p;
		ma[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	printf("%s\n", ans ? "Yes" : "No");
	if(ans) {
		inc(i, n) {
			// printf("%d\n", mi[i]);
			writerLn(mi[i]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n, sum = 0, ans = 0;
    cin >> n;
    vector<ll> v(n);
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        sum += b;
        v[i] = a + b;
    }
    sort(ALL(v), greater<ll>());
    for (ll i = 0; i < n; i += 2)
    {
        ans += v[i];
    }
    ans -= sum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);
    int N; // 1 20
    cin >> N;
    vector<int> V(N), C(N); // vi ci 1 50
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    int res = 0; // select none
    int maske = 1 << N;
    for(int mask = 1; mask < maske; mask++){
        int X = 0, Y = 0; // <= 50 * 20
        for(int i = 0; i < N; i++){
            if((mask >> i) & 1){
                X += V[i];
                Y += C[i];
            }
        }
        res = max(res, X - Y);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256