akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int x[100000], y[100000];
bool used[100000];


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

	int n;
	cin>>n;
	rep(i, n)cin >> x[i] >> y[i];
	set<pair<int,int>> xg,yg;
	set<pair<int, int>, greater<pair<int,int>>> xl, yl;

	rep(i, n){
		xg.emplace(x[i],i);
		yg.emplace(y[i], i);
		xl.emplace(x[i], i);
		yl.emplace(y[i], i);
	}

	long long ans=0;
	priority_queue<pair<int, int>, vector<pair<int,int>> ,greater<pair<int, int>>> pq;
	pq.emplace(0, 0);
	rep(i,n){
		auto p = pq.top();
		pq.pop();
		while (used[p.second]){
			p = pq.top();
			pq.pop();
		}
		used[p.second] = true;
		xg.erase(make_pair(x[p.second], p.second));
		yg.erase(make_pair(y[p.second], p.second));
		xl.erase(make_pair(x[p.second], p.second));
		yl.erase(make_pair(y[p.second], p.second));
		ans += p.first;

		auto it1 = xg.lower_bound(make_pair(x[p.second], 0));
		if (it1 != xg.end()){
			pq.emplace(min(abs(x[p.second] - x[it1->second]), abs(y[p.second] - y[it1->second])), it1->second);
		}
		auto it2 = yg.lower_bound(make_pair(y[p.second], 0));
		if (it2 != yg.end()){
			pq.emplace(min(abs(x[p.second] - x[it2->second]), abs(y[p.second] - y[it2->second])), it2->second);
		}
		auto it3 = xl.lower_bound(make_pair(x[p.second], INF));
		if (it3 != xl.end()){
			pq.emplace(min(abs(x[p.second] - x[it3->second]), abs(y[p.second] - y[it3->second])), it3->second);
		}
		auto it4 = yl.lower_bound(make_pair(y[p.second], INF));
		if (it4 != yl.end()){
			pq.emplace(min(abs(x[p.second] - x[it4->second]), abs(y[p.second] - y[it4->second])), it4->second);
		}

	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 23868
import java.util.Scanner;

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

        String t2 = t.substring(0, t.length() - 1);
        
        if (s.equals(t2)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35688
N=int(input())
s=[int(i) for i in input().split()]
ans=0
for C in range(1,N):
    fkC=0
    L=0;R=N-1
    if ((N-1)%C==0):
        while(L<R):
            fkC+=s[L]+s[R]
            ans=max(ans,fkC)
            L+=C
            R-=C
    else:
        while(L+C<N-1):
            fkC+=s[L]+s[R]
            ans=max(ans,fkC)
            L+=C
            R-=C
print(ans)

Measured memory_bytes: 14468
#ARC007-B
if False:
    N,M=map(int,input().split())
    case=[i for i in range(N+1)]
    for _ in range(M):
        now=int(input())
        i=case.index(now)
        case[i]=case[0]
        case[0]=now
        # print(case)
    for i in range(1,N+1):
        print(case[i])

#ABC004-C (0408)
if False:
    N=int(input())-1
    N=N%30
    ans=list(range(1,7))
    for i in range(N+1):
        ans[i%5],ans[i%5+1]=ans[i%5+1],ans[i%5]
        # print(ans)
    print(''.join(map(str,ans)))

#AGC011-A (0408)
if False:
    N,C,K=map(int,input().split())
    T=[int(input()) for _ in range(N)]
    T.sort()
    cnt=1
    pas=1 # 乗客数
    tim=K+T[0] # departure time
    # print(T)
    for i in range(1,N):
        t=T[i]
        if tim<t or pas>=C:
            cnt+=1
            tim=t+K
            pas=1
        else:
            pas+=1
        # print(tim,pas,cnt)
    print(cnt)

#ABC072-D (0408)
if True:
    N=int(input())
    P=[int(i) for i in input().split()]
    ans=0
    cnt=0
    for i in range(N-1):
        if P[i]==i+1:
            P[i],P[i+1]=P[i+1],P[i]
            cnt+=1
    if P[N-1]==N:
        P[N-1],P[N-2]=P[N-2],P[N-1]
        cnt+=1
    print(cnt)


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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] s = new int[n];
        int mindex = 0;
        for (int i = 0; i < n; i++) {
            s[i] = scanner.nextInt();

        }
        Arrays.sort(s);
        int sum = Arrays.stream(s).sum();
        int copy = sum;
        while (sum % 10  == 0){
            if (s[mindex] % 10 != 0){
                sum -= s[mindex];
            }
            mindex++;
            if (mindex == n && sum == copy){
                sum = 0;
                break;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 30804
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  char c = '0';
  int count = 0;
  char prev = '0';
  for (int i=0; i<N; i++){
    std::cin >> c;
    if(c!=prev){
      count++;
    }
    prev = c;
  }
  std::cout << count;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/



void Calc() {

  string s = in;
  char c = s[0];
  int ans = 0;
  for (auto& i : s) {
    if (i != c) {
      c = i;
      ans++;
    }
  }
  cout << (ans) << endl;
}


Measured memory_bytes: 512
import numpy as np

N, K = map(int, input().split())
p = list(map(int, input().split()))

last_value = 0
l = [0]

for head, tail in zip(p, p[K:]):
    now = tail - head + last_value
    l.append(now)
    last_value = now
max_index = np.argmax(l)
max_sum = sum(p[max_index : max_index + K])
print((K + max_sum) / 2)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x) cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    ll n, k, q, win;
    cin >> n >> k >> q;
    ll a[100005];
    m0(a);

    for(ll i = 0; i < q; i++) {
        cin >> win;
        a[win - 1]++;
    }

    for(ll i = 0; i < n; i++) {
        Yes(k - (q - a[i]) > 0);
    }

    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
using namespace std;
int main(){
        int N,t[100];
        cin >> N;
        int counter=0;
        for(int i=0 ; i<N ; i++ ){
                cin >> t[i];
                counter+=t[i];
        }
        int M,p,x;
        cin >> M;
        for(int i=0 ; i<M ; i++ ){
                cin >> p >> x;
                cout << counter+-t[p-1]+x << endl;
        }
        return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(map(int,input().split()))for i in range(h)]
p=True
q=[0,0]
d=[]
for i in range(h):
    if i%2==0:
        for j in range(w):
            if p:
                if s[i][j]%2==1:
                    q=[i,j]
                    p=False
            else:
                d.append([q[0]+1,q[1]+1,i+1,j+1])
                q=[i,j]
                if s[i][j]%2==1:
                    p=True
    else:
        for j in range(w-1,-1,-1):
            if p:
                if s[i][j]%2==1:
                    q=[i,j]
                    p=False
            else:
                d.append([q[0]+1,q[1]+1,i+1,j+1])
                q=[i,j]
                if s[i][j]%2==1:
                    p=True
print(len(d))
for i in d:
    print(i[0],i[1],i[2],i[3])

Measured memory_bytes: 30724
import math
N, M = map(int, input().split())

loop = 10000
ans = 0
tmp = 1
for l in range(1, loop):
    ans += tmp * l
    tmp *= (1 - 1 / 2 ** M)
ans *= ((N - M) * 100 + M * 1900)
ans /= (2 ** M)
ans = math.ceil(ans)
print(ans)


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<pair<unsigned long, unsigned long>>> k(N);
    for(auto& I : k){
        unsigned long a;
        cin >> a;
        for(unsigned long i{0}, x, y; i < a; ++i){
            cin >> x >> y;
            I.emplace_back(x - 1, y);
        }
    }
    unsigned long ans{0};
    for(unsigned long i{0}; i < 1UL << N; ++i)[&]{for(unsigned long j{0}; j < N; ++j)if(i >> j & 1)for(const auto& l : k[j])if((i >> l.first & 1) != l.second)return;ans = max<unsigned long>(ans, __builtin_popcount(i));}();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt() - (i + 1);
		}
		
		Arrays.sort(map);
		
		//平均値でやっていたのが問題だった、中央値を求める
		int val = map[N / 2];
		
		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(map[i] - val);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64672
#include <cstdio>
#include <complex>
#include <cmath>
using namespace std;

void koch_curve(int depth, const complex<double> &left, const complex<double> &right) {
	if(depth==0) {
		printf("%.8f %.8f\n",left.real(),left.imag());
		return;
	} else {
		complex<double> v1,v2,v3,rot={cos(M_PI/3),sin(M_PI/3)};
		v1=(2.0*left+right)/3.0;
		v3=(left+2.0*right)/3.0;
		v2=v1+(v3-v1)*rot;
		koch_curve(depth-1,left,v1);
		koch_curve(depth-1,v1,v2);
		koch_curve(depth-1,v2,v3);
		koch_curve(depth-1,v3,right);
	}
}

int main() {
	int n;
	scanf("%d",&n);
	complex<double> v1={0.0,0.0},v2={100.0,0.0};
	koch_curve(n,v1,v2);
	printf("%.8f %.8f\n",v2.real(), v2.imag());
	return 0;
}

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

int main(){
    int n,k ;
    cin >> n >> k ;
    vector<int> l(n) ;
    for(int i=0;i<n;i++) cin >> l.at(i) ;
    sort(l.begin(),l.end()) ;
    reverse(l.begin(),l.end()) ;
    int ans = 0 ;
    for(int i=0;i<k;i++) ans += l.at(i) ;
    cout << ans << endl ;
}






Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int N = in.nextInt(), K = in.nextInt();
	int[] V = new int[N];
	for (int i = 0; i < N; i++) {
	    V[i] = in.nextInt();
	}
	int tryMax = Math.min(N, K);
	int ans = 0;
	for (int a = 0; a <= tryMax; a++) {
	    for (int b = 0; b <= (tryMax - a); b++) {
		int[] arr = concat(
		    Arrays.copyOfRange(V, 0, a),
		    Arrays.copyOfRange(V, N - b, N));
		Arrays.sort(arr);
		int max = Math.min(arr.length, K - a - b);
		for(int k = 0; k < max; k++) {
		    if(arr[k] > 0) { break; }
		    arr[k] = 0;
		}
		ans = Math.max(ans, IntStream.of(arr).sum());
	    }
	}
	System.out.println(ans);
    }
    
    public static int[] concat(int[] arr1, int[] arr2) {
	int[] res = new int[arr1.length + arr2.length];
	for (int i = 0; i < arr1.length; i++) {
	    res[i] = arr1[i];
	}
	for (int i = 0; i < arr2.length; i++) {
	    res[arr1.length + i] = arr2[i];
	}
	return res;
    }
}


