akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll N;
map<char, map<ll, set<double>>> Vs;
double R = 1e20;

void update(double t) {
  t = abs(t);
  double res = 1;
  for (char xy : {'x', 'y'}) {
    set<double> avs;
    for (const auto &d_vs : Vs[xy]) {
      ll d = d_vs.first;
      const auto &vs = d_vs.second;
      avs.insert(*vs.begin() + d * t);
      avs.insert(*vs.rbegin() + d * t);
    }
    res *= *avs.rbegin() - *avs.begin();
  }
  R = min(R, res);
}
int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    double x, y;
    char d;
    cin >> x >> y >> d;
    Vs['x'][d == 'R' ? 1 : d == 'L' ? -1 : 0].insert(x);
    Vs['y'][d == 'U' ? 1 : d == 'D' ? -1 : 0].insert(y);
  }
  update(0);
  for (char xy : {'x', 'y'}) {
    for (ll d : {0, 1, -1}) {
      if (!Vs[xy].count(d)) continue;
      for (ll d2 : {0, 1, -1}) {
        if (d == d2) continue;
        if (!Vs[xy].count(d2)) continue;
        const auto &vs = Vs[xy][d], &vs2 = Vs[xy][d2];
        update((*vs2.begin() - *vs.begin()) / (d - d2));
        update((*vs2.rbegin() - *vs.rbegin()) / (d - d2));
      }
    }
  }
  cout << setprecision(10) << R << endl;
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 1e5+1;

ll N, E, T, A, B = 1e18, x[MN], DP[MN];

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> N >> E >> T;
	for (int i = 0; i < N; ++i) cin >> x[i];

	multiset<ll> S;
	S.insert(0);
	for (int i = 0, j = 0; i < N; ++i) {
		while (2*(x[i]-x[j]) >= T) {
			B = min(DP[j]-2*x[j], B);
			S.erase(S.find(DP[j]));
			++j;
		}
		DP[i+1] = min(A+(i+1)*T, B+2*x[i]);
		if (S.size()) DP[i+1] = min(*begin(S)+T, DP[i+1]);
		A = min(DP[i+1]-(i+1)*T, A);
		S.insert(DP[i+1]);
	}
	cout << DP[N]+E;
}


Measured memory_bytes: 7064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(n>=m)
    {
        cout<<"0"<<endl;
        return 0;
    }
    vector <ll> x(m);
    vector <ll> diff(m-1);
    for(ll i=0;i<m;i++)
        cin>>x[i];
    sort(x.begin(),x.end());
    for(ll i=0;i<m-1;i++)
        diff[i]=x[i+1]-x[i];
    sort(diff.begin(),diff.end());
    reverse(diff.begin(),diff.end());
    ll sum=0;
    for(ll i=0;i<m-1;i++)
        sum+=diff[i];
    for(ll i=0;i<n-1;i++)
        sum-=diff[i];
    cout<<sum<<endl;
    return 0;
}


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


long long int gcd(long long int a, long long int b)
{
    long long int ret;
    
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
    
    if( b == 0 ) return a;
    
    ret = a % b;
    ret = gcd(b, ret);
    
    return ret;
}


long long int lcm(long long int a, long long int b)
{
    return (a*b)/gcd(a, b);
}


int main()
{
    while( 1 ){
        long long int a, b;
        if( scanf("%lld%lld", &a, &b) == EOF ) break;
        printf("%lld %lld\n", gcd(a, b), lcm(a, b));
    }

    return 0;
}



Measured memory_bytes: 3188
A, B, K = map(int, input().split())

if A >= 1:
    tmp = A - K
    if tmp <= 0:
        A = 0
        K = abs(tmp)
        
    else:
        K = 0
        A = tmp
        

if B >= 1:
    tmp = B - K
    if tmp <= 0:
        B = 0
        K = abs(tmp)
        
    else:
        K = 0
        B = tmp
        
