akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  long long N;
  cin>>N;
  long long n;
  long long d;
  bool flag = false;
  for(long long h=1;h<=3500;h++){
    for(long long w=1;w<=3500;w++){
      d = 4*h*w-N*h-N*w;
      if(d<=0)continue;
      if(N*h*w%d==0){
        n = N*h*w/d;
        cout<<h<<" "<<n<<" "<<w<<endl;
        flag = true;
        break;
      }else{
        continue;
      }
    }
    if(flag)break;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

//#include "atcoder/all"
//using namespace atcoder;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<ll> p, q, r;
	rep(i,a){
		ll d;
		cin >> d;
		p.push(d);
	}
	rep(i,b){
		ll d;
		cin >> d;
		q.push(d);
	}
	rep(i,c){
		ll d;
		cin >> d;
		r.push(d);
	}
	r.push(-1);
	int red = 0, green = 0;
	ll ans = 0;
	rep(i,x+y){
		ll A = p.top();
		ll B = q.top();
		ll C = r.top();
		if(B <= A && C <= A){
			p.pop();
			ans += A;
			++red;
			if(red == x){
				while(!p.empty()) p.pop();
				p.push(-1);
			}
		}
		else if(A <= B && C <= B){
			q.pop();
			ans += B;
			++green;
			if(green == y){
				while(!q.empty()) q.pop();
				q.push(-1);
			}
		}
		else{
			r.pop();
			ans += C;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6376
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
object Main extends App {
  import scala.io.StdIn._


  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val a = readLine.trim.split(' ').map(_.toInt)
  val b = readLine.trim.split(' ').map(_.toInt)
  val andArray = mutable.ArrayBuffer[Int]()
  val orArray = ArrayBuffer[Int]().also{_.appendAll(b)}
  for (i ← a){
    if (binarySearch(b, i)){
      andArray.append(i)
    }else {
      orArray.append(i)
    }
  }
  println(s"${andArray.length} ${orArray.length}")
  if (andArray.nonEmpty) println(andArray.mkString("\n"))
  if (orArray.nonEmpty) println(orArray.sorted.mkString("\n"))


  def binarySearch(array: Array[Int], target: Int): Boolean = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) < target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    if (right < array.length) array(right) == target
    else false
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}



Measured memory_bytes: 141332
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i,j;
    int x=0;
    int y=0;
    int z1,z2;

    int n,m;
    int **a;
    int *b;

    scanf("%d %d",&n,&m);

    a =(int **)malloc(n*sizeof(int *));
    b =(int *)malloc(m*sizeof(int));

    for(i=0;i<n;i++){
        a[i] = (int *)malloc(m*sizeof(int));
    }

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(j==0){
                scanf("%d",&x);
            }
            else{
                scanf(" %d",&x);
            }
            a[i][j] = x;
        }
    }

    for(i=0;i<m;i++){
        scanf("%d",&x);
        b[i] =x;
    }


    for(i=0;i<n;i++){
        y=0;
        for(j=0;j<m;j++){
            z1 = a[i][j];
            z2 = b[j];
            y += z1*z2;
        }

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

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

    free(a);
    free(b);

    return 0;
}





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

int gcdx(int a, int b) {
  if (a % b == 0) return b;
  return gcdx(b, (a % b));
}

