akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

void ntoarray( int a[], int n ) {
	int i = 0;
	while( n > 0 ) {
		a[ i ] = n % 10; n = n / 10;
		i += 1;
	}
	return;
}

bool chk_permu( int n, int i ) {
	const int amax = 12;
	int na[ amax ] = { 0 };
	int ia[ amax ] = { 0 };

	ntoarray( na, n );
	std::sort( na, na + amax );
	ntoarray( ia, i );
	std::sort( ia, ia + amax );

	bool issame = true;
	for( int i = 0; i < amax; i++ ) {
		if( na[ i ] !=  ia[ i ] ) {
			issame = false;
			break;
		}
	}

	return issame;
}

int next_permu( int n, int nmax ) {
	int p = 0;
	for( int i = n + 1; i < nmax; i++ ) {
		bool ispermu = chk_permu( n, i );
		if( ispermu ) {
			p = i;
			break;
		}
	}
	return p;
}

bool isallconnected( int np, int n, int m, int a[], int b[] ) {
	std::vector<int> nv;
	int t = np;
	while( t > 0 ) {
		nv.insert( nv.begin(), t % 10 );
		t = t / 10;
	}

	int edges = 0;
	for( int i = 0; i < nv.size() - 1; i++ ) {
		for( int j = 0; j < m; j++ ) {
			if( ( nv[ i ] == a[ j ] and nv[ i + 1 ] == b[ j ] ) or
					( nv[ i ] == b[ j ] and nv[ i + 1 ] == a[ j ] ) ) {
				edges += 1;
			}
		}
	}

	return ( edges == n - 1 ? true : false );
}

int main( void )
{
	int n, m;
	std::cin >> n >> m;

	const int mmax = 28;
	int a[ mmax ], b[ mmax ];
	for( int i = 0; i < m; i++ ) {
		std::cin >> a[ i ] >> b[ i ];
	}

	int np = 0;
	for( int i = 1; i <= n; i++ ) {
		np = np * 10 + i;
	}

	int nmax = std::pow( 10, n - 1 ) * 2;
	int cnt = 0;
	while( np > 0 ) {
		bool isall = isallconnected( np, n, m, a, b );
		if( isall ) {
			cnt += 1;
		}

		np = next_permu( np, nmax );
	}

	std::cout << cnt << std::endl;
	return 0;
}



Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =  Integer.parseInt(sc.next());
		
		
		String ans = "No";
		for (int i = 1 ; i < 10 ; i++) {
			for (int j = 1 ; j < 10 ; j++) {
				if (i*j == a ) {
					ans = "Yes";
				}
				
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
/******Old_school_@15******/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back hellooitsme1
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld k; cin>>k;
          if(k%2==0){
              cout<<-1;
              return 0;
          }
          lld prd=7;
          lld ans=0;
          lld hash[k]={0};
          while(true){
              if(hash[prd%k]){
                  ans=-1;
                  break;
              }
              if(prd%k==0){
                  ans++;
                  break;
              }
              else
                ans++;
              prd=prd%k;
              hash[prd]++;
              prd=(prd)*10+7;
              
          }
          cout<<ans;
      }
}


Measured memory_bytes: 11392
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;
int num[100001];
int main(void) {
	int num = 0;
	string s;
	cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == 'o')num++;
	}
	cout << 700 + 100 * num << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());

  ll t = 0;
  rep(i, n) {
    t += p[i].second;
    if (t > p[i].first) {
      puts("No");
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

int main(void){
    int r,c;
    std::cin>>r>>c;
    std::vector<std::vector<int>> data(r,std::vector<int>(c,0));
    int i,j;
    for(i=0;i<r;i++){
        int sum=0;
        for(j=0;j<c;j++){
            std::cin>>data[i][j];
            sum+=data[i][j];
        }
        data[i].push_back(sum);
    }
    for(i=0;i<r;i++){
        for(j=0;j<c+1;j++){
            std::cout<<data[i][j];
            if(j!=c)std::cout<<" ";
        }
        std::cout<<std::endl;
    }
    for(i=0;i<c+1;i++){
        int sum=0;
        for(j=0;j<r;j++){
            sum+=data[j][i];
        }
        std::cout<<sum;
        if(i!=c)std::cout<<" ";
    }
    std::cout<<std::endl;
    return 0;
}

Measured memory_bytes: 3112
use proconio::input;

fn main() {
    input! {
        (n, m): (usize, usize),
        hs: [usize; n],
        abs: [(usize, usize); m]
    };

    let mut map = vec![Vec::new(); n+1];

    /* 1 - 3 - 2 - 4
       1: [3]
       2: [3,4]
       3: [1,2]
       4: [2]
    */
    for (a, b) in abs {
        map[a].push(b);
        map[b].push(a);
    }

    let mut ans = 0;

    'outer: for i in 1..=n {
        if map[i].len() == 0 {
            ans += 1;
        } else {
            for &j in map[i].iter() {
                if hs[i-1] <= hs[j-1] {
                    continue 'outer;
                }
            }

            ans += 1;
        }
    }

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


Measured memory_bytes: 12224
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;


int main() {
	priority_queue<ll> q;
	ll n;
	cin >> n;
	vector<ll> persons(n);
	for (ll i = 0; i < n; i++) {
		cin >> persons[i];
	}
	sort(persons.begin(), persons.end(), greater<ll>());
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		if (q.empty()) {
			q.push(persons[i]);
		}
		else {
			ans += q.top();
			q.pop();
			q.push(persons[i]);
			q.push(persons[i]);
		}
	}
	cout << ans << endl;


	

}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    bitset<2000*2000+1> s("1");
    rep(i, n) s = (s | s << a[i]);
    int i = 1, cnt = 0, tar = s.count() - 1;
    while (i<sz(s)) {
        if (s[i] == 1) ++cnt;
        if (cnt == (tar+1)/2) break;
        ++i;
    }
    cout << i << endl;
    return 0;
}


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

