akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char C[2][3];
    cin >> C[0] >> C[1];
    if((C[0][0] == C[1][2]) && (C[0][1] == C[1][1]) && (C[0][2] == C[1][0])) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i <(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

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

const int MAXN = 2 * 100000 + 5;

int n, x;
int sol[MAXN], bio[MAXN];

int main(){
    cin >> n >> x;
    if(x == 1 || x == 2 * n - 1){
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    if(x == 2){
        sol[n - 1] = 2 * n - 1;
        sol[n] = 2;
        sol[n + 1] = 1;
        sol[n + 2] = 2 * n - 2;
    }
    else{
        sol[n - 1] = 1;
        sol[n] = x;
        sol[n + 1] = 2 * n - 1;
        sol[n + 2] = 2;
    }
    bio[sol[n - 1]] = 1;
    bio[sol[n]] = 1;
    bio[sol[n + 1]] = 1;
    bio[sol[n + 2]] = 1;

    int cnt = 1;
    FOR(i, 1, 2 * n){
        if(!sol[i]){
            while(bio[cnt])++cnt;
            bio[cnt] = 1;
            sol[i] = cnt;
        }
    }
    FOR(i, 1, 2 * n){
        cout << sol[i] << "\n";
    }
return 0;
}


Measured memory_bytes: 3072
var  now,ans,ansx:longint;
     x,a:array[0..150000]of longint;
     n:longint;
     i:longint;
begin
  read(n);
  now:=0;
  for i:=1 to n do
  begin
    read(a[i]);
    x[i]:=now;
    ans:=ans+abs(now-a[i]);
    now:=a[i];
  end;
  a[n+1]:=0;
  x[n+1]:=now;
  ans:=ans+abs(now-a[i+1]);
  for i:=1 to n do
  begin
    ansx:=ans-abs(x[i]-a[i])-abs(x[i+1]-a[i+1])+abs(x[i]-a[i+1]);
    writeln(ansx);
  end;
end.

Measured memory_bytes: 1792
# include<stdio.h>
#include <stdlib.h>
int main()
{
	int A, B;
	scanf("%d%d", &A,&B);
	if (A>1&&B>1)
	{
		if (A == B)
		{
			printf("Draw\n");
		}
		if (A > B)
		{
			printf("Alice\n");
		}
		if (A < B)
		{
			printf("Bob\n");
		}
	}
	else
	{
		if (A == B)
		{
			printf("Draw\n");
		}
		if (A > B)
		{
			printf("Bob\n");
		}
		if (A < B)
		{
			printf("Alice\n");
		}
	}
	system("pause");
}

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



int main() {
    int h, n;
    cin >> h >> n;
    
    vector<int> dp(h+1,100000005);
    dp[0] = 0;
    
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        //0~hでi番目の魔法を使った場合で更新
        rep(j,h) {
            int j_n = min(j+a, h);
            dp[j_n] = min(dp[j_n], dp[j]+b);
        }
    }
    
    cout << dp[h] << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

template<typename T>
T ceil(T x, T y){
    return (x + (y - 1)) / y;
}

ll A,B,C1,D;
int main(void){
    cin >> A >> B >> C1 >> D;
    ll g = lcm(C1,D);
    A -= 1;
    cout <<(B-A) - (B/C1-A/C1) - (B/D-A/D) + (B/g-A/g) << endl;

    return 0;
}



Measured memory_bytes: 256
/**
*    author:  musasi
*    created: 19.04.2020 21:06:15
**/

#include <bits/stdc++.h>

using namespace std;
#define rep2(x,from,to) for(long long (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define ASSERT(expr...) assert((expr))
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 (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<ll,P > PP;
typedef pair<ll,PP > PPP;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
double n;
signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   cin>>n;
   cout<<2.00000*3.1415926535897*n<<endl;
   return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

vector<ll> inv, FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    ll n,k,ans = 0;
    cin >> n >> k;
    nfor(i, k, n + 2){
        ans += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1;
        ans %= mod;
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 3644
<?php
    $n = trim(fgets(STDIN));
    $nums = explode(" ",trim(fgets(STDIN)));

    $flag = 0; //0=neutral, 1=up, 2=down

    $ans = 1;

    for($i=1;$i<$n;$i++){

        if($flag == 0 && $nums[$i] > $nums[$i-1]){
            $flag = 1;
        }

        if($flag == 0 && $nums[$i] < $nums[$i-1]){
            $flag = 2;
        }

        if($flag == 1){ //up
            if($nums[$i] < $nums[$i-1]){
//                echo "prev, now ->",$nums[$i-1],",",$nums[$i]," now go down.",PHP_EOL;
                $ans++;
                $flag = 0;
            }
        }

        if($flag == 2){ //down
            if($nums[$i] > $nums[$i-1]){
//                echo "prev, now ->",$nums[$i-1],",",$nums[$i]," now go up.",PHP_EOL;
                $ans++;
                $flag = 0;
            }
        }
    }

    echo $ans;
?>

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

int main(){
	int a, b;
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0)
			break;
		for(int i = 0; i < a; i++){
			for(int j = 0; j < b; j++){
				if((i+j)% 2 == 0)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M; cin >> M;
    ll sum1=0,sum2=0;
    rep(i,M){
        ll d,c; cin >> d >> c;
        sum1+=c; sum2+=d*c;
    }
    cout << sum1-1+(sum2-1)/9 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
    int n;
    string s;
    bool flag = true;
    cin >> n;
    while(flag){
        s = to_string(n);
        if ((s[0] == s[1]&&(s[1] == s[2]))){
            flag = false;
        }
        else{
            n += 1;
        }
    }
    cout << n << endl;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

std::string S;
int DP[100000];

bool begin_of(int i, const char* str) {
	auto iter = S.begin() + i; auto iter_end = S.end();
	while (iter != iter_end && *str != '\0') {
		if (*iter != *str) {
			return false;
		}
		++iter; ++str;
	}
	return  (*str == '\0');
}
template<size_t N>
constexpr size_t str_len_c(const char(&)[N]) { return N - 1; }
bool func(int i)
{
	if (S.size() <= i) { return true; }
	if (DP[i] != -1) { return DP[i] != 0; }
#define DO_FUNC_11(STR) \
	if (begin_of(i, #STR)) {\
		if(func(i + str_len_c(#STR))){\
			DP[i] = 1; return true;\
		}\
	}
	DO_FUNC_11(dream);
	DO_FUNC_11(dreamer);
	DO_FUNC_11(erase);
	DO_FUNC_11(eraser);
	DP[i] = 0; return false;
#undef DO_FUNC_11
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> S;
	for (auto& i : DP)
	{
		i = -1;
	}
	out << (func(0) ? "YES" : "NO");
	return 0;
}
#endif


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

using namespace std;

int gcd(int a,int b){
  if(a % b == 0){
    return b;
  }else
  {
    return(gcd(b,a % b));
  }
}
int main(){
  int N;
  int count = 0;
  cin >> N;
  long long int sum = 0;
  vector<long long int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] < 0) count++;
    sum += abs(A[i]);
  }

  if(count % 2 == 0){ cout << sum; return 0; }
  
  for(int i = 0; i < N; i++){
    if(A[i] < 0) A[i] *= -1;
  }

  sort(A.begin(),A.end());
  A[0] *= -1;
  sum = sum + 2 * A[0];

  cout << sum;


    return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
vector <ll> parent,size1;
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

//Union by size
void make_set(int v) {
    parent[v] = v;
    size1[v] = 1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size1[a] < size1[b])
            swap(a, b);
        parent[b] = a;
        size1[a] += size1[b];
    }
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
	ll n,m;
	cin>>n>>m;
	parent.assign(n+1,0);
	size1.assign(n+1,0);
	rep (i,0,n+1)
	{
		make_set(i);
	}
	rep (i,0,m)
	{
		ll x,y;
		cin>>x>>y;
		union_sets(x,y);
	}
	set <ll> s1;
	rep (i,1,n+1)
	{
		s1.insert(find_set(i));
	}
	ll ans=s1.size();
	ans-=1;
	cout<<ans<<"\n";
}


Measured memory_bytes: 8308
//???????????????????????????Aizu??§???runnning
#include<iostream>
#include<cstdio>
using namespace std;
  
int main()
{
    int b,i;
	int sum=0;
	char x[1001];//?????????
	
	while(1){
		cin >> x;
		//x=0?????¨?????????
		sum = 0;
		if(x[0] == '0')break;
		
		for( i=0; x[i] != 0; i++){
		b = x[i]-'0';//?????????x?????????i?????°????????????
		sum += b;
		}
		cout << sum << endl;
	}
	return 0;
}

	

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

const int INF = 100000000;

int d[200][200];
int V;

void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++) {
        int ri;
        cin >> ri;
        ri--;
        r.at(i) = ri;
    }
    for (int i = 0; i < 200; i++) {
        for (int j = 0; j < 200; j++) {
            d[i][j] = INF;
            if (i == j) d[i][j] = 0;
        }
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        d[a][b] = c;
        d[b][a] = c;
    }

    V = n;
    warshall_floyd();

    sort(r.begin(), r.end());
    
    int ans = INF;
    do{
        int sum = 0;
        int from = r.at(0);
        for (int i = 1; i < R; i++) {
            sum += d[from][r.at(i)];
            from = r.at(i);
        }

        ans = min(ans, sum);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}

Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;
long[10^^5+50] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long[10^^5+1] MEMO, RN;

void main()
{
    init();
    
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    foreach (i; 0..N) RN[i+1] = (RF[i+1] * F[i]) % P;
    foreach (i; 0..N) MEMO[0] = (MEMO[0] + RN[i+1]) % P;

    for (int i = 2, j = N; i <= N; ++i, --j) {
        MEMO[i-1] = (MEMO[i-2] - RN[j] + RN[i]) % P;
        if (MEMO[i-1] < 0) MEMO[i-1] += P;
    }

    long r;
    foreach (i, a; AS) {
        r = (r + ((a * F[N]) % P * MEMO[i]) % P) % P;
    }

    writeln(r);
}

Measured memory_bytes: 7604
import java.io.*;
import java.util.StringTokenizer;



public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();

        String num = Integer.toString(N);

        char num1 = num.charAt(0);
        char num2 = num.charAt(1);
        char num3 = num.charAt(2);
        char num4 = num.charAt(3);


        if (num1 == num2 && num1 == num3)
        {
            System.out.println("Yes");
            System.exit(0);
        }
        if (num2 == num3 && num2 == num4)
        {
            System.out.println("Yes");
            System.exit(0);
        }
        else
            {
                System.out.println("No");
            }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 23124
import java.lang.Exception
import java.util.*

fun main(args: Array<String>) {
	
	val scanner = Scanner(System.`in`)
	val N = scanner.nextInt()
	val K = scanner.nextInt()
	val S = scanner.next()
	scanner.close()
	
	
	val array = ArrayList<TwoNum>()
	try {
		var first = -1
		for (i in 0 until N) {
			if (S[i] == '1') {
				if (first == -1) first = i
			} else {
				if (first != -1) {
					array.add(TwoNum(first, i - 1))
					first = -1
				}
			}
		}
		if (first != -1){
			array.add(TwoNum(first, N - 1))
		}
		if (array[0].first != 0) {
			array.reverse()
			array.add(TwoNum(0, 0))
			array.reverse()
		}
		if (array[array.size - 1].last != N - 1) {
			array.add(TwoNum(N - 1, N - 1))
		}
	} catch (e: Exception) {
	
	}
	
	
	if (array.size - 1 <= K) {
		print(N)
		return
	}
	var max = 0
	try {
		for (i in 0 until array.size - K) {
			val temp = array[i + K].last - array[i].first + 1
			max = if (temp > max) temp else max
		}
	} catch (e: Exception) {
		e.printStackTrace()
	}
	print(max)
}

class TwoNum (val first: Int, val last: Int)

Measured memory_bytes: 36992
mod = 10 ** 9 + 7

N, *E = map(int, open(0).read().split())
E = sorted((e, 2 * (i < N) - 1) for i, e in enumerate(E))

res = 1
cnt = 0
for _, delta in E:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

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

int main()
{
  int N;
  cin >> N;
  vector<int> count_num(pow(10, 5), 0);
  rep(i, N)
  {
    int a;
    cin >> a;
    count_num[a]++;
  }
  int max_count = 0;
  rep(i, pow(10, 5) - 2)
  {
    int sum = count_num[i] + count_num[i + 1] + count_num[i + 2];
    max_count = max(max_count, sum);
  }
  cout << max_count << endl;
  return 0;
}

Measured memory_bytes: 640
N = 3
SRR = [
    "acornistnt",
    "peanutbomb",
    "constraint",
]

N = 5
SRR = [
    "abaaaaaaaa",
    "oneplustwo",
    "aaaaaaaaba",
    "twoplusone",
    "aaaabaaaaa",
]

N = int(input())
SRR = []

for i in range(N):
    SRR.append(input())

def calculate(n,arr):
    dict = {}
    for i in range(n):
        str = "".join(sorted(list(arr[i])))
        if dict.get(str) == None:
            dict.__setitem__(str,1)
        else:
            dict.__setitem__(str,dict.get(str) + 1)

    result = 0

    for item in dict.values():
        if item > 1:
            result += (item * (item-1)) // 2

    print(result)


calculate(N, SRR)

Measured memory_bytes: 29144
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {	
	char Day[7][5] = 
	{   "SUN",
		"MON",
		"TUE",
		"WED",
		"THU",
		"FRI",
		"SAT" 
	};
	char S[5];
	int ans = 0;
	scanf("%s", &S);
	for (int i = 0; i < 7; i++) {
		if (strcmp(S, Day[i]) == 0) ans = (7 - i);
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.*;

public class Main{

    static Scanner sc = new Scanner(System.in);
    static int h = Integer.parseInt(sc.next());
    static int w = Integer.parseInt(sc.next());
    static char[][] s = new char[h][w];

    public void run(){
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] s = new char[h][w];
    }

    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();

        for (int i=0; i<h; i++){
            s[i] = sc.next().toCharArray();
        }

        int ans = 0;

        Set<Integer> set = new TreeSet<>();

        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                if (s[i][j]=='#'){
                    continue;
                }
//                System.out.print(i);
//                System.out.println(j);
                P tmp = new P(i, j);
                int tt = bfs(tmp);
                set.add(tt);
            }
        }
        long end = System.currentTimeMillis();
//        out.println(end-start);
        StringBuilder sb = new StringBuilder();
        sb.append(((TreeSet<Integer>) set).last());
        out.println(sb);
        out.flush();

    }

    public static int bfs(P tmp){
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};

        int ret = 0;
        Queue<P> queue = new ArrayDeque<>();
        ((ArrayDeque<P>) queue).add(tmp);
        int[][] d = new int[h][w];

        d[tmp.s][tmp.t] = 0;

        while (!queue.isEmpty()){
            P p = ((ArrayDeque<P>) queue).pollFirst();
            for (int k=0; k<4; k++){
                int ny = p.s+dy[k];
                int nx = p.t+dx[k];
                if (ny<0 || h<=ny || nx<0 || w<=nx) continue;
                if (s[ny][nx]=='#') continue;
                if (d[ny][nx]!=0) continue;
                if (ny==tmp.s && nx==tmp.t) continue;
                P pp = new P(ny, nx);
                ((ArrayDeque<P>) queue).add(pp);
                d[ny][nx] = d[p.s][p.t]+1;
                ret = Math.max(ret, d[ny][nx]);
            }
        }
        return ret;
    }

    public static class P{
        int s;
        int t;
        public P(int s, int t){
            this.s = s;
            this.t = t;
        }
    }
}


Measured memory_bytes: 26404
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

class Edge
{
	public:
	int to,cost;

	Edge(int t,int c)
	{
		to=t;cost=c;
	}
};
vector<Edge> g[200010];
bool used[200010];
ll vecx=0; //連結成分中のx側の個数
ll vecy=0;
//連結成分の深さを判定する
int saiki(int now,int dep)
{
	//cerr<<dep<<endl;
	int ret=dep;
	used[now]=true;
	if(now<1e5)
		vecx++;
	else
		vecy++;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(!used[e.to])
			ret=max(ret,saiki(e.to,dep+1));
	}
	return ret;
}

