akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath> 
#include<set>
#include<cctype>

using namespace std;

const int N=1e3+50;

multiset <string> v;

int a,b,c;

int main()
{
	

	cin>>a>>b>>c;
	for(int i=1;i<=a;i++)
	    v.insert("a");
	for(int i=1;i<=b;i++)
	    v.insert("b");
	for(int i=1;i<=c;i++)
	    v.insert("c");
	while(v.size()>1)
	{
		string x=*v.begin();
		string y=*v.rbegin();
		v.erase(v.lower_bound(x));
		v.erase(v.lower_bound(y));
		v.insert(x+y);  
	}
	cout<<*v.begin();
}

Measured memory_bytes: 256
use utf8;
use strict;
use feature qw(say);

chomp(my $line = <STDIN>);
my @ls = split " ", $line;
my @ref = qw/2 3 4 5 6 7 8 9 10 11 12 13 1/;
my ($a_inx) = grep { $ref[$_] == int $ls[0]} 0 .. $#ref;
my ($b_inx) = grep { $ref[$_] == int $ls[1]} 0 .. $#ref;
if ($a_inx > $b_inx){
    say "Alice\n";
}elsif($a_inx < $b_inx){
    say "Bob\n";
}else{
    say "Draw\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void PDF(int n)
{
    int c,s=0,t;
    float k;
    if(n%1000!=0)
    {
        k = (double) n/1000;
        t = ceil(k);
        s = (1000*t) - n;
    }
    cout << s<<endl;
}
int main()
{
    int n,i,j,l;
    cin >>n;
    PDF(n);
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i % 3600 / 60;
   s = i % 3600 % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}



Measured memory_bytes: 3088
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = INPUT()
    T = INPUT()
    N = len(S)

    for i in range(N):
        if S == T:
            print('Yes')
            sys.exit(0)
        else:
            S = S[N-1] + S[:N-1]

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  set<int> x;
  x.insert(a);
  x.insert(b);
  x.insert(c);
  if (x.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll n;
    cin >> n;
    vector<ul> a(n);
    rep(i,0,n) cin >> a[i];

    rep(i,0,n)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans(1); 
    constexpr ll lim (1e18);
    rep(i,0,n)
    { 
        if (a[i]<=lim/ans)
            ans *= a[i];
        else
        {
            cout << -1 << endl; 
            return 0;
        }

    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3960
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n);
    vl A(n);
    map<ll,ll>T;
    vl sum(n+1,0);
    vl nos(n+1,0);
    REP(i,n){
        inl(x);
        A[i]=x;
        T[x]++;
    }
    REP(i,n){
        ll x= T[i+1];
        sum[i+1]= x*(x-1)/2;
        nos[i+1]= (x-1)*(x-2)/2;
        if(sum[i+1]==0) nos[i+1]=0;
    }

    ll s= accumulate(all(sum),0ll);
    REP(i,n){
        out(s-sum[A[i]]+nos[A[i]]);
    }
    // out();
}

Measured memory_bytes: 19840
import math
X = int(input())

def IsBekijo(x):
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False



for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        exit()
print(1)


Measured memory_bytes: 9080
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 250005;
const ll MOD1 = 998244353;
const ll MOD2 = 1000000007;

int n;
int p[MAXN];

ll inv1,inv2,ans;

pair<ll,ll> h[MAXN];
pair<ll,ll> pw[MAXN];
pair<ll,ll> rpw[MAXN];

char s[MAXN];

map<pair<ll,ll>,int> cnt;

ll power(ll a,ll b,ll p)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			(res *= a) %= p;
		(a *= a) %= p;
		b >>= 1;
	}
	return res;
}

pair<ll,ll> getv(int t)
{
	return t >= 0 ? pw[t] : rpw[-t];
}

pair<ll,ll> mul(pair<ll,ll> a,pair<ll,ll> b)
{
	return make_pair(a.first * b.first % MOD1,a.second * b.second % MOD2);
}

pair<ll,ll> add(pair<ll,ll> a,pair<ll,ll> b)
{
	return make_pair((a.first + b.first) % MOD1,(a.second + b.second) % MOD2);
}

pair<ll,ll> sub(pair<ll,ll> a,pair<ll,ll> b)
{
	return make_pair((a.first - b.first) % MOD1,(a.second - b.second) % MOD2);
}

