akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


bool ctn(ll a, ll b) {
    return (a | b) == a;
}

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

//    cout << bitset<30>(k) << endl;

    vector<P> v(n);
    for (P &p:v)cin >> p.first >> p.second;
    ll ans = 0;
    for (P p : v) if (ctn(k, p.first)) ans += p.second;

    rep(i, 32) {
        if (!((k >> i) & 1))continue;
        ll l = (k >> (i + 1));
//        cout << bitset<30>(l) << endl;

        ll now = 0;
        for (P p : v) {
            if ((p.first >> i) & 1) continue;
            if (!ctn(l, p.first >> (i + 1)))continue;
            now += p.second;
        }
//        cout << now << endl;
        cmax(ans, now);
    }
    cout << ans << endl;


}

Measured memory_bytes: 4844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <math.h>

int solve(int a, int b, int k)
{
    int i;

    for (i = 100; i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {return i;}
        }
    }

    return -1;
}

int main(int argc, char *argv[])
{
    int a, b, k;
    int ans;

    scanf("%d %d %d", &a, &b, &k);

    ans = solve(a, b, k);

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

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char N[3];

    //input
    cin >> N;

    if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  long N,A,B;in(N,A,B);
  out(N/(A+B)*A+min(N-N/(A+B)*(A+B),A));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define MOD (1000000007)

void init();
void solve();

signed main()
{
	init();
	solve();
}

int H, W, K;
vector<vector<ll> > dp;
vector<ll> fib;

void init()
{
	cin >> H >> W >> K;
	dp.resize(H+1, vector<ll>(W, 0));
	dp[0][0] = 1;
	fib.resize(W+10);
	fib[0] = fib[1] = 1;
	reps(i, 2, W+10) {
		fib[i] = fib[i-1] + fib[i-2];
	}
}

void update(int r)
{
	rep(i, W) {
		if (i == 0) {
			ll t = fib[W-1] * dp[r-1][i] % MOD;
			t += fib[W-2] * dp[r-1][i+1] % MOD;
			dp[r][i] += t % MOD;
		} else if (i == W-1) {
			ll t = fib[W-1] * dp[r-1][i] % MOD;
			t += fib[W-2] * dp[r-1][i-1] % MOD;
			dp[r][i] += t % MOD;
		} else {
			ll t = fib[i] * fib[W-i-1] % MOD * dp[r-1][i] % MOD;
			t += fib[i-1] * fib[W-i-1] % MOD * dp[r-1][i-1] % MOD;
			t += fib[i] * fib[W-i-2] % MOD * dp[r-1][i+1] % MOD;
			dp[r][i] += t % MOD;
		}
		dp[r][i] %= MOD;
	}
}

void solve()
{
	if (W == 1) {
		cout << 1 << endl;
		return;
	}
	reps(i, 1, H+1) {
		update(i);
	}
	cout << dp[H][K-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <queue>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    int p=0;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	p^=a[i];
    }
    for(int i=0;i<n;i++){
    	cout << (p^a[i]) << " ";
    }
    cout << endl;
}




Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll x[51] = {};
ll dp[51][51][3001] = {};
int main() {
	ll N, A; cin >> N >> A;
	rep(i, 0, N)cin >> x[i];

	dp[0][0][0] = 1;
	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, N*A) {
				if (k + x[i] <= N * A) {
					dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				}
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	repe(i, 1, N) {
		ans += dp[N][i][i*A];
	}

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

Measured memory_bytes: 60032
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int x;
  cin >> x;
  if (x == 1) {
    P("Hello World");
  } else {
    int a, b;
    cin >> a >> b;
    P(a + b);
  }

  return 0;
}



Measured memory_bytes: 256
<?php
$input = explode(' ', fgets(STDIN));
$a = intval($input[0]);
$b = intval($input[1]);
$c = intval($input[2]);

$cou = 0;

for($i=$a; $i <= $b; $i++) {
	if($c % $i === 0)
		$cou++;
}

echo "$cou\n";

Measured memory_bytes: 6560
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#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 uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n,k;
  cin>>n>>k;
  vl h(n);
  cin>>h;
  sort(rng(h));
  if(k>=n){
    cout<<0<<endl;
  } else{
    cout<<accumulate(h.begin(),h.end()-k,0ll)<<endl;;
  }
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(200002, 0);
  for(int i = 0; i < m; i++){
    int c, d;
    cin >> c >> d;
    if(c == 1) a.at(d)++;
    if(d == n) a.at(c)++;
    if(a.at(d) == 2){
      cout << "POSSIBLE";
      return 0;
    }
    if(a.at(c) == 2){
      cout << "POSSIBLE";
      return 0;
    }
  }
  cout << "IMPOSSIBLE";
}


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

