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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        l: usize,
        r: usize
    }
    if r - l >= 2018 {
        println!("0");
        return;
    }
    let mut ans = 2019;
    for i in l..r {
        for j in i + 1..r + 1 {
            ans = min(ans, i * j % 2019);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
#include <cstdint>
#include<tuple>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;

vector<tuple<ll,ll,ll>> adj[100001];

ll mintime[100001];
bool kakutei[100001];

int main(void){
  string s[]={"Sunny", "Cloudy", "Rainy" };
  string t;
  cin>>t;
  rep0(i,3){
    if(s[i]==t){
      cout<<s[(i+1)%3]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n;
    ll d;
    cin >> n >> d;
    vector<pair<ll, ll>> arr(n);
    for(auto &x : arr)
        cin >> x.ff >> x.ss;
    d *= d;
    int cnt = 0;
    for(auto x : arr)
    {
        ll dist = x.ff * x.ff + x.ss * x.ss;
        if(dist <= d)
        	cnt++;
    }
    cout<<cnt;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 6364
//============================================================================
// Name        : aoj2502.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	int n, s[393], l[393], p[393], m, w[393], dp[394];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s[i] >> l[i] >> p[i];
	}
	cin >> m;
	for(int i = 0;i < m;i++){
		cin >> w[i];
	}
	fill(dp,dp + 394,-1);
	dp[0] = 0;
	for(int i = 0;i <= 393;i++){
		for (int j = 0; j < n; j++) {
			for (int k = s[j]; k <= l[j]; k++) {
				if (i - k >= 0) {
					dp[i] = max(dp[i - k] + p[j], dp[i]);
				}
			}
		}
	}
	for(int i = 0;i < m;i++){
		if(dp[w[i]] == -1){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i = 0;i < m;i++){
		cout << dp[w[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
     int n,k;
     cin>>n>>k;
     vi v(n);
     for(int i=0;i<n;i++)cin>>v[i];
        sort(all(v));
     ll ans=0;
     for(int i=0;i<n-k;i++)ans+=v[i];
        cout<<ans<<endl;
 }
}















Measured memory_bytes: 3996
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
	n += 1;
  n /= 2;
  n *= 2;

  for (int i = n-2; i > 0; i -= 2) {
    s = s.substr(0, i);
    int l = s.length();
			//cerr << s.substr(0, l / 2 ) << " " << s.substr(l / 2, l) << endl;
    if (s.substr(0, l / 2) == (s.substr(l / 2, l))) {
      break;
    }
  }

  cout << s.length() << endl;
  return 0;
}


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

int main(void){
    vector<int>A(26,0);
    string w;cin>>w;
    for(int i=0;i<w.size();i++){
        A[(int)w[i]-97]++;
    }
    for(int i=0;i<26;i++){
        if(A[i]%2==1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#define INF 100000000000
using namespace std;
 
int main() {
    int n,m,x;cin>>n>>m>>x;
    int c[n];
    int a[n][m];
    for(int i = 0;i<n;i++){
      cin >> c[i];
      for(int j = 0;j<m;j++){
      cin >>a[i][j];
      }  
    }
   long long kotae  = INF;
   for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

        long cg = 0;
        long long ag[m];
        for(int i = 0;i<m;i++) ag[i] = 0;
        for (int i = 0; i < (int)S.size(); ++i) {
           cg += c[S[i]];
           for(int j = 0;j<m;j++){
             ag[j] += a[S[i]][j];
           }      
        }
        bool dame = false;
        for(int i = 0;i<m;i++){
          if(ag[i] < x) dame = true;
        }
        if(dame != true){
          if(cg <= kotae) kotae = cg;
        }
　　}
    if(kotae == INF){
     cout<<"-1";
     return 0;
    }
    cout<<kotae;
    return 0;
}　

Measured memory_bytes: 3164
#include <iostream>
#include <cmath>
#include <cstring>
#include <limits>

const int nax = 1e5+5;
int arr[nax][3];
int dp[nax][3];

int main() {

	std::ios_base::sync_with_stdio(false);

	int N;
	std::cin >> N;

	for (int i=0; i<N; i++) {
		for (int j=0; j<3; j++) {
			std::cin >> arr[i][j];
		}
	}

	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];

	for (int i=1; i<N; i++) {
		for (int j=0; j<3; j++) {
			for (int k=0; k<3; k++) {
				if (j!=k) {
					dp[i][j] = std::max(dp[i][j], arr[i][j] + dp[i-1][k]);
				}
			}
		}
	}

	std::cout << std::max(dp[N-1][0], std::max(dp[N-1][1], dp[N-1][2]));

	return 0;
}



Measured memory_bytes: 2560
#include <cstdio>

char grid[10][10];

int main(){
  int H,W;
  int cnt=0;
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++){
    scanf("%s",grid[i]);
    for(int j=0;j<W;j++){
      cnt+=(grid[i][j]=='#');
    }
  }
  if(cnt==H+W-1){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
  return 0;
}


Measured memory_bytes: 128
N, C, K = gets.split.map(&:to_i)
ts = N.times.map{gets.to_i}.sort

ans = 1
capa = 1
time = ts[0]
(1...N).each do |i|
    if capa == C || ts[i] - time > K
        ans += 1
        capa = 1
        time = ts[i]
    else
        capa += 1
    end
end

puts ans

Measured memory_bytes: 4656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        
        long ans=0L;
        
        ans+=((N/500)*1000);
        N-=(ans/2);
        ans+=((N/5)*5);
        
        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
import collections
n,k = map(int, input().split())
l=[]
for i in range(n):
    x = list(map(int, input().split()))
    l+=x[1:]
c = collections.Counter(l)
s=0
for i in c.most_common():
    #print(i)
    if n == i[1]:
        s+=1
print(s)



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		a[i] = x + y;
		b[i] = x - y;
		
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int sol = max(abs(a[n - 1] - a[0]), abs(b[n - 1] - b[0]));
	printf("%d", sol);
	
	return 0;
}


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

int main(){
 UL N; string S; cin>>N>>S;
 UL ans=0;
 for(UL p=0; p<N-1; p++){
  bool ox = false;
  if(S[p]=='X' && S[p+1]=='O') ox=true;
  else if(S[p]=='O' && S[p+1]=='X') ox=true;
  if(ox){ ans++; p++; }
 }
 cout<<ans<<endl;
 return 0;
}



Measured memory_bytes: 3340
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-22:16:08:54
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  string s; cin >> s;
  int k; cin >> k;
  int n = s.size();

  if (n == 1) {
    cout << k / 2 << endl;
    return 0;
  }

  char c1 = s[0];
  if (all_of(s.begin(), s.end(), [&](char c){return c == c1;})) {
    cout << static_cast<int64>(n) * static_cast<int64>(k) / 2LL << endl;
    return 0;
  }

  if (s[0] == s[n - 1]) {
    int f_len = 0, b_len = 0;
    while (s[f_len] == s[0]) ++f_len;
    while (s[n - 1 - b_len] == s[n - 1]) ++b_len;

    int beg = 0;
    int sum = 0;
    while (beg < n) {
      int end = beg;
      while (end + 1 < n && s[end + 1] == s[beg]) {
        ++end;
      }
      int len = end - beg + 1;
      sum += len / 2;
      beg = end + 1;
    }

    int64 ans = static_cast<int64>(sum) * static_cast<int64>(k);
    if (f_len & 1 && b_len & 1) {
      ans += static_cast<int64>(k - 1);
    }
    cout << ans << endl;
  } else {
    int beg = 0;
    int sum = 0;
    while (beg < n) {
      int end = beg;
      while (end + 1 < n && s[end + 1] == s[beg]) {
        ++end;
      }
      int len = end - beg + 1;
      sum += len / 2;
      beg = end + 1;
    }

    cout << static_cast<int64>(sum) * static_cast<int64>(k) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int k, a, b, done=0;
    scanf("%d%d%d", &k, &a, &b);
    for(int i=a; i<=b; i++){
        if(i%k==0){
            printf("OK");
            done =1;
            break;
        }
    }
    if(done == 0){
        printf("NG");
    }

    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;

    char c = s[k - 1];
    //cout << c << endl;
    for (int i = 0; i < n; i++) {
        if (s[i] != c) {
            s[i] = '*';
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 300*300+10;
ll cost[MAX_N][20];
int nxt[MAX_N][20];

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    int n = h * w;
    vector<int> X(n), Y(n);
    rep(y, h) rep(x, w) {
        int a;
        cin >> a;
        --a;
        X[a] = x;
        Y[a] = y;
    }
    rep(i, n) rep(j, 20) {
        cost[i][j] = 0;
        nxt[i][j] = -1;
    }
    rep(i, n - d) {
        cost[i][0] = abs(X[i] - X[i+d]) + abs(Y[i] - Y[i+d]);
        nxt[i][0] = i+d;
    }
    REP(k, 1, 20) {
        rep(i, n) {
            if(nxt[i][k-1] == -1) continue;
            nxt[i][k] = nxt[nxt[i][k-1]][k-1];
            cost[i][k] = cost[i][k-1] + cost[nxt[i][k-1]][k-1];
        }
    }

    #ifdef DEBUG_MODE
    //DEBUG_2D
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 20; j++) printf("%2d",nxt[i][j]);
        printf("\n");
    }
    cout << endl;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 20; j++) printf("%2d",cost[i][j]);
        printf("\n");
    }
    #endif

    int q;
    cin >> q;
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        ll ans = 0LL;
        while(x < y) {
            // cout << x << " " << y << endl;
            repr(i, 20) {
                if(nxt[x][i] >= 0 && nxt[x][i] <= y) {
                    ans += cost[x][i];
                    x = nxt[x][i];
                    break;
                }
            }
        }
        // cout << x << " " << y << endl;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 22912
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

typedef  long long ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define endl "\n"
#define ioss ios::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define eb emplace_back



double startTime;
double gct()//get_current_time
{
    return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

void suraj();

int main()
{
    startTime=(double)clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt,"w",stdout);
    //ioss
    //int t;cin>>t;while(t--)
    suraj();
    //suraj2();
    //suraj3();
    //suraj4();
    return 0;
}
































int dp[100009];



void suraj(){
int n;cin>>n;
vector<int>v(n);
for(int &i:v)cin>>i;
dp[0]=0;dp[1]=abs(v[1]-v[0]);
for(int i=2;i<n;i++){
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],dp[i-2]+abs(v[i]-v[i-2]));
}
cout<<dp[n-1]<<endl;
}













Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 510000
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < n; ++i)

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = n % 1000;
    if (res == 0)
        cout << 0 << endl;
    else
        cout << 1000 - res << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll N, K;
long double A[200010];

int main() {
    cin >> N >> K;
    rep(i, N) {
        cin >> A[i];
    }
    sort(A, A + N, greater<long double>());

    ll l = 0, r = A[0];

    while (l != r - 1) {
        ll c = (l + r) / 2;
        //ここでK回切ってc以下を達成できるか調べる
        ll k = 0;
        bool check = true;
        rep(i, N) {
            k += (ll)ceil(A[i] / c) - 1;
            if (k > K) {
                check = false;
                break;
            }
        }
        if (check) r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 6756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	ll ans = 0;
	ll tow = N / 2;
	ans += min(min(min(D, S * 2), H * 4), Q * 8)*tow;
	ll one = N % 2;
	ans += min(min(S, H * 2), Q * 4)*one;

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

Measured memory_bytes: 256
N = int(input())
import sys
sys.setrecursionlimit(90000)

graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))

color = [-1 for _ in range(N)]
def dfs(p, c, color):
    color[p] = c
    cinv = 0 if c == 1 else 1
    for q, d in graph[p]:
        if color[q] != -1:
            continue
        if d % 2 == 1:
            color = dfs(q, cinv, color)
        else:
            color = dfs(q, c, color)
    return color

A = dfs(0, 0, color)
for a in A:
    print(a)

Measured memory_bytes: 79488
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a == b) {
            System.out.println("a == b");
        }
        else if(a > b) {
            System.out.println("a > b");
        }
        else {
            System.out.println("a < b");
        }
    }
}



Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main(){
    cin >> a >> b;
    for(int i = 1; i <= 2000; i += 1){
        if(int((double)i*0.08) == a && int((double)i*0.1) == b){
            cout << (int)i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  s <- getLine                                                                                                                                        
  let partS = filter (\x -> x `isInfixOf` s) $ subsequences s                                                                                         
  print $ maximum $ map length $ filter (\xs -> all (`notElem` xs) "BDEFHIJKLMNOPQRSUVWXYZ") partS

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

    int ans=h[0];
    for(int i=0; i<n-1; i++){
        ans+=max(0, h[i+1]-h[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, i, j, k, l, m, n, ans, tmp, hoge;

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

    cin >> n;
    cin >> k;
    vl x(n);
    rep(i, n) cin >> x[i];

    for (const auto &_x : x)
        a += min(abs(_x), abs(_x - k)) * 2;

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int n,a[100005],cnt[100005];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	int m=n;
	while(!cnt[m])
	m--;
	int s=n-cnt[m];
	if(cnt[m-1]!=s)
	return puts("No"),0;
	if(m==n-1 && cnt[m]==n)
	return puts("Yes"),0;
	if(2*m-s>n || m<=s)
	return puts("No"),0; 
	puts("Yes");
	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1e9 + 7;
using namespace std;

#ifndef ONLINE_JUDGE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}

//Check N size twiceeeeeeeeeeeeeeeeee, and verify it
const int N = 5*1e3 + 10;

const int inf = 1e18;
int dp[N][N], n;
pii v[N];

int32_t main(){_
	
	cin>>n;

	for (int i = 1; i <= n; ++i)
	{
		cin>>v[i].fi>>v[i].se;
		v[i].fi += v[i].se;
	}

	sort(v+1, v+n+1);

	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			dp[i][j] = inf;
		}
	}

	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i)
	{
		v[i].fi -= v[i].se;
		int H = v[i].fi;
		int P = v[i].se;
		for (int j = 1; j <= i; ++j)
		{
			dp[i][j] = dp[i-1][j];
			if(H >= dp[i-1][j-1]){
				smin(dp[i][j], dp[i-1][j-1] + P);
			}
		}
	}

	int best = 0;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			if(dp[i][j] != inf){
				smax(best, j);
			}
		}
	}

	cout<<best;
	return 0;
}

Measured memory_bytes: 196096
#include <stdio.h>

#define sqr(x) (x) * (x)

int main() {
	int count_rectangle = 0;
	int count_diamond = 0;
	int input[3];

	while(scanf("%d,%d,%d", &input[0], &input[1], &input[2]) != EOF) {
		if(sqr(input[0]) + sqr(input[1]) == sqr(input[2]))
			count_rectangle++;

		else if(input[0] == input[1])
			count_diamond++;
	}

	printf("%d\n%d\n", count_rectangle, count_diamond);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    if(a == b) ans = c;
    if(a == c) ans = b;
    if(b == c) ans = a;
    p(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int A, B;
int nCr[4001][4001], nCrT[4001][4002];
int dp[4002][4002];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  nCr[0][0] = 1;
  for (int i=1; i<=4000; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=i; j++) {
      nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % MOD;
    }
  }
  for (int i=0; i<=4000; i++) {
    for (int j=0; j<=i; j++) {
      add(nCrT[i][j], nCr[i][j]);
      if (j > 0) add(nCrT[i][j], nCrT[i][j-1]);
    }
  }
  dp[0][0] = 1;
  for (int n=1; n<=4000; n++) {
    for (int k=1; k<=4000; k++) {
      add(dp[n][k], nCrT[k-1][min(k-1, n-k)]);
    }
  }
  for (int n=0; n<=4000; n++) {
    for (int k=0; k<=4000; k++) add(dp[n+1][k], dp[n][k]);
  }

  cin >> A >> B;
  int s = 1; // RR...BB
  for (int pos=B; pos<A+B; pos++) {
    for (int b=1; b<=B; b++) {
      //cout<<"pos="<<pos<<", b="<<b<<"\n";
      int t = dp[A+B-pos][B-b];
      //cout << "s += "<<nCr[B-1][b-1]<<"*"<<t<<"=dp["<<A+B-pos<<"]["<<B-b<<"] ("<<nCr[A+B-pos][B-b]<<")\n";
      add(s, (1LL*nCr[B-1][b-1]*t) % MOD);
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 187904
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           System.IO

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getEdges es = do
  e <- getIntList
  eof <- isEOF
  if eof
    then return (e:es)
    else getEdges (e:es)

main = do
  n <- getInt
  es <- getEdges []

  vs <- VBM.new (n+1)
  VBM.set vs []

  forM_ es $ \[u, v, w] -> do
    tu <- VBM.read vs u
    VBM.write vs u ((v, w):tu)
    tv <- VBM.read vs v
    VBM.write vs v ((u, w):tv)

  vs' <- VB.freeze vs

  ds <- VM.new (n+1)
  VM.set ds (-1::Int)

  let dfs i d = do
        di <- VM.read ds i
        if di >= 0
          then return ()
          else do VM.write ds i d
                  forM_ (vs' VB.! i) $ \(j, w) -> dfs j (d+w)

  dfs 1 0

  forM_ [1..n] $ \i -> do
    when (i > 1) $ putStr " "
    di <- VM.read ds i
    putStr . show $ di .&. 1

  putStrLn ""

Measured memory_bytes: 57596
f[168],z[]={24,23,25,12,36,11,13,35,37,22,26,48},x,s,m;main(y){for(;s?++f[y*12+x+z[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:0;);for(x=100,s=23;++s<144;s%12<10?m=fmax(m,f[s]),f[s]&&--x:0);x=!printf("%d\n%d\n",x,m);}

Measured memory_bytes: 0
def main(n,lst):
    if len(set(lst)) != n:
        return "No"
    last = lst[0][-1]
    for e in lst[1:]:
        if e[0]==last:
            last = e[-1]
        else:
            return "No"
    return "Yes"
n = int(input())
lst = [input() for i in range(n)]
print(main(n,lst))


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d=c/(a*7+b);
    int e=c%(a*7+b);
    if(e%a!=0){
        if(e>a*7){
            cout << d*7+7 << endl;
            return 0;
        }
        cout << d*7+e/a+1 << endl;
        return 0;
    }
    else
    {
        if(e>a*7){
            cout << d*7+7 << endl;
            return 0;
        }
        cout << d*7+e/a << endl;
        return 0;
    }
    
}


Measured memory_bytes: 3116
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,m;
  cin >> n>>m;
  
  ll ans=0;
  vector<pair<ll,ll>> p(n);
  rep(i,n){
  cin>>p[i].fi>>p[i].se;
  }
  
  sort(all(p));
  
  ll buy = 0;
  rep(i,n){
    if(m-buy>p[i].se) {
    ans+=p[i].fi*p[i].se;
    buy+=p[i].se;  
    }
    else{
    ans+=p[i].fi*(m-buy);
    break;
    }
  }
  
  cout << ans << endl;
  
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    set<long long> a1 = {2,4,5,7,9};

    set<long long> a2 = {0,1,6,8};

    set<long long> a3 = {3};

    long long n;

    cin >> n;

    long long last = n%10;

    if(a1.find(last)!=a1.end()) {

        cout << "hon" << '\n';

    } else if(a2.find(last)!=a2.end()) {

        cout << "pon" << '\n';

    } else {

        cout << "bon" << '\n';

    }

    return 0;

}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int A, B, C;
	cin >>A >>B >>C;
	if((A==B)&&(B==C))
		cout <<"No" <<endl;
	else if (A==B)
		cout <<"Yes" <<endl;
	else if (B==C)
		cout <<"Yes" <<endl;
	else if (C==A)
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
from functools import cmp_to_key
def cmp(x, y):
  if x[0] < y[0]:
    return -1
  elif x[0] > y[0]:
    return 1
  else:
    return int(y[1]) - int(x[1])
n = int(input())
d = [input().split() for _ in range(n)]
for i in range(n):
  d[i].append(i + 1)
d.sort(key = cmp_to_key(cmp))
for i in range(n):
  print(d[i][2])


Measured memory_bytes: 3572
# s1 = "axx"
# s2 = "dxx"
# s3 = "axxx"
# puts s1 <= s2
# puts s1 <= s3
# puts s1 >= s3

N, L = gets.split.map(&:to_i)
S = Array.new(N)
N.times do |i|
  S[i] = gets
end
(S.map(&:chomp).sort {|a,b| a <=> b}).map {|s| print s}
puts
  


Measured memory_bytes: 1788
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            line = Console.ReadLine();
            strs = line.Split(' ');
            int Sum = 0;
            for(int i = 0; i < M; i++)
            {
                Sum += int.Parse(strs[i]);
            }
            if (Sum > N)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(N-Sum);
            }
        }
    }
}


Measured memory_bytes: 28296
from itertools import permutations
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]