int main()
{
	scanf("%d%s",&n,s + 1);
	inv1 = power(786433,MOD1 - 2,MOD1);
	inv2 = power(786433,MOD2 - 2,MOD2);
	pw[0] = make_pair(1,1);
	for (int i = 1;i <= n;i++)
		pw[i] = mul(pw[i - 1],make_pair(786433,786433));
	rpw[0] = make_pair(1,1);
	for (int i = 1;i <= n;i++)
		rpw[i] = mul(rpw[i - 1],make_pair(inv1,inv2));
	for (int i = 1;i <= n;i++)
	{
		if (s[i] == '+')
		{
			p[i] = p[i - 1];
			h[i] = add(h[i - 1],getv(p[i]));
		}
		if (s[i] == '-')
		{
			p[i] = p[i - 1];
			h[i] = sub(h[i - 1],getv(p[i]));
		}
		if (s[i] == '<')
		{
			h[i] = h[i - 1];
			p[i] = p[i - 1] - 1;
		}
		if (s[i] == '>')
		{
			h[i] = h[i - 1];
			p[i] = p[i - 1] + 1;
		}
	}
	for (int i = n;i >= 1;i--)
	{
		(h[i].first += MOD1) %= MOD1;
		(h[i].second += MOD2) %= MOD2;
	}
	for (int i = n;i >= 1;i--)
	{
		cnt[h[i]]++;
		ans += cnt[add(mul(h[n],getv(p[i - 1])),h[i - 1])];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 44416
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define umi unordered_map<int,int>
#define uml unordered_map<ll,ll>
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"

ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

ll gcd(ll a, ll b)
{ 
	return !b ? a : gcd(b, a % b); 
}
ll lcm(ll a, ll b)
{ 
	return (a / gcd(a, b)) * b; 
}
ll fastExponentiation(ll n, ll x, ll modulo) 
{
	ll res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}


ll power(ll n , ll p ){
	if(p==0)
	   return 1;
 
	 ll res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 

int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 

double diff(double n,double mid) 
{ 
    if (n > (mid*mid*mid)) 
        return (n-(mid*mid*mid)); 
    else
        return ((mid*mid*mid) - n); 
} 

double cubicRoot(double n) 
{ 
    double start = 0, end = n,e = 0.0000001; 
    while (true) 
    { 
        double mid = (start + end)/2; 
        double error = diff(n, mid); 
 
        if (error <= e) 
            return mid; 
 
        if ((mid*mid*mid) > n) 
            end = mid; 
        else
            start = mid; 
    } 
} 


void solve()
{
    cout<<fixed<<setprecision(20)<<endl;
	double n;
	cin>>n;
	
	double ans=n/3;
	
	ans=ans*ans*ans;
	cout<<ans<<endl;
	
}


int main()
{
	fastio
	
	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long num[45];
vector<int>v;
void cal(long long x)
{
    v.clear();
    while(x)
    {
        v.push_back(x%2);
        x>>=1;
    }
    long long t=0;
    for(int i=0;i<v.size();i++)
    {
        if(v[i]==1)
        {
            for(int j=0;j<i;j++)
                num[j]+=(1ll<<i)/2;
            num[i]+=t+1;
        }
        t+=v[i]*(1ll<<i);
    }
}
int main()
{
    long long a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    cal(b);
    for(int i=0;i<=40;i++)
        num[i]*=-1;
    if(a) cal(a-1);
    for(int i=0;i<=40;i++)
        num[i]*=-1,ans+=num[i]%2*(1ll<<i);
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
import sys

n, m = [int(i) for i in input().split()]
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for ai in range(n - m + 1):
    for aj in range(n - m + 1):
        can = True
        for bi in range(m):
            if a[ai+bi][aj:aj+m] != b[bi]:
                can = False
                break
        if can:
            print('Yes')
            sys.exit(0)

print('No')

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

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

const long long INF = 1LL << 60;

int main(){

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

	long long dp[100010];

	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	// 初期条件
	dp[0] = 0;

	// ループ
	for (int i = 1; i < N; ++i) {
    	chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
		if(i>1) chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
	}

	cout << dp[N-1] << endl;

	}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int solve(int Y, const vector<int>& v, int K, int Q){
  vector<vector<int>> w;
  vector<int> tmp;
  rep(i,v.size()){
    if(v[i] >= Y){
      tmp.push_back(v[i]);
    }else{
      if(tmp.size() > 0) w.push_back(tmp);
      tmp.clear();
    }
  }
  if(tmp.size() > 0) w.push_back(tmp);

  vector<int> ww;
  rep(i,w.size()){
    if(w[i].size() >= K){
      sort(ALLOF(w[i]));
      rep(j,w[i].size()-K+1){
        ww.push_back(w[i][j]);
      }
    }
  }

  if(ww.size() < Q) return 1000000005;
  
  sort(ALLOF(ww));
  
  return ww[Q-1] - ww[0];
}

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  int ret = 1000000005;
  rep(i,N){
    int Y = v[i];
    ret = min(ret, solve(Y, v, K, Q));
  }

  cout << ret << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;

const int MAXV = 200, INF = 100000000;
int d[MAXV][MAXV]; // d[u][v]は辺(u, v)のコスト、存在しない場合はINF
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(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int M, R; cin >> V >> M >> R;
  int r[R];
  for(int i=0;i<R;i++){
    int tr; cin >> tr;
    r[i] = tr - 1;
  }
  // initialize d
  for(int i=0;i<V;i++){
    for(int j=0;j<V;j++){
      if(i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  for(int i=0;i<M;i++){
    int a, b;
    ll c; cin >> a >> b >> c;
    d[a-1][b-1] = c;
    d[b-1][a-1] = c;
  }
  warshall_floyd();
  vector<int> order;
  for(int i=0;i<R;i++) order.push_back(i);
  sort(order.begin(), order.end());
  int mintotal = INF;
  int total = 0;
  do{
    total = 0;
    /*
    for(int i=0;i<R;i++){
      cout << order[i] << " ";
    }
    cout << endl;
    */
    for(int i=1;i<=R-1;i++){
      total += d[r[order[i]]][r[order[i-1]]];
    }
    mintotal = min(mintotal, total);
  }while(next_permutation(order.begin(), order.end()));
  cout << mintotal << endl;
}

Measured memory_bytes: 384
N = int(input())
ab_list = [list(map(int, input().split())) for _ in range(N)]

# print(ab_list)

ab_list = sorted(ab_list, key = lambda x:x[1])

time = 0
for a, b in ab_list:
  time = time + a
  if time > b:
    print("No")
    exit()
    
print("Yes")

Measured memory_bytes: 55264
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    string ans;
    if (a<=0&&b>=0) ans = "Zero";
    else if (a>=1) ans = "Positive";
    else {
        if ((b-a+1)%2==1) ans = "Negative";
        else ans = "Positive";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long int

using namespace std; 

int main() 
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i=0; i<s.length(); i++){
    	s[i] += n;
    	if (s[i] > 90){
    		s[i] -= 26;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


// 八方向への移動ベクトル
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int n;
  cin >> n;
  
  if(n==2) {
    cout << 0 << endl;
    return 0;
  }

  int ans=0;

  vector<vector<bool>> p(n,vector<bool>(n,true));
  vector<vector<int>> dist(n,vector<int>(n));
  deque<pair<int,int>> que;

  rep(i,n){
    rep(j,n){
      dist[i][j]=min({i,j,n-1-i,n-1-j});
    }
  }

  rep(i,n*n) {
    int x;
    cin>>x;
    int a =(x-1)/n;
    int b =(x-1)%n;
    ans+=dist[a][b];
    p[a][b]=false;

    auto q=mp(a,b);
    que.pb(q);


    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pair<int,int> v = que.front(); // キューから先頭頂点を取り出す
        que.pop_front();

        //vの上下左右をすべて調べる
        rep(j,4) {
          int nh = v.fi + dx[j];
          int nw = v.se + dy[j];

          // 場外アウトしたり、移動先が壁の場合はスルー
          if (nh < 0 || nh >= n || nw < 0 || nw >= n) continue;        
          
          if(p[v.fi][v.se]==false){
            if(dist[nh][nw]>dist[v.fi][v.se]) {
              dist[nh][nw]=dist[v.fi][v.se];
              auto z=mp(nh,nw);
              que.pb(z);
            }
          }
          if(p[v.fi][v.se]){
            if(dist[nh][nw]>dist[v.fi][v.se]+1) {
              dist[nh][nw]=dist[v.fi][v.se]+1;
              auto z=mp(nh,nw);
              que.pb(z);
            }
          }          
        }        
    }
  }

  cout << ans << endl;       
}

Measured memory_bytes: 4664
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        h: [u64; n],
    }
    let mut ans = 0;
    let mut acc = 0;
    for i in (1..n).rev() {
        if h[i] <= h[i - 1] {
            acc += 1;
        } else {
            ans = max(ans, acc);
            acc = 0;
        }
    }
    ans = max(ans, acc);

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


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

int num(int N)
{
  int C = (int)sqrt(N);
  int count = 0;
  
  if(C * C == N)
  {
    for(int i = 1; i < C; i++)
    {
      if(N % i == 0) count += 2;
    }
    count++;
  }
  else
  {
    for(int i = 1; i <= C; i++)
    {
      if(N % i == 0) count += 2;
    }
  }
  return count;
}

int solve(int N)
{
  if(N == 2) return 1;
  else return num(N - 1) + solve(N - 1);
}

int main()
{
  int N;
  cin >> N;
  
  cout << solve(N) << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = long double;
#define pb push_back
#define x first
#define y second
using pii = pair<int,int>;

const db pi = 3.1415926535897932384626433832795L;

void minto(int &a, int b) { a = min(a, b); }

int n;
pii s, t;
vector<pii> a;

db dist(pii a, pii b) {
	return (abs(a.x - b.x) + abs(a.y - b.y)) * 100.0L;
}

int main() {
	cin >> s.x >> s.y >> t.x >> t.y;
	cin >> n;
	cout.setf(ios::fixed);
	cout.precision(15);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		a.pb({x, y});
	}
	
	/*if (s.x == t.x || s.y == t.y) {
		if (s.y == t.y) {
			swap(s.x, s.y);
			swap(t.x, t.y);
			for (auto &i : a)
				swap(i.x, i.y);
		}
		
		if (s.y > t.y)
			swap(s, t);
		
		int cnt = 0;
		for (auto i : a)
			if (i.x == s.x && s.y <= i.y && i.y <= t.y)
				++cnt;
		
		cout << dist(s, t) + cnt * (-20.0L + 10.0L * pi) << endl;
		
		return 0;
	}*/
	
	if (s.x > t.x)
		swap(s, t);
	
	if (s.y > t.y) {
		auto tr = [](int &x) {
			x = -x;
		};
		tr(s.y);
		tr(t.y);
		for (auto &i : a)
			tr(i.y);
	}
	
	sort(a.begin(), a.end());
	
	vi f(n + 1, INT_MAX);
	f[0] = INT_MIN;
	for (auto i : a) if (s.x <= i.x && i.x <= t.x && s.y <= i.y && i.y <= t.y)
		minto(*upper_bound(f.begin(), f.end(), i.y), i.y);
	
	int cnt = find(f.begin(), f.end(), INT_MAX) - f.begin() - 1;
	
	db p = 0;
	if (cnt == min(abs(s.x - t.x), abs(s.y - t.y)) + 1) {
		--cnt;
		p = (-20.0L + 10.0L * pi);
	}
	
	cout << dist(s, t) + cnt * (-20.0L + 5.0L * pi) + p << endl;
	
	return 0;
}


Measured memory_bytes: 2672
using System;

public class Test
{
    public static void Main()
    {
        int a, b;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);

        if (a < b)
        {
            Console.WriteLine("a < b");
        }

        else if (a > b)
        {
            Console.WriteLine("a > b");
        }

        else
        {
            Console.WriteLine("a == b");
        }

    }
}


Measured memory_bytes: 15944
#include <cstdio>

using namespace std;

int main()
{
    int amount;
    int change[] = {500, 100, 50, 10, 5, 1};

    while (scanf("%d", &amount), amount){
        int money = 1000;
        money -= amount;
        int count = 0;
        int i = 0;

        while (i < 6){
            if (money - change[i] >= 0){
                money -= change[i];
                count++;
            }
            else {
                i++;
            }
        }

        printf("%d\n", count);
    }

    return (0);
}

Measured memory_bytes: 1028
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	sort.Sort(sort.IntSlice(list))
	result := "No"
	total := 0
	for i := 0; i < n-1; i++ {
		total += list[i]
	}
	if total > list[n-1] {
		result = "Yes"
	}
	fmt.Println(result)

}


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

int main() {
  int64_t n, t, a, b;
  cin >> n;
  t = pow(n, 0.5) / 1;
  for(int i = t; i > 0; --i){
    if(n % i == 0){
      a = n / i;
      b = i;
      break;
    }
  }
  cout << a + b - 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
  int N;
  int K;
  int x;
  int i;
  int ans;
  cin >> N;
  cin >> K;
  for(i=1;i<=N;i++){
    cin >> x;
    ans += 2*min(abs(K-x), abs(x-0));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        
        var NM = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        //展望台の数
        var N = NM[0];
        //道の数
        var M = NM[1];
        //高さを高さ配列に保持する
        var height = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        var conn = new Dictionary<int,List<int>>();
        var havePath = new bool[N];
        for(int num = 0;num < M;num++)
        {
            var path = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
            var A = path[0];
            var B = path[1];
            if(!conn.ContainsKey(A))
            {
                conn[A] = new List<int>();
                conn[A].Add(B);
            }
            else
            {
                conn[A].Add(B);
            }
            if(!conn.ContainsKey(B))
            {
                conn[B] = new List<int>();
                conn[B].Add(A);
            }
            else
            {
                conn[B].Add(A);
            }
            havePath[A-1]=true;
            havePath[B-1]=true;
        }
        var ans = 0;
        foreach(var c in conn)
        {
            var heightNow = height[c.Key-1];
            var flg = true;
            foreach(var val in c.Value)
            {
                if(heightNow <= height[val-1])
                {
                    flg =false;
                    break;
                }
            }
            if(flg)
            {
                ans++;
            }
        }
        Console.WriteLine(ans + havePath.Count(e => e == false));
    }
}


Measured memory_bytes: 59836
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll=long long;
long long modpow(long long a, long long n, long long mod=1e9+7) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    const int MOD=1e9+7;
    int n,k;
    cin>>n>>k;
    vector<ll> cnt(k+1);
    int now=0;
    cnt[0]=0;
    cnt[1]=1;
    for(int i=2;i<=k;i++){
        for(int j=1;j<=sqrt(i);j++){
            if(i%j==0){
                if(j!=1){
                    now-=cnt[(i-1)/j];
                    now%=MOD;
                    now+=cnt[i/j];
                    now%=MOD;
                }
                if(i!=j*j){
                    now-=cnt[(i-1)/(i/j)];
                    now%=MOD;
                    now+=cnt[i/(i/j)];
                    now%=MOD;
                }
            }
        }
        cnt[i]=(modpow(i,n)-now)%MOD;
    }
    ll ret=0;
    for(int i=1;i<=k;i++){
        ret+=i*cnt[k/i];
        ret%=MOD;
    }
    cout<<ret<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		long count=Arrays.asList((new Scanner(System.in)).nextLine().split(""))
				.stream()
				.filter(s->s.equals("1"))
				.count();
		System.out.println(count);

	}

}


Measured memory_bytes: 27092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        int r[] = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = sc.nextInt();
        }
        long max = -1000000010;
        long min = r[0];
        for (int i = 1; i < n; i++) {
            if (r[i] - min > max)
                max = r[i] - min;
            if (r[i] < min)
                min = r[i];
        }
        System.out.println(max);
        sc.close();
    }
}