Measured memory_bytes: 26964
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


signed main() {
	FAST_IO;
	// int q;
	// cin >> q;
	// while (q--) {	
		int h1, m1, h2, m2, k;
		cin >> h1 >> m1 >> h2 >> m2 >> k;
		m1 += h1 * 60;
		m2 += h2 * 60;
		m2 -= k;
		cout << m2 - m1 << "\n";
	// }
 	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a*b==15?"*":a+b==15?"+":"x")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head


int main() {
	int n;
	string s;
	cin>>n>>s;
	map<int,int> f;
	for(auto c:s) ++f[c];
	ll ans=1;
	for(auto t:f) ans=ans*(t.y+1)%P;
	cout<<ans-1<<endl;
}


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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int mod=1e9+7;
    ll n,m;cin>>n>>m;
    vector<vector<ll>> v(n,vector<ll>(m,0)),dp(n,vector<ll>(m,0));
    f(i,0,n)f(j,0,m){
        char c;cin>>c;
        if(c=='.')v[i][j]=1;
    }
    f(i,0,m){
        if(v[0][i]==0)break;
        dp[0][i]=1;
    }
    f(i,0,n){
        if(v[i][0]==0)break;
        dp[i][0]=1;
    }
    f(i,1,n){
        f(j,1,m){
            if(v[i-1][j])(dp[i][j]+=dp[i-1][j])%=mod;
            if(v[i][j-1])(dp[i][j]+=dp[i][j-1])%=mod;
        }
    }
    cs(dp[n-1][m-1]);
    

  }


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