int main(){
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  vector<char> T(N);
  for (int i=0; i<N; i++) {
    cin >> T[i];
  }

  int ans = 0;
  for (int i=0; i<N; i++){
    if (i>=K){
      if(T[i] != T[i-K]){
        if (T[i] == 'r') ans += P;
        else if (T[i] == 's') ans += R;
        else ans += S;
      } else {
        T[i] = '*';
      }
    } else {
      if (T[i] == 'r') ans += P;
      else if (T[i] == 's') ans += R;
      else ans += S;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N; 
  cin >> N;

  vector<pair<int, int>> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;

  vector<pair<int, int>> B(N);
  REP(i, N) cin >> B[i].first >> B[i].second;

  sort(ALL(A), [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second > r.second;
      });
  sort(ALL(B));

  vector<bool> used(N, false);


  int ans = 0;
  for(auto p : B){
    REP(i, N){
      if(used[i]) continue;
      if(A[i].first < p.first && A[i].second < p.second){
        used[i] = true;
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
//UnionFind 木
// T (typename) : グラフの頂点を表す型, (int)parent, (int)size を持つ必要あり
template <typename T>
struct UnionFind {
    vector<T> &u;
    UnionFind(vector<T> &u) : u(u) {
        for (int i = 0; i < u.size(); i++) {
            u[i].parent = i;
        }
    }
    int root(int x) {
        if (x < 0 || u.size() <= x)
            return -1;
        else if (x == u[x].parent)
            return x;
        else
            return u[x].parent = root(u[x].parent);
    }
    bool connect(int a, int b) {
        a = root(a), b = root(b);
        if (a == b || a < 0 || b < 0) return false;
        u[a].depth = max(u[a].depth, u[b].depth);
        u[b].parent = a;
        return true;
    }
    // O(u.size())
    void count(map<int, int> &ret) {
        for (int i = 0; i < u.size(); i++) {
            int tmp = u[i].parent;
            if (!ret.count(tmp)) {
                ret[tmp] = 0;
            }
            ret[tmp]++;
        }
    }
};

struct Node {
    int parent;
    int depth;
};

using P = pair<int, int>;

// 奇数ループがあると死
int main() {
    int N;
    cin >> N;
    vector<set<int>> edge(N);
    for (int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < N; j++) {
            if (tmp[j] == '1') edge[i].insert(j);
        }
    }
    int ans = -1;
    for(int v = 0; v < N; v++) {
        vector<int> layer(N, -1);
        vector<Node> uf_node(N, {-1, -1});
        UnionFind<Node> uf(uf_node);
        set<P, std::greater<P>> s;
        uf_node[v].depth = layer[v] = 0;
        queue<int> q;
        q.push(v);
        bool flag = false;
        while (!flag && q.size()) {
            int x = q.front();
            q.pop();
            for (int y : edge[x]) {
                if (uf_node[y].depth < 0) {  // 追加
                    q.push(y);
                    layer[y] = layer[x] + 1;
                    uf_node[y].depth = layer[y];
                } else {  // 検証
                    if (abs(layer[x] - layer[y]) != 1) {
                        flag = true;
                        break;
                    }
                }
                if (x != v && y != v) uf.connect(x, y);
            }
        }
        if(flag) continue;
        int ans_ = 1;
        for (int i = 0; i < N; i++) {
            int p = uf.root(i);
            s.insert({uf_node[p].depth, p});
        }
        ans_ += s.begin()->first;
        s.erase(s.begin());
        ans_ += s.begin()->first;
        s.erase(s.begin());
        ans = max(ans, ans_);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  string S;
  while (cin >> N >> K >> S) {
    --K;
    S[K] = (S[K] - 'A') + 'a';
    cout << S << endl;
  }
  return 0;
}


Measured memory_bytes: 764
import std.stdio;
import std.string;
import std.conv;
import std.math;



int main()
{
	string s;
	while((s=readln.chomp).length != 0)
	{
		double value = s.to!double;
		double min_t = value/9.8;
		double just = 4.9*min_t*min_t;
		int number = cast(int)((just+10)/5.0);
		writeln(number);
	}
	return 0;
}

Measured memory_bytes: 1068
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break 
    
    for i in range(1,H+1,1):
        row = ""
        for j in range(1,W+1,1):
            if (i+j)%2 == 0:
                row += "#"
            else:
                row += "."
        print(row)
    print()


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
 int n;
 int mp[1000001]={0};
 int arr[200001];
 cin>>n;
 sa(arr,n,d);
 int c=0;
 rep(i,n) mp[arr[i]]++;
 rep(i,n){
     bool f=true;
     for(int j=2;j*j<=arr[i];j++){
         if(arr[i]%j==0 && mp[j]!=0) {f=false;break;}
         if(arr[i]%j==0 && mp[arr[i]/j]!=0) {f=false;break;}
     }
     if(mp[arr[i]]>1 || (arr[i]==1 && mp[1]>1) || (arr[i]!=1 && mp[1]>=1)) f=false;
     if(f) c++;
 }cout<<c<<endl;
  return 0;
}


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const ll mx=1e7;

int main()
{
    optimize();

    string s;
    ll d[2]= {}, t=mx;
    d[0]=20190430;
    cin>> s;

    for(int i=0; i<10; i++)
    {
        if(i!=4 && i!=7)
        {
            d[1]+=((s[i]-'0')* t);
            t/=10;
        }
    }

    if(d[1]> d[0])
        cout<< "TBD\n";

    else
        cout<< "Heisei\n";

    return 0;
}




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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize()
{
    for (int i = 0; i < N; i++)
    {
        row[i] = FREE, col[i] = FREE;
    }
    for (int i = 0; i < 2 * N - 1; i++)
    {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard()
{
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (X[i][j])
            {
                if (row[i] != j)
                    return;
            }
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i)
{
    if (i == N)
    {
        printBoard();
        return;
    }
    for (int j = 0; j < N; j++)
    {
        if (NOT_FREE == col[j] || NOT_FREE == dpos[j + i] || NOT_FREE == dneg[i - j + N - 1])
            continue;
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}

int main()
{
    initialize();

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            X[i][j] = false;
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }
    recursive(0);

    return 0;
}



Measured memory_bytes: 3124
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
int n,f[4005][4005],pn=2000,a[200005],b[200005],fr[1000005],infr[1000005],val=1e6;
int C(int x,int y)
{
	return 1ll*fr[x]*infr[y]%mod*infr[x-y]%mod;
}
int main()
{
	fr[0]=infr[0]=1;
	for(int i=1;i<=val;i++)
		fr[i]=1ll*fr[i-1]*i%mod;
	infr[val]=fpow(fr[val],mod-2);
	for(int i=val-1;i>0;i--)
		infr[i]=1ll*infr[i+1]*(i+1)%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++)
		f[pn-a[i]][pn-b[i]]++;
	for(int i=0;i<=2*pn;i++)
		for(int j=0;j<=2*pn;j++)
		{
			if(i) f[i][j]=addmod(f[i][j]+f[i-1][j]);
			if(j) f[i][j]=addmod(f[i][j]+f[i][j-1]);
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=addmod(ans+f[pn+a[i]][pn+b[i]]);
	for(int i=1;i<=n;i++)
		ans=submod(ans-C(2*(a[i]+b[i]),2*a[i]));
	ans=1ll*ans*fpow(2,mod-2)%mod;
	printf("%d",ans);
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    int min_idx = -1;
    int min_num = 1e9;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < min_num) {
            min_num = a[i];
            min_idx = i;
        }
    }

    int left = ceil(1.0 * min_idx / (k-1));
    int amari = left * (k - 1) - min_idx;
    int right =  ceil(1.0 * (n - min_idx - amari - 1) / (k - 1));
    cout << left + right << endl;
}


Measured memory_bytes: 1016
a,b=map(int,input().split())
i=0
while(True):
    xa=int(i*0.08)
    xb=int(i*0.10)
    if(xa==a and xb==b):
        print(i)
        break
    elif(xa>a and xb>b):
        print(-1)
        break
    else:
        i+=1


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N, a, b = map(int, input().split())
t = []
dp = [[[float("inf")] * (N * 10 + 1) for _ in range(N * 10 + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0
for i in range(N):
  x, y, c = map(int, input().split())
  for j in range(N * 10 + 1):
    for k in range(N * 10 + 1):
      if dp[i][j][k] != float("inf"):
        dp[i + 1][j + x][k + y] = min(dp[i + 1][j + x][k + y], dp[i][j][k] + c)
      dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k])
res = float("inf")
for j in range(1, N * 10 + 1):
  for k in range(1, N * 10 + 1):
    if j / a == k / b:
      res = min(res, dp[-1][j][k])
if res != float("inf"): print(res)
else: print(-1)

Measured memory_bytes: 123484
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  for(var i = 0, len = input[0] - 0; i < len; i++){
    var c = input[i+1].split(' ');
    var a = b = 0;

    for(var j = 0, jlen = c.length; j < jlen; j++){
      if((d = +c[j]) > a)
        a = d;
      else if(d > b)
        b = d;
      else
        a = b = 11;
    }

    console.log(a==11?'NO':'YES');
    
  }

  
}

Measured memory_bytes: 7644
#include<bits/stdc++.h>
using namespace std;
int main() {
	vector<int>a(6);
	vector<int>b(6);
	string S;
	for (int i = 0;i < 6;i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	cin >> S;
	int n;
	n = S.length();
	for (int i = 0;i < n;i++) {
		if (S[i] == 'N') {
			a[0] = b[1];
			a[1] = b[5];
			a[2] = b[2];
			a[3] = b[3];
			a[4] = b[0];
			a[5] = b[4];
			for (int j = 0;j < 6;j++) {
				b[j] = a[j];
				//cout << a[j];
			}//cout << endl;
		}
		else if (S[i] == 'E') {
			a[0] = b[3];
			a[1] = b[1];
			a[2] = b[0];
			a[3] = b[5];
			a[4] = b[4];
			a[5] = b[2];
			for (int j = 0;j < 6;j++) {
				b[j] = a[j];
				//cout << a[j];
			}//cout << endl;
		}
		else if (S[i] == 'W') {
			a[0] = b[2];
			a[1] = b[1];
			a[2] = b[5];
			a[3] = b[0];
			a[4] = b[4];
			a[5] = b[3];
			for (int j = 0;j < 6;j++) {
				b[j] = a[j];
				//cout << a[j];
			}//cout << endl;
		}
		else if (S[i] == 'S') {
			a[0] = b[4];
			a[1] = b[0];
			a[2] = b[2];
			a[3] = b[3];
			a[4] = b[5];
			a[5] = b[1];
			for (int j = 0;j < 6;j++) {
				b[j] = a[j];
				//cout << a[j];
			}//cout << endl;
		}
	}
	cout << a[0] << endl;
	return 0;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        sc.close();

        int pre = Integer.parseInt(S.substring(0, 2));

        int suf = Integer.parseInt(S.substring(2, 4));

        String answer = "";

        if (0 < pre && pre <= 12) {
            if (0 < suf && suf <= 12) {
                answer = "AMBIGUOUS";
            } else {
                answer = "MMYY";
            }
        } else {
            if (0 < suf && suf <= 12) {
                answer = "YYMM";
            } else {
                answer = "NA";
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 35612
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = [a[i]-b[i] for i in range(n)]
e = [i for i in d if i > 0]
f = [i for i in d if i < 0]
e.sort(reverse = True)
g = abs(sum(f))
if sum(d) < 0:
    print(-1)
else:
    if f == []:
        print(0)
    else:
        sum = 0
        for i in range(len(e)):
            sum += e[i]
            if sum >=  g:
                print(i+len(f)+1)
                break


Measured memory_bytes: 18356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    vector<int> ans(n,0);
    rep(sv,n){
        vector<int> dist(n,mod);
        queue<int>q;
        auto push=[&](int v,int d){
          if(dist[v]!=mod)return;
          dist[v]=d;
          q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v=q.front();q.pop();
            int d=dist[v];
            if(v-1>=0)push(v-1,d+1);
            if(v+1<n)push(v+1,d+1);
            if(v==x)push(y,d+1);
            if(v==y)push(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    rep(i,n)ans[i]/=2;
    for(int i=1;i<n;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1&&b==1&&c==0||a==0&&b==0&&c==1){
        cout<<"Open"<<endl;
    }
    else {
        cout<<"Close"<<endl;
    }

}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
  int N=0;
  int d[150]={0};
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum+=d[i]*d[j];
    }
  }
  cout<<sum;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if  abs(a-b)<=k and abs(a-c)<=k and abs(a-d)<=k and abs(a-e)<=k and abs(b-c)<=k and abs(b-d)<=k and abs(b-e)<=k and abs(c-d)<=k and abs(c-e)<=k and abs(d-e)<=k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

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

	if (0 < a && a < 10 && 0 < b && b < 10) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 単語ごとに入力するならこれ */
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	v := make([]int, n)

	for i := 0; i < n; i++ {
		sc.Scan()
		v[i], _ = strconv.Atoi(sc.Text())
	}

	sort.Ints(v)

	var sum float64 = float64(v[0])

	for i := 1; i < n; i++ {
		sum = (sum + float64(v[i])) / 2
	}

	/* 出力用 */
	_, _ = fmt.Fprintf(stdout, "%v\n", sum)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

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

using namespace std;

typedef struct dice
{
    int a1,a2,a3,a4,a5,a6;
    int up=1;
    dice(int q,int w,int e,int r,int t,int y):a1(q),a2(w),a3(e),a4(r),a5(t),a6(y) {}
    dice() {}
} D;

map<char,int > m;

int main()
{
//    freopen("in.txt","r",stdin);

    int a[10];
    for(int i=0; i<6; i++)
        cin>>a[i];

    D touzi=D(a[0],a[1],a[2],a[3],a[4],a[5]);

    string s;
    cin>>s;
    int len=s.length();
    for(int i=0; i<len; i++)
    {
        if(s[i]=='W')
        {
            int c1=touzi.a1;
            touzi.a1=touzi.a3;
            touzi.a3=touzi.a6;
            touzi.a6=touzi.a4;
            touzi.a4=c1;
        }
        else if(s[i]=='N')
        {
            int c2=touzi.a1;
            touzi.a1=touzi.a2;
            touzi.a2=touzi.a6;
            touzi.a6=touzi.a5;
            touzi.a5=c2;
        }
        else if(s[i]=='E')
        {
            int c3=touzi.a1;
            touzi.a1=touzi.a4;
            touzi.a4=touzi.a6;
            touzi.a6=touzi.a3;
            touzi.a3=c3;
        }
        else if(s[i]=='S')
        {
            int c4=touzi.a1;
            touzi.a1=touzi.a5;
            touzi.a5=touzi.a6;
            touzi.a6=touzi.a2;
            touzi.a2=c4;
        }
    }
    cout<<touzi.a1<<endl;


}



Measured memory_bytes: 3208
def main():
    n,m=map(int,input().split())
    p =[[] for i in range(n)]
    for i in range(m):
        pp,ss=input().split()
        ppp=int(pp)
        p[ppp-1].append(ss)


    cntA = 0
    cntW = 0
    for i,a in enumerate(p):
        flg = 0
        cnt=0
        for j,s in enumerate(a):
            if  s == 'WA':
                cnt += 1
            elif s == 'AC':
                cntA += 1
                cntW+=cnt
                break
    print(str(cntA) + ' ' + str(cntW))
    # print(cntA)
    # print(cntW)
if __name__=='__main__':
    main()


Measured memory_bytes: 20272
//P-Independent set
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i=a;i<=b;i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(),(x).end()
#define prDouble(x) cout<<fixed <<setprecision(10)<<x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<int>tree[100001];
ll dp[100001][2];

ll solve(int u,bool constraint,int pr) //pr:PARENT
{

if(dp[u][constraint]!=-1)
return dp[u][constraint];

ll ans=0;
ll w1=1;

for(int child:tree[u])
{
    if(child!=pr)
        w1=(w1*solve(child,0,u))%mod;

}
    ans=(ans+w1);

    if(!constraint)
    {
        ll w2=1;
        
    for(int child:tree[u])
{    
    if(child!=pr)
    
        w2=(w2*solve(child,1,u))%mod;

}  
    ans=(ans+w2)%mod;

}
return dp[u][constraint]=ans;
}
int main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
   // memset(dp,-1,sizeof dp);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       tree[u].push_back(v);
       tree[v].push_back(u);

   }
   cout<<solve(1,0,-1); //node 1 and it is under no constraints

   return 0;

}


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

using namespace std;

const long long MOD = 1e9 + 7;
const int N = 4004;
long long f[N];
int dp[N][N][2];

long long power(long long a, long long b) {
    long long x = 1, y = a;
    while (b > 0) {
        if (b & 1) {
            x = (x * y);
            if (x > MOD)
                x %= MOD;
        }

        y = y * y;
        if (y > MOD)
            y %= MOD;

        b >>= 1;
    }
    return x;
}


long long nCr(long long n, long long r) {
    return (f[n] * power(f[r] * f[n - r] % MOD, MOD - 2)) % MOD;
}

int mul(int x, int y) {
    return 1LL * x * y % MOD;
}

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        x -= MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        x += MOD;
    return x;
}

int solve(int r, int b, int flag) {
    if (r < 0 || b < 0)return 0;
    if (r == 0 && b == 0)return 1;
    int &ret = dp[r][b][flag];
    if (~ret)return ret;
    ret = solve(r - 1, b, 0);
    if (!flag)
        ret = add(ret, solve(r, b - 1, 1));
    return ret;
}

int main() {
    f[0] = 1;
    for (int i = 1; i < N; i++)
        f[i] = (f[i - 1] * i) % MOD;

    memset(dp, -1, sizeof dp);
    int n, k;
    cin >> n >> k;
    int r = n - k;
    int inv = power(f[r], MOD - 2);
    cout << mul(f[r + 1], inv) << "\n";
    for (int i = 2; i <= k; i++) {
        int ans = nCr(k - 1, i - 1);
//        cout << solve(r, i, 0) << "***";
        ans = mul(ans, solve(r, i, 0));
        cout << ans << "\n";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 125696
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

int main() {
  ll a,b;
  cin >> a >> b;
  ll c = min(a,(ll)(b/2LL));
  a -= c;
  b -= c * 2LL;
  c += (ll)(b/4LL);
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int main(){
  int m1,m2,d1,d2;
  cin >>m1>>d1>>m2>>d2;
  if(m1 != m2)cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   
   int i;
   int n;
   int x;
   scanf("%d", &n);
   
   for(i = 1; i <= n; i++){
        x = i;
        if(x % 3 == 0){
            printf(" %d", i);
            continue;
        }
        
        do{
            if(x % 10 == 3){
                printf(" %d", i);
            break;
            }
            x /= 10;
        }while(x);

        
   }
   
  printf("\n");
  return 0;
   
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
#define int long long int
#define mod 998244353
int power(int a,int b)
{
	if(b==0)
	  return 1;
    else
    {
		int r=power(a,b/2);
		r=r%mod;
		r=r*r;
		r=r%mod;
		if(b%2==0)
		   return r;
		else
		{
			r=r*a;
			r=r%mod;
			return r;
		}
	}
}
int32_t main()
{
    int k;
    cin>>k;
    int n;
    cin>>n;
    int arr[n+1];
    int j;
    for(j=0;j<n;j++)
       cin>>arr[j];
    arr[n]=arr[0];
    int answer=k;
    int max_val=0;
    for(j=0;j<n-1;j++)
    {
		int val=abs(arr[j+1]-arr[j]);
		max_val=max(max_val,val);
	}
	int val=(k-arr[n-1]+arr[0]);
	max_val=max(max_val,val);
	answer-=max_val;
	cout<<answer<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const ll inf = 1e+15;
const int NMAX = 200000;
int N,M,S,T;
ll d[NMAX];
vector<pair<int,ll>> edge[NMAX];
void dijkstra(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > > q;
  for(int i=0;i<N;++i) d[i] = inf;
  d[s]=0;
  q.push(make_pair(0,s));
  while(!q.empty()){
    pair<ll,int> p = q.top();q.pop();
    int w=p.second;
    if(d[w]<p.first) continue;
    for(int i=0;i<edge[w].size();i++){
      int t=edge[w][i].first;
      ll c=edge[w][i].second;
      if(d[t]>d[w]+c){
	d[t]=d[w]+c;
	q.push(make_pair(d[t],t));
      }
    }
  }
}

ll db[NMAX];
vector<pair<int,ll>> edgeb[NMAX];
void dijkstrab(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > > q;
  for(int i=0;i<N;++i) db[i] = inf;
  db[s]=0;
  q.push(make_pair(0,s));
  while(!q.empty()){
    pair<ll,int> p = q.top();q.pop();
    int w=p.second;
    if(db[w]<p.first) continue;
    for(int i=0;i<edgeb[w].size();i++){
      int t=edgeb[w][i].first;
      ll c=edgeb[w][i].second;
      if(db[t]>db[w]+c){
	db[t]=db[w]+c;
	q.push(make_pair(db[t],t));
      }
    }
  }
}


int main()
{
  cin >> N >> M >> S >> T;
  for(int i=0;i<M;++i){
    int u,v;
    ll a,b;
    cin >> u >> v;
    cin >> a >> b;
    u--;v--;
    edge[u].push_back(make_pair(v,a));
    edge[v].push_back(make_pair(u,a));
    edgeb[u].push_back(make_pair(v,b));
    edgeb[v].push_back(make_pair(u,b));		          
  }

  dijkstra(--S);
  dijkstrab(--T);
  vector<ll> res(N);
  for(int i=0;i<N;++i){
    res[i] = d[i]+db[i];
  }
  ll mini = inf;
  for(int i=N-1;i>=0;--i){
    mini = min(mini,res[i]);
    res[i] = inf - mini;
  }
  for(int i=0;i<N;++i){
    cout << res[i] << "\n";
  }
  
  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,co[4]={0},i;
	
	for(i=0;i<6;i++){
		cin>>a;
		co[a-1]++;
	}
	int ev=0,one=0;
	for(i=0;i<4;i++){
		if(co[i]%2==0)ev++;
		else if(co[i]==1)one++;
	}
//	cout<<co[0]<<" "<<co[1]<<" "<<co[2]<<" "<<co[3]<<endl;
	if(one==2&&one+ev==4)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  int K, X;
  cin >> K >> X;
  if(X<=500*K) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(auto a,long long b){
    long long ans=1;
    //cout<<ans;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    ///cout<<ans<<" ";    
    return ans;
        
}
void maxi(auto &a,auto b){
    a=max(a,b);
}
void mini(auto &a,auto b){
    a=min(a,b);
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int x=0,y=0,k=0;
    while(n--){
        int z;
        cin>>z;
        if(z>k){x=max(x,y);y=0;}
        else{
            y++;
        }
        k=z;
    }
    cout<<max(x,y);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 10000000000ll
#define N 100005
#define M 10000005
using namespace std;
 
int n,trtot,cnt1,cnt2,h[N],rt1[N],rt2[N],sum[M],sz[M],ls[M],rs[M],P[M];
map<ll,int> mp1,mp2; ll m,a[N],b[N];
void ins(int &k,ll l,ll r,ll x,int y,int p){
	if (!k) k=++trtot;
	if (l==r){ sum[k]=1; sz[k]=y; P[k]=p; return; }
	ll mid=l+r>>1;
	if (x<=mid) ins(ls[k],l,mid,x,y,p); else ins(rs[k],mid+1,r,x,y,p);
	sum[k]=sum[ls[k]]+sum[rs[k]];
	sz[k]=sz[ls[k]]+sz[rs[k]];
}
int qry(int k,ll l,ll r,ll x,ll y){
	if (!sum[k] || x>y) return 0;
	if (x<=l && r<=y) return sum[k];
	ll mid=l+r>>1; int ans=0;
	if (x<=mid) ans+=qry(ls[k],l,mid,x,y);
	if (y>mid) ans+=qry(rs[k],mid+1,r,x,y);
	return ans;
}
int getp(int k,ll l,ll r,ll x,ll y){
	if (!sz[k] || x>y || l>y || r<x) return 0;
	if (l==r) return P[k];
	ll mid=l+r>>1; int t=0;
	if (x<=mid) t=getp(ls[k],l,mid,x,y);
	return (t)?t:getp(rs[k],mid+1,r,x,y);
}
void dlt(int x){
	ins(rt1[mp1[a[x]]],0,inf,b[x],0,x);
	ins(rt2[mp2[b[x]]],0,inf,a[x],0,x);
}
int main(){
	scanf("%d%d%d",&n,&h[1],&h[2]);
	int i,x,y,head=0,tail=2;
	for (i=1; i<=n; i++){
		scanf("%d%d",&x,&y);
		a[i]=x+y+1000000000ll; b[i]=x-y+1000000000ll;
	}
	m=max(abs(a[h[1]]-a[h[2]]),abs(b[h[1]]-b[h[2]]));
	for (i=1; i<=n; i++){
		if (!mp1[a[i]]) mp1[a[i]]=++cnt1;
		ins(rt1[mp1[a[i]]],0,inf,b[i],(i!=h[1] && i!=h[2])?1:0,i);
		if (!mp2[b[i]]) mp2[b[i]]=++cnt2;
		ins(rt2[mp2[b[i]]],0,inf,a[i],(i!=h[1] && i!=h[2])?1:0,i);
	}
	ll ans=0;
	while (head<tail){
		x=h[++head];
		ans+=qry(rt1[mp1[a[x]+m]],0,inf,b[x]-m,b[x]+m);
		ans+=qry(rt1[mp1[a[x]-m]],0,inf,b[x]-m,b[x]+m);
		ans+=qry(rt2[mp2[b[x]+m]],0,inf,a[x]-m+1,a[x]+m-1);
		ans+=qry(rt2[mp2[b[x]-m]],0,inf,a[x]-m+1,a[x]+m-1);
		while (y=getp(rt1[mp1[a[x]+m]],0,inf,b[x]-m,b[x]+m)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt1[mp1[a[x]-m]],0,inf,b[x]-m,b[x]+m)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt2[mp2[b[x]+m]],0,inf,a[x]-m+1,a[x]+m-1)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt2[mp2[b[x]-m]],0,inf,a[x]-m+1,a[x]+m-1)){
			h[++tail]=y; dlt(y);
		}
	}
	printf("%lld\n",ans>>1);
	return 0;
}


Measured memory_bytes: 165888
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;

int main() {
	int n;
	cin>>n;
	
	int c0=0, c1=0, c2=0;
	int x;
	for (int k=0; k < n; k += 1)
	{
		cin>>x;
		if (x == 1) c0++;
		else if (x == 2) c1++;
		else c2++;
	}
	
	int MAX = 308;
	double dp[MAX][MAX][MAX];
	memset(dp, 0.0, sizeof(dp));

	for (int k=0; k < MAX; k += 1)
	{
		for (int j = 0; j < MAX - k; j += 1)
		{
			for (int i = 0; i < MAX - k - j; i += 1)
			{
				if ((i == 0 && j == 0 && k == 0) || i + j + k > MAX)
				continue;
				
				double waiting_time = (double) n / (i + j + k);
				double p1 = (double) i/(i + j + k);
	            double p2 = (double) j/(i + j + k);
	            double p3 = (double) k/(i + j + k);
	            if (i)
	                dp[i][j][k] += p1 * dp[i - 1][j][k];
	            if (j)
	                dp[i][j][k] += p2 * dp[i + 1][j - 1][k];
	            if (k)
	                dp[i][j][k] += p3 * dp[i][j + 1][k - 1];
	            dp[i][j][k] += waiting_time;
			}
		}
	}
	
	
	cout<<fixed<<setprecision(10)<<dp[c0][c1][c2];
	return 0;
}

Measured memory_bytes: 228608
#include<stdio.h>
int main(void)
{
	int n,l[4],s[4],a,b,c,d,e;
	scanf("%d",&n);
	while(n!=0000){
		int f=0;
		b=0;
		while(n!=6174){
			l[0]=n/1000;
			l[1]=n/100-l[0]*10;
			l[2]=n/10-(l[0]*100+l[1]*10);
			l[3]=n-(l[0]*1000+l[1]*100+l[2]*10);
			if(l[0]==l[1]&&l[1]==l[2]&&l[2]==l[3]){
				printf("NA\n");
				f=1;
				break;
			}
			for(c=0;c<4;c++){
				for(d=c+1;d<4;d++){
					if(l[c]<l[d]){
						e=l[c];
						l[c]=l[d];
						l[d]=e;
					}
				}
			}
			for(c=0;c<4;c++){
				s[c]=l[3-c];
			}
			n=(l[0]*1000+l[1]*100+l[2]*10+l[3])-(s[0]*1000+s[1]*100+s[2]*10+s[3]);
			b=b+1;
		}
		if(f!=1){
		printf("%d\n",b);
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<complex>
using namespace std;
int main(){
    int time;
    cin>>time;
    for(int i=0;i<time;++i){
        float a,b,c,d;
        cin>>a>>b>>c>>d;
        complex<float> x(a-c,b-d);
        cin>>a>>b>>c>>d;
        complex<float> y(a-c,b-d);
        y = conj(y);
        complex<float> z = x*y;
        if(z.imag()==0){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b;
    if((a==1 && b == 2) || (a == 2 && b == 1)) c =3;
    if((a==2 && b == 3)|| (a == 3&& b == 2)) c = 1;
    if((a==1 && b == 3)|| (a == 3&& b == 1)) c = 2;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int a,b,temp,n;
int main()
{
    int n;
    cin>>n;
    while(n--){
        int flag=1;
        a=0,b=0;
        queue<int>que;
        //while(que.size())que.pop();
        for(int i=0;i<10;i++){
            cin>>temp;
            que.push(temp);
        }
        while(que.size()){
            temp=que.front();
            que.pop();
            if(temp<=a&&temp<=b){
                cout<<"NO\n";
                flag=0;
                break;
            }
            else if(temp<=a&&temp>b)b=temp;
            else if(temp<=b&&temp>a)a=temp;
            else {
                if(a>=b)a=temp;
                else b=temp;
            }
        }
        if(flag)cout<<"YES\n";
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <new>

using namespace std;

int main(void)
{
    int num;
    int neccesary_height;
    int neccesary_width;
    int count;

    cin >> num >> neccesary_height >> neccesary_width;
    int *heights = new int[num];
    int *widths = new int[num];

    count = 0;
    for(int i = 0; i < num; i++){
        cin >> heights[i] >> widths[i];
        if(heights[i] >= neccesary_height && widths[i] >= neccesary_width){
            count++;
        }
    }

    cout << count << endl;

    delete[] heights;
    delete[] widths;

    return 0;
}


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

int main() {
	char a, b;
    cin >> a >> b;
    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
        cout << "H" << endl;
    }
    else{
        cout << "D" << endl;
    }
}

Measured memory_bytes: 256