akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [2**60 for i in range(110000)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])

Measured memory_bytes: 57440
import sys

N = int(input()); A = list(map(int,input().split()))

if N == 2:
    print(max(A))
    sys.exit()

dp = [0,max(A[:3]),A[0]+A[2]]
tmp1 = dp[:]
tmp2 = [0,max(A[:2]),0]
flag1 = False
flag2 = True if A[0] < A[2] and A[1] < A[2] else False
flag3 = False

for i in range(3,N):
    b = A[i]
    if i%2 == 0:
        dp[0] = max(tmp2[0],tmp1[0]+b)
        flag1 = True if tmp2[0] < tmp1[0]+b else False
        if flag3:
            dp[1] = max(tmp2[1],tmp1[1]+b)
            flag2 = True if tmp2[1] < tmp1[1]+b else False 
        else:
            dp[1] = max(tmp2[1],tmp2[0]+b,tmp1[1]+b)
            flag2 = True if tmp2[1] < tmp2[0]+b or tmp2[1] < tmp1[1]+b else False 
        dp[2] += A[i]
        tmp1 = dp[:]
    else:
        if flag1:
            dp[0] = max(tmp1[1],tmp2[0]+b)
            flag3 = True if tmp1[1] < tmp2[0]+b else False
        else:
            dp[0] = max(tmp1[1],tmp1[0]+b,tmp2[0]+b)
            flag3 = True if tmp1[1] < tmp1[0]+b or tmp1[1] < tmp2[0]+b else False
        if flag2:
            dp[1] = max(tmp1[2],tmp2[1]+b)
        else:
            dp[1] = max(tmp1[2],tmp1[1]+b,tmp2[1]+b)
        tmp2 = dp[:]
        
print (dp[1])

Measured memory_bytes: 33160
c11,c12,c13 = list(input())
c21,c22,c23 = list(input())
C = [c11,c12,c13,c21,c22,c23]
invC = [c23,c22,c21,c13,c12,c11]

flag = True
for c,ic in zip(C,invC):
    if c != ic:
        flag = False
        break

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<complex>
using namespace std;

char m[12][12];
int w[4][2]={{-1,0},{1,0},{0,-1},{0,1}};

void sol(int i,int j) {
    int ni,nj;
    m[i][j]='0';
    for(int k=0;k<4;++k) {
        ni=i+w[k][0];
        nj=j+w[k][1];
        if (ni>=0 && ni<=11 && nj>=0 && nj<=11 ) {
            if(m[ni][nj]=='1') sol(ni,nj);
        }
    }
    return;
}


int main(){
    int ans;
    while (scanf("%s",m[0])!=EOF){
        ans=0;
        for (int i=1;i<12;++i) {
            scanf("%s",m[i]);
        }

        for (int i=0;i<12;++i) {
            for (int j=0;j<12;++j) {
                if (m[i][j]=='1') {
                    sol(i,j);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int cons[3], sz[3], tmp, tt, n;
vector<pair<int, int>> v;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> cons[0] >> cons[1] >> sz[0] >> sz[1] >> sz[2];
    n = sz[0] + sz[1] + sz[2];
    cons[2] = 2e5;
    for (int i = 0; i < 3; ++i) {
    	for (int j = 0; j < sz[i]; ++j) {
    		cin >> tmp;
    		v.pb({tmp, i});
    	}
    }
    ll ans = 0;
    sort(all(v));
    int tmx = cons[0] + cons[1];
    for (int i = n-1; i >= 0 && tt < tmx; --i) {
    	if (cons[v[i].second]) {
    		cons[v[i].second]--;
    		ans += v[i].first;
    		tt++;
    	}
    }
    cout << ans;
    cout << endl;

    return 0;
}

Measured memory_bytes: 6128
#include <iostream>

using namespace std;

int a[5];
int res;

void enter()
{

    for (int i = 0 ; i < 5 ; i ++) cin >> a[i];

}

int bound(int x)
{
    if (x % 10 == 0) return x;
    else
    return (x - x%10 + 10);

}

void process()

{

    int tmp_mod = 10;
    int pos = -1;

    for (int i = 0 ; i < 5 ; i ++)
    {
        if ( (a[i]%10) < tmp_mod && (a[i]%10) != 0 )
        {
            tmp_mod = a[i] % 10;
            pos = i;
        }
    }

    //cout << tmp_mod << " " << pos << endl;

    for (int i = 0 ; i < 5 ; i ++)
    {

        if (i != pos)
        {
            res += bound(a[i]);
        }
        else res += a[i];

    }

    cout << res;

}

int main()
{

    enter();
    process();
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin>>d[i];

    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=d[i]*d[j];
        }
    }

cout<<sum;

    return 0;
}


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

int main()
{
	int n; std::cin >> n;
	
	int* A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int k;
		std::cin >> k;
		int* lb = std::lower_bound(A, A+n, k);
		int* ub = std::upper_bound(A, A+n, k);
		std::cout << lb - A << " " << ub - A << std::endl;
	}
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 3104
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)
	kindsCount := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		kindsCount[i] = sameCharCount(s[:i+1], s[i+1:])
	}
	fmt.Println(max(kindsCount))
}

