akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it
int n, **x;
ll *dp, *y;
ll solve(int mask = (1 << n) - 1)
{
	if(!mask)
		return 0;
	ll &ret = dp[mask];
	if(~ret)
		return ret;
	for(int submsk = mask; submsk; submsk = (submsk - 1) & mask)
		ret = max(ret, y[submsk] + solve(mask ^ submsk));
	return ret;
}
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    cin >> n;
    x = new int *[n];
	dp = new ll[1 << n];
	y = new ll[1 << n];
	memset(dp, -1, (1 << n) * 8);
    for(int i = 0; i < n; i++)
    {
    	x[i] = new int[n];
    	for(int j = 0; j < n; j++)
    		cin >> x[i][j];
    }
    y[0] = 0;
    for(int i = 1; i < (1 << n); i++)
    {
    	ll sum = 0;
    	int tmp = i, cnt = 0;
    	while(!(tmp & 1))
    	{
    		tmp >>= 1;
    		cnt++;
    	}
    	int j = cnt + 1;
    	tmp >>= 1;
    	while(tmp)
    	{
    		if(tmp & 1)
    			sum += x[cnt][j];
    		tmp >>= 1;
    		j++;
    	}
    	y[i] = sum + y[i & (i - 1)];
    }
    cout << solve();
}