int main(){
  int N,mincount=1e9;
  cin >> N;
  for(int i=0;i<N;i++){
    int A,count=0;
    cin >> A;
    while(A%2==0){
      count++;
      A/=2;
    }
    mincount=min(mincount,count);
  }
  cout << mincount << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= n; i--)
#define all(c) c.begin(),c.end()
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e3 + 10; 
int main()
{   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  	ll n;cin>>n;
  	string s[n];
  	map <string,int> count_find;
  	int c=0;
  	f(i,0,n) cin>>s[i];
  	for(auto &s: s){
  		int count = ++count_find[s];
  		if(count==1)
  			++c;
  	}
  	cout<<c;
	return 0;
}

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

        int main() {        
          int H, W;
          cin >> H >> W;
          vector<vector<int>> A(H, vector<int>(W)); 
          for(int i=0; i<H; i++){
            string S; 
            cin>> S; 
            for(int j=0; j<W; j++){
              if(S.at(j)=='#') A.at(i).at(j)=1; 
              if(S.at(j)=='.') A.at(i).at(j)=0; 
            }
          }// inputのencoding終わり
          
          vector<vector<int>> L(H,vector<int>(W));  
          vector<vector<int>> R(H,vector<int>(W));
          vector<vector<int>> U(H,vector<int>(W));
          vector<vector<int>> D(H,vector<int>(W));
          
          for(int i=0; i<H; i++){
            int pointer = -1;
            for(int j=0; j<W; j++){
              if(A.at(i).at(j)==0) L.at(i).at(j)=pointer;
              if(A.at(i).at(j)==1) pointer = j;   
            }
          }
          
          for(int i=0; i<H; i++){
            int pointer = W;
            for(int j=W-1; j>=0; j--){
              if(A.at(i).at(j)==0) R.at(i).at(j)=pointer;
              if(A.at(i).at(j)==1) pointer = j;   
            }
          }
          
         for(int j=0; j<W; j++){
            int pointer = -1;
            for(int i=0; i<H; i++){
              if(A.at(i).at(j)==0) U.at(i).at(j)=pointer;
              if(A.at(i).at(j)==1) pointer = i;   
            }
          }
          
         for(int j=0; j<W; j++){
            int pointer = H;
            for(int i=H-1; i>=0; i--){
              if(A.at(i).at(j)==0) D.at(i).at(j)=pointer;
              if(A.at(i).at(j)==1) pointer = i;   
            }
          }
         
         int answer=0;  
          
         for(int i=0; i<H; i++){
            //cout<< endl; 
            for(int j=0; j<W; j++){
              if(A.at(i).at(j)==0){
                int l = L.at(i).at(j);
                int r = R.at(i).at(j);
                int u = U.at(i).at(j);
                int d = D.at(i).at(j);
                //cout<< r-l-1 + d-u-1 -1 ;
                answer = max( answer, r-l-1 + d-u-1 -1);
              }
              if(A.at(i).at(j)==1){
                //cout<<'#';
              }
            }
          }
        cout<< answer ;   
        }