func sameCharCount(str1 string, str2 string) int {
	m1 := map[string]bool{}
	m2 := map[string]bool{}
	for _, c := range strings.Split(str1, "") {
		m1[c] = true
	}
	for _, c := range strings.Split(str2, "") {
		m2[c] = true
	}
	var count int
	for _, c := range strings.Split("abcdefghijklmnopqrstuvwxyz", "") {
		if m1[c] && m2[c] {
			count++
		}
	}
	return count
}

func max(a []int) int {
	max := a[0]
	for _, i := range a {
		if i > max {
			max = i
		}
	}
	return max
}


Measured memory_bytes: 1152
# 全探索する
# 範囲はなんかよくわからんけどaiの取り得る範囲らしい。なんかよくわからんけど

n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
if arr.uniq.size == 1
  puts 0
  exit
end
ans = 100000000000000000000000
(-100).upto(100).each do |i|
  cost = 0
  arr.each do |j|
    cost += (j-i)**2
  end
  ans = [ans, cost].min
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  if(A+B<10) {
cout<<A+B<<endl;
  }
  else {
cout<<"error"<<endl;
  }
}


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

const int N = 100000 + 5;
int n, a[N];
int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) scanf ("%d", &a[i]);
	long long sum = 0, need1 = 0, need2 = 0;
	for (int i = 1; i <= n; ++i) {
		sum += a[i];
		if (i & 1) {
			if (sum >= 0) need1 += sum + 1, sum = -1;
		} else {
			if (sum <= 0) need1 += 1 - sum, sum = 1;
		}
	}
	sum = 0;
	for (int i = 1; i <= n; ++i) {
		sum += a[i];
		if (i & 1) {
			if (sum <= 0) need2 += 1 - sum, sum = 1;
		} else {
			if (sum >= 0) need2 += sum + 1, sum = -1;
		}
	}
	cout << min(need1, need2) << '\n';
	return 0; 
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353 ;
ll add(ll a,ll b){
    ll t=(a+b);
    if(t>=p)t-=p;
        return t;
}
ll sub(ll a,ll b){
    ll t=a-b+p;
    t=t%p;
    return t;
}
ll power(ll a,ll x){
    if(x<0)return 1;
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;r%=p;
        }
        a=a*a;a%=p;
        x=x/2;
    }
    return r;
}
ll mul(ll a,ll b){
    ll t=(a*b);
    if(t>=p)t%=p;
    return t;
}
map<int,int> m;
int rec(int i){
    if(i==1)return 0;
    if(m.find(i)!=m.end())return m[i];
    int x;
    if(i%2==0){
        x=1+rec(i/2);
    }
    else{
        x=1+rec(3*i+1);
    }
    m[i]=x;
    return x;
}
int getKth(int lo, int hi, int k) {
    int arr[1001];
    memset(arr,-1,sizeof(arr));
    pair<int,int> b[hi-lo+1];
    for(int i=1;i<=1000;i++){
        if(arr[i]==-1){
            rec(i);
        }
        arr[i]=m[i];
    }
    for(int i=lo;i<=hi;i++){
        b[i-lo].first=arr[i];
        b[i-lo].second=i;
    }
    sort(b,b+hi-lo+1);
    return b[k-1].second;
}
int main() {
 
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        string s;cin>>s;
        string ans="No";
        if(s[2]==s[3]&&s[4]==s[5]){
            ans="Yes";
        }
        cout<<ans;
    }   
    return 0;   
}   

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> edge_num(N, 0);
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) {
            swap(a, b);
        }

        if (a == 0) {
            edge_num[b]++;
        } else {
            edge_num[a]++;
            edge_num[b]++;
        }
    }

    for (ll i = 1; i < N; i++) {
        if (edge_num[i] % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

int main() {
  //変数の設定
  int N, A, B;
  cin >> N >> A >> B;
  
  //桁の和を入れる配列を作る
  vector<int> number(N);
  
  //Nまでの変数の桁の和を配列に代入。10^4までだから上限つけていいかしらん
  for (int i = 1; i <= N; i++) {
    int number5 = i / 10000;
    int rest = i % 10000;
    int number4 = rest / 1000;
    rest = rest % 1000;
    int number3 = rest / 100;
    rest = rest % 100;
    int number2 = rest / 10;
    int number1 = rest % 10;
    number.at(i-1) = number1 + number2 + number3 + number4 + number5;
  }
  
  //桁の和のゾーンに入ってるかどうかをチェック
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (number.at(i) >= A && number.at(i) <= B) {
      count += (i + 1);
    }
  }
  
  cout << count << endl;
    
  
  
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int last[26];
int needs[26];

int main() {
	string s;
	cin >> s;

	for (int i=0; i<s.size(); i++) {
		needs[s[i]-'a'] = max(needs[s[i]-'a'],i-last[s[i]-'a']);
		last[s[i]-'a'] = i+1;
	}

	for (int i=0; i<26; i++) {
		needs[i] = max(needs[i],int(s.size())-last[i]);
	}

	int mn = s.size();
	for (int i=0; i<26; i++) {
		mn = min(mn,needs[i]);
	}

	cout << mn << "\n";
}


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

using namespace std;

const int INF=1999999999;

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

	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];

	int dp[n];
	for(int i=0;i<n;i++) dp[i] = INF;
	int tmp;
	int ans=0;

	for(int i=0;i<n;i++){
		*lower_bound(dp,dp+n,a[i]) = a[i];
	}

//	for(int j=0;j<n;j++){
//		for(int i=0;i<n;i++){
//			cout << dp[i][j] << " ";
//		}
//		cout << "\n";
//	}
//	for(int i=n-1;i>=0;i--){
//		cout << "i = " << i << "\n";
//		if(dp[n-1][i] != INF){
//			cout << i+1 <<"\n";
//			break;
//		}
//	}
	cout << lower_bound(dp,dp+n,INF)-dp << "\n";

//	for(int i=0;i<n;i++) cout << dp[i] << " ";
//	cout << "\n";

	return 0;
}


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