Measured memory_bytes: 1280
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	boolean f(char[] cs,int l,int r) {
		boolean ret=true;
		while(l<r) {
			ret&=cs[l]==cs[r-1];
			++l;--r;
		}
		return ret;
	}
	
	void run() {
		FastScanner sc = new FastScanner();
		double L=sc.nextLong();
		System.out.println(String.format("%.20f",(L/3)*(L/3)*(L/3)));
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 20564
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 21:54:34 2018
ABC091D
@author: maezawa
"""

n = int(input())
ab = []
cd = []

for _ in range(n):
    abi = list(map(int, input().split()))
    ab.append(abi)
for _ in range(n):
    cdi = list(map(int, input().split()))
    cd.append(cdi)
    
ab.sort(key=lambda x:(x[0],x[1]), reverse=True)
cd.sort(key=lambda x:(x[1],x[0]))

cnt = 0
for red in ab:
    for i, blue in enumerate(cd):
        if red[0] < blue[0] and red[1] < blue[1]:
            cnt += 1
            cd.pop(i)
            #print(red, blue)
            break

print(cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int ds(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}
pair<ll, ll> m[200010];
int r[200010];
ll cnt[200010];

int main(void) {

  int n;
  ll d, a;
  //pair<ll, ll> m[200010];

  cin >> n >> d >> a;
  rep(i, n) cin >> m[i].first >> m[i].second;
  d *= 2LL;
  sort(m, m + n);

  //int r[200010];
  r[0] = 0;
  for (int i = 1; i < n; i++) {
    int le = -1, ri = i;
    while (ri - le > 1) {
      int med = (ri + le) >> 1;
      if (m[med].first >= m[i].first - d) ri = med;
      else le = med;
    }
    r[i] = ri;
  }
  //rep(i, n) cout << r[i] << " ";
  //cout << endl;
  

  //ll cnt[200010];
  cnt[0] = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (r[i] == i) {
      ll k;
      if (m[i].second % a == 0) k = m[i].second / a;
      else k = m[i].second / a + 1;

      ans += k;
      cnt[i + 1] = cnt[i] + k;
    } else {
      ll l = cnt[i] - cnt[r[i]];
      if (a * l >= m[i].second) cnt[i + 1] = cnt[i];
      else {
	m[i].second -= a * l;
	ll k;
	if (m[i].second % a == 0) k = m[i].second / a;
	else k = m[i].second / a + 1;
	ans += k;
	cnt[i + 1] = cnt[i] + k;
      }
    }
  }
  cout << ans << endl;
}
    
    

  


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;

  const ll K = 55555 + 1;
  vector<bool> p(K, true);
  p[0] = p[1] = false;
  REP(i, 0, K) if (p[i]) for (ll j = i * 2; j < K; j += i) p[j] = false;

  vector<ll> ans;
  REP(i, 0, K) {
    if (i % 5 == 1 && p[i]) {
      ans.push_back(i);
    }
  }

  assert(ans.size() >= 55);

  REP(i, 0, N) cout << ans[i] << (i + 1 != N ? " " : "\n");
}

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

const ll MOD = 1e9+7;

ll repsq(ll n,ll p){
    if(p == 0) return 1;
    if(p & 1) return (n * repsq(n,p-1)) % MOD;
    else {
        ll t = repsq(n,p/2) % MOD;
        return (t * t) % MOD;
    }
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = (repsq(2,n) - 1) % MOD;

    ll x_a = 1,x_b = 1;
    ll y_a = 1,y_b = 1;
    ll dis_a = 1,dis_b = 1;

    for(ll i=0;i<a;i++){
        x_a = x_a * (n-i) % MOD;
        y_a = y_a * (1+i) % MOD;
    }
    dis_a = x_a * repsq(y_a,MOD-2) % MOD;

    for(ll i=0;i<b;i++){
        x_b = x_b * (n-i) % MOD;
        y_b = y_b * (1+i) % MOD;
    }
    dis_b = x_b * repsq(y_b,MOD-2) % MOD;

    ans = (ans - dis_a + MOD) % MOD;
    ans = (ans - dis_b + MOD) % MOD;

    cout<< ans % MOD <<endl;
}

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

int main()
{
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2-y << " " << y2+x << " " << x1-y << " " << y1+x << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

H, W, K = map(int, readline().split())
s = (np.resize(np.frombuffer(read(), dtype='S1'), (H, W + 1))[:, :-1] == b'#') * 1

answer = np.cumsum(s, axis=1)
tmp = 0
for i in range(H):
    if np.all(answer[i] == 0):
        pass
    else:
        answer[i] = np.where(answer[i] == 0, 1, answer[i])
        answer[i] = answer[i] + tmp
        tmp = answer[i, -1]

np.maximum.accumulate(answer, axis=0, out=answer)

zero = 0
for i in answer:
    if np.all(i == 0):
        zero += 1
    else:
        break

if zero >= 1:
    answer[:zero] = answer[zero]

for i in answer:
    print(' '.join(map(str, i.tolist())))

Measured memory_bytes: 14548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

ll X[1010], Y[1010];

int main() {
	int N; scanf("%d", &N);
	for(int i=0;i<N;i++) scanf("%lld%lld", X+i, Y+i);
	for(int i=1;i<N;i++) {
		ll t = (X[i] + Y[i] - X[0] - Y[0]) & 1;
		if(t) {
			puts("-1");
			return 0;
		}
	}
	ll t = (X[0] + Y[0]) & 1;
	int R = 34;
	if(!t) {
		printf("%d\n", R + 1);
		for(int i=0;i<R;i++) printf("%lld ", 1LL<<i); puts("1");
	}
	else {
		printf("%d\n", R);
		for(int i=0;i<R;i++) printf("%lld ", 1LL<<i); puts("");
	}
	for(int i=0;i<N;i++) {
		if(!t) ++X[i];
		ll a = (X[i] + Y[i] + (1LL << R) - 1) / 2;
		ll b = (X[i] - Y[i] + (1LL << R) - 1) / 2;
		for(int j=0;j<R;j++) {
			int ta = !!(1LL << j & a);
			int tb = !!(1LL << j & b);
			printf("%c", "LDUR"[ta*2+tb]);
		}
		if(!t) puts("L");
		else puts("");
	}
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv,std.array;
void main(){
	//auto i = to!int( readln().chomp() );
	Map map = new Map();
	while(1){
		auto cs = readln().chomp().split(",");
		if( !cs ){	break;	}
		map.drop( to!int(cs[0]), to!int(cs[1]), to!int(cs[2]) );
	}
	writeln(map.not);
	writeln(map.max);
}
class Map{
	int[10][10] map;
	int not = 10*10;
	int max = 0;
	void drop( int x, int y, int w ){
		drop(x,y);
		drop(x,y+1);
		drop(x+1,y);
		drop(x,y-1);
		drop(x-1,y);
		if( w<2 ){	return;	}
		drop(x+1,y+1);
		drop(x+1,y-1);
		drop(x-1,y+1);
		drop(x-1,y-1);
		if( w<3 ){	return;	}
		drop(x+2,y);
		drop(x-2,y);
		drop(x,y+2);
		drop(x,y-2);
	}
	void drop( int x,int y ){
		if(	x<0 || y<0 || 9<x || 9<y ){	return;	}
		map[x][y]+=1;
		if( map[x][y] == 1 ){	not--;	}
		if( max < map[x][y] ){	max = map[x][y];	}
	}
	
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int S, W;
    cin >> S >> W;
    if (S <= W)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
INTEGER M,ALICE,BOB
INTEGER,ALLOCATABLE,DIMENSION(:)::A
READ*,M
ALLOCATE(A(M))
READ*,A
CALL BUBBLESORT(M,A)

ALICE=0
BOB=0
DO I=1,M,2
 ALICE=ALICE+A(I)
END DO
DO I=2,M,2
 BOB=BOB+A(I)
END DO
PRINT"(I0)",ALICE-BOB

CONTAINS

subroutine bubblesort(N,array)
  integer,intent(in)::N
  INTEGER,intent(inout)::array(1:N)
  integer::i,j
  INTEGER::t
   
  do i=1,N-1
     do j=i+1,N
        if(array(i) < array(j))then
           t=array(i)
           array(i)=array(j)
           array(j)=t
        end if
     end do
  end do

  return
end subroutine bubblesort
END

Measured memory_bytes: 256
N = int(input())
S = input()

R_count = S.count('R')
G_count = S.count('G')
B_count = S.count('B')

ans = R_count * G_count * B_count

for i in range(N-2):
    for d in range(1,N):
        if i+2*d >= N:
            break
        else:
            j = i+d
            k = j+d
            
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)    



Measured memory_bytes: 73492
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

SUM = 0
for i in range(N):
  SUM += B[A[i]-1]
  
for i in range(1,N):
  if A[i]-A[i-1]==1:
    SUM += C[A[i-1]-1]

print(SUM)

Measured memory_bytes: 9112
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_x) vec.erase(remove_if(all(vec),[](auto x){return condition_x;}),vec.end())
#define countif(vec,condition_x) count_if(all(vec),[](auto x){return condition_x;})
#define replaceif(vec,condition_x,n) replace_if(all(vec),[](auto x){return condition_x;},n)
#define optvalue(vec,condition_x,relation_x_opt) *min_element(all(vec),[](int x,int opt){return condition_x ? (opt==0)||!(relation_x_opt):false;})
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_x) for_each(all(vec),[](int&x){x= calc_x;})
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}




// #define int int64_t
// #define double long double


// 無名関数template
// map,makepair

signed main(){
  IOS;

  in(string,s);
  string ans="";

  int ss=si(s);
  fou(i,0,ss){
    if(s[i]=='0') ans.pub('0');
    elif(s[i]=='1') ans.pub('1');
    elif(s[i]=='B') {
      if(si(ans)>0) ans.pob();
    }
  }
  out(ans);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
using namespace std;
 
typedef long long ll;
 
const int maxn=1005;
 


int main()
{
    int n;
    string s1,s2;
	cin>>s1>>s2;
	int ans=0;
	for( int i=0;i<s1.size();i++ )
	{
		if( s1[i]!=s2[i] )
		{
			puts("No");
			return 0;
		}
		
	} 
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x/500*1000;
  x %= 500;
  ans += x/5*5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
cnt = 0
for i in range(n):
    b = [0]*n
    b[i]=v[i]-c[i]
    if v[i]>=c[i]:
        cnt += b[i]
print(cnt)

Measured memory_bytes: 3060
#include <iostream>

int main(void) {
  
  int N = 0;
  int *V = NULL;
  int *C = NULL;
  
  std::cin >> N;
  
  V = new int[N];
  C = new int[N];
  
  for(int ii = 0;ii < N; ii++) {
    std::cin>> V[ii];
  }
  
   for(int ii = 0;ii < N; ii++) {
    std::cin>> C[ii];
  }
  
  int answer = 0;
  int sa = 0;
  for(int ii = 0;ii < N;ii++) {
    sa = V[ii] - C[ii];
    if(sa > 0) {
      answer = answer + sa;
    }
  }
  
  std::cout << answer;
  
  return 0;
}

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

int main(){
    list<char> l;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        l.push_back(s[i]);
    }
    int q;
    cin >>q;
    bool front=1;
    for(int i=0;i<q;i++){
        int t;
        cin >> t;
        if(t==1){
            front =!front;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if((front && f==1) ||(!front&&f==2)){
                l.push_front(c);
            }else{
                l.push_back(c);
            }
        }
    }
    if(!front){
        reverse(l.begin(),l.end());
    }
    for(list<char>::iterator it = l.begin();it!=l.end();it++){
        cout << *it;
    }
    cout << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    vector<int> v(26);

    for(int i = 0; i < s.length(); i++) {
        v[s[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++) {
        if(v[i] % 2) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int cnt = 0;
    int total = 0;

    int[] A = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      total = 0;
      for (int j = 0; j < M; j++) {
        total += A[j] * sc.nextInt();
      }
      if (total + C > 0) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
  using namespace std;
   
  int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cities(n, 0);
    
    for(int i=0;i<m;i++) {
      int c1, c2;
      cin >> c1 >> c2;
      cities[c1-1]++;
      cities[c2-1]++;
    }
    
    for(int i=0;i<n;i++) {
      cout << cities.at(i) <<endl;
    }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t n;
    cin >> n;
    int64_t ans = 1;
    for(int64_t i=1; i<=n; i++){
        ans = ans*i%1000000007;
    }
    cout << ans%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def search(now, a, b, c):
  if now == N:
    return abs(A-a) + abs(B-b) + abs(C-c) if min(a, b, c) > 0 else INF
  MP0 = search(now+1, a, b, c)
  MP1 = search(now+1, a+l[now], b, c) + 10
  MP2 = search(now+1, a, b+l[now], c) + 10
  MP3 = search(now+1, a, b, c+l[now]) + 10
  return min(MP0, MP1, MP2, MP3)

print(search(0,0,0,0)-30)

Measured memory_bytes: 43996
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	string s;
	while (cin >> s, s != "#") {
		int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; d--;
		int size(1); rep(i, 0, s.size())if (s[i] == '/')size++;
		vector<string>v;
		string t;
		rep(i, 0, s.size()) {
			if (s[i] == 'b') {
				t.push_back(s[i]);
			}
			else if (isdigit(s[i])) {
				rep(j, 0, s[i] - '0')t.push_back('.');
			}
			else if (s[i] == '/') {
				v.push_back(t);
				t.clear();
			}
		}
		v.push_back(t);
		swap(v[a][b], v[c][d]);
		string ans;
		rep(i, 0, v.size()) {
			int j(0); string t;
			if (i)t += "/";
			while (j < v[i].size()) {
				if (v[i][j] == 'b') {
					t.push_back('b');
					j++;
				}
				else if (v[i][j] == '.') {
					int cnt(0);
					while (v[i][j] == '.'&&j < v[i].size()) {
						cnt++; j++;
					}
					t.push_back(cnt + '0');
				}
			}
			ans += t;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	int n;
	string s;
	cin >> n >> s;
	if(n%2 == 1) {
		cout << "No" << '\n';
		return 0;
	}
	if(s.substr(0,n/2) == s.substr(n/2)) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {

  def sum(n:Int, s:Int, x:Int):Int = {
    if(n==1) {
      if(s >= 0 && s<=9 && s > x ) 1 else 0
    } else { for(i <- 0 to 9 if s>=i && i>x) yield sum(n-1,s-i,if(i>x) i else x) }.sum
  }

  def getSum(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0)  print(sb.result)
    else {
      println(sum(r(0),r(1),-1))
      getSum(sb)
    }
  }

  def main(args:Array[String]) = getSum(new StringBuilder)
}

Measured memory_bytes: 46172
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

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

  vector< vector<long long> > DP(N, vector<long long>(3));
  DP[0][0] = A[0];
  DP[0][1] = B[0];
  DP[0][2] = C[0];
  for (int i = 1; i < N; i++) {
    DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + A[i]; 
    DP[i][1] = max(DP[i - 1][0], DP[i - 1][2]) + B[i]; 
    DP[i][2] = max(DP[i - 1][0], DP[i - 1][1]) + C[i]; 
  }
  cout << max(max(DP[N - 1][0], DP[N - 1][1]), DP[N - 1][2]) << endl;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
/* 角度でソートし全区間を試す */

#define rep(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define repn(i, m, n) for (int (i) = (m) ; (i) < (int)(n) ; ++(i))
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define repn_rev(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= (m) ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    stack<int> S;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '0') {
            S.push(0);
            // cout << s[i] << " " << S.top() << " " << S.size() << endl;
        } else if (s[i] == '1') {
            S.push(1);
            // cout << s[i] << " " << S.top() << " " << S.size() << endl;
        } else {
            if (S.empty() == false) {
                S.pop();
                // cout << s[i] << " " << S.top() << " " << S.size() << endl;
            }
        }
    }

    int n = S.size();
    int ans[10];
    for (int i = 0; i < n; ++i) {
        ans[n - 1 - i] = S.top();
        S.pop();
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x;
  cin >> x;
  if(x == 7 || x == 5 || x== 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

snt = 10 ** 9 + 1

def merge(A, left, mid, right):
    cnt = 0
    L = A[left:mid] + [snt]
    R = A[mid:right] + [snt]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += len(L) - 1 - i
    return cnt

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        v1 = merge_sort(A, left, mid)
        v2 = merge_sort(A, mid, right)
        v3 = merge(A, left, mid, right)
        return v1 + v2 + v3
    else:
        return 0

ans = merge_sort(A, 0, N)
print(ans)


Measured memory_bytes: 27472
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

c = 0
cnt = [0]*n

for i in range(n):
    A[i] -= 1

for i in range(n):
    cnt[A[i]] += 1

def combinations(n):
    return n*(n-1)//2

for i in range(n):
    c += combinations(cnt[i])

for i in range(n):
    ans = c
    ans -= combinations(cnt[A[i]])
    ans += combinations(cnt[A[i]]-1)
    print(ans)



Measured memory_bytes: 100876
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long best = N+2;
  for (long long i = 1; i * i <= N; i++){
    if (N%i==0){
      best = i + N/i;
    }
  }
  cout << best - 2;
}


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

using namespace std;

void calc() {
    int cnt = 0;
    string s("ATCG");
    for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) {
                    if (i == 0 && j == 3 && k == 2) continue;
                    if (i == 0 && j == 2 && k == 3) continue;
                    if (i == 3 && j == 0 && k == 2) continue;

                    if (i == 0 && j == 3 && l == 2) continue;
                    if (i == 0 && k == 3 && l == 2) continue;

                    if (j == 0 && k == 3 && l == 2) continue;
                    if (j == 0 && k == 2 && l == 3) continue;
                    if (j == 3 && k == 0 && l == 2) continue;
        string t;
        for (auto x: {i, j, k, l}) {
            t += s[x];
        }
        if (t.find("AGC") != string::npos) cout << "tt: " << t << endl;
        if (t.find("GAC") != string::npos) cout << "tt: " << t << endl;
        if (t.find("ACG") != string::npos) cout << "tt: " << t << endl;
        // cout << t << endl;
        ++cnt;
    }
    cout << cnt << endl;
}

int main()
{
    // calc();
    ios::sync_with_stdio(false);
    cin.tie(0);
    const int M = 1e9+7;
    int n;
    cin >> n;
    long long ans = 0;
    if (n == 1) ans = 4;
    else if (n == 2) ans = 16;
    else {
        vector<vector<vector<long long>>> dp1(4, vector<vector<long long>>(4, vector<long long>(4)));
        for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) {
            dp1[i][j][k] = 1;
        }
        dp1[0][3][2] = dp1[0][2][3] = dp1[3][0][2] = 0;
        for (int x = 4; x <= n; ++x) {
            vector<vector<vector<long long>>> dp2(4, vector<vector<long long>>(4, vector<long long>(4)));
            for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) {
                for (int l = 0; l < 4; ++l) {
                    // if (i == 0 && j == 3 && k == 2) continue;
                    // if (i == 0 && j == 2 && k == 3) continue;
                    // if (i == 3 && j == 0 && k == 2) continue;

                    if (i == 0 && j == 3 && l == 2) continue;
                    if (i == 0 && k == 3 && l == 2) continue;

                    if (j == 0 && k == 3 && l == 2) continue;
                    if (j == 0 && k == 2 && l == 3) continue;
                    if (j == 3 && k == 0 && l == 2) continue;
                    dp2[j][k][l] += dp1[i][j][k];
                    dp2[j][k][l] %= M;
                }
            }
            swap(dp1, dp2);
        }
        for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) {
            ans += dp1[i][j][k];
            ans %= M;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n, k;
int arr[100];
int M = 1000000007;
int dp[101][100001] = {};
int pre[100001] = {};


int main(void)
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = k; j >= 0; j--)
        {
            if (i == n - 1)
            {
                if (arr[i] < j)
                    dp[i][j] = 0;
                else
                    dp[i][j] = 1;
                continue;
            }
            // for (int l = j; l >= max(0, j - arr[i]); l--)
            // {
            //     dp[i][j] = (dp[i][j] + dp[i + 1][l]) % M;
            // }
            if (j == k)
                dp[i][j] = pre[max(0, j - arr[i])];
            else
                dp[i][j] = (pre[max(0, j - arr[i])] - pre[j + 1]);
            dp[i][j] %= M;
        }
        pre[k] = dp[i][k];
        for (int j = k - 1; j >= 0; j--)
        {
            pre[j] = (pre[j + 1] + dp[i][j]) % M;
        }
        
    }
    // int sum = 0;
    // for (int i = k; i >= max(0, k - arr[0]); i--)
    //     sum = (sum + dp[0][i]) % M;
    if  (dp[0][k] < 0)
        dp[0][k] += M;
    printf("%d", dp[0][k]);
    
}

Measured memory_bytes: 43076
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	ll N;
	cin >> N;
	map<char, ll>mp;
	map<char, ll>min_v;
	for (char c = 'a'; c <= 'z'; c++) {
		min_v[c] = 100000000;
	}

	for (ll i = 0; i < N; i++) {
      	string S;
		cin >> S;
		for (ll i = 0; i < S.size(); i++) {
			mp[S[i]]++;
		}
		for (char c = 'a'; c <= 'z'; c++) {
			min_v[c] = min(mp[c], min_v[c]);
          	mp[c]=0;
		}
	}
	string s = "";
	for (auto p : min_v) {
		ll x = p.first;
		ll y = p.second;
		for (ll i = 0; i < p.second; i++) {
			s += x;
		}
	}
	cout << s << endl;
}
	










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++)cin >> h[i];
  int ans=0;
  int now=0;
  for(int i=0; i<n-1; i++){
    if(h[i]>=h[i+1])now++;
    else{
      ans=max(now,ans);
      now=0;
    }
  }
  ans=max(now,ans);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string a[150];
int n;
bool b=true;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
       string t=a[i];
        if(t==a[j]&&i!=j){
                b=false;break;
    }}
    if(b==false)break;
}
if(b==false)cout<<"No";
else{
    for(int i=0;i<n-1;i++){
    string s=a[i];
    string t=a[i+1];
    int m=s.size();
    if(s[m-1]==t[0])
        b=true;
    else {
            b=false;break;}
}
if(b==false)cout<<"No";
else cout<<"Yes";}
return 0;

}


Measured memory_bytes: 3660
#include<stdio.h>

int main(void){

  int rate;

  scanf("%d",& rate);

  if((400<=rate)&&(rate<=1999)){

  if((400<=rate)&&(rate<=599)){
    printf("8\n");
  }if((600<=rate)&&(rate<=799)){
    printf("7\n");
  }if((800<=rate)&&(rate<=999)){
    printf("6\n");
  }if((1000<=rate)&&(rate<=1199)){
    printf("5\n");
  }if((1200<=rate)&&(rate<=1399)){
    printf("4\n");
  }if((1400<=rate)&&(rate<=1599)){
    printf("3\n");
  }if((1600<=rate)&&(rate<=1799)){
    printf("2\n");
  }if((1800<=rate)&&(rate<=1999)){
    printf("1\n");
  }

  }

  return 0;
}


Measured memory_bytes: 1632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    string s, t;
    cin >> s >> t;

    int n = s.length(), m = t.length();
    vector<VI> dp(n + 1, VI(m + 1, 0));
    FOR(i, 0, n)FOR(j, 0, m) {
        if (s[i] == t[j])chmax(dp[i + 1][j + 1], dp[i][j] + 1);
        chmax(dp[i + 1][j + 1], max(dp[i + 1][j], dp[i][j + 1]));
    }

    string ans = "";
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j])i--;
        else if (dp[i][j] == dp[i][j - 1])j--;
        else {
            i--, j--;
            ans = s[i] + ans;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 35584
n=raw_input()
k=n.split(" ")

W=int(k[0])
H=int(k[1])
x=int(k[2])
y=int(k[3])
r=int(k[4])
f=0

if 0<=x-r<=x+r<=W:
  if 0<=y-r<=y+r<=H:
    print "Yes"
    f=1
if f==0:
  print "No"

Measured memory_bytes: 6436
#pragma GCC optimize("Ofast")
/*#pragma GCC target("avx,avx2,fma")
#pragma GCC target ("sse4")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
bool isPowerOfTwo (int x) {  return x && (!(x&(x-1)));  }
void solve()
{
    ll a,b; cin>>a>>b;
    cout<<max((a-b),max(a*b,a+b));
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<fixed<<setprecision(5)<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}

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

using namespace std;

int main(){
	vector<int> a(10);
	vector<int> b(10);
	for(int i=0;i<10;i++){
		cin >> a[i];
	}
	for(int i=0;i<10;i++){
		cin >> b[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	cout << a[0] + a[1] + a[2] << " ";
	sort(b.begin(),b.end(),greater<int>());
	cout << b[0] + b[1] + b[2] << endl;
	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iomanip>
using namespace std;

typedef long long ll;
const int N=1e5+5;
int arr[N];
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
int n,m;
cin>>n>>m;

for(int i=0;i<n;i++){
    cin>>arr[i];
}
sort(arr,arr+n);
int mini=1e9+5;
for(int i=0;i<=n-m;i++){
    mini=min(mini,arr[i+m-1]-arr[i]);
}
cout<<mini;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <random>


using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int d;
    cin >> d;

    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    std::uniform_int_distribution<> rand26(1, 26);        // [0, 99] 範囲の一様乱数
    for (int i = 0; i < d; ++i) {
        std::cout << rand26(mt) << "\n";
    }
}

Measured memory_bytes: 3180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main{

	public static void main(String[] args) throws IOException{

			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int num = Integer.parseInt(br.readLine());
			int rank = 13;
			ArrayList<Integer> spade = new ArrayList<Integer>();
			ArrayList<Integer> heart = new ArrayList<Integer>();
			ArrayList<Integer> club = new ArrayList<Integer>();
			ArrayList<Integer> diamond = new ArrayList<Integer>();

			for(int i = 0; i < num; i++){

				String[] token = br.readLine().split(" ");
				String type = token[0];
				int rank_num = Integer.parseInt(token[1]);

				if(type.equals("S")){
					spade.add(rank_num);
				}else if(type.equals("H")){
					heart.add(rank_num);
				}else if(type.equals("C")){
					club.add(rank_num);
				}else if(type.equals("D")){
					diamond.add(rank_num);
				}

			}

			for(int i = 1; i <= rank; i++){
				if(!spade.contains(i)){
					System.out.println("S " + i);
				}
			}

			for(int i = 1; i <= rank; i++){
				if(!heart.contains(i)){
					System.out.println("H " + i);
				}
			}

			for(int i = 1; i <=rank; i++){
				if(!club.contains(i)){
					System.out.println("C " + i);
				}
			}

			for(int i = 1; i <= rank; i++){
				if(!diamond.contains(i)){
					System.out.println("D " + i);
				}
			}

	}
}

Measured memory_bytes: 24376
import sys
input = sys.stdin.readline

n = int(input())
s = [input() for _ in range(n)]

ans = -1

for i in range(n):
    edges = [[] for _ in range(n)]
    for j in range(n):
        for k in range(j,n):
            if s[j][k] == '1':
                edges[j].append(k)
                edges[k].append(j)

    tmp = 0
    stack = [i]
    visit = [False]*n
    visit[i] = True
    flag = True
    while True:
        li = []
        while stack:
            li2 = []
            l = stack.pop(-1)
            for j in edges[l]:
                li2.append(j)
            for j in li2:
                edges[j].remove(l)
            li += li2
        li = list(set(li))
        for j in li:
            if visit[j]:
                flag = False
        if flag:
            stack = li
            for j in li:
                visit[j] = True
            tmp += 1
        else:
            break
        if not stack:
            ans = max(ans,tmp)
            break

print(ans)


Measured memory_bytes: 84316
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define scanf_s scanf
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);

int main(void){
	int n,ans,i,j,k,ok;
	double r,sit;
	double x[20];
	double y[20];
	double dp[20][20]={0};//x??????y????????????
	double dpc[20][20]={0};
	static bool isok[20][20][20];
	double d;
	double pi=3.141592653589793238462643383279502884197;
	scanf("%d",&n);
	scanf("%lf %lf",&r,&sit);
	sit=(sit/180)*pi;
	for(i=0;i<n;i++){
		scanf("%lf %lf",&x[i],&y[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			dp[i][j]=0;
			dpc[i][j]=big;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			for(k=0;k<n;k++){
				d=abs(atan2(y[i]-y[k],x[i]-x[k])-atan2(y[k]-y[j],x[k]-x[j]));
				isok[i][k][j]=(min(2*pi-d,d)<sit);
			}
		}
	}
	for(ans=0;;ans++){
		for(k=0;k<n;k++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					if(ans!=0&&(k-i)*(i-j)==0){
						continue;
					}
					if(j-k==0){
						continue;
					}
					if(ans==0&&k!=0){
						continue;
					}
					if(ans==0||isok[i][k][j]){
						dpc[k][j]=min(dpc[k][j],dp[i][k]+hypot(x[k]-x[j],y[k]-y[j]));
					}
				}
			}
		}
		ok=0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				dp[i][j]=dpc[i][j];
				if(dpc[i][j]<r){
					ok=1;
				}
				dpc[i][j]=big;
			}
		}
		if(ok==0){break;}
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */

int main() {
  ll N, T; cin >> N >> T;
  ll ans = 0;
  vector<ll> t(N+1);
  REP(i, N) {
    cin >> t[i];
  }
  t[N] = INF;
  REP(i, N){
    if(t[i+1] - t[i] >= T){
      ans += T;
    }else{
      ans += t[i+1] - t[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
l,r=map(int,input().split())
ans=int(10000000)
if r-l>2019:
    print(0)
    exit()

for i in range(l,r):
    for j in range(i+1,r+1):
        now=int((i*j)%2019)
        if ans>now:
            ans=now

print(ans)

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

int main(){
	int a[4];
	for(int i = 0;i < 4;i++)scanf("%d", &a[i]);
	sort(a, a+4);
	if(a[0] == a[1] && a[2] == a[3])printf("yes\n");
	else printf("no\n");
	return 0;
}


Measured memory_bytes: 3212
/*
author: shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,m,i,j,temp,flag,count=0;
    map<ll,ll>m1;
    cin>>n>>m;
    for(i=0;i<n;i++){
        cin>>temp;
        for(j=0;j<temp;j++){
            cin>>flag;
            m1[flag]+=1;
        }
    }
    for(i=1;i<=m;i++){
        if(m1[i]==n)
            count+=1;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

//////////////////////////////////////////////////////////////////////

ll x[50], y[50];
long long n, k;

ll sz(ll x1, ll x2, ll y1, ll y2) {
	ll count = 0LL;
	for (int i = 0; i < n; i++)
	{
		if (x[i] <= x1 && x[i] >= x2 && y[i] >= y2 && y[i] <= y1) count++;
	}
	//debug(count);
	if (count >= k) return (x1 - x2)*(y1 - y2);
	else return 4000000000000000100;
}
int main() {
	cin >> n >> k;
	rep(n) {
		cin >> x[i] >> y[i];
	}
	ll ans = 4000000000000001000;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = 0; k < n - 1; k++) {
				for (int l = 0; l < n; l++) {
					ll x1, x2, y1, y2;
					x1 = x[i], x2 = x[j];
					y1 = y[k], y2 = y[l];
					if (x1 < x2)swap(x1, x2);
					if (y1 < y2)swap(y1, y2);
					mins(ans, sz(x1, x2, y1, y2));// debug(sz(x1, x2, y1, y2));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n,h,w;
    cin >> n >> h >> w;
    int a[n],b[n];
    int count=0;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        if(a[i]>=h&&b[i]>=w) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#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 ll long long
//#define DEBUG 0
using namespace std;
const int Inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=3e5+10;
void debug()
{
	#ifdef DEBUG
	cout<<"***"<<endl;
	#endif
}
void solve()
{
	ll x,y,ans=0;
	cin>>x>>y;
	for(ll i=x;i<=y;i*=2){
		ans++;
	}
	cout<<ans<<endl;
}
int main()
{
	//freopen("D://data.txt","r",stdin);
	solve();
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	return 0;
}



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


int main()
{
    int n,a,b,c,d,x,y,z,p;
    double k;


    cin>>a>>b;
    if(a!=b)
    {
        k=(a+b)*0.5;
        if(k==(int)k)
        {
            x=abs(a-k);
            y=abs(b-k);
            //cout<<"x: "<<x<<endl;
            //cout<<"y: "<<y<<endl;
            if(x==y)
            {
                cout<<fixed<<setprecision(0)<<k<<endl;
            }
            else {
                cout<<"IMPOSSIBLE"<<endl;
            }

        }
        else{
            cout<<"IMPOSSIBLE"<<endl;}
    }

    return 0;
}



Measured memory_bytes: 256