akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,x;
    cin >> n;
    ll arr[n+2] = {0};
    for (ll i = 1; i<n; i++)
    {
        cin >> x;
        arr[x]++;
    }
    for(ll i = 1; i<=n; i++)
    {
        cout << arr[i] << endl;
    }
    return 0;
}   

Measured memory_bytes: 5180
class SegmentTreeBase
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    if @l == @r
      @agg = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  attr_reader :agg, :l, :r

  def update(i, x)
    if @l == @r
      update_single(x)
    else
      (i <= @left_child.r ? @left_child : @right_child).update(i, x)
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  def query(l, r)
    return @agg if l == @l && r == @r
    return @left_child.query(l, r) if r <= @left_child.r
    return @right_child.query(l, r) if @right_child.l <= l
    agg_left = @left_child.query(l, @left_child.r)
    agg_right = @right_child.query(@right_child.l, r)
    return aggregation_of(agg_left, agg_right)
  end
end

class SegmentTree < SegmentTreeBase
  def update_single(x)
    @agg += x
  end

  def aggregation_of(x, y)
    x + y
  end
end

n, q = gets.split.map(&:to_i)
seg = SegmentTree.new(Array.new(n, 0))
q.times do
  c, x, y = gets.split.map(&:to_i)
  if c == 0
    seg.update(x - 1, y)
  else
    puts seg.query(x - 1, y - 1)
  end
end


Measured memory_bytes: 26848
n = int(input())
p = [int(x) for x in input().split()]

tmp=0
s=0
cnt=0
e=0 

for i in range(1,n+1):
   # print(p[i-1],i)
   if p[i-1] != i:
      cnt += 1
   
if cnt == 2 or cnt == 0:
   print("YES")
else:
   print("NO")

# for i in range(0,n-1):
#    if p[i] > p[i+1]:
#       if i == 0:
#          cnt+=1
#          s=i # 交換する場所
#       else:
#          cnt+=1
#          e=i+1  # 交換する場所
#    if i == n-2 and cnt==2:
#       tmp=p[s]
#       p[s]=p[e]
#       p[e]=tmp
   
# if sorted(p) == p:
#    print("YES")
# else:
#    print("NO")

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int an,bn,i,j,count=0;
    scanf("%d",&an);
    int A[an+1];
    for(i=0;i<an;i++)
        scanf("%d",&A[i]);
    scanf("%d",&bn);
    int B[bn+1];
    for(i=0;i<bn;i++)
        scanf("%d",&B[i]);
    
    //search
    for(i=0;i<bn;i++){
        j=0;
        A[an]=B[i];
        while(A[j]!=B[i])
            j++;
        if(j!=an)count++;
        //printf("j=%d\n",j);
    }
    printf("%d\n",count);
    
    return 0;
    
        
}

