akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABL
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_A();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var k = ReadInt;
            var s = "";
            for (int i = 0; i < k; i++)
            {
                s += "ACL";
            }
            s.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }

        public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
        public static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }
    }
}


Measured memory_bytes: 27484
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int x=s.size();
    for(int i=0;i<x;i++){
        cout<<'x';
    }
    return 0;


}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

namespace ConsoleApp15
{
    class Class404
    {
        static void Main()
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = Abs(r[0] - r[1]);
            int b = Abs(r[0] - r[2]);
            if (a > b)
            {
                Console.WriteLine("B");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}


Measured memory_bytes: 28224
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var k, s int 
  fmt.Scan(&k, &s)

  cnt := 0
  for x := 0; x <= minInt(k, s); x++ {
    t := s - x
    if t <= k {
      cnt += t + 1
    } else if t <= k * 2 {
      cnt += k - (t - k) + 1
    }
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
from functools import *
from itertools import *
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
 
M = 10**9+7
N = int(input())

@lru_cache(maxsize=None)
def mod_inv(x):
  return 1 if x == 1 else M // x * -mod_inv(M%x) % M

Weight = [0]*(N+1)
Size = [0]*(N+1)
def calc_subtree(v):
  W, S = 1, 1
  for child in Edge[v]:
    Edge[child].remove(v)
    w, s = calc_subtree(child)
    W = W * w % M
    S += s
  Weight[v] = W * S % M
  Size[v] = S
  return Weight[v], Size[v]

Ans = [0]*(N+1)
def calc_ans(v, a):
  Ans[v] = a
  for child in Edge[v]:
    n = Size[child]
    calc_ans(child, a * n * mod_inv(N-n) % M)

Edge = [set() for i in range(N+1)]
fact = N
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)
  
calc_subtree(1)
calc_ans(1, mod_inv(Weight[1]) * fact % M)

for a in islice(Ans, 1, None):
  print(a)



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

int main(){
  string str;
  int n = 0,w = 0,s = 0,e = 0,ans = 0;
  cin >> str;

  for(int i = 0; i < str.length();i++){
    if(str[i] == 'N'){
      n++;
    }else if(str[i] == 'W'){
      w++;
    }else if(str[i] == 'S'){
      s++;
    }else if(str[i] == 'E'){
      e++;
    }
  }

  if(n*s != 0){
    ans ++;
  }else if(n >= 1 && s == 0){
    ans -= 1000;
  }else if(s >= 1 && n == 0){
    ans -= 1000;
  }
  if(w*e != 0){
    ans ++;
  }else if(w >= 1 && e == 0){
    ans -= 1000;
  }else if(e >= 1 && w == 0){
    ans -= 1000;
  }

  if(ans >= 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
A,B  =map(int,input().split())
K = 50
S = [['.']*(2*K) for _ in range(2*K)]
for i in range(K):
    for j in range(2*K):
        S[i][j] ='#'
i,j = 0,0
A-=1
B-=1
while A>0:
    S[i][j] ='.'
    if j +2 <2*K:
        j +=2
    else:
        i += 2
        j=0
    A-=1
i,j = 2*K-1,2*K-1
while B>0:
    S[i][j]='#'
    if j-2>0:
        j-=2
    else:
        i-=2
        j=2*K-1
    B-=1
print(str(2*K)+' '+str(2*K))
for s in S:
    print(''.join(s))

Measured memory_bytes: 64012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;

  int n = s.size()+1;

  vector<int> res(n);
  res[0] = 0;
  int minv = 0;
  int cv = 0;
  rep1(i,n-1){
    if(s[i-1]=='<') {
      res[i-1] = cv;
      cv++;
      if(i==n-1) res[i] = cv;
    }
    else{
      res[i-1] = cv;
      cv=0;
    }
  }
  cv = 0;
  for(int i=n-1;i>=1;i--){
    if(s[i-1]=='>'){
      res[i] = max(cv,res[i]);
      cv++;
      if(i==1) res[i-1] = max(cv,res[i-1]);
    }
    else{
      res[i] = max(cv,res[i]);
      cv=0;
    }
  }
  ll ans =0;
  rep(i,n){
    // cout << res[i] << endl;
    ans += res[i];
  }
  cout << ans << endl;

  return 0;
    

}


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

int main() {
	int N; cin >> N;N++;
	vector<int> h(N);
	for(int i = 1 ; i < N ; i++){
		cin >> h[i];
	}
	vector<vector<int>> garden(N,vector<int>(100));
	for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j < h[i] ; j++){
			garden[i][j] = 1;
		}
	}
	int ans = 0;
	for(int i = 0 ; i < N - 1 ; i++){
		for(int j = 0 ; j < 100 ; j++){
			if(garden[i][j] == 0 && garden[i+1][j] == 1)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)

const ll mod = 1e+9 + 7;
const int maxn = 200000 + 10;
ll fact[maxn];
ll rfact[maxn];

ll inv(ll a, ll p)
{
    return a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p;
}

void precalc()
{
    fact[0] = 1;
    rfact[0] = 1;
    for(int i = 1; i < maxn; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
        rfact[i] = inv(fact[i], mod);
    }
}



ll cnm(ll m, ll n)
{
    return (fact[n] * ((rfact[n - m] * rfact[m]) % mod)) % mod;
}

ll f(ll m, ll n)
{
    return cnm(m - 1, m + n - 2);
}

void solve()
{
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    precalc();
    ll res = 0;
    for(ll i = b + 1; i <= w; i++)
    {
        res += (f(h - a, i) * f(a, w - i + 1)) % mod;
        res %= mod;
    }
    cout << res << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    solve();
    return 0;
}

Measured memory_bytes: 3328
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = [None]*N
for i in range(N):
    k = int(input())
    tmp = [None]*k
    for j in range(k):
        tmp[j] = list(map(int,input().split(' ')))
    l[i] = tmp

M = 0
A = [2]*N
n = 2**N
for i in range(2**N):#1の人が正しいとする
    bin_num = bin(i)
    bin_str = str(bin_num)
    bin_str = bin_str[2:].zfill(N)
    k = list(bin_str)
    flag = False
    for j in range(N):
        s = k[j]
        if s=='1':
            correct = l[j]
            for num,opinion in correct:
                if k[num-1]!=str(opinion):
                    flag = True
                    break
            if flag:
                break
    if not flag:
        M = max(M,sum(list(map(int, bin_str))))
print(M)

Measured memory_bytes: 3064
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int N=S.size();
	int sum=0;
	rep(i,N){
		sum+=S[i]-'0';
	}
	if(sum%9==0) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 3732
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    e = [i * (i + 1) / (2 * i) for i in range(1, 1001)]

    sum = [0] * n
    sum[0] = e[p[0] - 1]
    for i in range(1, n):
        sum[i] = sum[i - 1] + e[p[i] - 1]

    max = sum[k - 1]
    for i in range(k, n):
        if max < sum[i] - sum[i - k]:
            max = sum[i] - sum[i - k]

    print(max)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int x;
    int y;
    int flg;
}data;

//x軸の昇順
int xasc(const void* a, const void* b){
    data p = *(data*)a;
    data q = *(data*)b;
    if(p.x!=q.x) return p.x-q.x;
    else return p.y-q.y;
}

//y軸の降順
int ydesc(const void* a, const void* b){
    data p = *(data*)a;
    data q = *(data*)b;
    if(p.y!=q.y) return q.y-p.y;
    else return q.x-p.x;
}

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