def dfs(dep, a, b, c, not_use)->int:
    if dep == N:
        return abs(A-a)+abs(B-b)+abs(C-c) - 30 if min(a, b, c) > 0 else float('inf')
    else:
        d1 = dfs(dep+1, a+l[dep], b, c, not_use)+10
        d2 = dfs(dep+1, a, b+l[dep], c, not_use)+10
        d3 = dfs(dep+1, a, b, c+l[dep], not_use)+10
        d4 = dfs(dep+1, a, b, c, not_use+l[dep])

        return min(d1, d2, d3, d4)


print(dfs(0, 0, 0, 0, 0))


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int n, m, q;
vector<int>a(100), b(100), c(100), d(100), A(20);

int res = 0;
void dfs(int dep, int x){

    if(dep == n){
        int sum = 0;
        rep(i, q){
            if(A[b[i] - 1] - A[a[i] - 1] == c[i])sum += d[i];
        }
        res = max(res, sum);
        return;
    }

    REP(i, x, m){
        A[dep] = i;
        dfs(dep + 1, i);
    }

}

int main(){
    cin >> n >> m >> q;
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(0, 1);
    cout << res << endl;

}



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

int main(){
    int N;
    cin >> N;
    int A_list[2][100];
    int dp[3][101];
    for(int i=0; i<3; i++){
        for(int j=0; j<101; j++){
            dp[i][j] = 0;
        }
    }
    for(int i=0; i<2; i++){
        for(int j=0; j<N; j++){
            cin >> A_list[i][j];
        }
    }
    for(int i=0; i<2; i++){
        for(int j=0; j<N; j++){
            dp[i+1][j+1] = A_list[i][j] + (dp[i][j+1] >= dp[i+1][j] ? dp[i][j+1] : dp[i+1][j]);
        }
    }
    cout << dp[2][N];
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input())for i in range(h)]
e=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            p=[i,j]
            q=[p]
            t=[[1]*w for j in range(h)]
            t[p[0]][p[1]]=0
            g=0
            while q:
                c=[]
                for i,j in q:
                    a=[1,-1,0,0]
                    b=[0,0,1,-1]
                    for d in range(4):
                        if 0<=i+a[d]<h and 0<=j+b[d]<w:
                            if s[i+a[d]][j+b[d]]==".":
                                if t[i+a[d]][j+b[d]]:
                                    t[i+a[d]][j+b[d]]=0
                                    c.append([i+a[d],j+b[d]])
                if len(c)==0:
                    break
                else:
                    g+=1
                    q=c[::]
            e=max(e,g)