long long int a[100005]={0};

long long int solve(long long int n, long long int sum){
    long long int ans = 0;
    for(int i=1;i<n;++i){
        long long int s = sum + a[i];
        if((s^sum) >= 0 || s == 0){
            ans += abs(s) + 1;
            s = (sum < 0 ? 1 : -1);
        }
        sum = s;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> a[i];
    long long int ans = solve(n, 1) + abs(1-a[0]);
    ans = min(solve(n, -1) + abs(-1-a[0]), ans);
    if(a[0] != 0)ans = min(solve(n, a[0]), ans);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int n, k;
vector<int> arr;

int main(){
    AC
    cin>>n>>k;
    int maxi = -1;
    arr.resize(n);
    for(int i=0; i<n; i++){
        cin>>arr[i];
        maxi = max(maxi, arr[i]);
    } 

    if(maxi==0 && k%2==1){
        cout<<0<<endl;
        return 0;
    }

    sort(arr.begin(), arr.end());

    if(maxi<0 && k%2==1){
        ll ans = 1;
        for(int i=arr.size()-1, j=0; j<k; j++, i--){
            ans = (ans*arr[i])%M;
        }
        cout<<(ans+M)%M<<endl;
        return 0;
    }

    ll ans = 1;
    int l=0, r=n-1;
    if(maxi>0 && k%2==1){
        ans = (ll)arr[n-1];
        r=n-2;
        k-=1;
    }

    while(k>0){
        ll left_prod = (ll)arr[l]*arr[l+1];
        ll right_prod = (ll)arr[r]*arr[r-1];
        if(left_prod>right_prod){
            //cout<<"picking "<<arr[l]<<" "<<arr[l+1]<<endl;
            l+=2;
            left_prod%=M;
            ans = (ans*left_prod)%M;
        }
        else{
            //cout<<"picking "<<arr[r]<<" "<<arr[r-1]<<endl;
            r-=2;
            right_prod%=M;
            ans = (ans*right_prod)%M;
            //cout<<ans<<endl;
        }
        k-=2;
    }
    cout<<(ans+M)%M<<endl;
}

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

int main(){
	int N,ball,B=0,C=0;
	bool failure;
	cin>>N;
	for(int i=0;i<N;i++){
		failure=0;
		for(int j=0;j<10;j++){
			cin>>ball;
			if(ball<B && ball<C){failure=1;}
			if(B<ball && C<B){B=ball;}
			else if(C<ball && B<C){C=ball;}
			else if(C<B){C=ball;}
			else 		{B=ball;}
		}	
		if(failure) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		B=C=failure=0;
	}
	return 0;
}

Measured memory_bytes: 1152
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
    int n;
    cin>>n;
    vector<int>a;
    a.push_back(0);
    for(int i=0;i<n;i++){
        int k; cin>>k;
        a.push_back(k);
    }
    a.push_back(0);

    int total=0;
    for(int i=0;i<n+2;i++){
       total+=abs(a[i+1]-a[i]);
    }

    vector<int>cum1(n+2,0);
    for(int i=1;i<n+1;i++){
        cum1[i]=abs(a[i+1]-a[i-1]);
    }

    vector<int>cum2(n+2,0);
    for(int i=1;i<n+1;i++){
        cum2[i]=abs(a[i+1]-a[i])+abs(a[i]-a[i-1]);
    }

    for(int i=1;i<n+1;i++){
        cout<<total+cum1[i]-cum2[i]<<endl;
    }

    

}

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

int main() {
  int c=0;
  string s;
  cin >> s;
  if(s[0] == 'o') c++;
  if(s[1] == 'o') c++;
  if(s[2] == 'o') c++;
  
  cout << 700 + c*100 << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
       mut s:Chars,

    Q:usize,
    }
    let mut rev = false;
    let mut ss = VecDeque::new();
    for &x in s.iter() {
        ss.push_back(x);
    }

    for _ in 0..Q {
        input! {q:usize}
        if q == 1 {
            rev ^= true;
        } else {
            input! {f:usize,c:char}
            if rev ^ (f == 1) {
                ss.push_front(c);
            } else {
                ss.push_back(c);
            }
        }
    }
    let mut s = vec![];
    while let Some(x) = ss.pop_front() {
        s.push(x);
    }
    if rev {
        s.reverse();
    }
    for &x in s.iter() {
        print!("{}", x);
    }
    println!();
}


