akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector <ll> A(N), B(N);
	vector<ll> ok;// D:準備度の足りている試験の準備度と合格値の差
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];
	ll ans = 0;
	ll lack = 0; //不足してる準備度
	for (int i = 0; i < N; i++) {
		if (A[i] < B[i]) {
			lack += B[i] - A[i];
			ans++;
		}
		else {
			ok.push_back(A[i] - B[i]);
		}
	}
	if (lack > 0) {
		sort(ok.begin(), ok.end(), greater<>());
		for (int i = 0; i < ok.size() && lack > 0; i++) {
			lack -= ok[i];
			ans++;
		}
		if (lack > 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	else {
		cout << 0 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

  n=s.size();
  pointer=n-1;

  while (pointer>=4) {
    if (s[pointer]!='m' && s[pointer]!='r' && s[pointer]!='e'  ) {
      printf("NO\n");
      return 0;
    }

    string tmp=s.substr(pointer-4,5);
    if (tmp=="dream") {
      pointer -= 5;
    }else if (tmp=="erase") {
      pointer -= 5;
    }else if (tmp == "eamer") {
      if (pointer >= 6 && s.substr(pointer-6,7)=="dreamer") {
        pointer -=7;
      }else{
        printf("NO\n");
        return 0;
      }
    }else if (tmp == "raser") {
      if (pointer >= 5 && s.substr(pointer-5,6)=="eraser") {
        pointer -=6;

      }else{
        printf("NO\n");
        return 0;
      }
    }else{
      printf("NO\n");
      return 0;
    }
  }
  if(pointer==-1){
    printf("YES\n" );
  }else{
    printf("NO\n" );
  }
  return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b,c;
	cin>>a>>b>>c;
	
	int ct =0;
	
	if(a ==b)ct++;
	if(b==c)ct++;
	if(a==c)ct++;
	
	if(ct ==1){
		writeln("Yes");
	}else {
		writeln("No");
	}
	

}


Measured memory_bytes: 256
n = int(input())
m = int(input())
in_counts = [0] * n
out_set = [set() for _ in range(n)]
for _ in range(m):
    s, t = (x - 1 for x in map(int, input().split()))
    in_counts[t] += 1
    out_set[s].add(t)

roots = {s for s, link_count in enumerate(in_counts) if not link_count}
unique = True

while roots:
    if unique and len(roots) > 1:
        unique = False
    r = roots.pop()
    print(r + 1)
    for nxt in out_set[r]:
        in_counts[nxt] -= 1
        if not in_counts[nxt]:
            roots.add(nxt)

print(int(not unique))

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

int main() {
  ll n, k, s;
  cin >> n >> k >> s;
  vector<ll> v(n);
  rep(i, n) {
    if (i < k) {
      v[i] = s;
    } else {
      ll num = 1000000000;
      if (s == num) {
        v[i] = num-1;
      } else {
        v[i] = num;
      }
    }
  }
  
  
  rep(i, n) {
    cout << v[i];
    if (i == n-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 2048
using System;

class AOJ {
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        for(int i=0; i<n; i++) {
            int[] x = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Array.Sort(x);

            if (x[2]*x[2] == x[0]*x[0] + x[1]*x[1])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 9196
def main():
    n = int(input())
    numbers = list(map(int, input().split()))
    count_odd = 0
    for num in numbers:
        if num % 2:
            count_odd += 1
    print("YES" if count_odd % 2 == 0 else "NO")


if __name__ == '__main__':
    main()



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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
    
    return 0;
}



Measured memory_bytes: 3140
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    k = max(a).bit_length()
    mod = 10**9 + 7
    c = 0
    for kk in range(k):
        h, l = 0, 0
        for ai in a:
            if ai // 2**kk % 2:
                h += 1
            else:
                l += 1
        kc = h * l * pow(2, kk, mod) % mod
        c = (c + kc) % mod
    print(c)

if __name__ == '__main__':
    main()

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vl a(n+1,0);
    rep(_,m){
        ll p,q;cin>>p>>q;
        a[p]++; a[q]++;
    }
    bool ok=true;
    rep(i,n+1)ok&=a[i]%2==0;
    YN(ok);
    return 0;
}

Measured memory_bytes: 1024
// <head>
    // #define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
// </head>

// <library>
    
// </library>

int main(){
    string s; cin >> s;
    int n = (int)s.size();
    int bc=0;
    ll ans=0;
    for (int i = n-1; i >= 0; i--){
        if(s[i]=='C'){
            if(i>0 && s[i-1]=='B'){
                i--;
                bc+=1;
            } else {
                bc=0;
            }
        } else if(s[i]=='B'){
            bc=0;
        } else if(s[i]=='A'){
            ans+=bc;
        }
        
    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 720
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int n;
    cin >> n;
    
    vector<pint> s;
    int a;
    rep(i, n){
        cin >> a;
        s.pb(mp(a, i + 1));
    }
    
    sort(all(s), [](auto l, auto r){return l.first < r.first;});
    
    for(auto i : s){
        cout << i.second << endl;
    }
    
	
	return 0;
}

Measured memory_bytes: 1780
n = int(raw_input())
a = map(int, raw_input().split())

count = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
            
    if a[i] != a[minj]:
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp
        count += 1

for i in range(n):
    if i == n-1:
        print a[i]
    else:
        print a[i],

print count

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

long long a, b, c, k;

int main() {
  cin >> a >> b >> c >> k;
  long long res = 0, now = 0;
  now = min(a, k);
  res += now;
  k -= now;
  k -= min(b, k);
  now = min(c, k);
  res -= now;

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

Measured memory_bytes: 3636
def main():
  N,S = map(int,input().split())
  A = list(map(int,input().split()))
  MOD = 998244353

  ans = 0
  q = [0 for _ in range(S+1)]
  for i in range(len(A)):
    q[0] += 1
    q[0] %= MOD
    q2 = q[:]
    for j in range(S):
      if j+A[i] <= S:
        q2[j+A[i]] += q[j]
        q2[j+A[i]] %= MOD
    q = q2[:]
    ans += q[S]
  #print(q)
  print(ans%MOD)
  
main()

Measured memory_bytes: 43068
class UnionFindTree():
    def __init__(self, N):
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(len(self.__parent_of)):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, M = map(int, input().split())
    uft = UnionFindTree(N)
    for _ in range(M):
        x, y, z = map(int, input().split())
        uft.unite(x-1, y-1)
    print(len(uft.groups()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 86616
(h=Hash[q=[[$_.chop,0]]]
puts (while q[0]
s,c=q.shift
break c if s.squeeze("rgb").size<2
(0..s.size-2).map{|i|s[i]!=s[i+1]&&(t=s.dup;t[i,2]="rgb".delete(t[i,2])*2;h[t]||=(q<<[t,c+1];0))}end)||:NA)while gets>?a

Measured memory_bytes: 7536
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
ans = 0
sum_A_j = sum(A)
for A_i in A:
    sum_A_j -= A_i
    ans += A_i * sum_A_j
    ans %= 10**9 + 7

# 結果出力
print(ans)


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

int main(){
  long long X,Y;
  cin>>X>>Y;

  long long cnt=0;
  long long tmp = X;
  
  while( Y  >= tmp ){
    tmp *= 2;
    cnt++;
  }

  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,t,x,y;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    int xnow = 0;
    int ynow = 0;
    int lst = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> t >> x >> y;
        int dist = abs(x - xnow) + abs(y - ynow);
        if(dist > t) rc("No");
        if((t - dist) & 1) rc("No");
    }
    rc("Yes");
}

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

typedef long long ll;

int main(void)
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> t(n+1, 0);
    rep(i, n)
    {
        t[i+1] = t[i];
        if(i == 0) continue;
        if(s[i-1] == 'A' && s[i] == 'C') t[i+1]++;
    }
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        int ans = t[r+1] - t[l];
        if(l-1 >= 0 && s[l-1] == 'A' && s[l] == 'C') ans--;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

void print_sharp(void)
{
    printf("####################");
}

int main(void)
{
    int b, f, r, v, n, i, l, x;
    int count[4][3][10] = {0};

    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b - 1][f - 1][r - 1] = count[b - 1][f - 1][r - 1] + v;
    }

    for (i = 0; i < 4; i++)
    {
        for (l = 0; l < 3; l++)
        {
            for (x = 0; x < 10; x++)
            {
                if (count[i][l][x] == 0)
                {
                    printf(" 0");
                }
                else
                {
                    printf(" %d", count[i][l][x]);
                }
            }
            putchar('\n');
            if (l == 2 && i < 3)
            {
                printf("####################\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();

	int A = 0;
	int B = 0;
	rep(i, N) {
		if (i % 2) {
			if (S[i] == '1') A++;
			else B++;
		}
		else {
			if (S[i] == '0') A++;
			else B++;
		}
	}
	co(min(A, B));

	Would you please return 0;
}

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

int main() {
    int n,a,b; cin >> n >> a >> b;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int r = 0;
        string str = to_string(i);
        while (not str.empty()) {
            r += str.back() - '0';
            str.pop_back();
        }
        if (r >= a and r <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int str[26]={};
    int ans  = 10000;
    for(int i=0;i<26;i++){
        int cnt = 0;
        int cnt2 = 0;
        for(int j=0;j<s.length();j++){
            if(s[j]-'a'==i){
                str[i] = max(str[i],cnt);
                cnt2+=cnt+1;
                cnt=0;
            }else{
                cnt++;
            }
        }
        cnt2=s.length()-cnt2;
        str[i] = max(str[i],cnt2);
        if(str[i]<ans){
            ans = str[i]; 
        }
    }
    cout << ans << endl;
}

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

int main(){
    int a, b, c, d, e;
    scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
    printf("%d\n", min(a, min(b, c)) + min(d, e) - 50);
    return 0;
}

Measured memory_bytes: 1184
MOD = 1000000007

class Integer
  def factorial
    # 階乗 n!
    return 1 if self == 0
    (1..self).inject{|result,item|result * item % MOD}
  end

  def permutation(r)
    # 順列 nPr
    return 1 if self == 0
    s = self - r + 1
    (s..self).inject{|result,item|result * item % MOD}
  end

  def combination(r)
    r = [r, self - r].min
    return self if r == 1
    return 1 if r == 0
    self.permutation(r) * (r.factorial.inverse) % MOD
  end

  # aのn乗
  def power(n)
    res = 1
    a = self
    while (n > 0)
      if n.odd?
        res = (res * a) % MOD
      end
      a = a * a % MOD
      n >>= 1 # n / 2
    end
    return res
  end

  def inverse
    # 逆元 a^{-1} mod を計算する
    return self.power(MOD-2)
  end
end


str = gets
nab = str.chomp.split(" ").map(&:to_i)
n = nab[0]
a = nab[1]
b = nab[2]

# 0本のときは花束にならないので-1
all = 2.power(n) - 1
rem1 = n.combination(a)
rem2 = n.combination(b)
total = (all - rem1 - rem2) % MOD
p total


Measured memory_bytes: 1916
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else


const int MAXN = 2e5 + 20;

ll cnts[MAXN];

void solve() {

    int n;
    cin >> n;

    vector<ll> v;

    for (int i = 0; i < n; ++ i){
        ll curr;
        cin >> curr;
        cnts[curr]++;
        v.push_back(curr);
    }
    ll answr = 0;


    ll was = 0;

    for (int i = 1; i < MAXN; ++i){
        answr += cnts[i] * (cnts[i] - 1) / 2;
    }

    for (int i = 0; i < n; ++ i) {

        ll el = v[i];
        answr -= cnts[el] * (cnts[el] - 1) / 2;
        answr += (cnts[el] - 1) * (cnts[el] - 2) / 2;

        cout << answr << "\n";

        answr += cnts[el] * (cnts[el] - 1) / 2;
        answr -= (cnts[el] - 1) * (cnts[el] - 2) / 2;
    }

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++)  << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
long long x,k,d;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>x>>k>>d;
	x=abs(x);
	if(k<x/d)
	{
		cout<<x-k*d<<endl;
	}
	else
	{
		long long ci=x/d,ans;
		long long c=x-ci*d;
		if(ci%2==k%2)
		{
			ans=c;
		}
		else ans=d-c;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
lista = input().split(" ")
a, b = lista
a = int(a)
b = int(b)
s = 0
a1=[]

while(a!=0):
    s+=b
    a1.append(b)
    b+=1
    a-=1
if 0 in a1:
    print((int(s)))
elif(b>0):
    print((int(s)-min(a1)))
else:
    print((int(s)-max(a1)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    str[k-1]=str[k-1]-'A'+'a';
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 256
#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() {
  double n, k, ans = 0;
  cin >> n >> k;
  for (double i = 1; i <= n; i++) {
    double a = i, p = 1 / n;
    while (a < k) {
      p *= 0.5;
      a *= 2;
    }
    ans += p;
  }
  printf("%.10lf\n", ans);
  return 0;
}


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

typedef struct {
	char L[21];
	double efficient;
} CROP;

CROP crop[50];

int main(void)
{
	int N;
	int P, A, B, C, D, E, F, S, M;
	int i, j;
	int days, income;
	CROP t;
	
	while (1){
		scanf("%d", &N);
		if (N == 0){
			break;
		}
		
		
		for (i = 0; i < N; i++){
			scanf("%s", crop[i].L);
			
			scanf("%d%d%d%d%d%d%d%d%d", &P, &A, &B, &C, &D, &E, &F, &S, &M);
			
			days = A + B + C + (D + E) * M;
			income = M * F * S - P;
			
			crop[i].efficient = (double)income / days;
		}
		
		for (i = 0; i < N; i++){
			for (j = 0; j < N - 1; j++){
				if (crop[j].efficient < crop[j + 1].efficient){
					t = crop[j];
					crop[j] = crop[j + 1];
					crop[j + 1] = t;
				}
				else if (crop[j].efficient == crop[j + 1].efficient &&
				         strcmp(crop[j].L, crop[j + 1].L) > 0){
					t = crop[j];
					crop[j] = crop[j + 1];
					crop[j + 1] = t;
				}
			}
		}
		
		for (i = 0; i < N; i++){
			printf("%s\n", crop[i].L);
		}
		printf("#\n");
	}
	
	return (0);
}

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

void fnInput(int& rnLowNum, int& rnHighNum)
{
  cin >> rnLowNum >> rnHighNum;
}

void fnDigitGet(int nNum, vector<int>& rvnDigit)
{
  for (int n = rvnDigit.size() - 1; n >= 0; n--)
  {
    rvnDigit[n] = nNum % 10;
    nNum /= 10;
  }
}

int fnPalindromeCnt(int nLowNum, int nHighNum)
{
  int nPlindromeCnt = 0;
  vector<int> vnDigit(5);

  for (int nNum = nLowNum; nNum <= nHighNum; nNum++)
  {
    fnDigitGet(nNum, vnDigit);

    vector<int> vnRevDigit(vnDigit);
    reverse(begin(vnRevDigit), end(vnRevDigit));

    if (vnDigit == vnRevDigit)  nPlindromeCnt++;
  }
  return nPlindromeCnt;
}

int main()
{
  int nLowNum, nHighNum, nMinSum, nMaxSum;
  fnInput(nLowNum, nHighNum);

  cout << fnPalindromeCnt(nLowNum, nHighNum) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int r;
  scanf("%lld", &r);
  
  std::cerr << "Answer:" << std::endl;
  std::cout << 3*r*r << std::endl;
  
  return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string s;
    cin >> s;
    int ans;
    if(s == "MON") ans = 6;
    if(s == "TUE") ans = 5;
    if(s == "WED") ans = 4;
    if(s == "THU") ans = 3;
    if(s == "FRI") ans = 2;
    if(s == "SAT") ans = 1;
    if(s == "SUN") ans = 7;
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;

const int MAXN = 200002;
const int LOG_N = 40;

int n;
lld k;
vector<int> arr;
unordered_map <int, int> firstOc, lastOc;
lld f[LOG_N][MAXN]; // f^2n = f(f(f(f())))

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  arr.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if (lastOc.count(arr[i]) > 0) {
      int l = lastOc[arr[i]];
      f[0][l] = i-l+1;
    } else {
      firstOc[arr[i]] = i;
    }
    f[0][i] = n - i + firstOc[arr[i]] + 1;
    lastOc[arr[i]] = i;
  }

  for (int j = 1; j < LOG_N; ++j) {
    for (int i = 0; i < n; ++i) {
      lld p = f[j-1][i];
      int nextPosition = (p + (lld) i) % n;
      f[j][i] = p + f[j-1][nextPosition];
    }
  }

  int current = 0;
  lld saltos = k * (lld) n;
  for (int j = LOG_N-1; j >= 0; --j) {
    if (f[j][current] <= saltos) {
      saltos-= f[j][current];
      current = ((lld) current + f[j][current]) % n;
      j = LOG_N;
    }
  }

  vector <int> ans;
  unordered_set <int> present;
  for (int i = 0; i < saltos; ++i) {
    if (present.count(arr[current]) > 0) {
      while (ans.back() != arr[current]) {
        present.erase(ans.back());
        ans.pop_back();
      }
      ans.pop_back();
      present.erase(arr[current]);
    } else {
      ans.push_back(arr[current]);
      present.insert(arr[current]);
    }
    current = (current + 1) % n;
  }

  for (int x : ans) {
    cout << x << " ";
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 90512
import numpy as np

N=int(input())

fact = [i for i in range(1600)]
fact[0]=fact[1]=0
for i in range(2,40):
    tmp=i
    tmp*=i
    while tmp<1600:
        fact[tmp]=0
        tmp+=i
fact = np.array(fact)
fact = fact[fact!=0]
fact = fact[fact%5==1]

ans=str(fact[0])
for i in range(1,N):
    ans+=' {}'.format(fact[i])
print(ans)

Measured memory_bytes: 21528
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int A[50];
int fib(int n){
	if(A[n]) return A[n];
	else if(n==1 || n==0) A[n]=1;
	else A[n]=fib(n-1)+fib(n-2);
	return A[n];
}

int main (){
	int n;
	cin>>n;
	cout<<fib(n)<<endl;
	return 0;
}


Measured memory_bytes: 3120
from itertools import permutations
import numpy as np

MAX = 1e9
N, M, r = map(int, input().split())
R = list(map(lambda x: int(x) - 1, input().split()))
E = np.array([MAX]*(N**2), dtype=int).reshape((N, N))
for i in range(N):
    E[i, i] = 0
for _ in range(M):
    s, t, d = map(int, input().split())
    E[s-1, t-1] = d
    E[t-1, s-1] = d

for k in range(N):
    for i in range(N):
        E[i, :] = np.minimum(E[i, :], E[i, k] + E[k, :])

perm = permutations(R)
ans = MAX
for p in perm:
    c = 0
    for i in range(r-1):
        c += E[p[i]][p[i+1]]
    ans = min(ans, c)
print(ans)

Measured memory_bytes: 13012
#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() {
  string s; cin >> s;
  if (s.at(0) != s.at(1) || s.at(1) != s.at(2)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=n
for i in range(n+1):
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    j=n-i
    while j>0:
        cnt+=j%9
        j//=9
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

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

    vector<vector<int>> G(n);
    map<pi,int> m;
    rep(i,n-1){
        int a,b;
        cin >>a >>b;
        --a;
        --b;

        G[a].pb(b);
        G[b].pb(b);
        m[{a,b}] = m[{b,a}] = i;
    }

    vector<int> c(n-1);

    vector<set<int>> used(n);
    vector<bool> vis(n);
    vis[0] = true;
    queue<int> que({0});
    while(!que.empty()){
        int v = que.front();
        que.pop();
        int now = 1;
        for(int nx:G[v])if(!vis[nx]){
            while(used[v].count(now)) ++now;
            used[v].insert(now);
            used[nx].insert(now);

            int eidx = m[{v,nx}];
            c[eidx] = now;

            que.push(nx);
            vis[nx] = true;
        }
    }

    int ans = 0;
    rep(i,n) ans = max(ans, (int)G[i].size());

    cout << ans << "\n";
    rep(i,n-1) cout << c[i] << "\n";
    return 0;
}


Measured memory_bytes: 33024
#include <stdio.h>

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

  int fiv1Cnt = 0;
  int fiv2Cnt = 0;
  while (X >= 500) {
    X = X - 500;
    fiv1Cnt++;
  }
  while (X >= 5) {
    X = X - 5;
    fiv2Cnt++;
  }
  int sum = 0;
  sum = fiv1Cnt * 1000 + fiv2Cnt * 5;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K, Q; cin >> N >> K >> Q;

  vector<int> B(N, K-Q);
  REP(i, Q) {
    int a; cin >> a;
    B[a-1]++;
  }

  REP(i, N) cout << (B[i] > 0 ? "Yes" : "No") << endl;
}

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

int n, x, a[200], ans;

int main() {
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1);
	for (int i=1;i<n;i++) if (a[i] <= x) x -= a[i], ++ans;  else break;
	if (x == a[n]) ++ans;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
C = [["" for _ in range(w)] for _ in range(h)]
c = 0
for j in range(h):
    s = input()
    for i in range(w):
        C[j][i] = s[i]
        if s[i] == "#":
            c += 1

ans = 0
for bit_i in range(1<<h):
    for bit_j in range(1<<w):
        btor = 0
        for i in range(h):
            if bit_i & (1<<i):
                for ij in range(w):
                    if C[i][ij] == "#":
                        btor += 1
        for j in range(w):
            if bit_j & (1<<j):
                for ji in range(h):
                    if C[ji][j] == "#":
                        btor += 1
        for i in range(h):
            for j in range(w):
                if (bit_j & (1<<j)) and (bit_i & (1<<i)):
                    if C[i][j] == "#":
                        btor -= 1
        if c - btor == k:
            ans += 1

print(ans)


Measured memory_bytes: 9280
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a;
    string data;
    while(cin >> data){
        if(data[0]=='+'){
            int s = a[a.size()-1];
            int t = a[a.size()-2];
            a.pop_back(),a.pop_back();
            t = s+t;
            a.push_back(t);
        }else if(data[0]=='-'){
            int t = a[a.size()-1];
            int s = a[a.size()-2];
            a.pop_back(),a.pop_back();
            t = s-t;
            a.push_back(t);
        }else if(data[0]=='*'){
            int s = a[a.size()-1];
            int t = a[a.size()-2];
            a.pop_back(),a.pop_back();
            t = s*t;
            a.push_back(t);
        }
        else a.push_back(stoi(data));
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3176
N, M = map(int, input().split())
H = list(map(int, input().split()))
road_list = [[] for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    road_list[A].append(B)
    road_list[B].append(A)
count = 0
for i, idx_list in enumerate(road_list):
    if i == 0:
        continue
    compareH_list = []
    for idx in idx_list:
        compareH_list.append(H[idx-1])
    if compareH_list == []:
        count+=1
    elif max(compareH_list) < H[i-1]:
        count += 1
    else:
        pass

print(count)


Measured memory_bytes: 29992
n = int(input())
adj_matrix = [[0 for _ in range(n)] for _ in range(n)]
    
for i in range(n):
    l = list(map(int, input().split()))[2:]
    for j in l:
        adj_matrix[i][j-1] = 1

for l in adj_matrix:
    print(*l)


Measured memory_bytes: 6388
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
long long Read() {
    long long x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
int ans;
long long x,y;
int main(){
	x=Read(),y=Read();
	while(x<=y){
		x*=2;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > X(N);
    for(int i=0; i<N;i++){
        std::cin >> X[i];
    }
    
    int sta_min = -1;
    for(int i=1; i<=100;i++){
        int sta = 0;
        for(int j=0; j<N;j++){
            sta += (i - X[j]) * (i - X[j]);
        }
        if(sta < sta_min || sta_min == -1){
            sta_min = sta;
        }
    }
    
    std::cout << sta_min << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  if(1<=s/100&&s/100<=12){
    if(1<=s%100&&s%100<=12){
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if(1<=s%100&&s%100<=12){
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int c_not[3]    = {2,1,0};
int c_and[3][3] = {{0,0,0},{0,1,1},{0,1,2}};
int c_or[3][3]  = {{0,1,2},{1,1,2},{2,2,2}};

int calc(string s, int p, int q, int r){

  for(int i=0;i<s.size();i++){

    if(s[i] == 'P'){
      s[i] = '0' + p;
    }
    if(s[i] == 'Q'){
      s[i] = '0' + q;
    }
    if(s[i] == 'R'){
      s[i] = '0' + r;
    }
    
  }
  
  while(s.size() > 1){
    string s_old = s;
    
    //debug(s);
    
    for(int i=0;i<s.size();i++){

      //not
      if(i+1 < s.size()){
        if(s[i] == '-' && ('0' <= s[i+1] && s[i+1] <= '2')){
          int p = c_not[s[i+1]-'0'];
          s = s.substr(0,i) + "0" + s.substr(i+2, s.size() - (i+2));
          s[i] += p;
          break;
        }
      }

      
      if(0 < i && i+1 < s.size()){
        //and
        if(('0' <= s[i-1] && s[i-1] <= '2') &&
           s[i] == '*' &&
           ('0' <= s[i+1] && s[i+1] <= '2')){
          int p = c_and[s[i-1]-'0'][s[i+1]-'0'];
          s = s.substr(0,i-1) + "0" + s.substr(i+2, s.size() - (i+2));
          s[i-1] += p;
          break;
        }

        //or
        if(('0' <= s[i-1] && s[i-1] <= '2') &&
           s[i] == '+' &&
           ('0' <= s[i+1] && s[i+1] <= '2')){
          int p = c_or[s[i-1]-'0'][s[i+1]-'0'];
          s = s.substr(0,i-1) + "0" + s.substr(i+2, s.size() - (i+2));
          s[i-1] += p;
          break;
        }

        //(*)
        if(s[i-1] == '(' &&
           ('0' <= s[i] && s[i] <= '2') &&
           s[i+1] == ')'){
          int p = s[i]-'0';
          s = s.substr(0,i-1) + "0" + s.substr(i+2, s.size() - (i+2));
          s[i-1] += p;
          break;
        }
      }
    }

    if(s == s_old){
      assert(false);
      break;
    }
  }

  return s[0]-'0';
}

bool solve(){
  string s;

  cin >> s;

  if(s == ".") return false;

  int ans = 0;
  
  for(int i=0;i<=2;i++){
    for(int j=0;j<=2;j++){
      for(int k=0;k<=2;k++){
        ans += calc(s,i,j,k) == 2;
      }
    }
  }

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

  return true;
}
  

int main(){

  while(solve());
  
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;


int main() {
	int N,W;
	cin >> N >> W;
	vector<long long>dp(W+1,0),w(N),v(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> w.at(i)>>v.at(i);
		for (size_t j = W; j >= w.at(i); j--)
		{
			dp.at(j) = max(dp.at(j-w.at(i))+v.at(i), dp.at(j));
		}
	}
	
	sort(dp.begin(), dp.end(), greater<long long>());
	cout << dp.at(0);
}

Measured memory_bytes: 1024
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main _argv =
    let input = stdin.ReadLine()
    let chars = input.ToCharArray(0, input.Length)
    
    let acgt = [|'A'; 'C'; 'T'; 'G'|]
    
    let createRes (chars: Char[]) =
        let last = chars.Length-1
        let rec loop res cnt index =
            if index > last then
                res
            else
                if Array.IndexOf(acgt, chars.[index]) >= 0 then
                    let newCnt = cnt + 1
                    let newRes =
                        (fun i ->
                            if i > res then
                                i
                            else
                                res) newCnt
                    loop newRes newCnt (index + 1)
                else
                    loop res 0 (index + 1)
        loop 0 0 0
    
    createRes chars
    |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 14040
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

ans = 0
for i in range(N):
	if a[a[i]-1] == i+1: ans += 1
print(ans//2)


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

using namespace std;

typedef pair<int, int> pii;

bool possible(int tim, pii A, pii B) {
    int x = abs(A.first - B.first);
    int y = abs(A.second - B.second);
    int leftover = tim - (x + y);
    if (leftover < 0)
        return false;
    if (leftover == 0)
        return true;
    if (leftover % 2 == 0)
        return true;

    return false;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;

    pii pos = {0, 0};
    int tim = 0;

    int t, x, y;
    while (N--) {
        cin >> t >> x >> y;
        if (!possible(t-tim, pos, {x, y})) {
            cout << "No\n";
            return 0;
        }
        pos = {x, y};
        tim = t;
    }
    cout << "Yes\n";

    return 0;
}


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

long gcd(long a, long b) {
	long tmp,r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int calc(long n)
{
	if (n == 1) {
		return 1;
	}

	long a, prev;
	int ans = 0;
	vector<long> so;
	a = 2;
	prev = 0;
	so.push_back(1);
	while (n >= a * a) {
		if (n % a == 0) {
			//printf("%d * ", a);
			if (prev != a) {
				//ans++;
				so.push_back(a);
			}
			prev = a;
			n /= a;
		}
		else {
			a++;
		}
	}
	//	ans++;
	//	printf("%d\n", n);

	if (prev != n) {
		so.push_back(n);
	}

	/*
	for (int i = 0; i < so.size(); i++) {
		cout << " " << so[i];
	}
	cout << endl;
	*/

	int i, j;
	int size = so.size();
	bool *flg = new bool[size];
	for (i = 0; i < size; i++) {
		for (j = i + 1; j < size; j++) {
			if (gcd(so[i], so[j]) == 1) {
				flg[i] = flg[j] = true;
			}
		}
	}

	for (i = 0; i < size; i++) {
		if (flg[i] == true) {
			ans++;
		}
	}
	return ans;
}


int main()
{
	long a, b;

	cin >> a >> b;

	b = gcd(a, b);

	cout << calc(b) << endl;
	
	return 0;
}



Measured memory_bytes: 256
N=int(input())
b=[int(i) for i in input().split()]
a=[]
try:
    while len(b)>0:
        a2=max([j for i,j in enumerate(b) if b[i]==i+1])
        a.insert(0,a2)
        x=b.pop(a2-1)
    for n in a:
        print(n)
except:
    print(-1)

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)
#define NUM_M 1000
#define MAX_H 10000
typedef long long ll;
int dp[MAX_H + 1]; // dp[i+1][j] -> i番目までの魔法でダメージがj(以上?)になるように選んだ時の魔力消費の最小値
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H, N; cin >> H >> N;
    vector<int> damage;
    vector<int> mp;
    REP(i, N) {
        int tmp_d, tmp_m; cin >> tmp_d >> tmp_m;
        damage.push_back(tmp_d);
        mp.push_back(tmp_m);
    }
    int INF = 1000000000; // A_i >= 1 H<= 10^4 より　B_i(max) 10^4 * H は越えない
    REP(j, MAX_H + 1) dp[j] = INF;
    dp[0] = 0;
    REP(i, N) {
        REP(j, MAX_H + 1) {
            int j_i = max(j-damage[i], 0);
            dp[j] = min(dp[j], dp[j_i] + mp[i]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main()
{
	char X, Y, dummy;

	scanf("%c", &X);
	scanf("%c", &dummy);
	scanf("%c", &Y);

	if (X > Y) {
		printf(">\n");
	}
	else if (X < Y) {
		printf("<\n");
	}
	else if (X == Y) {
		printf("=\n");
	}
}


Measured memory_bytes: 128
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;
const ll INF = 1LL << 40;

int main(void){
    // Your code here!
    int s;
    cin >> s;
    
    int n = 10000000;
    

    vector<int> a(n);
    a[0] = s;
    //cout << a[0] << endl;
    
    vector<int> stock;
    stock.push_back(s);
    
    FOR(i,0,n-1){
        //a[i+1] = f(a[i])計算
        if (a[i] % 2 == 0) a[i+1] = int(a[i] / 2);
        else a[i+1] = 3 * a[i] + 1;
        //cout << a[i+1] << endl;
        
        //過去に出てきた数字か
        auto iter = find(stock.begin(), stock.end(), a[i+1]);
        if (iter != stock.end()){
            cout << i+2 << endl;
            exit(0);
        }
        else stock.push_back(a[i+1]);
        
    }
    
}


Measured memory_bytes: 39296
"""
5
0 0
0 1
0 2
0 3
"""
import copy
while True:
  N = int(input())
  if N==0:
    break
  T = [[0,0]]
  for i in range(N-1):
    n,d = map(int,input().split())
    S = copy.copy(T[n])
    if d==0:
      S[0] = S[0]-1
    elif d==1:
      S[1] = S[1]-1
    elif d==2:
      S[0] = S[0]+1
    else:
      S[1] = S[1]+1
    T.append(S)
  W,H = 0,0
  T.sort(key=lambda x:x[0])
  W = T[N-1][0] - T[0][0] + 1
  T.sort(key=lambda x:x[1])
  H = T[N-1][1] - T[0][1] + 1
  print(W,H)


Measured memory_bytes: 6340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String up = "QWERTYUIOPASDFGHJKLZXCVBNM";
		String a = sc.next();
		if(up.indexOf(a) >= 0) {
			System.out.println("A");
		}else {

			System.out.println("a");
		}
	}

}

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

const int N = 100000 + 10;
const int oo = 0x3f3f3f3f;

int n, m;
vector<int> g[N];
int mark[N], deg[N];
bool del[N];

void first() {
	printf( "First\n" );
	exit(0);
}
void second() {
	printf( "Second\n" );
	exit(0);
}
int main() {
	scanf( "%d", &n );
	for( int i = 1; i < n; i++ ) {
		int u, v;
		scanf( "%d%d", &u, &v );
		deg[u]++;
		deg[v]++;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<int> z, zz;
	for( int u = 1; u <= n; u++ ) {
		if( deg[u] == 1 ) {
			z.push_back(u);
		}
	}

	int remain = n;
	while(remain) {
		for( int t = 0; t < (int)z.size(); t++ ) {
			int u = z[t];
			for( int tt = 0; tt < (int)g[u].size(); tt++ ) {
				int v = g[u][tt];
				if( del[v] ) continue;
				if( mark[v] ) first();
		//		printf( "%d mark %d\n", u, v );
				mark[v] = true;
				zz.push_back(v);
			}
		}
		/*
		printf( "z: " );
		for( int t = 0; t < (int)z.size(); t++ ) printf( "%d ", z[t] );
		printf( "\nzz: " );
		for( int t = 0; t < (int)zz.size(); t++ ) printf( "%d ", zz[t] );
		printf( "\n" );
		*/

		vector<int> zzz;
		for( int t = 0; t < z.size(); t++ ) {
			int u = z[t];
			if( !del[u] ) remain--;
			del[u] = true;
		}
		for( int t = 0; t < zz.size(); t++ ) {
			int u = zz[t];
			if( !del[u] ) remain--;
			del[u] = true;
		}
		for( int t = 0; t < zz.size(); t++ ) {
			int u = zz[t];
			for( int tt = 0; tt < (int)g[u].size(); tt++ ) {
				int v = g[u][tt];
				if( del[v] ) continue;
				--deg[v];
				if( deg[v] == 0 ) first();
				if( deg[v] == 1 ) {
					zzz.push_back(v);
				}
			}
		}
		z = zzz;
		zz.clear();
	}
	if( remain == 1 )
		first();
	else
		second();
}



Measured memory_bytes: 7036
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
char s[N];int n;
int main(){
	scanf("%s",s+1);
	puts(s[3]==s[4]&&s[5]==s[6]?"Yes":"No");
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll H;
    cin >> H;
    ll ans = 1;
    ll count = 1;
    while (H > 1)
    {
        H /= 2;
        count *= 2;
        ans += count;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
ll t[100010][50];
const ll mod = 1000000007;
void AroundSquare() {
	ll n;
	cin >> n;
	ll i = 1;
	ll b = 0;
	while (i * i <= n)
	{
		b = i * i;
		i++;
	}
	cout << to_string(b) << endl;
}

int main() {
	AroundSquare();

	return 0;
}



Measured memory_bytes: 256