akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;

inline int gauss_jordan(const mat& A, const vec& b){
  int n = A.size();
  mat B(n,vec(n+1));
  rep(i,n)rep(j,n)B[i][j] = A[i][j];
  rep(i,n)B[i][n] = b[i];

  rep(i,n){
    int p = i;
    for(int j=i;j<n;j++){
      if(B[j][i]==1){p = j; break;}
    }
    swap(B[i],B[p]);
    if(B[i][i] == 0)continue;;
    
    rep(j,n){
      if(i!=j && B[j][i]){
	for(int k=i;k<=n;k++)(B[j][k] += B[i][k]) &= 1;
      }
    }
  }
  rep(i,n){
    bool f = false;
    rep(j,n)f |= (B[i][j]==1);
    if(!f && B[i][n])return 0;
  }
  return 1;
}

const int dy[] = {-1,-1,1,1}, dx[] = {-1,1,-1,1};
inline vec manhattan(int y, int x, int d, int h, int w){
  vec res(h*w,0);
  res[y*w+x] = 1;
  rep(dir,4){
    rep(k,d+1){
      int ny = y + k*dy[dir], nx = x + (d-k)*dx[dir];
      if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
      res[ny*w+nx] = 1;
    }
  }
  return res;
}

int main(){
  int w,h,d;
  while(scanf("%d%d%d",&w,&h,&d),h){
    mat A(h*w);
    vec b(h*w);
    rep(i,h)rep(j,w){
      A[i*w+j] = manhattan(i,j,d,h,w);
      scanf("%d",&b[i*w+j]);
    }
    cout << gauss_jordan(A,b) << endl;
  }
}

Measured memory_bytes: 4232
def resolve():
    S = input()
    P = int(S[0]+S[1])
    Q = int(S[2]+S[3])
    if 0<P<=12 and 0<Q<=12:
        print("AMBIGUOUS")
    elif 0<P<=12 and (Q>12 or Q==0):
        print("MMYY")
    elif (P>=13 or P==0) and 0<Q<=12:
        print("YYMM")
    else:
        print("NA")
