akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;


int board[2010][2010];
signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    int sum = 0, white = 0;
    for(int i = 0; i < N; i++){
        int x,y; char c; cin >> x >> y >> c;
        x %= 2 * K;
        y %= 2 * K;
        if(c == 'B') {
            board[x+1][y+1]++;
            sum++;
        }
        else{
            board[x+1][y+1]--;
            sum--;
            white++;
        }
    }

    for(int i = 1; i <= 2*K; i++){
        for(int j = 1; j <= 2*K; j++){
            board[i][j] += board[i][j-1];
        }
    }
    for(int j = 1; j <= 2*K; j++){
        for(int i = 1; i <= 2*K;i++){
            board[i][j] += board[i-1][j];
        }
    }
    int ma = -INF;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            int a = board[i][j];
            int b = board[i+K][j+K] - board[i+K][j] - board[i][j+K] + board[i][j];
            int c = board[2*K][j] - board[i+K][j];
            int d = board[i][2*K] - board[i][j+K];
            int e = board[2*K][2*K] - board[2*K][j+K] - board[i+K][2*K] + board[i+K][j+K];
            int tmp = a+b+c+d+e;
            ma = max(ma,max(tmp,sum-tmp));
        }
    }
    ma += white;
    cout << ma << endl;

}

Measured memory_bytes: 16000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] tmp = br.readLine().split(" ");
			long h = Long.parseLong(tmp[0]);
			long w = Long.parseLong(tmp[1]);
			if(h == 0 && w == 0)break;
			else write(h, w);
		}
	}
	
	private static void write(long h, long w){
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < w;i++){
			sb.append("#");
		}
		sb.append(String.format("%n"));
		String line = sb.toString();
		sb.delete(0, sb.length());
		for(int i = 0;i < h;i++){
			sb.append(line);
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 18444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 36

typedef struct{
  char c;
  int value;
} Card;

Card card1[N], card2[N];

void BubbleSort(Card C[], int n){

  int i, j, temp=0;
  char ctemp;
  
  for(i=0; i<n; i++){
    for(j=n-1; j>=i+1; j--){
      if(C[j].value < C[j-1].value){
	temp = C[j].value;
	ctemp = C[j].c;
	C[j].value = C[j-1].value;
	C[j].c = C[j-1].c;
	C[j-1].value = temp;
	C[j-1].c = ctemp;
      }
    }
  }
}

void SelectionSort(Card C[], int n){

  int i, j, minj=0, temp=0;
  char ctemp;

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(C[j].value < C[minj].value){
	minj = j;
      }
    }
    temp = C[i].value;
    ctemp = C[i].c;
    C[i].value = C[minj].value;
    C[i].c = C[minj].c;
    C[minj].value = temp;
    C[minj].c = ctemp;
  }
}

int isStable(Card c1[], Card c2[], int n){
  int i;

  for(i=0; i<n; i++){
  if(c1[i].c != c2[i].c) return 0;
  }

  return 1;
}

