akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.util.function.*;
 
public class Main{
	
	int N;
	int M;
	int L;
	int[] A;
	int[] dp;
	public void solve(){
		N = nextInt();
		L = nextInt();
		A = new int[N];
		int max = 0;
		int maxi = 0;
		for(int i = 0; i < N; i++){
			A[i] = nextInt();
			if(i != 0){
				if(A[i - 1] + A[i] > max){
					max = A[i - 1] + A[i];
					maxi = i;
				}
			}
		}
		if(max < L){
			out.println("Impossible");
		}else{
			out.println("Possible");
			for(int i = 1; i < maxi; i++){
				out.println(i);
			}
			for(int i = N - 1; i >= maxi; i--){
				out.println(i);
			}
		}
	}
	
 
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 20568
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


vector<pair<long long, int>> factorize(long long n) {
	vector<pair<long long, int>> res;
	for (long long i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

vector<ll> A;
ll N, K;
ll ans;
void solve(ll S) {
	if (S == 1)return;
	vector<ll> a,s;
	REP(i, 0, N) if (A[i] % S != 0)a.push_back(A[i] % S);
	sort(a.begin(), a.end());
	s.resize(a.size() + 1);
	s[0] = 0;
	REP(i, 0, a.size())s[i + 1] = s[i] + a[i];
	if (s.back() % S != 0)return;
	REP(i, 1, s.size()) {
		if (s[i] == (a.size() - i)*S - (s.back()-s[i]) && s[i] <= K) {
			ans = max(ans, S);
			return;
		}
	}
}

void f(int ind, vector<pair<ll,int>>& v, ll cur) {
	if (ind == v.size()) {
		solve(cur);
		return;
	}
	ll tmp = 1;
	REP(i, 0, v[ind].second + 1) {
		f(ind + 1, v, cur * tmp);
		tmp *= v[ind].first;
	}
}

int main() {
	cin >> N >> K;
	A.resize(N);
	ll sum = 0;
	ans = 1;
	REP(i, 0, N) {
		cin >> A[i];
		sum += A[i];
	}
	auto v = factorize(sum);
	f(0, v, 1);
	PRI(ans);
	return 0;
}




Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
	int x,y,z;
	
	scanf("%d %d %d", &x, &y, &z);
	
	if((x <= z)&&(z <= y)){
		printf("Yes");
	}
	else if((y <= z)&&(z <= x)){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return(0);
}

Measured memory_bytes: 128
n = int(input())
s = input()
ans = ""
for c in s:
	o = ord(c)
	o = chr(o+n)
	if o<='Z':
		ans = ans + o
	else:
		o = ord(o)-91
		# print(o)
		o = 65+o
		ans = ans + chr(o)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b){printf("Draw");}
    else if(a!=1 && b!=1)
    {
        if(a>b) {printf("Alice");}
        else if(a<b) {printf("Bob");}
    }
    else if(a==1 && b>1){printf("Alice");}
    else if(b==1 && a>1){printf("Bob");}
}


Measured memory_bytes: 128
#include<atcoder/all>
using namespace atcoder;

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

int main() {
    int H, W; cin >> H >> W;
    char G[50][50]; rep(y, 50) rep(x, 50) G[x][y] = '#';
    rep(y, H) rep(x, W) cin >> G[x][y];

    int L1 = 0, s = L1 + 50 * 50, t = s + 1;
    mcf_graph<LL, LL> F(t + 1);
    int flow_limit = 0;
    rep(y, 50) rep(x, 50) {
        int p = y * 50 + x;
        if (G[x][y] == 'o') {
            F.add_edge(s, L1 + p, 1, 0);
            flow_limit++;
        }
        if (x != 49) if (G[x][y] != '#') if (G[x + 1][y] != '#')
            F.add_edge(L1 + p, L1 + p + 1, 50000, 0);
        if (y != 49) if (G[x][y] != '#') if (G[x][y + 1] != '#')
            F.add_edge(L1 + p, L1 + p + 50, 50000, 0);
        F.add_edge(L1 + p, t, 1, 100 - x - y);
    }
    auto flow = F.flow(s, t, flow_limit);

    LL ans = flow.second;
    ans -= 100 * flow_limit;
    ans *= -1;
    rep(y, 50) rep(x, 50) if (G[x][y] == 'o') ans -= (x + y);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <array>

std::map<int, int> memo;

int main()
{
    std::string str;
    int p, gab;
    std::cin >> gab >> p >> str;
  	memo[0] = 1;
  long long ans = 0;
  int n = 0;
    if (p == 2 || p == 5)
    {
        for (int i = gab-1; i >= 0; i--)
        {
            n = (str[i] - '0') % p;
          	if(n == 0)
            {
              ans+=(i+1);
            }
        }
        std::cout << ans << std::endl;
      	return 0;
    }
    int powmod = 1;
    for (int i = gab-1; i >= 0; i--)
    {
        n = (n + (str[i] - '0') * powmod) % p;
        auto it = memo.find(n);
        if (it == memo.end())
        {
            memo[n] = 1;
        }
        else
        {
          	ans += memo[n];
            memo[n]++;
        }
        powmod = (powmod * 10) % p;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    int input;
    int cnt = 0;
    int ans = 0;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        if(i == input){
            cnt++;
        }else{
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    
    ans += (cnt + 1) / 2;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,y,rem,cg;

  scanf("%d %d",&x,&y);

  if(x<y){
    cg = x;
    x = y;
    y = cg;
  }

  rem = x % y;
  while(rem != 0){
    x = y;
    y = rem;
    rem = x % y;
  }

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

  return 0;
}



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

int main() {
  long long n;
  cin >> n;
  vector<long long>a;
  vector<long long>b;
  for(long long i=1;i<=1000000;i++){
    if(n%i==0){
      a.push_back(n/i);
      b.push_back(i);
    }
  }
  long long m=a[0]+b[0];
  for(int i=0;i<a.size();i++){
    if(a[i]+b[i]<m) m=a[i]+b[i];
  }
  cout<<m-2<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <iostream>
using namespace std;

int main() {
    map<string, int> map;
    
    int N;
    scanf(" %d", &N);
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        map[s]++;
    }

    int M;
    scanf("%d", &M);
    for(int i = 0; i < M; i++) {
        string s;
        cin >> s;
        map[s]--;
    }

    //map<string, int>::iterator it;
    int max = 0;
    for(std::map<string, int>::iterator it = map.begin(); it != map.end(); it++) {
        if(max < it->second) {
            max = it->second;
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;
	cout << s.substr(0,4) << " " << s.substr(4) << endl;
	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	ll right = c - (a + b);

	if (right <= 0){
		cout << "No" << endl;
		return 0;		
	}

	ll left = 4 * a * b;
	right = right*right;

	if (right > left){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
import heapq
def main():

    N, M = map(int, input().split())
    task = []
    for _ in range(N):
        A, B = map(int, input().split())
        task.append([A, B])
    task.sort()

    hq = []
    ans = 0
    for i in range(1, M+1):
        while task and task[0][0]<= i:
            _, v = heapq.heappop(task)
            heapq.heappush(hq, -v)
        if hq:
            v = heapq.heappop(hq)
            ans += -v
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 20296
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

#define UP   '/'
#define DOWN '\\'
#define FLAT '_'
#define END  20001

int calc_area(int i, int j, const string* input)
{
    int area = 0, d = 0;
    while (i < j) {
	if ((*input)[i] == UP)
	    area += d--;
	else if ((*input)[i] == DOWN)
	    area += d++;
	else
	    area += d;
	i++;
    }
    return area;
}

int main(void)
{
    vector<int> areas, heights;
    string input;
    cin >> input;

    int h= 0;
    heights.push_back(0);
    for (auto x: input) {
	if (x == DOWN)
	    h--;
	else if (x == UP)
	    h++;
	heights.push_back(h);
    }
    heights.push_back(END);

    int i = 0, k = 0, total = 0;
    while (heights[i] != END) {
	int j = i + 1;
	while (heights[j] != END && heights[j] < heights[i])
	    j++;
	if (heights[i] == heights[j]) {
	    int area = calc_area(i, j, &input);
	    if (area > 0) {
		total += area;
		areas.push_back(area);
		k++;
	    }
	    i = j;
	} else
	    i++;
    }

    printf("%d\n%d", total, k);
    if (k > 0)
	for (int i = 0; i < k; i++)
	    printf(" %d", areas[i]);
    puts("");
    
    return 0;
}

Measured memory_bytes: 1392
<?php
    $N = intval(trim(fgets(STDIN)));
    
    $A = array_map('intval',explode(" ",trim(fgets(STDIN))));
    array_unshift($A,0);
    
    
    //結局山谷で全額の売買すればよいのでは？
    
    //最初下がるか上がるかだけ欲しい
    $k=1;
    while($A[$k] == $A[$k+1]){
        $k++;
    }
 
    $money=1000;
    // echo $A[$k];
    // echo $A[$k+1];
    //株価が一生変わらない場合がある。
    if($k==$N){
        echo "1000";
        exit;
    }else{
        if($A[$k] < $A[$k+1]){
            $old_flg=1;
            
            $kabu = intdiv($money,$A[$k]);
            $money = $money - ($A[$k]*$kabu);
            
        }elseif($A[$k] > $A[$k+1]){
            $old_flg=2;
            //最初下がったら何もしない。
            $kabu=0;
        }
        
    }
    // echo $money;
    // echo $kabu;
    // echo $k;

    for($i=$k+1;$i<=$N-1;$i++){
        //前日比増
        if($A[$i] > $A[$i+1]){
            //山を確認すると
            if($old_flg==1){
                //あるだけうる
                // echo "a";
                $money = $money + ($A[$i]*$kabu);
                $kabu=0;
            }
            $old_flg=2;
        //前日比減
        }elseif($A[$i] < $A[$i+1]){
            //谷を確認するとあるだけ買う
            if($old_flg==2){
                // echo "b";
                $kabu = intdiv($money,$A[$i]);
                $money = $money - ($A[$i]*$kabu);
            }
            $old_flg=1;
        //前日比同
        }
    }
    // echo $kabu." ".$A[$N]." ";
    // echo $money;
    echo $kabu*$A[$N] + $money;
?>

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long B,a,b,c=0,k,d=0,i,n,j,temp,p,m,tx,ty,x,y,dx,dy;
	    cin>>a;
	    char A;
	    cin>>A;
	    cin>>b;
	    if(A=='+')cout<<a+b;
	    else cout<<a-b;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	int N, K, C;
	string S;
	cin >> N >> K >> C >> S;
	vector<bool> work(N+1, true);
	vector<int> work_front(K), work_back(K);
	for(int i=0;i<N;i++) {
		if(S[i] == 'x') {
			work[i] = false;
		}
	}
	int now = 0;
	for(int k=0;k<K;k++) {
		while(now < N and work[now] == false) now++;
		if(now == N) break;
		work_front[k] = now;
		now += (C + 1);
	}
	now = N - 1;
	for(int k=K-1;k>=0;k--) {
		while(now >= 0 and work[now] == false) now--;
		if(now == -1) break;
		work_back[k] = now;
		now -= (C + 1);
	}
	for(int k=0;k<K;k++) {
		if(work_front[k] == work_back[k]) {
			cout << work_front[k] + 1 << endl;
		}
	}
}

Measured memory_bytes: 3332
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int n; cin >> n;
  vector<int> value(n), cost(n);
  REP(i,n) cin >> value[i];
  REP(i,n) cin >> cost[i];
  
  int ans = 0;
  REP(i,n){
    int sub = value[i] - cost[i];
    if(sub>0) ans += sub;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3572
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for idx_row in range(n - m + 1):
    for idx_col in range(n - m + 1):
        is_ans = True
        for B_row_offset in range(m):
            if A[idx_row + B_row_offset][idx_col:idx_col + m] != B[B_row_offset]:
                is_ans = False
        if is_ans:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

	vector<int> b(N);
	rep(i, N) cin >> b[i];

	vector<int> backup;

	//i:回数のループ
	revrep(i, N)
	{
		bool flg = true;

		//j:使える数字のループ
		//大きい数字から消す
		revrep(j, i + 1)
		{
			//k:数列の番号のループ
			auto itr = find(all(b), j + 1);

			if (itr == b.begin() + j)
			{
				backup.push_back(*itr);
				b.erase(itr);
				flg = false;
				break;
			}
		}

		//要素を削除できない場合は不可
		if (flg)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	revrep(i, backup.size())
	{
		cout << backup[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long k=c-a-b;
	if(k>0&&4*a*b<k*k)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b)
        cout << "a > b" << endl;
    else if(a == b)
        cout << "a == b" << endl;
    else
        cout << "a < b" << endl;
    return 0;
}


Measured memory_bytes: 3020
r,c=map(int,input().split())
grid=[input() for _ in [0]*r]
ans=sum([grid[i].count(".") for i in range(r)])
q=[]
[[q.append([i,j]) for j in range(c) if grid[i][j]=="#"] for i in range(r)]
visit=[[grid[i][j]=="#" for j in range(c)] for i in range(r)]
d=[(1,0),(-1,0),(0,1),(0,-1)]
cnt=0

while q:
    qq=[]
    while q:
        i,j=q.pop()
        for dx,dy in d:
            if 0<=i+dx<r and 0<=j+dy<c:
                if i+dx==r-1 and j+dy==c-1:
                    flag=True
                if visit[i+dx][j+dy]==False:
                    visit[i+dx][j+dy]=True
                    qq.append([i+dx,j+dy])
    q=qq
    cnt+=1
    
print(cnt-1)

Measured memory_bytes: 156340
s = int(input())
def f(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1
table = {s}
for i in range(2,1000001):
    t = f(s)
    if t in table:
        print(i)
        break
    table.add(t)
    s = t

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main ()
{
    int h, n, i=0, j=0;
    cin>>h>>n;
    int dp[h+1];
    int a[n+1], b[n+1];
    for(i=1; i<=n; i++){
        cin>>a[i]>>b[i];
    }
    dp[0]=0;
    for(i=1; i<=h; i++){
        dp[i]=1000000000;
    }
    for(i=1; i<=h; i++){
        for(j=1; j<=n; j++){
            if(i-a[j]>=0)
            dp[i]=min(b[j]+dp[i-a[j]],dp[i]);
            else
            dp[i]=min(b[j],dp[i]);
        }
    }
    cout<<dp[h];
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n,i;
	double x[100],y[100],s;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lf",&x[i]);
	for(i=0;i<n;i++)scanf("%lf",&y[i]);
	s=0;
	for(i=0;i<n;i++)s+=fabs(x[i]-y[i]);
	printf("%.6f\n",s);
	s=0;
	for(i=0;i<n;i++)s+=pow(fabs(x[i]-y[i]),2);
	printf("%.6f\n",sqrt(s));
	s=0;
	for(i=0;i<n;i++)s+=pow(fabs(x[i]-y[i]),3);
	printf("%.6f\n",pow(s,1./3));
	s=0;
	for(i=0;i<n;i++)if(fabs(x[i]-y[i])>s)s=fabs(x[i]-y[i]);
	printf("%.6f\n",s);
	return 0;
}


Measured memory_bytes: 2036
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] c = S.toCharArray();
		Set<String> set = new HashSet<>();
		for (int i = 0; i < S.length(); i++) {
			String s = String.valueOf(c[i]);
			set.add(s);
		}
		for (char i = 'a'; i <= 'z'; i++) {
			if (set.contains(String.valueOf(i))) {
			} else {
				System.out.println(i);
				sc.close();
				return;
			}
		}
		sc.close();
		System.out.println("None");
	}
}


Measured memory_bytes: 29644
@1=map$-=$_-2,@0=1..<>+2;--$0[-1];map{$p=$_;$\+=$p*($$_[$N=$$_[$i=$_[$p]]]-($$_[$P=${1-$_}[$i]]=$N))*($i-$P)for 0,1}map$_[$_]=++$i,glob<>;print

Measured memory_bytes: 43940
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, d;
	cin>>n>>d;
	int ct[1000][1000]={};
	for(int i=0; i<n; i++){
		int x, y;
		cin>>x>>y;
		ct[x%d][y%d]++;
	}
	ll m1=1, m2=1e9;
	while(m1!=m2){
		int m=(m1+m2)/2;
		bool ok=0;
		ll c[1000];
		ll cm=m/d+1;
		int l=0;
		for(int k=0; k<d; k++){
			if(k>m) c[k]=0;
			else c[k]=(m-k)/d+1;
			cm=min(c[k], cm);
			if(c[k]==m/d+1) l=k;
		}
		if(l==d-1){
			ok=1;
			for(int i=0; i<d; i++){
				for(int j=0; j<d; j++){
					if(ct[i][j]>cm*cm){
						ok=0;
						break;
					}
				}
				if(!ok) break;
			}
			if(ok) m2=m;
			else m1=m+1;
			continue;
		}
		bool nuee=0;
		int ctx[1001]={}, cty[1001]={};
		int ct2[1001][1001]={};
		for(int i=0; i<d; i++){
			for(int j=0; j<d; j++){
				if(ct[i][j]>(cm+1)*(cm+1)){
					nuee=1;
					break;
				}else if(ct[i][j]>(cm+1)*cm){
					ctx[i+1]++;
					cty[j+1]++;
				}else if(ct[i][j]>cm*cm){
					ct2[i+1][j+1]++;
				}
			}
			if(nuee) break;
		}
		if(nuee){
			m1=m+1;
			continue;
		}
		for(int i=1; i<=d; i++){
			ctx[i]+=ctx[i-1];
			cty[i]+=cty[i-1];
		}
		for(int i=1; i<=d; i++){
			for(int j=1; j<=d; j++){
				ct2[i][j]=(ct2[i-1][j]+ct2[i][j-1]-ct2[i-1][j-1]+ct2[i][j]);
			}
		}
		for(int i=0; i<d; i++){
			if(i+d-l-2<=d-1){
				if(ctx[i]!=ctx[i+d-l-1]) continue;
			}else{
				if(ctx[i]!=ctx[d] || ctx[(i+d-l-2)%d+1]!=0) continue;
			}
			for(int j=0; j<d; j++){
				if(j+d-l-2<=d-1){
					if(cty[j]!=cty[j+d-l-1]) continue;
				}else{
					if(cty[j]!=cty[d] || cty[(j+d-l-2)%d+1]!=0) continue;
				}
				if(j+d-l-2<=d-1 && i+d-l-2<=d-1){
					if(ct2[i+d-l-1][j+d-l-1]-ct2[i+d-l-1][j]-ct2[i][j+d-l-1]+ct2[i][j]>0) continue;
				}else if(i+d-l-2<=d-1){
					if(ct2[i+d-l-1][d]-ct2[i+d-l-1][j]-ct2[i][d]+ct2[i][j]+ct2[i+d-l-1][(j+d-l-2)%d+1]-ct2[i][(j+d-l-2)%d+1]>0) continue;
				}else if(j+d-l-2<=d-1){
					if(ct2[d][j+d-l-1]-ct2[d][j]-ct2[i][j+d-l-1]+ct2[i][j]+ct2[(i+d-l-2)%d+1][j+d-l-1]-ct2[(i+d-l-2)%d+1][j]>0) continue;
				}else{
					if(ct2[(i+d-l-2)%d+1][(j+d-l-2)%d+1]+(ct2[d][(j+d-l-2)%d+1]-ct2[i][(j+d-l-2)%d+1])+(ct2[(i+d-l-2)%d+1][d]-ct2[(i+d-l-2)%d+1][j])+ct2[d][d]-ct2[i][d]-ct2[d][j]+ct2[i][j]>0) continue;
				}
				ok=1;
				break;
			}
			if(ok) break;
		}
		if(ok) m2=m;
		else m1=m+1;
	}
	cout<<m1<<endl;
	return 0;
}

Measured memory_bytes: 8064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))

    a_sum = b_sum = 0
    a_i = b_i = 0
    while a_i < len(a_list) and a_sum + a_list[a_i] <= k:
        a_sum += a_list[a_i]
        a_i += 1
    ans = a_i

    while a_i > 0:
        # a_sum -= a_list[a_i - 1]  # wrong!
        while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
            b_sum += b_list[b_i]
            b_i += 1
            ans = max(ans, a_i + b_i)
        a_sum -= a_list[a_i - 1]  # correct!
        a_i -= 1

    while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
        b_sum += b_list[b_i]
        b_i += 1
        ans = max(ans, a_i + b_i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42200
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int INF = 1 << 10;

vector<string> stage;
vector<vector<int> > visited;

template <typename T> void display(T area, int h, int w){
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << area[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

P getStart(int h, int w, char c){
  bool flag = false;
  P res(INF, INF);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(stage[i][j] == c){
        res.first = i;
        res.second = j;
        flag = true;
        break;
      }
    }
    if(flag) break;
  }

  return res;
}

void init(int h, int w){
  visited.resize(h);
  for(int i = 0; i < h; i++){
    visited[i].resize(w);
    for(int j = 0; j < w; j++){
      visited[i][j] = INF;
    }
  }
}


int main(){
  int h, w, n;
  cin >> h >> w >> n;
  for(int i = 0; i < h; i++){
    string tmp;
    cin >> tmp;
    stage.push_back(tmp);
  }
  
  P s = getStart(h, w, 'S');

  int ans = 0, power = 0;

  while(1){
    //cout << s.first << " " << s.second << endl;
    if(power == n) break;

    queue<PP > que;
    que.push(PP(s, 1));

    vector<string> tmp(h);
    tmp = stage;

    init(h, w);
    visited[s.first][s.second] = 0;
    
    while(que.size()){
      PP p = que.front(); que.pop();
      P pos = p.first;
      bool goal = false;
      
      //display(tmp, h, w);
      //display(visited, h, w);
      
      for(int i = 0; i < 4; i++){
        int nx = pos.second + dx[i], ny = pos.first + dy[i];
        if(0 <= nx && nx < w && 0 <= ny && ny < h && tmp[ny][nx] != 'X' && visited[ny][nx] == INF){
          if(tmp[ny][nx] == char('0' + power + 1)){
            goal = true;
            s = P(ny, nx);
            break;
          }
          else{
            tmp[ny][nx] = '&';
            visited[ny][nx] = p.second;
            que.push(PP(P(ny, nx), p.second + 1));
          }
        }
      }
      
      if(goal){
        ans += p.second;
        power++;
        break;
      }
    }

    
  }

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

Measured memory_bytes: 8928
#pragma GCC optimize("Ofast")
#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)
void solve()
{
    ll n; cin>>n;
    cout<<3*n*n;

}
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 : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


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

using namespace std;
#define ll long long
#define sz(x) (ll)(x.size())
#define f first
#define se second
const ll N = 2e5+100;
int main() {
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll dp[n];
    dp[n - 1] = 0;
    dp[n - 2] = abs(a[n - 1] - a[n -2]);
    for(ll i = n - 3;i >= 0; i--){
        dp[i] = min(dp[i + 1] + abs(a[i + 1] - a[i]), dp[i + 2] + abs(a[i + 2] - a[i]));
    }
    cout << dp[0] << "\n";
}

Measured memory_bytes: 1792
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a] = stdin
  .split('\n')
  .filter(e => e)
  .map(Number)

const mod = n % 500

let res = 'No'

if (mod === 0) res = 'Yes'

if (mod <= a) res = 'Yes'

console.log(res)


Measured memory_bytes: 7372
#include <iostream>
     
int main() {
    	
      signed int first, second;
      std::cin >> first >> second;
      
      int ret1 = first + second;
      int ret2 = first - second;
      int ret3 = first * second;
      
      if(ret1 >= ret2 && ret1 >= ret3) {
      	std::cout << ret1;
      }
      else if (ret2 >= ret1 && ret2 >= ret3) {
      	std::cout << ret2;
      } else {
      	std::cout << ret3;
      }
    	
       return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

int par[200000];
void init(int n){
	rep(i,n){
		par[i]=i;
	}
}

int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}

int par2[200000];
void init2(int n){
	rep(i,n){
		par2[i]=i;
	}
}

int root2(int x){
	if(par2[x]==x){
		return x;
	}else{
		return par2[x] = root2(par2[x]);
	}
}

void unite2(int x,int y){
	x=root2(x);
	y=root2(y);
	if(x==y)return;
	par2[x]=y;
}

struct ans{
	int r1;
	int r2;
	int memo;
	int num;
	
};

bool operator< (const ans& left,const ans& right){
        return left.r1 == right.r1 ? left.r2 < right.r2 : left.r1 < right.r1;
    }

class MY_LESS_DEFINITION{
public:
    bool operator() (const ans& left, const ans& right) const {
        return left.num<right.num;
    }
};

int main(void){
	int n,k,l;
	cin>>n>>k>>l;
	int p,q,r,s;
	init(n);
	init2(n);
	rep(i,k){
		cin>>p>>q;
		unite(p-1,q-1);
	}
	rep(i,l){
		cin>>r>>s;
		unite2(r-1,s-1);
	}
	ans answer[n+1];

	rep(i,n){
		answer[i].r1 = root(i);
		answer[i].r2 = root2(i);
		answer[i].num = i;
	}
	sort(answer,answer+n);
	answer[n].r1 = 200001;
	answer[n].r2 = 200001;
	int memo=1;
	int memo2;
	q=0;
	int memoi = 0;
	while(q<=n){
		while(q<=n){
			if(answer[q].r1==answer[q+1].r1&&answer[q].r2==answer[q+1].r2){
				memo++;
				q++;
				continue;
			}else{
				for(int j=memoi; j<memoi+memo;j++){
					answer[j].memo = memo;
				
				}
				break;
			}
		}
		q++;
		memoi = q;
		memo = 1;
	}
	sort(answer,answer+n,MY_LESS_DEFINITION());
	rep(i,n){
		cout<<answer[i].memo<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        char[] s = in.next().toCharArray();
        for (int i = 0; i < s.length; i++) {
            if (s[i] == A) {
                for (int j = s.length - 1; j > -1; j--) {
                    if (s[j] == Z) {
                        System.out.println(j - i + 1);
                        return;
                    }
                }
            }
        }
    }

    static final char A = 'A', Z = 'Z';
}

Measured memory_bytes: 14060
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if (A>=13){
        cout<<B<<endl;
    }
    else if(A>=6 && A<=12){
        cout<<B/2<<endl;
    }
    else{
        cout<<0<<endl;
    }
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 100'009;

int a[N];
int b[N];
int oa[N];
int ob[N];
int pos[N];
int w[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", b + i);
  }
  for (int i = 0; i < n; ++i) {
    oa[i] = i;
    ob[i] = i;
    pos[i] = i;
    w[i] = i;
  }
  sort(oa, oa + n, [](int i, int j) {
    return a[i] < a[j];
  });
  sort(ob, ob + n, [](int i, int j) {
    return b[i] < b[j];
  });
  for (int i = 0; i < n; ++i) {
    if (a[oa[i]] > b[ob[i]]) {
      puts("No");
      return 0;
    }
  }
  for (int i = n - 1; i >= 1; --i) {
    if (pos[oa[i]] == ob[i] || a[oa[i]] <= b[ob[i - 1]]) {
      puts("Yes");
      return 0;
    }
    int x = w[ob[i]];
    int px = ob[i];
    int y = oa[i];
    int py = pos[oa[i]];
    pos[x] = py;
    w[py] = x;
    pos[y] = px;
    w[px] = y;
  }
  puts("No");
}


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;

int main() {
  int a,b,c;
  vector<int> n(3);
  rep(i,3) {
    cin >> n[i];
      }
  sort(n.begin(), n.end());
  a = n[0];
  b = n[1];
  c = n[2];
  // check(a);
  // check(b);
  // check(c);
  if(a==b && b!=c){
    cout << "Yes"<< endl;
    return 0;
  }
  if(b==c && b!=a){
    cout << "Yes"<< endl;
    return 0;
  }

    cout << "No"<< endl;
}


Measured memory_bytes: 256
S = input()

# YYMM
flag1 = False
# MMYY
flag2 = False

if 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
    flag1 = True

if 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99:
    flag2 = True

if flag1 and not flag2:
    print("YYMM")
elif not flag1 and flag2:
    print("MMYY")
elif flag1 and flag2:
    print("AMBIGUOUS")
else:
    print("NA")


Measured memory_bytes: 61904
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m,x; cin>>n>>m>>x;
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    rep(i,n) {
        cin>>c[i];
        rep(j,m) cin>>a[i][j];
    }

    ll ans = LINF;
    for (int bit = 0; bit < (1<<n); ++bit) {
        ll tmp = 0;
        vector<ll> b(m);
        rep(i,n) {
            if (!(bit & (1<<i))) continue;
            rep(j,m) b[j] += a[i][j];
            tmp += c[i];
        }
        bool ok = true;
        rep(j,m) if (b[j] < x) ok = false;
        if (ok) chmin(ans, tmp);
    }

    ans = (ans==LINF) ? -1 : ans;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3628
S=input()
T=input()
min_t=len(T)
mins=0
for i in range(len(S)-len(T)+1):
  mins=0
  for j in range(len(T)):
    if T[j]!=S[i+j]:
      mins+=1
  if mins<min_t:
    min_t=mins
print(min_t)


Measured memory_bytes: 9108
#include<stdio.h>
  
int A[2000000];
int B[2000000];
  
void Counting_Sort(int k){
  int i,j;
  int C[10001];
  for(i=0;i<10001;i++)C[i]=0;
  for(j=0;j<k;j++)C[A[j]]++;
  for(i=1;i<10001;i++)C[i]+=C[i-1];  
  for(j=k-1;j>=0;j--){
    C[A[j]]--;
    B[C[A[j]]]=A[j];
  }
}
  
int main(){
  int n,i;
   
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  Counting_Sort(n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 17380
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

inline string add(string s,string t){
    int n=(int)s.size();
    int m=(int)t.size();
    int pre=0;
    string ans="";
    for(int i=0;i<max(n,m);i++){
        int nows,nowt;
        if(n-i-1<0)nows=0;
        else nows=s[n-i-1]-'0';
        if(m-i-1<0)nowt=0;
        else nowt=t[m-i-1]-'0';
        if(nows+nowt+pre<10){
            ans=(char)(nows+nowt+pre+'0')+ans;
            pre=0;
        }else{
            int a=nows+nowt+pre;
            string temp=to_string(a);
            ans=temp[1]+ans;
            pre=temp[0]-'0';
        }
    }
    if(pre!=0){
        ans=(char)(pre+'0')+ans;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    bool ng[10];
    cin>>m>>n;
    for(int i=0;i<10;i++){
        ng[i]=0;
    }
    for(int i=0;i<n;i++){
        int a;cin>>a;
        ng[a]=1;
    }
    for(int i=m;i<=10*m;i++){
        string temp=to_string(i);
        for(int j=0;j<(int)temp.size();j++){
            int now=temp[j]-'0';
            if(ng[now])break;
            if(j==(int)temp.size()-1){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    /*
    for(int i=0;i<10;i++){
        bool flag=0;
        for(int j=i;j<10;j++){
            if(!ng[j]){
                ok[i]=j;
                flag=1;
                break;
            }
        }
        if(!flag){
            ketaage[i]=1;
            ok[i]=-1;
        }
    }
    int minok=10;
    for(int i=0;i<10;i++){
        if(!ng[i]){
            minok=i;
            break;
        }
    }
    for(int i=0;i<10;i++){
        if(ok[i]==-1)ok[i]=minok;
    }
    int m=(int)s.size();
    for(int i=m-1;i>=0;){
        int pre=(int)s.size();
        //cerr<<s<<endl;
        int now=s[i]-'0';
        s[i]=ok[now]+'0';
        //cerr<<s<<endl;
        if(ketaage[now]){
            string t="";
            for(int j=m-1;j>=i;j--){
                t+='0';
            }
            t='1'+t;
            s=add(s,t);
        }
        int aft=(int)s.size();
        if(aft==pre){
            i--;
        }
    }
    cout<<s<<endl;*/
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
    vector<pair<int , int> > invert(n);

    int nmax=-10,nmin=(int)1e7;
    for(int i = 0; i < n; i++){
        int a , b;
        cin >> a >> b;
        invert[i].first = b;
        invert[i].second = a;

        nmin = min(nmin,a);
        nmax = max(nmax,b);
        //cout << nmax << " " << nmin << endl;
    }
    sort(invert.begin() , invert.end());
    nmax = min(nmax , n);
    int ans=0;

    for(int i = nmax; i >= nmin-1; i--){
        vector<pair<int , int> >::iterator up;
        pair<int , int> mp(i+1,0);
        up = lower_bound(invert.begin() , invert.end() , mp);
        int lower = distance(invert.begin() , up);
        int c = 0;
        //cout << invert[lower].first << " " << invert[lower].second << endl;
        for(int j = lower; j < invert.size(); j++){
            if(invert[j].second <= i+1){
                c++;
            }
        }
        if(c >= i){
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3564
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, W = list(map(int, sys.stdin.readline().split()))
Ws, Vs = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

Ws = np.array(Ws)
Vs = np.array(Vs)

w1 = Ws[0]
ws = np.arange(4) + w1
v1s = Vs[Ws == ws[0]]
v2s = Vs[Ws == ws[1]]
v3s = Vs[Ws == ws[2]]
v4s = Vs[Ws == ws[3]]
v1s.sort()
v2s.sort()
v3s.sort()
v4s.sort()
v1s = np.concatenate([[0], v1s[::-1].cumsum()])
v2s = np.concatenate([[0], v2s[::-1].cumsum()])
v3s = np.concatenate([[0], v3s[::-1].cumsum()])
v4s = np.concatenate([[0], v4s[::-1].cumsum()])

counts = np.array(list(itertools.product(
    range(len(v1s)),
    range(len(v2s)),
    range(len(v3s)),
    range(len(v4s))
)))
counts = counts[np.dot(counts, ws) <= W]

sums = v1s[counts[:, 0]] + \
       v2s[counts[:, 1]] + \
       v3s[counts[:, 2]] + \
       v4s[counts[:, 3]]

print(sums.max())


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

namespace CSharpSample01
{

    class Program
    {
        static int[] data; 
                   
        static void Main(string[] args)
        {
            data = new int[101];
            int max = 0;

            while (true)
            {
                string str = Console.ReadLine();

                if (String.IsNullOrEmpty(str))
                {
                    break;
                }
                else
                {
                    int key = int.Parse(str);
                    data[key]++;
                    
                    if(max <= data[key])
                    {
                        max = data[key];                       
                    }
                }

            }
            
            for(int i = 0; i < 101; i++)
            {
                if(max == data[i])
                {
                    Console.WriteLine(i);
                }
            }
           

        }
    }
}



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

int main() {
    long long int A,B,C,D, K, N;
    long long int new_A, new_B, new_C, new_K;
    long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, s, w;
    vector<long long int> a_v;
    string str;
    cin >> N;

    long long int sum = 0;
    for (long long int i = 1; i < N; i++) {
        sum += i;
    } 
    cout << sum << endl;
    // cout << str << endl;
    // long long int board[str.length()+1];
    // for (int i = 1; i <= str.length(); i++) {
    //     if (str[i] == '<') {
    //         board[i] = 1;
    //     } else {
    //         board[i] = 0;
    //     }
    // }
    // long long int sum = 0, cny = 0;
    // for (int i = 0; i < str.length(); i++) {
    //     if (board[i] == 1) {
    //         sum += i-cny;
    //         cny++;
    //     }
    // }
    // cout << sum << endl;
    // for (int i = 0; i < N; i++) {
    //     long long int a;
    //     cin >> a;
    //     a_v.push_back(a);
    // }

    // int now = 1;
    // bool flag = false;
    // for (i = 0; i < N; i++) { 
    //     now = a_v[now-1];
    //     // cout << now << endl;
    //     if (now == 2) {
    //         flag = true;
    //         break;
    //     }
    // }

    // if (flag) {
    //     cout << i+1 << endl;
    // }
    // else {
    //     cout << "-1" << endl;
    // }

    // cin >> A;
    // cin >> B;
    // cin >> C;
    // cin >> D;

    // while(1) {
    //     C = C-B;
    //     if (C <= 0) {break;} 
    //     A = A - D;    
    //     if (A <= 0) {break;} 
    // }
    // if (A <= 0) {
    //     cout << "No" << endl;
    // }
    // else {
    //     cout << "Yes" << endl;
    // }
    // long long int tmp, cnt = 0;
    // tmp = b;
    // for (;;) {
    //     tmp = tmp/10;
    //     cnt ++;
    //     if (tmp > 0) {
    //     }
    //     else {
    //         break;
    //     }
    // } 
    // long long int time = 1;
    // for (int i = 0; i < cnt; i++) {
    //     time *= 10;
    // }
    // b += a*time;
    // // cout << b<< endl;
    // bool flag = false;
    // for (long long int i = 0; i < sqrt(b)+1; i++) {
    //     if (i*i == b) {
    //         flag = true;
    //     }
    // }
    // if (flag) {
    //     cout << "Yes" << endl;
    // }
    // else {
    //     cout << "No" << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    cout << (a*min(n,(b-1)))/b << endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define p 1000000007
#define N 2005
using namespace std;
int n,m,k;
int f[N*2][N*2][2],sum[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    f[0][0][0]=1;n--;
    int ans=0;
    for(int i=1;i<=max(n,m)*2;i++)
    {
        for(int j=0;j<=m;j++)sum[j+1]=((sum[j]+f[i-1][j][0])%p+f[i-1][j][1])%p;
        for(int j=0;j<=m;j++)
        {
            f[i][j][0]=(sum[j+1]-sum[j]+p)%p;
            if(j)f[i][j][1]=(sum[j]-sum[max(0,j-(k-1))]+p)%p;
            if(j%(k-1)==m%(k-1)&&((k-1)*i-j)%(k-1)==n%(k-1)&&((k-1)*i-j)<=n)(ans+=f[i][j][1])%=p;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 124672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <iomanip>
#include <queue>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    ll N,P;
    cin>>N>>P;
    ll ans=1;
    repe(i,2,(ll)sqrt(P)+1){
    	ll cnt=0;
    	while(P%i==0){
    		P/=i;
    		cnt++;
    	}
    	ans*=pow(i,cnt/N);
    }
    if(N==1)ans*=P;
    cout<<ans<<endl;
    return 0;
}


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

int main () {

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }

    cout << a[0] + a[1] + a[2] << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
        int count = 0;

        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {
                    String tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                    count++;
                }
            }
        }

        System.out.println(String.join(" ", array));
        System.out.println(count);
    }
}

Measured memory_bytes: 25392
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

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

string S;

int main() {

	cin >> S;
	
	if(S[0]==S[1]|| S[1] == S[2]|| S[2] == S[3])
	{
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	
	}

	
}

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

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 

using namespace std;
const int N = 2*1e5 + 10;

#define int ll

int n, a[N];

ll check(ll b){
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
		sum += abs(a[i]-(b+i));
	return sum;
}

main(){
	boost;

	cin >> n;

	for (int i = 1; i <= n; ++i)
		cin>>a[i];

	ll low = -1e10, high = 1e10;
	ll ma = check(0);

	while (high - low > 1){
		ll mid = (high + low) >> 1;
		ll tmp = check(mid);
		ll tmp1 = check(mid + 1);
		ma = min(ma, min(tmp, tmp1));
		if (tmp > tmp1) {
			low = mid;
		}
		else {
		  high = mid;
		}
	}

	cout<<ma;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << fixed << setprecision(6) << a*b / 3.305785 << endl;
}

Measured memory_bytes: 3264