akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      int n;
      cin>>n;
      int a[n+2];
      FOR(i,1,n-1)cin>>a[i];
      a[0]=INT32_MAX;
      a[n]=INT32_MAX;
      int c[n+1];
      ll sum=0;
      for(int i=1;i<=n;i++)
      {
          c[i-1]=min(a[i],a[i-1]);
          sum+=c[i-1];
      }
      cout<<sum<<"\n";  
      
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int N = 5e5 + 15 ;
using namespace std ;

char s[N] ;
int a[N] ;

int main() {
	scanf("%s", s + 1) ;
	a[0] = strlen(s + 1) ;
	int L = a[0], sum = 0 ; 
	rep(i, 1, a[0]) a[a[0] - i + 1] = s[i] - '0' ;
	rep(i, 1, a[0]) a[i] *= 9 ;
	rep(i, 1, a[0]) {
		a[i + 1] += a[i] / 10 ;
		a[i] %= 10, sum += a[i] ;
		if (a[a[0] + 1]) ++ a[0] ;
	}
	rep(k, 1, L) {
		a[1] += 9, sum += 9 ; 
		rep(i, 1, a[0]) {
			if (a[i] / 10 == 0) break ; 
			a[i + 1] += a[i] / 10, sum += a[i] / 10 ;
			sum -= a[i], a[i] %= 10, sum += a[i] ;
			if (a[a[0] + 1]) ++ a[0] ;
		}
		if (sum <= 9 * k) {
			printf("%d\n", k) ;
			return 0 ;
		}
	}
	return 0 ; 
}

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

int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int ans1=a[n-1];
    int ans2=0;
    auto iter=lower_bound(a.begin(),a.end(),ans1/2);
    int index=iter-a.begin();
    if(abs(a[index-1]-ans1/2)<abs(a[index]-ans1/2)){
        if(a[index-1]==ans1) ans2=a[index];
        else ans2=a[index-1];
    }
    else{
        if(a[index]==ans1) ans2=a[index-1];
        else ans2=a[index];
    }
    cout<<ans1<<' '<<ans2<<endl;
}

Measured memory_bytes: 640
/*只要保证这个颜色开始的第一个填在第一个空位上
之后的都随便填即可
所以方案数就是C(空格位置-1,数量-1),组合意义就是这个颜色的小球中有一个小球填的位置是被钦定的，然后有一个空位也是被钦定填的，所以都要-1*/
#include<bits/stdc++.h>
#define Mod 1000000007
#define N 2005
#define M N*N
using namespace std;
int n,K,dp[N][N],fac[M],inv[M];
inline int ksm(int x,int y){
	int ans1=1;while (y){
		if (y&1) ans1=1ll*ans1*x%Mod;
		y>>=1;x=1ll*x*x%Mod;
	}return ans1;
}
inline int C(int n,int m){return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;}
int main(){
	scanf("%d%d",&n,&K);
	if (K==1) return puts("1"),0;dp[0][0]=1;
	fac[0]=1;for (int i=1;i<M;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[M-1]=ksm(fac[M-1],Mod-2);
	for (int i=M-2;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=i;j++){
			if (i) dp[i][j]=1ll*(dp[i][j]+dp[i-1][j])%Mod;
			if (j) dp[i][j]=1ll*(1ll*dp[i][j-1]*C(n*K-i-(j-1)*(K-1)-1,K-2)%Mod+dp[i][j])%Mod;
		}
	}
	printf("%lld\n",1ll*dp[n][n]*fac[n]%Mod);//颜色序列有n!种排列 
	return 0;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
set<int> s;
int main()
{
	cin>>a>>b>>c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size()==2) cout<<"Yes";
	else cout<<"No";
	return 0; 
}


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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  string s;
  cin >> s;
  int ret = (s[0] == '1')+(s[1] == '1')+(s[2] == '1');
  cout << ret << endl;
}


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

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;
 int dp[n+1][3]={0},a[n+1][3];
 for(int i=1;i<=n;i++)
 {
      cin>>a[i][0]>>a[i][1]>>a[i][2];
 }
 for(int i=1;i<=n;i++)
 {
      for(int k=0;k<3;k++)
      {
           for(int l=0;l<3;l++)
           {
                if(k!=l)
                dp[i][k]=max(dp[i][k],a[i][k]+dp[i-1][l]);
           }
      }
 }
 int ans=max(dp[n][0],dp[n][1]);
 ans=max(ans,dp[n][2]);
 cout<<ans;
} 