int main() {

  int i, n, v;
  char S[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", S);
    card1[i].c = S[0];
    card1[i].value = atoi(&S[1]);
  }

  for(i=0; i<n; i++){
    card2[i].c = card1[i].c;
    card2[i].value = card1[i].value;
  }

  BubbleSort(card1, n);
  for(i=0; i<n; i++){
    printf("%c%d",card1[i].c, card1[i].value);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("Stable\n");

  SelectionSort(card2, n);
  for(i=0; i<n; i++){
    printf("%c%d",card2[i].c, card2[i].value);
    if(i!=n-1) printf(" ");
  }
  printf("\n");

  if(isStable(card1, card2, n)){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

Measured memory_bytes: 612
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> C(M);
    vector<int> A(M);
    rep(i,M) {
        int k; cin >> C[i] >> k;
        rep(j,k) {
            int c; cin >> c;
            --c;
            A[i] |= (1<<c);
        }
    }

    vector<int> dp(1<<N,1e9);
    dp[0] = 0;
    rep(mask,1<<N) {
        rep(i,M) {
            chmin(dp[mask|A[i]],dp[mask] + C[i]);
        }
    }

    if (dp[(1<<N)-1] == 1e9) cout << -1 << ln;
    else cout << dp[(1<<N)-1] << ln;
}

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


int main(){
    int n;
    cin >> n;
    int a[n], left = 0, maxm = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for(int i = 1; i < n; i++)
    {
        if(a[i] > a[i-1])
            left = i;
        maxm = max(maxm, i - left);
    }
    cout << maxm<< endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int N,i;
    long int sum;

    sum=0; 

    scanf("%d",&N);

    for(i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0 && i%15!=0){
            sum += i;
        }
    }
    printf("%ld\n",sum);





    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int m1,m2,d1,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    m1 %= 12;
    cout << (m1+1==m2? 1 : 0) << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string ans = "Balanced";
    if(a+b>c+d)ans="Left";
    else if(a+b<c+d)ans="Right";
    cout<<ans<<endl;
    
    return 0;
}

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

#define N_Max 200001
#define A_Max 1000001
using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long k,n;
  long long res=0;
  long long flg,tmp;
  long long i,j;
  long pn2[1000001]={};
  long pn[10000000]={};
  long c_pn=0;
  
  cin>>n;

  for(i=2;i<1000000;i++){
    if(pn2[i]==0){
      for(j=i+i;j<1000000;j+=i){
        pn2[j]=1;
      }
    }
  }
  for(i=2;i<1000000;i++){
    if(pn2[i]==0){
      pn[c_pn]=i;
      //cout<<pn[c_pn]<<endl;
      c_pn++;
    }
  }
  
  //cout<<c_pn<<endl;
  
  for(i=0;pn[i]<=n && i<c_pn;i++){
    tmp=0;
    do{
      if(n%pn[i]==0){
        tmp++;
        n=n/pn[i];
      }
      else{
        break;
      }
    }while(1);
    if(tmp!=0){
	  //cout<<pn[i]<<" "<<tmp<<" "<<n<<endl;
      //cout<<(pow(2.0*double(tmp)+0.25,0.5)-0.5)<<endl;
      res+=long(pow(2*tmp+0.25,0.5)-0.5);
    }
  }
  //cout<<res<<" "<<n<<endl;
  if(n!=1){
    res++;
  }
  cout<<res<<endl;
  
  return 0;
  
}      

Measured memory_bytes: 89968
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
 
    ll dp[105][100005];
    
int main(){
    int n;
    ll W;
    cin>>n>>W;
    vector<ll>w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    rep(i,n+1)rep(j,100005)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,n)rep(j,100005){
      if(j<v[i])dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
    }
    ll ans=0;
    rep(i,100005)if(dp[n][i]<=W)ans=i;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 80256
import math

N, D = map(int, input().split())

tmp = []

for _ in range(N):
    x = list(map(int, input().split()))
    tmp.append(x)

cnt = 0

for i in range(len(tmp)):
    for j in range(len(tmp))[i+1:]:
        y = 0
        for k in range(D):
            y += abs(tmp[i][k] - tmp[j][k]) ** 2


        if math.sqrt(y).is_integer():
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
n = int(input())
h = list(map(int,input().split(" ")))

max_row = 0
count = 0

for i in range(len(h)-1):
  if (h[i] >= h[i+1] ):
    count += 1
    if ( i == len(h)-2 and max_row < count):
      max_row = count
  else:
    if (max_row < count):
      max_row = count
    count = 0
  
print(max_row)

Measured memory_bytes: 14252
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = input()
    ans = 0
    before = 'A'
    i = 0
    while i < len(S):
        T = S[i]
        while i + 1 < len(S) and T == before:
            i += 1
            T += S[i]
        i += 1
        ans += 1
        if T == before:
            ans -= 1
        before = T
    print(ans)
if __name__ == '__main__':
    main()

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

const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