resolve()

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let d: Vec<u32> = (0..n).map(|_| read()).collect();
    let mut sum: u32 = 0;

    for i in 0..n {
        for j in i+1..n {
            //println!("i:{}, j:{}", i, j);
            sum += d[i]*d[j];
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
  public static double e(int n){
    return (double)(n+1)/(double)2;
  }
	public static int sum(int n,int m){
		int j=0;
		for(int i=0;i<m;i++){
			j+=n-i;
		}
		return j;
	}
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),k=sc.nextInt(),f=0;
    int[] p=new int[n];
  	double[] s=new double[n];
  	
    double max=0,fmax=0;
    for(int i=0;i<n;i++){
      p[i]=sc.nextInt();
    	if(i==0){
    		s[i]=e(p[i]);
    	}else{
    		s[i]=s[i-1]+e(p[i]);
    	}
    }
  	for(int i=0;i<=n-k;i++){
  		if(i==0){
  			max=s[k-1];
  		}else{
  			max=Math.max(max,s[i-1+k]-s[i-1]);
  		}
  	}
  	
  	System.out.println(max);
  }
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    ll ans = 0;
    for(int i = 0; i < n; ++i) cin >> a[i];    

    for(int i = 0; i < n; ++i) {
        cin >> b[i];
        ans += b[i];
    }
    // cout << "\n" << ans << "\n";
    for(int i = 0; i < n-1; ++i) cin >> c[i];
    for(int i = 0; i < n-1; ++i) {
        if(a[i]+1==a[i+1]){
            ans += c[a[i]-1];
            // cout << i << " ";
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	string s;ll k;cin>>s>>k;
	int n =s.length();
	rep(i,n-1){
		if('z'-s[i]+1<=k&&s[i]!='a'){
			k-='z'-s[i]+1;
			s[i]='a';
		}
	}
	k%=26;
	k+=s[n-1]-'a';
	k%=26;
	s[n-1]='a'+k;
	cout<<s<<endl;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 3005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll dp[maxn][maxn],a,b,c,d;
const ll mod=998244353;

int main()
{
	cin>>a>>b>>c>>d; dp[a][b]=1;
	for(ll i=a;i<=c;i++)
	{
		for(ll j=b;j<=d;j++)
		{
			if(i==a&&j==b) continue;
			ll tmp=((i-1)*(j-1)*(dp[i-1][j-1]))%mod;
			dp[i][j]=((dp[i-1][j]*j)%mod+(i*dp[i][j-1])%mod-tmp+mod)%mod;
		}
	}
	cout<<dp[c][d]<<endl;
	return 0;
}

Measured memory_bytes: 73864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++) {
        cin >> p[i];
    }
    vector<double> P(N);
    for(int i=0; i<N; i++) {
        P[i] = (1.0+(double)p[i]) * 0.5;
    }

    double sum = accumulate(P.begin(), P.begin()+K, 0.0);
    double ans = sum;
    for(int i=1; i+K-1<N; i++) {
        sum = sum -  P[i-1] + P[i+K-1];
        ans = max(ans, sum);
    }

    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

const int NMAX = 55;

char s[NMAX];

int main()
{
    int K,N,i,j;
    cin>>N>>K;
    cin>>(s+1);
    s[K] = 'a' + (s[K]-'A');
    cout<<(s+1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=105;
int n,m;
int a[N][N];
int dp[N][N];
char s[N][N];
void ckmin(int &a,int b){
	a=min(a,b);
}
int main(){
	n=read(),m=read();
	For(i,1,n){
		scanf("%s",s[i]+1);
		For(j,1,m)
			a[i][j]=s[i][j]=='#',dp[i][j]=N*N;
	}
	dp[1][1]=a[1][1];
	For(i,1,n)
		For(j,1,m){
			if (j<m)
				ckmin(dp[i][j+1],dp[i][j]+(a[i][j]==0&&a[i][j+1]==1));
			if (i<n)
				ckmin(dp[i+1][j],dp[i][j]+(a[i][j]==0&&a[i+1][j]==1));
		}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
string S;

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

  vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));

  for (int i = N - 1; i >= 0; --i) {
    for (int j = N - 1; j >= 0; --j) {
      if (S[i] == S[j]) dp[i][j] = 1 + dp[i + 1][j + 1];
    }
  }

  int ans = 0;
  rep(i, N) rep(j, N) {
    if (i >= j) continue;
    ans = max(ans, min(dp[i][j], j - i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 98176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <utility>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  int a, b; cin >> a >> b;

  if(a % 2 && b % 2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s;
    cin >> s;
    int num;
    num = s.length();
    rep(i,num)
    {
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

const int INF = 1 << 28;

struct SegmentTree
{
 
  vector< int > small, add;
  int sz;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    small.assign(2 * sz - 1, INF);
    add.assign(2 * sz - 1, 0);
  }
  inline void Merge(int k)
  {
    small[k] = min(small[2 * k + 1] + add[2 * k + 1], small[2 * k + 2] + add[2 * k + 2]);
  }
  inline int RangeMinimumQuery(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return(INF);
    if(a <= l && r <= b) return(small[k] + add[k]);
    int L = RangeMinimumQuery(a, b, 2 * k + 1, l, (l + r) >> 1);
    int R = RangeMinimumQuery(a, b, 2 * k + 2, (l + r) >> 1, r);
    return(min(L, R) + add[k]);
  }
  int RangeMinimumQuery(int a, int b)
  {
    return(RangeMinimumQuery(a, b, 0, 0, sz));
  }
  inline void RangeAdd(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    RangeAdd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    RangeAdd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    Merge(k);
  }
  void RangeAdd(int a, int b, int x)
  {
    return(RangeAdd(a, b, x, 0, 0, sz));
  }
  inline int BinarySearch(int k, int l, int r, int upd)
  {
    if(k >= sz - 1) return(r);
    const int right = small[2 * k + 2] + add[2 * k + 2] + add[k] + upd;
    if(right >= 2) return(BinarySearch(2 * k + 1, l, (l + r) >> 1, upd + add[k]));
    return(BinarySearch(2 * k + 2, (l + r) >> 1, r, upd + add[k]));
  }
  int BinarySearch()
  {
    return(BinarySearch(0, 0, sz, 0));
  }
};

int main()
{
  int N, Q;

  scanf("%d %d", &N, &Q);
  char S[300001];
  scanf(" %s", S);
  SegmentTree tree(N);
  set< int > open, close;
  for(int i = 0; i < N; i++) {
    tree.RangeAdd(i, i + 1, -INF);
  }
  for(int i = 0; i < N; i++) {
    tree.RangeAdd(i, N, S[i] == '(' ? +1 : -1);
    if(S[i] == ')') close.insert(i);
    else open.insert(i);
  }
  while(Q--) {
    int q;
    scanf("%d", &q);
    --q;
    tree.RangeAdd(q, N, S[q] == ')' ? +2 : -2);
    if(S[q] == '(') {
      open.erase(q);
      close.insert(q);
      S[q] = ')';
      printf("%d\n", *close.begin() + 1);
      tree.RangeAdd(*close.begin(), N, +2);
      S[*close.begin()] = '(';
      open.insert(*close.begin());
      close.erase(close.begin());
      
    } else {
      close.erase(q);
      open.insert(q);
      S[q] = '(';
      int pos = *open.lower_bound(tree.BinarySearch());
      printf("%d\n", pos + 1);
      tree.RangeAdd(pos, N, -2);
      S[pos] = ')';
      open.erase(pos);
      close.insert(pos);
    }
  }
}

Measured memory_bytes: 25296
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("test (1).txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int sum = 0,c = 0;
    for(int i=0; i<n; i++)
    {
        if(s[i] == t[c]) {
                sum++;
                c++;
        }
        else
        {
            sum = c = 0;
            if(t[0] == s[i])
            {
                sum = 1;
                c = 1;
            }
        }
    }
    cout << n*2 - sum << '\n';

    return 0;
}


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

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

  long long a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c && a % 2 == 0) {
    return cout << -1 << '\n', 0;
  }

  int ans = 0;
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int na = (b + c) / 2, nb = (a + c) / 2, nc = (a + b) / 2;
    a = na, b = nb, c = nc;
    ans++;
  }
  cout << ans << '\n';
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

constexpr ll LNF = 1e15;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; ll z,w; cin >> n >> z >> w;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll ans = abs(a[n-1]-w);
    if(n==1){
        cout << ans << endl;
        return 0;
    }
    chmax(ans,abs(a[n-1]-a[n-2]));
    cout << ans << endl;
}

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

int main()
{
    int NUM_PUSH = 2;
    int A, B;
    cin >> A >> B;
    int push, sum = 0;
    for (int i = 0; i < NUM_PUSH; i++) {
        if (A >= B) {
            push = A;
            A--;
        }
        else {
            push = B;
            B--;
        }
        sum += push;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,m;
    int A;
    int sum=0;
    scanf("%d %d",&n,&m);
    for(int i=1; i<=m; i++){
        scanf("%d",&A);
        sum+=A;
    }
    printf("%d",n - sum <0 ? -1: n-sum);
    return 0;

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N;
vector<ll> D;
int main(){
	cin>>N;
	D.resize(N);
	rep(i,N) cin>>D[i];
	using ll_i = pair<ll,int>;
	vector<ll_i> dis;
	map<ll,int> mp;
	rep(i,N){
		dis.pb(ll_i(D[i],i));
		mp[D[i]] = i;
	}
	sort(all(dis),greater<ll_i>());
	using P = pair<int,int>;
	vector<P> es;
	vector<int> sz(N);
	vector<ll> dsum(N);
	rep(_,N-1){
		int v = dis[_].sc;
		sz[v]++;
		ll tar = D[v] - (N-2*sz[v]);
		if(!mp.count(tar)){
			puts("-1");
			return 0;
		}
		int p = mp[tar];
		sz[p] += sz[v];
		dsum[p] += dsum[v] + sz[v];
		es.pb(P(v,p));
	}
	{
		int r = dis[N-1].sc;
		if(dsum[r] != D[r]){
			puts("-1");
			return 0;
		}
	}
	for(P p: es){
		cout<<p.fs+1<<" "<<p.sc+1<<endl;
	}
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/26  Problem: ABC 116 B / Link: http://abc116.contest.atcoder.jp/tasks/abc116_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	int s; cin >> s;
	map<int,int>se;
	int cnt = 1;
	se[s] = cnt++;
	while (1) {
		int nx = (s & 1 ? 3 * s + 1 : s / 2);
		if (se.count(nx)) {
			ans = cnt;
			break;
		}
		else {
			se[nx] = cnt++;
			s = nx;
			DD(de(s));
		}
	}
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static int n = 0;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = sc.nextInt();


		}

		Arrays.sort(p);
		long ans = 1000000000;
		for(int i= 0;i + k -1 < n;i++){
			ans = Math.min(ans, p[i+k-1] - p[i]);

		}
		System.out.println(ans);




	}

}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


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

string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S;
    int i;
    for(i=(int)S.size()-2; i>=2; i-=2){
        int len = i/2;
        if(equal(S.begin(), S.begin()+len, S.begin()+len, S.begin()+2*len))break;
    }
    printf("%d\n", i);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    string n;
    cin >> n;
    rep(i,3){
        if(n[i]=='1') n[i] = '9';
        else n[i] = '1';
    }
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 3492
import java.util.Scanner;
import java.util.HashMap;
public class Main{
	static boolean[] kk;
	static HashMap<Integer,Long>[] map;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		kk=new boolean[n];
		map=new HashMap[n];
		for(int i=0; i<n; i++){
			map[i]=new HashMap<>();
		}
		for(int i = 0; i<n-1; i++){
			int u = sc.nextInt();
			int v = sc.nextInt();
			long w = sc.nextLong();
			map[u-1].put(v,w);
			map[v-1].put(u,w);
		}
		dfs(-1,0,0);
		for(int i=0; i<n; i++){
			if(kk[i]){
				System.out.println(1);
			}else{
				System.out.println(0);
			}
		}
	}
	static void dfs(long sum,int r,int o){
		if(sum%2==0){
			kk[r]=true;
		}
		for(int j:map[r].keySet()){
			if(j-1!=o){
				dfs(map[r].get(j)+sum,j-1,r);
			}
		}
		return;
	}
}


Measured memory_bytes: 124808
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n:u8,
        s: chars,
    }


    println!("{}", s.into_iter().map(|c| ((n + c as u8 - 'A' as u8)%26 + 'A' as u8 )  as char).collect::<String>());

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	int N, M;
	int A[128];
	int i;
	int wa = 0;
	int kaunto = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		wa += A[i];
	}

	for (i = 0; i < N; i++) {
		if (A[i] * 4 * M >= wa) kaunto++;
	}
	puts(kaunto >= M ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
ll pt[N][3];
ll fnd[N][2];
void solve(){
	int nn; 
	cin>>nn;
	ll h = 0;
	ll n = 0;
	for(int i=1;i<=nn;i++){
		int x,y,z; 
		cin>>x>>y>>z;
		if(z>0)pt[++n][0] = x;
		if(z>0)pt[n][1] = y;
		if(z>0)pt[n][2] = z;
	}
	if(n==1){
		cout<<pt[1][0]<<" "<<pt[1][1]<<" "<<pt[1][2]<<endl;
		return ;
	}
	
	for(int x = 0;x<=100;x++){
		for(int y=0;y<=100;y++){
			map<int,int>mp;
			for(int i=1;i<=n;i++){
				int dis = abs(x-pt[i][0])+abs(y-pt[i][1]);
				mp[dis+pt[i][2]]++;
			}
			for(auto p:mp){
				if(p.sc==n){
					if(h>0 and h!=p.fr){
						cout<<"WTF"<<endl;
						return ;
					}
					if(h==0)h = p.fr;
				}
			}
		}
	}
	for(int x = 0;x<=100;x++){
		for(int y=0;y<=100;y++){
			int trt = 0;
			int trrt = 0;
			for(int i=1;i<=n;i++){
				if(pt[i][2]==0)continue;
				trrt++;
				int dis = abs(x-pt[i][0])+abs(y-pt[i][1]);
				if(dis+pt[i][2]==h)trt++;
			}
			if(trt==trrt){
				cout<<x<<" "<<y<<" "<<h<<endl;
				return ;
			}
			
		}
	}
	assert(0);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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


s = input()
k = int(input())
n = len(s)
l = []
for i in range(5):
    l.extend([s[ii:(ii+i+1)] for ii in range(n-i)])
l = list(set(l))
l.sort()
ans = l[k-1]
print(ans)

Measured memory_bytes: 69292
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(void){
    string S;
    cin >> S;
    string ans = "Yes";
    int dp[1000] = {0};
    for(int i=0;i<S.size();i++){
        dp[S[i]]++;
    }
    for(int i='a';i<='z';i++){
        if(dp[i] % 2 == 1){
            ans = "No";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2972
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value,vector<ll> a)
{
	
	for (ll i = 0; i < a.size();i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}
//E869120 
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
 int x;
 cin>>x;
 for(int i=x;i<1000;i++){
  
   if(i%111==0){
      cout<<i;
      break;
   }
 }

	return 0;
}













Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int sum = 0;
        int count = 0;
        while(!(n == 0 && x == 0)){
            for(int i=1;i<=n;i++){
                for(int j=i+1;j<=n;j++){
                    for(int k=j+1;k<=n;k++){
                        sum = i + j + k;
                        if(sum == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
            n = sc.nextInt();
            x = sc.nextInt();
            sum = 0;
            count = 0;
        }
    }
}


Measured memory_bytes: 26864
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d) {
        cout << "Left" << endl;
    } else if (a + b == c + d) {
        cout << "Balanced" << endl;
    } else if (a + b < c + d) {
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      string s;
      cin>>s;
      for(int i=0;i<s.length();i++){
            char ans=(s[i]-'A'+n)%26+'A';
            cout<<ans;
      }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;
#define PI 3.141592653589793

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int upf(double num){
    if(num-(int)num>0)return (int)num+1;
    else return num;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};
bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-(2.0*a*b*cos((max(30.0*h+(m*0.5),6*m)-min(30.0*h+(m*0.5),6*m))*PI/180.0)));
    return 0;
}


Measured memory_bytes: 4232
# coding=utf-8
import math

root_three = math.sqrt(3)


def divide_segment(left, right):
    """divide segment

    Args:
        left: left edge coordinate
        right: right edge coordinate

    Returns:
        divided points
    """
    delta_x_quarter = (right[0] - left[0]) / 3.0
    delta_y_quarter = (right[1] - left[1]) / 3.0

    delta_x_quarter_rotated = (delta_x_quarter - root_three * delta_y_quarter) / 2.0
    delta_y_quarter_rotated = (root_three * delta_x_quarter + delta_y_quarter) / 2.0

    s = [left[0] + delta_x_quarter, left[1] + delta_y_quarter]
    t = [left[0] + delta_x_quarter * 2.0, left[1] + delta_y_quarter * 2.0]
    u = [s[0] + delta_x_quarter_rotated, s[1] + delta_y_quarter_rotated]

    return s, t, u


def make_coch_curve(depth, left, right):
    """make coch curve with depth iteration_number between point left, right
    each vertices positions are printed

    Args:
        depth: depth
        left: left edge point
        right: right edge point

    Returns:
        None
    """
    print("{0:2.8f} {1:2.8f}".format(left[0], left[1]))
    if depth == 0:
        print("{0:2.8f} {1:2.8f}".format(right[0], right[1]))
    else:
        make_coch_curve_recursively(depth - 1, left, right)


def make_coch_curve_recursively(depth, left, right):
    """recursion part of coch curve

    Args:
        depth: depth
        left: left edge coordinate
        right: right edge coordinate

    Returns:
        None
    """
    # get coordinate of divided points
    s, t, u = divide_segment(left, right)

    if depth == 0:
        print("{0:2.8f} {1:2.8f}".format(s[0], s[1]))
        print("{0:2.8f} {1:2.8f}".format(u[0], u[1]))
        print("{0:2.8f} {1:2.8f}".format(t[0], t[1]))
        print("{0:2.8f} {1:2.8f}".format(right[0], right[1]))
    else:
        make_coch_curve_recursively(depth - 1, left, s)
        make_coch_curve_recursively(depth - 1, s, u)
        make_coch_curve_recursively(depth - 1, u, t)
        make_coch_curve_recursively(depth - 1, t, right)


def main():
    depth = int(input().strip())
    make_coch_curve(depth, left=[0.0, 0.0], right=[100.0, 0.0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 7880
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	string s;
    cin>>s;
    map<char,int> m;
    REP(i,4){
        m[s[i]]++;
    }
    if(SZ(m)==2&&m[s[0]]==2) OUT("Yes");
    else OUT("No");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $in = <>;
	chomp $in;
	
	my @baseArray = qw/1 2 0 4 0 0 7 8 0 0 11 0 13 14 0/;

	my $x = int($in / 15);
	my $y = $in % 15;
	my $sum = 0;
	my $lineBase = 0;

	if ($x != 0){
		for(my $i = 0; $i < $x; $i++){
			$sum += 60;
			$sum += $lineBase * 8;
			$lineBase += 15;
		}
	}

	for (my $i = 0; $i < $y; $i++){
		if ($baseArray[$i] != 0){
			$sum += $lineBase + $baseArray[$i];
		}
	}

	print $sum, "\n";

	return 0;
}

#----- 実行 -----#
exit( main() );




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

int main(void)
{
	int h,r,f;
	scanf("%d %d",&h,&r);
	if(h>=0)	f=1;
	else {
		if(h+r>0)	f=1;
		else if(h+r==0)	f=0;
		else f=-1;
	}
	printf("%d\n",f);
	return 0;
}


Measured memory_bytes: 2696
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
M = sum(A)

# 答えの候補を列挙
ans_candidates = []
for n in range(1, int(M ** 0.5) + 1):
    if M % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(M // n)


ans = 0
for X in ans_candidates:
    A_mod = sorted([a % X for a in A])
    U = [X - a for a in A_mod]
    D = [-a for a in A_mod]  # わかりやすいので

    U = list(accumulate(U))
    D = list(accumulate(D))

    for i in range(N):
        if -D[i] > K:
            break

        if -D[i] == (U[-1] - U[i]):
            ans = max(ans, X)
            break

print(ans)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int x,a,b;
	scanf("%d %d %d", &x, &a, &b);

	if(abs(x-a) < abs(x-b))
	{
		printf("A");
	}
	else
	{
		printf("B");
	}
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))


int main()
{
    ll i,j,k,l,m,n,sum=1e9,ans=0;

    cin >> n;

    ll ar[n+10];

    for(i=0; i<n; i++)
        cin >> ar[i];
    for(m=0; m<=100; m++)
    {
        ans = 0;
        for(i=0; i<n; i++)
        {
            ans += ((m-ar[i])*(m-ar[i]));
        }
        sum = min(sum,ans);
    }

    cout << sum << endl;
}


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

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;
}
const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[110], value[110];
long long dp[110][100100];

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

	for (int i = 0; i < MAX_N; i++) for (int j = 0; j < MAX_V; j++) dp[i][j] = INF;

	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int sum_v = 0; sum_v <= MAX_V; sum_v++) {
			if (sum_v >= value[i]) {
				chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			}
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);
		}
	}

	long long res = 0;
	for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
		if (dp[N][sum_v] <= W) res = sum_v;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 89664