Measured memory_bytes: 78720
n=int(input())
l=list(map(int,input().split()))
def sorted(l):
    last=0
    for i in l:
        if last>i:
            return False
        last=i
    return True
for i in range(n):
    for j in range(i,n):
        l[i],l[j]=l[j],l[i]
        if sorted(l):
            print("YES")
            quit()
        l[i],l[j]=l[j],l[i]
print("NO")

Measured memory_bytes: 3064
//
/*
By:Luckyblock
*/
#include <cstdio>
#include <ctype.h>
#include <algorithm>
#define ll long long
//=============================================================
//=============================================================
inline int read() {
	int f = 1, w = 0; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
	return f * w;
}
//=============================================================
int main() {
  printf("%d", read() * read());
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B, C; cin >> A >> B >> C;

    set<int> mod;
    int i = 1;
    bool ans = false;
    while (1) {
        int rest = (A*i)%B;
        if (rest == C) {
            ans = true;
            break;
        }
        if (mod.find(rest) == mod.end()) {
            mod.insert(rest);
        } else {
            break;
        }
	i++;
    }

    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x;i <= y; ++ i)
#define repd(i,x,y) for(register int i = x;i >= y; -- i)
using namespace std;
typedef long long ll;
template<typename T>inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = -1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}
 
const int N = 340;
int a[N][N],nxt[N][N],pos[N][N];
vector<int>v[N],g[N];
bool vis[N];
 
int n,m;
inline bool check(int x)
{
	rep(i,1,m) vis[i] = 0;
	rep(i,1,m) g[i].clear();
	rep(i,1,n) g[pos[i][1]].push_back(i);
	while(1)
	{
		bool e = 1;
		rep(i,1,m)
		{
			int sz = g[i].size();
			if(((int)g[i].size()) <= x) continue;
			vis[i] = 1; e = 0; -- sz;
			rep(j,0,sz)
			{
				int num = g[i][j],pos = i;
				while(vis[pos]) pos = nxt[num][pos];
				if(pos == 0) return false;
				g[pos].push_back(num);
			}
			g[i].clear();
		}
		if(e) break;
	}
	rep(i,1,m) if(!vis[i]) return true;
	return false;
}
 
int main()
{
	read(n); read(m);
	rep(i,1,n) 
	{
		rep(j,1,m)
		{
			read(pos[i][j]);
			a[i][pos[i][j]] = j;
		}
		rep(j,1,m)
			nxt[i][j] = pos[i][a[i][j] + 1];
	}
	int l = 1,r = n,ans = n,mid;
	while(l <= r)
	{
		if(check(mid = l + r >> 1)) r = mid - 1,ans = mid;
		else l = mid + 1;
	}
	/*
	puts("");
	rep(i,1,n)  rep(j,1,m) printf("%d%c",nxt[i][j],j==m?'\n':' ');
	rep(i,1,m) printf("%d ",((int)g[i].size()));puts("");
	*/
	cout << ans << endl;
	return 0;
}

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
first_idx = {}
for i in range(N)[::-1]:
    first_idx[A[i]] = i
next_idx = {}
dist = [[0] * N for _ in range(41)]
for i in range(N)[::-1]:
    if A[i] in next_idx:
        dist[0][i] = next_idx[A[i]] - i + 1
    else:
        dist[0][i] = N - i + first_idx[A[i]] + 1
    next_idx[A[i]] = i