void solve(long long N, long long M) {
    ll num = 2;
    vector<ll> factors;
    ll sum = 0;
    while (M >= num * num) {
        ll temp = 0;
        while (M % num == 0) {
            M /= num;
            temp++;
        }
        if (temp) {
            // cerr << "M=" << M << "num=" << num << "temp=" << temp << endl;
            factors.push_back(temp);
            sum += temp;
        }
        num++;
    }
    if (M > 1) {
        factors.push_back(1);
        sum++;
    }

    combination comb = combination(int(1e6) + 5);
    mint ans = 1;

    for (ll fact : factors) {
        ans *= comb(fact + N - 1, fact);
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 18836
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,Q;
int A[3010],X[3010],Y[3010];
ll dp[3010][3010][2];
ll modpow(int m){
  ll res=1;
  rep(i,m){
    res=(res*2)%MOD;
  }  
  return res;
}
int Extgcd(int a,int b,int &x,int &y){
  int d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

int Invmod(int a,int p){//mod pでのaの逆元を求める
  int x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
void solve(){
  rep(i,N){
    rep(j,N){
      if(A[i]<=A[j]){
	dp[i][j][0]=0;
      }
      else dp[i][j][0]=1;
    }
  }
  ll in2=Invmod(2,MOD);
  rep(i,Q){
    int x=X[i],y=Y[i];
    rep(j,N){
      if(j!=y&&x!=j) {
	dp[x][j][1]=(in2*((dp[x][j][0]+dp[y][j][0])%MOD))%MOD;
	//	dp[j][x][1]=(1-dp[x][j][1]+MOD)%MOD;
	dp[j][x][1]=(in2*((dp[j][x][0]+dp[j][y][0])%MOD))%MOD;
	dp[y][j][1]=(in2*((dp[x][j][0]+dp[y][j][0])%MOD))%MOD;
	//	dp[j][y][1]=(1-dp[y][j][1]+MOD)%MOD;
	dp[j][y][1]=(in2*((dp[j][x][0]+dp[j][y][0])%MOD))%MOD;
      }
    }
    dp[x][y][1]=dp[y][x][1]=(in2*((dp[x][y][0]+dp[y][x][0])%MOD))%MOD;
    rep(j,N){
      if(j!=y&&x!=j){
	  dp[x][j][0]=dp[x][j][1];
	  dp[j][x][0]=dp[j][x][1];
	  dp[y][j][0]=dp[y][j][1];
	  dp[j][y][0]=dp[j][y][1];
	}
    }
    dp[x][y][0]=dp[x][y][1];
    dp[y][x][0]=dp[y][x][1];


    /*  rep(a,N){
      rep(b,N){
	std::cout<<dp[a][b][0]<<" ";
      }
      std::cout<<"\n";
      }*/
  }
  ll res=0;
  ll q=modpow(Q);
  rep(i,N){
    for(int j=i+1;j<N;j++){
      res=(res+(q*dp[i][j][0])%MOD)%MOD;
    }
  }

  prin(res);
}


int main(){
  cin>>N>>Q;
  rep(i,N) cin>>A[i];
  rep(i,Q){
    cin>>X[i]>>Y[i];
    X[i]--;Y[i]--;
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 141568
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n, m;
	long long int count = 1;

	cin >> n >> m;
	if (abs(n - m) >= 2) {
		count = 0;
	}
	else if (abs(n - m) == 0) {
		RFOR(i, n, 1) {
			count *= i;
			if (count > MOD) {
				count %= MOD;
			}
		}
		RFOR(i, m, 1) {
			count *= i;
			if (count > MOD) {
				count %= MOD;
			}
		}
		count *= 2;
		if (count > MOD) {
			count %= MOD;
		}
	}
	else {
		RFOR(i, n, 1) {
			count *= i;
			if (count > MOD) {
				count %= MOD;
			}
		}
		RFOR(i, m, 1) {
			count *= i;
			if (count > MOD) {
				count %= MOD;
			}
		}
		if (count > MOD) {
			count %= MOD;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    a77(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a77(args: Array<String>) {
    if (args.size != 2) {
        throw IllegalArgumentException()
    }
    val (first, second) = args
    println(if (first == second.reversed()) "YES" else "NO")
}


Measured memory_bytes: 33788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n/2; ++i) {
        if(s[i] != s[n-1-i]) ++ans;
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,n;
	cin>>h>>n;
	ll ah[1002],bm[1002];
	ll ch[20010];
	ch[0]=0;
	for(ll i=1;i<20010;i++){
		ch[i]=INF;
	}	
	for(ll i=0;i<n;i++){
		cin>>ah[i]>>bm[i];
	}
	ll ans=INF;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<n;j++){
			ch[i+ah[j]]=min(ch[i+ah[j]],ch[i]+bm[j]);
			if(i+ah[j]>=h){
			ans=min(ans,ch[i+ah[j]]);
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    
    int c = stoi(a+b);
    
    double tmp = sqrt(c);
    
    if (tmp - (int)tmp == 0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector<int>(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        y: usize,
    }

    let bills = vec![10000, 5000, 1000];

    let mut possible = false;
    'outer: for i in 0..n + 1 {
        for j in 0..n + 1 - i {
            let sum = bills[0] * i + bills[1] * j + bills[2] * (n - i - j);
            if sum == y {
                possible = true;
                println!("{} {} {}", i, j, n - i - j);
                break 'outer;
            }
        }
    }

    if !possible {
        println!("{} {} {}", -1, -1, -1);
    }
}


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

int main(int argc, char const *argv[])
{    
   
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1;
    cin>>s2;
    reverse(s1.begin(),s1.end());
    if(s1==s2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
from sys import exit
import copy
# import numpy as np
from collections import deque

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0


a.insert(0, 0)
b.insert(0, 0)


for i in range(1, n+1):
    a[i] += a[i-1]

for i in range(1, m+1):
    b[i] += b[i-1]

tmp = m
for i in range(n+1):
    for j in range(tmp, -1, -1):
        if a[i] + b[j] <= k:
            cnt = max(cnt, i + j)
            tmp = j
            break


print(cnt)


Measured memory_bytes: 123412
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 1.0e+100

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    if (B - A) % 2 == 0:
        C = (B - A) // 2
        D = INF
    else:
        C = (B - A) // 2 + A
        D = (B - A) // 2 + (N-B + 1)

    return min(C, D)


def main():
    N, A, B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6860
#include <iostream>

using namespace std;

int main(){
  int a, b, c, x, y, lp, tmp, ans=1000000007;
  cin>> a >> b >> c >> x >> y;
  lp=max(x, y);
  c*=2;
  
  for(int i=0;i<=lp;i++){
  	tmp=max(0, a*(x-i))+max(0, b*(y-i))+i*c;
  	ans=min(ans, tmp);
  //cout<< i << " " << ans <<endl;
  }

  cout<< ans <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    ll a, b;
    cin >> a >> b;
    ll k = (a + b) / 2;
    if ((a + b) % 2 == 0)
    {
        cout << k << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x[101];
int main(){
	int n,k,sum=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=n;i++){
		if(x[i]<=k/2) sum+=x[i]*2;
		else sum+=(k-x[i])*2;
	}
	cout<<sum<<endl;
	return 0;
}

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

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

    int starts = s.size();
    int ends = 0;
    for (int i=0; i<s.size(); ++i) {
        if (s[i] == 'A') {
            starts = min(starts, i);
        }
        if (s[i] == 'Z') {
            ends = max(ends, i);
        }
    }

    cout << ends - starts + 1 << endl;

    return 0;
}


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

int n=10000;
vector<vector<int>> node(n, vector<int>(0));
vector<int> c(n);
vector<bool> ju(n, true);

void search(vector<vector<int>> &ar,int si) {
	int x = ar[si].size();
	vector<int> neo(0);
	for (int i = 0;i < x;i++) {
		int y = node[ar[si][i]].size();
		for (int j = 0;j < y;j++) {
			if (ju[node[ar[si][i]][j]]) {
				ju[node[ar[si][i]][j]]=false;
				neo.push_back(node[ar[si][i]][j]);
			}
		}
	}
	ar.push_back(neo);
	if (neo.size() == 0)
		return;
	search(ar, si + 1);
	return;
}

int main() {
	cin >> n;
	for (int i = 0;i < n - 1;i++) {
		int a, b;
		cin >> a >> b;
		node[a - 1].push_back(b - 1);
		node[b - 1].push_back(a - 1);
	}
	for (int i = 0;i < n;i++) {
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	vector<vector<int>> ar(1, vector<int>(1, 0));
	ju[0] = false;
	search(ar, 0);
	int co = 10000 - 1;
	vector<int> ans(n);
	long long su = 0;
	for (int i = 0;i < ar.size()-1;i++) {
		for (int j = 0;j < ar[i].size();j++) {
			ans[ar[i][j]] = c[co];
			if (co < 9999) {
				su = (long long)su + c[co];
			}
			co--;
		}
	}
	cout << su << endl;
	for (int i = 0;i < n;i++) {
		if (i < n - 1)
			cout << ans[i] << ' ';
		else
			cout << ans[i] << endl;
	}
}

Measured memory_bytes: 2876
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,k=map(int, input().split())
    if a>=k:
        print(a-k,b)
    elif a<k and k<=a+b:
        print(0,a+b-k)
    elif a<k and k>a+b:
        print(0,0)
resolve()

Measured memory_bytes: 3060
#include <stdio.h>

#define lli long long int

lli gcd(lli x, lli y) {
	return ((y == 0) ? x : gcd(y, x % y));
}

int main() {
	lli a, b, c, d, kpk, p, q, sum, ans;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	kpk = c / gcd(c, d) * d;
	p = b / c;
	q = (a - 1) / c;
	sum = p - q;
	p = b / d;
	q = (a - 1) / d;
	sum += (p - q);
	p = b / kpk;
	q = (a - 1) / kpk;
	sum -= (p - q);
	ans = b - a + 1 - sum;
	printf("%lld\n", ans);
	return 0;
}

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

int main(){

    int n, x;

    std::cin >> n;

    for ( int i = 1; i <= n; i++ ) {

        x = i;

        if ( x % 3 == 0 ) {
            std::cout << " " << i;
        }

        else for ( ; x; x /= 10 ) {
            if ( x % 10 == 3 ) {
                std::cout << " " << i;
                break;
            }
        }

    }

    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  string s,t;
  cin >> s;
  for (int i = 0; i < s.length(); ++i)
    if (i % 2 == 0) {
      t += s[i];
    }
    cout << t << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)






x,y=map(int,input().split())
z=int(abs(y)-abs(x))
print(int(abs(z))+(z*x<0)+(z*y<0) if z!=0 else 1)

Measured memory_bytes: 5124
#include<bits/stdc++.h>
#ifndef LOCAL_PROJECT
#define cerr if(0)cerr
#endif
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef __int128 lll;
const lll ONE=1;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int mn=2e5+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;
ll po(ll a,ll b=mod-2){
    ll ans=1;
    for(;b;b>>=1,a*=a,a%=mod)if(b&1)ans*=a,ans%=mod;
    return ans;
}
#define mid ((l+r)>>1)
ll a[mn];
int main(){
#ifdef LOCAL_PROJECT
    freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#else
    cin.tie(0);
    cin.sync_with_stdio(0);
#endif
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,[](ll a,ll b){return abs(a)>abs(b);});
    ll ans=1;
    bool neg=0;
    ll spos=inf,sneg=inf;
    for(int i=0;i<k;i++){
        ans*=abs(a[i]),ans%=mod;
        if(a[i]<0)neg^=1,sneg=abs(a[i]);
        else spos=abs(a[i]);
    }
    if(!neg){printf("%lld",ans);return 0;}
    ll lpos=-inf,lneg=-inf;
    for(int i=n-1;i>=k;i--){
        if(a[i]>=0)lpos=abs(a[i]);
        else lneg=abs(a[i]);
    }
    cerr<<spos<<endl<<sneg<<endl<<lpos<<endl<<lneg;
    if((spos==inf||lneg==-inf)&&(sneg==inf||lpos==-inf)){
        ans=1;
        for(int i=1;i<=k;i++)ans*=a[n-i],ans%=mod;
        if(ans<0)ans+=mod;
        printf("%lld",ans);
        return 0;
    }
    else if((spos==inf||lneg==-inf)||ONE*lpos*spos>ONE*lneg*sneg){
        ans*=lpos,ans%=mod,ans*=po(sneg),ans%=mod;
    }
    else{
        ans*=lneg,ans%=mod,ans*=po(spos),ans%=mod;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 5348
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K, std::vector<long long> V){
    ll L = min(N, K);
    ll ans = -INF;
    for(ll A =0; A <= L; A++){
        for(ll B = 0; B +A <= L; B++){
            priority_queue<ll, vll, greater<ll> > que;
            REP(i, A) que.push(V[i]);
            REP(i, B) que.push(V[N-i-1]);
            REP(i, K-A-B){
                if(que.empty())
                    break;
                if(que.top()< 0) {
                    que.pop();
                }else{
                    break;
                }
            }
            ll tmp = 0;
            while(!que.empty()){
                tmp += que.top();
                que.pop();
            }
            ans = max(ans, tmp);
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    solve(N, K, std::move(V));
    return 0;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())

X = X-1
Y = Y-1

kDict = {}

for kIndx in range(1, N+1):
    kDict[kIndx] = 0

for jIndx in range(N):
    for iIndx in range(jIndx):
        if (jIndx <= X) or (iIndx >= Y):
            kDict[jIndx - iIndx] += 1
        elif (iIndx <= X) and (jIndx >= Y):
            kDict[(jIndx - iIndx) - (Y - X - 1)] += 1
        elif (iIndx <= X) and ((jIndx > X) and (jIndx < Y)):
            if 2 * jIndx - (X + Y) - 1 > 0:
                kDict[(jIndx - iIndx) - (2 * jIndx - (X + Y) - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1
        elif ((iIndx > X) and (iIndx < Y)) and (jIndx >= Y):
            if (X + Y) - 2 * iIndx - 1 > 0:
                kDict[(jIndx - iIndx) - ((X + Y) - 2 * iIndx - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1
        else:
            if (2 * (jIndx - iIndx) - (Y - X) - 1) > 0:
                kDict[(jIndx - iIndx) - (2 * (jIndx - iIndx) - (Y - X) - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1

for kIndx in range(1, N):
    print(kDict[kIndx])


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll n;
	cin >> n;
	map<ll, ll> mp;
	for (ll i = 0; i < n; i++) {
		ll d;
		cin >> d;
		mp[d]++;
	}
	ll m;
	cin >> m;
	for (ll i = 0; i < m; i++) {
		ll t;
		cin >> t;
		if (mp[t] > 0) mp[t]--;
		else {
			NO();
			return 0;
		}
	}
	YES();
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main()
{
    int N, i;
    cin >> N >> i;

    cout << N-i+1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'

using namespace std;
void solve() {
    int r;
    cin >> r;
    cout << 2 * M_PI * r << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3784
n = int(input())
v = [{}, {}]
for i, vi in enumerate(map(int, input().split())):
    j = i % 2
    v[j].update([(vi, v[j][vi] + 1)]) if vi in v[j] else v[j].update([(vi, 1)])
f1 = lambda v, i: max(v[i], key=v[i].get) if len(v[i]) > 0 else 0
f2 = lambda v, i, k: v[i].pop(k) if len(v[i]) > 0 else 0
kMax, vMax = [], []
for i in [0, 1]:
    kMax.append([f1(v, 0), f1(v, 1)])
    vMax.append([f2(v, 0, kMax[i][0]), f2(v, 1, kMax[i][1])])
if kMax[0][0] != kMax[0][1]:
    print(n - sum(vMax[0]))
else:
    print(n - max([vMax[0][0] + vMax[1][1], vMax[0][1] + vMax[1][0]]))

Measured memory_bytes: 21044
N=gets.to_i
a = gets.chomp.split.map(&:to_i)
p=[-1,a[0]]
s=1
i=0
t=1
while i < N 
 if a[i]==0
    s=1
    p[1]=0
 end
 i=i+1
 end
 if p[1]!=0
 i=1
 while i < N && (s==1)
 p[1]=p[1]*a[i]
  if p[1]>10**18
     s=0
  end
i=i+1
end
end
puts p[s]

Measured memory_bytes: 23520
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        //入力
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int k=scn.nextInt();
        //処理
        int cnt=0;
        int answer=0;
        for(int i=1;i<=Math.max(a,b);i++){
            if(a%i==0&&b%i==0)cnt++;
        }
        int length=cnt;
        cnt=0;
        for(int i=1;;i++){
            if(a%i==0&&b%i==0)cnt++;
            if(cnt==length-k+1){
                answer=i;
                break;
            }
        }
        //出力
        System.out.println(answer);
    }
}

Measured memory_bytes: 21972
N, K = gets.chomp.split(' ').map(&:to_i)
d = gets.chomp.split(' ').map(&:to_i)
nd = (0..9).select { |i| !d.include?(i) }
k = N.to_s.split('').length
a = []
nd.repeated_permutation(k) {|args| a << args.join.to_i}
nd.repeated_permutation(k+1) {|args| a << args.join.to_i}
puts a.find {|i| i >= N}


Measured memory_bytes: 2556
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    A = LI()

    def lcm(a, b): return a * b // math.gcd(a, b)
    l = reduce(lcm, A, 1)

    ans = 0
    for ai in A:
        ans = (ans + l * pow(ai, MOD - 2, MOD)) % MOD

    print(ans)





if __name__ == '__main__':
    main()

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> ans(n);
    int f;
    for(int x=1;x<=100;x++) {
        for(int y=1;y<=100;y++) {
            for(int z=1;z<=100;z++) {
                f = x*x+y*y+z*z+x*y+y*z+z*x;
                if(f<=n) ans[f-1]++;
            }
        }
    }

    for(auto i:ans) {
        cout << i << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc134_c solver = new abc134_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc134_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            //ArrayList<Integer> A = new ArrayList();
            int A[] = new int[N];
            int wA[] = new int[N];

            for (int i = 0; i < N; i++) {
                //A.add(in.nextInt());
                A[i] = in.nextInt();
                wA[i] = A[i];
            }
            Arrays.sort(wA);
            for (int i = 0; i < N; i++) {
                if (A[i] == wA[N - 1]) {
                    out.println(wA[N - 2]);
                } else {
                    out.println(wA[N - 1]);
                }
            }

        /*

        for (int i = 0; i < N; i++) {
            Arr
            WORK.clear();
            for (int j = 0; j < N; j++) {
               if (j!=i) {
                   WORK.add(A.get(i));
               }
            }
            Arrays.sort(WORK);
            out.println(Arrays.sort(WORK));

        }
        */
        }

    }
}



Measured memory_bytes: 93432
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   map<int,int> cnt;
   for (int i = 0; i < 4; i++) {
      int n; cin >> n;
      cnt[n]++;
   }

   if (cnt[1] * cnt[9] * cnt[7] * cnt[4]) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stack>
 
using namespace std;
 
struct Info{
    Info(){ left = height = 0;}
    Info(int arg_left,int arg_height){
        left = arg_left;
        height = arg_height;
    }
    int left,height;
};
 
int main(){
 
    int H,W,max_s,tmp,tmp_h;
 
    scanf("%d %d",&H,&W);
 
    int** table = new int*[H+1];
    for(int i = 0; i < H+1; i++){
        table[i] = new int[W+1];
    }
 
    for(int i = 0; i < W+1; i++)table[0][i] = 0;
    for(int i = 0; i < H+1; i++)table[i][W] = 0;
 
    stack<Info> S;
    Info work;
 
    max_s = 0;
 
    for(int i = 1;i <= H; i++){
        for(int k = 0; k < W; k++){
            scanf("%d",&table[i][k]);
            if(table[i][k] == 0){
                table[i][k] = table[i-1][k] + 1;
            }else{
                table[i][k] = 0;
            }
        }
 
        tmp_h = table[i][0];
        S.push(Info(0,tmp_h));
 
        for(int k = 1; k < W+1; k++){
            if(table[i][k] > tmp_h){
                S.push(Info(k,table[i][k]));
                tmp_h = table[i][k];
            }else if(table[i][k] == tmp_h){
 
            }else{
                while(S.empty() == false && S.top().height >= table[i][k]){
                    work = S.top();
                    S.pop();
                    tmp = (k - work.left)*work.height;
                    max_s = (max_s >= tmp)?max_s:tmp;
                }
                tmp_h = table[i][k];
                S.push(Info(work.left,table[i][k]));
            }
        }
    }
 
    printf("%d\n",max_s);
 
    return 0;
}


Measured memory_bytes: 10380
from functools import reduce


def gcd(a, b):
    while b != 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    n = int(input())

    ts = []
    for _ in range(n):
        ts.append(int(input()))

    print(reduce(lcm, ts))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   string s;
   cin >> n;
   cin >> s;
   if(n<3200){
      cout << "red\n";
   }else{
      cout << s << '\n';
   }
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll rui[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;cin>>n>>q;
  string s;cin>>s;
  s+='O';
  for(int i=0;i<s.size()-2;i++){
    if(s[i]=='A'&&s[i+1]=='C')
      rui[i+1]+=rui[i]+1;
    else rui[i+1]+=rui[i];
  }
  rui[n]+=rui[n-1];
  for(int i=0;i<q;i++){
    ll l,r;cin>>l>>r;
    ll minus=0;
    if(s[r-1]=='A'&&s[r]=='C')minus++;
    cout<<rui[r]-rui[l-1]-minus<<endl;
  }
  return 0;
}


Measured memory_bytes: 1872
#include<iostream>
using namespace std;
int main(){
  int n;
  int a[8]={1,2,4,8,16,32,64,101};
  cin>>n;
  for(int i=0;i<8;i++){
    if(n<a[i] &&0<i){
      cout<<a[i-1];
      break;
    }
    else if(n==1){
      cout<<"1";
      break;
    }

  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


void yes(){
    cout<<"Yes"<<endl;
}
void no(){
    cout<<"No"<<endl;
}

int main(){fastio
    ll n,m;cin>>n>>m;
    vector<ll>v[n+1];
    rep(i,1,m){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    /*
    rep(i,1,n){
        cout<<i<<":";
        for(auto x:v[i])cout<<x<<" ";cout<<endl;
    }
     */
    ll c1=0;
    rep(i,1,n){
        if(v[i].size()%2==1){
            no();return 0;
        }
        if(v[i].size()==4)c1++;
        if(v[i].size()>=6)c1=100;
    }
    if(c1>=3)yes();
    else if(c1<=1)no();
    else{
        ll p=-1,q=0;
        rep(i,1,n){
            if(v[i].size()==4){
                if(p==-1)p=i;
                else q=i;
            }
        }
        bool used[n+1];memset(used,false,sizeof(used));
        used[p]=true;
        for(auto x:v[p]){
            if(x==q)continue;
            queue<ll>que;que.push(x);used[x]=true;
            while(!que.empty()){
                ll t=que.front();que.pop();
                for(auto y:v[t]){
                    if(x!=t&&y==p){
                        cout<<"Yes";return 0;
                    }
                    if(y==q){
                        while(!que.empty())que.pop();
                        break;
                    }
                    if(used[y])continue;
                    used[y]=true;
                    que.push(y);
                }
            }
        }
        no();
    }
    return 0;
}
/*
 
 5 7
 1 2
 1 3
 1 4
 5 2
 5 3
 5 4
 5 1
 */


Measured memory_bytes: 5888
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
priority_queue<PP,vector<PP>,greater<PP>> que;
int dp[110][110];
char maze[110][110];
void dijkstra(int gx,int gy){
    que.push({0,{gx,gy}});
    while(que.size()){
        PP p = que.top();
        que.pop();
        int x = p.second.first,y = p.second.second,num = p.first;
        if(dp[x][y]<=num) continue;
        dp[x][y] = num;
        if(x>0) que.push({num + (maze[x - 1][y]!=maze[x][y]),{x - 1,y}});
        if(y>0) que.push({num + (maze[x][y - 1]!=maze[x][y]),{x,y - 1}});
    }
}

int main(){
    int i,j,h,w;
    cin >> h >> w;
    for(i=0;i<h;i++){
        string s; cin >> s;
        for(j=0;j<w;j++){
            maze[i][j] = s[j];
            dp[i][j] = 300;
        }
    }
    dijkstra(h - 1,w - 1);
    dp[0][0] += (maze[0][0]=='#') + (maze[h - 1][w - 1]=='#');
    cout << dp[0][0]/2 << endl;
}


Measured memory_bytes: 384
INF = float("inf")

N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

ans = INF
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        for j in range(k - K + 1):
            dy = YY[j + K - 1] - YY[j]
            ans = min(ans, dx * dy)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9+7;
char s[20];
ll ksm(int a,int b)
{
    if(b<0) return 1;
    int ans=1;
    for(;b;b>>=1,a=a*a)if(b&1) ans=ans*a;
    return ans;
}
ll SUM(int a,int b)
{
    ll ans=0;
    for(int i=a;i<=b;i++)
    {
        ans*=10;
        ans+=s[i]-'0';
    }
    return ans;
}
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    scanf("%s",s);
    int len=strlen(s);
    ll sum=0;
    for(int i=0;i<len;i++)
    {
        for(int j=i;j<len;j++)
        {
            sum+=ksm(2,i-1)*SUM(i,j)*ksm(2,len-j-2);
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  if(k*2>b-a){
    for(int i=a;i<=b;i++){
      cout<<i<<endl;
    }
  }else{
    for(int i=0;i<k;i++)cout<<i+a<<endl;
    for(int i=0;i<k;i++)cout<<b-k+1+i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256