Measured memory_bytes: 4992
N = gets.to_i
W = gets.split.map(&:to_i)

abs = []
(0...N-1).each do |n|
  calc = (W.slice(0..n).inject(:+) - W.slice(n+1..-1).inject(:+)).abs
  (puts 0 ; exit ) if calc == 0
  abs << calc
end

puts abs.min

Measured memory_bytes: 1788
#include <bits/stdc++.h> 
#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

vector<ll>x;

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

   int N,K;
   cin>>N>>K;

   ll zero = 0;
   for(int i=K;i<=N;i+=K){
      zero++;
   }
   zero=pow(zero,3);
   ll half = 0;
   if(K%2==0){
      for(int i=K/2;i<=N;i+=K){
         half++;
      }
   half=pow(half,3);
   }

   cout<<zero+half<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  long double a,b,h,m;
  cin >> a >> b >> h >> m;
  long double pi;
  pi=M_PI;
  long double x;
  x=h*30-11*m/2;
  long double y=x*pi/180;
  long double ans=sqrt(a*a+b*b-2*a*b*cos(y));
  cout << setprecision(15) <<ans;
    
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;
const int N = 10000001;

bool sieve[N] = {true, true};
int main()
{
  for (int i = 2; i * i < N; i++){
    if (sieve[i]) continue;
    for (int j = i * i; j < N; j += i) sieve[j] = true;
  }
  int n;
  while (n = in()){
    int l, r;
    l = r = 0;
    while (sieve[n - l]) l++;
    while (sieve[n + r]) r++;
    printf("%d\n", l + r);
  }

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val,typename Number>
//use ll or int for gcd
Val gcd(Val a, Val b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->push_back(make_pair(count,A->at(i)));
        count = 1;
      }
    }else{
      R->push_back(make_pair(count,A->at(i)));
      count = 1;
    }
  }
}

//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  vector<int> detA(N);
  ll total = 0;
  rep(i,N){
    cin>>A.at(i);
    if(i==0){
      detA.at(i)=abs(A.at(i));
    }else{
      detA.at(i)=abs(A.at(i)-A.at(i-1));
    }
    total+=detA.at(i);
  }
  A.push_back(0);
  detA.push_back(abs(A.at(N-1)));
  total+=detA.at(N);

  rep(i,N){
    ll ans;
    if(i==0){
      ans = total-detA.at(0)-detA.at(1)+abs(A.at(i+1));
    }else{
      ans = total-detA.at(i)-detA.at(i+1)+abs(A.at(i+1)-A.at(i-1));
    }
    cout<<ans<<endl;
  }


}


Measured memory_bytes: 2032
#include <stdio.h>

int main(void)
{
	//iはループ変数、indexは添字、input_valueは入力値を格納
	int i, index;
	int input_value[10000];

	//初期値は0
	index = 0;

	while(1){
		scanf("%d", &input_value[index]);
		//入力値が0ならばループを抜ける
		if(input_value[index] == 0){
			break;
		}
		index++;
	}

	//入力した回数だけ出力する
	for(i = 0; i < index; i++){
		printf("Case %d: %d\n", (i + 1), input_value[i]);
	}

	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.first,", ",x.second,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int block_size = 710;
vi arr;

ll cur = 0;
ll occ [500100] = {0};

inline void add(ll val) {
	if (occ[val] == 0) ++cur;
	occ[val]++;
}

inline void remove(ll val) {
	if (occ[val] == 1) --cur;
	occ[val]--;
}

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

	int N, T; cin >> N >> T;
	arr.resize(N);
	F0R(i, N) cin >> arr[i];
	vector<pair<pii, int>> queries (T);
	F0R(i, T) {
		int l, r; cin >> l >> r; --l; --r;
		queries[i] = {{l, r}, i};
	}

	sort(queries.begin(), queries.end(), [] (const auto& lhs, const auto& rhs) {
		pii q1 = lhs.first;
		pii q2 = rhs.first;
		if ((q1.first / block_size) != (q2.first / block_size)) 
			return (q1.first / block_size) < (q2.first / block_size);
		return q1.second < q2.second;
	});
	
	vll ans (T);

	int curL = 0;
	int curR = 0;
	add(arr[0]);
	for (pair<pii, int> qu : queries) {
		pii q = qu.first;
		
		while (curL < q.first) {
			remove(arr[curL]);
			++curL;
		}
		while (curL > q.first) {
			--curL;
			add(arr[curL]);
		}
		while (curR < q.second) {
			++curR;
			add(arr[curR]);
		}
		while (curR > q.second) {
			remove(arr[curR]);
			--curR;
		}
		ans[qu.second] = cur;
	}
	for (ll x : ans) print(x);
}