int search(int);

int n,S[100000];

int main(){
  
  int q,T[50000],counter=0;
  
  cin >>n;
  for(int i=0 ; i < n ; i++)cin >>S[i];
  
  cin >>q;
  for(int i=0 ; i < q ; i++)cin >>T[i];
  
  sort(S,S+n);
  
  for(int i=0 ; i < q ; i++)counter+=search(T[i]);
  
  cout <<counter<<endl;
  
  return 0;
}

int search(int t){
  
  int left=0;
  int right=n;
  
  while(left < right){
    int mid=(left+right)/2;
    if(S[mid] == t){
      return 1;
    }else if(t < S[mid]){
      right = mid;
    }else{
      left = mid+1;
    }
  }    
  
  return 0;
  
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
int num[100010];
int main(){
	int a,b,c;
	int count=0;
	scanf("%d %d %d",&a,&b,&c);
	while(a%2==0&&b%2==0&&c%2==0){
	    if(a==b&&b==c){
	    	cout<<"-1"<<endl;
	    	return 0;
		}
		int a1,b1,c1;
		a1=a;b1=b;c1=c;
		a=(c1+b1)/2;
		b=(a1+c1)/2;
	    c=(a1+b1)/2;
	    count++;
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;




int main(){
    ll N;
    cin >> N;
    ll D;
    cin >> D;
    if(N%(2*D+1)==0)
    cout<<N/(2*D+1)<<endl;

    else  cout<<N/(2*D+1)+1<<endl;


return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main()
{
  int n,m;
  for(;cin>>n>>m,n;)
    {
      int h[n+1];
      map<int,int>hash;

      for (int i=0; i< n; i++) {
        cin>>h[i];

        if(i!=0)
          {
            h[i]+=h[i-1];
            hash[h[i]]++;
            //  cerr<<"{SS}"<<hash[h[i]]<<" "<<h[i]<<endl;
            for (int ii=i-1; ii>=0; ii--) {
              {
                hash[h[i]-h[ii]]++;
                //        cerr<<"{N}"<<hash[h[i]-h[ii]]<<" "<<h[i]-h[ii]<<endl;
              }

            }
          }
        else
          {
            hash[h[i]]++;
            //      cerr<<"{S}"<<hash[h[i]]<<" "<<h[i]<<endl;
          }

      }
      int ans=0;
      int w[m+1];


      for (int i=0; i< m; i++) {
        cin>>w[i];

        if(i!=0)
          {
            w[i]+=w[i-1];
            ans+=hash[w[i]];
            for (int ii=i-1; ii>=0; ii--) {
              ans+=hash[w[i]-w[ii]];
            }
          }
        else
          {
            ans+=hash[w[i]];
          }

      }
      cout<<ans<<endl;

    }

  return 0;
}

Measured memory_bytes: 19044
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    double hAngel = 360/12 * h + (double)30/60 * m;
    double hradian = hAngel * M_PI / 180.0;
    pair<double, double> hxy;
    hxy.first = a*sin(hradian);
    hxy.second = a*cos(hradian);

    double mAngel = 360/60 * m;
    double mradian = mAngel * M_PI / 180.0;
    pair<double, double> mxy;
    mxy.first = b*sin(mradian);
    mxy.second = b*cos(mradian);

    //cout << hAngel << " " << hxy.first << " " << hxy.second  << endl;
    //cout << mAngel << " " << mxy.first << " " << mxy.second  << endl;

    double dx = mxy.first - hxy.first;
    double dy = mxy.second - hxy.second;
    double distance = sqrt(dx*dx + dy*dy);
    cout << fixed;
    cout << setprecision(10) << distance << endl;
}

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

int main() {
    string s;cin>>s;
    ll K;cin>>K;
    int N = s.size();
    //'a'との距離
    vector<int> v(N,0);
    rep(i,N){
        v[i] = 'z'-s[i]+1;
        if(s[i] == 'a')v[i] = 0;
    }
    rep(i,N){
        if(v[i]<=K){
            K-=v[i];
            v[i] = 0;
        }
    }
    K%=26;
    bool flag = true;
    for (int i = N-1; i >= 0; --i){
        if(v[i]>0){
            v[i] -=K;
            flag = false;
            break;
        }
    }
    //全部'a'になっているということ
    if(flag){
        v[N-1] +=26-K;
    }
    string T = "";
    rep(i,N){
        if(v[i] == 0){
            T.push_back('a');
        }
        else{
            T.push_back(char('z'-v[i]+1));
        }
    }
    cout<<T<<endl;
}

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

struct Edge { int from, to, cost; };
const int INF = 1 << 17;
const int V = 1001;
const int E = 2001;
int d[V];
Edge edge[E];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int v, e, r;
	cin >> v >> e >> r;
	
	int a, b, c;
	for(int i = 0; i < e; ++i){
		cin >> a >> b >> c;
		edge[i] = Edge{ a, b, c };
	}
	
	fill(d, d + v, INF);
	d[r] = 0;
	
	int cnt = 0;
	while(true){
		bool update = false;
		for(int i = 0; i < e; ++i){
			Edge e1 = edge[i];
			if(d[e1.from] != INF && d[e1.to] > d[e1.from] + e1.cost){
				d[e1.to] = d[e1.from] + e1.cost;
				update = true;
			}
		}
		cnt ++;
		if(!update)
			break;
		if(cnt == v - 1){
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	
	for(int i = 0; i < v; ++i){
		if(d[i] == INF)
			cout << "INF";
		else
			cout << d[i];
		cout << endl;
	}
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

#define MAX 100010
int V,E,sp,ep;
vector<int> G[MAX];
int mini[MAX][3];

struct Data {
  int cur, mod;
};

void solve() {
  rep(i,V) rep(j,3) mini[i][j] = INT_MAX;
  deque<Data> deq;
  deq.pb((Data){sp,0});
  mini[sp][0] = 0;
  while(!deq.empty()) {
    Data d = deq.front(); deq.pop_front();

    int nmod = ( d.mod+1 ) % 3;
    rep(i,(int)G[d.cur].size()) {
      int nex = G[d.cur][i];
      if( mini[nex][nmod] > mini[d.cur][d.mod] + 1 ) {
	mini[nex][nmod] = mini[d.cur][d.mod] + 1;
	deq.pb((Data){nex,nmod});
      }
    }
  }
  if( mini[ep][0] == INT_MAX ) puts("-1");
  else cout << (int)(mini[ep][0]/3) << endl;
}

int main() {
  cin >> V >> E;
  int u,v;
  rep(i,E) {
    cin >> u >> v;
    --u, --v;
    G[u].pb(v);
  }
  cin >> sp >> ep;
  --sp, --ep;
  solve();
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
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 long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};

int main() {
    int n=1000000;
    vector<int> dp(n),dp_odd(n);
    vector<int> table;
    rep(i,n) dp[i] = dp_odd[i] =  10010010;
    for(int i=1;i<=200;i++){
	int tmp = i*(i+1)*(i+2)/6;
	if(tmp>=n)break;
	dp[tmp] = 1;

	table.push_back(tmp);
	if(tmp%2==1) dp_odd[tmp]=1;
    }
	for(int j=0;j<n;j++){
	    for(int k=0;k<table.size();k++){
		if(j>table[k])chmin(dp[j],dp[j-table[k]]+1);
		if(j>table[k] && table[k]%2==1)chmin(dp_odd[j],dp_odd[j-table[k]]+1);
	    } 
	}
    while(1){
	int m;cin >> m;
	if(m==0) return 0;
	cout << dp[m] << " " << dp_odd[m]<< endl;;
    }
    return 0;
}



Measured memory_bytes: 10500
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    if a < c && c < b {
        return "Yes".to_string();
    }

    if b < c && c < a {
        return "Yes".to_string();
    }

    return "No".to_string();
}


Measured memory_bytes: 2108
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, m; cin >> n >> m;
    vi c(m); REP(i, m) cin >> c[i];

    vll dp(n + 1, INF);
    dp[0] = 0;

    REP(i, m) {
        REP(j, n) {
            if (j + c[i] <= n) dp[j + c[i]] = min(dp[j] + 1, dp[j + c[i]]);
        }
    }

    print(dp[n]);

}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	int odd = abs(n % 2 - 1);
	bool is_input_ok = true;
	map<ll, int> _map;
	vecll a(n);
	rep(i, n)
	{
		ll tmp;
		cin >> tmp;
		_map[tmp]++;
		if (tmp % 2 != odd)
			is_input_ok = false;
	}
	if (n % 2)
	{
		if (_map[0] != 1)
			is_input_ok = false;
		for (size_t i = 2; i < n; i += 2)
			if (_map[i] != 2)
				is_input_ok = false;
	}
	else
	{
		for (size_t i = 1; i < n; i += 2)
			if (_map[i] != 2)
				is_input_ok = false;
	}
	if (is_input_ok)
	{
		cout << repeat_squaring(2, n / 2, mod) << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 8968
N,K = map(int,input().split())
Data = [0]*N
for k in range(K):
    _ = input()
    user = list(map(int,input().split()))
    for u in user:
        Data[u-1] += 1
ans = 0
for i in range(N):
    if Data[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9188
#include<iostream>
using namespace std;
const int MAX_N=10000000, INF=1<<30;
int h, w, n;
int ma[1001][1001];
int dp[1001][1001];
void solve(int i, int j){
  if(i>h||j>w){
    cout<<i<<' '<<j<<endl;
    return;
  }
    if(ma[i][j])
      solve(i,j+1);
    else
      solve(i+1,j);
}
int main(){
  while(cin>>h>>w>>n&&h){
    for(int i=0;i<1001;i++){
      fill(ma[i],ma[i]+1001,0);
      fill(dp[i],dp[i]+1001,0);
    }
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	cin>>ma[i][j];
      }
    }
    ma[1][0]=INF;
    dp[1][1]=n-1;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	if(i==1&&j==1) continue;
	dp[i][j]+=dp[i][j-1]/2+dp[i-1][j]/2;
	if(ma[i][j-1]&&dp[i][j-1]%2==1)
	  dp[i][j]++;
	if(ma[i-1][j]==0&&dp[i-1][j]%2==1)
	  dp[i][j]++;
      }
    }
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	if(dp[i][j]%2==1){
	  if(ma[i][j]==1)
	    ma[i][j]=0;
	  else
	    ma[i][j]=1;
	}
      }
    }
    solve(1,1);
  }
}

