akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
ans=1
if n==1:
    print(ans)
    exit()
c=0#1なら増加傾向、2なら減少傾向
for i in range(n):
    if i!=n-1:
        if c==1:
            if a[i+1]<a[i]:
                ans+=1
                c=0
                continue
        elif c==2:
            if a[i+1]>a[i]:
                ans+=1
                c=0
                continue
        
        if a[i+1]>a[i]:
            c=1
        elif a[i+1]<a[i]:
            c=2
print(ans)

Measured memory_bytes: 14228
#include <stdio.h>

#define MAX 25

struct Node{
  int parent;
  int right;
  int left;
  int degree;
};

int n;
struct Node u[MAX];

int sibling(int);
int depth(int);
int height(int);

int main(){
  int i,id,r,l;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].parent=-1;
    u[i].right=-1;
    u[i].left=-1;
    u[i].degree=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    u[id].left=l;
    u[u[id].left].right=r;
    if(u[id].left!=-1){
      u[u[id].left].parent=id;
      u[id].degree++;
    }
    if(u[u[id].left].right!=-1){
      u[u[u[id].left].right].parent=id;
      u[id].degree++;
    }
  }

  for(i=0;i<n;i++){
    if(u[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,u[i].degree,height(i));

    else if(u[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),u[i].degree,depth(i),height(i));

    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,sibling(i),u[i].degree,depth(i),height(i));
  }

  return 0;
}

int sibling(int x){
  if(u[x].right!=-1) return u[x].right;
  else if(u[u[x].parent].left!=x) return u[u[x].parent].left;
  else return -1;
}

int depth(int x){
  int d=0,p;
  p=u[x].parent;

  while(p!=-1){
    p=u[p].parent;
    d++;
  }

  return d;
}