print(A,B)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    long a = readLong();
    ArrayList<Long> beki = new ArrayList<Long>();
    boolean flg = true;
    for(long i=2;a>1;){
      if(a%i==0){
        a/=i;
        if(flg){
          beki.add(1L);
          flg = false;
        }else{
          beki.set(beki.size()-1,beki.get(beki.size()-1)+1);
        }
      }else{
        flg = true;
        if(i*i>a){
          beki.add(1L);
          break;
        }
        i++;
      }
    }
    long count=0;
    for(int i=0;i<beki.size();i++){
      long e = 1;
      long z = beki.get(i);
      while(z>=e){
        count++;
        z-=e;
        e++;
      }
    }
    pl(count+"");
  }
  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return Long.parseLong(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

using namespace std;

const int NMAX = 105;

int N;

char S[NMAX];

static inline bool Pal (int Left, int Right)
{
    if(Left > Right)
        return 0;

    if(Left == Right)
        return 1;

    if(Left == Right - 1)
        return (S[Left] == S[Left + 1]);

    if(S[Left] != S[Right])
        return 0;

    return Pal(Left + 1, Right - 1);
}

int main()
{
    cin >> (S + 1);

    N = (int)strlen(S + 1);

    if(!Pal(1, N))
    {
        cout << "No" << '\n';

        return 0;
    }

    if(Pal(1, (N - 1) / 2) && Pal((N + 3) / 2, N))
    {
        cout << "Yes" << '\n';

        return 0;
    }

    cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
	
int32_t main(){
	boost;
	int n;
	cin>>n;
	int d[n+1]={0};
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i)
			d[j]++;
	}
	int ans  = 0;	
	for(int i=1;i<=n;i++)
		ans += i*d[i];
	cout<<ans<<endl;
}



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

int main(){
    int N, A, B;
    cin >> N >> A >> B;

    vector<int> res(N);

    // 1〜Nの数値の各桁の和を調べ、該当するものをpush_backする
    for(int i = 1; i <= N; ++i) {
        int cnt = 0;
        int num = i;
        int num_var = 0;

        while(num > 0) {
            num_var = num % 10;
            cnt = cnt + num_var;
            num = num / 10;
        }

        if(cnt >= A && cnt <= B) {
            res.push_back(i);
        }
    }

    // 回答の配列の数値をsumして、coutする。
    cout << accumulate(res.begin(), res.end(), 0) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    string date;
    cin >> date;

    date[3]='8';

    cout << date<<endl;

    return 0;
}


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

