akhauriyash/Code-Regression huggingface dataset:
import sys
def input():
    return sys.stdin.readline()[:-1]

N, M = map(int, input().split())
L = []
for i in range(N):
    l, r = map(int, input().split())
    L.append((r - l + 1, l, r + 1))
L.sort()


class Bit:
    """
    0-indexed
    # 使用例
    bit = Bit(10)  # 要素数
    bit.add(2, 10)
    print(bit.sum(5))  # 10
    """

    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


class BitImos:
    """
    ・範囲すべての要素に加算
    ・ひとつの値を取得
    の2種類のクエリをO(logn)で処理
    """

    def __init__(self, n):
        self.bit = Bit(n + 1)

    def add(self, s, t, x):
        # [s, t)にxを加算
        self.bit.add(s, x)
        self.bit.add(t, -x)

    def get(self, i):
        return self[i]

    def __getitem__(self, key):
        # 位置iの値を取得
        return self.bit.sum(key + 1)


imos = BitImos(M + 1)
il = 0
a = N
for i in range(1, M + 1):
    while il < N:
        ra, l, r = L[il]
        if i < ra:
            break
        il += 1
        a -= 1
        imos.add(l, r, 1)
    ans = 0
    for j in range(i, M + 1, i):
        ans += imos[j]

    print(ans + a)


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

int main()
{
    const int MOD = 1000000007;
    long ans = 1, N;
    cin >> N;
    for (int i = 1; i <= N; i++)
        ans = i * ans % MOD;
    cout << ans << endl;

    return 0;
}


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

ans = 0
S=A+B
Q=int(N/S)
#print(int(N/(A+B)))
#for i in range(1, int(N/(A+B))+1):
#    ans = ans + A
ans = Q*A

r = N-Q*S
#print(r)

if r <= A:
    ans = ans + r
else:
    ans = ans + A

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int ans;
string s;
string lst="?";
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        int j=i;
        string now="";now+=s[i];
        if(i==s.size()-1 && lst==now) break;
        while(now==lst) j++,now+=s[j];
        lst=now;
        ans++;
        i=j;
    }
    int ans1=0;lst="?";
    for(int i=s.size()-1;i>=0;i--){
        int j=i;
        string now="";now+=s[i];
        if(i==0 && lst==now) break;
        while(now==lst) j--,now+=s[j];
        lst=now;
        ans1++;
        i=j;
    }
    cout<<max(ans,ans1)<<endl;
    return 0;
}

Measured memory_bytes: 640
using System;