for j in range(40):
    for i in range(N):
        dist[j+1][i] = dist[j][i] + dist[j][(i + dist[j][i]) % N]
s = []
i = 0
while i < N * K:
    for j in range(41)[::-1]:
        if i + dist[j][i % N] <= N * K:
            i += dist[j][i % N]
            break
    else:
        s.append(A[i % N])
        i += 1
print(*s)



Measured memory_bytes: 157564
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int N, K; cin >> N >> K;
    long long x[N];
    for (int i = 0; i < N; ++i) cin >> x[i];
    long long res = 1LL << 60;
    for (int i = 0; i + K -1 < N; ++i) {
        if (x[i+K-1] <= 0) res = min(res, abs(x[i]));
        else if(x[i] < 0 && 0 < x[i+K-1]) res = min(res, abs(x[i])+x[i+K-1]+min(abs(x[i]), x[i+K-1]));
        else res = min(res, x[i+K-1]);
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
K = int(input())
S = input()
N = len(S)

MOD = 10 ** 9 + 7

# 逆元を利用してcomb(nCk)をO(1)計算
# https://qiita.com/ophhdn/items/5622ac22cce8fc9432bf
n = N + K + 3
fac = [1] * (n + 1) 
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = (fac[j - 1] * j) % MOD

inv[n] = pow(fac[n], MOD-2, MOD)
for j in range(n - 1, -1, -1):
    inv[j] = (inv[j + 1] * (j + 1)) % MOD

def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return (fac[n] * inv[n - r] * inv[r]) % MOD

ans = 0
for i in range(K + 1):
  p = comb(N + K - i - 1, N - 1) * pow(26, i, MOD) * pow(25, K - i, MOD) % MOD
  ans += p
  ans %= MOD
  
print(ans)

Measured memory_bytes: 122888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; string S; cin >> K >> S;
    int s=S.size();
    if (s<=K) cout << S << '\n';
    else {
        for (int i=0;i<K;++i) cout << S[i];
        cout << "..." << '\n';
    }
}

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

using namespace std;