import sys
input=sys.stdin.readline

N,K = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort()

ans = H[-1] - H[0]
for i in range(N-K+1):
    ans = min(ans, H[i+K-1] - H[i])
print(ans)


Measured memory_bytes: 7500
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int A, P;
  std::cin >> A >> P;
  std::cout << ((A * 3 + P) / 2) << std::endl;
}


Measured memory_bytes: 888
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = (l); i < (r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int r;
	cin>>r;
	cout<<2*M_PI*r;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        if (sum >= h) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 50796
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  while(n){
    n /= k;
    ans++;
  }
  print(ans);
}


Measured memory_bytes: 256
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))
#define pb push_back

using namespace std;

const int inf=0x3f3f3f3f;

int n,k;
double ans;

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		double tmp=1.0;
		int cur=i;
		while (cur<k){
			cur*=2;
			tmp/=2;
		}
		ans+=tmp/n;
	}
	printf("%.12f\n",ans);

	return 0;
}



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


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n;
int m;
int dp[MAX];
vector<int> adj[MAX];

int solve(int u){

        if(!adj[u].size()){
            return 0;
        }

        int &res=dp[u];
        if(res!=-1){
            return res;
        }

        res=0;
        for(auto &v:adj[u]){
            res=max(res,solve(v)+1 );
        }

        return res;
}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



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


    int ans=0;
    mem(dp,-1);
    for(int i=1;i<=n;i++){
        ans=max(ans,solve(i));
    }

    cout<<ans;






     return 0;

}