namespace Sample101
{
    class Program
    {
        static int SumOfDigits(int n)
        {
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
        static void Main(string[] args)
        {
            string result = "No";
            int N = int.Parse(Console.ReadLine());
            // Nはハーシャッド数か
            // 各桁の数字の和
            // Nが和で割り切れるならハーシャッド数
            int sum = SumOfDigits(N);
            if (N % sum == 0)
            {
                result = "Yes";
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
using namespace std;
  
int a[4];
int c[8];
int k;
  
int calc(){
    int op = c[k++];
    int ret = 0;
    if(op >= 0){
        ret = op;
    }
    else if(op >= -3){
        int x = calc();
        int y = calc();
        if(op == -1){
            ret = x + y;
        }
        else if(op == -2){
            ret = x - y;
        }
        else{
            ret = x * y;
        }
    }
    else{
        throw 0;
    }
    return ret;
}
  
void print(){
    int op = c[k++];
    if(op >= 0){
        printf("%d", op);
    }
    else{
        char ch;
        if(op == -1){ ch = '+'; }
        else if(op == -2){ ch = '-'; }
        else{ ch = '*'; }
  
        putchar('(');
        print();
        printf(" %c ", ch);
        print();
        putchar(')');
    }
}
 
const int brnum = 100000;
  
void solve(int i, int S, int oprem, int numrem){
    if(i == 6){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[6] = a[j];
            }
        }
        try{
            k = 0;
            if(calc() == 10 && k == 7){
                k = 0;
                print();
                puts("");
                throw "";
            }
        }catch(int){}
        return;
    }
  
    if(oprem > 0){
        for(int op = -1; op >= -3; --op){
            c[i] = op;
            solve(i + 1, S, oprem - 1, numrem + 1);
        }
    }
  
    if(numrem > 0){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[i] = a[j];
                solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
            }
        }
    }
}
  
int main(){
    while(1){
        for(int i = 0; i < 8; ++i){
            c[i] = -9;
        }
        for(int i = 0; i < 4; ++i){
            scanf("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
        try{
            solve(0, 15, 3, 0);
            puts("0");
        }catch(...){}
    }
}

Measured memory_bytes: 1128
n, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = 0
for i in range(1, len(a)):
	b = a[i - 1] + a[i]
	d = b - x
	if d > 0:
		c += d
		e = min(a[i], d)
		a[i] -= e
		d -= e
		if d > 0:
			a[i - 1] -= d
print(c)


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n;

int count(vector<int>& b, int l, int r) {
  if (b.empty()) return 0;
  auto hi = lower_bound(b.begin(), b.end(), r);
  if (hi == b.begin()) return 0;
  --hi;
  auto lo = lower_bound(b.begin(), b.end(), l);
  return hi - lo + 1;
}

int solve(int i, vector<int> a, vector<int> b) {
  int mod = 1 << (i+1);
  for (int i=0; i<n; i++) {
    a[i] %= mod;
  }
  for (int i=0; i<n; i++) {
    b[i] %= mod;
  }
  int T = 1 << i;
  sort(b.begin(), b.end());
  int res = 0;
  for (int x: a) {
    int cnt = 0;
    cnt += count(b, T-x, 2*T-x);
    cnt += count(b, 3*T-x, 4*T-x);
    res += cnt;
  }
  return res;  
}

vector<int> a, b;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  a.resize(n);
  b.resize(n);
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  for (int i=0; i<n; i++) {
    cin>>b[i];
  }

  int ans = 0;

  for (int j=28; j>=0; j--) {
    int res = solve(j, a, b);
    //cout<<j<<": "<<res<<endl;
    if (res%2) {
      ans = ans | (1 << j);
    }
  }

  cout<<ans<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 3456
#include <stdio.h>
int main(void){
int H,W,j,i;
    while(1){
       
        scanf("%d %d\n",&H,&W);
         if( W == 0 && H == 0 ){
            break;
        }
for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
        printf("#");
    }
    printf("\n");
}
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#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() {
    ll N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];

    ll sum = 0;
    ll mini = A[0];
    for (int i = 1; i < N; i++) {
        if (A[i] < mini) {
            sum += mini - A[i];
        } else {
            mini = A[i];
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
    ll N, W;
    cin >> N >> W;
    ll dp[N+1][100010];
    ll w[N+1], v[N+1];
    REP(i,N){cin >> w[i] >> v[i];}
    REP(i,N+1){REP(j,100010){dp[i][j] = INF;}}
    dp[0][0] = 0;
    REP(i,N){
        REP(j,100001){
            if(j-v[i]>=0){
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    ll ans = 0;
    REP(j,100001){
        if (dp[N][j]<=W) ans = j;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int x,a,b; cin >> x >> a >> b;

	if(abs(a-x) > abs(b-x)) cout << "B" << endl;
	else cout << "A" << endl;

	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 100005;

int N;
LL S[MN], A, B;
int b[MN], f[MN], g[MN];

int main() {
	scanf("%d%lld%lld", &N, &A, &B);
	if (A > B) std::swap(A, B);
	for (int i = 1; i <= N; ++i) scanf("%lld", &S[i]);
	f[1] = g[1] = 1;
	int j = 1;
	for (int i = 2; i <= N; ++i) {
		b[i] = b[i - 1] + (S[i] - S[i - 1] < A);
		if (S[i] - S[i - 1] >= A) f[i] = (f[i - 1] + g[i - 1]) % Mod;
		else if (i == 2 || S[i] - S[i - 2] >= A) f[i] = g[i - 1];
		while (j < i && S[i] - S[j] >= B) ++j;
		if (j == i) g[i] = (f[i - 1] + g[i - 1]) % Mod;
		else if (b[i - 1] - b[j] == 0) g[i] = f[j];
	}
	printf("%d\n", (f[N] + g[N]) % Mod);
	return 0;
}

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

int main() {
  int N,M,sum;
  cin >> N >> M;
  vector<int> vec(N);
    for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
	}
  for (int i = 0; i < N; i++) {
    sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int m=M-1;
  if (4*M*vec.at(m) >= sum){
    cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;
const int ms= 1e5+9;
vector<int> v1,v2,v3;
int n;

main(){
	cin >> n;
	v1.resize(n);
	v2.resize(n);
	for(int i= 0;i<n;i++) cin >> v1[i];
	sort(v1.begin(),v1.end());
	
	int sz = 0;
	for(int i = 2;i<n;i+=2)
		v2[i] = v1[sz++];
	v2[0] = v1[sz++];
	
	sz = n-1;
	for(int i = 1;i<n;i+=2)
		v2[i] = v1[sz--];
		
	int soma = 0;
	for(int i =1;i<n;i++)
		soma += labs(v2[i] - v2[i-1]);
		
	
	sort(v1.begin(),v1.end(),greater<int>());
	
	sz = 0;

	for(int i = 2;i<n;i+=2)
		v2[i] = v1[sz++];
	
	v2[0] = v1[sz++];
	
	sz = n-1;
	
	for(int i = 1;i<n;i+=2)
		v2[i] = v1[sz--];
	
	int soma1 = 0;
	
	for(int i= 1;i<n;i++)
		soma1 += labs(v2[i-1] - v2[i]);
	
	cout<<max(soma,soma1);
		
}

Measured memory_bytes: 1792
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if (a > b)
            {
                int d = 0;
                d = a;
                a = b;
                b = d;

            }
            if (b > c)
            {
                int d = 0;
                d = b;
                b = c;
                c = d;

            }
            if (a > b)
            {
                int d = 0;
                d = a;
                a = b;
                b = d;

            }
            Console.WriteLine(a + " " + b + " " + c);
        }
    }
}

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

int main(){
    long N, M;
    cin >> N >> M;
    vector<pair<long, long>> edge(M);
    for(auto& i : edge)cin >> i.first >> i.second;

    class union_find{
    public:
        vector<long> v;
        union_find(size_t n) : v(n, -1){}
        long root(long i){
            while(v[i] >= 0)i = v[v[i]] >= 0 ? v[i] = v[v[i]] : v[i];
            return i;
        }
        long unite(long a, long b){
            a = root(a);
            b = root(b);
            //pair<long, long> ret(-v[a], -v[b]);
            long ret(v[a] * v[b]);
            if(a == b)return 0;
            if(v[a] > v[b])swap(a, b);
            v[a] += v[b];
            v[b] = a;
            return ret;
        }
    };

    reverse(edge.begin(), edge.end());

    union_find uf(N + 1);

    vector<long> ans;

    ans.push_back(N * (N - 1) / 2);

    for(const auto& i : edge){
        long t = *ans.rbegin();
        ans.push_back(t - uf.unite(i.first, i.second));
    }

    ans.pop_back();

    reverse(ans.begin(), ans.end());

    for(const auto i : ans)cout << i << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const int M = 1e9 + 7;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    s.erase(unique(all(s)), s.end());

    cout << (n == s.size() ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

#define MOD 1000000007

void add(int& a, int b){
	a+=b;
	if(a>=MOD)a-=MOD;
}

int n;
char s[3005];
int f[3005];

int main(){
	scanf("%d%s",&n,s);
	fore(i,0,n)f[i]=1;
	fore(i,0,n-1){
		if(s[i]=='<'){
			fore(j,0,n-i-1)add(f[j+1],f[j]);
		}
		else {
			int a=0;
			for(int j=n-i-1;j;--j){
				int t=f[j-1];
				f[j-1]=f[j];
				add(f[j-1],a);
				a=t;
			}
		}
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n):
    a[i]*=-1

heapq.heapify(a)
for _ in range(m):
    x=heapq.heappop(a)*(-1)
    x=x//2
    heapq.heappush(a,-x)

print(sum(a)*(-1))

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

using namespace std;

#define ll long long

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES";
	else cout << "NO";
	return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
template <class T> inline void read(T &n) {
	n=0;register char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));
}
char a[N];
int b[N],len,l,r,k;
int main() {
    scanf("%s",a); len=strlen(a);
    while(1) {
    	while(a[r]!='L')++r;
    	//printf("from %d to %d is R\n",l,r);
    	for(int i=l;i<r;++i)if(r-i&1)++b[r-1];else ++b[r];
    	k=l=r;
		while(a[r]!='R'&&r!=len)++r;
		//printf("from %d to %d is L\n",l,r);
    	for(int i=l;i<r;++i)if(i-k&1)++b[k-1];else ++b[k];
    	l=r;
		if(r==len)break;
    }
    for(int i=0;i<len;++i)printf("%d ",b[i]);
    return 0;
}



Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N;
ll A=1, B=1;

int main() {
	cin >> N;
	cin >> A >> B;
	FOR(i, 0, N-1) {
		ll a, b;
		cin >> a >> b;
		ll Aa = 0, Bb = 0;
		if (A%a != 0)Aa++;
		if (B%b != 0)Bb++;
		Aa += A / a;
		Bb += B / b;
		A = max(Aa, Bb)*a;
		B = max(Aa, Bb)*b;


	}
	ct(A + B);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAXN = 3001, MOD = 998244353;
int N, S;
ll A[MAXN];
ll f[MAXN][MAXN], g[MAXN][MAXN];
ll inv2 = 499122177;

int main() {
    cin >> N >> S;
    for (int i = 1; i <= N; i++)
        cin >> A[i];
    
    ll pown = 1;
    for (int i = 1; i <= N; i++) {
        pown = pown * 2 % MOD;
    }

    // init
    for (int i = 0; i <= N; i++) {
        f[i][0] = pown;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= S; j++) {
            f[i][j] = f[i - 1][j] % MOD;
            if (A[i] <= j)
                f[i][j] = (f[i][j] + f[i - 1][j - A[i]] * inv2) % MOD;
        }
    }
    cout << f[N][S] << endl;
}


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

using namespace std;
typedef long long ll;

int main(void) {
	int Anum, Bnum, Cnum, i, j, k;
	cin >> Anum >> Bnum >> Cnum >> k;
	vector<ll> a(Anum), b(Bnum), c(Cnum), ab(Anum * Bnum), abc(min(k, Anum * Bnum) * Cnum);
	for (i = 0; i < Anum; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < Bnum; i++)
		scanf("%lld", &b[i]);
	for (i = 0; i < Cnum; i++)
		scanf("%lld", &c[i]);
	for (i = 0; i < Anum; i++) {
		for (j = 0; j < Bnum; j++) {
			ab[i * Bnum + j] = a[i] + b[j];
		}
	}
	sort(ab.begin(), ab.end(), greater<ll>());
	for (i = 0; i < Cnum; i++) {
		for (j = 0; j < min(k, Anum * Bnum); j++) {
			abc[i + j * Cnum] = c[i] + ab[j];
		}
	}
	sort(abc.begin(), abc.end(), greater<ll>());
	for (i = 0; i < k; i++)
		printf("%lld\n", abc[i]);
	return 0;
}

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

int main() {
	scanf("%d",&n);
	int res=0;
	int t=n;
	while(t){
		res++;
		t/=10;
	}
	int num=pow(10,res-1);
	num=n-num;
	n-=num;
	num++;
//	printf("%d\n",num);
	int pos=0;
	for(int i=1;i<=res-1;i+=2){
		pos+=9*pow(10,i-1);
	}
	if(res%2==1)pos+=num;
	printf("%d\n",pos);
	return 0;
}

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

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

	for (int i = 0; i < n - k; i++)
	{
		if (a[i] < a[i + k]) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4028
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

def judge():
    for i in range(H):
        for j in range(W):
            if s[i][j] == '.':
                continue
            periphery = []
            if i != 0:
                periphery.append(s[i - 1][j])
            if i != H - 1:
                periphery.append(s[i + 1][j])
            if j != 0:
                periphery.append(s[i][j - 1])
            if j != W - 1:
                periphery.append(s[i][j + 1])
            if '#' not in periphery:
                return False
    return True

print('Yes' if judge() else 'No')


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

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

    map<ll, ll> mod_list;

    ll f = n / k;
    ll a = ((n % k) >= (k / 2)) ? 1 : 0;
    ll j = f + a;

    if (k % 2 == 0) {


        cout << f * f * f + j * j * j << endl;

    } else {
        cout << f * f * f << endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    cout << 180*(n-2) << endl; 

    return 0; 
}


Measured memory_bytes: 3652
package main

import (
	"strconv"
	"fmt"
	"strings"
)


func main() {
	var out int

	var S string
	fmt.Scan(&S)

	n := len(S)
	for bits := 0; bits < (1 << uint(n-1)); bits++ {
		slice := S
		for i := 0; i < n; i++ {
			if (bits >> uint(i))&1 == 1 {
				slice = string(slice[:n-i-1]) + " " + string(slice[n-i-1:])
			}
		}

		nums := strings.Split(slice, " ")

		sum := 0
		for _, a := range nums {
			val, _ := strconv.Atoi(a)
			sum += val
		}
		out += sum
	}
	fmt.Println(out)
}

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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define sz(x)          (int)x.size()
#define TN             typename
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof(a))
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

template <TN T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}

#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
	vector <string> v;
	stringstream ss(s); string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
	cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
	err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod;}

const int N          = 2e5 + 5;
const ll  Mod        = (ll)1e9 + 7;
const int inf        = (int)2e9;
const ll  Inf        = (ll)1e18;
const int mod        = (int)1e9 + 7;

ll dp[405][405];

int solve() {
	int n = in();
	vi a(n + 1);
	for (int i = 1; i <= n; i++) {
		a[i] = in();
	}
	for (int l = n; l >= 1; l--) {
		for (int r = l; r <= n; r++) {
			if (l == r) continue;
			dp[l][r] = Inf;
			ll sum = 0;
			for (int i = l; i <= r; i++) {
				sum += a[i];
			}
			for (int i = l; i < r; i++) {
				smin(dp[l][r], dp[l][i] + dp[i + 1][r] + sum);
			}
		}
	}
	printf("%lld\n", dp[1][n]);
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}





Measured memory_bytes: 1536
N,K = map(int,input().split())

a = [list(map(int, input().split())) for i in range(N)]
a.sort(key=lambda x: x[0])

sum=0
ans=0
for i in a:
    if sum <K:
        ans = i[0]
        sum+=i[1]
    else:
        break
print(ans)

Measured memory_bytes: 29144
from itertools import accumulate


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


def LCM(a, b):
    return a // GCD(a, b) * b


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    lcm = 1
    ans = list(accumulate(A, func=LCM))[-1]
    print(ans)


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

int main(){
  string s;
  cin>>s;
  bool at=true;
  if(s.size()%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<s.size()-1;i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
      at=false;
      break;
    }
  }
  if(at==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

int main()
{
    char a[11],b[11],c[11];


    scanf("%s",a);
    getchar();
    scanf("%s",b);
    getchar();
    scanf("%s",c);
    getchar();

    if((a[strlen(a)-1]==b[0])&&(b[strlen(b)-1]==c[0]))
    {
        printf("YES\n");
        return 0;
    }
    else
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

i64 h, w, dist[401][401];
vector<string> s;

int idx(int i, int j) {
    return w * i + j;
}

int main() {
    cin >> h >> w;
    read_n(s, h);
    for (int i = 0; i <= h * w; ++i) {
        for (int j = 0; j <= h * w; ++j) {
            if (i != j) dist[i][j] = 1e9;
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                if (i < h - 1 && s[i + 1][j] == '.') {
                    dist[idx(i, j)][idx(i + 1, j)] = dist[idx(i + 1, j)][idx(i, j)] = 1;
                }
                if (j < w - 1 && s[i][j + 1] == '.') {
                    dist[idx(i, j)][idx(i, j + 1)] = dist[idx(i, j + 1)][idx(i, j)] = 1;
                }
            }
        }
    }

    for (int k = 0; k < h * w; ++k) {
        for (int i = 0; i < h * w; ++i) {
            for (int j = 0; j < h * w; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    i64 ans = 0;
    for (int i = 0; i < h * w; ++i) {
        for (int j = 0; j < h * w; ++j) {
            if (dist[i][j] < 1e9) {
                ans = max(ans, dist[i][j]);
            }
        }
    }

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

Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s << endl;
    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.rbegin(), v.rend());
  int res=0;
  for(int i=0;i<k;i++){
    res += v[i];
  }
  cout<<res<<endl;

  return 0;
}


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

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};


int main() {

    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    rep(i, h){
        cin >> s[i];
    }

    int ans = 0;
    rep(si, h){
        rep(sj, w){
            if(s[si][sj] == '#'){
                continue;
            }
            vector<vector<int>> dist(h, vector<int>(w, INF));
            queue<pair<int, int>> q;
            auto update = [&](int i, int j, int x){
                if(dist[i][j] != INF){
                    return;
                }
                dist[i][j] = x;
                q.emplace(i, j);
            };
            update(si, sj, 0);

            while(!q.empty()){
                int i = q.front().first;
                int j = q.front().second;
                q.pop();
                rep(dir, 4){
                    int ni = i + di[dir];
                    int nj = j + dj[dir];
                    if(ni < 0 || ni >= h || nj < 0 || nj >= w){
                        continue;
                    }
                    if(s[ni][nj] == '#'){
                        continue;
                    }

                    update(ni, nj, dist[i][j]+1);

                    ans = max(ans, dist[ni][nj]);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int n;
char s1,s2;
int main(void){
    string a;
    cin>>n>>a;
    s1=a[a.size()-1];
    mp[a]++;
    for(int i=0;i<n-1;i++){
        cin>>a;
        //cout<<a<<endl;
        mp[a]=1;
        s2=a[0];
        //cout<<s1<<" "<<s2<<endl;
        if(s1!=s2){
            cout<<"No"<<endl;
            return 0;
        }
        s1=a[a.size()-1];
    }
    if(mp.size()==n){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int h, a[500000];

void maxheap(int i)
{
  int l, r, largest, x;

  l = 2*i;
  r = 2*i+1;
  if (l <= h && a[l] > a[i])
    largest = l;
  else
    largest = i;
  if (r <= h && a[r] > a[largest])
    largest = r;
  if (largest != i){
    x = a[i];
    a[i] = a[largest];
    a[largest] = x;
    maxheap(largest);
  }
}

int main()
{
  int i;

  scanf("%d",&h);
  for (i = 1; i <= h; i++)
    scanf("%d",&a[i]);
  for (i = h/2; i > 0; i--)
    maxheap(i);
  for (i = 1; i <= h; i++)
    printf(" %d",a[i]);
  printf("\n");
  
    return 0;
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

ll dp[102][102][302];

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N, W;
    cin >> N >> W;
    vector<Pll> items(N);
    for (int i = 0; i < N; i++) {
        cin >> items[i].first >> items[i].second;
    }

    ll w0 = items[0].first;
    fill_n(&dp[0][0][0], sizeof(dp) / sizeof(dp[0][0][0]), -L_INF);
    for (int w = 0; w <= 300; w++) {
        dp[0][0][w] = 0;
    }


    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int w = 0; w <= 300; w++) {
                ll wi, vi;
                tie(wi, vi) = items[i];
                wi -= w0;
                if (w - wi >= 0 && j - 1 >= 0) {
                    dp[i + 1][j][w] = max(dp[i][j][w], dp[i][j - 1][w - wi] + vi);
                }
                else {
                    dp[i + 1][j][w] = dp[i][j][w];
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        ll r = min(W - w0 * i, 300LL);
        if (r >= 0)
            ans = max(ans, dp[N][i][r]);
    }

    cout << ans << endl;


    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int x = a, y = b;
  for (int i = 1; i < b; i++) {

    x += a * pow(10,i);
  }
  for (int i = 1; i < a; i++) {
    y += b * pow(10,i);
  }

  if (to_string(x) < to_string(y)) cout << x << endl;
  else cout << y << endl;
}


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

flag = [0 for _ in range(N)]

tmp = 1
i = 1
flag[0] = 1
while(True):
    tmp = A[tmp-1]
    i += 1
    if (flag[tmp-1] != 0):
        break
    flag[tmp-1] = i

pre = flag[tmp-1] - 1
cyc = i - flag[tmp-1]
if (K >= pre):
    index = (K - pre) % cyc
    if (index == 0):
        print(A[flag.index(pre + cyc)])
    else:
        print(A[flag.index(pre+index)])
else:
    print(A[flag.index(K)])

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int x = 0, x_max = 0;
	for (int i = 0; i < N; i++) {
		if (S.at(i) == 'I') {
			x++;
		} else {
			x--;
		}

		if (x_max < x) {
			x_max = x;
		}
	}

	cout << x_max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (abs(a-c) <= d ? "Yes" : (abs(a-b) <= d)&&(abs(b-c) <= d) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

#define N 100000

int A[N];
int n,k;

int K_search(int P){
    int TR[N]={0};
    int tr = 0;
    int count = 0;
    
    for (int i = 0; i < n; i++) {
        if (TR[tr]+A[i]<=P) {
            TR[tr] += A[i];
            count++;
        }else if(tr+1<k && A[i]<=P){
            tr++;
            TR[tr] += A[i];
            count++;
        }else{
            break;
        }
    }
    return count;
}

int solve(){
    int Right=0,Left=0;
    for (int i = 0; i < n; i++) {
        Right += A[i];
    }
    int mid;
    
    
    while ( Right-Left > 1 ) {
        mid = (Right+Left)/2;
        
        int v = K_search(mid);
        if (v >= n) {
            Right = mid;
        }else{
            Left = mid;
        }
    }
    return Right;
}


int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    cout << solve() << endl;
    
    return 0;
}

Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; int aux;
	cin >> n;
	vector<int>nums;
	int suma1 = 0;
	int suma2 = 0;
	while(n--){
		cin >> aux;
		nums.push_back(aux);
		suma1 += aux;
	}
	sort(nums.begin(), nums.end());
	for(int i = 0; i < nums.size(); i++){
		if(suma1 % 10 != 0) {cout << suma1; return 0;} else if(nums[i] % 10 != 0) suma1 -= nums[i];  
	}
	cout << "0";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = mod;
  rep(i, n+1-k) {
    int cans = h[k-1+i] - h[i];
    ans = min(ans, cans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
a, b, k = map(int, input().split())
maxint = max(a, b)
divisor = []
for i in range(1, maxint + 1):
  if ((a % i) == 0) and ((b % i) == 0):
    divisor.append(i)
reverselist = sorted(divisor, reverse=True)
print(reverselist[k - 1])

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

int main()
{
       char s1[10002];
       int len,j,pos;
       scanf("%d",&pos);
       getchar();
       gets(s1);
       len=strlen(s1);
       for(j=0;j<len;j++)
       {
           s1[j]=s1[j]+pos;
           if(s1[j]>'Z')
            s1[j]=s1[j]-26;
       }
       puts(s1);
       printf("\n");




    return 0;
}


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

int N;
int a[300005];
long long sum=0;

bool descending (int a, int b)
{
    if (a>b)
    {
        return true;
    }

    return false;
}

int main()
{
    cin>>N;

    for (int i=1; i<=3*N; i++)
    {
        cin>>a[i];
    }

    sort(a+1, a+3*N+1, descending);

    for (int i=2; i<=2*N; i+=2)
    {
        sum=sum+a[i];
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 1408
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = LIST()
S = input()

# stand = []
# reverse = []
# state = None
# count = 0
# tmp = None
# for i in S:
# 	if i == "0":
# 		state = "stand"
# 	else:
# 		state = "reverse"
# 	if tmp == "stand" and state == "reverse":
# 		stand.append(count)
# 		count = 1
# 	elif tmp == "reverse" and state == "stand":
# 		reverse.append(count)
# 		count = 1
# 	else: # 状態が前と同じ
# 		count += 1
# 	tmp = state
# if state == "stand":
# 	stand.append(count)
# else:
# 	reverse.append(count)

# if "0" not in S:
# 	print(len(S))
# else:
# 	if K >= len(stand): # 全員逆立ちにできる
# 		print(len(S))
# 	else:
# 		if len(stand) > len(reverse):
# 			reverse.append(0)
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "0":
# 			reverse.insert(0, 0)
# 		if len(stand) == len(reverse) and S[0] == "1":
# 			reverse.append(0)
# 		# print(stand)
# 		# print(reverse)
# 		max_ = 0
# 		for i in range(max(1, 1+len(reverse)-(K+1))):
# 			# print(reverse[i:i+K+1],stand[i:i+K])
# 			tmp = sum(reverse[i:i+K+1]+stand[i:i+K])
# 			if tmp > max_:
# 				max_ = tmp
# 		print(max_)
indexes = [0]
if S[0] == "0":
    indexes.append(0)
for i in range(N-1):
	if S[i] != S[i+1]:
		indexes.append(i+1)
indexes.append(N)
if S[N-1] == "0":
    indexes.append(N)
ans = []
# print(indexes)
r = len(indexes)//2 -1
if K >= r:
	print(N)
else:
	print(max(indexes[2*(i+K)+1]-indexes[2*i] for i in range(r-K+1)))
	# for i in range(len(indexes)):
	# 	# print(i)
	# 	if i == len(indexes)-1:
	# 		break
	# 	if S[indexes[i]] == "0":
	# 		if i+2*K >= len(indexes):
	# 			continue
	# 		ans.append(indexes[i+2*K]-indexes[i])
	# 	else:
	# 		if i+2*K+1 >= len(indexes):
	# 			continue
	# 		ans.append(indexes[i+2*K+1]-indexes[i])
	# if ans == []:
	# 	print(len(S))
	# else:
	# 	print(max(ans))

Measured memory_bytes: 7160
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  else return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

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

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

int main() {
    int m,d;
    cin >> m >> d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int id=1;id<=d;id++){
            int d1 = id%10;
            int d10 = id/10;
            if( (d1 >= 2 && d10 >= 2) && (i == d1*d10))ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, m;
vector<int> edge[100010];
int grp[100010];
int R(int x){return (x==grp[x])?x:(grp[x]=R(grp[x])); }

void in(){
    read(n, m);
    for(int i=1; i<=m; ++i){
        int x, y; read(x, y);
        edge[x].pb(y);
        edge[y].pb(x);
    }
}

void Join(){
    for(int i=1; i<=n; ++i) grp[i]=i;
    for(int i=1; i<=n; ++i) for(int j:edge[i]){
        grp[R(i)]=R(j);
    }
}

bool vis[100010];
int color[100010];
bool odd[100010];
int gsz[100010];
int cs[100010][2];
void DFS(int x, int gi){
    vis[x]=1;
    ++cs[gi][color[x]];
    ++gsz[gi];
    for(int y:edge[x]){
        if(vis[y]){
            if(color[x] == color[y]){
                odd[gi]=1;
            }
            continue;
        }
        color[y]=1-color[x];
        DFS(y, gi);
    }
}

int main()
{
	in(); Join();
	int odds=0, bi=0;
	int single=0;
	for(int i=1; i<=n; ++i) if(grp[i]==i){
        DFS(i, i);
        if(gsz[i] == 1){
            ++single;
            continue;
        }
        if(odd[i]) ++odds;
        else ++bi;
	}
	ll ans = single*2LL*(n-single) + single*1LL*single;
	
	ans += odds * 1LL * odds; // odds x odds
	// odds x bi : left is 1, right is 1
	// left, right -> x2
	ans += odds * 2LL * bi;
	// bi x bi : 4 for each
	ans += bi * 2LL * (bi-1);
	// bi self
	ans += bi * 2LL;
	printf("%lld\n", ans);
    return 0;
}


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

int main() {
    int L;
    cin >> L;
    
    long double V;
    //long double a = L/3;
    //V = pow(a,3);
    
    V = pow(L,3)/27;

    cout << fixed << setprecision(10) << V << endl;
    return 0;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(min(50, k)):
    l = [0]*(n+1)
    for i in range(n):
        l[max(i-a[i], 0)] += 1 #光の届く距離（後ろ）
        l[min(i+a[i]+1, n)] -= 1 #光が届かなくなる距離(前)
    add = 0
    for i in range(n):
        add += l[i] #光の届いている電球の数を累積
        a[i] = add
print(*a)


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

int main() {
	string n;
	cin >> n;
	string ans;
	if (n[0] == '9' || n[1] == '9') {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int N, K;
	int a[112345];
	
	cin >> N >> K;
	REP(i, N) scanf("%d", a + i);
	
	int g = a[0];
	REP(i, N) g = gcd(g, a[i]);
	
	int ma = *max_element(a, a + N);
	
	if (ma < K || K % g != 0) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,i,j,k,cnt,a,b,c,d;
    string ch,ct;
    cin>>ch;
    a=ch.size();
    for(i=0;i<=2;i++)
    {
        cout<<ch[i];
    }
}



Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC147.Myself;

namespace ABC147
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = NextInt();
            var a1 = a[0];
            var a2 = a[1];
            var a3 = a[2];

            Print(a1 + a2 + a3 > 21 ? "bust" : "win");
        }
    }

    public class Myself
    {
        public static List<int> NextInt()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

        public static List<long> NextLong()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        public static List<double> NextDouble()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
        }

        public static List<string> NextString()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        public static void Swap<T>(ref T a, ref T b)
        {
            T temp = a;
            a = b;
            b = temp;
        }

        /// <summary>
        /// コンソール出力関数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        public static void Print<T>(T a)
        {
            Console.WriteLine(a);
        }
    }

    public struct Point
    {
        public double X
        {
            get;
            set;
        }
        public double Y
        {
            get;
            set;
        }

        public Point(double x, double y)
        {
            X = x;
            Y = y;
        }

        public static Point CalcOffsetPoint(Point a, Point b)
        {
            b.X -= a.X;
            b.Y -= a.Y;

            return new Point(b.X, b.Y);
        }

        public static double CalcArea(Point a, Point b)
        {
            return Math.Abs((a.X * b.Y) - (a.Y * b.X)) / 2;
        }
    }

    class Utility
    {
        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 最大公約数
        private static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            long d = 0;
            do
            {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const int Maxn=1e5;
const ll Mod=1000000007;

int N,K;
vector<int> G[Maxn+5];
void addedge(int u,int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

long long ans;

long long DFS(int u,int fa,int dep) {
	int tmp=K-min(dep,2);
	for(int i=0;i<(int)G[u].size();i++) {
		int v=G[u][i];
		if(v==fa)continue;
		if(DFS(v,u,dep+1)==0)
			return 0;
		ans=ans*tmp%Mod;
		tmp--;
	}
	return ans;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&K);
	for(int i=1;i<N;i++) {
		int u,v;
		scanf("%d %d",&u,&v);
		addedge(u,v);
	}
	ans=K;
	printf("%lld\n",DFS(1,-1,1));
	return 0;
}

Measured memory_bytes: 11520
fn main() {
    let s: String = read_line();
    let k = read_line::<u64>() - 1;

    for (i, c) in s.chars().enumerate() {
        if c != '1' || i as u64 >= k {
            println!("{}", c);
            return;
        }
    }
}

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


Measured memory_bytes: 4352
S =  int(input())
 
hh = 0
mm = 0
ss = 0
 
while S >= 3600:
     S -= 3600
     hh += 1
     
while S >= 60:
     S -= 60
     mm += 1
      
     
ss = S
print(hh,mm,ss, sep=':') 


Measured memory_bytes: 5592