akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  int s[m], c[m];
  for(int i = 0; i < m; i++){
    cin >> s[i] >> c[i];
    for(int j = 0; j < i; j++){
      if(s[j] == s[i] && c[j] != c[i]){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for(int i = 0; i < 1000; i++){
    string x = to_string(i);
    if(x.length() == n){
      int j;
      for(j = 0; j < m; j++){
        if(x[s[j] - 1] - 48 != c[j]) break;
      }
      if(j == m){
        cout << x << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int A[MAX], n;

int partition(int p, int r){ // pは区間の左、rは区間の右
    int x,i,j,t;
    x = A[r]; // 最右をxに入れる
    i = p - 1; // 0オリジンのため
    for( j = p; j < r; j++){
        if( A[j] <= x){ // 対象がxより小さい時に左側のパーティションを広げる
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main(){
    int i,q;
    scanf("%d", &n);
    for( i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for(i = 0; i < n; i++){
        if(i) printf(" ");
        if( i==q ) printf("[");
        printf("%d", A[i]);
        if( i == q) printf("]");
    }
    printf("\n");

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        sum += a[i];
    }
    sum = round((double)sum / (double)n);
    int res = 0;
    //cout << sum << endl;
    for(int i=0;i<n;++i){
        res += pow((a[i]-sum),2);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=1000;
const LL p=7+1e9;
const LL INF=1<<30;
LL N;
VI edges[SIZE];
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
LL maps[SIZE][SIZE];
LL minium[SIZE][SIZE];
LL solve(){
	LL H,W,K,sx,sy;
	cin >> H >> W >> K;
	REP(i,SIZE) REP(j,SIZE) minium[i][j]=INF;
	REP(i,H){
		string s;
		cin >> s;
		REP(j,W) {
			maps[i][j]=s[j]!='#';
			if(s[j]=='S'){
				sx=j;
				sy=i;
			}
		}
	}
	queue<pr> qu;
	qu.push(pr(sy,sx));
	minium[sy][sx]=0;
	LL dx[]={0,1,0,-1};
	LL dy[]={1,0,-1,0};
	while(!qu.empty()){
		int nowx=qu.front().second,nowy=qu.front().first;
		qu.pop();
		if(nowy==0 or nowx==0 or nowy==H-1 or nowx==W-1) return (K-1+minium[nowy][nowx])/K;
		if(minium[nowy][nowx]==K+1) continue;
		REP(i,4){
			int ny=nowy+dy[i],nx=nowx+dx[i];
			if(maps[ny][nx]==0) minium[ny][nx]=K+1;
			else if(minium[ny][nx]>minium[nowy][nowx]+1){
				minium[ny][nx]=minium[nowy][nowx]+1;
				qu.push(pr(ny,nx));
			}
		}

	}
	REP(i,H) REP(j,W){
		if(minium[i][j]==K+1) qu.push(pr(i,j));
	}
	while(!qu.empty()){
		int nowx=qu.front().second,nowy=qu.front().first;
		qu.pop();
		//cout << minium[nowy][nowx] <<" " <<nowx << " " << nowy << endl;
		if(nowy==0 or nowx==0 or nowy==H-1 or nowx==W-1) return (K-1+minium[nowy][nowx])/K;
		REP(i,4){
			int ny=nowy+dy[i],nx=nowx+dx[i];
			if(minium[ny][nx]>minium[nowy][nowx]+1){
				minium[ny][nx]=minium[nowy][nowx]+1;
				qu.push(pr(ny,nx));
			}
		}

	}

	return INF;
}
int main(){
	cout << solve() << endl;
	return 0;
}

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

int main(){ 
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  vector<double> e(n);
  for (int i = 0; i < n; i++) {
    double sum = (p[i]) * (p[i] + 1) / 2;
    e[i] = sum / (double)(p[i]);
  }
  double res = 0.0;
  vector<double> ecum(n+1,0);
  for (int i = 0; i < n; i++) ecum[i+1] = ecum[i] + e[i];
  for (int i = 0; i + k <= n; i++) {
    double tmp = ecum[i+k] - ecum[i];
    res = max(res, tmp);
  }
  printf("%.12f\n", res);
  return 0;
} 

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

using namespace std;

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 Main() {
    ll N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    ll Q;
    cin >> Q;

    vector<vector<ll>> dp(min(N + 1, (1LL << 10) + 1), vector<ll>(100001, 0));
    rep2(i, 1, min(N + 1, (1LL << 10) + 1)) {
        rep(j, 100001) {
            ll par = i / 2;
            dp[i][j] = dp[par][j];
            if (j - items[i - 1].second >= 0) {
                dp[i][j] = max(dp[i][j], dp[par][j - items[i - 1].second] + items[i - 1].first);
            }
        }
    }
    vector<ll> ans(Q);
    vector<P> query(Q);
    rep(q, Q) cin >> query[q].first >> query[q].second;
    rep(q, Q) {
        ll v = query[q].first;
        ll L = query[q].second;
        vector<ll> use;
        v--;
        ll u = v;
        use.push_back(u);
        while (u != 0) {
            u = (u - 1) / 2;
            use.push_back(u);
        }
        if (v < (1LL << 10)) {
            ans[q] = dp[v + 1][L];
            continue;
        }
        sort(use.begin(), use.end());
        ll n = use.size();
        vector<ll> use_p;
        ll last = -1;
        rep(i, n) {
            if (use[i] >= (1LL << 10)) {
                use_p.push_back(use[i]);
            } else {
                last = max(last, use[i]);
            }
        }
        ll a = 0;
        rep(i, 1LL << (ll) use_p.size()) {
            ll value = 0;
            ll weight = 0;
            rep(j, use_p.size()) {
                if (i & (1 << j)) {
                    value += items[use_p[j]].first;
                    weight += items[use_p[j]].second;
                    if (weight > L) break;
                }
            }
            if (L - weight < 0) continue;
            a = max(a, dp[last + 1][L - weight] + value);
        }
        ans[q] = a;
    }
    rep(q, Q) {
        cout << ans[q] << '\n';
    }
}

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


Measured memory_bytes: 813172
var dp, back: array[0..5000, 0..5000] of longint;
    c: array[1..3000] of char;
    s, t: ansistring;
    i,j,k: longint;
begin
    readln(s);
    readln(t);
    for i:=1 to length(s) do 
    begin
        for j:=1 to length(t) do
        begin
            if s[i]=t[j] then
            begin
                dp[i,j]:=dp[i-1][j-1]+1;
                back[i,j]:=0;
            end
            else
            begin
                if dp[i,j-1]>dp[i-1,j] then
                begin
                    dp[i,j]:=dp[i,j-1];
                    back[i,j]:=1;
                end
                else
                begin
                    dp[i,j]:=dp[i-1,j];
                    back[i,j]:=2;
                end;
            end;
        end;
    end;
    k:=0;
    while k<dp[length(s),length(t)] do
    begin
        if back[i,j]=2 then
            dec(i)
        else if back[i,j]=1 then
            dec(j)
        else
        begin
            inc(k);
            c[k]:=s[i];
            dec(i);
            dec(j);
        end;
    end;
    for i:=k downto 1 do
        write(c[i]);
    writeln;
end.

Measured memory_bytes: 120448
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                cnt += 1
print(cnt)

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

ll h,w,n,a[10005];

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

    cin>>h>>w>>n;
    for(ll i=1;i<=n;i++)
        cin>>a[i];

    ll cnt=1;

    for(ll i=1;i<=h;i++)
    {
        if(i%2==1)
        {
            for(ll j=1;j<=w;j++)
            {
                if(a[cnt]>0)
                {
                    cout<<cnt<<" ";
                    a[cnt]--;
                }
                else
                {
                    cnt++;
                    cout<<cnt<<" ";
                    a[cnt]--;
                }
            }
        }
        else
        {
            vector<ll> stampa;
            for(ll j=1;j<=w;j++)
            {
                if(a[cnt]>0)
                {
                    stampa.push_back(cnt);
                    a[cnt]--;
                }
                else
                {
                    cnt++;
                    stampa.push_back(cnt);
                    a[cnt]--;
                }
            }
            for(ll j=stampa.size()-1;j>=0;j--)
                cout<<stampa[j]<<" ";
        }
        cout<<endl;
    }


    return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    set<int> s;
    rep(i, n)  {
        int d;
        cin >> d;
        s.emplace(d);
    }

    cout << s.size() << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i,m)
    {
        cin >> L[i] >> R[i];
    }
    sort(all(L),greater<int>());
    sort(all(R));
    
    if(R[0] - L[0] >= 0) cout << R[0] - L[0] + 1 << endl;
    else cout << 0 << endl;


    //rep(i,m) cout << l[i].first << "      " <<  l[i].second << endl;


}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  modint pow(unsigned long long i){
    if(i == 0) return 1;
    if(i & 1){
      return (*this) * (this->pow(i-1));
    }
    modint<mod>hpow = (this->pow(i>>1));
    return hpow * hpow;
  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};

using mint = modint<1000000007>;

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int cnt[] = {0,0,0};
  mint ans = 1;
  for(int i = 0; i < n; ++i){
    int x = 0;
    for(int j = 0; j < 3; ++j)x += cnt[j] == v[i];
    ans *= x;
    for(int j = 0; j < 3; ++j){
      if(cnt[j] == v[i]){
	cnt[j]++;
	break;
      }    
    }
  }
  cout << ans << endl;
  return 0;  
}


Measured memory_bytes: 3784
from fractions import gcd
n,k = map(int, input().split())
aa = list(map(int, input().split()))

gcd_aa = aa[0]
for a in aa[1:]:
    gcd_aa = gcd(gcd_aa, a)

print('POSSIBLE' if k<=max(aa) and k%gcd_aa==0 else 'IMPOSSIBLE')


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

int main() {
  int N; cin>>N;
  vector<int> V(N); for(auto &elm: V)cin>>elm; 
  vector<int> C(N); for(auto &elm: C)cin>>elm; 
  vector<int> diff(N);
  for(int i=0;i<N;++i) diff[i]=V[i]-C[i];
  int total=0;
  for(auto d: diff) total+=(d>0?d:0);
  cout<<total<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

#define N 55
#define no -1;
long long int dpp[N+1][N+1][(N+1)*(N+1)];

int t[N];
long long int dp(int x,int y,int sum){
    long long int ans=0;
    
    if(sum<0){
        ans=0;
    }else if(dpp[x][y][sum]>=0){
        ans=dpp[x][y][sum];
    }else if(x==0){
        if((y==0&&sum==0)||(y==1&&sum==t[0])){dpp[x][y][sum]=1;ans=1;}
        else {dpp[x][y][sum]=0;ans=0;}
    }else if(y==0){
        if(sum==0){dpp[x][y][sum]=1;ans=1;}
        else {dpp[x][y][sum]=0;ans=0;}
    }else{
        dpp[x][y][sum]=dp(x-1,y,sum)+dp(x-1,y-1,sum-t[x]);
        ans=dpp[x][y][sum];
    }
    /*if(ans>=1)printf("%d %d %d\n",x,y,sum);*/
    return ans;
}

int main() {
    int n,a;cin>>n>>a;
    for(int i=0;i<=n-1;i++)cin>>t[i];
    for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)for(int k=0;k<=N*N;k++)dpp[i][j][k]=no;
    
    long long int sum=0;
    for(int i=1;i<=n;i++)sum+=dp(n-1,i,i*a);
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 77184
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str,num;
        int a,b,i;

        while(true){
            str = scan.nextLine();
            if(str.equals("-")){
                break;
            }
            num = scan.nextLine();
            a = Integer.valueOf(num);
            for(i=0;i<a;i++){
                num = scan.nextLine();
                b = Integer.valueOf(num);
                str = str.substring(b) + str.substring(0,b);
            }
            System.out.println(str);
        }


        scan.close();

    }

}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int r;
  cin >> r;
  cout << (r < 1200 ? "ABC" : (r < 2800 ? "ARC" : "AGC")) << endl;
}


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

int main(){
	string s,t;
	cin >> s;
	cin >> t;
	bool flag = true; 
	rep(i,s.length()){
		if (s[i] != t[i])
			flag = false;
	}

	if (flag == true && t.length() - s.length() == 1)
		cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  vector<int> a(3);
  int k;
  cin >> a[0] >> a[1] >> a[2];
  cin >> k;
  int max=0;
  sort(a.begin(),a.end());
  for(int i=0;i<k;i++) {
    a[2] *= 2;
    sort(a.begin(),a.end());
  }
  max=a[0]+a[1]+a[2];
  cout << max << endl;
  return 0;
}

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

struct record {
	int id, correct, penalty;
	record(int i, int c = 0, int p = 0):id(i), correct(c), penalty(p){}

	bool operator>(const record& r) const {
		return correct > r.correct
			|| correct == r.correct && (penalty < r.penalty
										|| penalty == r.penalty && id < r.id);
	}

	void accept(int time) {
		++correct;
		penalty += time;
	}

	void print() {
		cout << id << " " << correct << " " << penalty << endl;
	}
};

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

	for(int t, p, r; cin >> t >> p >> r, t;) {
		vector<vector<int> > wrong(t, vector<int>(p, 0));
		vector<record> records;
		records.reserve(t);
		for(int i = 1; i <= t; ++i)
			records.push_back(record(i));

		for(int i = 0; i < r; ++i) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			--tid;
			--pid;

			if(message[0] == 'C')
				records[tid].accept(time + wrong[tid][pid] * 1200);

			else
				++wrong[tid][pid];
		}

		sort(records.begin(), records.end(), greater<record>());
		for(int i = 0; i < (int)records.size(); ++i)
			records[i].print();
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 != 0) cnt++;
    }
    cout << (double) cnt / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i <= x; i++){
        int a = i;
        bool ok = false;
        for(int j = 2; j <= sqrt(i); j++){
            a = i;
            while(a % j == 0 && a > 0) {
                a /= j;
            }
            if(a == 1) {
                ok = true;
                break;
            }
        }
        if(ok) ans = max(i, ans);
    }
    cout << ans;
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
	cout << "Left" << endl;
  }
  else if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int N;
    unsigned long long int ans = 0;
    string s;
    map<char, unsigned long long int> mp;
    cin >> N >> s;
    for (int i = 0; i < s.size(); i++) {
        mp[s[i]]++;
    }
    ans = mp['R'] * mp['G'] * mp['B'];
    if (ans == 0 || s.size() < 3) {
        cout << 0 << endl;
        return 0;
    }
    int stride = 1;
    while(true) {
        if (stride*2+1 > s.size()) {
            break;
        }
        for (int i = 0; i < s.size()-stride*2; i++) {
            char a = s[i];
            char b = s[i+stride];
            char c = s[i+stride*2];
            if (a != b && b != c && c != a) {
                ans--;
            }
        }
        stride++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>

#define ASSET(EXPECT, ACTUAL)														\
do																					\
{																					\
	if ((EXPECT) == (ACTUAL))														\
		;																			\
	else																			\
	{																				\
		std::cout << "ERROR: " << __LINE__ << "ACTUAL: " << (ACTUAL) << std::endl;	\
	}																				\
}while(0)

//#define DEBUG

short alph[128];

int min(int a, int b)
{
	return a <= b ? a : b;
}

int diffChar(char* str, int s, int e)
{
	int count = 0;
	for (int i = 0; i < 128; i++)
	{
		alph[i] = 0;
	}
	for (int i = s; i < e; i++)
	{
		if (alph[str[i]] == 0)
		{
			count++;
			alph[str[i]] = 1;
		}
	}
	return count;
}

int diffChar2(char* str, int s, int e)
{
	int count = 0;
	for (int i = s; i < e; i++)
	{
		if (alph[str[i]] == 1)
		{
			alph[str[i]] = 2;
			count++;
		}
	}
	return count;
}

int main()
{
#ifndef DEBUG

	int n;
	char str[100];
	std::cin >> n;
	std::cin >> str;
	int max = 0;
	int a = diffChar(str, 0, 1);
	int b = diffChar2(str, 1, 2);
	for (int i = 0; i <= n; i++)
	{
		int a = diffChar(str, 0, i);
		int b = diffChar2(str, i, n);
		int t = min(a, b);
		if (t > max)
		{
			max = t;
		}
	}
	std::cout << max;

#endif // !DEBUG

#ifdef DEBUG
	char str[100] = "tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir";
	ASSET(0, diffChar(str, 0, 0));
	ASSET(0, diffChar(str, 45, 45));

	char testStr1[100] = "aaaaaaaaaa";
	char testStr2[100] = "ababababab";
	ASSET(1, diffChar(testStr1, 0, 10));
	ASSET(2, diffChar(testStr2, 0, 10));

	std::cout << diffChar(str, 0, 11);
	std::cout << diffChar(str, 11, 45);
#endif // DEBUG

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving csa rating

// Code below

string s;

void inp() {
    cin >> s;
}


void solve() {
    string rev = s;
    reverse(all(rev));
    cout << (s == rev ? "Yes" : "No");
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


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

using namespace std;
#define int long long
const int MOD = 1000000007;
int N;
vector<int> X;
int ask(vector<int> &A) {
    // int t = 0;
    // for (int i = 0; i < N; i++) {
    //     t += 2 * X[A[i]] - 1;
    // }
    // if (t > 0) {
    //     return 1;
    // } else {
    //     return 0;
    // }
    cout << "?";
    for (int i = 0; i < A.size(); i++) {
        cout << " " << A[i] + 1;
    }
    cout << endl;
    cout << flush;
    string res;
    cin >> res;
    return res[0] == 'R' ? 1 : 0;
}
int askseq(int a) {
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = a + i;
    }
    return ask(A);
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    // X.resize(2 * N);
    // for (int i = 0; i < 2 * N; i++) {
    //     cin >> X[i];
    // }
    int l = 0;
    int r = N;
    int ll = askseq(l);
    int rr = 1 - ll;
    while (r - l > 1) {
        int m = (r + l) / 2;
        int t = askseq(m);
        if (t == ll) {
            l = m;
        } else {
            r = m;
        }
    }
    // cerr << l << " " << r << endl;
    string res(2 * N, 'R');
    vector<int> A;
    vector<int> B;
    for (int i = r; i < l + N; i++) {
        A.push_back(i);
    }
    for (int i = 0; i < l; i++) {
        B.push_back(i);
    }
    for (int i = r + N; i < 2 * N; i++) {
        B.push_back(i);
    }
    // cerr << A.size() << " " << B.size() << endl;
    for (int i = 0; i < 2 * N; i++) {
        int t;
        if (i < r || i >= r + N) {
            A.push_back(i);
            t = ask(A);
            A.pop_back();
        } else {
            B.push_back(i);
            t = ask(B);
            B.pop_back();
        }
        res[i] = (t == 1 ? 'R' : 'B');
    }
    cout << "! " << res << endl;
    cout << flush;
}

Measured memory_bytes: 724
x,y, a,b,c = list(map(int, input().split()))

tmp = list(map(int, input().split()))
tmp.sort(reverse=True)
red = [2e+9]
red.extend(tmp)

tmp = list(map(int, input().split()))
tmp.sort(reverse=True)
green = [2e+9]
green.extend(tmp)
none = list(map(int, input().split()))
none.sort(reverse=True)

n_red = x
n_green = y
n_none = 0


while(True):
  if(red[n_red] >= green[n_green]):
    if(green[n_green] <= none[n_none]):
      n_green -= 1
      n_none += 1
    else:
      break
  else: # redの最小の方が小さい時
    if(red[n_red] <= none[n_none]):
      n_red -= 1
      n_none += 1
    else:
      break
  if(n_none == len(none)):
    break
#

print(int(sum(red[1:n_red+1])
          +sum(green[1:n_green+1])
          +sum(none[:n_none])))

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

int main() {
    int N, A;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> A;
        vec.at(i) = A;
    }
    sort(vec.begin(), vec.end());
    cout << vec.at(N - 1) - vec.at(0) << endl;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<queue>
using namespace std;
int bfs[1000][1000];
bool field[1000][1000];
pair<int,int> point[10];
char str[1001];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ret=0;
	for(int i=0;i<a;i++){
		scanf("%s",str);
		for(int j=0;j<b;j++){
			if(str[j]=='X')field[i][j]=false;
			else field[i][j]=true;
			switch(str[j]){
				case 'S':
					point[0]=make_pair(i,j);
					break;
				case '1':
					point[1]=make_pair(i,j);
					break;
				case '2':
					point[2]=make_pair(i,j);
					break;
				case '3':
					point[3]=make_pair(i,j);
					break;
				case '4':
					point[4]=make_pair(i,j);
					break;
				case '5':
					point[5]=make_pair(i,j);
					break;
				case '6':
					point[6]=make_pair(i,j);
					break;
				case '7':
					point[7]=make_pair(i,j);
					break;
				case '8':
					point[8]=make_pair(i,j);
					break;
				case '9':
					point[9]=make_pair(i,j);
					break;
			}
		}
	}
	for(int i=0;i<c;i++){
		for(int k=0;k<a;k++)
			for(int j=0;j<b;j++)
				bfs[k][j]=-1;
		bfs[point[i].first][point[i].second]=0;
		queue<pair<int ,int> > Q;
		Q.push(point[i]);
		while(Q.size()){
			int row=Q.front().first;
			int col=Q.front().second;
			if(row>0&&field[row-1][col]&&bfs[row-1][col]==-1){
				bfs[row-1][col]=bfs[row][col]+1;
				Q.push(make_pair(row-1,col));
			}
			if(col>0&&field[row][col-1]&&bfs[row][col-1]==-1){
				bfs[row][col-1]=bfs[row][col]+1;
				Q.push(make_pair(row,col-1));
			}
			if(row<a-1&&field[row+1][col]&&bfs[row+1][col]==-1){
				bfs[row+1][col]=bfs[row][col]+1;
				Q.push(make_pair(row+1,col));
			}
			if(col<b-1&&field[row][col+1]&&bfs[row][col+1]==-1){
				bfs[row][col+1]=bfs[row][col]+1;
				Q.push(make_pair(row,col+1));
			}
			Q.pop();
		}
		ret+=bfs[point[i+1].first][point[i+1].second];
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  int num = 0;
  rep(i,N){
    if(v[i] == num+1) ++num;
  }
  if(num == 0) cout << -1 << endl;
  else cout << N-num << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  string s;
  cin>>s;
  int a=0,b=0;
  r(i,s.size()){
    if(s[i]=='0')a++;
    else b++;
  }
  int c=min(a,b);
  a-=c;
  b-=c;
  cout<<c*2<<endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

void func139() {

    int n;
    cin >> n;
    vector<int> h(n+1);
    for (int i = 0; i < n; ++i) cin >> h[i];
    h[n] = pow(10, 9) + 1;

    int max = 0;
    int temp = 0;

    for (int i = 0; i < h.size()-1; ++i) {

        //cout << h[i] << "\n";
        if (h[i] >= h[i + 1]) ++temp;
        else {
            if (temp > max) max = temp;
            temp = 0;
        }
       
    }

    cout << max;

}


int main() {

    func139();
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef pair<long long, long long>pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 200050;
const double pi = acos(-1); constexpr double EPS = 1e-12;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

void solve() {
	int N, M, K; cin >> N >> M >> K;
	COMinit();
	ll ans = 0;
	REP(k,K+1){
		ans += mult(COM(N-1, k), mult(M,bin_pow(M - 1, N-1-k)));
		ans %= MOD;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

int main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		if (i == x - k + 1)cout << i;
		else cout << " " << i;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> gcd_(2);
  FORi(N){
    cin>>A[i];
  }
  gcd_[0]=A[0];
  gcd_[1]=A[1];
  for(ll i=1;i<N;++i){
    vector<ll> g;
    g.push_back(gcd(gcd_[0],A[i]));
    if(g[0]!=gcd_[0]){
      g.push_back(gcd_[0]);
    }
    for(auto&& a:gcd_){
      ll tmp=gcd(a,A[i]);
      if(std::find(g.begin(),g.end(),tmp)==g.end()){
        g.push_back(tmp);
      }
    }
    gcd_=g;
  }
  ll ans=0;
  for(auto a:gcd_){
    //cout<<a<<endl;
    if(a>ans)ans=a;
  }
  cout<<ans<<endl;
  
  return 0;
}


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

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		
		Arrays.sort(s);
		Arrays.sort(t);
		
		String l = new String(s);
		String r = new StringBuilder(new String(t)).reverse().toString();
		
		System.out.println((l.compareTo(r) < 0) ? "Yes" : "No");
		
	}

}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<ll> dp;
vector<vector<ll>> a;
int N;

ll dfs(ll n) {
  if (dp[n]!=-1) return dp[n];
  ll result = 0, sum = 0;
  rep(i,N) repr(j,i+1,N) if (n&(1<<i)&&n&(1<<j)) sum += a[i][j];
  result = max(result, sum);
  for (int i=(n-1)&n; i>0; i=(i-1)&n) result = max(result, dfs(i)+dfs(n^i));
  return dp[n] = result;
}

int main() {
  cin >> N;
  a.resize(N, vector<ll>(N)); rep(i,N) rep(j,N) cin >> a[i][j];
  dp.resize(1<<N,-1);
  ll result = dfs((1<<N)-1);
  cout << result << endl;
  // debug(all(dp));
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  string S;
  cin >> N >> S;
  map<pair<string, string>, long long> mp;
  for(int tmp = 0; tmp < 1 << N; tmp++){  
    string sr, sb;//string red, string blue
    for(int i = 0; i < N; i++){  
      if(1 & tmp >> i){  
        sr += S[i]; 
      } else{  
        sb += S[i]; 
      }
    } 
    mp[make_pair(sr, sb)]++;
  }
  long long ans = 0;
  for(int tmp = 0; tmp < 1 << N; tmp++){  
    string sr, sb;//string red, string blue
    for(int i = N-1; i >= 0; i--){  
      if(1 & tmp >> i){  
        sr += S[N + i]; 
      } else{  
        sb += S[N + i]; 
      }
    } 
    ans += mp[make_pair(sr, sb)];
  }
  cout << ans <<endl;
}


Measured memory_bytes: 60924
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl



signed main(){
    int N,K;
    int Ans=INF;
    int h[114514];
    cin >> N >> K;
    REP(i,N){
        cin >> h[i];
    }
    sort(h,h+N);
    for(int i=0;i<N-K+1;i++){
        Ans=min(Ans,h[i+K-1]-h[i]);
    }
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  long long N;
  cin>>N;
  int max = 0;
  int digit = 0;
  long long num = N;
  int topNumber = 0;
  while(num!=0){
    if(num < 10) {
      topNumber = num;
    }
        num /= 10;
        digit++;
    }
  // long long topNumber = N / (long long)pow(10, (int)log10(N));


  if (digit == 1) {
    max = N;
  }
  else if ((N + 1) % (long long)pow(10, digit - 1) != 0) {
    max = topNumber - 1 + 9 * (int)log10(N);
  }
  else {
    max = 9 * (digit - 1) + topNumber;
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,maxi=0,f=0,mini=INF;
    double sum=0;
    string str,sub;
    ll h,w;
    string str1;
    double k;
    cin>>n>>k;
    ll per=1;
    ll first=1;
    for(ll i=1;i<=n;i++){
        per=1;
        while(per<(double)(k/i)){
            per*=2;
        }
        //if(i<=5)cout<<i<<" "<<per<<endl;
        if(i==1) first=per;
        sum+=(double)first/per;
        
    }
    n*=first;
    //cout<<n<<" "<<sum<<endl;
    printf("%.10lf\n",(double)sum/n);
    return 0;
}


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


N, M = map(int, input().split())
*H, = map(int, input().split())

G = [[] for _ in [0]*N]
for _ in [0]*M:
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

ans = 0
for v, g in enumerate(G):
    for u in g:
        if H[u] >= H[v]:
            break
    else:
        ans += 1

print(ans)


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

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

    vector<int> l(q), r(q);
    for(int i=0; i<q; i++){
        cin >> l[i] >> r[i];
    }

    int n = 1e5;
    vector<int> primes;

    vector<bool> is_prime_list(n, true);
    is_prime_list[0] = false; 
    is_prime_list[1] = false;

    for (int i=2; i<n; i++) {
        if (is_prime_list[i] == true){
            for (int j=i*2; j<n; j+=i){
                is_prime_list[j] = false;// exclude multipliers of i (prime)
            }
            if(is_prime_list[(i+1)/2] == true) primes.push_back(i);
        }// if not prime, do nothing -> proceed to i+1
    }

    for(int i=0; i<q; i++){
        cout << lower_bound(primes.begin(),primes.end(),r[i]+1) - lower_bound(primes.begin(),primes.end(),l[i]) << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    char s[3]={};
    scanf("%s",s);
    if(s[0]==s[1] && s[1]==s[2])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a, b, c;
		int d;
		a = sc.next();
		b = sc.next();
		c = a.concat(b);
		d = Integer.parseInt(c);
		for (int i = 0; i < d / 2; i++) {
			if (i * i == d) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		sc.close();
	}

}


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


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

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,f[200005],a[200005],b[200005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&f[i]);
	for(int i=1;i<=n;i++){
		if(i%2==1)a[i/2+1]=f[i];
		else b[i/2]=f[i];
	}
	if(n%2==1){
		for(int i=n/2+1;i>=1;i--)printf("%d ",a[i]);
		for(int i=1;i<=n/2;i++)printf("%d ",b[i]);
	}
	else if(n%2==0){
		for(int i=n/2;i>=1;i--)printf("%d ",b[i]);
		for(int i=1;i<=n/2;i++)printf("%d ",a[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    vector<int> s_num(4);
    for (int i = 0; i < 4; i++){
        s_num.at(i) = s[i] - '0';
    }

    for (int i = 0; i < (1 << 3); i++){

        bitset<4> bs(i);
        int sum = s_num[0];
        string f = {s.at(0)};

        for (int j = 0; j < 3; j++){
            if (bs.test(j)){
                f.push_back('+');
                sum += s_num[j+1];
            }
            else{
                f.push_back('-');
                sum -= s_num[j+1];
            }
            f.push_back(s[j+1]);
        }

        if (sum == 7){
            cout << f << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>

using ll = long long;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int main() {
    int A, P;

    cin >> A >> P;

    cout << (P + A * 3) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
X, Y= [0]*n,[0]*n

for i in range(n):
    x,y = map(int,input().split())
    X[i]=x
    Y[i]=y
    

def kaijo(x):
    if x==1:
        return 1
    else:
        return x*kaijo(x-1)

dis = 0.0
for i in range(n):
    for j in range(n):
        dis += (((X[i]-X[j])**2+(Y[i]-Y[j])**2)**0.5)*kaijo(n-1)


print(dis/kaijo(n))

Measured memory_bytes: 38256
N=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
a=[0]*(N)
for i in range(N):
  for k in range(i+1):
    a[i]+=x[k]
  for j in range(N-i):
    a[i]+=y[j+i]

print(max(a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    int q; cin >> q;
    deque<char> deq;
    REP(i,s.size()) deq.push_back(s[i]);
    bool rev = false;

    REP(i,q) {
        int t; cin >> t;
        if (t == 1) rev = !rev;
        else {
            int f; cin >> f;
            char c; cin >> c;
            if ((!rev && f == 1) || (rev && f == 2)) deq.push_front(c);
            else deq.push_back(c);
        }

    }

    string ans;
    ans.resize(deq.size());
    if (rev) {
        int dl = deq.size();
        REP(i,deq.size()) {
            ans[i] = deq[dl-1-i];
        }
    } else {
        REP(i,deq.size()) {
            ans[i] = deq[i];
        }
    }
    OUT(ans)

    return 0;
}

Measured memory_bytes: 1232