Measured memory_bytes: 7552
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
int p[200200], sz[200200];
int root(int x)
{
    if(p[x]==x) return x;
    return p[x] = root(p[x]);
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    ll sum = 0;
    cin >> n >> m;
    for(i=1;i<=n;i++) p[i] = i, sz[i]=1;
    for(i=1;i<=m;i++) {
        cin >> x >> y;
        int rootx = root(x);
        int rooty = root(y);
        if(rootx==rooty) continue;
        p[rootx]=rooty;
        sz[rooty]+=sz[rootx];
    }
    ans = 0;
    for(i=1;i<=n;i++) ans=max(ans,sz[i]);
    cout<<ans<<endl;
    return 0;
}


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



int main() {
    int a,b;
    cin >>a>>b;
    if(a>b) swap(a,b);

    if (b==1) {cout <<1 << endl;
    return 0;}
    if (a==1) {cout << b-2 << endl; 
    return 0;}
    
    ll ans = (ll)(a-2)*(b-2);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 508
def solve():
    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())
    p = (A1 - B1) * T1
    q = (A2 - B2) * T2
    if p < 0:
        p *= -1
        q *= -1

    if p + q > 0:
        print(0)
    elif p + q == 0:
        print('infinity')
    else:
        s = -p // (p + q)
        t = -p % (p + q)
        if t != 0:
            print(s*2+1)
        else:
            print(s*2)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064