Measured memory_bytes: 100784
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n,a =0,b =0,c=0;
    cin >> n;
    vector <int> p(n),q(n),np(n);
    for (int i = 0; i < n; ++i)
    {
    	np[i] = i+1;
    }
   	for (int i = 0; i < n; ++i)
   	{
   		cin >> p[i];
   	}
   	for (int i = 0; i < n; ++i)
   	{
   		cin >> q[i];
   	}
   	do
   	{
   		c++;
   		if(np == p)
   			a = c;	
   		if(np == q)
   			b = c;
   	}
   	while(next_permutation(np.begin(),np.end()));
   	cout << abs(a-b);
   	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size();
    vll used(26);
    REP(i, n){
        if(used[s[i] - 'a']){
            cout << "no" << endl;
            return 0;
        }
        used[s[i] - 'a']++;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
#define Iter(c) __typeof__((c).begin())
#define foreach(i,c) for(Iter(c) i = (c).begin();i != (c).end();++i)
#define Right 1
#define Left 3
#define Top 2
#define Bottom 0
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int R,C;
char cmap[20][20];
bool used[20][20][16][4];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void move(P *coor,int dir,int mem){
  if(!(0<= (*coor).F+dx[dir] && (*coor).F+dx[dir] < C && 0<= (*coor).S+dy[dir] && (*coor).S+dy[dir] < R)){
    if(!(0<= (*coor).F+dx[dir] && (*coor).F+dx[dir] < C)){
      if((*coor).F+dx[dir] >= C){
	(*coor).F = 0;
      }
      else if((*coor).F+dx[dir] < 0){
	(*coor).F = C-1;
      }
      else assert(false);
    }
    else if(!(0<= (*coor).S+dy[dir] && (*coor).S+dy[dir] < R)){
      if((*coor).S+dy[dir] >= R){
	(*coor).S = 0;
      }
      else if((*coor).S+dy[dir] < 0){
	(*coor).S = R-1;
      }
      else assert(false);
    }
    else assert(false);

  }
  else (*coor).F += dx[dir],(*coor).S += dy[dir];
 
}


int main(){
 
  cin >> R >> C;
  
  
  rep(i,R){
    string s;
    cin >> s;
    rep(j,C){
      cmap[i][j] = s[j];
      rep(k,16)
	rep(l,4)used[i][j][k][l] = false;
    }
  }

  
  queue<PP> que;
  que.push(PP(P(0,0),P(0,1)));//PP(P(x,y),P(memory,direction))
  //used[0][0][0][1] = true;

  while(!que.empty()){
    PP pi = que.front(); que.pop();
    P coor = pi.F;
    int mem = pi.S.F;
    int dir = pi.S.S;
    //cout << cmap[coor.S][coor.F] << " : coor(" << coor.F << "," << coor.S << ") , mem: " << mem << ", dir : "  << dir << endl;
    if(cmap[coor.S][coor.F] == '@'){
      cout << "YES" << endl;
      return 0;
    }

    if(used[coor.S][coor.F][mem][dir])continue;
    used[coor.S][coor.F][mem][dir] = true;

    if('0' <= cmap[coor.S][coor.F] && cmap[coor.S][coor.F] <= '9'){
      mem = (int)(cmap[coor.S][coor.F]-'0');
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '.'){
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '+'){
      mem = (mem+1)%16;
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '-'){
      mem--;
      if(mem < 0)mem = 15;
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '_'){
      dir = !mem?1:3;
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '|'){
      dir = !mem?0:2;
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    }
    else if(cmap[coor.S][coor.F] == '?'){
      rep(i,4){
	P coor_bk = coor;
	move(&coor_bk,i,mem);
	que.push(PP(coor_bk,P(mem,i)));
      }
    }
    else {
      dir = cmap[coor.S][coor.F] =='<'?Left:cmap[coor.S][coor.F] == '>'?Right:cmap[coor.S][coor.F] == '^'?Top:Bottom;
      move(&coor,dir,mem);
      que.push(PP(coor,P(mem,dir)));
    } 
  }
  cout << "NO" << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int m = N/2;
    int x[N], y[N];
    rep(i, N) {
        cin >> x[i];
        y[i] = x[i];
    }

    sort(y, y+N);

    int p = y[m-1];
    int q = y[m];

    rep(i, N) {
        if(x[i] <= p) {
            cout << q << "\n";
        }
        else {
            cout << p << "\n";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a.sort(reverse=True)

    if n % 2 == 0:
        print(even_pattern(a))
    else:
        print(max(odd_pattern1(a), odd_pattern2(a)))

def odd_pattern1(a):
    m = len(a) // 2
    s = 0
    s += 2 * sum(a[:m])
    s -= sum(a[m:m+2])
    s -= 2 * sum(a[m+2:])
    return s

def odd_pattern2(a):
    m = len(a) // 2 - 1
    s = 0
    s += 2 * sum(a[:m])
    s += sum(a[m:m+2])
    s -= 2 * sum(a[m+2:])
    return s

def even_pattern(a):
    m = len(a) // 2 - 1
    s = 0
    s += 2 * sum(a[:m])
    s += a[m]
    s -= a[m+1]
    s -= 2 * sum(a[m+2:])
    return s

main()


Measured memory_bytes: 7516
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	C := Int(s)

	nums := []int{A, B, C}

	maxNum, index := max(nums)
	diff := 0
	for i, num := range nums {
		if i == index {
			continue
		}
		diff += maxNum - num
	}
	if diff%2 != 0 {
		diff += 3
	}
	fmt.Println(diff / 2)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func max(nums []int) (int, int) {
	res := nums[0]
	index := 0
	for i, num := range nums {
		if res < num {
			res = num
			index = i
		}
	}
	return res, index
}

Measured memory_bytes: 640
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

h,w = ma()
A = []
for i in range(h):
    A.append(lma())
B= []
for i in range(h):
    B.append(lma())
D = [[abs(A[i][j]-B[i][j]) for j in range(w)] for i in range(h)]
mx = 0
for i in range(h):
    for j in range(w):
        mx = max(mx,D[i][j])

le = (h+w)*mx
prev = [0]*w
nex = [0]*w
prev[0]=prev[0] | 2**le
for i in range(h):
    for j in range(w):
        d = D[i][j]
        if j==0:
            nex[j] = nex[j] | prev[j]>>d |prev[j]<<d
        else:
            nex[j] = nex[j] | prev[j]>>d |prev[j]<<d
            nex[j] = nex[j] | nex[j-1]>>d |nex[j-1]<<d
        #print(i,j,d,bin(nex[j]))
    prev=nex
    nex = [0]*w
for i in range(le+1):
    if (prev[w-1]>>le+i &1) or (prev[w-1]>>le-i &1):
        print(i)
        exit()


Measured memory_bytes: 77584
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)

#define MAX_L 1000

int DP[MAX_L+1][MAX_L+1];

int max(int a, int b) {
	if (a > b) return a;
	return b;
}

int main(void) {
	int n;
	scanf("%d", &n);
	char X[MAX_L + 1];
	char Y[MAX_L + 1];
	for (int i = 0; i < n; ++i) {
		scanf("%s", &X[0]);
		scanf("%s", &Y[0]);
		int xl = strlen(X);
		int yl = strlen(Y);

		for (int j = 0; j < yl; ++j) {
			for (int i = 0; i < xl; ++i) {
				if (X[i] == Y[j]) {
					DP[j + 1][i + 1] = DP[j][i] + 1;
				}
				else {
					DP[j + 1][i + 1] = max(DP[j][i + 1], DP[j + 1][i]);
				}
			}
		}
		printf("%d\n", DP[yl][xl]);

	}

	return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read(a,n) rep(i,n)cin>>a[i]

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li d[100100];

int main() {
    cin >> n;
    read(d, n);

    sort(d, d + n);

    li res = 0;
    rep(i, 100001) {
        li num = d + n - lower_bound(d, d + n, i);
        if (num == n / 2) {
            res++;
        }
        if (num < n / 2) {
            break;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int co = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] * 4 * m >= sum) {
            co++;
        }
    }
    if (co >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int vx=x2-x1,vy=y2-y1;
  int x3=x2-vy,y3=y2+vx;
  int x4=x3-vx,y4=y3-vy;

  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<" "<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define NUM 1000

int main()
{
  int N;
  int i,j,k;
  int A[NUM];
  int v;

  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
  printf("%d",A[0]);
  for(i = 1;i < N;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  for(i = 1;i < N;i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    printf("%d",A[0]);
    for(k = 1;k < N;k++){
      printf(" %d",A[k]);
    }
    printf("\n");
  }

  return 0;
}
  



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

int main()
{
    int k, a, b; cin >> k >> a >> b;

    bool can = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) can = true;
    }

    if (can) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int n, q;
vector<i64> c;
vector<vector<int>> g;
void dfs(int u, int p) {
    for (int v : g[u]) {
        if (v != p) {
            c[v] += c[u];
            dfs(v, u);
        }
    }
}
int main() {
    cin >> n >> q;
    g.resize(n + 1);
    c.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        c[p] += x;
    }
    dfs(1, 0);
    for (int u = 1; u <= n; ++u) {
        cout << c[u] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<math.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> cc(h, vector<char>(w));
	rep(i, h)rep(t, w) cin >> cc[i][t];
	vector<vector<char>> c(h, vector<char>(w));
	int ans = 0;

	for (int biti = 0; biti < (1<<h); biti++)
	{
		for (int bitt = 0; bitt < (1<<w); bitt++)
		{
			rep(ii, h)rep(tt, w) c[ii][tt] = cc[ii][tt];

			for (int i = 0; i < h; i++)
			{
				if (biti & (1 << i))
				{
					for (int x=0; x < w; x++)
					{
						c[i][x] = '?';
					}
				}
			}
			
			for (int t = 0; t < w; t++)
			{
				if (bitt & (1 << t))
				{
					for (int y = 0; y < h; y++)
					{
						c[y][t] = '*';
					}
				}
			}
			          
			int count = 0;
			rep(p, h)rep(q, w)
			{
				if (c[p][q] == '#') count++;
			}
			if (count == k) ans++;
		}
	}

	cout << ans;	
	return 0;
}

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

struct SCC {
public:
    SCC(vector<vector<int>>& G) : G(G), comp(G.size(), -1), visited(G.size()), G_rev(G.size()) {
        for (int u = 0; u < G.size(); u++) {
            for (int v : G[u]) G_rev[v].push_back(u);
        }

        for (int v = 0; v < G.size(); v++) dfs(v);
        reverse(order.begin(), order.end());
        int c = 0;
        for (int v : order) if (comp[v] == -1) rdfs(v, c++);
    }

    int operator[](int k) const {
        return comp[k];
    }

private:
    vector<vector<int>> G, G_rev;
    vector<int> comp, order;
    vector<bool> visited;

    void dfs(int u) {
        if (visited[u]) return;
        visited[u] = true;
        for (int v : G[u]) dfs(v);
        order.push_back(u);
    }

    void rdfs(int u, int c) {
        if (comp[u] != -1) return;
        comp[u] = c;
        for (int v : G_rev[u]) rdfs(v, c);
    }
};

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

    int N, D;
    cin >> N >> D;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    vector<vector<int>> G(2*N);
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (abs(X[i] - X[j]) < D) {
                G[i].push_back(N + j);
                G[j].push_back(N + i);
            }
            if (abs(X[i] - Y[j]) < D) {
                G[i].push_back(j);
                G[N + j].push_back(N + i);
            }
            if (abs(Y[i] - X[j]) < D) {
                G[N + i].push_back(N + j);
                G[j].push_back(i);
            }
            if (abs(Y[i] - Y[j]) < D) {
                G[N + i].push_back(j);
                G[N + j].push_back(i);
            }
        }
    }
    SCC scc(G);
    for (int i = 0; i < N; i++) {
        if (scc[i] == scc[N + i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < N; i++) {
        if (scc[i] > scc[N + i]) cout << X[i];
        else cout << Y[i];
        cout << "\n";
    }
}

Measured memory_bytes: 3900
def main():
    n = int(input())
    coins = list(map(float,input().split()))
    dp = [[0 for i in range(n+1)] for j in range(n+1)]

    dp[0][0] = 1
        
    for pos in range(1,n+1):
        for heads in range(pos+1):
            if heads == 0:
                dp[pos][heads] = dp[pos-1][heads]*(1-coins[pos-1])
            else:
                dp[pos][heads] = dp[pos-1][heads]*(1-coins[pos-1])
                dp[pos][heads] += dp[pos-1][heads-1]*coins[pos-1]

    
    print(sum(dp[-1][(n+1)//2:]))

main()


Measured memory_bytes: 261512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define SZ(X) ((int)(X).size())

int32_t main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout <<  max(max(a*c, b*d), max(a*d, b*c)) << '\n';
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
#define mod 1000000007
signed main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a!=0)cout<<b/x-(a-1)/x<<endl;
    else if(a==0&&b==0)cout<<1<<endl;
    else cout<<b/x+1<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]

    for i in range(K, N):
        if A[i-K] < A[i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 94208