Measured memory_bytes: 6424
n, k = map(int, input().split())
nums = [0] * (10**5 + 1)
for _ in range(n):
    a, b = map(int, input().split())
    nums[a] += b
s = 0
for i in range(10**5 + 1):
    s += nums[i]
    if s >= k:
        print(i)
        break

Measured memory_bytes: 5736
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        int[][] dp = new int[a.length()+1][b.length()+1];
        for (int i=0; i<=a.length(); i++) {
            for (int j=0; j<=b.length(); j++) {
                if (i == 0 || j == 0) {
                    dp[i][j] = 0;
                } else if (a.charAt(i-1) == b.charAt(j-1)) {
                    dp[i][j] = 1 + dp[i-1][j-1];
                } else {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        // for (int i=0; i<=a.length(); i++) {
        //     for (int j=0; j<=b.length(); j++) {
        //         System.out.print(dp[i][j] + " ");
        //     }
        //     System.out.println();
        // }
        // System.out.println(dp[a.length()][b.length()]);
        StringBuilder sb = new StringBuilder();
        int i = a.length(), j = b.length();
        while (i > 0 && j > 0) {
            if (a.charAt(i-1) == b.charAt(j-1)) {
                sb.append(a.charAt(i-1));
                i -= 1;
                j -= 1;
            } else {
                if (dp[i][j] == dp[i-1][j]) {
                    i -= 1;
                } else {
                    j -= 1;
                }
            }
        }
        System.out.println(sb.reverse().toString());
    }
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int N;
    std::cin >> N;
    string S;
    std::cin >> S;
    string S_ori = S;
    S = string(N, '$') + S + string(N, '$');

    int max_num = 0;
    REP(i, S.size() - N) {
        int num = 0;
        REP(j, S_ori.size()) {
            if(S_ori[j] == S[i + j]) {
                int tmp = 1;
                while(j < S_ori.size()) {
                    j++;
                    if(S_ori[j] == S[i + j]) tmp++;
                    else break;
                }
                chmax(num, tmp);
                if(abs(N - (int)i) < num) {
                    num = abs(N - (int)i);
                    break;
                }
            }
        }
        chmax(max_num, num);
    }

    std::cout << max_num << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;


int main(){
	int n, l;
	string s[100];
	string ans="";
	scanf("%d%d", &n, &l);
	for (int i = 0; i < n; i++){
		char buf[101];
		scanf("%s", buf);
		s[i] = buf;
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++){
		ans += s[i];
	}
	printf("%s\n", ans.c_str());
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<"First"<<endl;
    return 0;
  }
  vector<vector<int> > g(n);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  vector<int> used(n,-1);
  queue<int> q;
  q.push(0);
  used[0]=0;
  int ma=0,mv;
  while(q.size()){
    int v=q.front();
    q.pop();
    if(used[v]>ma){
	 ma=used[v];
	 mv=v;
    }
    for(int i=0;i<g[v].size();i++){
	 int to=g[v][i];
	 if(used[to]==-1){
	   q.push(to);
	   used[to]=used[v]+1;
	 }
    }
  }

  used=vector<int>(n,-1);
  q=queue<int>();
  q.push(mv);
  used[mv]=0;
  ma=0;
  while(q.size()){
    int v=q.front();
    q.pop();
    ma=max(ma,used[v]);
    for(int i=0;i<g[v].size();i++){
	 int to=g[v][i];
	 if(used[to]==-1){
	   q.push(to);
	   used[to]=used[v]+1;
	 }
    }
  }
  if(ma%3==1)cout<<"Second"<<endl;
  else cout<<"First"<<endl;
  return 0;
}


Measured memory_bytes: 17520
h, w, m = gets.split(" ").map(&:to_i)
grid = {}
h_grid = Array.new(h+1, 0)
w_grid = Array.new(w+1, 0)

hmax = h_grid.max
h_arr = []
wmax = w_grid.max
w_arr = []

m.times do
  hi, wi = gets.split(" ").map(&:to_i)
  grid[[hi, wi]] = true
  h_grid[hi] ||= 0
  w_grid[wi] ||= 0
  h_grid[hi] += 1
  w_grid[wi] += 1
  
  if h_grid[hi] > hmax
    hmax = h_grid[hi]
    h_arr = [hi]
  elsif h_grid[hi] == hmax
    h_arr << hi
  end
  if w_grid[wi] > wmax
    wmax = w_grid[wi]
    w_arr = [wi]
  elsif w_grid[wi] == wmax
    w_arr << wi
  end
end

bomb = true
h_arr.each do |i|
  w_arr.each do |j|
    bomb = false unless grid[[i, j]]
    break unless bomb
  end
  break unless bomb
end

puts hmax + wmax + (bomb ? -1 : 0)



Measured memory_bytes: 59264
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int h, w; cin >> h >> w;
    vec<string> field(h);
    for (auto &e : field) cin >> e;

    int d[][2] = {
        { -1, -1 }, { -1, 0 }, { -1, 1 },
        { 0, -1 }, { 0, 0 }, { 0, 1 },
        { 1, -1 }, { 1, 0 }, { 1, 1 },
    };

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (field[i][j] == '#') {
                cout << '#';
                continue;
            }
            int cnt = 0;
            for (auto [dy, dx] : d) {
                int ny = i + dy;
                int nx = j + dx;
                if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
                cnt += field[ny][nx] == '#';
            }
            cout << cnt;
        }
        cout << endl;
    }
}



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