print(e)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define umap unordered_map
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const ll mod = 1e9 + 7; 
const int inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 


int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int s; cin >> s;
	vector<ll> dp(s+1, 0);
	for (int i = 3; i<=s; i++) dp[i] = 1;
	for (int i = 4; i<=s; i++) {
		for (int j = 3; j <= i; j++) {
			if (i - j >= 3) {
				dp[i] += dp[i-j];
				dp[i] %= mod;
			}
		}
	} 
	cout << dp[s] << '\n';
}
 


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

int main(void){
    int a, b, x;
    cin >> a >> b >> x;
    if(a <= x && x <= a+b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=10010010;
const double PI=3.141592653589;


int main(){
  int r; cin>>r;
  cout<<r*r<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  cout << (int)pow(N, 3) << endl;

  return 0;
}

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

int main() {
  int a,b,c,x,count;
  cin >> a >> b >> c >> x;
  count = 0;

  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      if(500*i+100*j<=x && 500*i+100*j+50*c>=x ) count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
import numpy as np

h, w = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
grid = (np.array(grid) == ".") * 1

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for j in range(w):
    if j == 0:
        L[:, j] = grid[:, j]
    else:
        L[:, j] = (L[:, j - 1] + 1) * grid[:, j]


for j in range(w - 1, -1, -1):
    if j >= w - 1:
        R[:, j] = grid[:, j]
    else:
        R[:, j] = (R[:, j + 1] + 1) * grid[:, j]

for i in range(h):
    if i <= 0:
        U[i, :] = grid[i, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * grid[i, :]


for i in range(h - 1, -1, -1):
    if i >= h - 1:
        D[i, :] = grid[i, :]
    else:
        D[i, :] = (D[i + 1, :] + 1) * grid[i, :]

print(np.max(L + R + U + D - 3))


Measured memory_bytes: 266508
n = 104730
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    n_i = int(input())
    if n_i == 0:
        break
    s = 0
    i = 0
    j = 0
    while i < n_i:
        j += 1
        if c[j] == 1:
            s += j + 1
            i += 1
    print(s)



Measured memory_bytes: 6464
#include <iostream>
using namespace std;
long long N, K, A[1 << 18];
int main() {cin >> N >> K;for (int i = 1; i <= N; i++) cin >> A[i];for (int i = K + 1; i <= N; i++) {if (A[i - K] < A[i]) cout << "Yes" << endl;else cout << "No" << endl;}return 0;}


Measured memory_bytes: 4544