int main() {
  int k;
  int sum = 0;
  cin >> k;

  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int q = 1; q <= k; q++) {
        int x = gcdx(max(i, j), min(i, j));
        sum += gcdx(max(x, q), min(x, q));
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

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

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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=43;
int a[MAX_N],b[MAX_N],c[MAX_N];
int dp[450][450][43];
int main(){
	rep(i,450)rep(j,450)rep(k,43)dp[i][j][k]=INF;
	int n,m_a,m_b;
	cin>>n>>m_a>>m_b;
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	dp[0][0][0]=0;
	rep(l,n){
		rep(i,400){
			rep(j,400){
				dp[i][j][l+1]=min(dp[i][j][l+1],dp[i][j][l]);
				dp[i+a[l]][j+b[l]][l+1]=min(dp[i+a[l]][j+b[l]][l],dp[i][j][l]+c[l]);
	
			}
		}
	}
	int ans=INF;
	for(int i=1;i*(max(m_a,m_b))<450;i++){
		ans=min(ans,dp[i*m_a][i*m_b][n]);
	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
}


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

// ABC147 B - Palindrome-philia
// 2020.06.19

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int ans = 0;
  REP(i, N/2){
    if(S[i] != S[N-1-i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
//##Moh_K_Imar .......
//27/08/2020  ...  8.26
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a,b;
    cin>>a>>b;
    ll counter=0;
    for(ll i=0;i<b.size();i++){
        if(a[i]==b[i])counter++;
    }
    if(counter==a.size())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



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

bool isBinWord(string s, int len){
  string former, latter;
  for(int i=0;i<len/2;i++){
    former+=s[i];
    latter+=s[i+len/2];
  }
  
  return former==latter;
}

int main(){
  string s;
  int len, ans=1;
  bool isfinished = false;
  
  cin >> s;
  
  len = s.length();
  if(len % 2 ==1){
    len--;
    //delete 1
    s=s.erase(len);
    
    if(isBinWord(s, len)){
      ans = len;
      isfinished=true;
    }
  }

  len-=2;
  if(!isfinished){
  while(len>0){
    s=s.erase(len);
    if(isBinWord(s, len)){
      ans = len;
      isfinished = true;
      break;
    }
    len-=2;
  }
  }
  
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){
	
	ll a , b;
	cin >> a >> b;
	for(ll i = 1; i <= 100000; i++){
		if((i*8)/100 == a && i/10 == b){
			cout << i;
			return;
		} 
	}
	cout << "-1";
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
   // cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n),b(n),pa(n),pb(n);
    fr(i,n) cin>>a[i]>>b[i];
    iota(pa.begin(),pa.end(),0);
    iota(pb.begin(),pb.end(),0);
    sort(pa.begin(),pa.end(),[&](int i,int j){
        return a[i]<a[j];
    });
    sort(pb.begin(),pb.end(),[&](int i,int j){
        return b[i]<b[j];
    });
    if(n%2){
        cout<<b[pb[n/2]]-a[pa[n/2]]+1<<'\n';
    }
    else{
        cout<<b[pb[n/2]]+b[pb[n/2-1]]-a[pa[n/2]]-a[pa[n/2-1]]+1<<'\n';
    }
}

Measured memory_bytes: 6340
unittest
{
	assert( [ "4 4", "1 2", "2 3", "3 4", "4 1", "1 3" ].solve == 2 );
	assert( [ "3 3", "1 2", "2 3", "3 1", "1 2" ].solve == -1 );
	assert( [ "2 0", "1 2" ].solve == -1 );
	assert( [ "6 8", "1 2", "2 3", "3 4", "4 5", "5 1", "1 4", "1 5", "4 6", "1 6" ].solve == 2 );
}



import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto uvs = new long[ 2 ][ m ];
	foreach( ref uv; uvs )
	{
		input.popFront;
		uv = input.front.split.to!( long[] );
		uv[] -= 1;
	}
	input.popFront;
	auto s = 0L;
	auto t = 0L;
	input.front.formattedRead!"%s %s"( s, t );
	s--;
	t--;
	
	auto nss = toAdjacencyList( n, uvs );
	auto dss = bfsEx( nss, 3, s );
	return ( dss[ t ][ 0 ] == long.max ) ? -1 : dss[ t ][ 0 ];
}

// 辺配列から隣接リストを作成
auto toAdjacencyList( bool undirected = false )( long n, long[ 2 ][] es )
{
	auto nss = new long[][ n ];
	foreach( e; es )
	{
		nss[ e[ 0 ] ] ~= e[ 1 ];
		static if( undirected ) nss[ e[ 1 ] ] ~= e[ 0 ];
	}
	return nss;
}

// グラフの始点指定最短経路探索（幅優先探索）
auto bfsEx( long[][] nss, long c, long s )
{
	auto dss = new long[][]( nss.length, c );
	foreach( ref ds; dss ) ds[] = long.max;
	dss[ s ][ 0 ] = 0;
	
	auto queue = make!DList( tuple( s, 0L ) );
	while( !queue.empty )
	{
		auto fi = queue.front[ 0 ];
		auto fc = queue.front[ 1 ];
		queue.removeFront();
		
		foreach( ti; nss[ fi ] )
		{
			auto tc = ( fc + 1 ) % c;
			if( dss[ ti ][ tc ] < long.max ) continue;
			
			dss[ ti ][ tc ] = dss[ fi ][ fc ] + ( tc == 0 );
			queue.insertBack( tuple( ti, tc ) );
		}
	}
	return dss;
}


Measured memory_bytes: 18644
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>
#include <list>
#include <iterator>
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"


template <typename A, typename B> 
ostream& operator<<(ostream& os, pair<A,B> &p) {
	return os << "(" << p.first << "," << p.second << ")";
} 

template <typename A> 
ostream& operator<<(ostream& os, vector<A> &p) {
	for (auto &x : p) {
		os << x << " ";
	}
	os << endl;
	return os;
} 

vector<int> primes;
void siv(int n) {
	vector<bool> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			primes.push_back(i);
		}
	    if (is_prime[i] && (long long)i * i <= n) {
	        for (int j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
}

void foo(char *x, char *y) {
	while (*y != '\0') {
		*x = *y;
		x++, y++;
	}
	*x = '\0';
}

void xg() {
	int n, a, b;
	cin >> n;
	double total = 0, curr = 0;
	while (n--) {
		cin >> a >> b;
		total += b * 10;
		curr += a * b;
	}

	cout << "Current : " << curr << " / " << total << endl;
	cout << "% : " << curr / total * 10<< endl;
}

template <typename T>
T gcd(T a, T b) {
	if (a < 0) a *= -1;
	if (b < 0) b *= -1;
	
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}


// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

bool qsortComparator(const int &a, const int &b) {
	return a > b;
}

int partition(int lo, int hi, vector<int> &a) {
	int i = lo, j = hi + 1, element = a[lo]; // start element as pivot.
	while (true) {
		while (qsortComparator(a[++i], element)) {
			if (i == hi)
				break;
		}

		while (qsortComparator(element, a[--j])) {
			if (j == lo)
				break;
		}

		if (i >= j)
			break;

		swap(a[i], a[j]);
	}

	swap(a[lo], a[j]);
	return j;
}


void qsort(int lo, int hi, vector<int> &a) {
	if (lo >= hi)
		return ;
	int pivot = partition(lo, hi, a);
	qsort(lo, pivot - 1, a);
	qsort(pivot + 1, hi, a);
}

void getArr(vector<int> &a) {
	for (auto &it : a)
		cin >> it;
	sort(a.rbegin(), a.rend());
}

void solve() {
	string s;
	cin >> s;
	int ans = 0, res  = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'S') 
			ans = 0;
		else
			ans++;
		res = max(res, ans);
	}

	cout << res << endl;
}


int main(){
	IOS;
	


	int t = 1;
	// cin >> t;
	while (t--) 
		solve();

	return 0;
}



























 

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

using namespace std;

using int64 = long long;
const int mod = 924844033;

struct Combination
{
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
  {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main()
{
  Combination comb(2001, mod);

  int N, K;
  cin >> N >> K;
  vector< int > line[2001];
  for(int i = 0; i < N; i++) line[i % K].push_back(i);

  int ret = 0;

  vector< int > dp(N + 1);
  dp[0] = 1;
  for(int i = 0; i < 2 * K; i++) {
    vector< int > dp2(N + 1);
    for(int j = 0; (int) line[i % K].size() - j >= 0; j++) {
      auto add = comb.C((int) line[i % K].size() - j, j);
      for(int k = 0; k < N; k++) {
        if(dp[k] == 0 || j + k > N) continue;
        (dp2[j + k] += 1LL * dp[k] * add % mod) %= mod;
      }
    }
    dp.swap(dp2);
  }
  
  for(int i = 0; i <= N; i++) {
    auto sub = dp[i] * comb.fact(N - i) % mod;
    if(i % 2 == 0) (ret += sub) %= mod;
    else (ret += mod - sub) %= mod;
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200090;

ll n,m,k,ans;
ll a[maxn],b[maxn];
ll prea[maxn],preb[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans=0;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	n=read(),m=read(),k=read();
	for(int i=1;i<=n;i++) a[i] = read(),prea[i] = a[i],prea[i] += prea[i-1];
	for(int i=1;i<=m;i++) b[i] = read(),preb[i] = b[i],preb[i] += preb[i-1];
//	for(int i=1;i<=n;i++) printf("%d ",prea[i]); printf("\n"); 
	for(ll i = 0;i <= n; i++ )
 	{
		if(prea[i] > k) break;
		ll t = k-prea[i];
		ll pos = upper_bound(preb+1,preb+m+1,t)-preb;
//		printf("%d %d\n",t,pos);
		ans=max(ans,i+pos-1);
	}

	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 9948
#include<stdio.h>
int main()
{
int a,j,max,smax;
  scanf("%d",&a);
int b[a];
  scanf("%d %d",&b[0],&b[1]);
  if(b[0]>b[1]){max=b[0];
                smax=b[1];}
  else         {max=b[1];
                smax=b[0];}
  for(j=2;j<a;++j)
  {
  scanf("%d",&b[j]);
  if(b[j]>max) max=b[j];
  else if(b[j]>smax) smax=b[j];
  }
  
for(j=0;j<a;++j)  
{if(b[j]==max) printf("%d\n",smax);
else printf("%d\n",max);
}
  
return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#pragma warning (disable : 4996)
using namespace std;
int main()
{
	int n, cnt = 0;
	scanf("%d", &n);
	for (int i = 0, x; i < n; i++)
	{
		scanf("%d", &x);
		while (!(x % 2)) cnt++, x /= 2;
	}
	return !printf("%d\n", cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,r,c,si,an;
bool a[30][30],b[30][30]; 

void check() {

  cout << endl;
  cout << " --------------------------"<< endl;
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {

      cout <<a[i][j];
      if(j != n-1) cout <<" ";
    }
    cout << endl;
  }
  cout << "--------------------------"<< endl;
  cout<< endl;

}

/*void rotate() {
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      b[i][j] = a[i][j];
  
  
  for(int rt=0;rt<an/90;rt++) {
    
    for(int i=0;i<si;i++){
      for(int j=0;j<si;j++) {
	//printf("a[%d][%d](%d) = b[%d][%d](%d)\n",r+i,c+j,a[r+i][c+j],c+si-j-1,i+r,b[r+si-j-1][i+r]);
	a[r+i][c+j] = b[c+si-j-1][i+r];
      }
    }
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++) 
	b[i][j] = a[i][j];
    // check();   
  } 

} 

*/
void rotate(){
  for(int k=0;k<an/90;k++){
    for(int i=0;i<si;i++)
      for(int j=0;j<si;j++)
	b[i][j] = a[r+i][c+j];
     
    for(int i=0;i<si;i++)
      for(int j=0;j<si;j++)
    a[i+r][j+c] = b[si-j-1][i];
  }
}


void reversal() {

  for(int i=r;i<r+si;i++) {
    for(int j=c;j<c+si;j++) {
      a[i][j] = !a[i][j];
    }
  }

}

void IR(int x, int y) {
  int dx[4] = {0,0,1,-1};
  int dy[4] = {-1,1,0,0};
 
  a[y][x] = !a[y][x];
 
  for(int i=0;i<4;i++) {
    if(y+dy[i] >= 0 && y+dy[i] <n && x+dx[i] >=0 && x+dx[i] < n) 
      if(a[y+dy[i]][x+dx[i]] != a[y][x])
	IR(x+dx[i],y+dy[i]);  
  }
}


void RS() {

  a[r][0] = b[r][n-1];
  for(int i=1;i<n;i++) a[r][i] = b[r][i-1];
  for(int i=0;i<n;i++) b[r][i] = a[r][i];


}

void LS() {
  a[r][n-1] = b[r][0];
  for(int i=n-2;i>=0;i--) a[r][i] = b[r][i+1];
  for(int i=0;i<n;i++) b[r][i] = a[r][i];

}

int main(){

  cin >> n >> m;

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


  int o;

  for(int k=0;k<m;k++) {
    cin >> o;

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	b[i][j] = a[i][j];

    if(o == 0){
      cin >> r >> c >> si >> an;
      r--;
      c--;
      rotate();
    }
    else if(o == 1) {
      cin >> r >> c >> si;
      r--;
      c--;
      reversal();
    } 
    else if(o == 2) {
      cin >> r;
      r--;
      LS();
    }
    else if(o==3) {
      cin >> r;
      r--;
      RS();
    }
    else if(o == 4) {
      cin >> r >> c ;
      r--;
      c--;
      IR(c,r);

    }

  }


  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {

      cout <<a[i][j];
      if(j != n-1) cout <<" ";
    }
    cout << endl;
  }

  return 0;

}

Measured memory_bytes: 1180
#include <iostream>
#include <cstdint>
#include <type_traits>
#include <vector>


template<uint32_t mod> class Residue_Field {
public:
    uint32_t num = 0;
    Residue_Field() { }
    Residue_Field(const Residue_Field &x) : num(x.num) { }
    template<class T> Residue_Field(T x) {
        using Int = std::conditional_t<sizeof(T) >= 4, T, int32_t>;
        Int y = x;
        y %= static_cast<Int>(mod);
        if(y < 0) y += mod;
        num = static_cast<uint32_t>(y);
    }
    Residue_Field& operator+=(Residue_Field x) {
        num += x.num;
        if(num >= mod) num -= mod;
        return *this;
    }
    Residue_Field& operator-=(Residue_Field x) {
        if(num < x.num) num += mod;
        num -= x.num;
        return *this;
    }
    Residue_Field& operator*=(Residue_Field x) {
        num = static_cast<uint64_t>(num) * x.num % mod;
        return *this;
    }
    Residue_Field& operator/=(Residue_Field x) {
        return *this *= x.inv();
    }
    Residue_Field operator+(Residue_Field x) const { return Residue_Field(*this) += x; }
    Residue_Field operator-(Residue_Field x) const { return Residue_Field(*this) -= x; }
    Residue_Field operator*(Residue_Field x) const { return Residue_Field(*this) *= x; }
    Residue_Field operator/(Residue_Field x) const { return Residue_Field(*this) /= x; }
    Residue_Field pow(uint64_t x) const {
        Residue_Field ans = 1, cnt = *this;
        while(x){
            if(x & 1) ans *= cnt;
            cnt *= cnt;
            x >>= 1;
        }
        return ans;
    }
    Residue_Field inv() const { return pow(mod - 2); }
};

int main(){
    using Mint = Residue_Field<998244353>;
    
    int n, s;
    std::cin >> n >> s;
    std::vector<int> a(n);
    for(int& x : a) std::cin >> x;
    
    std::vector<Mint> dp(s + 1);
    dp[0] = Mint(2).pow(n);
    for(int x : a) {
        for(int i = s; i >= x; i--) dp[i] += dp[i - x] / 2;
    }
    std::cout << dp[s].num << std::endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#define MOD 1000000007
#define SMAX 2000
#define CMAX 26

int dp[SMAX][SMAX], nearl[CMAX][SMAX], nearr[CMAX][SMAX];
int dfs(int l, int r);
int main(void)
{
  int i, j, slen;
  char str[SMAX+1];
  scanf("%s", str);
  slen = strlen(str);
  for (i = 0; i < CMAX; i++) {
    for (j = 0; j < slen; j++) {
      nearl[i][j] = slen;
      nearr[i][j] = -1;
    }
  }
  for (i = 0; i < slen; i++) nearl[str[i]-'a'][i] = nearr[str[i]-'a'][i] = i;
  for (i = 0; i < CMAX; i++) {
    for (j = slen - 2; j >= 0; j--) {
      if (nearl[i][j] > nearl[i][j+1]) nearl[i][j] = nearl[i][j+1];
    }
    for (j = 1; j < slen; j++) {
      if (nearr[i][j] < nearr[i][j-1]) nearr[i][j] = nearr[i][j-1];
    }
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", dfs(0, slen - 1));
}

int dfs(int l, int r)
{
  int i;
  long long res = 0;
  if (~dp[l][r]) return dp[l][r];
  for (i = 0; i < CMAX; i++) {
    if (nearl[i][l] <= nearr[i][r]) res++;
    if (nearl[i][l] < nearr[i][r]) res += dfs(nearl[i][l] + 1, nearr[i][r] - 1) + 1;
  }
  return dp[l][r] = res % MOD;
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    cout<<"ABC"<<N<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n, m, p[100010], y[100010], now[100010];
P q[100010];
map<P, string>ans;

int main() {
	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		cin >> p[i] >> y[i];
		q[i].fr = y[i];
		q[i].sc = p[i];
	}
	sort(q, q + m);
	for (int i = 0;i < m;i++) {
		string t;
		int r = q[i].sc;
		while (r) {
			int s = r % 10;
			r /= 10;
			t += char(s + '0');
		}
		string x;
		for (int j = t.size()-1;j >= 0;j--)x += t[j];
		string e;
		while (x.size() + e.size() != 6) {
			e += '0';
		}
		t = e + x;
		string w;
		now[q[i].sc]++;
		r = now[q[i].sc];
		while (r) {
			int s = r % 10;
			r /= 10;
			w += char(s + '0');
		}
		string y;
		for (int j = w.size()-1;j >= 0;j--)y += w[j];
		string f;
		while (y.size() + f.size() != 6) {
			f += '0';
		}
		w = f + y;
		ans[P(q[i].sc, q[i].fr)] = t + w;
	}
	for (int i = 0;i < m;i ++) {
		cout << ans[P(p[i], y[i])] << endl;
	}
	return 0;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t




int main(){
    ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];
    priority_queue<ll> E, ANS;
    sort(C.rbegin(), C.rend());
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++) E.push(A[i]+B[j]);
    }
    for(int _ = 0; _ < min(X*Y, K); _++){
        ll e = E.top(); E.pop();
        for(int i = 0; i < min(Z, K); i++){
            ANS.push(e+C[i]);
        }
    }
    for(int i = 0; i < K; i++){
        ll x = ANS.top(); ANS.pop();
        cout << x << endl;
    }


}

Measured memory_bytes: 43240
def divisors(N):
    U = int(N ** 0.5)
    res = []
    *_, = (res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
bool odd(int a)
{
	if (a%2==1)
		return true;
	else
		return false;
}
bool plat(int a,int b)
{
	int t=b-a+1;
	if (odd(t))
		return true;
	else
		return false;
}
int main()
{
	int x,y;
	cin>>x>>y;
	if (x>y)
	{
		x=x+y;
		y=x-y;
		x=x-y;
	}
	if (x>0 && y>0)
		cout<<"Positive"<<endl;
	if (x<=0 && y>=0)
		cout<<"Zero"<<endl;
	if (x<0 && y<0)
		if (plat(x,y))
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
	return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=105,M=N*N;
int f[N][M],dv[N][M],n,p,s,res,sum;
int main(){
	scanf("%d%d",&n,&p);
	f[n][0]=1;
	fp(i,1,n)fp(j,1,n*n/i)dv[i][i*j]=j;
	fp(i,1,n)fp(j,1,n*n)if(!dv[i][j])dv[i][j]=dv[i][j-1];
	fd(i,n,1){
		if(p>i)fp(j,0,s)f[i-1][j]=mul(f[i][j],p-i);
		R int t=s;
		fp(j,0,s)if(f[i][j])fp(k,0,min(p,i)){
			upd(f[i-1][j+dv[i][j+k]],f[i][j]);
			cmax(t,j+dv[i][j+k]);
		}
		s=t;
	}
	fp(i,0,s)upd(res,mul(i,f[0][i]));
	sum=mul(n*p*(p+1)>>1,ksm(p+1,n-1));
	printf("%d\n",dec(sum,res));
	return 0;
} 

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
int t,n,m,k;
int ans,a[201][201];
int vis[201][201][3];
int dx[]={0,0,1},dy[]={0,1,0};
bool check(int x,int y){
	if(x>n||y>m) return false;
	return true;
}
int dfs(int x,int y,int sum)
{
	int i,j;
	if(x==n&&y==m){
		ans=min(ans,sum);
		return 0;
	} 
	int c=a[x][y];
	int ss=n+m+10;
	if(vis[x][y][2]!=n+m+10){
		if(sum<vis[x][y][1]){
			vis[x][y][1]=sum;
		}
		ans=min(ans,vis[x][y][2]+sum);	
		return vis[x][y][2];
	}
	vis[x][y][1]=min(vis[x][y][1],sum);
	for(i=1;i<=2;i++){
		int xx=x+dx[i],yy=y+dy[i];
		if(!check(xx,yy)) continue;
		int s=a[xx][yy];
		if(c==s){
			ss=min(ss,dfs(xx,yy,sum));
		}
		else if(s==-1){
			ss=min(ss,dfs(xx,yy,sum+1)+1);
		}
		else{
			ss=min(ss,dfs(xx,yy,sum));
		}
	}
	vis[x][y][2]=min(ss,vis[x][y][2]);
	return ss;
}
int main()
{
	int i,j;
	n=read();m=read();
	char s[201];
	for(i=1;i<=n;i++){
		scanf("%s",s+1);
		int len=strlen(s+1);
		for(j=1;j<=len;j++){
			int x=i,y=j;
			vis[x][y][1]=vis[x][y][2]=n+m+10;
			if(s[j]=='#') a[i][j]=-1;
			else a[i][j]=1;
		}
	}
	k=1;
	ans=n+m;
	vis[1][1][1]=vis[n][m][2]=0;
	if(a[1][1]==-1) t=1,k=-1;
	dfs(1,1,t);
	printf("%d",ans);
	return 0;
}   

Measured memory_bytes: 640
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)*}
    };
}

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, 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")
    };
}

fn main(){

    input!{
        n: usize,
        s: chars,
    }

    let mut flag: bool = true;
    if n % 2 != 0{
        flag = false;
    } else {
        for i in 0..n/2{
            if s[i] != s[i+n/2]{
                flag = false;
                break;
            }
        }
    }

    if flag==true{
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k< u->key){
    return treeSearch(u->left,k);
  }else{
    return treeSearch(u->right,k);
  }
}


void insert(int k){
  Node y = NIL; //x' parent
  Node x = root; //T root
  Node z;

  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }else if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

  


void inorder(Node u){
  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20448
#include <functional>
#include <queue>
#include <vector>
#include <iostream>
using namespace std;

bool CheckStr(string &str, int pos, string target) {
    if (pos + target.length() > str.length()) {
        return false;
    }
    for (int i = 0; i < target.length(); i++)
    if (str[pos + i] != target[i]) {
        return false;
    }
    return true;
}

bool Check(string &str) {
    int len = str.length(), pos = 0;
    while (pos < len) {
        if (str[pos] == 'd') {
            if (!CheckStr(str, pos, "dream")) {
                return false;
            }
            pos += 5;
            if (pos >= len) { continue; }
            if (pos + 2 <= len && str[pos] == 'e' && str[pos + 1] == 'r') {
                if (pos + 2 == len) {
                    pos += 2;
                } else {
                    if (str[pos + 2] != 'a') {
                        pos += 2;
                    }
                }
            }
        } else if (str[pos] == 'e') {
            if (!CheckStr(str, pos, "erase")) {
                return false;
            }
            pos += 5;
            if (pos < len) {
                if (str[pos] == 'r') {
                    pos++;
                }
            }
        } else {
            return false;
        }
    }
    return true;
}

int main() {
    string str;
    cin >> str;
    cout << (Check(str) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())

cnt_max = 0
ans = 1
for i in range(1, n + 1):
    num = i
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > cnt_max:
        cnt_max = cnt
        ans = i

print(ans)


Measured memory_bytes: 2940
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# ABが水、CDが砂糖、Eがとけられる量、Fが上限
A, B, C, D, E, F = getNM()

# A,Bを好きな回数使うことでi(0 <= i <= 30)の水を作り出せる
dp1 = [0] * 31
dp1[0] = 1
for i in range(1, 31):
    if i >= A:
        dp1[i] = max(dp1[i], dp1[i - A])
    if i >= B:
        dp1[i] = max(dp1[i], dp1[i - B])
waterlist = []
for i in range(31):
    if dp1[i] > 0:
        waterlist.append(i)

# C,Dを好きな回数使うことでi(0 <= i <= 3000)の砂糖を作り出せる
dp2 = [0] * 3001
dp2[0] = 1
for i in range(1, 3001):
    if i >= C:
        dp2[i] = max(dp2[i], dp2[i - C])
    if i >= D:
        dp2[i] = max(dp2[i], dp2[i - D])
sugerlist = []
for i in range(3001):
    if dp2[i] > 0:
        sugerlist.append(i)

ans = [0, 0]
concent = 0

for water in waterlist[1:]:
    if 100 * water <= F:
        left = F - (water * 100)
        # Fから水をひいた分、溶ける砂糖の限界を超えない量の砂糖を取得する
        index = bisect_right(sugerlist, min(left, E * water))
        suger = sugerlist[index - 1]
        # 濃度計算
        optconc = (100 * suger) / (100 * water + suger)
        # ここ>にすると濃度0%に対応できずWAに
        if optconc >= concent:
            concent = optconc
            ans = [100 * water + suger, suger]
print(*ans)

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> fie(h);
    rep(i,h) cin>>fie[i];
    
    int ans=0;
    
    int h2=pow(2,h),w2=pow(2,w);
    //int h3=64/h2,w3=64/w2;
   // cout<<h2<<" "<<w2<<endl;
    for(int i=0;i<h2;i++){
        for(int j=0;j<w2;j++){
            int cnt=0;
            bitset<6> s(i);
            bitset<6> t(j);
            
            rep(l,h){
                rep(r,w){
                    if(s[l]==1||t[r]==1) continue;
                    if(fie[l][r]!='#') continue;
                    cnt++;
                }
            }
            if(cnt==k) ans++;
            //cout<<cnt<<endl;
        }
    }
    cout<<ans<<endl;
    
   
   
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    string s=to_string(N+1);
    int ans=0;
    REP(i,s.size()){
        if(s[i]=='0') continue;
        int sum=0;
        for(int j=0;j<i;j++) sum+=s[j]-'0';
        sum+=s[i]-'1';
        for(int j=i+1;j<s.size();j++) sum+=9;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
  X = int(readline().strip())
  ret = False
  for i in range(-120, 120):
    for j in range(-120, 120):
      if i**5-j**5 == X:
        ret = True
        print(i, j)
        break
    if ret:
      break

if __name__ == '__main__':
  main()

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
ll a[200005];
ll suff[200005];
ll par[200005];
map<ll,ll> help;
ll find_par(ll v){
	if(v==par[v])return v;
	return find_par(par[v]);
}
void dsu_union(ll x,ll y){
	ll a=find_par(x);
	ll b=find_par(y);
	
	if(a==b) return ;
	
	if(help[a]>help[b]){
		par[b]=a;
		help[a]+=help[b];
		help[b]=0;
	}
	else{
		help[b]+=help[a];
		help[a]=0;
		par[a]=b;
	}
}
int main(){
	boost;
	ll n,m;
	ll mod=1e9+7;
	ll ans=0;
	cin>>n>>m;
	for(ll i=1;i<=n;i++)par[i]=i,help[i]=1;
	
	while(m--){
		ll x,y;
		cin>>x>>y;
		dsu_union(x,y);
	}
	ans=0;
		
	
	for(ll i=1;i<=n;i++)ans=max(ans,help[i]);
	
	cout<<ans;
	
	
}
  
  
  
   


    

Measured memory_bytes: 17692
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
const LL N = 300005;
const LL MOD = 1000000007;

struct node{
	LL l,r;
}s[N],t[N];
bool cmp(node x,node y){
	return (x.l == y.l ? x.r > y.r : x.l < y.l);    
}

LL n;
struct BIT{
	LL tr[N << 1];
	LL lowbit(LL x){ return (x & (-x)); }
	void modify(LL x,LL v){ for(;x <= n + 1;x += lowbit(x)) tr[x] += v; }
	LL query(LL x){ LL ret = 0; if(!x) return 0; for(;x;x -= lowbit(x)) ret += tr[x]; return ret; }
}b;

LL pr[N],p[N],sr[N];
LL dp[N];
map <LL,LL> mp;

int main(){
	ios::sync_with_stdio(false);
	LL m,u,v,tl,tr,ct = 0;
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++) cin >> pr[i];
	for(LL i = 1;i <= m;i ++) cin >> p[i];
	
	for(LL i = 1;i <= n;i ++){
		if(pr[i] < p[1] || pr[i] > p[m]) continue;
		tl = lower_bound(p + 1,p + 1 + m,pr[i]) - p - 1;
		tr = lower_bound(p + 1,p + 1 + m,pr[i]) - p;
		s[i].l = pr[i] - p[tl]; s[i].r = p[tr] - pr[i];
	}
	sort(s + 1,s + 1 + n,cmp);
	for(LL i = 1;i <= n;i ++){
		if(s[i].l != s[i - 1].l || s[i].r != s[i - 1].r) t[++ ct] = s[i];
	} n = ct; ct = 0;
	for(LL i = 1;i <= n;i ++) sr[i] = t[i].r;
	sort(sr + 1,sr + 1 + n);
	for(LL i = 1;i <= n;i ++) if(mp.find(sr[i]) == mp.end()) mp[sr[i]] = ++ ct;
	for(LL i = 1;i <= n;i ++) t[i].r = mp[t[i].r];
	
	dp[0] = 1; t[0].l = t[0].r = 0; t[n + 1].l = t[n + 1].r = n + 1;
	for(LL i = 1;i <= n + 1;i ++){
		dp[i] = 1 + b.query(t[i].r - 1); dp[i] %= MOD;
		b.modify(t[i].r,dp[i]);
	}
	cout << dp[n + 1] << '\n';
	return 0;
}

Measured memory_bytes: 21504
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=2000;
const int MAXM=2000;

int n,m;
vector<int> tadj[MAXN];
pair<int,int> sedge[MAXM];

int tpar[MAXN][MAXN];
int tdst[MAXN][MAXN];
int exists[MAXN][MAXN]; // exists[a][b] = any node on the tree path from a to b for which the edge (a,edge[a][b]) exists in g

void dfsinit(int at,int par,int rt) {
	tpar[rt][at]=par,tdst[rt][at]=par==-1?0:tdst[rt][par]+1;
	REPSZ(i,tadj[at]) { int to=tadj[at][i]; if(to==par) continue; dfsinit(to,at,rt); }
}

void addedge(int a,int b) {
	while(exists[a][b]!=-1) a=exists[a][b];
	while(exists[b][a]!=-1) b=exists[b][a];
	assert(exists[a][b]==-1&&exists[b][a]==-1);
	if(a==b) return;
	exists[a][b]=b,exists[b][a]=a;
	vector<pair<int,int>> toadd;
	REP(rep,2) {
		queue<int> q; q.push(b);
		while(!q.empty()) {
			int at=q.front(); q.pop();
			REPSZ(i,tadj[at]) {
				int to=tadj[at][i]; if(to==tpar[a][at]) continue;
				if(exists[a][to]==-1) {
					exists[a][to]=b;
					q.push(to);
				} else {
					assert(exists[a][to]==to);
					toadd.PB(MP(b,to));
				}
			}
		}
		swap(a,b);
	}
	REPSZ(i,toadd) addedge(toadd[i].first,toadd[i].second);
}

int dfscalc(int at,int rt,int last) {
	int ret=0;
	if(exists[last][at]!=-1) { assert(exists[last][at]==at); ++ret; last=at; }
	REPSZ(i,tadj[at]) { int to=tadj[at][i]; if(to==tpar[rt][at]) continue; ret+=dfscalc(to,rt,last); }
	return ret;
}

int solve() {
	REP(i,n) dfsinit(i,-1,i);

	REP(i,n) REP(j,n) exists[i][j]=-1;
	REP(i,m) addedge(sedge[i].first,sedge[i].second);

	int ret=0;
	REP(i,n) ret+=dfscalc(i,i,i);
	assert(ret%2==0); ret/=2;
	return ret;
}


void run() {
	scanf("%d%d",&n,&m);
	REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; tadj[a].PB(b); tadj[b].PB(a); }
	REP(i,m) { int a,b; scanf("%d%d",&a,&b); --a,--b; sedge[i]=MP(a,b); }
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


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

int main() {
  int n,k,q;
  cin>>n>>k>>q;
  int score[n];
  for(int i = 0; i < n; i++) score[i] = k-q;
  for(int i = 0; i < q; i++) {
    int temp;
    cin>>temp;
     
    score[temp-1]++;
    
  }
  for(int j = 0; j < n; j++) {
    if(score[j] > 0) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
  }
  
  return 0;
}
 

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static long [][] map;
    static long [][] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        map = new long[n][n];
        dp = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int d = sc.nextInt();
                map[i][j] = d;
                dp[i][j] = d;
            }
        }

        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if(dp[i][j] >= dp[i][k] + dp[k][j] && i != k && j != k) {
                        if(dp[i][j] > dp[i][k] + dp[k][j] ) {
                            System.out.println(-1);
                            return;
                        }
                        dp[i][j] = dp[i][k] + dp[k][j];
                        map[i][j] = 0;
                    }
                }
            }
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                long d = map[i][j];
                if(d == dp[i][j]) {
                    sum += d;
                }
            }
        }

        System.out.println(sum/2);
    }

}



Measured memory_bytes: 49144