int main(){
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    //and it fucked the entire hardwork just bcz it we need to buy 2 for the same
    c=2*c;
    if(a>=c && b>=c){
        cout<<max(x,y)*c;
    }else if(a>=c && b<c){
        if(x>=y){
            cout<<x*c;
        }else{
            cout<<x*c+(y-x)*b;
        }
    }else if(a<c && b>=c){
        if(y>=x)cout<<y*c;
        else cout<<y*c+(x-y)*a;
    }else if(a<c && b<c){
        if(a+b>=c){
            ll allc,sep;
            allc=(x+y)*c;
            ll mn=min(x,y);
            sep=mn*c+(x-mn)*a+(y-mn)*b;
            cout<<min(allc,sep);
        }
        else cout<<x*a+y*b;
    }
}


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

int main() {
	int64_t N;
	cin >> N;
	int judge = 1;

	for (int i = 1; i <= 3500 && judge == 1; i++){
		for (int j = 1; j <= 3500 && judge == 1; j++){
			int64_t x = 4 * i * j - N * i - N * j;
			int64_t Z = N * i * j;
			if (x > 0){
				if (Z % x == 0){
					cout << i;
					cout << " ";
					cout << j;
					cout << " ";
					cout << Z / x;
					cout << endl;
					judge = 0;
					break;
				}
			}
		if (judge == 0){
			break;
		}
		}
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
int n,m,k,sx,sy,step[888][888],ans=1e9;
string s[888];
bool ch(int x,int y)
{
	return x>=0 && x<n && y>=0 && y<m && step[x][y]==0 && s[x][y]=='.';
}
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='S')
			{
				sx=i;
				sy=j;
			}
		}
	}
	queue<pii>q;
	q.push(pii(sx,sy));
	step[sx][sy]=1;
	while(!q.empty())
	{
		pii p=q.front();
		int x=p.first,y=p.second;
		q.pop();
		ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));
		for(int i=0;i<4;i++)
		{
			int nx=x+dx[i],ny=y+dy[i];
			if(ch(nx,ny) && step[x][y]<=k)
			{
				step[nx][ny]=step[x][y]+1;
				q.push(pii(nx,ny));
			}
		}
	}
	cout<<(ans+k-1)/k+1<<endl;
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int64_t x,y,z;
  x=1;
  y=2;
  z=1;
  for(int i=0;i<n;i++){
    x=(x*10)%1000000007;
  }
  for(int i=0;i<n;i++){
    y=(y*9)%1000000007;
  }
  for(int i=0;i<n;i++){
    z=(z*8)%1000000007;
  }
  if(x-y+z>0){
    cout<<(x-y+z)%1000000007<<endl;
  }
  else{
    cout<<(x-y+z+3000000021)%1000000007<<endl;
  }
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int X = cin.nextInt();

        if (X == 3 || X == 5 || X == 7)
        {
            Console.WriteLine("YES");
            return;
        }

        Console.WriteLine("NO");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11092
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});
process.stdin.on('end', () => {
  const [, line] = content
    .trim()
    .split('\n');
  const nums = line.split(' ').map(n => parseInt(n, 10));
  const max = Math.max(...nums);
  const min = Math.min(...nums);
  const sum = nums.reduce((prev, cur) => prev + cur);
  console.log(min, max, sum);
});