Measured memory_bytes: 8988
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<bool> v1(N, false);
    vector<bool> v2(N, false);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a == 0) v1[b] = true;
        if(b == N-1) v2[a] = true;
    }

    for(int i=0; i<N; i++){
        if(v1[i] && v2[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#[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")
    };
}


fn decide_group(val: usize) -> usize {
    match val {
        2 => 1,
        4| 6| 9| 11 => 2,
        _ => 3
    }
}

fn main() {
    input! {
        x: usize,
        y: usize,
    }
    let xg = decide_group(x);
    let yg = decide_group(y);
    if xg == yg {
        println!("Yes");
    } else {
        println!("No");
    }
} 


Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(mut xs: Vec<u32>) -> Vec<u32> {
    let xs2 = xs.clone();
    xs.sort();

    let m1 = xs[(xs.len()-1)/2];
    let m2 = xs[xs.len()/2];

    xs2.iter().map(|x| if *x <= m1 {m2} else {m1}).collect()
}

fn main() {
    read_line!();

    let xs = parse_vec!(u32);
    for a in solve(xs) {
        println!("{}", a);
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![2,4,4,3]), vec![4,3,3,4]);
    assert_eq!(solve(vec![1,2]), vec![2,1]);
    assert_eq!(solve(vec![5,5,4,4,3,3]), vec![4,4,4,4,4,4]);
}


Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n;
  n = s.size();
  int b = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){//奇数文字
      if(s.at(i) == 'L')
        b = 1;
    }
    else{
      if(s.at(i) == 'R')
        b = 1;
    }
  }
  if(b == 1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


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

    string s;
    cin>>s;
    if(s.back() == 's')
    {
        s+='e';
        s+='s';
    }
    else 
    {
        s+='s';
    }
    cout<<s<<endl;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int p[500*500];
int s[500*500];
int ans[500][500];
int vis[500][500];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	rep(i,n*n) cin>>s[i],s[i]--;
	int fns=0;
	rep(i,n) rep(j,n) ans[i][j]=min({i,j,n-1-i,n-1-j}),vis[i][j]=1;
	rep(i,n*n){
		int x = s[i]/n,y=s[i]%n;
		fns+=ans[x][y];
		vis[x][y]=0;
		queue<int> q;
		q.push(s[i]);
		while(!q.empty()){
			int z = q.front();
			q.pop();
			int x = z/n,y=z%n;
			if(x&&ans[x-1][y]>ans[x][y]+vis[x][y]) ans[x-1][y]=ans[x][y]+vis[x][y],q.push((x-1)*n+y);
			if(y&&ans[x][y-1]>ans[x][y]+vis[x][y]) ans[x][y-1]=ans[x][y]+vis[x][y],q.push((x)*n+y-1);
			if(x+1<n&&ans[x+1][y]>ans[x][y]+vis[x][y]) ans[x+1][y]=ans[x][y]+vis[x][y],q.push((x+1)*n+y);
			if(y+1<n&&ans[x][y+1]>ans[x][y]+vis[x][y]) ans[x][y+1]=ans[x][y]+vis[x][y],q.push((x)*n+y+1);
		}
	}
	cout<<fns;
	return 0;
}



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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x - r < 0 || x + r > W) {
        cout << "No" << endl;
        return 0;
    }
    if (y - r < 0 || y + r > H) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}



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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, K, Q, A[MAX];