#define pi acos(-1);
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(2);
    cout<<2*r*pi;
    nl;
    return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	long n; get n;


	long i = 0;
	while(true){
		i += n;
		if (i % n == 0 && i % 2 == 0) {
			put i;
			return;
		}
	}
}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
// 根のペアが同じならどちらでも連結している
// union - find tree !!!!!!!!!!!!!!!!!!!!!!!!!
vector<vector<int> > par; //oya
vector<vector<int> > rnk; //ki no hu ka sa
// n要素で初期化
void init(int n){
    par.resize(2, vector<int>(n));
    rnk.resize(2, vector<int>(n));
    FOR(i,0,n)FOR(j,0,2){par[j][i] = i;rnk[j][i] = 0;}
}
//木の根を求める
int find(int x, int k){
    if(par[k][x] == x) return x;
    else return par[k][x] = find(par[k][x], k);
}
//xとyの属する集合を併合
void unite(int x, int y, int k){
    x = find(x, k);y = find(y, k);
    if(x == y) return;
    if(rnk[k][x] < rnk[k][y])par[k][x] = y;
    else{par[k][y] = x;if(rnk[k][x] == rnk[k][y]) rnk[k][x]++;}
    return;
}
bool isSame(int x, int y, int k){return find(x, k) == find(y, k);}
int main()
{
  int N, K, L;
  cin >> N >> K >> L;
  map<P, int> MAP;
  init(N+1);
  FOR(i,0,K) {
    int a, b; cin >> a >> b;
    unite(a, b, 0);
  }
  FOR(i,0,L) {
    int a, b; cin >> a >> b;
    unite(a, b, 1);
  }
  FOR(i,1,N+1) MAP[P(find(i,0), find(i,1))]++;
  FOR(i,1,N+1) {
    printf("%d%c",MAP[P(find(i,0), find(i,1))],i==N?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 15120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>vec;
    for(int i = 0;i < 10;++i)
    {
        int v; cin >> v;
        vec.push_back(v);
    }
    sort(vec.begin(),vec.end());
    cout << vec[9] <<endl<< vec[8] <<endl << vec[7] <<endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"

int main() {
  ll k, x;
  cin >> k >> x;
  vector <ll> a, b;
  for(ll i=0; i<k; ++i){
    a.push_back(x-i);
  }
  for(ll i=1; i<k; ++i){
    b.push_back(x+i);
  }
  for(ll i = a.size() - 1; i>=0; --i)
    cout << a[i] << " ";
  for(ll x:b)
    cout << x << " ";
  cout << endl;  
  return 0;
}

Measured memory_bytes: 3604
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
// #define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int ans = 1;

    for(int i = 0;i < n;i ++){
        int a; cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0) ans = 0;
        }
    }

    if(ans == 0) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

template <typename T, typename U> class dijkstra {
public:

    struct edge {
        T to;
        U cost;
    };

    using P = pair<U, T>;
    map<T, vector<edge> > E;
    map<T, U> d;

    void calc(T s) {
        priority_queue <P, vector<P>, greater<P> > que;
        rep(i, limit) d[i] = INF;
        que.emplace(U(0), s);
        d[s] = U(0);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            T v = p.second;
            if (d[v] < p.first) continue;

            for (auto&& e : E[v]) {
                //if (d.find(e.to) == d.end()) d[e.to] = INF;
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.emplace(d[e.to], e.to);
                }
            }
        }
    }
};

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

    int k;
    cin >> k;
    dijkstra<int, int> ds;
    rep(i, k) ds.E[i].push_back({(i + 1) % k, 1});
    rep(i, k) ds.E[i].push_back({10 * i % k, 0});
    ds.calc(1);
    cout << ds.d[0] + 1 << endl;
    return 0;

}



Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=3009,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	int n,s,a[N],g[N];
	int main(){
		n=read<int>(),s=read<int>();
		for(int i=1;i<=n;i++) a[i]=read<int>();
		int ans=0;
		for(int j=1;j<=n;j++){
			for(int i=s;i>=a[j];i--)
				g[i]=add(g[i],g[i-a[j]]);
			g[a[j]]=add(g[a[j]],j);
			ans=add(ans,g[s]);
		}
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    int j = -1, cnt = 0, ans = 0, r = 0, w = 0;
    string c;
    cin>>c;
    f(i, 0, n) r += (c[i] == 'R'), w += (c[i] == 'W');
    f(i, 0, r) cnt += (c[i] == 'W');
    fb(j, n-1, n-w) ans += (c[j] == 'R');
    cnt = min(ans, cnt);
    cout<<cnt<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3764
dct = {'2': 0, '3': 1, '4': 2, '5': 3, '6': 4, '7': 5, '8': 6, '9': 7, '10': 8, '11': 9, '12': 10, '13': 11, '1': 12}
a, b = input().split()
print('Draw' if dct[a] == dct[b] else 'Alice' if dct[a] > dct[b] else 'Bob')

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);


      int  A = sc.nextInt();
      int  B = sc.nextInt();

      B = 2*B;

      int answer = A-B;

      if(answer<0){
        System.out.println(0);
      }else{
        System.out.println(answer);
      }

                   }
      }


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