Measured memory_bytes: 19472
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long A = sc.nextLong();
      String b = sc.next();
      String B = b.substring(0,1)+b.substring(2,4);
      int C =Integer.parseInt(B);
      long D = A*C;
      System.out.println(D/100);
	}
}

Measured memory_bytes: 39256
// url: http://abc075.contest.atcoder.jp/tasks/abc075_c

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];

  struct Edge { size_t a, b; }
  auto e = new Edge[](m);
  foreach (i; 0..m) {
    auto rd2 = readln.split.to!(size_t[]), ai = rd2[0]-1, bi = rd2[1]-1;
    e[i] = Edge(ai, bi);
  }

  auto ans = 0;
  foreach (i; 0..m) {
    auto uf = UnionFind(n);
    foreach (j; 0..m)
      if (i != j) uf.unite(e[j].a, e[j].b);
    if (uf.countForests > 1) ++ans;
  }

  writeln(ans);
}

struct UnionFind
{
  import std.algorithm, std.range;

  size_t[] p; // parent
  const size_t s; // sentinel
  const size_t n;
  size_t countForests; // number of forests
  size_t[] countNodes; // number of nodes in forests

  this(size_t n)
  {
    this.n = n;
    s = n;
    p = new size_t[](n);
    p[] = s;
    countForests = n;
    countNodes = new size_t[](n);
    countNodes[] = 1;
  }

  size_t opIndex(size_t i)
  {
    if (p[i] == s) {
      return i;
    } else {
      p[i] = this[p[i]];
      return p[i];
    }
  }

  bool unite(size_t i, size_t j)
  {
    auto pi = this[i], pj = this[j];
    if (pi != pj) {
      p[pj] = pi;
      --countForests;
      countNodes[pi] += countNodes[pj];
      return true;
    } else {
      return false;
    }
  }

  auto countNodesOf(size_t i) { return countNodes[this[i]]; }
  bool isSame(size_t i, size_t j) { return this[i] == this[j]; }

