akhauriyash/Code-Regression huggingface dataset:
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// cs++;
		cin>>n;
		// n=s.length();
		ll a[n];
		rep(i,n)
		{
			cin>>a[i];
			m=1;
			rep(j,i) if(a[j]>a[i]) m=0;
			if(m) cs++;
		}
		
		
		cout<<cs;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin  >> n;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  bool r=true;
  for(i=0;i<n-1;i++){
    if(vec.at(i)==vec.at(i+1)){
      r=false;
    }
  }
  if(r){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


Measured memory_bytes: 1024
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
struct edge{int to,cost;};
//使うやつはここから下に置こうな

signed main() {
    string s;cin>>s;
    reverse(s.begin(),s.end());
    rep(i,0,s.size()){
        if(s.substr(i,5)=="maerd"){
            i+=4;
        }
        else if(s.substr(i,5)=="esare"){
            i+=4;
        }
        else if(s.substr(i,6)=="resare"){
            i+=5;
        }
        else if(s.substr(i,7)=="remaerd"){
            i+=6;
        }
        else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

string s,t;
vl moji[26];

void input(void){
   cin>>s>>t;
}

void solve(void){
    ll ans=-1,now=-1,now2,k;
    rep(i,s.length()){
        moji[s[i]-'a'].push_back(i);
    }
    rep(i,t.length()){
        k=t[i]-'a';
        if(moji[k].empty()){
            cout<<-1<<endl;
            return;
        }
        now2=upper_bound(all(moji[k]),now)-moji[k].begin();
        if(now2==moji[k].size()){
            ans+=s.length()-now+moji[k][0];
            now=moji[k][0];
        }
        else{
            ans+=moji[k][now2]-now;
            now=moji[k][now2];
        }
    }

    cout<<ans+1<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 1736
import numpy as np
N = input()
a = np.array(input().split()).astype(int)
flags = (np.diff(a) <= 0).astype(int)
result = 0
max_result = 0
for i, flag in enumerate(flags):
    if flag == 0:
        if result > max_result:
            max_result = result
        result = 0
    else:
        result += 1
    if i == len(flags) - 1:
        if result > max_result:
            max_result = result
print(max_result)

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

using namespace std;

int main(void) {
    long long n, w;

    cin >> n >> w;

    vector<pair<long long, long long>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }

    vector<vector<long long>> dp(n + 1, vector<long long>(w + 1, 0));

    for (int i = 0; i <= n; i++) dp[i][0] = 0;
    for (int i = 0; i <= w; i++) dp[0][i] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            long long weight = v[i - 1].first;
            long long val = v[i - 1].second;
            if (weight <= j) {
                dp[i][j] = max(dp[i - 1][j - weight] + val, dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}

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

int main() {
  int n;
  while(cin >> n && n) {
    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    int num = 32;
    int p = 0;
    while(num) {
      int d = (num - 1) % 5;
      num -= d;
      cout << num << endl;
      if(num) {
        num -= v[p];
        num = max(num, 0);
        p = (p + 1) % v.size();
        cout << num << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    stack<char> st;
    int cnt = 0;
    rep(i, s.length()) {
        if ( s[i] == '0' ) {
            if ( st.empty() || st.top() == '0' ) {
                st.push(s[i]);
            }
            else {
                cnt += 2;
                st.pop();
            }
        }
        if ( s[i] == '1' ) {
            if ( st.empty() || st.top() == '1' ) {
                st.push(s[i]);
            }
            else {
                cnt += 2;
                st.pop();
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
   
   string s, t;
   cin >> s >> t;
   int ans = 0;
   vector<int> vec;
   rep(i,s.size()-t.size()+1){
       int cnt = 0;
    for(int j = 0;j<t.size();j++){
        if(s[i+j]==t[j]) cnt++;
    }
    vec.push_back(cnt);
   }
   sort(vec.begin(), vec.end());
   cout<<t.size()-vec[vec.size()-1]<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1e5 + 5;
const ll mod = 1e8 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
void solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = b * d;
    ans = max(a * c, ans);
    ans = max({ans, a * d, b * c});
    cout << ans << '\n';
}  
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve(); 
    }
    //EjecuteTime;
    return 0;
}  

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    long long int res=0;
    for(unsigned int i=0;i<s.size();i++){
        res+=s.at(i)-'0';
    }
    //cout<<res;
    if(res%9==0 || res==0)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3752
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >>N;
    int A[N],B[N],C[N];
    for(int i = 0;i<N;i++)
    {
        cin>>A[i];
    }
    for(int i = 0;i<N;i++)
    {
        cin>>B[i];
    }
    for(int i = 0;i<N-1;i++)
    {
        cin>>C[i];
    }

    long long sum = 0;
    
    for(int i = 0;i<N;i++)
    {
        sum += B[A[i]-1];
    }

    for(int i = 0;i<N-1;i++)
    {
        if(A[i+1]-A[i]==1)
        {
            sum += C[A[i]-1];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] color = Console.ReadLine().Split(' ');
            HashSet<string> check = new HashSet<string>();
            for(int i = 0; i < N; i++)
            {
                if(color[i] =="G"|| color[i] == "W"|| color[i] == "P"|| color[i] == "Y")
                {
                    check.Add(color[i]);
                }
            }
            if(check.Count() == 3)
            {
                Console.WriteLine("Three");
            }
            else if(check.Count() == 4)
            {
                Console.WriteLine("Four");
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	string s;
	cin >> s;
	int cnt = 0;

	if (s.at(2) == s.at(3)) cnt++;
	if (s.at(4) == s.at(5)) cnt++;

	if (cnt == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;

}



Measured memory_bytes: 3616
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	
	ll n,m,x;
	cin>>n>>m>>x;
	ll c[n];
	ll a[n][m];
	f(i,n){
		cin>>c[i];
		f(j,m)
		cin>>a[i][j];
		
	}
	ll ans=inf;
	
	for(ll mask=1;mask<(1<<n);mask++){
		ll cs=0;
		vll k(m);
		for(ll i=0;i<n;i++){
		if(mask>>i&1){
			cs+=c[i];
			f(j,m){
				k[j]+=a[i][j];
				
			}
		}
		
		}
		ll f=0;
		f(j,m){
			if(k[j]<x)
			{
				f=1;
				break;
			}
		}
		
		if(!f)
		ans=min(ans,cs);
	}
	if(ans==inf)
	ans=-1;
	cout<<ans;
	
	
	
	

	



    

	return 0;
    
}

Measured memory_bytes: 3656
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

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

int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    fori(n)
        cin>>v[i];
    vector<int> c(n);
    fori(n)
        cin>>c[i];
    vector<int>d(n);
    fori(n)
        d[i]=v[i]-c[i];

    sort(d.begin(), d.end(), greater<int>());
    ll ans=0;
    for(int i=0; i<n && d[i]>0; i++)
        ans+=d[i];

    cout<<ans<<endl;
    

}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	int n, t;
	cin >> n >> t;
	vector<pair<int, int>> r(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		r[i] = pair<int, int>(a, b);
	}
	sort(r.begin(), r.end());
	vector<vector<ll>> dp(3010, vector<ll>(7000, -1));
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, 6000) {
			int time = r[i].first;
			int hap = r[i].second;
			if (j - time >= 0 && dp[i][j - time] != -1 && j - time < t) {
				chmax(dp[i + 1][j], dp[i][j - time] + hap);
			}
			chmax(dp[i + 1][j], dp[i][j]);
		}
	}
	ll ans = 0;
	rep(i, 6000) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}

Measured memory_bytes: 168236
M, D = map(int, input().split())

cnt = 0
for i in range(1, M+1):
    for j in range(22, D+1):
        d_10 = j // 10
        d_1 = j % 10
        if d_10 < 2 or d_1 < 2:
            continue
        if i == d_10 * d_1:
            cnt += 1
print(cnt)


Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

const int MAXN = 50;

template<typename T>
T power(T a, int p, int md = 1000000007){
    T ans(1);
    while(p){
        if(p&1) ans = ans*a;
        a = a*a;
        p >>= 1; 
    }
    return ans;
}

struct matrix{
    int mat[MAXN][MAXN] = {0};
    matrix(int val = 0){
        loop(MAXN) 
            Loop(0, MAXN, j) 
                if(i == j) mat[i][j] = val; 
                else 0;
    }

    matrix operator*(matrix b){
        matrix ans;
        for(int i = 0; i < MAXN; i++)
            for(int j = 0; j < MAXN; j++)
                for(int k = 0; k < MAXN; k++){
                    ans.mat[i][j] = ans.mat[i][j] + ((mat[i][k]%mod)*(b.mat[k][j]%mod))%mod; 
                    ans.mat[i][j] %= mod;
                }

        return ans;
    }

    
};


int32_t main(){
    int n;
    int k;
    cin >> n >> k;
    matrix a;
    loop(n) Loop(0, n, j) cin >> a.mat[i][j];
    matrix c = power<matrix>(a, k);

    int ans = 0;
    loop(n)
        Loop(0, n, j) 
            ans = (ans + c.mat[i][j])%mod;
    
    cout << ans << endl;

}

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

int main()
{
  int N;
  cin >> N;
  int A[210];
  for(int i = 0; i < N; i++) cin >> A[i];
  int count = 0; //操作回数
  
  /*可能な限り操作を行う*/
  while(true)
  {
      bool exist_odd = false; //A[i]が全て偶数かどうか判定するフラグ
      for(int i = 0; i < N; i++)
  	  {
      	if(A[i] % 2 != 0) exist_odd = true; //奇数があったらフラグを立てる
      }
 
      if(exist_odd) break; //フラグ回収
      for(int i = 0; i < N; i++)
      {
        A[i] /= 2;
      }
      ++count;  
 } 
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,p;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	printf("%d\n",min(a*p,b+max(0,p-c)*d));
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
ll prefix[200005];
using namespace std;
int main()
{
	ll n;
	cin >> n;
	ll a[n];
	cin >> a[0];
	prefix[0] = a[0];
    for(int i = 1; i < n; i++)
    {
    	cin >> a[i];
    	prefix[i] = prefix[i-1]+a[i];
	}
	ll ans = 0;
    for(int i = 0; i < n; i++)
    {
    	if(prefix[i] == 0)
    	ans++;
	}
	map <ll , ll> freq;
    for(int i = 0; i < n; i++)
    {
    	freq[prefix[i]]++;
	}
	for(int i = 0; i < n; i++)
	{
		if(freq[prefix[i]] >= 1)
		{
			ll x = freq[prefix[i]];
			freq[prefix[i]] = 0;
			ans += ((x*(x-1))/2);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 15872
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
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 ans = 0;
    int k = 0;
    for(int i=0; i<n; ++i){
        if(a[i] - a[k] > 2)
            ++ k;
        ans = max(ans, i - k + 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
import time as ti


class MyQueue(object):
    """
    My Queue class

    Attributes:
        queue: queue
        head
        tail
    """

    def __init__(self):
        """Constructor
        """
        self.length = 50005
        self.queue = [0] * self.length
        self.head = 0
        self.tail = 0

    # def enqueue(self, name, time):
    def enqueue(self, process):
        """enqueue method

        Args:
            name: enqueued process name
            time: enqueued process time

        Returns:
            None
        """
        self.queue[self.tail] = process
        self.tail = (self.tail + 1) % self.length

    def dequeue(self):
        """dequeue method

        Returns:
            None
        """
        self.queue[self.head] = 0
        self.head = (self.head + 1) % self.length

    def is_empty(self):
        """check queue is empty or not

        Returns:
            Bool
        """
        if self.head == self.tail:
            return True
        else:
            return False

    def is_full(self):
        """chech whether queue is full or not"""
        if self.tail - self.head >= len(self.queue):
            return True
        else:
            return False


class Process(object):
    """process class
    """

    def __init__(self, name="", time=0):
        """constructor
        Args:
            name: name
            time: time
        """
        self.name = name
        self.time = time

    def forward_time(self, time):
        """time forward method

        Args:
            time: forward time interval

        Returns:
            remain time

        """
        self.time -= time
        return self.time


def time_forward(my_queue, interval, current_time):
    """

    Args:
        my_queue: queue
        interval: time step interval
        current_time: current time
    """
    value = my_queue.queue[my_queue.head].forward_time(interval)
    if value <= 0:
        current_time += (interval + value)
        print my_queue.queue[my_queue.head].name, current_time
        my_queue.dequeue()

    elif value > 0:
        current_time += interval
        my_queue.enqueue(my_queue.queue[my_queue.head])
        my_queue.dequeue()
    return current_time


my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]

counter = 0
while counter < n:
    name, time = raw_input().split()
    my_queue.enqueue(Process(name, int(time)))
    counter += 1

current_time = 0
while not my_queue.is_empty():
    current_time = time_forward(my_queue, q, current_time)

Measured memory_bytes: 26416
n = int(input())
ls = [int(i) for i in input().split()]
ans = [0]*n    
if len(ls) >= n:
    for i in range(n,0,-1):
        for j in range(i,0,-1):
            if ls[j-1] == j:
                ls.remove(j)
                ans[i-1] = j
                break
if ls == []:
    for s in range(len(ans)):
        print(ans[s])
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long int
#define inf 1450000090
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define nax 100010
#define mp make_pair
#define pi pair <int , int>
#define pii pair < int , pair <int ,int > >
#define MOD 1000000007
using namespace std;  
int arr[3*nax];
int taken[3*nax];
vector<pi> v;
multiset< int > sett;
set < pi > takeable;
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  ll s1,s2;
  s1 = s2 = 0;
  for (int i = 1; i <=3*n; ++i)
  {
      sd(arr[i]);
      if(i<=n)
      {
        s1+=arr[i];
        sett.insert(arr[i]);
      }
      else
        v.pb(mp(arr[i],-i));
  }
  sort(v.begin(), v.end());
  for(int i=0;i<n;i++)
  {
      s2+=v[i].first;
      taken[-v[i].second] = 1;
  }
  for(int i=n;i<2*n;i++)
  {
      takeable.insert(mp(v[i].first,-v[i].second));
  }
  ll fans = s1-s2;
  int pos = 0; 
  for(int i=n+1;i<=2*n;i++)
  {
    //cout << fans << "\n";
    if(takeable.find(mp(arr[i],i))!=takeable.end())
      takeable.erase(mp(arr[i],i)); // yahan tak sab khatam
    int cur = arr[i];
    int smallest = *sett.begin();
    if(cur > smallest)
    {
        if(taken[i] && takeable.size()!=0)
        { 
            sett.erase(sett.find(smallest));
            sett.insert(cur);
            s1-=smallest;
            s1+=cur;
            s2-=cur;
            pi add = *takeable.begin();
            takeable.erase(add);
            s2+=add.first;
            taken[add.second] = 1;
        }
        else
        {
           sett.erase(sett.find(smallest));
           sett.insert(cur);
           s1-=smallest;
           s1+=cur;
        }
    }
    else
    {
      if(taken[i])
      {
        s2-=cur;
        pi add = *takeable.begin();
        takeable.erase(add);
        s2+=add.first;
        taken[add.second] = 1;
      }
    }
    fans = max(fans,s1-s2);
  }
  printf("%lld\n",fans);
  return 0;
}  

Measured memory_bytes: 13172
s = input()
t = s.split()
W,H,x,y,r = int(t[0]),int(t[1]),int(t[2]),int(t[3]),int(t[4])
sx,ex = x-r,x + r
sy,ey = y-r,y+r
if sx>=0 and ex<=W and sy >=0 and ey <= H:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int a,b;
	cin >> a >> b;
	cout << 6-a-b << endl;


  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + [int(input()) for _ in range(N)]

ans = 0
for i in range(1, N + 1):
    cnt = A[i-1] + A[i]
    if cnt % 2 == 1 and cnt > 1:
        A[i-1],A[i] = 0,1
    elif cnt % 2 == 0:
        A[i] = 0
    ans += cnt // 2

print(ans)

Measured memory_bytes: 7840
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, D = i2nn()
    D2 = D * D
    ans = 0
    for _ in range(N):
        X, Y = i2nn()
        d2 = X * X + Y * Y
        ans += d2 <= D2
    print(ans)
    return

main()


Measured memory_bytes: 9236
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;

template <class T>
class MaxFlowDinic {
 public:
    // you may need to change INF
    static const T INF = 2147483647; //INT_MAX
    int V;
    struct edge {
        int to, rev;
        T cap;
    };
    vector<vector<edge>> G;
    vector<int> level;
    vector<int> iter;

    MaxFlowDinic() {};
    MaxFlowDinic(int v) {
        V = v;
        G.resize(V); level.resize(V); iter.resize(V);
        for (int i = 0; i < V; i++) G[i].clear();
    }

    void add(int from, int to, T cap) {
        G[from].push_back(edge{to, (int)G[to].size(), cap});
        G[to].push_back(edge{from, (int)G[from].size() - 1, 0});
    }

    void add_dual(int from, int to, T cap) {
        G[from].push_back(edge{to, (int)G[to].size(), cap});
        G[to].push_back(edge{from, (int)G[from].size() - 1, cap});
    }

    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    T dfs(int v, int t, T f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                T d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }


    T max_flow(int s, int t) {
        T flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            T f;
            while ((f = dfs(s, t, INF)) > 0) {
                flow += f;
            }
        }
    }
};


int main(void) {
    int V, E;
    cin >> V >> E;
    MaxFlowDinic<int> mf(V);
    for (int i = 0; i < E; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        mf.add(u, v, c);
    }
    cout << mf.max_flow(0, V - 1) << endl;

    return 0;
}

Measured memory_bytes: 1272
#include <iostream>

using namespace std;
int n;
int a[50];

int main(){
    a[0]=1;
    a[1]=1;
    for(int i=2;i<45;i++){
        a[i]=a[i-2]+a[i-1];
    }
    cin>>n;
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int n,c,aa,ans=-1000000000;
  cin>>n;
  int a[n][10],b[n][11];
  rep(i,0,n) rep(j,0,10) cin>>a[i][j];
  rep(i,0,n) rep(j,0,11) cin>>b[i][j];
  rep(i,1,1024){
    aa=i;
    vector<int> d(n);
    rep(j,0,10){
      if(aa%2==1) rep(k,0,n) d[k]+=a[k][j];
      aa/=2;
    }
    rep(j,0,n) c+=b[j][d[j]];
    ans=max(ans,c);
    c=0;
  }
  co(ans);
  
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from itertools import combinations
def main():
    N, K = map(int, readline().split())    
    #全ての2頂点の組合せはN(N-1)/2通り
    #そのうち(N-1)通りは距離1で頂点同士を直接繋いでいる辺である
    #N(N-1)/2 - (N-1) = (N-2)(N-1)/2
    #上記の式より、距離が2以上の2頂点の組合せの数は(N-2)(N-1)/2通り
    #距離が2の頂点数は(N-2)*(N-1)/2以下であるからKがこれより大きいような題意を満たすグラフを構成することはできない
    if K > (N-2)*(N-1)//2:
        print(-1) 
        return 

    #頂点1を根とするスターグラフの頂点1以外の任意の2頂点の最短距離は2である
    #最短距離が2の頂点は(N-1)*(N-2)/2組ある
    #これをK組まで減らすことを考える
    #スターグラフの頂点1以外の2頂点同士に辺を張ることでその頂点間の最短距離を1にすることができる。
    #この操作は他の頂点間の最短距離に影響しない
    #上記の操作を(N-1)*(N-2)//2 - K回行うことで最短距離が2の2頂点の組をKにできる
    M = (N-1)*(N-2)//2 - K
    #N-1はスターグラフの辺の数
    #Mは操作によりスターグラフに追加して張る辺の数
    print(M + N-1) 

    #スターグラフで張る辺を出力
    for i in range(2, N+1):
        print(1, i)

    #あとの操作で張る辺を出力
    #cnt:=操作を行った回数
    cnt = 0
    #頂点2から頂点Nの任意の2頂点の組合せを順に列挙して、操作の対象となる頂点とする
    p = [int(i) for i in range(2, N+1)] 
    for i, j in combinations(p, 2):
        if cnt == M:
            return
        print(i, j)
        cnt += 1
if __name__ == '__main__':
    main()


Measured memory_bytes: 3608
n = int(input())
s = input()
r_cnt = s.count("R")
g_cnt = s.count("G")
b_cnt = s.count("B")
ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for j in range(i + 1, n):
        k = j + (j - i)
        if k >= n:
            continue
        elif len(set([s[i], s[j], s[k]])) == 3:
            ans -= 1
print(ans)
            

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

using namespace std;
vector<int> ans;
int cf[20][20];
bool field[20][20];
int w,h;
void dfs(int i,int j,int count);

int main(){
	while(1){
		cin >> w >> h;
		if(w + h == 0) break;
		for(int i = 0;i < 20;i++){
			for(int j = 0;j < 20;j++){
				cf[i][j] = -1;
				field[i][j] = false;
			}
		}
		
		int px,py;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				char t;
				cin >> t;
				if(t == '.') field[i][j] = true;
				else if(t == '@'){ px = j; py = i;field[i][j] = true;}
			}
		}
		
		int counta = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j] && cf[i][j] == -1){
					dfs(i,j,counta);
					counta++;
				}
			}
		}
		
		int pn = cf[py][px];
		int count = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(cf[i][j] == pn) count++;
			}
		}
		
		ans.push_back(count);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

void dfs(int i,int j,int count){
	cf[i][j] = count;
	if(i != 0 && field[i-1][j] && cf[i-1][j] == -1) dfs(i-1,j,count);
	if(i != h-1 && field[i+1][j] && cf[i+1][j] == -1) dfs(i+1,j,count);
	if(j != 0 && field[i][j-1] && cf[i][j-1] == -1) dfs(i,j-1,count);
	if(j != w-1 && field[i][j+1] && cf[i][j+1] == -1) dfs(i,j+1,count);
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	ll k;
	cin >> n >> k;

	vector<pair<int, int>> num(n);
	rep (i, 0, n)
		cin >> num[i].first >> num[i].second;

	sort(num.begin(), num.end());
	int res = 0;
	ll counter = 0;
	rep (i, 0, n) {
		counter += num[i].second;
		if (counter >= k) {
			res = num[i].first;
			break;
		}
	}

	cout << res << endl;
	return 0;
}


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

using namespace std;

int main(){
    int N = 3;
    int a[N];

    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    sort(a, a + N);

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


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

using namespace std;

typedef pair<int, bool> Link;
typedef vector<vector<Link> > Graph;

int main () {
    int V, E;
    cin >> V >> E;
    Graph g(V, vector<Link>(V));

    // Set identity to 0
    for(int i=0; i<V; i++)
        g[i][i] = make_pair(0, true);

    // Set known edges
    for(int i=0; i<E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = make_pair(d, true);
    }

    // Run Floyd-Warshall algorithm
    for(int k=0; k<V; k++)
        for(int i=0; i<V; i++)
            for(int j=0; j<V; j++)
                if (
                        (g[i][k].second && g[k][j].second) &&
                        (!g[i][j].second || g[i][j].first > g[i][k].first + g[k][j].first))
                    g[i][j] = make_pair(g[i][k].first + g[k][j].first, true);

    // Check if any cycle
    for(int i=0; i<V; i++)
        if (g[i][i].first < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }

    // Print output
    for(int i=0; i<V; i++) {
        for(int j=0; j<V; j++)
            if (g[i][j].second)
                cout << (j ? " " : "") <<  g[i][j].first;
            else
                cout << (j ? " " : "") << "INF";
        cout << endl;
    }
}



Measured memory_bytes: 3200
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var n = +lines.shift();
for (var i = 0; i < n; i++) {
	var nums = lines.shift().split(' ');
	var x1 = +nums[0];
	var y1 = +nums[1];
	var x2 = +nums[2];
	var y2 = +nums[3];
	var x3 = +nums[4];
	var y3 = +nums[5];
	var x4 = +nums[6];
	var y4 = +nums[7];

	if (((x2 - x1) * (y4 - y3)).toFixed(12) == ((x4 - x3) * (y2 - y1)).toFixed(12)) {
		console.log('YES');
	} else {
		console.log('NO');
	}
}

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

double xy[2][8];

double dist(int i, int j){
  double dx,dy;
  dx = xy[0][i] - xy[0][j];
  dy = xy[1][i] - xy[1][j];
  return pow(dx*dx + dy*dy,0.5);
}
int main(){
  int N,i;
  double FN = 1;
  
  cin >> N;
  for(i=0;i<N;i++){
    cin >> xy[0][i] >> xy[1][i];
  }
  for(i=1;i<N+1;i++){
    FN = FN*i;
  }
  vector<int> v(N);
  for(int i = 0; i < N; i++) v[i] = i;
  double ans = 0;
      do {
        for(int i = 0; i < N - 1; i++) ans += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
  ans = ans/FN;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");

        boolean ans = false;
        for (int i = 0; i < n.length; i++) {
            if (n[i].equals("9")) ans = true;
        }

        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

bool dp[2][900][900];

int main() {

  int N; cin >> N;
  vector<int> v;
  rep(i, N) {
    int t; cin >> t;
    v.push_back(t);
  }

  dp[0][0][0] = 1;

  rep(i, N) {
    auto& curr = dp[i&1];
    auto& next = dp[(i+1)&1];
    rep(a, 900) rep(b, 900) {
      if(a + v[i] > 900) { continue; }
      if(b + v[i] > 900) { continue; }
      next[a][b + v[i]] |= curr[a][b];
      next[a + v[i]][b] |= curr[a][b];
      next[a][b] |= curr[a][b];
    }
  }

  int ans = inf;
  const int sum = accumulate(all(v), 0);

  rep(a, 900) rep(b, 900) {
    int c = sum - a - b;
    if(0<=c&&c<=900 && dp[N&1][a][b]) {
      minimize(ans, max({a, b, sum - a - b}));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4732
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll dp[100005][2][102];//j 0超えていない 1超えている
int main(){
    string s;
    cin>>s;
    int d;
    cin>>d;
    dp[0][1][0]=1;
    int n=s.size();
    for(int i=0;i<n;i++){
        int t=s[i]-'0';
        for(int j=0;j<2;j++){
            for(int k=0;k<(j?t+1:10);k++){
                for(int r=0;r<d;r++){
                       (dp[i+1][(j&&k==t)][(r+k)%d]+=dp[i][j][r])%=mod;      
                }
            }
        }
    }
    cout<<(dp[n][0][0]+dp[n][1][0]-1+mod)%mod<<endl;
}


Measured memory_bytes: 16640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll h,w,a,b; cin >> h >> w >> a >> b;
  
  vvl table(h,vl(w));
  
  if(h == 1){
    rep(i,a) cout << 1;
    rep(i,w-a) cout << 0;
    cout << endl;
    
    return 0;
  }
  
  if(w == 1){
    rep(i,b) cout << 1 << endl;
    rep(i,h-b) cout << 0 << endl;
    
    return 0;
  }
  
  rep(i,h){
    rep(j,w){
      if((i < b and j < a) or (i >= b and j >= a)){
        table[i][j] = 1;
      }
      else table[i][j] = 0;
    }
  }
  
  for(auto array : table){
    for(ll x : array){
      cout << x ;
    }
    cout << endl;
  }
  
  
}

Measured memory_bytes: 11540
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI

int main(){
    char a, b;
    cin >> a >> b;
    if(a < b){
        cout << '<' << endl;
    }
    else if(a > b){
        cout << '>' << endl;
    }
    else cout << '=' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int lcs(string s, string t){
    int n = s.length(), m = t.length();
    VVI dp(n+1, VI(m+1));
    FOR(i,1,n) FOR(j,1,m){
        if (s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
        else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
    return dp[n][m];
}

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    VVI dp(n+1, VI(m+1)), bi(dp), bj(dp);
    FOR(i,1,n) FOR(j,1,m){
        if (s[i-1] == t[j-1]){
            dp[i][j] = dp[i-1][j-1] + 1;
            bi[i][j] = i - 1;
            bj[i][j] = j - 1;
        }else{
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (dp[i - 1][j] >= dp[i][j - 1]){
                bi[i][j] = i - 1;
                bj[i][j] = j;
            }else{
                bi[i][j] = i;
                bj[i][j] = j - 1;
            }
        }
    }
    string ans = "";
    int i = n, j = m;
    while (i || j){
        if (bi[i][j] < i && bj[i][j] < j){
            ans += s[i - 1];
        }
        int ii = bi[i][j];
        int jj = bj[i][j];
        i = ii;
        j = jj;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 106112
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	if(k > ((n - 1) * (n - 2)) / 2) cout << -1 << endl;
	else{
		k = ((n - 1) * (n - 2) / 2) - k;
		cout << n - 1 + k << endl;
		repn(i, 2, n + 1) cout << 1 << " " << i << endl;
		repn(i, 2, n + 1) repn(j, i + 1, n + 1){
			if(!k) goto end;
			cout << i << " " << j << endl;
			k--;
			if(!k) goto end;
		}
	}
end:;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(int(a / b))
    else:
        break



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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

ll dp[100001]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n,w;
	cin>>n>>w;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		for(ll j=w;j>=0;j--){
			if(dp[j]!=0&&j+a<=w){
				dp[j+a]=max(dp[j+a],dp[j]+b);
			}
		}
		dp[a]=max(dp[a],b);
	}
	ll maxi=0;
	for(ll i=0;i<=w;i++){
		maxi=max(maxi,dp[i]);
	}
	cout<<maxi<<endl;

	return 0;
}

Measured memory_bytes: 1024
mod = 998244353

def modinv(x, m = mod):
    b = m
    u = 1
    v = 0
    while b:
        t = x // b
        x -= t * b
        x, b = b, x
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))

    pow2 = [0 for _ in range(n+1)]
    pow2[0] = 1
    for i in range(n):
        pow2[i+1] = (pow2[i] * 2) % mod

    ans = 0
    dp = [0 for _ in range(s+1)]
    dp[0] = pow2[n]
    for i in range(n):
        dp_next = [0 for _ in range(s+1)]
        for j in range(s+1):
            dp_next[j] = (dp_next[j] + dp[j]) % mod
            if j + a[i] <= s:
                dp_next[j+a[i]] = (dp_next[j+a[i]] + (dp[j] * modinv(2))) % mod
        dp = dp_next

    print(dp[s])

if __name__ == '__main__':
    main()


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

typedef long long ll;
int a[3010],b[3010];
int dp[3010][3010][2];
signed main(){
   int n,T;
   cin>>n>>T;
   vector<pair<int,int>>v(n);
   REP(i,n) {
       cin>>a[i]>>b[i];
   }
  for (int i = 0; i < n; i++)
  {
      for (int t = 0; t < T; t++)
      {
           dp[i+1][t][0] = max( dp[i+1][t][0], dp[i][t][0]);
           dp[i+1][t][1] = max( dp[i+1][t][1], dp[i][t][1]);
          if(t+a[i]<T){
          dp[i+1][t+a[i]][0] = max( dp[i+1][t+a[i]][0] , dp[i][t][0]+b[i]);
          dp[i+1][t+a[i]][1] = max( dp[i+1][t+a[i]][1] , dp[i][t][1]+b[i]);
          }
         dp[i+1][t][0] = max( dp[i+1][t][0], dp[i][t][0]);
          dp[i+1][t][1] = max( dp[i+1][t][1] , dp[i][t][0]+b[i]); 
      }
      
  }
  cout<<dp[n][T-1][1]<<endl;
   


  
    return 0;
}

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

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    vector<int> v2(v);
    sort(ALL(v2));
    
    int l = v2[n/2-1], r = v2[n/2];
    REP(i,n) {
        if (v[i] < r) OUT(r)
        else OUT(l)
    }

    return 0;
}

Measured memory_bytes: 3840