Measured memory_bytes: 19336
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;


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

int h1,m1,h2,m2,k,ans,c=0;

cin>>h1>>m1>>h2>>m2>>k;

if(m2-m1<0){
    ans=m2+60-m1;
    h2--;
}else{ans=m2-m1;}

ans=ans+(h2-h1)*60;
ans=(ans-k<=0)? 0:ans-k;
cout<<ans;
return 0;

}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<int> t(n+1,0),v(n);
    for (int i = 0;i < n;++i) cin >> t[i+1];
    for (int i = 0;i < n;++i) cin >> v[i];
    for (int i = 0;i < n;++i) t[i+1] += t[i];
    int s = t[n]*2+1;
    vector<double> u(s);
    for (int i = 0;i < s;++i) u[i] = i*0.5;
    for (int i = 0;i < s;++i) u[i] = min(u[i],(s-i-1)*0.5);
    for (int i = 0;i < n;++i) {
        for (int j = t[i]*2;j < t[i+1]*2+1;++j) u[j] = min(u[j],(double)v[i]);
    }
    for (int i = 0;i < n+1;++i) {
        for (int j = t[i]*2;j < s;++j) u[j] = min(u[j],u[t[i]*2]+(j-t[i]*2)*0.5);
    }
    for (int i = 1;i < n+1;++i) {
        for (int j = 0;j < t[i]*2;++j) u[j] = min(u[j],u[t[i]*2]+(t[i]*2-j)*0.5);
    }
    double ans = 0;
    for (int i = 0;i < s;++i) ans += u[i];
    cout << fixed << setprecision(12) << ans/2 << endl;
}

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

int main() {

	int N;
	cin >> N;
	int a = N / 1000 + 1;
	N = a * 1000 - N;
	if (N == 1000)	N = 0;
	cout << N << endl;

	return 0;
}

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


int main() {
    int q;
    cin >> q;
    vector<int> list;
    for (int i = 0; i < q; i++) {
        int com;
        cin >> com;
        if (com == 0) {
            int x;
            cin >> x;
            list.push_back(x);
        } else if (com == 1) {
            int p;
            cin >> p;
            cout << list[p] << endl;
        } else {
            list.pop_back();
        }
    }

}


Measured memory_bytes: 3872
from collections import Counter as C
N = int(input())
X=[]
Y=[]
for i in range(N):
    a, b = map(int, input().split(" "))
    X.append (a)
    Y.append (b)

if len(C([(X[i]+Y[i])%2 for i in range(N)]).most_common()) > 1:
    print (-1) 
else: 
    if (X[0]+Y[0]) % 2 == 0: 
        print (33)
        print ("1 " + " ".join([str(2**i) for i in range(32)]))
        x_init = 1
        ret_init = "L"
    else: 
        print (32) 
        print (" ".join([str(2**i) for i in range(32)]))
        x_init = 0
        ret_init = ""
        
    for i in range(N):
        x=X[i]+x_init
        y=Y[i]
        ret = ret_init

        for j in range(32):
            if ((x+y) % 4 == 1) == (j < 31):
                if x % 2 !=0:
                    ret += "L"
                    x += 1
                else:
                    ret += "D"
                    y += 1
            else:
                if x % 2 !=0:
                    ret += "R"
                    x -= 1
                else:
                    ret += "U"
                    y -= 1
            x//=2
            y//=2
        print (ret)

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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int a = 0,b = 0, ba = 0;
    for(int i = 0;i < n; i++) {
        string s;
        cin >> s;
        int m = s.size();
        for(int j = 0; j + 1 < m; j++) {
            if(s[j] == 'A' && s[j + 1] == 'B') cnt++;
        }
        if(s[0] == 'B') b++;
        if(s[m - 1] == 'A') a++;
        if(s[0] == 'B' && s[m - 1] == 'A') ba++;
    }
    cnt += min(a, b);
    if(a == ba && b == ba && b > 0) cnt--;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
// 2015/04/21 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

struct Card{
	char a;
	int  b;
};

bool compare_as_ints(Card i, Card j)
{
	return (i.b<j.b);
}

int partition(Card A[], int p, int r)
{
	Card x = A[r];
	int i = p-1;

	for(int j=p; j<=r-1; j++){
		if(A[j].b<=x.b){
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i+1], A[r]);

	return i+1;
}