int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		y+=1e5;
		g[x].push_back(Edge(y,1));
		g[y].push_back(Edge(x,1));
	}
	fill(used,used+200010,false);
	//全要素について深さを判定する
	//2以上なら条件を満たしているので求める
	cerr<<"init done"<<endl;
	for(int i=0;i<200000;i++)
	{
		if(!used[i])
		{
			vecx=0;vecy=0;
			int tmp=saiki(i,0);
			//cerr<<vecx<<" "<<vecy<<endl;
			ans+=vecx*vecy;
		}
	}
	cout<<max(0LL,ans-n)<<endl;
	return 0;
}

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

int main() {
  ll n,m; cin >>n >>m;
  if(2*n>m) cout << m/2 << endl;
  else cout << n+(m-n*2)/4 << endl;
  return 0;
}

Measured memory_bytes: 3524
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=505;
const char c[]={"RYGB"};
char mp[N][N];int n,m,d;
int main(){
	scanf("%d%d%d",&n,&m,&d);
	fp(i,1,n)fp(j,1,m){
		R int x=i+j,y=i-j+m-1;
		mp[i][j]=c[((y/d)&1)+((x/d)&1)*2];
	}
	fp(i,1,n){
		fp(j,1,m)putchar(mp[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 768
a[3333];long p[3333][3333];long f(i,j){return i-j?p[i][j]?:(p[i][j]=fmax(a[i]-f(i+1,j),a[j-1]-f(i,j-1))):0;}main(i){while(~scanf("%d",a-i--));printf("%ld",f(0,~i));}

Measured memory_bytes: 80256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

fn a() {
    let n = read!(usize);
    println!("{}", n.pow(3));
}

fn b() {
    let n = read!(usize);
    let a = read!([usize]);
    let b = read!([usize]);
    let c = read!([usize]);
    let mut ans = 0;
    for i in 0..n {
        if i == 0 {
            ans += b[a[i] - 1];
        } else {
            ans += b[a[i] - 1];
            if a[i - 1] + 1 == a[i] {
                ans += c[a[i - 1] - 1];
            }
        }
    }
    println!("{}", ans);
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    b();
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);


            if((A<=C)&&(B>=C))
            {
                Console.WriteLine("Yes");
            }

            else
            {
                Console.WriteLine("No");
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>

using namespace std;

int match(const string& s, const string& t)
{
    for (int i = 0; i < s.size(); ++i)
        if (s.substr(i) == t.substr(0, s.size() - i)) return s.size() + i;
    return s.size() + t.size();
}

int main()
{
    int N;
    string s, t;
    cin >> N >> s >> t;
    cout << match(s, t) << endl;
    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N; 
	cin >> N; 
	vector<int> B(N);
	int tmp;
	rep(i, N) {
		cin >> tmp;
		B[tmp-1] = i+1;
	}
	
	rep(i, N) {
		cout << B[i] << ' ';
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
//#define N 1000000
//int a[N];
main(){
	int n,m,a,all=0;
 	cin>>n>>m;
 	for(int i=0;i<m;i++)cin>>a,all+=a;
 	if(all>n)cout<<"-1\n";
 	else cout<<n-all<<"\n"; 
}

Measured memory_bytes: 3632
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ab = abs(a[0])+abs(a[-1])
    for i in range(n-1):
        ab += abs(a[i]-a[i+1])

    for i in range(n):
        if i==0:
            print(ab - abs(a[i]-a[i+1])-abs(a[i])+abs(a[i+1]))
        elif i==n-1:
            print(ab - abs(a[i-1]-a[i])-abs(a[i])+abs(a[i-1]))
        else:
            print(ab - abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

        
    
int main(){
  int n; cin >> n; int cnt[1010000] = {};
  for(int i=1; i<=1000010; i++){
    for(int j=i; j<=1000010; j+=i){
      cnt[j]++;
    }
  }
  ll ans = 0;
  for(int i=1; i<=n-1; i++){
    ans+=cnt[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 7588
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する


public class Main{
	public static void main(String[] args){		//メソッド宣言
		double r;				//
		double a;
		double c;

		try(Scanner sc = new Scanner(System.in)){
			r = sc.nextDouble();

			c = 2 * r * Math.PI;
			a = r * r * Math.PI;

			System.out.println(String.format("%.8f %.8f",a,c));
		}
	}
}





Measured memory_bytes: 28140
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
ll ans;
ll n, k;

ll val(ll t)
{
	if(t==0)
	{
		return n/11;
	}
	else
	{
		return (n+11-t%11)/11;
	}
}

int main(void)
{
	cin>>n>>k;
	n-=2;
	ll i;
	for(i=1 ; i<=5 ; i++)
	{
		ans+=val((ll)(3*i+3-15*k+198)%11);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A, B = [0]*n, [0]*n
ans = 'IMPOSSIBLE'
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        A[b-1] += 1
    if b == n:
        B[a-1] += 1
if sum(B) == 0:
    print(ans)
    exit()
else:
    for i in range(n):
        if A[i] == 1 and B[i] == 1:
            ans = 'POSSIBLE'
            break
    print(ans)

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define F(n) for(int i=0;i<n;++i)
#define long long long
const int MOD=1e9+7;

long mpow(long x, long n){
    long ans=1;
    while(n!=0){
        if(n%2==1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n/2;
    }
    return ans;
}

long mfact(long n){
    long a=1;
    for(int i=2;i<=n;++i) a=a*i%MOD;
    return a;
}

long mcomb(long n,long m){
    if(n==0 && m==0) return 1;
    if(n<m || n<0) return 0;
    long ans = mfact(n)*mpow(mfact(m),MOD-2)%MOD;
    ans = ans*mpow(mfact(n-m),MOD-2)%MOD;
    return ans;
}

int main()
{
    long x,y;
    cin >> x >> y;
    if((x+y)%3!=0 || y>2*x || 2*y<x){
        cout << 0 << endl;
        return 0;
    }
    long n=(x+y)/3;
    long m=x-n;
    cout << mcomb(n,m) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[110][100010];


 
int main(){
	int N,K; cin >> N >> K;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	dp[0][0] = 1;
	rep(i,N){
		vector<ll> sum(K+2);
		rep(j,K+1){
			sum[j+1] = sum[j] + dp[i][j];
			dp[i+1][j] += sum[j+1]-sum[max(0,j-a[i])];
			dp[i+1][j] %= MOD;
		}
	}
	cout << dp[N][K] << endl;
}


Measured memory_bytes: 80124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,n=1,ans=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a==n)
      n++,ans++;
  }
  if(ans==0)
    cout<<-1<<endl;
  else
    cout<<N-ans<<endl;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))
AS = sum(A)
H = AS/2

wa = 0
for i in range(N):
    wa+=A[i]
    if wa>H:
        num = i
        R = wa
        L = wa-A[i]
        break

d = min(abs(H-R),abs(H-L))

print(int(d*2))

Measured memory_bytes: 26220
# from line_profiler import LineProfiler
from collections import deque

def main():
    while(True):
        W, H = map(int, input().split())
        if not W: break
        tx,ty = map(int, input().split())
        kx,ky = map(int, input().split())
        ma = [[False]*(W+2) for _ in range(H+2)]
        for i in range(1,H+1):
            for j,a in enumerate(input().split()):
                ma[i][j+1] = bool(1-int(a))
        from pprint import pprint
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if c > 100: break
            if tx == kx and ty == ky:
                ans = c
                break
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0]
                kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0]
                if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue
                que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])
                pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


Measured memory_bytes: 35884
//Classic
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin
#define X INT_MAX
#define N INT_MIN
////////////////////////////////////////////////////////////////


void solve() {

	int d, t, s; ciN >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




////////////////////////////////////////////////////////////////


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

	//int t; cin >> t;
	//while (t--)
	solve();


	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int l,r,d;
  cin >> l >> r >> d;
  int ret = 0;
  for(int i = l;i <= r;i++){
    if(i % d == 0)ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N, K, Q;
vector<int>A;





//サブ関数
//入力
void input()
{
	cin >> N >> K >> Q;
	A.resize(N);
	REP(i, N)cin >> A[i];
}

void append(vector<int>& mini, vector<int>& tmp)
{
	sort(tmp.begin(), tmp.end());
	if(tmp.size()>K-1)
		copy(tmp.begin(), tmp.end() - K + 1, back_inserter(mini));
	tmp.clear();
}

int X_Y(int base) {
	vector<int> mini, tmp;
	REP(i, N) {
		if (A[i] >= base) {
			tmp.push_back(A[i]);
		}
		else {
			append(mini, tmp);
		}
	}
	append(mini, tmp);

	if (mini.size() < Q)return INF;
	sort(mini.begin(), mini.end());
	return mini[Q - 1] - mini[0];
}

//計算
void calc()
{
	priority_queue<int,vector<int>,greater<int>> pq;
	set<int> si;
	for (auto num : A)si.insert(num);
	for (auto num : si)pq.push(num);

	int ans = INF;
	REP(i,N){
		int base = pq.top(); pq.pop();
		int tmp = X_Y(base);
		if (tmp == INF)break;
		ans = min(ans,tmp);
	}
	cout << ans << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int x, y;
    cin >> x >> y;
    for (int i=0; i<=x; i++){
        if (2*i + 4*(x-i) == y){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int x; cin >> x;
  if(x==7||x==5||x==3)cout << "YES";
  else cout << "NO";
  cout << endl;
}

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

int main(){
    int w,h;
    cin>>w>>h;
    ll ans=0;
    vector<ll> p(w);
    rep(i,w){
        cin>>p[i];
        ans+=p[i];
    }
    vector<ll> q(h);
    rep(i,h){
        cin>>q[i];
        ans+=q[i];
    }

    sort(ALL(p));
    sort(ALL(q));

    vector<ll> sump(w+1,0);
    vector<ll> sumq(h+1,0);

    rep(i,w){
        sump[i+1]=sump[i]+p[i];
    }
    rep(i,h){
        sumq[i+1]=sumq[i]+q[i];
    }

    //w=p,h=q
    rep(i,h){
        int idx=(lower_bound(ALL(p),q[i])-p.begin());
        idx--;
        ans+=sump[idx+1];
        ans+=q[i]*(w-idx-1);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int minb = 1001001001;
    int ans = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if (minb > b) {
            minb = b;
            ans = a + b;
        }
    }
    cout << ans << endl;
}

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


class Solver:
    def __init__(self):
        self.ans = 0

    def calc(self, cur: int, rest: str, pos: int):
        if not rest or len(rest) == pos:
            self.ans += cur + int(rest)
            return

        self.calc(cur + int(rest[:pos]), rest[pos:], 1)
        self.calc(cur, rest, pos + 1)


def main():
    S = input().strip()
    solve = Solver()
    solve.calc(0, S, 1)
    print(solve.ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define sz(x)                       (ll) x.size()
#define PB(x)                       push_back(x)
#define bs(a, x)                   binary_search(a , a + sizeof(a) / sizeof(a[0] , x)
#define ts(x)                       to_string(x)
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define bsv(a, x)                  binary_search(all(a), x)
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll dp[MAXN] , h[MAXN];
int main() {
    fast_io;
    set_random;
    ll n , k;
    cin >> n >> k;
    for (ll i = 0; i < n; i++)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (ll i = 2; i < n; i++) {
        dp[i] = INF;
        for (ll j = 1; j <= min(k , i); j++)
        {
            dp[i] = min(dp[i] , dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1792
import sys

def main(args):
    h, n = map(int,input().split())
    
    magic = [0]*n
    maxim = 0
    for i in range(n):
        dam, mp = map(int,input().split())
        magic[i] = (dam, mp)
        maxim = max(maxim, dam)
    
    damage = [float('inf')]*(2*10**4)
    damage[0] = 0
    for i in range(max(2*h, 2*maxim)):
        for m in magic:
            dam, mp = m
            damage[i] = min(damage[i-dam]+mp, damage[i])
    
    print(min(damage[h:]))

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 68380
def main():
    N = int(input())
    testimony = [[] for i in range(N)]
    for i in range(N):
        for j in range(int(input())):
            x,y = map(int,input().split())
            testimony[i].append([x-1,y])##0-indexに直す
    
    ans = 0
    for i in range(2**N):##証言について、2^N通り
        for j in range(N):##N人について検証
            flag = True
            if (i>>j)&1:##正直者である場合
                for x,y in testimony[j]:
                    if ((i>>x)&1) != y:##嘘をついている
                        flag = False
                        break
                if not flag:
                    break        
        if flag:##全員正直であった場合
            tmp = list(bin(i))
            ans = max(ans,tmp[2:].count("1"))

    print(ans)

if __name__ == "__main__":
    main()

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

int n, m;
vector <int > a[100002];
int f[100002];
int vis[100002];
int res = 0;
int cal(int u){
    if (f[u] != 0) return f[u];
    vis[u] = 1;
    for (int i=0;i<a[u].size();i++){
        if (vis[a[u][i]]) continue;
        f[u] = max(f[u], cal(a[u][i]) + 1);
        vis[a[u][i]] = 0;
    }
    res = max(res, f[u]);
    return f[u];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for (int i=1,x,y;i<=m;i++){
        cin>>x>>y;
        a[x].push_back(y);
    }
    for (int i=1;i<=n;i++){
        if (f[i] != 0) continue;
        f[i] = 0;
        cal(i);
        vis[i] = 0;
    }
    cout<<res;
}


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

const int INF = 1001001001;

using namespace std;

int main()
{
    int w, h;
    
    scanf("%d %d", &h, &w);
    
    for (int i = 0; i < h; i++){
        int ctr = INF;
        for (int j = 0; j < w; j++){
            char c;
            scanf(" %c", &c);
            ctr = (c == 'c' ? 0 : ctr + 1);
            printf("%d%c", ctr >= INF ? -1 : ctr, " \n"[j + 1 == w]);
        }
    }
    
    return (0);
}

Measured memory_bytes: 1188