  auto groups()
  {
    auto g = new size_t[][](n);
    foreach (i; 0..n) g[this[i]] ~= i;
    return g.filter!(l => !l.empty);
  }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define run  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ms(a,x) memset(a,x,sizeof(a))


ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
ll findGCD(ll arr[], ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
} 


// array 
ll findMaxGCD(ll arr[], ll n) 
{  
  ll high = 0; 
  ll i;
    for (i = 0; i < n; i++) 
        high = max(high, arr[i]); 
  
    ll count[high + 1] = {0}; 
    for ( i = 0; i < n; i++) 
        count[arr[i]]++; 
  
   ll counter = 0; 
  
   
    for ( i = high; i >= 1; i--) 
    { 
        ll j = i; 
       counter = 0; 
    
     
        while (j <= high) 
        { 
          
  
            if(count[j] >=2) 
               return j; 
  
           else if (count[j] == 1)          
                counter++;          
  
            j += i; 
  
            if (counter == 2)          
                return i; 
        } 
    } 
} 

int main()
 {
  run;

   ll n,i;
   cin>>n;
   ll a[n];
   for(i=0;i<n;i++)
     cin>>a[i];
     
    if( findGCD(a, n)!=1)
      cout<<"not coprime";
      else
      {
          
         if( findMaxGCD(a,n)!=1)
          cout<<" setwise coprime";
          else
          cout<<" pairwise coprime";
          
          
      }
   
 
 }

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  double n,k; cin>>n>>k;
  double ans;
  rep(i,n){
  	if(i>=k) ans++;
  	else{
    	int m=i;
        int time=0;
        while(k>m){
        	m*=2;
            time++;
            }
        double k=1;
        rep(i,time) k/=2;
        ans+=k;
        }
  }
  cout<<ans/n<<endl;
}

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

int main(){
        char a[100],b[26];
        int c[26];
        int i,j,k,n,flg,first,second,flg_fin,half;
        char first_c,second_c;


        while(1) {
                cin>>n;

                if(n==0) {
                        break;
                }

                flg_fin=0;
                first=0;
                second=0;
                k=0;


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


                for(i=0; i<n; i++) {
                        flg=0;
                      //  if(i>=1) {
                      //          cout<<i<<" first:"<<first_c<<first<<"second:"<<second_c<<second<<endl;
                      //  }
                        for(j=0; j<k; j++) { //kは既出の文字数
                                if(b[j]==a[i]) {
                                        c[j]++;
                                        flg=1; //countupした

                                        if(c[j]>first) {
                                                if(first_c==b[j]) { //
                                                        first++;
                                                }
                                                else{
                                                        second=first;
                                                        second_c=first_c;
                                                        first=c[j];
                                                        first_c=b[j];
                                                }
                                        }else if(c[j]>second) {
                                                second=c[j];
                                                second_c=b[j];  //
                                        }

                                        //    cout<<first_c<<first<<i<<endl;


                                }
                        }

                        if(flg==0) {  //新しい文字
                                b[k]=a[i]; //新しい文字
                                c[k]=1;
                                k++;
                                if(first==0) {
                                        first=1;
                                        first_c=a[i];
                                }else if(second==0) {
                                        second=1;
                                        second_c=a[i];
                                }
                        }

                        if((second+(n-(i+1)))<first) {
                                cout<<first_c<<' '<<i+1<<endl;
                                break;
                        }

                        if(i==n-1) {
                                if(first==second) {
                                        cout<<"TIE"<<endl;
                                }else{
                                        cout<<first_c<<' '<<i+1<<endl;
                                        break;
                                }
                        }

                }

        }
}