void quickSort(Card A[], int p, int r)
{
	if(p<r){
		int q = partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}

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

	Card A[100000], B[100000];
	for(int i=0; i<n; i++){
		cin >> A[i].a >> A[i].b;
		B[i] = A[i];
	}

	quickSort(A, 0, n-1);
	stable_sort(B, B+n, compare_as_ints);

	bool flg = true;
	for(int i=0; i<n; i++){
		if(!(A[i].a==B[i].a && A[i].b==B[i].b)){
			flg = false;
			break;
		}
	}
	if(flg){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}

	for(int i=0; i<n; i++){
		cout << A[i].a << ' ' << A[i].b << endl;
	}

	return 0;
}

Measured memory_bytes: 2856
N = int(input())
H = [int(item) for item in input().split()]

max_count = 0
count = 0
for i in range(len(H) - 1):
    if H[i + 1] <= H[i]:
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0

print(max_count)


Measured memory_bytes: 63984
N = input()
a = []
for i in range(N):
    a.append(input())

muten=[0]
noten=[0]

for i in range(len(a)):
    if (a[i]%10==0):
        muten.append(a[i])
    else:
        noten.append(a[i])

muten.sort()
noten.sort()

allmut=sum(muten)
allnot=sum(noten)

while (allnot%10==0):
    del noten[0]
    allnot=sum(noten)
    if (allnot==0):
        break

if (allnot==0):
    print 0
else:
    print allmut+allnot

Measured memory_bytes: 2692
X,N=map(int,input().split())
p=[int(i) for i in input().split()]



for j in range(0,X+1):

    flag_a=0
    flag_b=0

    a=X-j
    b=X+j

    for k in p:

        if a==k:
            flag_a=1
        if b==k:
            flag_b=1

    if flag_a==0:

        print(a)
        break
    
    elif flag_b==0:

        print(b)
        break

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if(s == t) puts("Yes");
  else puts("No");
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n, k;
  string s;
  cin >> n >> k >> s;
  int a[100001] = {}, index = 0;
  char c = '1';
  REP(i,n){
    if(s[i] != c) {
      index++;
      c = s[i];
    }
    a[index]++;
  }
  index++;
  if(s[n - 1] != '1'){
    index++;
  }
  int rng = k * 2 + 1;
  if(index <= rng){
    cout << n;
    return 0;
  }
  int sm = 0;
  REP(i,rng){
    sm += a[i];
  }
  int ans = sm;
  for(int i=0; i < index - rng; i+=2){
    sm = sm - a[i] - a[i + 1] + a[i + rng] + a[i + rng + 1];
    ans = max(ans, sm);
  }
  cout << ans << endl;
  return 0;
}


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

const long long MAX = 1e18;

