akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//Combination MOD
const ll MOD = INF + 7;
vector<ll> fac(300000);
vector<ll> fac_inv(300000);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;

    ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
    return tmp * fac[a] % MOD;
}


int main(){
    ll n, k;
    cin >> n >> k;


    fac[0] = 1;
    fac_inv[0] = 1;
    for(ll i = 0; i < 300000; i++){
        fac[i + 1] = fac[i] * (i + 1) % MOD;
        fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
    }

    REP(i, 1, k){
        ll res;
        
        res = comb(n - k + 1, i) * comb(k - 1, i - 1) % MOD;
        
        cout << res << endl;
    }

}




Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    int count=0;
    cin>>n;
    cout << fixed;
    if(n%2==0) cout << setprecision(10) << 0.5<<endl;
    else
    {
        double a=(n+1)/2;
        cout<<setprecision(10)<<a/n<<endl;
    }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int a, b;
    cin >> a >> b;
    if ((a + b) & 1) cout << "IMPOSSIBLE\n";
    else cout << (a + b) / 2 << '\n';
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;
 
class Program
{
    static void Main(string[] args)
    {
        label:
        var line = ReadLine();
        int a = Parse(line.Substring(0, 1));
        int b = Parse(line.Substring(1, 1));
        int c = Parse(line.Substring(2, 1));
        int d = Parse(line.Substring(3, 1));
        if (a + b + c + d == 7)
        {
            WriteLine($"{a}+{b}+{c}+{d}=7");
        }
        else if (a + b + c - d == 7)
        {
            WriteLine($"{a}+{b}+{c}-{d}=7");
        }
        else if (a + b - c + d == 7)
        {
            WriteLine($"{a}+{b}-{c}+{d}=7");
        }
        else if (a + b - c - d == 7)
        {
            WriteLine($"{a}+{b}-{c}-{d}=7");
        }
        else if (a - b + c + d == 7)
        {
            WriteLine($"{a}-{b}+{c}+{d}=7");
        }
        else if (a - b + c - d == 7)
        {
            WriteLine($"{a}-{b}+{c}-{d}=7");
        }
        else if (a - b - c + d == 7)
        {
            WriteLine($"{a}-{b}-{c}+{d}=7");
        }
        else if (a - b - c - d == 7)
        {
            WriteLine($"{a}-{b}-{c}-{d}=7");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
  
  
    int n;
    cin>>n;
    vector<int> v(n);
    
    rep(i,n){
        cin>>v[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(v[i]==v[i+1]){
            ans++;
            i++;
        }
        
    }
    cout<<ans<<endl;
    
    
    
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 50

using namespace std;
typedef pair<int, int> ipair;

llong N, x[MAX_N], y[MAX_N];
llong res = INF;

int solve() {
    if(N == 1) {
        res = 1;
        return 0;
    }

    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) {
            if(i == j) continue;

            llong p = x[i] - x[j];
            llong q = y[i] - y[j];

            int cur = 0;
            for(int a = 0; a < N; ++a)
                for(int b = 0; b < N; ++b) {
                    if(a == b) continue;

                    if(x[a] - x[b] == p && y[a] - y[b] == q)
                        ++cur;
                }
            
            res = min(res, N - cur);
        }
}
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }
    
    solve();
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto&i:a) cin>>i;
    unordered_map<int,int> mp;
    ll ans{};
    ifr(i,n){
        ans+=mp[a[i]+i];
        mp[i-a[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19248
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int n;
    cin >> n;
    vs s(n);
    map<string, int> memo;
    rep(i, n)
    {
        cin >> s[i];
        memo[s[i]]++;
    }
    int m = 0;
    vs result;
    rep(i, n)
    {
        m = max(m, memo[s[i]]);
    }
    rep(i, n)
    {
        if(m == memo[s[i]]){
            result.push_back(s[i]);
        }
    }
    sort(result.begin(), result.end());
    map<string, int> memo2;
    for(auto e : result)
    {
        if(memo2.count(e) != 0) continue;
        memo2[e] = 1;
        cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 42100
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int dp[50][500][500];
int main(){
  int N,Ma,Mb;
  cin >> N >> Ma >> Mb;
  for(int i=0; i<50; i++){
    for(int j=0; j<500; j++){
      for(int k=0; k<500; k++){
        dp[i][j][k] = inf;
      }
    }
  }
  dp[0][0][0] = 0;
  for(int i=0; i<N; i++){
    int A,B,C;
    cin >> A >> B >> C;
    for(int a=0; a<500; a++){
      for(int b=0; b<500; b++){
        if(dp[i][a][b] == inf) continue;
        chmin(dp[i+1][a][b],dp[i][a][b]);
        chmin(dp[i+1][a+A][b+B],dp[i][a][b] + C);
      }
    }
  }
  int ans = inf;
  for(int a=1; a<500; a++){
    for(int b=1; b<500; b++){
      if(Mb*a == Ma*b){
        chmin(ans,dp[N][a][b]);
      }
    }
  }
  if(ans == inf){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 49152
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items():
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44280
import math
N=int(input())
points=[]
for i in range(N):
  x,y=map(int,input().split())
  points.append((x,y))

su=0
for i in range(N-1):
  for j in range(i+1,N):
  	d=math.sqrt((points[i][0]-points[j][0])**2+(points[i][1]-points[j][1])**2)
  	su=su+d
print(su*2/N)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;


int main(){
   //boost;
   ll n,x,t;
   cin>>n>>x>>t;
   ll u=(n+x-1)/x;
   cout<<t*u<<endl;
}

    


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll A, B, C;
  cin >> A >> B >> C;

  if (A == B && B != C) {
    cout << "Yes" << endl;
    return 0;
  }

  if (B == C && A != C) {
    cout << "Yes" << endl;
    return 0;
  }

  if (A == C && B != C) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
//vector<string> vs;
int main(){
  ll n;
  cin>>n;
  ll anum=0,bnum=0,doub=0;
  ll ans=0;
  for(int i=1;i<=n;i++){
    string s;
    cin>>s;
    //vs.push_back(s);
    for(ll j=0;j+1<s.length();j++){
      if(s[j]=='A'&&s[j+1]=='B') ans++;
    }
    if(s[0]=='B'&&s[s.length()-1]=='A'){
      doub++;
    }
    else if(s[0]=='B'){
      bnum++;
    }
    else if(s[s.length()-1]=='A'){
      anum++;
    }
  }
//  cout<<ans<<endl;
  ans+=max(doub-1,(ll)0);
  if(anum>0&&doub>0) {
    anum--;
    ans++;
  }
  if(bnum>0&&doub>0){
    ans++;
    bnum--;
  }
//  cout<<ans<<endl;
  ans+=max((ll)0,min(n-1,min(anum,bnum)));
  //cout<<ans<<endl;
//  if(anum!=bnum&&doub>0) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
class Dice:
    def __init__(self):
        self.d = list(map(int, input().split()))

    def setNum(self, n0, n1, n2, n3, n4, n5):
        self.d[0], self.d[1], self.d[2], self.d[3], self.d[4], self.d[5] = (
            n0,
            n1,
            n2,
            n3,
            n4,
            n5,
        )

    def roll(self, direction):
        if direction == "E":
            self.setNum(
                self.d[3], self.d[1], self.d[0], self.d[5], self.d[4], self.d[2]
            )
        elif direction == "N":
            self.setNum(
                self.d[1], self.d[5], self.d[2], self.d[3], self.d[0], self.d[4]
            )
        elif direction == "S":
            self.setNum(
                self.d[4], self.d[0], self.d[2], self.d[3], self.d[5], self.d[1]
            )
        elif direction == "W":
            self.setNum(
                self.d[2], self.d[1], self.d[5], self.d[0], self.d[4], self.d[3]
            )

    def top(self):
        return self.d[0]

    def setTop(self, t):
        if self.d[0] == t:
            return
        elif self.d[1] == t:
            self.roll("N")
        elif self.d[2] == t:
            self.roll("W")
        elif self.d[3] == t:
            self.roll("E")
        elif self.d[4] == t:
            self.roll("S")
        elif self.d[5] == t:
            self.roll("N")
            self.roll("N")

    def getRight(self, f):
        if self.d[2] == f:
            return self.d[4]
        elif self.d[3] == f:
            return self.d[1]
        elif self.d[4] == f:
            return self.d[3]
        else:
            return self.d[2]


dice = Dice()
q = int(input())
for i in range(q):
    t, f = map(int, input().split())
    dice.setTop(t)
    print(dice.getRight(f))



Measured memory_bytes: 5620
def solve():
    N = int(input())
    L0 = 2
    L1 = 1
    if N == 1:
        print(L1)
        exit()
    Li2 = L0
    Li1 = L1
    Li = Li1 + Li2
    for _ in range(N - 2):
        Li2 = Li1
        Li1 = Li
        Li = Li1 + Li2
    print(Li)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

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

    ll k, a, b ,ans;
    cin >> k >> a >> b;

    if(b-a<=1)
        ans = 1 + k;
    else if(k<=a-1)
        ans = 1 + k;
    else{
        k -= (a - 1);
        ans = a;
        ans += (b - a) * (k / 2);
        if(k%2)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = []
a = gets.split(" ").map(&:to_i)

(n-1).times do |i|
  (i+1..n-1).each do |k|
    if a[i] < a[k] then
      a[k],a[i] = a[i],a[k]
    end
  end
end

sum = 0
n.times do |i|
  if i % 2 == 0
    sum += a[i]
  else
    sum -= a[i]
  end
end
print("#{sum}\n")

Measured memory_bytes: 1788
N = int(input())
max = 1
 
x = [1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,11**2,
12**2,
13**2,
14**2,
15**2,
16**2,
17**2,
18**2,
19**2,
20**2,
21**2,
22**2,
23**2,
24**2,
25**2,
26**2,
27**2,
28**2,
29**2,
30**2,
31**2,
]
 
for i in range(len(x)):
    if N >= int(x[i]) :
        if max < int(x[i]) :
            max = int(x[i])
print(max)

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

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if(S.size()<=K) cout << S << endl;
    else if(S.size()>=K){
        for(int i=0;i<K;i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    for(int i = 0; i < n; i++) {
        int temp = a[i];
        ans += a[i] / 2;
        a[i] = temp % 2;
        if(i - 1 > 0 && a[i] > 0 && a[i - 1] > 0) {
            ans++;
            a[i]--;
            a[i - 1]--;
        }
        if(i + 1 < n && a[i] > 0 && a[i + 1] > 0) {
            ans++;
            a[i]--;
            a[i + 1]--;
        }
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>A>>B;
    cout<<(B+A-3)/(A-1)<<endl;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

# 二つの長方形があります。
# 一つ目の長方形は、縦の辺の長さが A、横の辺の長さが Bです。
# 二つ目の長方形は、縦の辺の長さが C、横の辺の長さが Dです。
# この二つの長方形のうち、面積の大きい方の面積を出力してください。
# なお、二つの長方形の面積が等しい時は、その面積を出力してください。

area_ab = A * B
area_cd = C * D

if area_ab > area_cd:
    print(area_ab)
else:
    print(area_cd)

Measured memory_bytes: 8992
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(ins):
    ins = ins.split("\n")
    h = list(map(int, ins[1].split(" ")))
    # costs = [abs(h1 - h2) for h1, h2 in zip(h, h[1:])]
    costs = [10**4 for _ in enumerate(h)]
    costs[0] = 0
    costs[1] = min(costs[1], costs[0] + abs(h[0] - h[1]))
    for i, (h0, h1, h2) in enumerate(zip(h, h[1:], h[2:]), 2):
        costs[i] = min(costs[i - 2] + abs(h2 - h0), costs[i - 1] + abs(h2 - h1))
    return costs[-1]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))


Measured memory_bytes: 14948
<?php
fscanf(STDIN,'%d%d%d',$W,$A,$B);
if($A==$B){
  echo 0;
}else{
  if($A<$B){
    if($A+$W>=$B){
      echo 0;
    }else{
      echo $B-($A+$W);
    }
  }else{
    if($B+$W>=$A){
      echo 0;
    }else{
      echo $A-($B+$W);
    }
  }
}
 ?>


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

//0以下と101以上は塞がれない
int main(){
  int X,N;
  cin >> X >> N;
  unordered_map<int,bool> mp;
  
  int p[N+10];
  rep(i,N){
    cin>>p[i];
    mp[p[i]]=true;
  }
  
  int p1=0,p2=0;
  while(true){
    if(mp[X+p1]!=true){
      cout << X+p1;
      return 0;
    }
    else if(mp[X+p2]!=true){
      cout << X+p2;
      return 0;    
    }else{
      p1--;
      p2++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

void _149() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

void _148() {
    int a, b;
    cin >> a;
    cin >> b;

    int c = 0;
    if ((a != 1) && (b != 1))
        c = 1;
    else if ((a != 2) && (b != 2))
        c = 2;
    else if ((a != 3) && (b != 3))
        c = 3;
    cout << c << endl;
}

void _147() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}

void _146() {
    string s;
    cin >> s;

    vector<string> list = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    for (int i = 0; i < list.size(); ++i) {
        if (s == list[i])
            cout << i + 1 << endl;
    }
}

void _145() {
    int r;
    cin >> r;
    cout << pow(r, 2) << endl;
}

void _144() {
    int a, b;
    cin >> a >> b;

    if ((a >= 1 && a <= 9) && (b >= 1 && b <= 9))
        cout << a * b << endl;
    else
        cout << -1 << endl;
}

int main()
{
    _144();
    return 0;
}



Measured memory_bytes: 256
#!python3

INF = -(10 ** 15)

# input
D, G = list(map(int, input().split()))
p, c = [None] * D, [None] * D
for i in range(D):
    p[i], c[i] = list(map(int, input().split()))


def main():
    dp = [[INF] * 1001 for _ in range(D + 1)]
    dp[0][0] = 0
    for i in range(1, D + 1):
        dp[i][0] = 0
        for j in range(1, 1001):
            for k in range(p[i-1]):
                if k > j:
                    break
                dp[i][j] = max(dp[i][j], dp[i-1][j-k] + 100 * i * k)
            if p[i-1] <= j:
                dp[i][j] = max(dp[i][j], dp[i-1][j-p[i-1]] + 100 * i * p[i-1] + c[i-1])

    for j in range(1, 1001):
        if dp[-1][j] >= G:
            print(j)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    string s1,s2;
    cin >> s1 >> s2;
    //cout << s1 <<endl<< s2 <<endl;
    int n = s1.size(), m= s2.size();
    vector < vector <int> > dp(n+1, vector <int>(m+1));
    s1 = " "+s1;
    s2 = " "+s2;
    for(int i =1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            if(s2[j]==s1[i])dp[i][j]= dp[i-1][j-1]+1;
        }
    }
    string s="";
    int i =n,j=m;
    while(i>0 && j>0){
        if(dp[i][j] !=dp[i][j-1] && dp[i][j]!=dp[i-1][j] && dp[i][j] == dp[i-1][j-1]+1){
                s+=s2[j];
            i--;j--;
        }else if(dp[i][j-1]>=dp[i-1][j]){
            j--;
        }else i--;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}


Measured memory_bytes: 35584
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner input=new Scanner(System.in);
    int a=input.nextInt();
    int b=input.nextInt();
    int c=input.nextInt();
    int k=input.nextInt();
    int result=0;
    if(k<=a){
    result+=k;
    System.out.print(result);
    }
    else if(k<=a+b){
    System.out.print(a);
    }
    else {
    result=2*a+b-k;
    System.out.print(result);
    }
    }
}

Measured memory_bytes: 35564
N = int(input())


def l(i):
    return chr(i + 96)


def f(i, L):
    if i == N + 1:
        print(''.join(list(map(l, L))))
        return
    for d in range(1, min(i + 1, len(set(L)) + 2)):
        f(i + 1, L + [d])


f(1, [])


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    string T;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A') {
            T.push_back('A');
        } else if (i+1 < S.size() && S[i] == 'B' && S[i+1] == 'C') {
            T.push_back('X');
            i++;
        } else if (S[i] == 'B') {
            T.push_back('B');
        } else {
            T.push_back('C');
        }
    }
    int a = 0;
    Int ans = 0;
    for (char t : T) {
        if (t == 'A') a++;
        else if (t == 'X') ans += a;
        else a = 0;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  vector<int> P(N);
  rep(i,N) cin>>S[i]>>P[i];
  vector<pair<pair<string,int>,int>> A(N);
  rep(i,N) A[i]=make_pair(make_pair(S[i],-P[i]),i);
  sort(all(A));
  rep(i,N) cout<<A[i].second+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;

    //ifstream in("/home/spady/Cpp/Practice/tester/debug_out.log");
    //cin.rdbuf(in.rdbuf());

    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep(i, n) {
        cin >> a[i];
        a[i] %= MOD;
    }
    vector<ll> sum(n + 1, 0);
    repp(i, 1, n + 1) { sum[i] = (sum[i - 1] + a[i-1])%MOD; }
    ll res = 0;
    for (ll i = 0; i < n;i++){
        ll m = (sum[n] - sum[i + 1]);
        if (m < 0) m += MOD;
        res += ((a[i] * m) % MOD) % MOD;
    }
    cout << res%MOD << "\n";
    return 0;
}


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

long gcd(long A, long B) {
    while (B != 0) {
        long tmp = A;
        A = B;
        B = tmp % B;
    }
    return A;
}

int main() {
    long A = 0, B = 0;
    if (scanf("%ld%ld", &A, &B) != 0) {
        long GCD = gcd(A, B);
        int sumOfDivisors = 1;
        long i = 2;
        while (i <= sqrt(GCD)) {
            int flag = 1;
            while (GCD % i == 0) {
                GCD /= i;
                if (flag == 1) {
                    sumOfDivisors++;
                    flag = 0;
                }
            }

            ++i;
        }
        if (GCD != 1) {
            sumOfDivisors++;
        }

        printf("%d", sumOfDivisors);
    }

    return 0;
}

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

using namespace std;


struct Union{
	vector<int> par;
	vector<int> size;
	

	Union(int n) : par(n), size(n,1){
	    for(int i=0; i < n; i++){
			size[i] = 1;
			par[i] = i;
		}
	}

	int find(int x){
		if (x == par[x]) return x;
		return par[x] = find(par[x]);  
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);

		if(x == y) return;

		if(size[x] < size[y]) swap(x, y);
		
		par[y] = x;
		size[x] += size[y];
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}

	int getSize(int x){
		return size[find(x)];
	}
};


struct Edge{
	int a, b, cost;

	bool operator<(const Edge& o) const{
		return cost < o.cost;
	}
};


struct Graph{
	int n;  
	vector<Edge> e;  

	int kruskal(){
		sort(e.begin(), e.end());

		Union u(n);
		int min_cost = 0;

	    for(int i=0; i<e.size(); i++){
			Edge& x = e[i];
			if (u.same(x.a, x.b) == false){
				min_cost += x.cost;
				u.unite(x.a, x.b);
			}
		}

		return min_cost;
	}
};

int main(){
	Graph g;
	Edge e;
	int m;
	cin >> g.n >> m;
  
    for(int i=0; i<m; i++){	
		cin >> e.a >> e.b >> e.cost;
		g.e.push_back(e);
	}
  
	cout << g.kruskal() << endl;
  
	return 0;
}


Measured memory_bytes: 4556
//
//  main.cpp
//  单元最短路径
//
//  Created by 陆昱珉 on 2018/12/26.
//  Copyright © 2018 Lu. All rights reserved.
//

//dijkstra algorithm

#include <stdio.h>
#define INF 999999

int n, k;
int color[3000], d[3000];
int map[3000][3000];

int dijkstra(int s)
{
    for(int i = 0; i < n; i ++)
    {
        d[i] = INF;
    }
    d[s] = 0;
    while(1)
    {
        int min = INF;
        int u = -1;
        for(int i = 0; i < n; i ++)
        {
            if(min > d[i] && color[i] != 1)
            {
                u = i;
                min = d[i];
            }
        }
        if(u == -1)
            break;
        color[u] = 1;//染色，以防后面重复使用
        for(int i = 0; i < n; i ++)
        {
            if(color[i] != 1 && map[u][i] != INF)
                if(d[i] > d[u] + map[u][i])
                    d[i] = d[u] + map[u][i];
        }
    }
    return 0;
}

int main(void)
{
    int x, y, v;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
            map[i][j] = INF;
    for(int i = 0; i < n; i ++)
    {
        scanf("%d%d", &x, &k);
        for(int j = 0; j < k; j ++)
        {
            scanf("%d%d", &y, &v);
            map[x][y] = v;
        }
    }
    dijkstra(0);
    
    for(int i = 0; i < n; i ++)
    {
        if(d[i] != INF)
            printf("%d %d", i, d[i]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
template <typename T>
T Max(T a) {
    return a;
}

template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}

Int r, s, p;
#define GOO (0)
#define CHO (1)
#define PAA (2)

Int solve(vector<Int> ary) {
    Int prev[3] = {0};
    Int current[3] = {0};
    for (auto x : ary) {
        switch (x) {
        case GOO:
            current[GOO] = max(prev[CHO], prev[PAA]);
            current[CHO] = max(prev[GOO], prev[PAA]);
            current[PAA] = max(prev[GOO], prev[CHO]) + p;
            break;
        case CHO:
            current[GOO] = max(prev[CHO], prev[PAA]) + r;
            current[CHO] = max(prev[GOO], prev[PAA]);
            current[PAA] = max(prev[GOO], prev[CHO]);
            break;
        case PAA:
            current[GOO] = max(prev[CHO], prev[PAA]);
            current[CHO] = max(prev[GOO], prev[PAA]) + s;
            current[PAA] = max(prev[GOO], prev[CHO]);
        }
        prev[GOO] = current[GOO];
        prev[CHO] = current[CHO];
        prev[PAA] = current[PAA];
    }
    return Max(current[GOO], current[CHO], current[PAA]);
}

int main() {
    Int n, k;
    cin >> n >> k >> r >> s >> p;
    auto ary = vector<vector<Int>>(k, vector<Int>());
    rep(i, n) {
        char c;
        cin >> c;
        ary[i % k].PB(c == 'r' ? GOO : c == 's' ? CHO : PAA);
    }
    Int ans = 0;
    rep(i, k) {
        ans += solve(ary[i]);
    }
    PUTS(ans);
}


Measured memory_bytes: 5120
N = int(input())
lst = []
for n in range(N):
  lst.append(tuple(map(int, input().split())))
lst = sorted(lst, key=lambda x: x[1])
cnt = 0
flag = True
for l in lst:
  cnt += l[0]
  if cnt > l[1]:
    flag = False
print("Yes" if flag else "No")

Measured memory_bytes: 33476
from collections import deque

N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
q = deque()
t = 0
result = 0
for x, h in XH:
    while q:
        if x <= q[0][0]:
            break
        t -= q[0][1]
        q.popleft()
    h -= t
    if h <= 0:
        continue
    c = (h + A - 1) // A
    result += c
    t += c * A
    q.append((x + 2 * D, c * A))
print(result)


Measured memory_bytes: 66368
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  s <- getLine
  if length (group (sort s)) == 3
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 380
#include <iostream>
#include <fstream>
#include <string>


using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");

#endif

	int a, b;
	string op;


	while (true)
	{
		cin >> a >> op >> b;

		if (op[0] == '?') break;

		switch (op[0]){
		case '+':
		{
					cout << a + b << endl;
					break;

		}
		case '-':
		{
					cout << a - b << endl;
					break;

		}
		case '*':
		{
					cout << a * b << endl;
					break;
		}
		case '/':
		{
					cout << a / b << endl;
					break;
		}


		}
	}



}

Measured memory_bytes: 1200
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>
#define N 12
using namespace std;

int f[1 << N | 1];

int main(void)
{
    int n, m, a, b, v, k;
    int i;

    scanf("%d %d", &n, &m);
    for(i = 0; i < (1 << n); i ++)
        f[i] = INT_MAX >> 2;
    f[0] = 0;

    while(m --)
    {
        scanf("%d %d", &a, &b);
        for(v = 0; b --; )
        {
            scanf("%d", &k);
            v |= 1 << (k - 1);
        }

        for(i = (1 << n) - 1; i > -1; i --)
            f[i | v] = min(f[i | v], f[i] + a);
    }
    printf("%d\n", f[(1 << n) - 1] == INT_MAX >> 2 ? -1 : f[(1 << n) - 1]);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
ll gcd(ll a,ll b) { return !b?a:gcd(b,a%b); }
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	if(gcd(a,b)==b) {
		printf("-1");
		return 0;
	}
	for(ll i=a*2;i<1e18;i+=a) {
		if(i%b) {
			printf("%d\n",i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;
 #define LOOP 10000000


int main() {

  string S;
  int length;
  int count = 0;

  cin >> S;
  length = S.length()/2;

  REP(i, length){
    if( S[i] != S[S.length()-i-1] ){
      count++;
    }
  }

  cout << count << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#!/usr/bin/ruby
require 'mathn'
h={};2.step(36){|i|h[i]=i.prime_division}
while(l=gets.chomp)!="0 0"
	l=l.split
	n=l[0].to_i;m=l[1].to_i(n)
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div a) end
		r.div b
	}.min
end

Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=j;i<=k;i++) 
#define dec(i,j,k) for(int i=j;i>=k;i--)
#define mod 1000000007 
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll n,m,k,x,y,a,b,c,d,s,t,ans,q,r;
int arr [N];
const int nax = 1005;

void solve()
{ ll x,k,d;
  cin>>x>>k>>d; 
  x =abs(x);
   ans = x-x/d*d;
    k = k-x/d;
	if(k<0)  
	ans += abs(k*d);
	else if(k&1) 
	ans = abs(ans-d);
   cout<<ans;
}
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	
  
	
	int t=1;
	
 	//cin>>t; 
 
 
	int  a=0;
	while(t--)
	{ // cout<<"Case #"<<++a<<": ";
	   solve();
	   cout<<"\n"; 
	}    
	
    return 0;
}

Measured memory_bytes: 3648
import itertools

X = str(input())
for op in list(itertools.product(['+', '-'], repeat=3)):
    eq = X[0] + op[0] + X[1] + op[1] + X[2] + op[2] + X[3]
    result = eval(eq)
    if result == 7:
        break

print(eq + '=7')


Measured memory_bytes: 3060
from functools import lru_cache
N, A = map(int, input().split())
X = [int(x) for x in input().split()]
#with open("9", "w") as f:
#    print(50, 1, file=f)
#    print(*([1]*50), file=f)
assert len(X) == N
def solve0(i, n, s):
    if s < 0:
        return -1
    if N-i+1 < n:
        return -1
    if n == 0:
        if s == 0:
            return 1
        else:
            return -1
    if i == N:
        return -1
    s1 = solve(i+1, n-1,s-X[i])
    s2 = solve(i+1, n, s)
    if s1 == -1 and s2 == -1:
        return -1
    if s1 == -1:
        return s2
    if s2 == -1:
        return s1
    return s1 + s2

cache = {}
def solve(i, n, s):
    key = (i, n, s)
    a = cache.get(key, None)
    if a is None:
        a = solve0(i, n, s)
        cache[key] = a
    return a

answer = 0
for n in range(1, N+1):
    s = solve(0, n, n*A)
    if s != -1:
        answer += s
print(answer)

Measured memory_bytes: 67844
#include<bits/stdc++.h>
#define N 12000000
using namespace std;
int tot,Next[N],v[N],h[N];
int l[N],r[N],q[N],siz[N],dep[N];
int p[N],son[N],O,ill,cnt;
int n,k;
int ans[N];
int add(int x,int y){
	tot++;
	Next[tot]=h[x];
	v[tot]=y;
	h[x]=tot;
	return 0;
}
int get_siz(int x,int fa){
	siz[x]=1;
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		get_siz(v[i],x);
		siz[x]+=siz[v[i]];
	}
	return 0;
}
int get_son(int x,int fa,int OO){
	son[x]=OO-siz[x];
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		get_son(v[i],x,OO);
		son[x]=max(son[x],siz[v[i]]);
	}
	if(son[x]<son[O])O=x;
	return 0;
}
int get_son(int x){
	son[O]=10000000;
	O=0;
	get_siz(x,0);
	get_son(x,0,siz[x]);
	return O;
}
int AA,BB;
int lfs(int x,int fa){
//	printf("%d\n",x);
	dep[x]=dep[fa]+1;
	siz[x]=1;
	AA=max(AA,dep[x]);
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		lfs(v[i],x);
		siz[x]+=siz[v[i]];
	}
	l[dep[x]]++;
	return 0;
}
int ifs(int x,int fa){
	dep[x]=dep[fa]+1;
	siz[x]=1;
	BB=max(BB,dep[x]);
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		ifs(v[i],x);
		siz[x]+=siz[v[i]];
	}
	r[dep[x]]++;
	return 0;
}
int afs(int x,int fa){
	if(dep[x]>k)return 0;
	ans[x]+=-r[min(k-dep[x],BB)]+l[min(k-dep[x],AA)]+1;
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		afs(v[i],x);
	}
	return 0;
}
int cfs(int x,int fa){
	dep[x]=dep[fa]+1;
	l[dep[x]]=0;
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		cfs(v[i],x);
	}
	return 0;
}
int ccfs(int x,int fa){
	dep[x]=dep[fa]+1;
	r[dep[x]]=0;
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		if(v[i]==fa)continue;
		ccfs(v[i],x);
	}
	return 0;
}
int solve(int x){
	p[x]=1;
	AA=0,BB=0;
	dep[x]=0;
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		lfs(v[i],x);
	}
	for(int i=1;i<=AA;i++)l[i]+=l[i-1];
	ans[x]+=l[min(AA,k)];
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		BB=0;
		ifs(v[i],x);
		for(int i=1;i<=BB;i++)r[i]+=r[i-1];
		afs(v[i],x);
		ccfs(v[i],x);
	}
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		cfs(v[i],x);
	}
	for(int i=h[x];i;i=Next[i]){
		if(p[v[i]]==1)continue;
		int o=get_son(v[i]);
		solve(o);
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&k);
	if(k%2==0){
		k/=2;
		for(int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			add(x,y);
			add(y,x);
		}
	solve(1);
	int O=0;
   	for(int i=1;i<=n;i++)O=max(O,ans[i]);
   	printf("%d\n",n-O-1);
	}
	else{
		for(int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			add(x,n+i);
			add(n+i,x);
			add(y,n+i);
			add(n+i,y);
		}
		int p=n;
		n=n+n-1;
		solve(1);
		int O=0;
		for(int i=n/2+2;i<=n;i++)O=max(O,ans[i]);
//		for(int i=1;i<=20;i++)printf("%d\n",ans[i]);
		if(O+1==n)printf("%d\n",0);
		else printf("%d\n",p-O/2-1);
	}
	return 0;
}