int main()
{
	int a, b, c; cin >> a >> b >> c;
	string ans;

	if (a + b + c >= 22) {
		ans = "bust";
	}
	else {
		ans = "win";
	}

	cout << ans << endl;	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7

int main(){
    int n;
    cin >> n;
    int m;
    cin >> m;
    int a = 0;

    for(int i = 0; i < m; ++i){
        int b;
        cin >> b;
        a += b;
    }

    cout << (a > n ? -1 : n - a) << endl;


    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

bool f;
ll n,m;
vector<vector<pair<ll,ll> >> v,vr;
vector<ll> dis;
vector<bool> checked;

bool solve(){
    rep(i,n)if(!checked[i]){
        checked[i]=true;
        dis[i]=0;
        //bfs
        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int now=q.front();q.pop();
            for(auto x:v[now]){
                if(checked[x.first]){
                    if(dis[x.first]!=dis[now]+x.second)return false;
                }
                else{
                    dis[x.first]=dis[now]+x.second;
                    q.push(x.first);
                    checked[x.first]=true;
                }
            }
            for(auto x:vr[now]){
                if(checked[x.first]){
                    if(dis[x.first]!=dis[now]+x.second)return false;
                }
                else{
                    dis[x.first]=dis[now]+x.second;
                    q.push(x.first);
                    checked[x.first]=true;
                }
            }
        }
    }
    return true;
}

int main(){
    cin>>n>>m;
    v.resize(n);vr.resize(n);
    dis=vector<ll>(n,LINF);checked=vector<bool>(n,false);
    rep(i,m){
        ll l,r,d;
        cin>>l>>r>>d;l--,r--;
        v[l].push_back(make_pair(r,d));
        vr[r].push_back(make_pair(l,-d));
    }
    cout<<(solve()?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
string s;
vector <pair <int, int> > p[26], u, v;
int c[26];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    s='0'+s;
    FFOR(i, 1, s.size()) s[i]-='a';
    FFOR(i, 1, s.size()){
        c[s[i]]++;
        p[s[i]].pb(mp(c[s[i]]*2-i, i));
    }
    FFOR(i, 0, 26){
        sort(p[i].begin(), p[i].end());
        v.clear();
        u.clear();
        if(p[i].empty()) continue;
        v.pb(p[i][0]);
        u.pb(p[i][0]);
        FFOR(j, 1, p[i].size()) if(p[i][j].first==v.back().first){
            v.back().second=min(v.back().second, p[i][j].second);
            u.back().second=max(u.back().second, p[i][j].second);
        }
        else{
            v.pb(p[i][j]);
            u.pb(p[i][j]);
        }
        int best=s.size()+1;
        FFOR(j, 0, v.size()){
            best=min(best, v[j].second);
            if(u[j].second>best){
                cout<<best<<' '<<u[j].second;
                return 0;
            }
        }
    }
    cout<<"-1 -1";
}

Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	class Student
	{
		public int Index{get;set;}
		public int Count{get;set;}
	}
	public static void Main(string[] args)
	{
		int n = Console.ReadLine().ToInt();
		int[] a = Input().ToInt();
		Student[] s = new Student[n];
		for(int i = 0; i < n; i++)
		{
			s[i] = new Student() {Index = i+1, Count = a[i] };
		}
		Array.Sort(s, (d,b)=>d.Count - b.Count);
		for(int i = 0; i < n; i++)
			Console.Write("{0} ", s[i].Index);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1) return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

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

void solve() {
  int n, k; cin >> n >> k;
  cout << n - k + 1 << endl;
}

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
//#include <fstream>	// require freopen

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.russiandolls", "r", stdin );
	int n, m;

	while (cin >> n && n ){
		vector <P> taro (n);

		for (int i = 0; i < n; ++i){
			cin >> taro[i].first >> taro[i].second;
		} // end for
		cin >> m;
		vector <P> jiro (m);
		for (int j = 0; j < m; ++j ){
			cin >> jiro[j].first >> jiro[j].second;
		} // end for

		vector <P> all (n+m );
		for (int k = 0; k < n; ++k ){
			all[k] = taro[k];
		} // end for
		for (int k = n; k < n+m; ++k ){
			all[k] = jiro[k-n];
		} // end for
		sort (all.begin(), all.end() );


		vector <int> dp(n+m, 0 );

		int res = 0;
		for (int i = 0; i < n+m; ++i ){
			dp[i] = 1;
			for (int j = 0; j < i; ++j ){
				if (all[j].first < all[i].first && all[j].second < all[i].second ){
					dp[i] = max (dp[i], dp[j] + 1 );
				} // end if
			} // end for
			res = max (res, dp[i] );
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<map>


using namespace std;

int main(){

    int N,M;
    string tmp;
    map<string,int> out;
    int max =0;
    

    cin >>N;

    for(int i=0;i<N;i++){
        cin>>tmp;
        if(out[tmp]==0){
            out[tmp]=1;
        }else{
            out[tmp]+=1;
        }
    }

    cin >> M;

    for(int i=0;i<M;i++){
        cin>>tmp;
        if(out[tmp]==0){
            out[tmp]=-1;
        }else{
            out[tmp]-=1;
        } 
    }

    for(auto itr2 = out.begin();itr2!=out.end();++itr2){
        if(itr2->second>max){
            max = itr2->second;
        }
    }

    cout<<max<<endl;

    return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(__int128_t x){
  int s=0;
  int m=0;
  char f[40];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int K;
int D[5000];
int Q;
int N;
int X;
int M;
int a[5000];
__int128_t s;
int main(){
  int e98WHCEY;
  rd(K);
  rd(Q);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(K);Lj4PdHRW++){
      rd(D[Lj4PdHRW]);
    }
  }
  for(e98WHCEY=(0);e98WHCEY<(Q);e98WHCEY++){
    int i;
    rd(N);
    rd(X);
    rd(M);
    for(i=(0);i<(K);i++){
      if(D[i]%M==0){
        a[i] =M;
      }
      else{
        a[i] =D[i] % M;
      }
    }
    s = 0;
    for(i=(0);i<(K);i++){
      s += a[i];
    }
    s *= (N-1) / K;
    int KrdatlYV = (N-1)%K;
    for(i=(0);i<(KrdatlYV);i++){
      s += a[i];
    }
    s += X % M;
    wt_L(N - 1 - s / M);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// int K, D[5000], Q, N, X, M;
// 
// int a[5000];
// __int128_t s;
// 
// {
//   rd(K,Q,D(K));
//   rep(Q){
//     rd(N,X,M);
// 
//     rep(i,K) a[i] = if[D[i]%M==0, M, D[i] % M];
//     s = 0;
//     rep(i,K) s += a[i];
//     s *= (N-1) / K;
//     REP(i,(N-1)%K) s += a[i];
//     s += X % M;
// 
//     wt(N - 1 - s / M);
//   }
// }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  long long x; cin>>x;
  REP(i, 1, 1001) REP(j, -1001, 1001) {
    long long l = (long long)i * i * i * i * i;
    long long r = (long long)j * j * j * j * j;
    if (l - r == x) {
      print(i, j);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;
int opinions[15][15];

int main(){
    int n;cin>>n;
    ll values[n] = {0};
    ll sums[n+1] = {0};
    ll values2[n] = {0};
    ll sums2[n+1] = {0};
    sums[n+1] = 0;
    fore(i,0,n){
        ll val;cin>>val;
        values[i] = val;
        sums[i+1] = val + sums[i];
    }
    fore(i,0,n){
        values2[i] = values[i];
        sums2[i+1] = sums[i+1];
    }
    ll ans = 0;
    ll ans2 = 0;

    fore(i,0,n){
        sums[i+1] = sums[i]+values[i];
        //cout<<sums[i+1]<<"\n";
        if(i%2 == 0){
            if(sums[i+1]<=0){
                ans += abs(values[i]+sums[i])+1;
                values[i] = 1;
                sums[i+1] = 1;
            }
        }else{
            if(sums[i+1]>=0){
                ans += abs(values[i]+sums[i])+1;
                values[i] = -1;
                sums[i+1] = -1;
            }
        }
    }
    //cout<<ans<<" ";
    fore(i,0,n){
        sums2[i+1] = sums2[i]+values2[i];
        //cout<<sums[i+1]<<"\n";
        if(i%2 == 0){
            if(sums2[i+1]>=0){
                ans2 += abs(values2[i]+sums2[i])+1;
                values2[i] = -1;
                sums2[i+1] = -1;
            }
        }else{
            if(sums2[i+1]<=0){
                ans2 += abs(values2[i]+sums2[i])+1;
                values2[i] = 1;
                sums2[i+1] = 1;
            }
        }
    }
    //cout<<ans2<<" ";
    ans = min(ans,ans2);
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 3328
import numpy as np
from itertools import product
from sys import maxsize

n, m, x = map(int, input().split())
c = []
a = np.empty((n, m), dtype='i8')
for i in range(n):
    ipt = list(map(int, input().split()))
    c.append(ipt[0])
    a[i] = ipt[1:]

can = False
res = maxsize
for pt in product(range(2), repeat=n):
    understanding = np.zeros(m, dtype='i8')
    price = 0
    for i, b in enumerate(pt):
        if b:
            understanding += a[i]
            price += c[i]

    if np.all(understanding >= x):
        can = True
        if price < res:
            res = price

print(res) if can else print(-1)


Measured memory_bytes: 27340
#include <queue>
#include <cstdio>
using namespace std;

const int MAXN = 1e6 + 5;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

template<typename _T>
_T ABS( const _T a )
{
	return a < 0 ? -a : a;
}

struct node
{
	int l, r;
	node() { l = r = 0; }
	node( const int L, const int R ) { l = L, r = R; }
	bool operator < ( const node &b ) const { return ! ( ( r - l ) < ( b.r - b.l ) ); }
};

int a[MAXN];
int N;

int C( const int n, const int m ) { return n >= m; }

int cal( const int n, const int m )
{
	if( m == 0 ) return 1;
	return cal( n / 2, m / 2 ) * C( n % 2, m % 2 );
}

int cal()
{
	int ret = 0;
	for( int i = 1 ; i <= N ; i ++ )
		if( a[i] == 1 )
			ret ^= cal( N - 1, i - 1 );
	return ret;
}

int main()
{
	int t1 = 0, t2 = 0, p = 1;
	read( N );
	for( int i = 1 ; i <= N ; i ++ ) scanf( "%1d", &a[i] );
	for( int i = 1 ; i < N ; i ++ ) a[i] = ABS( a[i] - a[i + 1] );
	N --; 
	for( int i = 1 ; i <= N ; i ++ ) t1 += a[i] == 1, t2 += a[i] == 2;
	if( ! t1 ) 
	{
		for( int i = 1 ; i <= N ; i ++ ) a[i] >>= 1;
		p = 2;
	}
	write( cal() * p ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 4096
import copy
s = str(input())
t = str(input())
if s == t:
    print("Yes")
    exit()
for i in range(1,len(s)):
    tmp = s[-1] + s[:len(s)-1]
    s = copy.deepcopy(tmp)
    if t == tmp:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3444
import numpy as np
N, D = map(int, input().split())

X = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(N):
    for j in range(i + 1 , N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        if np.sqrt(tmp) % 1 == 0:
            ans += 1
            
print(ans)

Measured memory_bytes: 12496
#include<stdio.h>
int main()
{
	long long int i,j;
scanf("%lld%lld",&i,&j);
long long int x=i*j;
if(i==1||j==1)
printf("1");
else 
{
if(x%2==0)
printf("%lld",x/2);
else
printf("%lld",x/2+1);
}
}

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x

        return True
    
    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.parents[self.root(x)]
    
    def members(self, x):
        x_root = self.root(x)
        return [i for i in range(self.n) if self.root(i) == x_root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


    

N, M, K = map(int, input().split())
uf = UnionFind(N)

friend = [0] * N
block = [[]*N for i in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    friend[a] += 1
    friend[b] += 1
    uf.unite(a, b)

for _ in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    block[a].append(b)
    block[b].append(a)

for i in range(N):
    ans = uf.size(i) - 1
    ans -= friend[i]
    for br in block[i]:
        if uf.same(i, br):
            ans -= 1
    print(ans)



Measured memory_bytes: 26272
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = gets.chomp.split(" ").map{|i| i.to_i-1}
A = A.each_with_index.map{|n,i| n==i ? 1 : 0}
for i in 0..(N-2)
	if(A[i] == 1 && A[i+1] == 1)
		A[i+1] = 0
	end
end
puts A.inject(0){|sum,n| sum+n}



Measured memory_bytes: 11772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		int n = s.length();
		String subString1 = s.substring(0, (n-1)/2);
		String subString3 = s.substring((n+3)/2  - 1);
		
		if(iskaibun(s) && iskaibun(subString1) && iskaibun(subString3)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	
	boolean iskaibun(String s) {
		
		int left = 0; 
		int right = s.length()-1;
		
		while(left < right) {
			if(s.charAt(left) != s.charAt(right)) {
				return false;
			}
			left++;
			right--;
		}
		return true;
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21332
A = [[int(x) for x in input().split()] for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

Bingo = [[0, 0, 0] for _ in range(3)] 
for i in range(3):
  for j in range(3):
    for l in range(N):
      if(A[i][j] == b[l]):
        Bingo[i][j] = 1
bingo = 0
for i in range(3):
  if(Bingo[i][0]+Bingo[i][1]+Bingo[i][2])==3:
    bingo += 1
  elif(Bingo[0][i]+Bingo[1][i]+Bingo[2][i])==3:
    bingo += 1
if(Bingo[0][0]+Bingo[1][1]+Bingo[2][2])==3:
  bingo += 1
elif(Bingo[0][2]+Bingo[1][1]+Bingo[2][0])==3:
  bingo += 1

if(bingo!=0):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9268
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    if (h % 2 == 0 && w % 2 != 0 && w != W - 1 || h % 2 != 0 && w % 2 == 0 && w != W - 1) {
                        System.out.print(".");
                    }
                    if (h % 2 != 0 && w % 2 != 0 && w != W - 1 || h % 2 == 0 && w % 2 == 0 && w != W - 1) {
                        System.out.print("#");
                    }
                    if (h % 2 == 0 && w % 2 != 0 && w == W - 1 || h % 2 != 0 && w % 2 == 0 && w == W - 1) {
                        System.out.println(".");
                    }
                    if (h % 2 != 0 && w % 2 != 0 && w == W - 1 || h % 2 == 0 && w % 2 == 0 && w == W - 1) {
                        System.out.println("#");
                    }
                }
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34916
import sys
sys.setrecursionlimit(100000)
n,k=map(int,input().split())
ans=k
t=[set()for i in range(n)]
dp=[k]+[0]*(n-1)
for i in range(n-1):
  a,b=map(int,input().split())
  t[a-1].add(b)
  t[b-1].add(a)
no=1
w=k
def a(noo):
  global ans
  w=k
  for i in t[noo-1]:
    t[i-1].discard(noo)
    if w==0:print(0);exit()
    dp[i-1]=w-2;ans=(ans*(w-2))%(10**9+7)
    w-=1
    a(i)
for i in t[no-1]:
  t[i-1].discard(no)
  w-=1
  dp[i-1]=w;ans=(ans*w)%(10**9+7)
  a(i)
print(ans)

Measured memory_bytes: 100664
#include <cstdio>

char str[99];
char goal[99]="AKIHABARA";
int cnt[99];
int main() {
	scanf("%s",str);
	int N=0;
	while(str[N]!='\0') N++;
	int M=0;
	for(int i=0;i<N;i++) {
		while(M<11) {
			if(str[i]==goal[M]) break;
			M++;
		}
		if(str[i]==goal[M]) cnt[M++]++;
	}
	if(M>9) {
		printf("NO\n");
		return 0;
	} else {
		for(int i=0;i<9;i++) if(cnt[i]==0&&goal[i]!='A') {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int N=1e5+100;
LL a[N];
int main()
{
	LL n=gi(),i,l=2,r=3;
	for (i=1;i<=n;i++) a[i]=gi();
	if (a[n]!=2) return puts("-1"),0;
	for (i=n-1;i;i--) {
		l=(l-1)/a[i]*a[i]+a[i];
		r=r/a[i]*a[i]+a[i]-1;
		if (l>r) return puts("-1"),0;
	}
	cout<<l<<" "<<r<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<set>
using namespace std;
string str;
set<string>s;
int main(){
	int n,i,j,k;
	cin>>str>>k;
	n=str.length();
	for(i=0;i<min(n,5);i++){
		for(j=0;j<n-i;j++)s.insert(str.substr(j,i+1));
	}
	for(i=1;i<k;i++)s.erase(s.begin());
	cout<<*s.begin();
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool card[4][13]={};
    for(int i=0;i<n;++i){
        char a;
        int b;
        cin>>a>>b;
        if(a=='S'){
            card[0][b-1]=1;
        }
        if(a=='H'){
            card[1][b-1]=1;    
        }
        if(a=='C'){
            card[2][b-1]=1;  
        }
        if(a=='D'){
            card[3][b-1]=1;
        }
    }
    for(int i=0;i<4;++i){
        for(int j=0;j<13;++j){
            if(card[i][j]==0){
                if(i==0){
                    cout<<"S "<<j+1<<endl;
                }
                if(i==1){
                    cout<<"H "<<j+1<<endl;
                }
                if(i==2){
                    cout<<"C "<<j+1<<endl;
                }
                if(i==3){
                    cout<<"D "<<j+1<<endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3104
import math
A, B, H, M = map(int, input().split())
alpha = math.pi * M * 6 / 180
beta = (math.pi * (H * 30 + M * 0.5)) / 180
theta = abs(alpha - beta)
AB = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(theta))
print(AB)

Measured memory_bytes: 9420
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
//head
map<int,int>a;
void run() {
 int n,x;
 cin>>x>>n;
 for(int i=1;i<=n;i++){
	int tp;
	cin>>tp;
	a[tp]=1;
 }
 if(n==0) {
 cout<<x<<'\n';
 return;
 }
 int ans=0;
 int pre=1000,pos=0;
 for(int i=-1000;i<=1000;i++){
 	if(!a[i]&&abs(i-x)<pre) pos=i,pre=abs(i-x);
 }
 cout<<pos<<'\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(20);
	//int T; cin >> T; while (T--)
	run();
	return 0;
}


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

#include <utility>
using namespace std;

#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e9;
using Pii = pair<int, int>;

const int con_type = 26;
int D = 365;
int C[con_type];
int S[365][con_type];
vector<int> ans;
int last[con_type];

struct State {
  int cost;
  vector<int> ans;
  vector<int> last;

  State() {
    cost = 0;
    last = vector<int>(26, -1);
  }

  State(int cost, vector<int> ans, vector<int> last):
    cost(cost), ans(ans), last(last) {};

  bool operator<( const State& s ) const {
    return cost < s.cost;
  }

  bool operator>( const State& s ) const {
    return cost > s.cost;
  }
};

void solve() {
  priority_queue<State> Q;
  Q.push(State());
  REP(d, D) {
    priority_queue<State> nQ;
    while ( !Q.empty() ) {
      State now = Q.top(); Q.pop();
      vector<Pii> add_cost;
      int sum = 0;
      int type_cost[26];
      REP(i, con_type) {
        sum += (d-now.last[i])*C[i];
        type_cost[i] = (d-now.last[i])*C[i];
      }
      REP(i, con_type) {
        add_cost.emplace_back(Pii(S[d][i]+(d-now.last[i])*C[i]-sum, i));
      }
      sort(add_cost.begin(), add_cost.end(), greater<Pii>());
      REP(i, 8) {
        int id = add_cost[i].second;
        State next = now;
        next.cost += S[d][id];
        next.cost -= sum;
        next.cost += type_cost[id];
        next.ans.emplace_back(id);
        next.last[id] = d;
        nQ.push(next);
      }
    }
    Q = priority_queue<State>();
    REP(i, min(1200, (int)nQ.size())) {
      Q.push(nQ.top()); nQ.pop();
    }
  }

  ans = Q.top().ans;
}

void input() {
  cin >> D;
  REP(i, con_type) {
    cin >> C[i];
    last[i] = -1;
  }
  REP(i, D) REP(j, con_type) cin >> S[i][j];
}

void output() {
  REP(i, D) cout << ans[i]+1 << endl;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  input();
  solve();
  output();

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

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

	vi ans = {};

	rep1(i, 55555) {
		if (i == 1||i%5!=1)continue;
		bool prime=true;

		rep1(j,(int)sqrt(i)) {
			if (j == 1)continue;
			if (i % j==0)prime = false;
		}

		if (prime)ans.push_back(i);
	}

	rep(i, n)cout << ans[ans.size()-1-i] << " " << endl;
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[100010];
  for(int i =1 ;i<=N; i++){
    cin >> a[i];
  }
  if(a[1] == 2){
    cout << 1 << endl;
    return 0;
  }
  else{
  int count = 1;
  int p = a[1];
  while(count<=N){
  p = a[p];
  count ++;
  if(p==2){
    cout << count << endl;
    return 0;
  }
}
  if(count > N){
    cout << -1 << endl;
    return 0;
  }
}
}

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

int main(){
  int n, ans = 0;
  int l, r;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	for (int i = 0; i <= n / 4; i++) {
		for (int j = 0; j <= n / 7; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 256