int main() {
    int N;
    cin >> N;
    long long *A = new long long[N];
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    
        if (A[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    
    long long sum = 1;
    long long sum_old = 1;
    for (int i = 0; i < N; i++) {
        sum_old = sum;
        sum *= A[i];

        if (sum > MAX || sum / A[i] != sum_old || sum == 0) {
            cout << -1;
            return 0;
        }

        /*
        if (MAX / sum < A[i]) {
            cout << -1;
            return 0;
        } else {
            sum *= A[i];
        }
        */
    }
    
    cout << sum;
    return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
char c;
cin >> c;
bool flg = false;
string s = "aiueo";
REP(i,s.size()) if(c == s[i]) flg = true;
if(flg) cout << "vowel" << endl;
else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>=n)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int n, a[2000000];
vector <int> b;

int main(){
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    int cnt = 0, init = 1;
    while(true){
        cnt++;
        init = a[init];
        if(init == 2) { cout << cnt; return 0; }
        if(cnt > n) { cout << -1; return 0; }
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a,b,n;
int main() {
  cin >>n;
  for(int a=0;a<10;a++){
    for(int b=0;b<10;b++){
      if(a*b == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll X[N];
    ll x[N];
    rep(i,N){
        cin >> X[i];
        x[i] = X[i];
    }
    sort(x,x+N);
    ll out = 0;
    rep(i,N){
        if(X[i]<=x[N/2-1]) out = x[N/2];
        else out = x[N/2-1];
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 5376
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int e;
	while (cin >> e&&e) {
		int minl = INF;
		for (int i = 0; i*i*i <= e; i++) {
			for (int j = 0; j*j <= e - i*i*i; j++) {
				minl = min(minl, i + j + e - i*i*i - j*j);
			}
		}
		cout << minl << endl;
	}
}

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

signed main() {
    int n, a[200000];
    long long ans;
    
    cin >> n;
    for (int i=0 ;i<n ;i++ ) {
        cin >> a[i];
    }
    
    ans = 0;
    for(int i=1; i<n ;i++ ) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    
    cout << ans << '\n';
    
    return (0);
}

Measured memory_bytes: 4412
#include<stdio.h>
int main(){
  char s;
  
  scanf("%c",&s);
  
  if(s=='A')
    printf("T");
  if(s=='C')
    printf("G");
  if(s=='G')
    printf("C");
  if(s=='T')
    printf("A");
  
 
  return 0;
}

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

int main(){
    string s; cin >> s;

    int ans = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '1') ans++;
    }

    cout << ans << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define bit(n) (1LL<<(n))

vector<pair<lint, lint>> edges[51];
bitset<30> bs[51]; // i -> {mask}
lint dp[51][bit(21)];

bool dfs(lint node, lint goal, lint from, lint label) {
    bool past = (node == goal);

    for(auto elem : edges[node]) {
        lint next, index;
        tie(next, index) = elem;

        if(next == from)  continue;
        if(dfs(next, goal, node, label)) {
            past = true;
            bs[index].set(label);
        }
    }
    return past;
}

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

    for(lint i=0; i<n-1; i++) {
        lint a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
    }

    lint m;
    cin >> m;

    // 1. 辺i -> 制約{mask[i]}
    for(lint i=0; i<m; i++) {
        lint u, v;
        cin >> u >> v;
        u--, v--;
        dfs(u, v, -1, i);
    }

    // 2. bitDP
    // dp[i][mask] := 辺[0, i)を塗り分ける場合のうち、制約{mask}を満たすものの個数
    dp[0][0] = 1;
    for(lint i=0; i<n-1; i++)
    for(lint mask=0; mask<bit(m); mask++) {
        dp[i+1][mask] += dp[i][mask];
        dp[i+1][mask | bs[i].to_ullong()] += dp[i][mask];
    }

    cout << dp[n-1][bit(m)-1] << endl;
}

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

int main()
{
    int haiku[3];

    for(int i = 0; i < 3; i++){
        cin >> haiku[i];
    }
    int five = 0, seven = 0;
    for(int i = 0; i < 3; i++){
        if(haiku[i] == 5) five++;
        if(haiku[i] == 7) seven++;
    }
    cout << (five == 2 && seven == 1 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	map<string,int> m;
	int n;
	cin>>n;
	int res=0;
	while(n--){
		string s;
		cin>>s;
		res=max(res,++m[s]);
	}
	for(auto &i:m){
		if(i.second==res)cout<<i.first<<'\n';
	}
	return 0;
}



Measured memory_bytes: 23808
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef pair<ldb,ll> P;
typedef double db;


ll sx,sy,tx,ty,x[1002],y[1002],r[1002];
ll n;
ldb d[1002][1002];
ldb D[1002];
                     
int main()
{
	scanf("%lld%lld%lld%lld",&sx,&sy,&tx,&ty);
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&r[i]);
		d[i][0]=d[0][i]=sqrt((x[i]-sx)*(x[i]-sx)+(y[i]-sy)*(y[i]-sy))-r[i];
		d[n+1][i]=d[i][n+1]=sqrt((x[i]-tx)*(x[i]-tx)+(y[i]-ty)*(y[i]-ty))-r[i];
		if(d[0][i]<0)d[0][i]=d[i][0]=0;
		if(d[n+1][i]<0)d[n+1][i]=d[i][n+1]=0;
	}
	d[0][n+1]=d[n+1][0]=sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty));
	fill(D,D+1002,1000000000000);
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			if(i==j){
				d[i][j]=0;
				continue;
			}
			d[i][j]=sqrt( (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])) -r[i]-r[j] ;
			if(d[i][j]<0) d[i][j]=0;
		}
	}
	d[0][0]=d[n+1][n+1]=0;
	D[0]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0,0));
	while(!q.empty()){
		P p=q.top();
		q.pop();
		ll x=p.second;
		if(p.first>D[x]) continue;
		for(ll i=0;i<=n+1;i++){
			if(i==x) continue;
			if(D[i]>D[x]+d[x][i]){
				D[i]=D[x]+d[x][i];
				q.push(P(D[i],i));
			}
		}
	}
	//for(ll i=0;i<n+2;i++){
	//	for(ll j=0;j<n+2;j++){
	//	cout<<"d["<<i<<"]["<<j<<"]="<<d[i][j]<<endl;
	//	}
	//}
	printf("%.14Lf\n",D[n+1]);
}