Measured memory_bytes: 4128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		String S = sc.next();
		if (N < 2) {
			System.out.println("No");
			return;
		}
		String before = S.substring(0, N / 2);
		String after = S.substring(N / 2);
		if (before.equals(after)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main() {
	int n, T, A;
	double t;
	double minT = 1000000;
	int ans;

	cin >> n >> T >> A;

	vector<int> H(n);

	for (int i = 0; i < n; i++) {
		cin >> H[i];
		t = T - H[i] * 0.006;
		if (minT > abs(A - t)) {
			minT = abs(A - t);
			ans = i+1;
		}
	}
	cout << ans;
	return 0;
}

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

P p[2][400000];
int q[400000];

#define MAX_LOG 22
template<class T,class comp>
class SparseTable {
	vector<T>t[MAX_LOG];
	vector<int>l2;
public:
	T DEFAULT;
	int n;
	void init(int n_,T DEF) {
		DEFAULT=DEF;
		n = n_;
		rep(i, MAX_LOG)t[i].assign(n, DEFAULT);
		l2.assign(n + 1, 0);
		int k = 0;
		rep(i, n + 1) {
			while ((1 << k + 1) <= i)k++;
			l2[i] = k;
		}
	}
	void set_array(int n_, T*a,T DEF) {
		init(n_,DEF);
		rep(i, n)t[0][i] = a[i];
		for (int i = 1; i < MAX_LOG; i++) {
			for (int j = 0; j + (1 << i - 1) < n; j++){
				if(comp()(t[i-1][j],t[i-1][j+(1<<i-1)]))t[i][j]=t[i-1][j];
				else t[i][j]=t[i-1][j+(1<<i-1)];
			}
		}
	}
	T query(int a, int b) {
		int w = b - a;
		int l = l2[w];
		return comp()(t[l][a],t[l][b-(1<<l)])?t[l][a]:t[l][b - (1 << l)];
	}
};
SparseTable<P,less<P>>t[2];
struct st{
	int l,r;
	bool operator<(const st&b)const{
		return t[l%2].query(l,r)>t[b.l%2].query(b.l,b.r);
	}
};
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &p[i%2][i].first);
		p[!(i%2)][i].first=INT_MAX;
		p[i%2][i].second=i;
	}
	t[0].set_array(n,p[0],P(INT_MAX,0));t[1].set_array(n,p[1],P(INT_MAX,0));
	priority_queue<st>que;
	que.push({0,n});
	int d=0;
	while(!que.empty()){
		st p=que.top();que.pop();
		P a=t[p.l%2].query(p.l,p.r);
		P b=t[!(p.l%2)].query(a.second+1,p.r);
		q[d++]=a.first;q[d++]=b.first;
		if(p.l<a.second)que.push({p.l,a.second});
		if(a.second+1<b.second)que.push({a.second+1,b.second});
		if(b.second+1<p.r)que.push({b.second+1,p.r});
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", q[i]);
	}
	puts("");
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, m, n1, n2, s[51];
vector<int> v[51];

void solve(int p) {
  if(s[p]) return;
  s[p] = 1;
  rep(i, 0, v[p].size()) {
    if(p == n1 && v[p][i] == n2) continue;
    if(p == n2 && v[p][i] == n1) continue;
    solve(v[p][i]);
  }
}

signed main() {
  cin >> n >> m;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    v[a].pb(b);
    v[b].pb(a);
  }
  int ans = 0;
  map<P, int> ss;
  rep(i, 1, n + 1) {
    rep(j, 0, v[i].size()) {
      n1 = v[i][j];
      n2 = i;
      P p = P(min(n1, n2), max(n1, n2));
      if(ss[p]) continue;
      ss[p] = 1;
      solve(1);
      rep(k, 1, n + 1) {
        if(!s[k]) {
          ans++;
          break;
        }
      }
      rep(k, 1, n + 1) s[k] = 0;
    }
  }
  cout << ans << endl;
}


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

int main(){
  	int n,k;cin >> n >> k;
  	long ans=0;
  	for(int i=0;i<n;i++){
      	int t;
      	cin >> t;
    	if(t>=k)ans++;
    }
  	cout << ans;
  	return 0;
}


Measured memory_bytes: 3644