akhauriyash/Code-Regression huggingface dataset:
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N=1e6;


int main(){
	fastio;
	ll n; cin>>n;
	ll ans = 1e18;
	for(ll i=1; i*i<=n; i++){
		if(n%i==0){
			ans = min(ans, i+n/i-2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        double n;
        cin >> n;

        n /= 3;
        n = n * n * n;
        cout << fixed << setprecision(7) << n << '\n'; 

    }
    
    return 0;
}



Measured memory_bytes: 3800
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, Z, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
    ans = [0] * K
    seen = {(0, 0, 0)}

    for idx in range(K):
        s, i, j, k = heappop(hq)
        ans[idx] = -s

        if i < X - 1 and (i + 1, j, k) not in seen:
            heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
            seen.add((i + 1, j, k))
        if j < Y - 1 and (i, j + 1, k) not in seen:
            heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
            seen.add((i, j + 1, k))
        if k < Z - 1 and (i, j, k + 1) not in seen:
            heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
            seen.add((i, j, k + 1))

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		if(n.contains("9")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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

int main(){
    string s;
    int cnt;
    cin >> s;
    if(s[0] == '1') cnt++;
    if(s[1] == '1') cnt++;
    if(s[2] == '1') cnt++;
    cout << cnt << endl;
    return 0;
}

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

int p[100];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&p[i]);
	sort(p,p+n,greater<int>());
	int Max=0;
	rep(i,n)Max=max(Max,min(i+1,p[i]));
	cout<<Max<<endl;
}

Measured memory_bytes: 3228
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
        char s = S.charAt(K-1);
        String sn = String.valueOf(s);
        if(sn.equals("A")){
            sn = "a";
        }
        else if(sn.equals("B")){
            sn = "b";
        }
        else if(sn.equals("C")){
            sn = "c";
        }

        if(K==1){
            System.out.println(sn + S.substring(1));
        }
        else if(K==2){
            System.out.println(S.charAt(0) + sn + S.substring(2));
        }
        else if(K>=3){
            System.out.println(S.substring(0, K-1) + sn + S.substring(K));
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#define mod 1000000007
using namespace std;
typedef long long ll;
bool chmax(ll &a,ll b){
    if(a>b)return 0;
    a=b; return 1;
}
bool chmin(ll &a,ll b){
    if(a<b)return 0;
    a=b; return 1;
}

#define N 100010
vector<ll> g[N];
ll n,m,p[N];
bool vis[N];
set<ll> s,t;
void dfs(ll x){
    if(vis[x])return;
    vis[x]=1;
    s.insert(x);
    t.insert(p[x]);
    for(auto y:g[x]){
	dfs(y);
    }
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
	cin>>p[i];
	vis[i]=0;
    }
    for(int i=0;i<m;i++){
	ll a,b; cin>>a>>b;
	g[a].push_back(b);
	g[b].push_back(a);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
	if(vis[i]==1)continue;
	s.clear();
	t.clear();
	dfs(i);
	for(auto a:s){
	 if(t.find(a)!=t.end())ans++;   
	}
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 18944
from fractions import Fraction
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

ZERO = Fraction(0, 1)
Z = 1000000007

class Pow:
    def __init__(self, n):
        self.N = n
        self.e = [1] * (n + 1)
        for i in range(n):
            self.e[i + 1] = (self.e[i] * 2) % Z
    def get(self, n):
        if self.N >= n:
            return self.e[n]
        else:
            for i in range(self.N + 1, n + 1):
                self.e += [(self.e[i] * 2) % Z]
            return self.e[n]


def calc(N, G):
    zz = 0
    r = {}
    r_max = 0
    for a, b in G:
        if b == 0:
            if a == 0:
                zz += 1
            else:
                if 0 in r:
                    r[0][1][1] += 1
                else:
                    r[0] = {1: [0, 1]}
                r_max = max(r_max, r[0][1][1])
        else:
            if a == 0:
                if 0 in r:
                    r[0][1][0] += 1
                else:
                    r[0] = {1: [1, 0]}
                r_max = max(r_max, r[0][1][0])
            else:
                f = Fraction(a, b)
                if f > 0:
                    i = f.numerator
                    j = f.denominator
                    if i in r:
                        if j in r[i]:
                            r[i][j][0] += 1
                        else:
                            r[i][j] = [1, 0]
                    else:
                        r[i] = {j: [1, 0]}
                    r_max = max(r_max, r[i][j][0])
                else:
                    i = f.denominator
                    j = -f.numerator
                    if i in r:
                        if j in r[i]:
                            r[i][j][1] += 1
                        else:
                            r[i][j] = [0, 1]
                    else:
                        r[i] = {j: [0, 1]}
                    r_max = max(r_max, r[i][j][1])
    ans = 1
    pow = Pow(r_max)
    for i in r:
        for j in r[i]:
            ans = (ans * (pow.get(r[i][j][0]) + pow.get(r[i][j][1]) - 1)) % Z
    return (ans + zz - 1) % Z

    

N = int(input())
G = [tuple([int(s) for s in input().split()]) for _ in range(N)]
print(calc(N, G))

Measured memory_bytes: 190804
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int main() {

	int n, m, a;
	while (cin >> n >> m >> a) {
		if (n == 0 & m == 0 && a == 0) {
			break;
		}
		vector<int> amid(n);
		for (int i = 0; i < n; i++) {
			amid[i] = i + 1;
		}
		int h, p, q;
		vector<Q> sen(m);
		for (int i = 0; i < m; i++) {
			cin >> h >> p >> q;
			sen[i] = Q(h, P(p, q));
		}
		sort(sen.begin(), sen.end());
		for (int i = 0; i < m; i++) {
			P pp = sen[i].second;
			swap(amid[pp.first - 1], amid[pp.second - 1]);
		}
		cout << amid[a - 1] << endl;
	}

	return 0;
}


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

void trace(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (0 < i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main() {
    int N;
    cin >> N;
    
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int num = 0;
    int i = 0;
    while (i < N) {
        for (int j = N - 1; j > i; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j],A[j - 1]);
                num++;
            }
        }
        i++;
    }
    trace(A,N);
    cout << num << endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

long long lcm(long long N, long long M){
    return N*M/gcd(N,M);
}

int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> A(N,0);
    cin >> A[0];
    long long tmp=A[0];
    long long fact=1;
    while(tmp%2==0 && tmp>0){
        tmp/=2;
        fact*=2;
    }
    if(fact==1){
        cout << 0 << endl;
        return 0;
    }

    long long lcm_=A[0];
    for(int i=1; i<N; i++){
        cin >> A[i];
        if(A[i]%fact!=0 || (A[i]/fact)%2==0){
            cout << 0 << endl;
            return 0;
        }
        lcm_=lcm(lcm_, A[i]);
        if(lcm_>MOD){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << 2*M/lcm_-M/lcm_ << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    string s; cin>>s;
    ll sum=0;
    rep(bit,0,1<<s.size()){
        ll suc=1;
        sum+=s[s.size()-1]-'0';
        for(ll i=s.size()-2; i>=0; i--){
            if(bit & (1<<i)){
                suc*=10;
                sum+=(s[i]-'0')*suc;
            }else{
                suc=1;
                sum+=(s[i]-'0');
            }
        }
    }
    cout<<sum/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	vector<char> v;
	v.resize(s.length());
	int j=0;
	for( int i=0;s[i];i++)
	{
		if(s[i]=='0')
			v[j++]=s[i];
		else if(s[i]=='1')
			v[j++]=s[i];
		else 
		{
			if(j!=0)
				j--;
		}
	}
	for( int i=0;i<j;i++)
		cout<<v[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
  long long n,k;
  cin>>n>>k;
  long long A[n];
  for(int i=0;i<n;i++)
  cin>>A[i];
  //cout<<n;
  sort(A,A+n);
  long sum=0;
  for(int i=0;i<n-k;i++){
  sum+=A[i];
  	//cout<<sum;
  }
  cout<<sum;
  //cout<<n;
}

Measured memory_bytes: 1792
import sys

N_MAX = 200000 + 5
INF = 10**9
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]

z = 0
c = 0

def merge(A, left, right):

    global c, z

    n1 = (right - left) // 2 + left  # L側の個数

    L = A[left:n1]
    R = A[n1:right]

    L.append(INF)
    R.append(INF)

    # print(L, R)

    i = 0
    j = 0
    l = len(L)
    for k in range(left, right):
        z += 1

        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            # print(l-i-1)
            c += l-i-1


def mergesort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, right)


mergesort(A, 0, N)

# print(" ".join([str(x) for x in A]))
# print(z)
print(c)



Measured memory_bytes: 27604
#include<iostream>

using namespace std;

int main(){
  int r,c;
  int a[150][150];
  int r_sum[150]={0};
  int c_sum[150]={0};
  int t_sum=0;

  cin >> r >> c;

  int i,j;
  for(i=0;i<r;i++)
    for(j=0;j<c;j++)
      cin >> a[i][j];

  for(i=0;i<r;i++)
    for(j=0;j<c;j++)
      r_sum[i]+=a[i][j];

  for(i=0;i<c;i++)
    for(j=0;j<r;j++)
      c_sum[i]+=a[j][i];

  for(i=0;i<r;i++)
    t_sum+=r_sum[i];

  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      cout << a[i][j] << " ";
    }
    cout << r_sum[i] << endl;
  }

  for(i=0;i<c;i++)
    cout << c_sum[i] << " ";
  cout << t_sum << endl;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=1000000000000000001;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll l[n]={0};
    ll r[n]={0};
    for(ll i=0;i<n;i++){
        l[0]=a[0];
        l[i+1]=gcd(l[i],a[i+1]);
    }
    for(ll i=n-1;i>=0;i--){
        r[n-1]=a[n-1];
        r[i-1]=gcd(a[i-1],r[i]);
    }
    ll ans=max(r[1],l[n-2]);
    for(ll i=1;i<n;i++){
        ll tmp=0;
        tmp=gcd(l[i-1],r[i+1]);
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;




int main()
{
	int n;

	while(cin >> n  &&  n )
	{
		int cell[500][500];

		int x[300];
		int y[300];

		memset(cell,-1,sizeof(int)*500*500);
		memset(x,-1,sizeof(int)*300);
		memset(y,-1,sizeof(int)*300);

		cell[250][250] = 0;
		
		x[0] = 250;
		y[0] = 250;

		for(int i = 1;i < n;i++)
		{
			int tmp0,tmp1;

			cin >> tmp0 >> tmp1;

			int tx,ty;

			if(tmp1 == 0)
			{
				tx = -1;
				ty =  0;
			}else
			if(tmp1 == 1)
			{
				tx =  0;
				ty =  1;
			}else
			if(tmp1 == 2)
			{
				tx =  1;
				ty =  0;
			}else
			if(tmp1 == 3)
			{
				tx =  0;
				ty = -1;
			}

			cell[x[tmp0] + tx][y[tmp0] + ty] = i;
			x[i] = x[tmp0] + tx;
			y[i] = y[tmp0] + ty;
		}
		
		int h,w;

		int start = 500;
		int end = 0;
		for(int i = 0;i < 500;i++)
		{
			for(int j = 0;j < 500;j++)
			{
				if(cell[i][j] != -1){start = min(start,j);break;}
			}
			for(int j = 499;j >= 0;j--)
			{
				if(cell[i][j] != -1){end   = max(end,j);break;}
			}
		}

		h = end - start + 1;
		
		start = 500;
		end = 0;

		for(int i = 0;i < 500;i++)
		{
			for(int j = 0;j < 500;j++)
			{
				if(cell[j][i] != -1){start = min(start,j);break;}
			}
			for(int j = 499;j >= 0;j--)
			{
				if(cell[j][i] != -1){end   = max(end,j);break;}
			}
		}

		w = end - start + 1;

		cout << w << " " << h << endl;
		
	}

  return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define tezz std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

signed main() {
    int a,b;
    cin>>a>>b;
    int c=0;
    vector<int> aa(a);
    for(int i=1;i<=a;i++) cin>>aa[i];
    for(int i=1;i<=a;i++){
        if(aa[i]>=b) c++;
    }
    cout<<c<<endl;
    

}

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

int main() {
  
  string a, b;
  cin >> a >> b;
  
  int n = stoi(a + b);  
  
  bool ans = false;
  REP(i,1000) {
    if (i * i == n ) ans = true;
  }
  
  cout << (ans ? "Yes" : "No") << endl;
  
}

Measured memory_bytes: 3584
s = input()
n = len(s)
op = n - 1
ans = 0
for i in range(2**op):
  opm = [''] * op
  for j in range(op):
    if ((i >> j) & 1):
      opm[op - 1 - j] = '+'

  formula = ''
  for j in range(op):
    formula += s[j] + opm[j]
  formula += s[-1]
  ans += eval(formula)

print(ans)

Measured memory_bytes: 3188
/*input
3 4
2 2 4
*/
#include <bits/stdc++.h>
using namespace std;
 

#define int 				long long int
#define all(c)				c.begin(), c.end()
#define init(arr, num)		memset(arr, num, sizeof(arr))
#define fast				ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inputFile			freopen("input.txt", "r", stdin); 
#define outputFile			freopen("output.txt", "w", stdout);
#define modM 				998244353


#ifdef Voneone
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>  void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args> 
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; 
		__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
int modpower(int x, unsigned int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
}

int inline inverse(int x){
	return modpower(x, modM - 2, modM);
}

int inline add(int a, int b){
	return ((a%modM )+ (b%modM))%modM;
}

int inline mul(int a, int b){
	return ((a%modM) *(b%modM))%modM;
}

void solve() 
{ 


	int n, s;
	cin >> n >> s;
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];

	int dp[n+1][s+1];
	init(dp, 0);
	dp[0][0] = modpower(2, n, modM);
	trace(dp[0][0]);
	int inv2 = inverse(2);
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= s; j++){
			dp[i+1][j] = add(dp[i+1][j], dp[i][j]);
			if(j + arr[i] <= s){
				dp[i+1][j + arr[i]] = 
					add(dp[i+1][j + arr[i]], mul(dp[i][j], inv2));
			}
		}
	}

	cout << dp[n][s];


	

} 
 
 
signed main()
{
 
	
	#ifdef _DEBUG
		inputFile;
	#endif
	fast;
	int T = 1;
	// cin >> T;
	while(T--)
	{
		solve();
		cout << endl;
	}
	
	
	return 0;
 
}


  

Measured memory_bytes: 74036
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let x = new Array(n), y = new Array(n);
  for(let i=0; i<n; i++) {
    let k = input[i+1].split(' ').map(val => parseInt(val));
    x[i] = k[0], y[i] = k[1];
  }
  // console.log(n, x, y);
  let distanceSum = 0;
  for(let i=0; i<n-1; i++) {
    for(let j=i; j<n; j++) {
      distanceSum += Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  // console.log(distanceSum);
  console.log(distanceSum/n*2);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    queue<int64_t> q;
    int count = 0;
    int64_t start = 0;
    for (int i = 1; i <= 9; i++){
        q.push(i);
    }
    while (count < K){
        count ++;
        start = q.front();
        //cout << count << " " << start << endl;
        q.pop();
        int f_num = start % 10;
        for (int i = -1; i <= 1; i++){
            if (f_num + i >= 0 && f_num + i <= 9){
                q.push(start * 10 + f_num + i);
                //cout << "push " << start * 10 + f_num + i << endl;
            }
        }
        
    }
    cout << start << endl;
}

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

typedef long long ll;
ll a, b, i, cnt, g;
ll f(ll p, ll q) {
	if (p % q == 0) return q;
	f(q, p % q);
}
int main()
{
	cin >> a >> b;
	g = f(a, b);
	for (i = 2; i * i <= g; i++) {
		if (g % i == 0) {
			cnt++;
		}
		while (g % i == 0) g /= i;
	}
	if (g > 1) cnt++;
	cout << cnt + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  string s; cin>>s;
  rep(i,s.size())
  cout<<"x";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import sys
from math import ceil, log2, isinf


class SegmentTree(object):
    __slots__ = ('dat', 'tree_range')

    def __init__(self):
        """
        Init a SegmentTree with update and find for RMQ.
        """
        self.tree_range = end
        self.dat = [float('inf')] * (2 * self.tree_range - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.tree_range - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, l=0, r=float('inf')):
        if r <= s or t <= l:
            return float('inf')

        elif s <= l <= r <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, l, (l + r) // 2)
            vr = self.find(s, t, k * 2 + 2, (l + r) // 2, r)
            return min(vl, vr)


def action(cmd_list):
    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, r=end)
            if isinf(res):
                print(INIT_MAX)
            else:
                print(res)

    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    end = pow(2, ceil(log2(n_num)))
    INIT_MAX = pow(2, 31) - 1

    case = SegmentTree()

    ans = action(q_list)

Measured memory_bytes: 19636
#include <bits/stdc++.h>
#define ll long long
#define pi (acos(-1))
using namespace std;
/*todos
 * for macro
 * */
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
    auto f = [](unsigned ll i) {
        unsigned ll c = 1, r = 1;
        while (r != 0)
        {
            r = (r * 10 + 1) % i;
            ++c;
        }
        return c;
    };

    unsigned ll k;
    cin >> k;
    if (k == 1||k==7)
    {
        cout << 1 << endl;
        return 0;
    }
    auto s = to_string(k);
    bool ffff = true;
    for (auto &cc : s)
    {
        if (cc != '1')
        {
            ffff = false;
            break;
        }
    }

    if (ffff)
    {
        cout << f(k) << endl;
        return 0;
    }

    if (k % 2 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    if (k % 7 == 0)
    {
        cout << f(k / 7) << endl;
        return 0;
    }
    /*
    bool bbb = false;
    auto pv = genprimevec(10000000);
    for (auto i : pv)
    {
        if (i == k && i != 5)
        {
            bbb = true;
            break;
        }
    }
    if (!bbb)
    {
        cout << -1 << endl;
        return 0;
    }
*/
    if (k % 5 == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << f(k) << endl;


    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void)
{
	int n;
	int a[1000], b[1000], c[1000];
	int i;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		
		if (a[i] > b[i] && a[i] > c[i]){
			if (a[i] * a[i] == b[i] * b[i] + c[i] * c[i]){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else if (b[i] > a[i] && b[i] > c[i]){
			if (b[i] * b[i] == a[i] * a[i] + c[i] * c[i]){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else if (c[i] > a[i] && c[i] > b[i]){
			if (c[i] * c[i] == a[i] * a[i] + b[i] * b[i]){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else {
			printf("NO\n");
		}
			
	}
	
	return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    cin >> a;
    sort(a.begin(), a.end());
    auto judge = [&](int idx) {
        bitset<5001> base = 1;
        for (int i = 0; i < N; i++) {
            if (i == idx || a[i] > 5000) continue;
            base |= (base<<a[i]);
        }
        bool ok = true;
        for (int i = max(0, K - a[idx]); i < K; i++) {
            if (base[i] == 1) ok = false;
        }
        return ok;
    };
    int left = 0, right = N - 1;
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (judge(mid)) left = mid;
        else right = mid;
    }
    if (right == 1) {
        cout << judge(0) << endl;
    } else if (right == N - 1) {
        cout << right + judge(right) << endl;
    } else {
        cout << right << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 21474836001234567
#define double long double

int main(){
  int w,h;
  cin>>w>>h;
  vector<string> vec(h);
  rep(i,h) cin>>vec[i];

  int sx,sy,tx,ty;
  vector<int> spx,spy;
  rep(i,h)rep(j,w){
    if(vec[i][j]=='s') sx=i,sy=j;
    if(vec[i][j]=='g') tx=i,ty=j;
    if(vec[i][j]=='*') spx.pb(i), spy.pb(j);
  }

  vector<vector<long>> d(h, vector<long>(w, INF));
  // g?????§??????????????¢
  {
    queue<int> xs,ys;
    d[tx][ty] = 0;
    xs.push(tx); ys.push(ty);
    while(!xs.empty()){
      int x = xs.front(); xs.pop();
      int y = ys.front(); ys.pop();
      const int dx[] = {0,0,-1,1}, dy[] = {-1,1,0,0};
      rep(i,4){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(vec[nx][ny]!='#' && vec[nx][ny]!='*' && d[nx][ny]>d[x][y]+1){
          d[nx][ny] = d[x][y]+1;
          xs.push(nx);
          ys.push(ny);
        }
      }
    }
  }

  vector<vector<long>> ds(h,vector<long>(w,INF));
  // ????????????spring?????§??????????????¢
  {
    queue<int> xs,ys;
    rep(i,spx.size()){
      xs.push(spx[i]);
      ys.push(spy[i]);
      ds[spx[i]][spy[i]] = 0;
    }
    while(!xs.empty()){
      int x = xs.front(); xs.pop();
      int y = ys.front(); ys.pop();
      const int dx[] = {0,0,-1,1}, dy[] = {-1,1,0,0};
      rep(i,4){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(vec[nx][ny]!='#' && vec[nx][ny]!='*' && ds[nx][ny]>ds[x][y]+1){
          ds[nx][ny] = ds[x][y]+1;
          xs.push(nx);
          ys.push(ny);
        }
      }
    }
  }

  double p = INF; // ????????§?£???°??????????????¨?????????????§????????????????
  {
    int cnt=1;
    rep(i,h)rep(j,w)if(vec[i][j]=='.') cnt++;

    double l = 0, r = 500.0*500*500*500;
    rep(_,1000){
      double m = (l+r)/2.0;
      double accm = min<double>(d[sx][sy], ds[sx][sy]+m);
      rep(i,h) rep(j,w)if(vec[i][j]=='.'){
        accm += min<double>(d[i][j], ds[i][j]+m);
      }
      p = accm/cnt;
      if(p<m) r = m;
      else l = m;
    }
    p = (r+l)/2.0;
  }

  printf("%.10llf\n", min<double>(d[sx][sy], ds[sx][sy]+p));

  return 0;
}

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

using namespace std;

const int MAX_V = 1e5+10;

vector<vector<int> > g(MAX_V);
vector<pair<int, int> > bridge;
int n;
bool visited[MAX_V];
int ord[MAX_V], low[MAX_V], timer;

void dfs(int v, int p){
	ord[v] = low[v] = timer++;
	visited[v] = true;
	for (int i = 0; i < g[v].size(); ++i)
	{
		int to = g[v][i];
		if (to == p) continue;
		if (visited[to]) low[v] = min(low[v], ord[to]);
		else {
			dfs(to, v);
			low[v] = min(low[v], low[to]);
			if (ord[v] < low[to]) bridge.push_back(make_pair(min(v,to),max(v, to)));
		}
	}
}

void find_bridge(){
	for (int i = 0; i < n; ++i) visited[i] = false;

	timer = 0;
    dfs(0,-1);
    sort(bridge.begin(), bridge.end());
	bridge.erase(unique(bridge.begin(), bridge.end()), bridge.end());
}

int main(int argc, char const *argv[])
{
	int m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int s, t;
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}

	find_bridge();

	for (int i = 0; i < bridge.size(); ++i) cout << bridge[i].first << ' ' << bridge[i].second << endl;
	return 0;
}


Measured memory_bytes: 6772
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
const int N=1e6+10;
using namespace std;
ll a,b,k;

int main() {
  cin>>a>>b>>k;
  if(k>=a+b){
      cout<<0<<" "<<0<<endl;
      return 0;
  }
  else if(k<=a){
      cout<<a-k<<" "<<b<<endl;
      return 0;
  }
  else {
      cout<<0<<" "<<b-k+a<<endl;
      return 0;
  }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
using namespace std;
  
class Task {
public:
  void input() {
    cin >> name >> time;
  }
  string name;
  int time;
};
  
int main() {
  int n, q;
  queue<Task> tasks;
  
  cin >> n >> q;
  for (int i=0; i<n; i++) {
    auto task = Task();
    task.input();
    tasks.push(task);
  }
  
  int time = 0;
  
  while (!tasks.empty()) {
    auto current = tasks.front(); tasks.pop();
    if (current.time > q) {
      time += q;
      current.time -= q;
      tasks.push(current);
    } else {
      time += current.time;
      cout << current.name << ' ' << time << endl;
    }
  }
}

Measured memory_bytes: 6368
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  vector<int> ws;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ws.push_back(a);
  }
  int r, s = 1;
  for (int i = 1; i <= n; i++) {
    int s1 = 0, s2 = 0;
    for (int j = 0; j < n; j++) {
      if (j >= i) {
        s1 += ws[j];
      } else {
        s2 += ws[j];
      }
    }
    if (s == 1) {
      r = abs(s1 - s2);
      s = 0;
    } else {
      int memo = abs(s1 - s2);
      if (r > memo) {
        r = memo;
      }
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll maxSubArraySum(int a[], int size)
{
         ll max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;

       /* Do not compare for all elements. Compare only
          when  max_ending_here > 0 */
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
                return max_so_far;
}
int main()
{
	ll n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	if(abs(a-b)%2==0)
	{
		cout<<abs(a-b)/2<<endl;
	}
	else
	{
		ll mini=min(a,b);
		ll maxi=max(a,b);
		cout<<min(mini-1,n-maxi)+1+(maxi-mini-1)/2;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string s, t;


signed main(){
    cin >> s >> t;

    cout << t << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n / 10 % 111 == 0 || n % 1000 % 111 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n,r;
  cin >> n >> r;
  if(n<10) cout<< r + 100 * (10-n) <<endl;
  else cout<< r <<endl;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
import numpy as np
N = int(input())
A = np.array([list(map(int, input().split())) for _ in [0]*N], dtype=np.int)
D = csgraph_from_dense(A)
D = floyd_warshall(D, directed=False)

if (A == D).all():
    ans = 0
    D += np.identity(N, int) * (1 << 60)
    for i in range(N):
        for j in range(i+1, N):
            a = np.min(D[i]+D[j])
            if a > D[i, j]:
                ans += D[i, j]
    print(int(ans))
else:
    print(-1)


Measured memory_bytes: 42504
import math
A, B, H, M = map(int, input().split())
x = 360 * H / 12 + 30 * M / 60
y = 360 * M / 60
# print(x, y)
h = abs(x - y)
# h = abs(min(x, 360 - x) - min(y, 360 - y))
h = min(h, 360 - h)
# print(h)
ans = (A**2 + B**2 - 2*A*B*math.cos(h*math.pi/180))**0.5
print(ans)


Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

P dp[105][105];

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    if (s[0][0] == '#') dp[0][0] = P(0, 1);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0) {
                if (j == 0) continue;
                dp[i][j] = dp[i][j - 1];
            } else {
                if (j == 0) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
            }
            if (dp[i][j].second == 1) {
                if (s[i][j] != '#') dp[i][j] = P(dp[i][j].first + 1, 0);
            } else if (s[i][j] == '#') dp[i][j] = P(dp[i][j].first, 1);
        }
    }
    if (dp[h - 1][w - 1].second == 1) dp[h - 1][w - 1] = P(dp[h - 1][w - 1].first + 1, 0);
    cout << dp[h - 1][w - 1].first << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
#define vsz(x) ((long long) x.size())
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
// mt19937 rng(steady_clock::now().time_since_epoch().count());
mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;


 
ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;



void solve(int tc) {
  cin >> n >> m;
  if (m % 2) {
    cout << "No\n";
    return;
  }
  cout << (2 * n <= m && m <= 4 * n ? "Yes\n" : "No\n");
}
 
int main() {
  send help
 
  // usaco("cowland");

  int tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

Measured memory_bytes: 3652
s=str(input())
n=len(s)
k=s[0:(n-1)//2]
k1=s[(n+3)//2-1:n]

if n%2!=0 and k=="".join(reversed(k)) and k1=="".join(reversed(k1)) and s=="".join(reversed(s)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <queue>
#include <cmath>
#include <set>



using namespace std;
typedef long long ll;


int main () {
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s.size()>=4 && s[0]=='Y' && s[1]=='A' && s[2]=='K' &&s[3]=='I')
        cout<<"Yes";
    else
        cout<<"No";
    
    return 0;

    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<pair<long long,long long>> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i].first;
        A[i].second=i+1;
    }
    sort(A.begin(),A.end());
    /*
    for(auto p:A){
        cout<<"<"<<p.first<<","<<p.second<<"> ";
    }
    //*/

    //*
    vector<vector<long long>> dp(N+1,vector<long long>(N+1,0));
    int pt=A.size()-1;
    for(int i=1;i<=N;i++){
        //cout<<A[pt].first<< " "<<A[pt].second<<endl;
        for(int j=0;j<=i;j++){
            //cout<<j<<" "<<i-j<<endl;
            if(j==0){
                dp[j][i-j]=dp[j][i-j-1]+A[pt].first*abs(N+1-i+j-A[pt].second);
            }else if(i-j==0){
                dp[j][i-j]=dp[j-1][i-j]+A[pt].first*abs(j-A[pt].second);
            }else{
                dp[j][i-j]=max(dp[j][i-j-1]+A[pt].first*abs(N+1-i+j-A[pt].second),dp[j-1][i-j]+A[pt].first*abs(j-A[pt].second));
            }
        }
        pt--;
    }
    /*
    for(int i=0;i<=N;i++){
        for(auto p:dp[i]){
            cout<<p<<" ";
        }
        cout<<endl;
    }
    //*/
    long long ans=0;
    for(int i=0;i<=N;i++){
        if(ans<dp[i][N-i]){
            ans=dp[i][N-i];
        }
    }
    cout<<ans<<endl;
    //*/


    return 0;
}

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

cnt=0
a=a*2
l=[[0,0] for i in range(n)]
for i in range(n):
    for j in range(i+1,n+i):
        if a[i]>a[j] and j<=n-1:
            l[i][0]+=1
        elif a[i]>a[j] and j>n-1:
            l[i][1]+=1

for i in range(n):
    num=l[i][0]
    num1=l[i][1]
    cnt+=num*k*(k+1)//2+num1*(k-1)*k//2

print(cnt%(10**9+7))

Measured memory_bytes: 3348
n = int(input())
A = [int(a) for a in input().split()]
cnt = 0
flg = True
while flg:
    flg = False
    for j in range(n-1, 0, -1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            cnt += 1
            flg = True
A = [str(a) for a in A]
print(" ".join(A))
print(cnt)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m,k;
    cin >> n >> m >> k;
    REP(i,n+1)REP(j,m+1){
        if(m * i + n * j - 2 * i * j == k){
            Yes(true);
            return 0;
        }
    }
    Yes(false);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <tuple>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) {
            return 0;
        }

        vector<tuple<int, int, int>> v;
        for (int i = 0; i < m; ++i) {
            int t, s, d;
            cin >> t >> s >> d;
            v.emplace_back(t, s, d);
        }
        sort(begin(v), end(v), [](const auto& a, const auto& b) {
            return get<0>(a) < get<0>(b);
        });
        vector<bool> states(n, false);
        states[0] = true;
        for (auto&& message : v) {
            int s, d;
            tie(ignore, s, d) = message;
            if (states[s - 1]) {
                states[d - 1] = true;
            }
        }
        cout << accumulate(begin(states), end(states), 0, [](int z, bool b) {
            return b ? z + 1 : z;
        }) << endl;
    }
}


Measured memory_bytes: 3372
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N;

long long a[100010][3];

long long dp[100010][3];

int main(){
  int N;
  cin>>N;
  for(int i=0; i<N; i++) for (int j=0; j<3; j++) cin>>a[i][j];
  
  for (int i=0; i<N; i++){
    for (int j=0; j<3; j++){
      for (int k=0; k<3; k++){
  if (j==k) continue;
  chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  
  long long res=0;
 for(int i=0; i<3; i++) chmax(res, dp[N][i]);
  cout<<res<<endl;
}
  
    

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <bitset>

#define ll long long

int main()
{
    ll N;
    std::cin >> N;

    std::vector<ll> A(N), B(N);
    for(ll i=0; i < N; i++) {
        std::cin >> A[i] >> B[i];
    }
    std::sort(A.begin(), A.end());
    std::sort(B.begin(), B.end());

    if(N%2==1) {
        // 奇数の時
        ll ans = B[N/2] - A[N/2]+1;
        std::cout << ans << std::endl;
    }
    else {
        // 偶数の時
        ll now1 = B[N/2] + B[N/2-1];
        ll now2 = A[N/2] + A[N/2-1];
        ll ans = now1-now2+1;
        std::cout << ans << std::endl;
    }
}

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

int main()
{
    long long int t,r,c,i,m=2019,j;

    cin>>t>>r;
    if((t+2020)<r)
    {
        r=t+2020;
    }

    for(j=t;j<r;j++)
    {

    for(i=t+1;i<=r;i++)
    {
    c=((j*i)%2019);

    if(c<m)
        m=c;

    }
    }
    cout<<m<<endl;


    return 0;
}


Measured memory_bytes: 256
Matches = {num: c for num, c in zip([1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 5, 4, 5, 6, 3, 7, 6])}


def solve(N, M, As):
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(N + 1):
        for a in As:
            c = Matches[a]
            if dp[i] == -1:
                continue
            if i + c <= N:
                dp[i + c] = max(dp[i + c],
                                dp[i] * 10 + a)
    return dp[N]

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, M, As))


Measured memory_bytes: 51164
/*
[agc039] A - Connection and Disconnection
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

string S;
ll K;
int N;

ll solve() {
    N = S.length();
    if (S == string(N, S[0])) {
        return N * K / 2;
    }

    vector<int> cs;
    for (int i = 1, cnt = 1; i <= N; i++) {
        if (i < N && S[i - 1] == S[i]) {
            cnt++;
        } else {
            cs.push_back(cnt);
            cnt = 1;
        }
    }

    ll ans = 0;
    for (int c : cs) {
        ans += (c / 2) * K;
    }
    if (S[0] == S[N - 1]) {
        int x = *cs.begin();
        int y = *cs.rbegin();
        ans += ((x + y) / 2 * (K - 1)) - (x / 2) * (K - 1) - (y / 2) * (K - 1);
    }

    return ans;
}

int main() {
    cin >> S;
    cin >> K;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256