Measured memory_bytes: 1184
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int sum = 0;
        boolean isYes = true;
        ArrayList<Integer> nums = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            nums.add(in.nextInt());
            sum += nums.get(i);
        }
        in.close();
        Collections.sort(nums);
        for (int i = 0; i < m; i++) {
            if (nums.get(nums.size()-1-i) < sum/(4.0*m)) {
                System.out.println("No");
                isYes = false;
                break;
            }
        }
        if (isYes) {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23636
N = int(input())
A = list(map(int,input().split()))
Ans = 1
for a in A:
    if a == 0:
        print("0")
        break
else:
    for a in A:
        Ans *= a
        if Ans>10**18:
            print("-1")
            break
    else:
        print(Ans)

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

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

    int res;

    switch(n){
        case 0:  res = 1; break;
        case 1:  res = 2; break;
        case 2:  res = 1; break;
        default: res = 0; break;
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int w, a,b;
    cin >> w >> a >> b;
    if (a > b)
    {
        int temp = a;
        a = b;
        b=temp;
    }
    if (a <= b && b <= a + w)
    {
        cout << 0 << endl;
    }
    else
    {
        cout<<b-(a+w)<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int n, k;
    cin >> n >> k;
    int ans = 0;
    ans += max(0, (n * (n - 1) ) / 2);
    ans += max(0, (k * (k - 1) ) / 2 );
    cout << ans << '\n';
    return 0;
}



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

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << ' ' << 2 * a + 2 * b << endl;
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

int main(){
  string s;
  cin >> s;
  bool f = false;
  for(int i = 0; i < s.size() / 2; i++){
    s.pop_back();
    s.pop_back();
    //cout << s << endl;
    for(int j = 0; j < s.size() / 2; j++){
      if(s[j] != s[j + s.size() / 2]){
        break;
      }
      if(j == s.size() / 2 - 1){
        cout << s.size() << endl;
        f = true;
        break;
      }

    }
    if(f){ break; }
  }
  if(f == false){ cout << 2 << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n, m;
bool ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    if (abs(sqrt(1.0 * n) - (int)sqrt(1.0 * n)) < 1e-9) {
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
    return 0;
}

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


Measured memory_bytes: 640
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    sushi = []
    for _ in range(N):
        x, v = map(int, input().split())
        sushi.append((x, v))

    """
    まず最初の観察として、行ったり来たりしながら寿司をゲットするのは非効率。
    なので移動範囲は開始位置を含む円弧になる。
    円弧の左端をA、右端をB、開始位置をOとすると、移動方法は
        OA -> AB もしくはOB -> BA
    の２通り考えられる。

    それぞれに対してはOからの得点の累積和を前計算しておけばO(N^2)で答えが求まる。
    さらに次の工夫をすることでO(N)で計算が可能になる。

    OA->ABの場合で考える。まずBの位置を一箇所固定する。
    この時最適なAの位置をO(1)で取得できれば良いので、あらかじめ
        [v1　-　x1 * 2, v1 + v2 - x2 * 2, v1 + v2 + v3 - x3 * 2, ... ]
    の中の最大値を計算しておけば良い。
    あとはこれに(vN + v(N-1) + ... + vB) - (C - xB)を加えたものが得点になる。
    """

    #累積和の前計算
    A_sum = [0] # = [0, v1, v1 + v2, v1 + v2 + v3, ... ]
    B_sum = [0] # = [0, vN, vN + v(N - 1), vN + v(N - 1) + v(N - 2), ... ]
    A_max = [(0, 0)] # A_max[i] = (i番目の寿司まで見た時に一番得点が大きい場所とその得点の組)
    B_max = [(0, 0)] # B_max[i] = (N-i番目の寿司まで見た時に一番得点が大きい場所とその得点の組)
    for x, v in sushi:
        A_sum.append(A_sum[-1] + v)
        cand = A_sum[-1] - x * 2
        A_max.append(max(A_max[-1], (cand, x)))
    for x, v in sushi[::-1]:
        B_sum.append(B_sum[-1] + v)
        cand = B_sum[-1] - (C - x) * 2
        B_max.append(max(B_max[-1], (cand, x)))
    #print("A_sum={}".format(A_sum))
    #print("B_sum={}".format(B_sum))
    #print("A_max={}".format(A_max))
    #print("B_max={}".format(B_max))

    # OA->ABの場合の最大得点
    ans1 = -10**10
    for b in range(N, 0, -1):
        val = B_sum[N-b+1] - (C - sushi[b - 1][0])
        #print("b={} -> val={}".format(b, val))
        ans1 = max(ans1, A_max[b - 1][0] + val)

    # OB->BAの場合の最大得点
    ans2 = -10**10
    for a in range(1, N + 1):
        val = A_sum[a] - sushi[a - 1][0]
        #print("a={} -> val={}".format(a, val))
        ans2 = max(ans2, B_max[N - a][0] + val)

    print(max(0, ans1, ans2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 107536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

ll fibo(vll &fi, int n) {
  if (n == 0 || n == 1) return 1; 
  if (fi[n] != -1) return fi[n];
  
  fi[n] = fibo(fi, n - 1) + fibo(fi, n - 2);
  return fi[n];
}

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

  vll fi(n + 1, -1);
  cout << fibo(fi, n) << endl;
}



Measured memory_bytes: 3100
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let num: f64 = read();

    println!("{}", 2.0 * num * std::f64::consts::PI);
}

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

int main() {
	char c;
	char v[5];

	cin >> c;
	v[0] = 'a';
	v[1] = 'i';
	v[2] = 'u';
	v[3] = 'e';
	v[4] = 'o';
	bool isV = false;

	for (int i = 0; i < 5; ++i) {
		if (v[i] == c) isV = true;
		}
	if (isV) cout << "vowel" << endl;
	else cout << "consonant" << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort(reverse=True)
    ans = 0

    for i in range(0, n-1):
        now_index = (i+1) // 2
        ans += a[now_index]

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)


Measured memory_bytes: 94092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1e5+10,INF=0x3f3f3f3f;
int n,a[M],k,dp[M];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    memset(dp,INF,sizeof(dp));
    dp[1]=0;
    for(int i=2;i<=n;i++)
        for(int j=1;j<=k && i-j>=1;j++)
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    double rad;
    if(x <= a*b/2) rad = atan2(b*b, 2*x);
    else rad = atan2(2*(a*b-x), a*a);
    double ans = rad / (2*acos(-1)) * 360;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 4148
#include <stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))

int main()
{
    int n;
    scanf("%d", &n);
    int s = 0;
    int no = n;
    while(n!=0){
        s += n % 10;
        n /= 10;
    }
    
    if(no%s==0) printf("Yes");
    else printf("No");
    
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, m, xin, yin, zin;
  cin >> n >> m;
  vector<tuple<ll, ll, ll>> cake(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> xin >> yin >> zin;
    cake[i] = make_tuple(xin, yin, zin);
  }

  ll ans = 0;
  for(int mask = 0; mask <= 8; mask++)
  {
    vector<ll> points;
    for(int i = 0; i < n; ++i)
    {
      ll x, y, z;
      tie(x, y, z) = cake[i];

      ll point = 0;
      point += ((mask & 0b001) > 0) ? x : -x;
      point += ((mask & 0b010) > 0) ? y : -y;
      point += ((mask & 0b100) > 0) ? z : -z;
      points.emplace_back(point);
    }

    sort(points.rbegin(), points.rend());
    auto st = points.begin();
    auto de = next( points.begin(), m);
    ans = max( ans, accumulate(st, de, 0LL) );
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3696
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int n; cin >> n;
	vector<int> a(n), suf(n, 0);
	for (int i = 0; i < n; i++) cin >> a[i];
	suf[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--) suf[i] = (suf[i + 1] + a[i]) % mod;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		ans = (ans + (a[i] * suf[i + 1]) % mod) % mod;
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

int main(int argc, char *argv[]) {
	int D = 0;
	int N = 0;
	std::cin >> D >> N;

	int answer = 0;
	int count = 0;
	switch (D) {
	case 0:
		for (int i = 1; i <= 200; i++) {
			if (i % 100 != 0) {
				count++;
			}
			if (count == N) {
				answer = i;
				break;
			}
		}
		break;
	case 1:
		for (int i = 1; i <= 20000; i++) {
			if (i % 100 == 0 && (i % 10000 != 0)) {
				count++;
			}
			if (count == N) {
				answer = i;
				break;
			}
		}
		break;
	case 2:
		for (int i = 1; i <= 2000000; i++) {
			if (i % 10000 == 0 && i % 1000000 != 0) {
				count++;
			}
			if (count == N) {
				answer = i;
				break;
			}
		}
		break;
	default:
		std::abort();
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>

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

  int c[10][10];
  for (int i=0; i<10; ++i)
    for (int j=0; j<10; ++j)
      scanf("%d", &c[i][j]);

  for (int k=0; k<10; ++k)
    for (int i=0; i<10; ++i)
      for (int j=0; j<10; ++j)
        c[i][j] = std::min(c[i][j], c[i][k]+c[k][j]);

  int res=0;
  for (int i=0; i<H; ++i)
    for (int j=0; j<W; ++j) {
      int d;
      scanf("%d", &d);
      if (d == 1 || d == -1)
        continue;

      res += c[d][1];
    }

  printf("%d\n", res);
  return 0;
}
 

Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            ll = [l[i],l[j],l[k]]
            if ll[2]<ll[0]+ll[1] and ll[1]<ll[0]+ll[2] and ll[0]<ll[1]+ll[2] and len(set(ll))==3:
                ans += 1
#                 print(ll)
print(ans)

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

const int MOD = 1e9 + 7;

int ADD(int x, int y) {
  int res = x + y;
  if (res >= MOD) res -= MOD;
  return res;
}

int MUL(int x, int y) {
  return 1ll * x * y % MOD;
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<vector<int>> dp(2, vector<int>(n + s.size() + 6, 0));
  dp[n & 1][s.size()] = 1;

  for (int i = n - 1; i >= 0; i--) {
    fill(begin(dp[i & 1]), end(dp[i & 1]), 0);
    for (int j = 0; j < n + s.size() + 5; j++) {
      dp[i & 1][j + 1] = ADD(dp[i & 1][j + 1], MUL(2, dp[(i + 1) & 1][j]));
      dp[i & 1][max(0, j - 1)] = ADD(dp[i & 1][max(0, j - 1)], dp[(i + 1) & 1][j]);
    }
  }

  cout << dp[0][0] << "\n";
  return 0;
}


Measured memory_bytes: 384
n = int(input())
cnt = [[0]*9 for _  in range(9)]
for idx in range(1,n+1):
    a = str(idx)
    if a[-1] == '0':
        continue
    cnt[int(a[0])-1][int(a[-1])-1] += 1
ans = 0
for i in range(9):
    for j in range(9):
        ans += cnt[i][j]*cnt[j][i]
print(ans)

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int64_t ans = 0, s = 0;
    for(auto a : A){
        add(ans, s*a);
        add(s, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
 
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   ll n,k,score;
   cin>>n>>k;
   double ans=0.0;
   cout << fixed << setprecision(11);
   for(int i=1;i<=n;i++){
       double ansi=1/double(n);
       score=i;
       if(score>=k){
           ans+=ansi;
           continue;
       }
       for(int j=1;j>0;j++){
           score=score*2;
           ansi=ansi/2;
           if(score>=k){
               ans+=ansi;
               //cout<<i<<" "<<ans<<endl;
               break;
           }
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  string s;
  cin >> s;
  bool flagB = false;
  bool flagW = false;
  ll ans = 0;
  rep(i,s.size()){
    if(i == 0){
      if(s[i] == 'B'){
        flagB = true;
      }
      else{
        flagW = true;
      }
    }
    else{
      if(flagB && s[i] == 'W'){
        flagB = false;
        flagW = true;
        ans++;
      }
      if(flagW && s[i] == 'B'){
        flagW = false;
        flagB = true;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;

    vector<int> A(N);
    int posN = 0, negN = 0;
    rep(i, 0, N) {
        int in;
        cin >> in;
        A[i] = in;
        if (in > 0) ++posN;
        else ++negN;
    }
    sort(A.begin(), A.end());

    vector<pair<int, int>> ops;

    while(A.size() > 1) {
        if (A.size() == 2) {
            int x = max(A[0], A[1]);
            int y = min(A[0], A[1]);
            ops.push_back(make_pair(x, y));
            A.clear();
            A.push_back(x-y);
            break;
        }

        int L = A[0]; int R = A[A.size()-1];

        if (posN >= 2 and negN >= 1) {
            ops.push_back(make_pair(L, R));
            A[0] = L-R;
            --posN;
            A.pop_back();
        }
        else if (posN == 1 and negN >= 1) {
            ops.push_back(make_pair(R, L));
            A[A.size()-1] = R-L;
            --negN;
            A.erase(A.begin());
        }

        else if (posN >= 2 and negN == 0) {
            int x = L;
            int y = A[1];
            ops.push_back(make_pair(x, y));
            A[0] = x-y;
            posN -= 2;
            if (x-y <= 0) ++negN;
            A.erase(A.begin()+1);
        }
        
        else if (posN == 0 and negN >= 2) {
            int x = R;
            int y = A[A.size()-2];
            ops.push_back(make_pair(x, y));
            A[A.size()-2] = x-y;
            --negN; ++posN;
            A.pop_back();
        }
    }

    printf("%d\n", A[0]);
    rep(i, 0, ops.size()) {
        printf("%d %d\n", ops[i].first, ops[i].second);
    }
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int N,M,X,r=INF;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));

	rep(i,N) {
		cin >> C.at(i);
		rep(j,M)
			cin >> A.at(i).at(j);
	}

	rep(i,1<<N) {
		vector<int> al(M,0);
		int t = 0;
		bool ok = 1;

		rep(j,N)
			if(i & 1<<j) {
				t += C.at(j);
				rep(k,M)
					al.at(k) += A.at(j).at(k);
			}

		rep(j,M)
			if(al.at(j) < X)
				ok = 0;

		if(ok)
			r = min(r, t);
	}

	if(r == INF)
		cout << -1;
	else
		cout << r;
	cout << endl;
}

Measured memory_bytes: 3636
def mcxi_to_digit(s)
  h = { 'm' => 1000, 'c' => 100, 'x' => 10, 'i' => 1 }
  sum = 0
  h.each do |k, v|
    if s.include?(k)
      if s[s.index(k)-1] >= '2' and s[s.index(k)-1] <= '9'
        sum += s[s.index(k)-1].to_i * v
      else
        sum += v
      end
    end
  end
  return sum
end

def digit_to_mcxi(n)
  h = { 'm' => 1000, 'c' => 100, 'x' => 10, 'i' => 1 }
  str = ''
  h.to_a.map do |k, v|
    val = n/v
    n = n%v
    if val >= 2
      str += "#{val}#{k}"
    elsif val == 1
      str += k
    end
  end
  return str
end

n = gets.to_i
n.times do
  a, b = gets.chomp.split(' ')
  sum = mcxi_to_digit(a) + mcxi_to_digit(b)
  puts digit_to_mcxi(sum)
end

Measured memory_bytes: 6120
#include <stdio.h>

int main(void){

    long A = 0;
    long B = 0;
    long min = 0;
    long tmp = 0;
    long C = 0;

    scanf("%ld %ld", &A, &B);

    min = A * B;

    if(A < B){
        int tmp = A;
        A = B;
        B = tmp;
    }

    C = A % B;
    while(C != 0){
        A = B;
        B = C;
        C = A % B;
    }

    printf("%ld\n", min/B);

    return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    M, K = map(int, input().split())
    answer = []
    if M==K==1:
        print(-1)
    elif 2**M - 1 < K:
        print(-1)
    elif K == 0:
        for i in range(2**M):
            answer += [i,i]
    else:
        for i in range(K):
            answer += [i]
        for i in range(K+1,2**M):
            answer += [i]
        answer += [K]
        for i in range(1,2**M-K):
            j = 2**M - i
            answer += [j]
        for i in range(2**M-K+1,2**M+1):
            j = 2**M - i
            answer += [j]
        answer += [K]
    print(*answer)
    
    
main()

Measured memory_bytes: 67056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>

using namespace std;
int main()
{
    long long int a, b, c, d;
    long long int n, ans = 0;

    cin >> a >> b >> c >> d >> n;


    if (d > a*8) {
        d = a*8;
    }
    if (c > a*4) {
        b = a*4;
    }
    if (b > a*2) {
        b = a*2;
    }
    if (d > b*4) {
        d = b*4;
    }
    if (c > b*2) {
        c = b*2;
    }
    if (d > c*2) {
        d = c*2;
    }

    if (n%2) {
        cout << d*(n/2)+c << endl;
    }
    else {
        cout << d*(n/2) << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
typedef long long ll;

template <typename _tp> inline void read(_tp&x){
    char ch=getchar(),ob=0;x=0;
    while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 201000;
struct Edge {int v, nxt;} a[N*4];
int head[N], Head[N], indeg[N];
int sz[N], pr[N];
bool vis[N];
int n, _;

inline void add(int x, int y, int*arr) {
    a[++_].v = y, a[_].nxt = arr[x], arr[x] = _;
}

const int p = 1e9+7;
int fac[N], ifac[N], inv[N];

int st[N], tp;
#define FID(i) for(int id=1,i;i=st[id],id<=tp;++id)

int X, Y;
int et, pt;

void bfs(int x, int las) {
    vis[st[++tp] = x] = true;
    for(int i=head[x];i;++et,i=a[i].nxt)
        if(!vis[a[i].v]) bfs(a[i].v, x);
        else if(a[i].v != las) X = x, Y = a[i].v;
}

void tfs(int x, int las) {
    for(int i=head[x];i;i=a[i].nxt)
        if(a[i].v != las and a[i].v != X)
            pr[a[i].v] = x, tfs(a[i].v, x);
}

void dfs(int x, int las) {
    sz[x] = 1;
    for(int i=Head[x];i;i=a[i].nxt)
        if(a[i].v != las)
            dfs(a[i].v, x), sz[x] += sz[a[i].v];
}

int solve() {
    tfs(X, Y);
    pr[X] = Y;
    FID(i) Head[i] = indeg[i] = 0;
    FID(x) for(int i=head[x];i;i=a[i].nxt)
        if(a[i].v < pr[x]) add(x, a[i].v, Head), ++indeg[a[i].v];
    FID(i) if(!indeg[i]) dfs(i, i);
    int Ans = fac[pt];
    FID(i) Ans = (ll)Ans * inv[sz[i]]%p;
	 return Ans;
}

int main() {
    read(n);
    for(int i=1,x,y;i<=(n<<1);++i) {
        read(x), read(y), y += n;
        add(x, y, head), add(y, x, head);
    }
    
    n <<= 1;
    fac[0] = fac[1] = inv[0] = inv[1] = ifac[0] = ifac[1] = 1;
    for(int i=2;i<=n;++i) {
        fac[i] = (ll)fac[i-1] * i%p;
        inv[i] = (ll)(p-p/i) * inv[p%i]%p;
        ifac[i] = (ll)ifac[i-1] * inv[i]%p;
    }
    
    int Ans = fac[n];
    for(int i=1;i<=n;++i)
        if(!vis[i]) {
            tp = pt = et = 0;
				bfs(i, i);
            Ans = (ll)Ans * ifac[pt]%p;
            if((tp << 1) != et) return puts("0"), 0;
            X ^= Y, Y ^= X, X ^= Y;
            int res = solve();
            X ^= Y, Y ^= X, X ^= Y;
            res += solve();
            Ans = (ll)Ans * res%p;
        }
    printf("%d\n", Ans);
    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  long long a; double b;
  cin >> a >> b;
  b = b*100.00 + 1e-12;
  cout << (a*((long long)b))/100LL << '\n';
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>x(m);
    rep(i,0,m){
        cin>>x.at(i);
    }
    sort(all(x));
    vector<int>sa(m-1);

    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,m-1){
        sa.at(i)=abs(x.at(i+1)-x.at(i));
    }
    sort(all(sa),greater<int>());
    int sum=0;
    
    rep(i,0,n-1){
        sum+=sa.at(i);
        //cout<<sa.at(i)<<endl;
    }
    cout<<abs(x.at(m-1)-x.at(0))-sum<<endl;
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int a, pul;
  cin >> a;
  pul = a;
  
  int ans = 0;
  rep(i, 3){
    ans += pul;
    pul *= a;
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    cin>>n>>m;
    for(i=0;i<=n;i++)
    {
        ll s=i*2+(n-i)*4;
        if(s==m)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3652
/*
{

AuThOr Gwj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int main(){
	fastio;
	int n,a,b;
	cin>>n>>a>>b;
	cout<<b*((a+n-1)/a);
	return 0;
}



Measured memory_bytes: 3644
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())

m = {
    0: "",
    1: "0",
    2: "00",
    3: "000",
    4: "0000",
}
m2 = {
    0: "",
    1: "9",
    2: "99",
    3: "999",
    4: "9999",
}
def f(t):
    t = str(t)
    c = 0
    if len(t) > 1:
        if t[0] == t[-1]:
            c += 1

    if len(t) == 1:
        t = t * 2
        c += 1

    for i in range(0, 5):
        p = t[-1] + m[i] + t[0]
        p2 = t[-1] + m2[i] + t[0]

        if str(int(p)) == p and int(p) <= N:
            c += 1
            if len(p) > 2:
                n = 10 ** (len(p) - 2) - 1
                if N < int(p2):
                    n = (N - int(p)) // 10
                c += n

    return c

ans = 0
for i in range(1, N+1):
    ans += f(i)

print(ans)

Measured memory_bytes: 3444
k, n = gets.chomp.split(" ").map{|i|i.to_i}
a = gets.chomp.split(" ").map{|i|i.to_i}

max = 0
max_in = 0
(n-1).downto(0) do |i|
  c = a[i] - a[i-1] if i != 0
  c = k - a[i-1] + a[i] if i == 0
  if max < c
    max = c
  end
end
puts k-max

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

int max(int a, int b){
  if (a>b) return a;
  else return b;
}


int main(){
  int n, a, b, c, val;
  cin>>n;
  for(int i=0; i<n; i++){
    cin >> a>> b>> c;
    val = max(a, max(b,c));
    if((val*val)*2 == a*a+b*b+c*c)
      cout<< "YES"<<endl;
    else
      cout<< "NO"<<endl;
  }
}
      
      

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

const int MAX = 4e6;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int sum = accumulate(A.begin(), A.end(), 0);
	bitset<MAX + 1> bs;
	bs[0] = true;
	for (int i = 0; i < N; i++) {
		bs |= bs << A[i];
	}
	int res = sum;
	for (int i = (sum + 1) / 2; i <= sum; i++) if (bs[i]) {
		res = i;
		break;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
def slope(x1, y1, x2, y2)
  return (y2 - y1).round(5)/(x2 - x1).round(5)
end

result = []

gets.to_i.times{
  xa, ya, xb, yb, xc, yc, xd, yd = gets.split.map(&:to_f)
  ab = slope(xa, ya, xb, yb)
  cd = slope(xc, yc, xd, yd)
  result << ((ab == cd) ? "YES" : "NO")
}

result.each{|r|
  puts r
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

str S;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> S;
	if (S == "SUN") {
		cout << 7;
	} else if (S == "MON") {
		cout << 6;
	} else if (S == "TUE") {
		cout << 5;
	} else if (S == "WED") {
		cout << 4;
	} else if (S == "THU") {
		cout << 3;
	} else if (S == "FRI") {
		cout << 2;
	} else if (S == "SAT") {
		cout << 1;
	}
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include<map>
#include<iostream>
using namespace std;
map <string,int> ma;
int main()
{
    int n;
    cin>>n;
    string s;
    while(n--)
    {
        cin>>s;
        ma[s]+=1;
    }
    map <string, int>::iterator m;
    m=ma.begin();
    int max1=0;
    for(m;m!=ma.end();m++)
    {
        if(m->second>max1)
            max1=m->second;
    }
    m=ma.begin();
    for(m;m!=ma.end();m++)
    {
        if(m->second==max1)
            cout<<m->first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, c, key, l, r, n, m, t, k, d;
    ll t2, t3, t4, t1;
    string s;
    cin >> x >> k >> d;
    ll ans;
    x = abs(x);


    ll val = (x) / d;
    t1 = x - (val * d);
    t2 = abs(x - ((val + 1) * d));
    if (val > k)
    {
        ans = x - k * d;
        cout << ans;
        return 0;
    }
    if (k % 2 == val % 2)
        ans = t1;
    else
        ans = t2;

    cout << ans;




    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
  static final int INF = Integer.MAX_VALUE;
  static int n, k;
  static List< List< Integer > > G;
  static int[][] edges;

  static int[] dist;
  static int count;

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

    n = sc.nextInt(); k = sc.nextInt();
    G = new ArrayList< List< Integer > >(n);
    for(int i = 0; i < n; i++){
      G.add(new ArrayList< Integer >());
    }

    edges = new int[n - 1][2];
    for(int i = 0; i < n - 1; i++){
      int v = sc.nextInt() - 1, w = sc.nextInt() - 1;
      G.get(v).add(w);  G.get(w).add(v);
      edges[i][0] = v;  edges[i][1] = w;
    }

    int ans = INF;
    if(k % 2 == 0){
      int d = k / 2;
      for(int s = 0; s < n; s++){
        count = 0;
        dfsCut(s, -1, 0, d);
        ans = Math.min(ans, count);
      }
    }
    else{
      int d = (k - 1) / 2;
      for(int s = 0; s < n - 1; s++){
        count = 0;
        dfsCut(edges[s][0], edges[s][1], 0, d);
        dfsCut(edges[s][1], edges[s][0], 0, d);
        ans = Math.min(ans, count);
      }
    }

    System.out.println(ans);
  }

  private static void dfsCut(int v, int p, int d, int l){
    if(d > l){
      ++count;
    }
    for(int i = 0; i < G.get(v).size(); i++){
      int w = G.get(v).get(i);
      if(w != p){
        dfsCut(w, v, d + 1, l);
      }
    }
  }
}

Measured memory_bytes: 15872
#include <stdio.h>
#define abs(a) ((a)<0 ? -(a) : (a))
int main(){
  int a, b;  scanf("%d%d", &a, &b);

  if(a > 0 && b > 0)
    printf("Positive\n");
  else if(a==0 || b==0 || (a<0 && 0<b))
    printf("Zero\n");
  else if(abs(b-a) % 2)
    printf("Positive\n");
  else
    printf("Negative\n");
  return 0;
}
    


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int a,b,q; cin >> a >> b >> q;
    vector<ll> s(a),t(b);
    rep(i,a) cin >> s[i];
    rep(i,b) cin >> t[i];
    rep(i,q){
        ll x;cin >> x;
        auto Iter1 = upper_bound(ALL(s),x);
        auto Iter2 = upper_bound(ALL(t),x);
        if(Iter1 == s.begin()) {
            if(Iter2 == t.begin()) cout << max(s[0],t[0])-x << endl;
            else if(Iter2 == t.end()) cout << t[0]-s[a-1]+min(t[0]-x,x-s[a-1]) << endl;
            else cout << min(max(*Iter2,s[0])-x,s[0]-*(Iter2-1)+min(s[0]-x,x-*(Iter2-1))) << endl;
        }else if(Iter1 == s.end()){
            if(Iter2 == t.begin()) cout << t[0]-s[a-1]+min(t[0]-x,x-s[a-1]) << endl;
            else if(Iter2 == t.end()) cout << x-min(t[b-1],s[a-1]) << endl;
            else cout << min(x-min(*(Iter2-1),s[a-1]),*Iter2-s[a-1]+min(*Iter2-x,x-s[a-1])) << endl;
        }else{
            if(Iter2 == t.begin()) cout << min(max(*Iter1,t[0])-x,t[0]-*(Iter1-1)+min(t[0]-x,x-*(Iter1-1))) << endl;
            else if(Iter2 == t.end()) cout << min(x-min(t[b-1],*(Iter1-1)),*Iter1-t[b-1]+min(*Iter1-x,x-t[b-1])) << endl;
            else cout << min(min(max(*Iter2,*Iter1)-x,x-min(*(Iter2-1),*(Iter1-1))),min(*Iter2-*(Iter1-1)+min(*Iter2-x,x-*(Iter1-1)),*Iter1-*(Iter2-1)+min(*Iter1-x,x-*(Iter2-1)))) << endl;
        }
    }
}

Measured memory_bytes: 2944
#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main() {
    int n, a[222222], i,p;
  long long ans=0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        a[i] -= (i+1);
    }
    qsort(a, n, sizeof(int), compare_int);
    p = n / 2;
    if (n % 2 == 1)
        p++;
    p = a[p-1];
    for (i = 0; i < n; i++) {
        a[i] -= p;
        if (a[i] < 0)
            a[i] = -a[i];
        ans += a[i];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    for(int i = 0; i < len(s); ++i){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        }
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << max(ans, cnt) ;
}


Measured memory_bytes: 3620
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
s = set()
for _ in range(N):
    s.add(int(input()))

lis = list(s)
lis.sort()
print(len(lis))

Measured memory_bytes: 62024
package main

import (
	"fmt"
)

func main() {
	var n int
	var offhouse [4][3][10]int
	var b, f, r, v int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&b, &f, &r, &v)
		b--
		f--
		r--
		offhouse[b][f][r] += v
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", offhouse[i][j][k])
			}
			fmt.Printf("\n")
		}
		if i != 3 {
			fmt.Println("####################")
		}
	}
}



Measured memory_bytes: 1132
N=gets.to_i
S=gets.chomp
ret=0
N.times{|i|
    x=S[0..i]
    y=S[i+1...N]
    cnt=0
    ('a'..'z').to_a.each{|c|cnt+=1 if [x,y].all?{|s|s.include?(c)}}
    ret=cnt if cnt>ret
}
p ret

Measured memory_bytes: 3836
#include <iostream>

using namespace std;

int main() {

    int x, y, a, b;
    cin >> x >> y >> a >> b;
    while(1) {
        a -= y;
        if (a <= 0) {
            cout << "Yes";
            break;
        }
        x -= b;
        if (x <= 0) {
            cout << "No";
            break;
        }
    }
    return 0;
}

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

x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[n-1])



Measured memory_bytes: 2940
import copy

H, W, K = map(int, input().split())
data = []
ans = 0
count = 0
for _ in range(H):
    line = list(input())
    count += line.count('#')
    data.append(line)
omega = count

# H, Wのbit全探索を行う。
for h in range(2 ** H):
    copy_data = copy.deepcopy(data)
    for f in range(H):
        if list(bin(h)[2:].zfill(H))[f] == '1':
            count -= copy_data[f].count('#')
            copy_data[f] = ['.' for _ in range(W)]
    tmp = count
    for w in range(2 ** W):
        count = tmp
        for g in range(W):
            if list(bin(w)[2:].zfill(W))[g] == '1':
                for row in copy_data:
                    if row[g] == '#':
                        count -= 1
        if count == K:
            ans += 1
    count = omega

print(ans)


Measured memory_bytes: 9328
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

 int a,b,c;
 cin>>a>>b>>c;
 int ans=b;
 if(c<=a+b+1) ans+=c;
 else ans+=(a+b+1);
 cout<<ans<<endl;
 
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	cin >> n;

	if(n == 1) cout << "Hello World" << endl;
	else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}

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

int main() {

	int a, b; cin >> a >> b;
	string ans = "No";
	for (int i = 1; i <= 3; i++) {
		if (a * b * i % 2 == 1) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> P(n);
  for (int i=0; i<n; i++){
    cin >> P[i];
  }
  int ans = 0;
  for (int i=1; i<n-1; i++){
    if ((P[i-1] < P[i] && P[i] < P[i+1]) || (P[i+1] < P[i] && P[i] < P[i-1])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256