Measured memory_bytes: 24300
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, ans;

int main()
{
  scanf( "%lld", &N );

  for( ll i = 1; i*i < N; ++i ) if( N % i == 0 )
  {
    if( i < N/i-1 )
      ans += N/i-1;
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

#include <iostream>
#include <string>

using namespace std;

int n;
string S;

string H(string A){
	string K="";
	for(int i=0;i<A.size();i++){
		if(A[i] == '/') continue;
		else K += A[i];
	}
	return K;
}

void comp(string A){
	string B = H(A);
	int T = 0;
	for(int i = 0;i < B.size();i++){
		T = T*10+(B[i]-'0');
	}
	if(T <= 20190430) cout << "Heisei" <<endl;
	else cout << "TBD" <<endl;
}

int main(){
	cin >> S;
	comp(S);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n, c, x[100001], v[100001];

lin solve2(int rIndex, lin rValue)
{
    lin pos = x[rIndex];
    lin mx = rValue;
    lin current = rValue;
    current -= pos;
    pos = c;

    for(int i = n - 1; i > rIndex; i--)
    {
        current -= (pos - x[i]);
        current += v[i];

        if(mx < current)
            mx = current;
        
        pos = x[i];
    }

    return mx;
}

lin solve()
{
    lin sh[100001];
    rep(i, n)
    {
        sh[i] = 0;
    }

    lin smx = 0;
    lin scur = 0;
    x[n] = c;
    sh[n] = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        scur -= (x[i + 1] - x[i]);
        scur += v[i];
        if(smx < scur)
            smx = scur;
        sh[i] = smx;
    }


    lin mx = 0;
    lin pos = 0;
    lin current = 0;

    rep(i, n)
    {
        current -= (x[i] - pos);
        current += v[i];
        pos = x[i];
        
        lin tmx1 = current;
        lin tmx2 = current - x[i] + sh[i + 1];
        lin tmx = max(tmx1, tmx2);
        if(tmx > mx)
            mx = tmx;
    }

    return mx;
}

int main(void)
{
    //cin >> n >> c;
    scanf("%lld %lld", &n, &c);
    rep(i, n)
    {
        scanf("%lld %lld", &(x[i]), &(v[i]));
        //cin >> x[i] >> v[i];
    }

    lin res1 = solve();
    reverse(x, x + n);
    reverse(v, v + n);
    rep(i, n)
    {
        x[i] = c - x[i];
    }
    lin res2 = solve();

    lin res = max(res1, res2);

    //cout << res1 << endl;
    //cout << res2 << endl;

    cout << res << endl;

    return 0;
}


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

int main(){
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;


    cout << A[K-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int, int> P;

#define INF (1<<29)

int n, m, res;
int a[1080], b[1080], c[1080];
int dist[108];
vector<P> edge[108];
void dijkstra(int s){
  for(int i = 0;i < n;i++)dist[i] = INF;
  dist[s] = 0;
  priority_queue<P, vector<P>, greater<P> > pq;
  pq.push(P(0, s));

  while(!pq.empty()){
    P tmp = pq.top();pq.pop();
    int from = tmp.second;
    int d = tmp.first;
    if(dist[from] < d)continue;
    for(int i = 0;i < edge[from].size();i++){
      int to = edge[from][i].first;
      int c = edge[from][i].second;
      if(dist[from] + c < dist[to]){
	dist[to] = dist[from] + c;
	pq.push(P(dist[to], to));
      }
    }
  }
}

int main(){
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    edge[a[i]].push_back(P(b[i],c[i]));
    edge[b[i]].push_back(P(a[i],c[i]));
  }
  for(int i = 0;i < m;i++){
    dijkstra(a[i]);
    if(dist[b[i]] != c[i])res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll cur = 0, nxt = 1;
    vector<bitset<4000010>> bs(2);
    bs[cur][0] = 1;
    REP(i, n) {
        bs[nxt] = bs[cur] | (bs[cur] << a[i]);
        swap(cur, nxt);
    }
    
    ll sum = 0;
    REP(i, n) sum += a[i];
    FOR(i, (sum+1)/2, 4000010) if(bs[cur][i]) {
        cout << i << "\n";
        break;
    }

    return 0;
}

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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

signed main() {
    int a,b,c,k;read(a),read(b),read(c),read(k);
    write((k&1?-1:1)*(a-b));
    return 0;
}


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

int main(){
    char b,c;
    cin >> b;
    if(b=='A') c='T';
    else if(b=='T') c='A';
    else if(b=='C') c='G';
    else c='C';
    cout << c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

int main() {
	

	unsigned long long int num,T;
	
	cin >> num>>T;

	vector<unsigned long long int>t(num);
	
	unsigned long long int sum = 0;

	rep(i, 0, num) {
		cin >> t[i];
		if (i > 0) {
			if (t[i]-t[i-1] < T) {
				sum += t[i] - t[i - 1];
			}
			else sum += T;
		}

	}
	sum += T;
	cout << sum << endl;
		
	return 0;
}



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

int main(void){
  int n,m,t,ans;
  int imos[100010]={0};
  
  cin >> n >> m;
  for (int i=0; i<m; i++){
    int l,r;
    cin >> l >> r;
    imos[l-1]++;
    imos[r]--;
  }
  t=0; ans=0;
  for (int i=0; i<=n; i++){
    t+=imos[i];
    //cout << t << endl;
    if (t==m) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll read(){
	bool minus = false;
	ll result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus){
		return -result;
	}
	else{
		return result;
	}
}

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

#define maxn 52
ll x[maxn], y[maxn];
ll cx[maxn], cy[maxn];

ll dist(ll x1, ll y1, ll x2, ll y2){
	return abs(x1 - x2) + abs(y1 - y2);
}

int main(){
	int n, m;
	cin >> n >> m;
	ll i, j;
	for ( i = 0 ; i < n ; i ++ ){
		cin >> x[i] >> y[i];
	}
	for ( i = 0 ; i < m ; i ++ ){
		cin >> cx[i] >> cy[i];
	}
	for ( i = 0 ; i < n ; i ++ ){
		ll ans = mod;
		for ( j = 0 ; j < m ; j ++ ){
			ans = min(ans, dist(x[i], y[i], cx[j], cy[j]));
		}
		for ( j = 0 ; j < m ; j ++ ){
			if ( ans == dist(x[i], y[i], cx[j], cy[j]) ){
				cout << j + 1 << "\n";
				goto hell;
			}
		}
		hell:;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++) cin >> a.at(i);

    long long sum = 0;
    for(int i=0;i<m;i++) sum += a.at(i);
    if(n < sum){
        cout << -1 << endl;
    }
    if(n >= sum){
        cout << n - sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int a = -1;
        int b = -1;
        int c = -1; 

        for(int i=0;i<=N;i++){
            for(int j=0;j<=N-i;j++){
                if(Y == (10000*i+5000*j+1000*(N-i-j))){
                    a = i;
                    b = j;
                    c = N-i-j;
                }
                
            }
        }
        System.out.print(a + " ");
        System.out.print(b + " ");
        System.out.print(c);
    }
}   

Measured memory_bytes: 38564
N = int(input())

def digit10(X, Y) :
    dig_X = 0
    dig_Y = 0
    while X :
        dig_X += 1
        X //= 10
    while Y :
        dig_Y += 1
        Y //= 10
    return max(dig_X, dig_Y)

root_N = int(N ** 0.5)
ans = 100

for A in range(1,root_N+1) :
    if N%A == 0 :
        B = N // A
        ans = digit10(A, B)

print(ans)


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


int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    string s,t,u;
    cin >> s >> t ;
    cin >> a >> b ;
    cin >> u ;
    if(u==s) cout << a-1 << " " << b ;
    else cout << a << " "  << b-1 ;
	return 0;
}

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

int main(){
	int n;
	string s;
	set<string> c;
	cin >> n;
	for(int i = 0; i<n; i++){
		cin >> s;
		c.insert(s);
	}
	cout << c.size();
	return 0;
} 

Measured memory_bytes: 19180
import java.util.*;
public class Main {
    public static class Pair{
        int pos;
        int state;
        public Pair(int pos,int state){
            this.pos=pos;
            this.state=state;
        }
    }
    public static HashMap<Integer,ArrayList<Pair>>g=new HashMap<>();
    public static int[] x;
    public static boolean[] used;
    public static ArrayList<Integer>ans=new ArrayList<>();

    public static int lower_bound(Pair[] nums, Pair pair) {
        int l = 0, r = nums.length;
        while (l< r) { 
            int m = (l + r) / 2;
            if (nums[m].pos == pair.pos
                    ? nums[m].state < pair.state
                    : nums[m].pos < pair.pos) {
                l = m+1;
            } else {
                r = m;
            }
        }
        return l;
    }

    public static int upper_bound(Pair[] nums,Pair pair) {
        int l = 0, r = nums.length;
        while (l< r) { 
            int m = (l + r) / 2;
            if (nums[m].pos == pair.pos
                    ? nums[m].state <= pair.state
                    : nums[m].pos <= pair.pos) {
                l = m+1;
            } else {
                r = m;
            }
        }
        return l;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        Pair[] a=new Pair[n];
        x=new int[n+1];
        used=new boolean[n+1];
        for(int i=0;i<n;i++)
        {
           a[i]=new Pair(sc.nextInt(),sc.nextInt());
        }
        Arrays.sort(a, Comparator.comparingInt(c -> c.pos));
        x[0]=a[0].state;
        for(int i=0;i<n-1;i++)
        {
            x[i+1]=a[i].state^a[i+1].state;
        }
        x[n]=a[n-1].state;
        for(int i=0;i<m;i++)
        {
            int l=sc.nextInt();
            int r=sc.nextInt();
            l=lower_bound(a,new Pair(l,0));
            r=upper_bound(a,new Pair(r,1));
            if(l>r)continue;
            if(g.get(l)==null)g.put(l,new ArrayList<>());
            if(g.get(r)==null)g.put(r,new ArrayList<>());
            g.get(l).add(new Pair(r,i+1));
            g.get(r).add(new Pair(l,i+1));
        }
        for(int i=0;i<n+1;i++)
        {
            if(used[i])continue;

            if(dfs(i)==1){
                System.out.println(-1);
                return;
            }
        }
            System.out.println(ans.size());
            Collections.sort(ans);
            for (int num : ans) {
                System.out.print(num + " ");
            }
            System.out.println("");

    }
    public static int dfs(int v)
    {
        used[v]=true;
        int res=x[v];
        if(g.get(v)==null)return res;
        for(Pair p:g.get(v))
        {
            if(used[p.pos])continue;
            int r=dfs(p.pos);
            if(r==1) ans.add(p.state);
            res^=r;
        }
        return res;
    }
}


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

using namespace std;

#define ll long long
#define ar array
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))

ll X,K,D;


bool compare(const pair<int, bool> &p1, const pair<int, bool> &p2){
    return p1.first > p2.first;
}

ll dest(ll X, ll K, ll D){
    ll cur = X;

    ll oft = abs(X) / abs(D);
    //cout << K << endl;

    if(oft >= K){
        if(X >= 0){
            cur -= K * D;
        }
        else
        {
            cur += K *D;  
        }
        return cur;
    }
    else{
        if(X >= 0){
            cur -= oft * D;
        }
        else
        {
            cur += oft *D;  
        }
    }
    K -= oft;
    //cout << K << endl;

    K  = K %2;
    //cout << K << endl;

    if(K == 1){
        if(abs(cur + D) <= abs(cur - D)){
            cur = cur +D;
        }   
        else
            cur = cur - D;
    }


    return cur;
}

void solve(){
    cin >> X >> K >> D;


    cout << abs(dest(X,K,D)) << endl;
     
    
    

    
   
}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    int a;
    int n_mult_four = 0;
    int n_even_else = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( a % 4 == 0 )
            n_mult_four++;
        else if ( a % 2 == 0 )
            n_even_else++;
    }

    if ( n_mult_four >= N / 2 ) {
        cout << "Yes" << endl;
        return 0;
    }
    else if ( n_even_else >= (N - n_mult_four * 2) ) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d %d %d" (fun a b c d ->
    let mat = Array.make_matrix (c + 1) (d + 1) (-1) in
    mat.(a).(b) <- 1;
    let z = 998244353 in
    let ( +@) a b = (a + b) mod z in
    let ( -@) a b = ((a - b) mod z + z) mod z in
    let ( *@) a b = (a * b) mod z in
    let rec calc w h =
        if mat.(w).(h) >= 0 then mat.(w).(h) else (
            let r = 
                if w = a then calc w (h - 1) *@ w else
                if h = b then calc (w - 1) h *@ h else
                    calc w (h - 1) *@ w +@ calc (w - 1) h *@ h -@ calc (w - 1) (h - 1) *@ (w - 1) *@ (h - 1)
            in
            mat.(w).(h) <- r;
            r
        )
    in
    calc c d |> Printf.printf "%d\n"
)

Measured memory_bytes: 75444
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const double pi=acos(-1.0);
ll mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	rep(i,3){
		if(s.at(i)=='1') s.at(i)='9';
		else s.at(i)='1';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
// きりみんちゃんの配信からきました
package main

import (
	"fmt"
)

var a, b, x int

func main() {
	fmt.Scan(&a, &b, &x)
	if a <= x && x <= a+b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512