Measured memory_bytes: 3096
Scanf.scanf "%d" (fun n ->
    let ta = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun t a -> t, a)) in

    let rec loop i t a =
        if i = n then Printf.printf "%d\n" (t + a) else
            let t1, a1 = ta.(i) in

            let t2 = (t + t1 - 1) / t1 * t1 in
            let a2 = t2 / t1 * a1 in

            let a3 = (a + a1 - 1) / a1 * a1 in
            let t3 = a3 / a1 * t1 in

            if t2 >= t && a2 >= a then (
                if t3 >= t && a3 >= a then (
                    if t2 < t3 then loop (i + 1) t2 a2
                               else loop (i + 1) t3 a3
                ) else loop (i + 1) t2 a2
            ) else loop (i + 1) t3 a3
    in
    loop 1 (fst ta.(0)) (snd ta.(0))
)

Measured memory_bytes: 4232
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1000000007;
const int INF = 0x3f3f3f;
const double eps = 1e-9;

int n;
char s[3][55];

int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=0;i<2;i++)
        {
            scanf("%s",s[i]);
        }
        ll ans=1;
        int pre=-1;
        for(int i=0;i<n;i++)
        {
            if(s[0][i]==s[1][i])
            {
                if(pre==-1)
                {
                    ans=3;
                    pre=1;
                }
                else if(pre==1)
                {
                    ans=(ans*2)%mod;
                    pre=1;
                }
                else if(pre==2)
                {
                    ans=ans;
                    pre=1;
                }
            }
            else if(s[0][i]==s[0][i+1])
            {
                if(pre==-1)
                {
                    ans=6;
                    pre=2;
                }
                else if(pre==1)
                {
                    ans=(ans*2)%mod;
                    pre=2;
                }
                else if(pre==2)
                {
                    ans=(ans*3)%mod;
                    pre=2;
                }
                i++;
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"
#define t(...)

void solve() {
    int h, w; cin >> h >> w;
    pair<int, int> src = {0, 0};
    pair<int, int> dest = {0, 0};
    cin >> src.first >> src.second >> dest.first >> dest.second;
    src.first = src.first - 1;
    src.second = src.second - 1;
    dest.first = dest.first - 1;
    dest.second = dest.second - 1;
    vector<vector<int>> arr(h, vector<int>(w));
    for(int i = 0; i < h; i ++) 
        for(int j = 0; j < w; j ++) {
            char ch; cin >> ch;
            arr[i][j] = ch == '.';
        }
    vector<vector<bool>> visited(h, vector<bool>(w, 0));
    vector<vector<int>> dist(h, vector<int>(w, 1e9));    
    set<pair<int, pair<int, int>>> pq;
    pq.insert({0, src});
    dist[src.first][src.second] = 0;
    visited[src.first][src.second] = 1;
    auto can = [&](int i, int j, int d) {
        t(i, j, d);
        if(i >= 0 && j >= 0 && i < h && j < w && arr[i][j] == 1) {
            if(visited[i][j] == 0) {
                return 1;
            }
            if(dist[i][j] > d) {
                return 1;
            }
            return 0;
        }
        return 0;
    };
    while(pq.size()) {
        auto v = *pq.begin();
        t(v);
        int x = v.second.first, y = v.second.second, d = v.first;
        pq.erase(pq.begin());
        if(can(x + 1, y, d)) {
            visited[x+1][y] = 1;
            dist[x + 1][y] = min(dist[x+1][y], d);
            pq.insert({d, {x+1, y}});
        }
        if (can(x - 1, y, d))
        {
            visited[x-1][y] = 1;
            dist[x - 1][y] = min(dist[x-1][y], d);
            pq.insert({d, {x - 1, y}});
        }
        if (can(x, y + 1, d))
        {
            visited[x][y+1] = 1;
            dist[x][y + 1] = min(dist[x][y+1], d);
            pq.insert({d, {x, y + 1}});
        }
        if (can(x, y - 1, d))
        {
            visited[x][y-1] = 1;
            dist[x][y-1] = min(dist[x][y-1], d);
            pq.insert({d, {x, y - 1}});
        }
        for(int i = x-2; i <= x + 2; i ++) {
            for(int j = y-2; j <= y + 2; j ++) {
                if(can(i, j, d + 1)) {
                t("here", i, j);
                    visited[i][j] = 1;
                    dist[i][j] = min(dist[i][j], d + 1);
                    pq.insert({d + 1, {i, j}});
                }
            }
        }
        t("exiting");
    }
    t(dist);
    int ans = dist[dest.first][dest.second];
    cout << (ans == 1e9 ? -1 : ans) << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    int H, W; cin >> H >> W;

    vector<string> S(H);
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
    }

    //2次元配列
    vector<vector<int>> cnt(H, vector<int>(W));

    //横方向のカウント
    for (int i = 0; i < H; ++i) {
        vector<int> done(W);

        for (int j = 0; j < W; ++j) {
            //障害物ならスキップ
            if (S[i][j] == '#') {
                continue;
            }

            //既にカウントしたところならスキップ
            if (done[j]) {
                continue;
            }

            //障害物なしの長さをカウント
            int l = 0;
            while (j+l < W) {
                if (S[i][j+l] == '#') {
                    break;
                }
                ++l;
            }

            for (int k = 0; k < l; ++k) {
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }

    //縦方向のカウント
    for (int j = 0; j < W; ++j) {
        vector<int> done(H);

        for (int i = 0; i < H; ++i) {
            //障害物ならスキップ
            if (S[i][j] == '#') {
                continue;
            }

            //既にカウントしたところならスキップ
            if (done[i]) {
                continue;
            }

            //障害物なしの長さをカウント
            int l = 0;
            while (i+l < H) {
                if (S[i+l][j] == '#') {
                    break;
                }
                ++l;
            }

            for (int k = 0; k < l; ++k) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ans = max(ans, cnt[i][j] - 1);
        }
    }

    cout << ans << endl;
}

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

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

	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		if (a % 2 == 0)
			if (!(a % 3 == 0 || a % 5 == 0))
		{
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul N,M;
inline void solve(){
  IN2(N,M);
  OUT((1<<M)*(1900*M+100*(N-M)));
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main() {
    int A[3][3];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    int B[N];
    rep(i, N) cin >> B[i];

    rep(b, N) {
        rep(i, 3) {
            rep(j, 3) {
                if (B[b] == A[i][j]) A[i][j] = 0;
            }
        }
    }

    string ans = "No";

    if (A[0][0] + A[0][1] + A[0][2] == 0) ans = "Yes";
    if (A[1][0] + A[1][1] + A[1][2] == 0) ans = "Yes";
    if (A[2][0] + A[2][1] + A[2][2] == 0) ans = "Yes";

    if (A[0][0] + A[1][0] + A[2][0] == 0) ans = "Yes";
    if (A[0][1] + A[1][1] + A[2][1] == 0) ans = "Yes";
    if (A[0][2] + A[1][2] + A[2][2] == 0) ans = "Yes";

    if (A[0][0] + A[1][1] + A[2][2] == 0) ans = "Yes";
    if (A[0][2] + A[1][1] + A[2][0] == 0) ans = "Yes";

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

priority_queue<int> que;

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, n){
		int x; scanf("%d", &x);
		que.emplace(x);
	}
	REP(i, m){
		int x = que.top(); que.pop();
		que.emplace(x/2);
	}
	ll ans = 0;
	REP(i, n){
		ans += que.top(); que.pop();
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

int main(){
  int N;
  string s;
  cin >>N>>s;
  int r = N;
  int left_b=0;
  int right_w=0;
  REP(i,N){if(s[i]=='.')right_w++;}
  r = min(right_w,r);
  REP(i,N){
    if(s[i]=='.'){right_w--;}
    else{left_b++;}
    r = min(right_w+left_b,r);
  }

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

Measured memory_bytes: 640
N =  int(input())
A =[0]*N
B = [0]*N
for i in range(N):
    A[i] ,B[i] = map(int,input().split())
    
B_sort = sorted(range(len(B)), key=lambda k: B[k])
flag = True
time = 0
for i in B_sort:
    time += A[i]
    if time > B[i]:
        flag = False
        print('No')
        break

if flag:
    print('Yes')
    

Measured memory_bytes: 66392