int height(int x) {
  int i,h=0,y;
 
  for(i=0;i<n;i++) {
    if(u[i].parent==x) {
      y=height(i)+1;
      if(y>h) h=y;
    }
  }
 
  return h;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;

int main() {
 int A,B;
 cin>>A>>B;
 if(A%3==0||B%3==0||(A+B)%3==0){cout<<"Possible"<<endl;}
 else{cout<<"Impossible"<<endl;}
return 0;}

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

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

template <class T, class Op = multiplies<>>
constexpr T power(T a, uint64_t n, T init = 1, Op op = Op{}) {
  while (n) {
    if (n & 1) init = op(init, a);
    if (n >>= 1) a = op(a, a);
  }
  return init;
}

template <uint32_t M>
struct modular {
  using T = modular;
  static constexpr uint32_t mod = M;
  uint32_t v;
  modular(int64_t x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  T operator-() const { return T() -= *this; }
  T& operator+=(T b) { return (int)(v += b.v - mod) < 0 ? v += mod : v, *this; }
  T& operator-=(T b) { return (int)(v -= b.v) < 0 ? v += mod : v, *this; }
  T& operator*=(T b) { return v = (uint64_t)v * b.v % mod, *this; }
  T& operator/=(T b) { return *this *= power(b, mod - 2); }
  friend T operator+(T a, T b) { return a += b; }
  friend T operator-(T a, T b) { return a -= b; }
  friend T operator*(T a, T b) { return a *= b; }
  friend T operator/(T a, T b) { return a /= b; }
  friend bool operator==(T a, T b) { return a.v == b.v; }
};

using mint = modular<998244353>;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (auto&& e : a) cin >> e;
  auto inv = mint(1) / accumulate(begin(a), end(a), 0);
  vector<mint> f(1 << n);
  auto fwht = [&] {
    for (int s = 0; s < n; ++s)
      for (int i = 0; i < 1 << n; ++i) {
        if (i >> s & 1) continue;
        int j = i | 1 << s;
        auto x = f[i], y = f[j];
        f[i] = x + y;
        f[j] = x - y;
      }
  };
  for (int i = 1; i < 1 << n; ++i) f[i] = -a[i] * inv;
  f[0] = -accumulate(begin(f), end(f), mint());
  fwht();
  for (int i = 1; i < 1 << n; ++i) f[i] = -1 / f[i];
  f[0] = -accumulate(begin(f), end(f), mint());
  fwht();
  for (auto&& e : f) cout << e.v << '\n';
}


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

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	int count;
	count = 1;
	for (int i = 0; i < N; i++) {
		int x;
		x = vec.at(0);
		if (vec.at(0) == 2) {
			cout << count << endl;
			break;
		}
		else {
			vec.at(0) = vec.at(x - 1);
			count++;
		}
	}
	if (count == N + 1)
		cout << -1 << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<pi> hp;
	rep(i, n){
		int h, p; cin >> h >> p;
		hp.emplace_back(h, p);
	}
	sort(all(hp),[]
		(pi a, pi b){
			return a.first + a.second < b.first + b.second;
		});
	vector<ll> dp(1);
	rep(i, n){
		vector<ll> next = dp;
		next.resize(i + 2); next[i + 1] = 1e18;
		rep(j, i + 1) if(dp[j] < 1e18){
			if(dp[j] <= hp[i].first)
			next[j + 1] = min(next[j + 1], dp[j] + hp[i].second);
		}
		dp = next;
	}
	for(int i = n; i >= 0; i--) if(dp[i] < 1e18){
		cout << i << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;

int main(){
    cin >> s;
    if(s.substr(0,4)=="YAKI"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 768
#include <iostream>
#include <deque>
#include <vector>
#include <cmath>
#define inf 99999999
using namespace std;
int a,b;
int max1;
deque<int> ha[100010];
deque<int> dp(100010);
deque<int> vis(100010);
int cal(int idx){
    if(vis[idx]) return dp[idx];
    while(!ha[idx].empty()){
        int a=ha[idx].front();
        ha[idx].pop_front();
        dp[idx]=max(dp[idx],1+cal(a));
    }
    vis[idx]=true;
    return dp[idx];
}
int main()
{
    int temp1;
    int temp2;
    while(cin>>a>>b){
        fill(dp.begin(),dp.end(),0);
        fill(vis.begin(),vis.end(),false);
        for(int i=1;i<=b;i++){
            cin>>temp1>>temp2;
            ha[temp1].push_back(temp2);
        }
        for(int i=1;i<a+1;i++){
            cal(i);
        }
        int max1=0;
        for(int i=0;i<dp.size();i++){
            if(dp[i]>max1){
                max1=dp[i];
            }
        }
        cout<<max1<<endl;
    }
}


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

function main()
	n,k = readline() |> split |> parseMap
	h = readline() |> split |> parseMap
	dp = 10^18*ones(Int,n+1,k+1,n+1)
	dpm = 10^18*ones(Int,n+1,k+1)
	dp[1,1,1] = 0
	dpm[1,1] = 0
	for i in 1:n
		for j in 1:k+1
			for m in 0:i-1
				if i-m+j-2<=k
					tmp = m>0?h[i]-h[m]:h[i]
					dp[i+1,i-m+j-1,m+1] = min(dp[i+1,i-m+j-1,m+1],dpm[m+1,j]+max(tmp,0))
					dpm[i+1,i-m+j-1] = min(dpm[i+1,i-m+j-1],dp[i+1,i-m+j-1,m+1])
				end
			end
		end
	end
	s = 10^18
	for i in 1:k+1
		for j in 1:n+1
			s = min(s,dp[n+1,i,j])
		end
	end
	for i in 0:k
		s = min(s,dpm[n-k+i+1,i+1])
	end
	println(s)
end

main()

Measured memory_bytes: 541072
#include <bits/stdc++.h>
using namespace std;
queue<unsigned long long> q;
int k,sum,last;
int main() 
{
	cin>>k;
	k-=1;
	for(int i=1;i<=9;i++)
	q.push(i);
   while(k--)
   {
   	unsigned long long temp=q.front();
   	q.pop();
   	int m=temp%10;
   	if(m!=0)
   	  q.push(temp*10+m-1);
   	q.push(temp*10+m);
   	if(m!=9)
   	  q.push(temp*10+m+1);
   }
   cout<<q.front(); 
	return 0;
}

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

const int N = 55;

int m[N][N];
int out[N][N];

int h, w;

bool checkRange(int i, int j) {
  return (i >= 0 && i < h && j >= 0 && j < w);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    string s; cin >> s;
    for (int j = 0; j < (int)s.size(); j++) {
      if (s[j] == '.') m[i][j] = 0;
      else m[i][j] = 1;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int cnt = 0;
      for (int x = -1; x < 2; x++) {
	for (int y = -1; y < 2; y++) {
	  if (x == 0 && y == 0) continue;
	  if (!checkRange(i + x, j + y)) continue;
	  if (m[i + x][j + y] == 1) cnt++;
	}
      }
      out[i][j] = cnt;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (m[i][j] == 1) cout << '#';
      else cout << out[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
const int MAXN = 1000;
int main(void)
{
	int d[MAXN],a[MAXN][MAXN],vis[MAXN],p[MAXN];
	int n,ans = 0,cnt = 0;
	scanf("%d",&n);
	for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) scanf("%d",&a[i][j]);
	for(int i = 0;i < n;i++)
	{
		vis[i] = 0;
		p[i] = -1;
		d[i] = 2001;
	}
	d[0] = 0;
	while(true)
	{
		int u = -1,minv = 2001;
		for(int i = 0;i < n;i++)
		{
			if(d[i] < minv && !vis[i])
			{
				u = i;
				minv = d[i];
			}	
		}
		if(u == -1) break;
		cnt++;
		vis[u] = 1;
		for(int v = 0;v < n;v++)
		{
			if(!vis[v] && a[u][v] != -1)
			{
				if(d[v] > a[u][v])
				{
					d[v] = a[u][v];
					p[v] = u;
				}
			}
		}
	}
	for(int i = 0;i < n;i++) if(p[i] != -1) ans += a[i][p[i]];
	printf("%d\n",(cnt == n)?ans:-1);
	return 0;
}


Measured memory_bytes: 3564
#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() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if (a + b + 2*sqrtl(a*b) < c) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 384
N, A, B = map(int, input().split())
l = []
ans = 0

for n in range(1, N+1):
    count = 0
    n_list = n
    while True:
        count += n%10
        n = n//10
        if n==0:
            break

    if A<= count <=B:
        l.append(n_list)

for i in l:
    ans += i

print(ans) 

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define int long long
#define endl '\n'
#define pi 3.14159265
ll n,m;
vector<ll> tmp;
ll val=0;
ll parent[200000],si[200000];
int fin(int v)
{
    if (v == parent[v])
        return v;
    return parent[v] = fin(parent[v]);
}
void uni(int a, int b)
{
    a = fin(a);
    b = fin(b);
    if (a != b) {
        if (si[a] < si[b])
            swap(a, b);
        parent[b] = a;
        val-=si[a]*si[b];
        tmp.push_back(val);
        si[a] += si[b];
    }
}
int32_t main()
{           
    IOS;
    cin>>n>>m;
    ll x[m],y[m];
    for(ll i=1;i<=n;i++)
    {
        parent[i]=i;
        si[i]=1;
    }
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        x[i]=a;
        y[i]=b;
    }
    val=n*(n-1)/2;
    tmp.push_back(val);
    for(ll i=m-1;i>=0;i--)
    {
        if(fin(x[i])==fin(y[i]))
        {
            tmp.push_back(val);
            continue;
        }
        uni(x[i],y[i]);   
    }
    for(ll i=m-1;i>=0;i--)
        cout<<tmp[i]<<" ";
} 

Measured memory_bytes: 5364
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long  n,h;
const int N = 1e5+5;
int a[N];
set<pair<int,int> > v;
int main() {
	IO
    cin>>n>>h;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<h;i++)
    {
        int x,y;
        cin>>x>>y;
        v.emplace(x,y);
    }
    int ans=0;
    int i=0;
    int freq[N];
    fill(freq,freq+N,1);
    for(auto x : v)
    {
//        cout<<" : "<<x.first<<" :"<<a[x.first-1]<<" "<<x.second<<" :"<<a[x.second-1]<<endl;
        if(a[x.first-1]>a[x.second-1]&&freq[x.first-1])ans++;
        else
            freq[x.first-1]=0;
        if(a[x.first-1]<a[x.second-1]&&freq[x.second-1])ans++;
        else
            freq[x.second-1]=0;
    }
    int cnt=0;
    for(int i=0;i<n;i++)
        if(freq[i]>0)cnt++;
    cout<<cnt<<endl;

    return 0;
}


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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> sizes; // size[i]:iの属する木の要素数

  UnionFind(int N) : par(N), sizes(N,1) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x){
      return x;
    }
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]>sizes[ry]){ // 小さい方を大き方にくっつける
      par[ry]=rx;
      sizes[rx]+=sizes[ry];
    }
    else{
      par[rx]=ry;
      sizes[ry]+=sizes[rx];
    }
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }

  int size(int x){
    return sizes[x]=sizes[root(x)];
  }
};