int main()
{
  int n, k;
  while(cin >> n >> k, n && k) {
    set<string> st;
    vector<string> card(n);
    for(string& s : card) cin >> s;
    sort(card.begin(), card.end());
    do {
      string t = "";
      for(int i = 0; i < k; i++) {
	t += card[i];
      }
      st.insert(t);      
    }while(next_permutation(card.begin(), card.end()));
    cout << st.size() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3264
import math
n,m=map(int,input().split())
def cc(n,r):
    return int(math.factorial(n)/(math.factorial(n-r)*math.factorial(r)))
if n>=2:
    if m>=2:
        print(cc(n,2)+cc(m,2))
    else:
        print(cc(n,2))
else:
    if m>=2:
        print(cc(m,2))
    else:
        print(0)

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

int main(){
  vector<int> a(5);
  rep(i,5){
    cin >> a.at(i);
  }
  if(a.at(0) == 0){
    cout << 1 << endl;
  }
  else if(a.at(1) == 0){
    cout << 2 << endl;
  }
  else if(a.at(2) == 0){
    cout << 3 << endl;
  }
  else if(a.at(3) == 0){
    cout << 4 << endl;
  }
  else if(a.at(4) == 0){
    cout << 5 << endl;
  }
    
}

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int x[N], y[N], a[N];
  int lx=0, ly=0, mx=W, my=H, s;
  
  for(int i=0; i<N; i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  
  for(int i=0; i<N; i++){
    if(a[i]==1){
      if(lx < x[i]) lx=x[i];
    }
    else if(a[i]==2){
      if(mx > x[i]) mx=x[i];
    }
    else if(a[i]==3){
      if(ly < y[i]) ly=y[i];
    }
    else{
      if(my > y[i]) my=y[i];
    }
  }
  
  s=(mx-lx) * (my-ly);
    
  if(mx>lx && my>ly)
    cout << s << endl;
  else
    cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S;
    cin >> S;
    if (S[S.size()-1]=='s') {
        cout << S + "es" << '\n';
    }else {
        cout << S + "s" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main() {

	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		int n;
		cin>>n;
		long double p[n+1];
		for(int i=1; i<=n; i++)
			cin>>p[i];

		long double dp[n+1];
		for(int i=1; i<=n; i++)
			dp[i] = 0.0;
		dp[0] = 1.0;
		//cout<<dp[0];
		for(int i=1; i<=n; i++) {
			for(int j=i; j>=0; j--) {
				if(j!=0)
					dp[j] = p[i]*dp[j-1] + (1-p[i])*dp[j];
				else dp[j] = (1-p[i])*dp[j];
				//cout<<dp[j]<<" ";
			}
			//cout<<dp[i]<<" ";
		}
		long double sum = 0.0;
		//cout<<dp[n];
		for(int i=(n/2)+1; i<=n; i++)
			sum += dp[i];

		cout<<setprecision(10)<<sum;
	}
	return 0;
}
// I K L M N

Measured memory_bytes: 512
n,x = map(int, input().split())
l = list(map(int, input().split()))
flag = 0
d = []
d.append(0)
for i in range(1,n+1):
    if d[i-1]+l[i-1] > x:
        break
    else:
        d.append(d[i-1]+l[i-1])
print(len(d))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  //入力
  int N,M;
  cin>>N>>M;
  vector<vector<int>> sich(M);
  vector<int> kakusyu;
  for(int i=0;i<M;i++){
    int k;
    cin>>k;
    kakusyu.push_back(k);
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      x--;
      sich[i].push_back(x);
    }
  }
  vector<int> denkyu(M);
  for(int i=0;i<M;i++)cin>>denkyu[i];


  //bit探索
  long long ans=0;
    for(int bit=0;bit<(1<<N);bit++){
      bool ok=true;
      for(int i=0;i<M;i++){
        int cnt=0;
        for(auto a:sich[i]){
          if(bit&(1<<a))cnt++;
        }
      if(cnt%2!=denkyu[i])ok=false;
    }
    if(ok)ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque


def main():
    N, X, Y = map(int, input().split())
    ans = [0] * N  # 距離ごとの合計 [d=0, d=1, d=2, d=3, d=4]の数
    X -= 1
    Y -= 1

    for start_vertex in range(N):
        dist = [float('inf')] * N
        q = deque()

        def push(vertex, distance):
            if dist[vertex] != float('inf'):
                return
            dist[vertex] = distance
            q.append(vertex)

        push(start_vertex, 0)  # 始点をpush

        while len(q) != 0:
            vertex = q.popleft()
            distance = dist[vertex]

            if vertex - 1 >= 0:
                push(vertex - 1, distance + 1)
            if vertex + 1 < N:
                push(vertex + 1, distance + 1)
            if vertex == X:
                push(Y, distance + 1)
            if vertex == Y:
                push(X, distance + 1)

        for i in range(N):
            ans[dist[i]] += 1

    for i in range(N):
        ans[i] //= 2

    for i in range(1, N):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 63452
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	string arr;
	cin>>n>>arr;
	ll ans=1e9;
	ll wh[n+1];
	wh[0]=0;
	for(ll i=1;i<=n;i++)
	if(arr[i-1]=='.')
	wh[i]=wh[i-1]+1;
	else
	wh[i]=wh[i-1];
	for(ll i=1;i<=n;i++)
	{
		ll val=(i-1-wh[i-1])+(wh[n]-wh[i]);//cout<<wh[i]<<endl;
		ans=min(ans,val);
	}
	cout<<ans;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using LL = long long;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long> VL;

int main() {
  int n; cin >> n;
  vector<int> A(n+1);
  rep(i, n) {
    cin >> A.at(i+1);
  }

  for(int i=1; i<n+1; i++) {
    cout << "node " << i << ": " << "key = " << A.at(i) << ", ";
    if (i !=1 ) {
      cout << "parent key = " << A.at(i/2) << ", ";
    }
    if (2*i <= n) {
      cout << "left key = " << A.at(i*2) << ", ";
    }
    if (2*i+1 <= n) {
      cout << "right key = " << A.at(i*2+1) << ", ";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;cin>>A>>B>>K;
  int i=A;
  for(;i<(A+K<=B? A+K:B); i++)cout<<i<<endl;
  if(i<B-K+1)i=B-K+1;
  for(;i<=B; i++){
    cout<<i<<endl;
  }
}

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

//atoi(t.c_str());
int keisan(string s){
  int i;
  int sum=s[0]-'0';
  for(i=1;i<6;i+=2){
    //t=s.at(i+1);
    if(s.at(i)=='+')sum+=s[i+1]-'0';
    else if(s.at(i)=='-')sum-=s[i+1]-'0';;
  }
  if(sum==7)return 1;
  else return 0;
}

void hantei(string s,int i,string &t){
  int flag=0;
  if(i<7){
    s=s.insert(i,"+");
    hantei(s,i+2,t);
    if(s.size()==7&&keisan(s)){t=s;return;}
    s=s.replace(i,1,"-");
    hantei(s,i+2,t);
    if(s.size()==7&&keisan(s)){t=s;return;}
  }
}

int main() {
  int sum=0;
  string s,t;
  cin >>s;
  hantei(s,1,t);
  cout << t <<"=7"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	Coordinate A, B, C, P, AB, BP, BC, CP, CA, AP;
	double x1, x2, x3, y1, y2, y3, xp, yp, c1, c2, c3;
	String[] input;
	while (scan.hasNext()) {
	    input = scan.nextLine().split(" ");
	    x1 = Double.parseDouble(input[0]);
	    y1 = Double.parseDouble(input[1]);
	    x2 = Double.parseDouble(input[2]);
	    y2 = Double.parseDouble(input[3]);
	    x3 = Double.parseDouble(input[4]);
	    y3 = Double.parseDouble(input[5]);
	    xp = Double.parseDouble(input[6]);
	    yp = Double.parseDouble(input[7]);
	    A = new Coordinate(x1, y1);
	    B = new Coordinate(x2, y2);
	    C = new Coordinate(x3, y3);
	    P = new Coordinate(xp, yp);
	    AB = sub(B, A);
	    BP = sub(P, B);
	    BC = sub(C, B);
	    CP = sub(P, C);
	    CA = sub(A, C);
	    AP = sub(P, A);
	    c1 = AB.x * BP.y - AB.y * BP.x;
	    c2 = BC.x * CP.y - BC.y * CP.x;
	    c3 = CA.x * AP.y - CA.y * AP.x;
	    if ((c1 < 0 && c2 < 0 && c3 < 0) || (c1 > 0 && c2 > 0 && c3 > 0)) {
		System.out.println("YES");
	    } else {
		System.out.println("NO");
	    }
	}
    }
    static Coordinate sub (Coordinate a, Coordinate b) {
	return new Coordinate(a.x - b.x, a.y - b.y);
    }
}
class Coordinate {
    double x;
    double y;
    Coordinate (double x, double y) {
	this.x = x;
	this.y = y;
    }
}

Measured memory_bytes: 26728
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_T _DEF(T,in,){return in<T>(gcu());}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

struct T {
	int w, l;
	char t;
	bool operator < (T a) const {
		return w == a.w ? l < a.l : w > a.w;
	}
};

int main() {
	for (int n; (n = in());) {
		vector<T> s(n);
		for (T &i: s) {
			i.t = gcu();
			gcu();
			for (int j {}, e {n - 1}; j < e; j++)
				switch (in()) {
				case 0:
					i.w++;
					break;
				case 1:
					i.l++;
				}
		}
		stable_sort(begin(s), end(s));
		for (T i: s)
			outl(i.t);
	}
}


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

int main()
{
    int n;
    scanf("%d", &n);
    vector<long long int>v(n);
    for (int i = 0; i < n; i++) scanf("%lld", &v[i]);
    sort(v.rbegin(), v.rend());
    long long int ans = 0;
    for (int i = 1; i < n; i++) ans += v[i/2];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4752
module Main where

import Numeric
import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let (q,r) = divMod a b
  ; let s = fromIntegral a / fromIntegral b
  ; putStrLn . unwords $ [show q, show r, showFFloat Nothing s ""]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 4036
using System;

namespace abc073A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            int Ans = 0;
            for(int i = 0; i < 2; i++)
            {
                string B = A.Substring(i, 1);
                if (B == "9")
                    Ans += 1;
            }
            if (Ans > 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
vector<int> adj[N];
bool vis[N],vis1[N];
void dfs(int child)
{
	vis1[child] = true;
	for(auto it:adj[child])
	{
		if(!vis1[it])
		dfs(it);
	}
}
int par[N];
void dfs1(int child,int pare)
{
	par[child] = pare;
	vis[child] = true;
	for(auto it:adj[child])
	{
		if(!vis[it])
		dfs1(it,child);
	}
}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,m;
		cin>>n>>m;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			adj[u].pb(v);
			adj[v].pb(u);
		}
		dfs(1);
		bool flag = true;
		for(int i=1;i<=n;++i)
		if(vis1[i]==0)
		flag = false;
		if(!flag)
		{
			cout<<"No";
			return 0;
		}
		cout<<"Yes\n";
		/*dfs1(1,-1);
		for(int i=2;i<=n;++i)
		cout<<par[i]<<"\n";  */
		queue<int> q;
		q.push(1);
		vis[1] = true;
		while(!q.empty())
		{
			int x = q.front();
			q.pop();
			for(auto it:adj[x])
			{
				if(!vis[it])
				{
					vis[it] = true;
					par[it] = x;
					q.push(it);
				}
			}
		}
		for(int i=2;i<=n;++i)
		cout<<par[i]<<"\n";  	
    }
    return 0;
}


Measured memory_bytes: 24600
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

ll pow2(ll x, int n){
	if(n == 0) return 1LL;
	ll ret = pow2(x * x, n / 2);
	if(n & 1) ret *= x;
	return ret;
}

ll gcd(ll a, ll b){
	return b == 0LL ? a : gcd(b, a % b);
}

int main(){
	while(1){
		string s;// = in.next();
		cin>>s;
		if(s == "#") break;
		
		vi v;
		int idx = 0;
		while(idx < s.size()){
			if(s[idx] == 'n'){
				v.pb(1);
				idx += 5;
			}
			else{
				v.pb(0);
				idx += 4;
			}
		}
		//reverse(all(v));
		
		ll a = pow2(2LL, v.size()-1) * (v.back()==1?0LL:90LL);
		ll b = pow2(2LL, v.size()-1);
			
		rep(i, v.size()-1){
			a += (v[i] == 1 ? -1 : 1) * 90 * pow2(2LL, i);
		}
		// cout<<v.size()<<" "<<pow2(2LL, v.size())<<endl;
		// cout<<a<<" / "<<b<<endl;
		
		ll k = gcd(a, b);
		a /= k;
		b /= k;
		
		printf("%lld", a);
		if(b != 1LL){
			printf("/%lld", b);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 100000000;
typedef pair<int, int> P;



int main() {
	string S;
	cin >> S;
	rep(i, S.size()) {
		for (int j = i+1; j < S.size(); j++)
		{
			if (S.at(i) == S.at(j)) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

int main() {
  int ans=0;
  int len=0;
  string s;
  cin>>s;
  rep(i,s.length()){
    while(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
      len++;
      i++;
    }
    if(ans<len){
      ans=len;
    }
    len=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  string n;
  cin >> n;
  replace(begin(n), end(n), '1', 'x');
  replace(begin(n), end(n), '9', '1');
  replace(begin(n), end(n), 'x', '9');
  cout << n << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str = br.readLine();
        String[] split = str.split(" ");
        int k = Integer.parseInt(split[0]);
        String[] s = br.readLine().split(" ");


        int maxDistance = 0;
        for (int i = 0; i < s.length - 1; i++) {
            int distance = Math.abs(Integer.parseInt(s[i]) - Integer.parseInt(s[i + 1]));
            if (maxDistance < distance) {
                maxDistance = distance;
            }
        }
        int distance = Math.abs(Integer.parseInt(s[s.length - 1]) - (k + Integer.parseInt(s[0])));
        if (maxDistance < distance) {
            maxDistance = distance;
        }

        System.out.println(k - maxDistance);
    }

}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int dp[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k; cin>>n>>k; int a[n+1];
    for(int i = 1; i <= n; ++i) cin>>a[i];
    for(int i = 1; i <= k; ++i) 
        for(int j = 1; j <= n; ++j) {
            if(a[j] <= i)
                dp[i] = dp[i]|(dp[i-a[j]]^1);
        }
    if(dp[k] == 1)
        cout<<"First\n";
    else 
        cout<<"Second\n";   
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

int main() {

    int n{0};
    std::cin >> n;

    int k{0};
    std::cin >> k;
    int arr[n];
    for(int index = 0; index< n; ++index)
    {
        int val;
        std::cin >> val;
        arr[index] = val;
    }

    int dp[n];
    dp[0] = 0;

    for(int i = 1; i < std::min(n,k); ++i)
    {
        dp[i] = std::abs(arr[0] - arr[i]);
    }

    for(int i = k; i < n; ++i)
    {
        dp[i] = INT8_MAX;
    }
  
  if(n <= k)
    {
        std::cout << dp[n-1] << '\n';
        return 0;
    }

    for(int index =k; index < n; ++index)
    {
        dp[index] = dp[index - k] + std::abs(arr[index] - arr[index-k]);
        for(int j = 1; j < k; ++j)
        {
            dp[index] = std::min(dp[index], dp[index-j] + std::abs(arr[index] - arr[index-j]));
        }
    }
  
    std::cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll H, W;
string S;

int main() {
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << ((H * W + 1) / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x,a,b,c,i,j,k,s=0;
	cin>>a>>b>>c;
	cin>>x;
	for (i=0;i<=a;i++)
		for (j=0;j<=b;j++)
			for (k=0;k<=c;k++)
		    {
		    	if (i*500+j*100+k*50==x) s++;
		    }
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=[]
for i in range(N):
    S.append(int(input()))

S.sort()
minh=10**10
for i in range(N-K+1):
    if minh>S[i+K-1]-S[i]:
        minh=S[i+K-1]-S[i]

print(minh)
    


Measured memory_bytes: 50392