int main(){
    cin >> N >> K >> Q;
    rep(i, Q) cin >> A[i];

    rep(i, Q) A[i]--;

    map<int, int> m;
    rep(i, Q){
        m[ A[i] ]++;
    }

    vector<int> ans(N, K);
    rep(i, N){
        ans[i] -= Q - m[i];
    }

    rep(i, N){
        if (ans[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 7936
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String[] firstLine = sc.nextLine().split("");
        String[] secondLine = sc.nextLine().split("");
        String[] thirdLine = sc.nextLine().split("");
        
        System.out.println(firstLine[0]+secondLine[1]+thirdLine[2]);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#define MAX_N 55
using namespace std;
typedef long long ll;

bool is_checked[MAX_N];
ll checked_burger[MAX_N], burger_len[MAX_N];
ll X;

ll dfs(int level) {
    if (level == 0) {
        burger_len[level] = 1LL;
        return checked_burger[level] = 1LL;
    }
    else {
        if (is_checked[level]) return checked_burger[level]; 
        else {
            is_checked[level] = true;
            checked_burger[level] = dfs(level - 1) * 2LL + 1LL;
            burger_len[level] = burger_len[level - 1] * 2LL + 3LL;
            return checked_burger[level];
        }
    }
}

ll ddfs(int level, ll length) {
    // levelハンバーガーの1層目からlength層目のパティを数える
    if (level == 0) return 1LL;
    if (length == 1) return 0LL;
    ll sub_len = burger_len[level - 1];
    if (length <= 1LL + sub_len) return ddfs(level - 1, length - 1);
    else if (length == 2LL + sub_len) return checked_burger[level - 1] + 1LL;
    else if (length <= 2LL + sub_len * 2LL) return checked_burger[level - 1] + 1LL + ddfs(level - 1, length - 2LL - burger_len[level - 1]);
    else return checked_burger[level];
}

int main() {
    int N;
    cin >> N >> X;
    ll hoge = dfs(N);
    cout << ddfs(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,loopnum=0,num,next,mg[1000];
    long long int spl[1000],ans;
    cin>>n>>k;
    int p[n],c[n],group[n];
    for(int i=0;i<n;i++)cin>>p[i];
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<n;i++)group[i]=-1;
    for(int i=0;i<n;i++){
        if(group[i]==-1){
            group[i]=loopnum;
            spl[loopnum]=0;
            mg[loopnum]=1;
            next=i;
            while(1){
                next=p[next]-1;
                spl[loopnum]+=c[next];
                if(group[next]==-1){
                    mg[loopnum]++;
                    group[next]=loopnum;
                }
                else break;
            }
            loopnum++;
        }
    }
    long long int maxinloop[loopnum];
    for(int i=0;i<loopnum;i++){
        long long int maxl=LONG_LONG_MIN,maxs=LONG_LONG_MIN,count=0;
        for(int j=0;j<mg[i];j++){
            count=0;
            next=-1;
            for(int l=0;l<=j;l++){
                while(1){
                    next++;
                    if(group[next]==i)break;
                }
            }
            for(int l=0;l<mg[i]-1;l++){
                next=p[next]-1;
                count+=c[next];
                if(l<k%mg[i]){if(maxl<count)maxl=count;}
                else if(maxs<count)maxs=count;
            }
        }
        if(mg[i]>k)maxinloop[i]=maxl;
        else if(spl[i]<=0)maxinloop[i]=max(maxl,maxs);
        else{
            long long int a=k/mg[i];
            maxinloop[i]=max(max(spl[i]*a+maxl,spl[i]*a),spl[i]*(a-1)+maxs);
        }
    }
    ans=maxinloop[0];
    for(int i=1;i<loopnum;i++){
        if(ans<maxinloop[i])ans=maxinloop[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef __int128 _int ;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,k;
int h[maxn];
vector<int >adj[maxn];
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)  cin>>h[i];
	for(int i=1;i<=k;i++){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int flag=1;
		for(int j=0;j<adj[i].size();j++){
			int v=adj[i][j];
			if(h[i]<=h[v])  flag=0;
		}
		if(flag)  ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 11460
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n;
int a[MAX_N];
ll cnt[MAX_N + 1];

int main() {
    fastio();

    cin >> n;
    forn(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll temp = 0;
    forn1(i, n) {
        temp += cnt[i] * (cnt[i] - 1) / 2;
    }

    forn(i, n) {
        ll ans = temp;
        ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;

        if (cnt[a[i]] > 1) {
            ans += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        }

        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout << "Yes";
    }
    else cout << "No";
    
}

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


n = int(input())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    _from, to, dist = map(int, input().split())
    edges[_from-1].append([to-1, dist])
    edges[to-1].append([_from-1, dist])

q, k = map(int, input().split())
k -= 1

distance_from_k_to = [10**7] * n
distance_from_k_to[k] = 0

todo = []
while edges[k]:
    to, dist = edges[k].pop()
    todo.append([to, dist])

while todo:
    node, dist = todo.pop()
    if distance_from_k_to[node] != 10**7:  # if node has been seen
        continue

    distance_from_k_to[node] = dist
    while edges[node]:
        to, add_dist = edges[node].pop()
        todo.append([to, dist+add_dist])

for _ in range(q):
    start, goal = map(int, input().split())
    start, goal = start-1, goal-1
    ans = distance_from_k_to[start] + distance_from_k_to[goal]
    print(ans)


Measured memory_bytes: 90928
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.ring3", "r", stdin );
	string s = "";
	cin >> s;
	int n;
	cin >> n;
	vector <string> ring (n );
	for (int i = 0; i < n; ++i ){
		cin >> ring[i];
	} // end for

	vector <bool> found (n, false );
	for (int i = 0; i < n; ++i ){
		if (ring[i].find(s) != string::npos ){
			found[i] = true;
		} // end if
	} // end for

	for (int i = 0;i < n; ++i ){
		ring[i] += ring[i];
	} // end for

	for (int i = 0; i < n; ++i ){
		if (!found[i] && ring[i].find(s) != string::npos ){
			found[i] = true;
		} // end if
	} // end for	

	int res = (int)count (found.begin(), found.end(), true );
	cout << res << endl;	
		
	return 0;
}

Measured memory_bytes: 0
<?php
  fscanf(STDIN,"%d%d", $n, $k);
  if($n == $k){
      echo "1";
      exit;
  }
  
  $a = explode(" ", trim(fgets(STDIN)));
  asort($a);
  $one = key($a);
  $left = $one;
  $right = $n-($one+1);
  
  $k--;
  echo ceil(($left+$right)/$k);

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

int n, m, s, t;
vector<int> g[100000];
int d1[100000], d2[100000];
int c1[100010], c2[100010];

void bfs(int dist[], int s)
{
	queue<int> q;
	fill_n(dist, 100000, -1);
	dist[s] = 0;
	q.push(s);
	while (q.size()){
		int v = q.front(); q.pop();
		for (int to : g[v]){
			if (dist[to] >= 0) continue;
			dist[to] = dist[v] + 1;
			q.push(to);
		}
	}
}

int main()
{
	cin >> n >> m >> s >> t, s--, t--;
	for (int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y, x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	bfs(d1, s);
	bfs(d2, t);

	for (int i = 0; i < n; i++){
		if (d1[i] >= 0) c1[d1[i]]++;
		if (d2[i] >= 0) c2[d2[i]]++;
	}

	long long res = 0;
	for (int i = 0; i < d1[t] - 1; i++){
		res += (long long)c1[i] * c2[d1[t] - 2 - i];
	}

	cout << res << endl;
}

Measured memory_bytes: 10244
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >

#define readN(N,X) for(int i=0;i<N;i++) scanf("%d",&X[i]);
using namespace std;
ll K;
int N;
pii kagi[100005];
int main(){
	read(N);
	cin>>K;
	FOR(i,0,N){
		int a, b;
		read(a);
		read(b);
		kagi[i] = make_pair(a,b);
	}	
	sort(kagi, kagi + N);
	for (int i=0;i<N;i++){
		K -= kagi[i].second;
		if (K < 1){
			printf("%d\n", kagi[i].first);
			return 0;
		}
	}
}

Measured memory_bytes: 1024
n = gets.strip.chomp.to_i

cnt = 0
a=[]
b=[]
n.times do
  a << gets.strip.chomp.chars.sort!
end
a.map{|c| b << c.join("")}
c = {}
b.each do |s|
  if c[s].nil?
    c[s] = 0 
  else
    c[s] += 1
  end
  cnt += c[s]
end
puts cnt

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

#define A first
#define B second

const int MAXN = 2e5+5;

int n, a[MAXN];

bool ok(int k) {
	set<pii> s;
	s.insert(pii(0, 0));
	for (int i = 0; i < n-1; ++i) {
		if (a[i+1] > a[i]) {
			s.insert(pii(a[i], 0));
			continue;
		}
		while (true) {
			pii t = (*s.rbegin());
			if (t.A >= a[i+1])
				s.erase(t);
			else
				break;
		}
		int p = a[i+1] - 1;
		while (true) {
			pii t = (*s.rbegin());
			if (t.B != k-1) {
				s.erase(t);
				s.insert(pii(p, t.B+1));
				if (t.A != p)
					s.insert(pii(t.A, t.B));
				if (p != a[i+1] - 1)
					s.insert(pii(p+1, 0));
				break;
			}
			if (t.A == 0)
				return 0;
			s.erase(t);
			p = t.A - 1;
		}
	}
	return 1;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	int lo = 1, hi = n;
	while (lo != hi) {
		int mid = (lo+hi)/2;
		if (ok(mid))
			hi = mid;
		else
			lo = mid+1;
	}
	cout << lo << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    string w;
    cin >> w;

    unordered_map<char, int> us;
    rep(i, w.size()) us[w[i]] = 0;
    rep(i, w.size()) us[w[i]]++;

        
    for(auto kv : us) {
        if (kv.second % 2 == 1){
            put("No");
            return 0;
        }
    } 
    put("Yes");
    return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;

  if(A%2==0 || B%2==0 || C%2==0){
    cout << 0 << endl;
  }else{
    ll ret1 = (ll)(A-A/2)*B*C - (ll)(A/2)*B*C;
    ll ret2 = (ll)(B-B/2)*A*C - (ll)(B/2)*A*C;
    ll ret3 = (ll)(C-C/2)*A*B - (ll)(C/2)*A*B;
    cout << min(ret1, min(ret2, ret3)) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3


def solv(n, a, b, c, d, e):
    limited = min(a, b, c, d, e)
    ans = 4 + (n + (limited-1)) // limited
    return ans


if __name__ == '__main__':

    n = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    ans = solv(n, a, b, c, d, e)

    print(ans)


Measured memory_bytes: 3060
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
k = int(input())
cnt = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for h in range(1, k + 1):
            cnt += gcd(i, j, h)
print(cnt)

Measured memory_bytes: 69660
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	m=m*2+1;
	cout <<(n+m-1)/m;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n';

int main()
{

    int n;
    cin>>n;
    int arr[n];
    int c=0;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i+=2) if(arr[i]%2==1) c++;
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3528