int main(){
  int N,M,K;
  cin >> N >> M >>K;
  UnionFind fri(N);
  vector<int> frinum(N,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    --a;
    --b;
    fri.unite(a,b);
    frinum[a]++;
    frinum[b]++;
  }
  vector<set<int>> block(N);
  for(int i=0;i<K;i++){
    int c,d;
    cin >> c >> d;
    --c;
    --d;
    block[c].insert(d);
    block[d].insert(c);
  }
  for(int i=0;i<N;i++){
    int count=fri.size(i)-frinum[i]-1;
    if(!block[i].empty()){
      for(int x:block[i]){
        if(fri.same(i,x)){
          --count;
        }
      }
    }
    cout << count;
    if(i!=N-1){
      cout << " ";
    }
    else{
      cout << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 18452
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int n;
  int m;
  int count=0;
  scanf("%d",&n);
  int a[n];
  for(m=0;m<n;m++){
    scanf("%d",&a[m]);
    if(a[m]%2 == 1){
      count++;}
  }
  if(count%2 == 0){
    printf("YES");}
  else{
    printf("NO");}
  return 0;
}


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

#define int long long

int32_t main(){
	int s , n ;
	cin >> s >> n ;
	for(int i = 0 ; i < n ; i++){
		int x ;
		cin >> x ;
		s -= x ;
	}
	if(s <= 0){
		cout << "Yes" ;
	} else {
		cout << "No" ;
	}
	return 0 ;
}



Measured memory_bytes: 256
import numpy

n, a, b = map(int, input().split())
v = list(map(int, input().split()))

v.sort()

res = numpy.average(v[n - a:])
x = min(v[n - a:])

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if v[n - 1] != x:
    print(res)
    c = v[n-a:].count(x)
    m = v.count(x)
    print(cmb(m, c))
else:
    print(res)
    ans = 0
    m = v.count(x)
    for i in range(a, min(m, b) + 1):
        ans += cmb(m, i)
    print(ans)



Measured memory_bytes: 12580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by Reopard on 2014/05/06.
 */
public class Main {
    public static void main(String args[]) {
        long a, b, gcd, lcm;
        String line;
        String number[];
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while((line = reader.readLine()) != null){
                number = line.split(" ");
                a = Long.parseLong(number[0]);
                b = Long.parseLong(number[1]);
                if(a > b) gcd = GCD(a, b);
                else gcd = GCD(b, a);
                lcm = a*b/gcd;
                System.out.println(gcd + " " + lcm);
            }
        }catch(IOException e){
            System.exit(0);
        }
    }

    static long GCD(long a, long b){
        long tmp;
        if(a%b != 0){
            tmp = GCD(b, a%b);
        }else return b;
        return tmp;
    }
}

Measured memory_bytes: 16932
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()
{
	fast
	string n;
	cin>>n;
	if(n.find('7')!=string::npos)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3672
N,K=map(int,input().split())
sum_value = 0
for i in range(1,N+1):
    if(i>=K):
        sum_value = sum_value+1/N
    else:
        for j in range(1,18):
            if(i*(2**j)>=K):
                sum_value=sum_value+((1/N)*(1/(2**j)))
                break
print(sum_value)


Measured memory_bytes: 2940
### ABC107 B - Grid Compression
h, w = map(int, input().split())
grid = [[x for x in str(input())] for _ in range(h)]

del_h = [False] * h
del_w = [False] * w

for i in range(h):
  if grid[i].count('#') == 0:
    del_h[i] = True

for j in range(w):
  del_w[j] = True
  for i in range(h):
    if grid[i][j] == '#':
      del_w[j] = False
      break

for i in range(h):
  if del_h[i]: continue
  row = ''.join([grid[i][j] for j in range(w) if not del_w[j]])
  print(row)

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0104&lang=jp
"""
import sys


class MagicalTiles():
    def __init__(self, data):
        self.map = data[:]
        self.pos = (0, 0)
        self.path = [(0, 0)]
        self.mark = self.map[0][0]
        self.loop = False

    def move(self):
        x, y = self.pos[0], self.pos[1]
        self.mark = self.map[y][x]
        if self.mark == '>':
            x += 1
        elif self.mark == '<':
            x -= 1
        elif self.mark == '^':
            y -= 1
        elif self.mark == 'v':
            y += 1
        if self.mark != '.' and (x, y) in self.path:
            self.loop = True
        else:
            self.path.append((x, y))
        self.pos = (x, y)


def main(args):
    # data = []
    # data.append('>>>v..>>>v')
    # data.append('...v..^..v')
    # data.append('>>>>>>^..v')
    # data.append('.........v')
    # data.append('.v<<<<...v')
    # data.append('.v.v.^...v')
    # data.append('.v.v.^<<<<')
    # data.append('.v.v.....v')
    # data.append('.v...^...v')
    # data.append('.>>>>^....')
    #
    # data = []
    # data.append('>>>>>>>>>v')
    # data.append('.........v')
    # data.append('.........v')
    # data.append('>>>>v....v')
    # data.append('^...v....v')
    # data.append('^<<<<<<<<<')
    while True:
        h, w = [int(x) for x in input().split(' ')]
        if h == 0 and w == 0:
            break
        data = [input() for _ in range(h)]

        m = MagicalTiles(data)
        while m.mark != '.':
            m.move()
            if m.loop:
                break
        if m.loop:
            print('LOOP')
        else:
            print(m.pos[0], m.pos[1])


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7668
#include<stdio.h>

void InsertSort(int *a,int n){
    int i,j,v;

    for (i = 1; i < n; i++) {
        v=a[i];
        j=i-1;
        while (j!=-1&&a[j]>v) {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;

    }

}


int main(int argc, char const *argv[]) {
    int a[3],i;
    for (i = 0; i < 3; i++) {
    scanf("%d",&a[i]);
    }
    InsertSort(a,3);
    for (i = 0; i < 2; i++) {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[2]);
    return 0;
}

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

int main(void)
{
    long long A, B;
    long long X;

    scanf("%lld",&X);

    for(A=-118; A<=119; A++){
        for(B=-119; B<=118; B++){
            if(pow(A,5)-pow(B,5) == X){
                printf("%lld %lld\n",A,B);
                return 0;
            }
        }
    }


    return 0;
}

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

int main() {
  int N, x;
  int a[N];
  cin >> N >> x;
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  
  // sort
  int tmp;
  for (int i=0; i<N; ++i) {
    for (int j=i+1; j<N; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  
  int y = x;
  int bp = 0;
  for (int i=0; i<N; i++) {
    y = y - a[i];
    if (y < 0) {
      bp = i;
      break;
    }
  }
  
  int result = 0;
  if (y < 0) {
  // aの総数 > N
    result = bp;
  } else if (y > 0) {
  // aの総数 < N
    result = N - 1;
  } else {  
  // aの総数 = N
    result = N;
  }
  
  cout << result << endl;
}
    
  
  

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ int v[20],c[20],cha[20];
  int i,n,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  { 
   
    scanf("%d",&v[i]);
    
  }

  for(i=0;i<n;i++)
  { 
   
    scanf("%d",&c[i]);
    cha[i]=v[i]-c[i];
  }

  for(i=0;i<n;i++)
  {
	  if(cha[i]>0)
        sum+=cha[i];
  }
  
   printf("%d\n",sum);
return 0;

}

Measured memory_bytes: 128
// I love
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

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

void MAIN() {
  int n; cin >> n;
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    int t; cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    int cnt = 0;
    // 最初ボタン1が光っている
    int index = 1;
    while (cnt <= n) {
        // ボタンiを押すと光るボタンの番号
        index = a[index];
        cnt++;
        // cout << "index is " << index << endl;
        if (index == 2)
        {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    String s=sc.next();
    String t=sc.next();
    final int wakeru = 400;
    String[] ss = new String[(s.length()+wakeru-1)/wakeru];
    for(int i=0;i<ss.length;i++){
      ss[i]=s.substring(wakeru*i,Integer.min(wakeru*(i+1),s.length()));
    }
    boolean[][] exist = new boolean['z'-'a'+1][ss.length];
    for(int i='a';i<='z';i++){
      for(int j=0;j<ss.length;j++){
        exist[i-'a'][j]=(ss[j].indexOf(i)!=-1);
      }
    }
//    System.out.println(Arrays.deepToString(exist));
    long page=0;
    int sect=0;
    int gaze=-1;
    
    for(int i=0;i<t.length();i++){
      int will=-1;
      if(exist[t.charAt(i)-'a'][sect]){
        will=ss[sect].indexOf(t.charAt(i),gaze+1);
      }
      if(will==-1){
        for(int j=sect+1;j<ss.length;j++){
          if(exist[t.charAt(i)-'a'][j]){
            sect=j;
            will=ss[sect].indexOf(t.charAt(i));
            break;
          }
        }
      }
      if(will==-1){
        for(int j=0;j<=sect;j++){
          if(exist[t.charAt(i)-'a'][j]){
            page++;
            sect=j;
            will=ss[sect].indexOf(t.charAt(i));
            break;
          }
        }
        if(will==-1){
          System.out.println(-1);
          return;
        }
      }
      gaze=will;
    }
    System.out.println(page*s.length()+((long)sect*wakeru)+gaze+1);
    
    
  }
}

Measured memory_bytes: 27248
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Stones
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                int n = int.Parse(Console.ReadLine());
                var str = Console.ReadLine();
                var cs = new int[n + 1];
                cs[0] = 0;
                // 白の医師の個数を数える
                for (int i = 1; i <= n; i++)
                {
                    if (str[i - 1] == '.')
                    {
                        cs[i] = cs[i - 1] + 1;
                    }
                    else
                    {
                        cs[i] = cs[i - 1];
                    }
                }
                int min = int.MaxValue;
                for (int i = 0; i <= n; i++)
                {
                    min = Math.Min(min, (i - cs[i]) + cs[n] - cs[i]);
                }

                CWrite(min);
            }
        }

        static string[] GetArrayCharInput() => Console.ReadLine().Split();
        static int[] GetArrayIntInput() => Console.ReadLine().StringToIntArray();
        static int GetIntInput() => Console.ReadLine().ToInt();
        static void CWrite<T>(T str) => Console.WriteLine(str);

    }

    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static int[] StringToIntArray(this string str) =>
            str.Split().Select(int.Parse).ToArray();
        public static int ToInt(this string str) => int.Parse(str);
    }
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         MAX         262144


int main()
{
    ll i,j,k,l,m,n,q,a,b;

    cin >> n >> q;
    vl v[n+10];
    ll pr[n+10];
    ll vis[n+10];
    memset(pr,0,sizeof pr);
    memset(vis,0,sizeof vis);

    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
   for(i=0;i<q;i++)
   {
       cin >> a >> b;

       pr[a] += b;
   }

   queue<ll>Q;

   Q.push(1);
   vis[1] = 1;
   while(!Q.empty())
   {
       a = Q.front();
       Q.pop();

       for(auto x : v[a])
       {
           if(vis[x])continue;

           pr[x] += pr[a];
           vis[x] = 1;
           Q.push(x);
       }
   }

   for(i=1;i<=n;i++)cout<<pr[i]<<" " ;

   cout<<endl;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;
ll dp[405][405];
ll v[405];
ll psum[405];
bool mark[405][405];

ll f(int l, int r) {
	if(l == r) return 0;
	if(mark[l][r]) return dp[l][r];
	mark[l][r] = true;

	ll ret = 1e18;
	for(int i = l; i < r; i++) {
		ll left = f(l, i);
		ll pleft = psum[i] - psum[l-1];
		ll right = f(i+1, r);
		ll pright = psum[r] - psum[i];
		
		ret = min(ret, left + right + pleft + pright);

	}

	return dp[l][r] = ret;
}

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

	for(int i = 1; i <= n; i++)
		scanf("%lld", &v[i]);

	for(int i = 1; i <= n; i++)
		psum[i] = psum[i-1] + v[i];

	printf("%lld\n", f(1,n));
	
    return 0;
}

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

int main(){
	int d;
	cin >> d;
	if(d == 25){
		cout << "Christmas" << endl;
	}else if(d == 24){
		cout << "Christmas Eve" << endl;
	}else if(d == 23){
		cout << "Christmas Eve Eve" << endl;
	}else{
		cout << "Christmas Eve Eve Eve" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n;
	long long *ip;
	long long mult=1;
	
	scanf("%d",&n);
	ip = (long long*)calloc(n, sizeof(long long));
	for(int i=0;i<n;i++){
		scanf("%lld",ip);
		if((*ip) == 0){
			mult = 0;
			break;
		}else if((mult > 1000000000) && ((*ip) > 1000000000)){
			mult = -1;
		}else if(mult/1000000000*(*ip) > 1000000000){
			mult = -1;
		}else if(mult == -1){
			mult = -1;
		}else{
			mult *= (*ip);
			if(mult > 1000000000000000000) mult = -1;
		}
		
		ip++;
	}
	
	printf("%lld",mult);
	return 0;
}

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

int main() {
  int A, B , count, num1, num2, num4, num5 ;
  cin >> A >> B;
  for(int i = A; i <= B; i++){
    num1 = i / 10000 % 10;
    num2 = i / 1000 % 10;
    num4 = i / 10 % 10;
    num5 = i  % 10;
 	if(num1 == num5 && num2 == num4) count++;
  }
  cout << count << endl;
  return 0;
}


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

money = 1000
stocks = 0

for n in range(N-1):
  if A[n] < A[n+1]:
    stocks += money//A[n]
    money = money%A[n]
  elif A[n] > A[n+1]:
    money += stocks*A[n]
    stocks = 0
money += stocks * A[-1]
print(money)


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

int main() {
  int a=500;
  int N,A;
  
  cin >>N >> A;
  if(N>=0 && N<=10000){
    int ichien;
    ichien= N % a;
    if(A>=ichien){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout <<"Please 1<=N<=10000"<<endl;
  }
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
char arr[5];
int main()
{
    while(cin>>arr){
        int num=0;
        for(int i=1;i<4;i++){
            if(arr[i]==arr[i-1])num++;
            else if(num<2)num=0;
        }
        if(num>=2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# なぜかダメだった方法（前post参照）の原因がわからんので視点を変える
# nから配列は同定されるのでそれと与えられる配列を比較する

n = gets.chomp.to_i

# nから題意の配列を導出するマシーン
def f(n)
  if n.odd?
    return [0] + (2..n-1).each_slice(2).map(&:first).map{|ai| [ai, ai]}.flatten
  else
    return (1..n-1).each_slice(2).map(&:first).map{|ai| [ai, ai]}.flatten
  end
end

arr_origin = f(n)

# マシーンと比較するためソート
arr_target = gets.chomp.split.map(&:to_i).sort
if arr_origin == arr_target
  puts n.even? ? 2**(n/2) % (10**9+7) : 2**((n-1)/2) % (10**9+7)
else
  puts 0
end

Measured memory_bytes: 13824
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

md=10**6+3
n_max = md-1
fac = [1]
for i in range(1, n_max + 1): fac.append(fac[-1] * i % md)
ifac = [1] * (n_max + 1)
ifac[n_max] = pow(fac[n_max], md - 2, md)
for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1) % md

def main():
    for _ in range(II()):
        x,d,n=MI()
        if x==0:ans=0
        elif d==0:ans=pow(x,n,md)
        else:
            invd=pow(d,md-2,md)
            x=x*invd%md
            if x+n-1>=md:ans=0
            else:
                ans=fac[x+n-1]*ifac[x-1]*pow(d,n,md)%md
        print(ans)

main()

Measured memory_bytes: 83096
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string x, y; cin >> x >> y;
  if(x < y) cout << "<" << endl;
  else if(x > y) cout << ">" << endl;
  else cout << "=" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max((a+b)-n,0)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
map<int,int> cnave[200005];
int a[200005],b[200005];
inline int finda(int t){
	if(a[t]==t) return a[t];
	int x=finda(a[t]);
	a[t]=x;
	return x;
}
inline int findb(int t){
	if(b[t]==t) return b[t];
	int x=findb(b[t]);
	b[t]=x;
	return x;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,p,q,i,j,x,y;
	cin>>n>>p>>q;
	for(i=0;i<n;i++) a[i]=b[i]=i;
	for(i=0;i<p;i++){
		cin>>x>>y;
		a[finda(x-1)]=finda(y-1);
	}
	for(i=0;i<q;i++){
		cin>>x>>y;
		b[findb(x-1)]=findb(y-1);
	}
	for(i=0;i<n;i++){
		finda(i);
		findb(i);
		cnave[a[i]][b[i]]++;
	}
	for(i=0;i<n;i++) cout<<cnave[a[i]][b[i]]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
    int Q;
    cin >> Q;

    int64_t sum_b = 0;
    int64_t sum_small = 0;
    int64_t sum_large = 0;

    priority_queue<int, vector<int>, less<int>> pq_small;
    priority_queue<int, vector<int> , greater<int>> pq_large;

    while(Q--) {
        int q;
        cin >> q;
        if(q == 2) {
            if(pq_small.size() == pq_large.size()) {
                cout << pq_small.top() << ' ' << sum_b + sum_large - sum_small << endl;
            } else {
                cout << pq_small.top() << ' ' << sum_b + sum_large - sum_small + pq_small.top() << endl;
            }
        } else {
            int a, b;
            cin >> a >> b;
            sum_b += b;
            if(pq_small.empty()) {
                pq_small.push(a);
                sum_small += a;
            } else if(a <= pq_small.top()) {
                pq_small.push(a);
                sum_small += a;
            } else {
                pq_large.push(a);
                sum_large += a;
            }
            if(pq_small.size() < pq_large.size()) {
                sum_large -= pq_large.top();
                sum_small += pq_large.top();
                pq_small.push(pq_large.top());
                pq_large.pop();
            } else if(pq_small.size() - pq_large.size() >= 2) {
                sum_small -= pq_small.top();
                sum_large += pq_small.top();
                pq_large.push(pq_small.top());
                pq_small.pop();
            }
        }
    }
    return 0;
}

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

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

int main()
{
    int n,x;
    cin >> n >> x;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
    }
    vec.push_back(x);
    sort(vec.begin(),vec.end());

    int d = vec[1]-vec[0];
    for(int i = 1; i < n; ++i)
    {
        d = gcd(d, vec[i+1]-vec[i]);
    }
    cout << d << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<ll>sum(n);
	rep(i, n) {
		int a;
		cin >> a;
		if (i > 0) {
			sum[i] = sum[i - 1] + a;
		}
		else {
			sum[i] = a;
		}
	}
	ll tmp = 1e10;
	rep(i, n-1) {
			tmp = min(tmp,abs(sum[n - 1] - sum[i] * 2));
	}
	cout << tmp << endl;

}

Measured memory_bytes: 1792
N = int(input())
xyList = [[int(i) for i in input().split()] for _ in range(N)]

def culcNumList(num):
    numList = [1]
    lastNum = 2
    while(True):
        if lastNum >= num:
            return numList
        numList.append(lastNum)
        lastNum *= 2

max_sum = 0
oddFlag = False
evenFlag = False
for xy in xyList:
    sum_xy = sum(xy)
    max_sum = max(sum_xy, max_sum)
    if sum_xy % 2 == 0: evenFlag = True
    else: oddFlag = True

if oddFlag and evenFlag:
    print(-1)
else:
    d = culcNumList(max_sum)[::-1]
    if evenFlag: d.append(1)
    print(len(d))
    print(" ".join([str(s) for s in d]))

    for xy in xyList:
        nowX, nowY = 0, 0
        ans = ""
        for arm in d:
            if abs(nowX - xy[0]) >= abs(nowY - xy[1]):
                if nowX > xy[0]:
                    ans += "L"
                    nowX -= arm
                else:
                    ans += "R"
                    nowX += arm
            else:
                if nowY > xy[1]:
                    ans += "D"
                    nowY -= arm
                else:
                    ans += "U"
                    nowY += arm
        print(ans)



Measured memory_bytes: 45276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,f;
  int d[1000000]={};
  int k[1000000]={};
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    d[i]=b;
  }
  for(int i=0;i<c;i++){
    cin>>f;
    k[f-1]++;
  }
  for(int i=0;i<a;i++){
     d[i]=d[i]-(c-k[i]);
     // cout<<d[i]<<"\n";
    if(d[i]<=0) cout<<"No\n";
    else cout<<"Yes\n";
  }
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline string ts()
	{
		string a="";
		int c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)a.push_back(c),c=fetch();
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 5007;

int n,nn,tim,baslen;string S,T;
int mic,mxlen;

inline string finder(int r)
{
	return string(baslen,mic)+string(T,nn-r-1+mxlen,n-baslen);
}

int main()
{
	n=ty(),tim=ty(),S=ts(),nn=n+n;
	T=S,reverse(T.begin(),T.end()),T=S+T;

	mic=255,mxlen=0;
	for(int i=0;i<nn;i++)mic=min(mic,T[i]);
	for(int i=0,now=0;i<nn;i++)mxlen=max(mxlen,now=((T[i]==mic)?(now+1):0));

	baslen=mxlen;
	for(int i=2;i<=tim && baslen<n;i++,baslen<<=1);
	if(baslen>=n){printf("%s\n",(string(n,mic)).c_str());return 0;}

	string ans=S;
	for(int i=0,now=0;i<nn;i++)
	{
		now=(T[i]==mic)?(now+1):0;
		if(i>=n && now>=mxlen)ans=min(ans,finder(i));
	}
	printf("%s\n",ans.c_str());

	return 0;
}


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

int main() {
    ll A;
    double B;
    cin>>A>>B;
    string s=to_string(B);
    ll c=(ll)(s[0]-'0')*100;
    c+=(ll)(s[2]-'0')*10;
    c+=(ll)(s[3]-'0');
    ll ans=(A*c)/100;
    cout<<ans<<endl;
}

Measured memory_bytes: 3812
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

int main(){
	int n,a[100005];
	int n1=0,n4=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2!=0) n1++;
		else{
			if(a[i]%4==0) n4++;
		}
	}
	if(n1+n4==n&&n1-n4==1) printf("Yes\n");
	else if(n4>=n1) printf("Yes\n");
	else printf("No\n");	
return 0;
} 

Measured memory_bytes: 640
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a, b = map(int, input().split())
a_list = prime_factorize(a)
b_list = prime_factorize(b)
a_set = set(a_list)
b_set = set(b_list)

ans_set = a_set & b_set
ans_set.add(1)
print(len(ans_set))


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	
	int n,i;
	long long int a[100010],ans1=0,ans2=0,sum=0;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	
	for(i=1;i<=n;i++){
		
		sum+=a[i];
		if(i%2==1&&sum<=0){
			ans1+=1-sum;
			sum=1;
		}else if(i%2==0&&sum>=0){
			ans1+=sum+1;
			sum=-1;
		}
	}
	
	sum=0;
	
	for(i=1;i<=n;i++){
		
		sum+=a[i];
		if(i%2==1&&sum>=0){
			ans2+=sum+1;
			sum=-1;
		}else if(i%2==0&&sum<=0){
			ans2+=1-sum;
			sum=1;
		}
	}
	
	if(ans1>ans2){
		printf("\n%lld\n\n",ans2);
	}else {
		printf("\n%lld\n\n",ans1);
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 896