    //A[0]~A[N-1]に格納する
    data* red;
    NEW(red,N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&red[i].x,&red[i].y);
        red[i].flg=0;
    }
    qsort(red,N,sizeof(data),ydesc);

    data* blue;
    NEW(blue,N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&blue[i].x,&blue[i].y);
        blue[i].flg=0;
    }
    qsort(blue,N,sizeof(data),xasc);

    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(red[j].flg) continue;
            if(red[j].x<blue[i].x && red[j].y<blue[i].y){
                ans++;
                red[j].flg=1;
                break;
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int c1, c2;
  c1 = n  * a;
  c2 = b;
  if(c1 < c2) {
    cout << c1 << endl;
  }
  else {
    cout << c2 <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
	
int main(){
	int x, a;
	cin >> x >> a;
	if(x < a)cout << 0  << endl;
	else cout << 10 << endl;
	return 0;
}                  
















Measured memory_bytes: 3600
#include <stdio.h>
#include <stack>
using namespace std;
int main(){
    char a[100];
    int now,x,y;
    stack<int>ans;
    for(int i=0;i<100;i++)a[i]='\0';
    while(scanf("%s",a)!=EOF){
        now=0;
        while(a[now]!='\0')now++;
        if(a[0]=='-'){
            y=ans.top();
            ans.pop();
            x=ans.top();
            ans.pop();
            ans.push(x-y);
        }
        else if(a[0]=='+'){
            y=ans.top();
            ans.pop();
            x=ans.top();
            ans.pop();
            ans.push(x+y);
        }
        else if(a[0]=='*'){
            y=ans.top();
            ans.pop();
            x=ans.top();
            ans.pop();
            ans.push(x*y);
        }
        else if(a[0]=='/')break;
        
        else {
            y=0;
            for(int i=0;i<now;i++){
                y+=a[i]-'0';
                y*=10;
            }
            ans.push(y/10);
        }
        for(int i=0;i<now;i++)a[i]='\0';
    }
    printf("%d\n",ans.top());
}

Measured memory_bytes: 2768
#include <bits/stdc++.h>
                using namespace std;
                 
                int main() {
                  char c;
                 
                  cin >> c;
                  
                  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
                    cout << "vowel" << endl;
                  
                  else
                    cout << "consonant" << endl;
                }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

/*
//ABC89 D
int main(void) {
	ll h, w, d;
	cin >> h >> w >> d;
	vector<pair<ll, ll>> a = vector<pair<ll, ll>>(h * w + 1);
	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			ll num;
			cin >> num;
			a[num] = make_pair(i, j);
		}
	}
	vector<ll> ruiseki = vector<ll>(h * w + 1, 0);
	rep(i, 1, d + 1) {
		for (ll j = i+d; j < h * w + 1; j += d) {
			pair<ll, ll> nowP = a[j - d];
			pair<ll, ll> nextP = a[j];
			ruiseki[j] = ruiseki[j - d] + abs(nowP.first - nextP.first) + abs(nowP.second - nextP.second);
		}
	}
	ll q;
	cin >> q;
	rep(i, 0, q) {
		ll l, r;
		cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l] << endl;
	}
}
*/

//ABC 80 C
int main(void) {
	ll n;
	cin >> n;
	vector<vector<ll>> shop_time = vector<vector<ll>>(n, vector<ll>(10));
	vector<vector<ll>> shop_value = vector<vector<ll>>(n, vector<ll>(11));
	rep(i, 0, n) {
		rep(j, 0, 10) {
			ll f;
			cin >> f;
			shop_time[i][j] = f;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11) {
			ll v;
			cin >> v;
			shop_value[i][j] = v;
		}
	}
	ll ans = -1e10;
	rep(i, 1, pow(2, 10)) {
		vector<ll> shop_count = vector<ll>(n);
		rep(j, 0, 10) {
			if (i & (1 << j)) {
				rep(k, 0, n) {
					if (shop_time[k][j]) {
						shop_count[k]++;
					}
				}
			}
		}
		ll ans_cand = 0;
		rep(j, 0, n) {
			ans_cand += shop_value[j][shop_count[j]];
		}
		ans = max(ans, ans_cand);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func min(nums ...int) int {
	min := nums[0]
	for _, v := range nums {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	fmt.Println(min(n*a, b))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  cout << n * n << endl;
}


Measured memory_bytes: 3660
N,M = gets.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i).sort.reverse
@count = Array.new(A[0]+1,0)
@sumA = []
A.each_with_index do |a,i|
  @count[a] += 1
  @sumA[i] = (@sumA[i-1] || 0) + A[i]
end
A[0].times do |i|
  @count[-i-2] += @count[-i-1]
end

def 点以上取れるパターン数 x
  count = 0
  N.times do |i|
    point = x - A[i]
    if point <= 0
      count += N 
    else
      count += @count[point] || 0
    end
  end
  count
end

left = 0
right = A[0]*2 + 1
while(left+1<right) do
  x = (left + right) >>1
  m = 点以上取れるパターン数(x)
  # p [x, m]
  if m >= M
    left = x
  else
    right = x
  end
end
x = left
m = 点以上取れるパターン数(x)
result = 0

N.times do |i|
  need = x - A[i]
  need = 0 if need <= 0 
  count = @count[need]||0
  if count > 0
    result += @sumA[count-1] + (A[i] * count)
  end
end
result -= (m-M)*x
puts result

Measured memory_bytes: 12184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


    
string solve2(ll N){
    string S;
    
    ll base = 1;
    rep(j, 20){
        N -= base;
        if (N < base * 26){
            rep(i, j + 1){
                S += 'a' + N %26;
                N /= 26;
            }
            string U;
            int k = S.size();
            rep(i, k){
                U += S[k - 1 - i];
            }
            //cout << U;
            return U;
        }
        base *= 26;
    }

}
int main() {
    //1000000000000001
    ll N;
    cin >> N;
    cout << solve2(N);
#if 0
    string U;
    int k = S.size();
    rep(i, k){
        U += S[k - 1 - i];
    }
    cout << U;
#endif
    return 0;
#if 0    
    if (N == 1){
        cout << "a";
        return 0;
    }
    
    N = 26 * 26 + 1;
    N--;
    int ii = 0;
    while (N > 0){
        if (N % 26 == 0){
            N/=26;
            continue;
        }
        //cout << N << " " << N % 26 << " " << N/26 << endl;
        if (ii != 0){
            S  += 'a' + N %26 - 1;
        } else {
            S  += 'a' + N %26;
        }
        N/=26;

        ii++;
    }
    //cout << S << endl;
    string U;
    int k = S.size();
    rep(i, k){
        U += S[k - 1 - i];
    }
    cout << U;
#endif
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      ll n;
      cin >> n;
      string s="";
      while(n>0){
            n--;
            int x = n%26;
            s = (char) ('a' + x)+s;
            n /= 26;
      }

      cout << s;


      
}


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

int main(){

	string str;
	cin >> str;
	
	int n;
	cin >> n;

	string com, sub;
	int a, b;

	while(n > 0){
		cin >> com >> a >> b;
		if(com == "replace"){
			cin >> sub;
			str.replace(a,b-a+1,sub);
		}
		else if(com == "reverse"){
			sub = str.substr(a,b-a+1);
			for(int i=0; i<sub.length(); ++i){
				str[a+i] = sub[sub.length()-i-1];
			}
		}
		else{
			cout << str.substr(a,b-a+1) << endl;
		}
		n += -1;
	}

	return 0;

}



Measured memory_bytes: 3204
def II():return int(input())
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes")
def ng():print("No");exit()

n,x,y=MI()

ans=[0]*n

for i in range(1,n+1):
    for j in range(i+1,n+1):
        num=min(abs(i-j),abs(x-i)+abs(y-j)+1)
        ans[num]+=1

for an in ans[1:]:
    print(an)

Measured memory_bytes: 3444
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import radians, cos, sqrt
def main():
    a, b, h, m = map(int, input().split())

    jishin_degree = h * 30 + m * 0.5
    bushin_degree = m * 6
    kakudo = abs(jishin_degree - bushin_degree)

    r = sqrt(a**2 + b**2 - 2 * a * b * cos(radians(kakudo)))
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >>  S;
    S[3] = '8';
    cout << S << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
   int w,h,n; cin >> w >> h >> n;

   vector<int> x(n);
   vector<int> y(n);
   vector<int> a(n);
   rep(i,n) cin >> x[i] >> y[i] >> a[i];

   int y_min = 0,y_max = h,x_min = 0,x_max = w;

    for (int i = 0; i < n; ++i) {
        if(a[i] == 1)if(x[i] > x_min)x_min = x[i];
        if(a[i] == 2)if(x[i] < x_max)x_max = x[i];
        if(a[i] == 3)if(y[i] > y_min)y_min = y[i];
        if(a[i] == 4)if(y[i] < y_max)y_max = y[i];
    }
    if(y_max > y_min && x_max > x_min)print((x_max - x_min) * (y_max - y_min));
    else print(0);

}

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

int main() {
    double n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++) {
        int num = ceil(log2(k/i));
        ans += 1/n*pow(1/2.,num<0?0:num);
    }
    printf("%.12f\n", ans);
    return 0;
}


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

struct BIT
{
    std::array<std::vector<std::int32_t>, 2> dat;
    std::int32_t unity_sum = 0;

    BIT(std::size_t n)
    {
        dat[0].assign(n + 1, unity_sum);
        dat[1].assign(n + 1, unity_sum);
    }

    inline void add(std::int32_t a, std::int32_t b, std::int32_t x)
    {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    inline std::int32_t sum(std::int32_t a, std::int32_t b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1)
             - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

  private:

    // 1-origin, [a, b)
    inline void sub_add(std::int32_t p, std::int32_t a, std::int32_t x)
    {
        for (std::int32_t i=a; i < dat[p].size(); i += i & -i)
        {
            dat[p][i] = dat[p][i] + x;
        }
    }

    inline std::int32_t sub_sum(std::int32_t p, std::int32_t a)
    {
        std::int32_t res = unity_sum;
        for (std::int32_t i = a; i > 0; i -= i & -i)
        {
            res = res + dat[p][i];
        }
        return res;
    }
};

int main()
{
    std::size_t N, Q;
    std::cin >> N >> Q;

    std::vector<std::int32_t> C(N);
    for(auto& c : C)
    {
        std::cin >> c;
    }

    std::vector<std::int32_t> Ls(Q);
    std::vector<std::int32_t> Rs(Q);
    std::vector<std::int32_t> ids(Q);

    for(std::size_t i=0; i<Q; ++i)
    {
        std::cin >> Ls[i] >> Rs[i];
        Ls[i] -= 1;
        ids[i] = i;
    }
    std::sort(ids.begin(), ids.end(), [&](const auto i, const auto j) {
                return Rs[i] < Rs[j];
            });

    BIT bit(N+5);

    std::vector<std::int32_t> prev(1100000, -1);
    std::vector<std::int32_t> res(Q, 0);

    int r = 0;
    for(const auto i : ids)
    {
        for(; r < Rs[i]; ++r)
        {
            bit.add(prev.at(C.at(r)) + 2, r+2, 1);
            prev.at(C.at(r)) = r;
        }

        int tmp = bit.sum(Ls[i]+1, Ls[i]+2);
        res[i] = std::max(res[i], tmp);
    }

    for(const auto& a : res)
    {
        std::cout << a << std::endl;
    }


    return 0;
}


Measured memory_bytes: 21728
#include <cstdio>
#include <cstring>

using namespace std;

#define S_MAX 102
char S[S_MAX];
int K;

void solve() {
}

int main() {
  scanf("%d", &K);
  scanf("%s", &S);
  //  printf("S=<%s>\n", S);
  if (strlen(S) <= K) printf("%s\n", S);
  else {
    for (int i = 0; i < K; i++) printf("%c", S[i]);
    printf("...\n");
  }

}







Measured memory_bytes: 1660
N=int(input())
p=list(map(int,input().split()))
D=[]
for i in range(1,N+1):
    if i==p[i-1]:
        D.append(1)
    else:
        D.append(0)
D.append(0)
tmp=0
ans=0
for i in range(N+1):
    if D[i]==1:
        tmp+=1
    else:
        if tmp==1:
            ans+=tmp
        elif tmp>=2:
            ans+=tmp//2+tmp%2
        tmp=0
print(ans)


Measured memory_bytes: 56300
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s; cin >> s;
  if (s[0] == '9' or s[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>

#define EMPTY 0

int main(void) {
    int i, car_stack[100];
    for(i = 0; i < 100; i++) car_stack[i] = EMPTY;                                                                                                      

    int id_coming_car;
    int pos_head = 0;
    while(scanf("%d", &id_coming_car) != EOF) {
        if(id_coming_car != 0) car_stack[pos_head++] = id_coming_car;
        else {
            printf("%d\n", car_stack[--pos_head]);
            car_stack[pos_head] = EMPTY;
        }
    }

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long long a[2010];
long long m=1e9+7;
int main(){
	long long n,k;
	cin >> n >> k;
	long long aa=(((k+1)*k)/2)%m;
	long long bb=((k*(k-1))/2)%m;
	for(long long i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	long long qian=0,hou=0;
	for(long long i=0;i<n;i++){
		for(long long j=i+1;j<n;j++){
			if(a[i]<a[j]){
				qian++;
				qian=qian%m;
			}
			else if(a[i]>a[j])
				hou++;
				hou=hou%m;
		}
	}
	long long ans=((hou*(aa%m))%m+(qian*(bb%m))%m)%m;
	cout << ans;
    return 0;
}//12312

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef complex<int> P;

int m,n,x,y;
P c[200],s[1000];

int main(){
	while(cin>>m){
		if(!m)return 0;
		int mx=9999999,my=9999999,M;
		for(int i=0;i<m;i++){
			cin>>x>>y;
			if(x<mx||x==mx&&y<my){mx=x;my=y;M=i;}
			c[i]=P(x,y);
		}
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			s[i]=P(x,y);
		}
		for(int i=0;i<n;i++){
			P dif=s[i]-c[M];
			int f=0;
			for(int j=0;j<m;j++){
				P t=c[j]+dif;
				int f2=0;
				for(int k=0;k<n;k++){
					if(s[k]==t){f2=1;break;}
				}
				if(!f2){f=1;break;}
			}
			if(!f){cout<<dif.real()<<" "<<dif.imag()<<endl;break;}
		}
	}
}

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

using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int h, w;
char maze[1010][1010];
ll dp[1010][1010];

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

  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> maze[i];

  dp[1][1] = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (i == 1 && j == 1) continue;
      if (maze[i-1][j-1] == '#') continue;
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
    }
  }
  cout << dp[h][w] << endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

bool pal(string S){
    if(S == "") return true;
    int l = 0, r = S.size()-1;
    while(l <= r){
        if(S[l] == S[r]){
            l++, r--;
        }
        else return false;
    }
    return true;
}

int main(){
    string S; cin >> S;
    int N = S.size();
    if(!pal(S)) {cout << "No" << endl; return 0;}
    string sub1 = S.substr(0, (N-1)/2);
    //cout << sub1 << endl;
    if(!pal(sub1)) {cout << "No" << endl; return 0;}
    string sub2 = S.substr((N+3)/2-1);
    //cout << sub2 << endl;
    if(!pal(sub2)) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;




}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  if(n<m){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
    }
  for(int i=n-m;i>=0;i--){
    bool flag=true;
    rep(j,m){
      if(s[i+j]!=t[j]&&s[i+j]!='?')
        flag=false;
      }
    if(flag){
      rep(j,i){
        if(s[j]=='?')cout<<'a';
        else cout<<s[j];
        }
      cout<<t;
      for(int j=i+m;j<n;j++){
        if(s[j]=='?')cout<<'a';
        else cout<<s[j];
        }
      cout<<endl;
      return 0;
      }
    }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
  }

Measured memory_bytes: 256
n,*d=map(int,open(0).read().split())
if 0 in d or d.count(12)>1 or any(d.count(x)>2 for x in range(1,12)) or n>24:
	print(0)
elif n>11:
	print(1)
else:
	m=0
	for i in range(2**n):
		l=[0,24]
		for j in range(n):
			if i>>j&1:
				l.append(24-d[j])
			else:
				l.append(d[j])
		l.sort()
		m=max(m,min(j-i for i,j in zip(l,l[1:])))
	print(m)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, sum int
	fmt.Scan(&N)
	L := make([]int, N)
	for i := range L {
		fmt.Scan(&L[i])
	}
	sort.Ints(L)
	for i := 0; i < N-1; i++ {
		sum += L[i]
	}
	if sum > L[len(L)-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int c=0;
	    for(int i=1; i<=N; i++) {
	    	int p=gi();
	    	if(p!=i)c++;
	    }
        //System.out.print(a);
        if (c<=2) {
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35676
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	private static Map<String, Integer> map = new HashMap<>();
	
	static {
		map.put("S", 0);
		map.put("H", 1);
		map.put("C", 2);
		map.put("D", 3);
	}

	public static void main(String[] args) {
		
		boolean given[][] = new boolean[4][13];
		
		try (Scanner sc = new Scanner(System.in);) {
			
			int n = sc.nextInt();
			
			for(int i = 0; i < n; i++) {
				String suit = sc.next();
				int rank = sc.nextInt();
				
				given[getIntSuit(suit)][rank - 1] = true;
			}
			
			for(int i = 0; i < 4; i++) {
				for(int j = 0; j < 13; j++) {
					if(!given[i][j]) {
						System.out.println(getStringSuit(i) + " " + (j + 1));
					}
				}
			}
		}
	}
	
	private static int getIntSuit(String str) {
		return map.get(str);
	}
	
	private static String getStringSuit(int i) {
		Set<Map.Entry<String, Integer>> entry = map.entrySet();
		
		for(Map.Entry<String, Integer> e : entry) {
			if(e.getValue().equals(i)) {
				return e.getKey();
			}
		}
		
		return ""; //unused
	}
}



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

bool prime(int x){
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

int main(){
    int x;cin>>x;
    while(!prime(x)) x++;
    cout<<x<<endl;
}

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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 105;
int n, st, mks, ctr[2];
vi adj[MAXN];
vector<pii> opt;

ll ans = 0ll, mtp = 0ll;
int que[2][MAXN], qr[2], ct;
bool vis[MAXN];

void getst (int now, int par, int l) {
	if (l>mks) {
		mks = l;
		st = now;
	}
	for (auto nex : adj[now]) {
		if (nex==par) continue;
		getst(nex,now,l+1);
	}
}

vi stk;
void getctr (int now, int par, int l) {
	stk.psb(now);
	if (l>mks) {
		mks = l;
		opt.clear();
	}
	if (l==mks) {
		if (l&1) {
			ct = stk[l/2];
		} else {
			ctr[0] = stk[(l/2)];
			ctr[1] = stk[(l/2)-1];
		}
	}
	for (auto nex : adj[now]) {
		if (nex==par) continue;
		getctr(nex,now,l+1);
	}
	stk.ppb();
}

void init () {
	setnul(vis);
	qr[0] = qr[1] = 0;
	// printf ("ctr = %d %d\n", 
	que[0][qr[0]++] = ctr[0];
	vis[ctr[0]] = 1;
	if (ctr[1]!=-1) {
		que[0][qr[0]++] = ctr[1];
		vis[ctr[1]] = 1;
	}
}

int countdeg (int x) {
	int ret = 0;
	for (auto nex : adj[x])
		if (!vis[nex]) ret++;
	return ret;
}

void solve () {
	int ia = 0, ib = 1;
	ans = (ll) qr[0];

	while (1) {
		ia ^= 1; ib ^= 1;
		qr[ia] = 0;

		// printf ("stat : ");
		// for (int i=0; i<qr[ib]; i++)
		// 	printf ("%d ", que[ib][i]);
		// endln;


		int mc = 0;
		for (int i=0; i<qr[ib]; i++)
			mc = max(mc, countdeg(que[ib][i]));
		if (mc==0) return;

		ans += ans * (mc-1);
		// printf ("mtp = %lld, ans = %lld\n", mtp, ans);

		for (int i=0; i<qr[ib]; i++) {
			for (auto nex : adj[que[ib][i]]) {
				if (vis[nex]) continue;
				vis[nex] = 1;
				que[ia][qr[ia]++] = nex;
			}
		}

		assert (ans>=0ll);

		// printf ("ans = %lld\n", ans);
	}
}


int main() {
	gi(n);
	for (int i=1; i<n; i++) {
		int u,v; gi(u); gi(v);
		adj[u].psb(v);
		adj[v].psb(u);
	}
	mks = 0;
	getst(1,-1,1);
	mks = 0;
	getctr(st,-1,1);

	if (!(mks&1)) {
		opt.psb({ctr[0], ctr[1]});
	} else {
		opt.psb({ct,-1});
		for (auto xx : adj[ct])
			opt.psb({ct,xx});
	}

	ll fin = infll;
	for (auto xx : opt) {
		ans = 0ll; mtp = 0ll;
		ctr[0] = xx.fi; ctr[1] = xx.se;
		init();
		solve();
		// printf ("ans = %lld\n",ans);
		fin = min(fin, ans);
	}

	printf ("%d %lld\n", (mks+1)/2, fin);
	return 0;
}

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

using namespace std;

ll gcd(ll a, ll b) {
  if(a < b)
    gcd(b, a);
  ll r;
  while((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

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

int main() {
  ll out, a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  lint N = S.length();
  lint M = T.length();

  lint ans = 1e18;
  for(lint i=0; i<N; i++) {
    string sub = S.substr(i,M);
    if(sub.length() != M) continue;
    lint diff = 0;
    for(lint j=0; j<M; j++) {
      diff += (sub[j] != T[j]);
    }
    ans = min(diff, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    long ans = 0;
    for (long i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            foreach (g; [i, m / i]) {
                if (m >= g * n) { // a_1, a_2, .., a_n の和(約数)が m を超えてはいけない
                    ans = max(ans, g);
                }
            }
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  ll K; cin >> K;
  queue<ll> lunlun;
  
  rep(i, 9) lunlun.push(i+1);
  
  ll temp;
  rep(i, K){
    temp = lunlun.front(); lunlun.pop();
    if(temp%10 != 0) lunlun.push(temp*10 + temp%10 - 1);
    lunlun.push(temp*10 + temp%10);
    if(temp%10 != 9) lunlun.push(temp*10 + temp%10 + 1);
  }
  
  
  cout << temp;
}

Measured memory_bytes: 1792
//0238
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t, n, s[10], f[10];
    while(true){
        cin >> t;
        cin >> n;
        if(t==0)break;
            //cin >> n;
        else{
        int sum=0;
            for(int i=0; i<n; i++){
                cin >>s[i] >>f[i];
                int x=f[i]-s[i];
                sum = sum + x;
            }
                    if(sum>=t)
                        cout << "OK" << endl;
                    else
                        cout << t-sum << endl;
        }
    }
}


Measured memory_bytes: 3092
#include  <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
string S, T;
int count = 0;
int max = 0;
cin >> S;
T = S;
for(int i = 0; i <= S.size(); i++){
 for(int j = 0;i + j <= S.size(); j++){
   if(i != 0){
   for(int x = 0; x < i; x++){S.at(i - x - 1) = 'x';}}
  if(j != 0){
  for(int x = 0; x < j; x++){S.at(S.size() - j + x) = 'x';}}//S完成
   for(int k = 0; k < S.size(); k++){   
if((S.at(k) == 'A' || S.at(k) == 'G' || S.at(k) == 'C' || S.at(k) == 'T')){
  count++;}
if((S.at(k) != 'A' && S.at(k) != 'G' && S.at(k) != 'C' && S.at(k) != 'T' && S.at(k) != 'x')){
  count = 0; break;}}//count完成
   S = T;
   if(count > max){max = count;}
   count = 0;}}
cout << max << endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10000000
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int k=0;
  cin  >> k;
  
  ll seed = 7 % k;
  int i = 1;
  set<int>s;

  while(s.count(seed) == 0){
    if(seed == 0){
      cout << i << endl;
      return 0;
    }
    s.insert(seed);
    seed = (seed * 10  + 7) % k;
    i++;  
  }

  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 50424
from sys import setrecursionlimit
from sys import stdin
input = stdin.readline
setrecursionlimit(10**7)

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

def update(v, p):
    for next in tree[v]:
        if next == p:
            continue
        counter[next] += counter[v]
        update(next, v)

tree = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x
update(0, -1)
print(" ".join(map(str, counter)))


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n), dp(n);
    
    for(int i = 0; i < n; i++)
        cin >> v[i];
    
    if(n == 1){
    	cout << 0;
        return 0;
    }
    
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    
    int ans = INT_MAX;
    for(int i = 2; i < n ; i++){
        dp[i] = min((abs(v[i] - v[i-1]) + dp[i - 1]), (abs(v[i] - v[i-2]) + dp[i - 2]));
    }
    
    // for(auto x : dp)
    //     cout << x << " ";
    
    cout << dp[n-1];
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    
    int ans = 0;
    REP(i,n) {
        int h;
        cin>>h;
        if(h>=k) ans++;
    }

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

Measured memory_bytes: 256