akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int d = min(n,k);
    int ans = 0;
    for (int i = 0; i <= d; i++) {
        for (int l = 0; l <= i; l++) {
            int r = i-l;
            vector<int> c;
            int tot = 0;
            for (int j = 0; j <= l-1; j++) {
                c.push_back(v[j]);
                tot += v[j];
            }
            for (int j = n-r; j <= n-1; j++) {
                c.push_back(v[j]);
                tot += v[j];
            }
            sort(c.begin(), c.end());
            int ta = k-i;
            rep(j,ta) {
                if (j >= c.size()) break;
                if (c[j] >= 0) break;
                tot -= c[j];
            }
            ans = max(ans, tot);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n, maxx = 0, ans = 0; cin >> n;
	FOR(n){
		int x; cin >> x;
		if(x>=maxx) ++ans, maxx = x;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
 
mt19937 _gen(chrono::system_clock::now().time_since_epoch().count());
int rd(int a, int b) {
	return uniform_int_distribution<int>(a, b)(_gen);
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string str;
	cin >> str;

	vector<string> cycle = {"Sunny", "Cloudy", "Rainy"};

	REP(i, 3) {
		if(cycle[i] == str)
			cout << cycle[(i + 1) % 3] << "\n";
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

bool check(int x, int a) {
  rep(i, 30) {
    if((!(x & (1<<i))) && (a & (1<<i))) return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  int A[100100];
  ll B[100100];
  rep(i, N) cin >> A[i] >> B[i];
  ll ans = 0;
  rep(i, N) {
    if(check(K, A[i])) ans += B[i];
  }
  rep(i, 30) {
    ll maxi = 0;
    if(!(K & (1<<i))) continue;
    int _K = K & ~(1<<i);
    rep(j, i) _K |= (1<<j);
    rep(i, N) if(check(_K, A[i])) maxi += B[i];
    ans = max(ans, maxi);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int h,w;
	cin>>h>>w;
	string arr[h];
	for(int i=0;i<h;i++)
		cin>>arr[i];
	int prerow[h][w];
	int precol[h][w];
	int sufcol[h][w];
	int sufrow[h][w];
	for(int i=0;i<h;i++)
	{
		prerow[i][0]=-1;
		sufrow[i][w-1]=w;
		if(arr[i][0]=='#')
			prerow[i][0]=0;
		if(arr[i][w-1]=='#')
			sufrow[i][w-1]=w-1;

	}
	for(int i=0;i<w;i++)
	{
		precol[0][i]=-1;
		sufcol[h-1][i]=h;
		if(arr[0][i]=='#')
			precol[0][i]=0;
		if(arr[h-1][i]=='#')
			sufcol[h-1][i]=h-1;
	}
	
	for(int i=0;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			if(arr[i][j]=='#')
				prerow[i][j]=j;
			else
				prerow[i][j]=prerow[i][j-1];
		}
	}
	for(int i=0;i<w;i++)
	{
		for(int j=1;j<h;j++)
		{
			if(arr[j][i]=='#')
				precol[j][i]=j;
			else
				precol[j][i]=precol[j-1][i];
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=w-2;j>=0;j--)
		{
			if(arr[i][j]=='#')
				sufrow[i][j]=j;
			else
				sufrow[i][j]=sufrow[i][j+1];
		}
	}
	for(int i=0;i<w;i++)
	{
		for(int j=h-2;j>=0;j--)
		{
			if(arr[j][i]=='#')
				sufcol[j][i]=j;
			else
				sufcol[j][i]=sufcol[j+1][i];
		}
	}
	ll fmax=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{	
			ll max=0;
			if(arr[i][j]!='#')
				max = (j- prerow[i][j])+(i-precol[i][j])+(sufrow[i][j]-j)+(sufcol[i][j]-i)-3;
			if(fmax<max)
				fmax=max;
		}
	}

	

	cout<<fmax<<"\n";

}

Measured memory_bytes: 73704
import sys
sys.setrecursionlimit(10 ** 7)

def resolve():
    N, M,K = map(int, input().split())
    frind = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x:int(x)-1, input().split())
        frind[a].append(b)
        frind[b].append(a)

    block = [[] for _ in range(N)]
    for _ in range(K):
        a, b = map(lambda x: int(x) - 1, input().split())
        block[a].append(b)
        block[b].append(a)


    D = {}
    parent = [-1]*N
    visited = [False]*N
    for root in range(N):
        if visited[root]:
            continue
        D[root] = set([root])
        stack = [root]
        while stack:
            n = stack.pop()
            visited[n] = True
            parent[n] = root
            for to in frind[n]:
                if visited[to]:
                    continue
                D[root].add(to)
                stack.append(to)

    ans = [0]*N
    for i in range(N):
        gr = D[parent[i]]
        tmp = len(gr)-len(frind[i]) - 1
        for bl in block[i]:
            if bl in gr:
                tmp -= 1
        ans[i] = tmp
    print(*ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 140784
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
int main()
{
    FAST
    ll a;
    ld b;
    cin>>a>>b;
    ll temp=b*100+0.5;
    ll ans=temp*a;
    ans/=100;

    cout<<fixed<<setprecision(0)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3720
import collections
import sys

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

l = []
for _ in range(n):
  l.append([])

# for x in range(n):
#   l[x]

for a, b in ab:
  a -= 1
  b -= 1
  l[a].append(b)
  l[b].append(a)

# c = [None] * n

# for i in range(n):
#   if c[i] is None:
#     c[i] = i
#   for f in l[i]:
#     if c[f] is None:
#       c[f] = i


# https://algo-logic.info/connected-components-num/

color = [None] * n

sys.setrecursionlimit(3*10**5)


def dfs(i, c):
  if color[i] is not None:
    return
  color[i] = c

  for f in l[i]:
    dfs(f, c)


for i in range(n):
  if color[i] is None:
    dfs(i, i)

print(max([v for k, v in collections.Counter(color).items()]))


Measured memory_bytes: 247536
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: usize,
    }

    let inf = 10_0000_0000 + 7;
    let mut dp: Vec<usize> = vec![0;s+5];
    dp[0] = 1;
    for i in 1..s+1 {
        if i>=3 {
            for j in 0..i-3+1 {
                dp[i] += dp[j];
                dp[i] %= inf;
            }
        }
    }

    println!("{}", dp[s]);

}


Measured memory_bytes: 2160
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul
from functools import lru_cache
from pprint import pprint

mod = 10 ** 9 + 7
sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n, m = LI()
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[1][1] = 1
for _ in range(m):
    new_dp = [[0] * (n + 1) for _ in range(n + 1)]
    for j in range(1, n + 1):
        for k in range(1, j + 1):
            new_dp[j][j] += dp[j][k] * k % mod
            new_dp[j][j] %= mod
            new_dp[j][k] += dp[j][k] * (j - k) % mod
            new_dp[j][k] %= mod
            if j != n:
                new_dp[j + 1][k] += dp[j][k] * (n - j) % mod
                new_dp[j + 1][k] %= mod
    dp = new_dp


print(dp[n][n])




Measured memory_bytes: 103140
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t x,y;
    cin >> x >> y;
    int64_t tmp = x, res = 1;
    for(int i=0; i<y; i++){
        tmp = tmp * 2;
        if(tmp > y) break;
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int unsigned long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e5 + 5;

int i,n,a[N];

void solve(){
    cin>>n;
    int ans=1;
    for(i=1;i<=n;++i){
        cin>>a[i];
        if(a[i]==0){
            cout<<0;
            return;
        }
    }
    for(i=1;i<=n;++i){
        if(a[i]>1e18/ans){
            cout<<-1;
            return;
        }
        ans*=a[i];
    }
    if(ans>1000000000000000000){
        cout<<-1;
        return;
    }
    cout<<ans;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N,M;

	cin >> N >> M;

	vector<int> City(N);

	for (int i = 0; i < M; ++i)
	{
		int t1,t2;
		cin >> t1 >> t2;
		City.at(t1 - 1) = City.at(t1 - 1) + 1;
		City.at(t2 - 1) = City.at(t2 - 1) + 1;
	}

	for (auto itr : City)
	{
		cout << itr << endl;
	}

	return 0;
}

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

int main() {
	int a, b;

	cin >> a >> b;
	
	if ((a*b) % 2 == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin>>n;
	vector<int>v;
	int mn=1e9,mx=0;
	int cnt_mn=0,cnt_mx=0;
	for(int i=0;i<n;i++){
		int a;cin>>a;v.push_back(a);
		mn=min(a,mn);mx=max(mx,a);
	}
	for(int i=0;i<n;i++){
		if(v[i]==mn)cnt_mn++;
		if(v[i]==mx)cnt_mx++;
	}
	if(mx-mn>1){
		cout<<"No"<<endl;
		return 0;
	}
	if(mx!=mn&&cnt_mn<=mn&&cnt_mx>1&&(cnt_mn>=mx-1||(cnt_mx>=4&&cnt_mn+(cnt_mx-2)/2>=mx-1))){
		cout<<"Yes"<<endl;
	}else{
		if(mx==mn&&((mx==1||mn==n-1)||(mx*2<=n)))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

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

using namespace std;

const int N = 1e3 + 5;

long long arr[N];
long long x[N];
long long y[N];
long long z[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld %lld", x + i, y + i, z + i);
  }
  long long ans = 0;
  for (int mask = 0; mask < 8; ++mask) {
    int a = mask & 1 ? 1 : -1;
    int b = mask & 2 ? 1 : -1;
    int c = mask & 4 ? 1 : -1;
    for (int i = 0; i < n; ++i) {
      arr[i] = a * x[i] + b * y[i] + c * z[i];
    }
    sort(arr, arr + n, greater < long long > ());
    long long ret = 0;
    for (int i = 0; i < m; ++i) {
      ret += arr[i];
    }
    ans = max(ans, ret);
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main(){
	long long int k, a, b;
	cin >> k >> a >> b;
	if(b - a < 2){
		cout << k + 1 << "\n";
	}
	else{
		if(k < a - 1)
			cout << k + 1 << "\n";
		else{
			k -=  a - 1;
			cout << a + (b - a) * (k / 2) + (k % 2);
		}
	}
}

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

int main() {
    int x;
    scanf("%d", &x);
    if (x >= 400 && x <= 599) {
        puts("8");
    }
    if (x >= 600 && x <= 799) {
        puts("7");
    }
    if (x >= 800 && x <= 999) {
        puts("6");
    }
    if (x >= 1000 && x <= 1199) {
        puts("5");
    }
    if (x >= 1200 && x <= 1399) {
        puts("4");
    }
    if (x >= 1400 && x <= 1599) {
        puts("3");
    }
    if (x >= 1600 && x <= 1799) {
        puts("2");
    }
    if (x >= 1800 && x <= 1999) {
        puts("1");
    }

    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
ll n,a,b;
int main()
{
    n=read();a=read(),b=read();
    if(a>b)swap(a,b);
    if(((b-a)&1)==0)cout<<(b-a)/2<<"\n";
    else cout<<min(a+(b-a-1)/2,n-b+1+(b-a-1)/2)<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

vi colour;
vvii adj;

void dfs(int node, int father, int c, int dist) {
	if(dist % 2 == 0) colour[node] = c;
	
	for(ii i : adj[node]) {
		if(i.ff != father) dfs(i.ff, node, c, dist + i.ss);
	}
}

void solve() {
	int n;
	cin >> n;
	
	colour.resize(n, 0);
	adj.resize(n);
	for(int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		adj[u].pub({v, w});
		adj[v].pub({u, w});
	}
	
	dfs(0, -1, 1, 0);
	for(int i = 0; i < n; i++) cout << colour[i] << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 11508
import itertools   
x,y = map(int,input().split())
ab = []
for _ in range(x):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])
ans = -1000000000000000000000
for i in itertools.product([1,-1], repeat=3):
    memo = []
    ansl = 0
    for j in ab:
        p = j[0]*i[0]+j[1]*i[1]+j[2]*i[2]
        memo.append(p)
    memo.sort(reverse=True)
    for k in range(y):
        ansl += memo[k]
    ans = max(ans, ansl)
print(ans)

Measured memory_bytes: 40560
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n, k;
    cin >> n >> k;

    double res = 0;
    for( int i = 1; i <= n; ++i ) {
        double tmp = 1.0 / n;
        double p = i;
        while( p < k ) {
            tmp *= 0.5;
            p *= 2;

        }
        res += tmp;

    }

    printf( "%.9lf\n", res );
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int i,j,k;

int main(){
    int a[3][3];
    int n;
    string ans="No";
    REP(i,3)REP(j,3)cin>>a[i][j];
    cin>>n;
    int b[n];
    REP(k,n){
        cin>>b[k];
        REP(i,3)REP(j,3){
            if(b[k]==a[i][j]){
                a[i][j]=0;
            }
        }
    }
    REP(i,3){
        if(a[0][i]+a[1][i]+a[2][i]==0){
            ans="Yes";
        }
        if(a[i][0]+a[i][1]+a[i][2]==0){
            ans="Yes";
        }
    }
    if(a[0][0]+a[1][1]+a[2][2]==0){
        ans="Yes";
    }
    if(a[2][0]+a[1][1]+a[0][2]==0){
        ans="Yes";
    }
    

    
    cout<<ans<<endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  map<ll, ll> mp;
  ll N; cin >> N;
  ll s = 0;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    s += a;
    mp[a]++;
  }
  ll Q; cin >> Q;
  for (ll _q = 0; _q < Q; _q++) {
    ll b, c; cin >> b >> c;
    s += (c - b) * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << s << "\n";
  }

  return 0;
}



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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
double dmax(double a,double b){
    return a>b?a:b;
}

int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}

int ruizyou(int a, int b){
    int i, num=1;
    rep(i, b){
        num = num*a;
    }
    return num;
}

int main(void){
    int i, n;
    n = in();
    int a[3];
    rep(i,3){
        a[i] = (n%ruizyou(10, 3-i))/ruizyou(10, 2-i);
    }
    if(a[1]<a[0]){
        printf("%d%d%d\n", a[0], a[0], a[0]);
    }
    else if(a[1]==a[0]){
        if(a[2]<=a[0]) printf("%d%d%d\n", a[0], a[0], a[0]);
        else printf("%d%d%d\n", a[0]+1, a[0]+1, a[0]+1);
    }
    else printf("%d%d%d\n", a[0]+1, a[0]+1, a[0]+1);
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  int n, maxx = 0;
  LL ans = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int w;
    scanf("%d", &w);
    if (w < maxx) {
      ans += maxx - w;
    } else {
      maxx = w;
    }
  }
  cout << ans << endl;



#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3692
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int Y = scan.nextInt();
        int Z = scan.nextInt();
        int t = X;
        X = Y;
        Y = t;
        t = X;
        X = Z;
        Z = t;
        System.out.printf("%d %d %d\n", X, Y, Z);

    }
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const ll INF=1e18;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	ll weight;
	Edge(){}
	Edge(int s,int d,ll w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

void Dijkstra(const Graph& g,int v,vl& dist)
{
	priority_queue<Edge,vector<Edge>,greater<Edge>> pq;
	pq.emplace(-1,v,0);
	while(pq.size()){
		Edge cur=pq.top(); pq.pop();
		if(dist[cur.dst]!=INF) continue;
		dist[cur.dst]=cur.weight;
		for(Edge e:g[cur.dst])
			pq.emplace(e.src,e.dst,cur.weight+e.weight);
	}
}

//string to_string(int x)
//{
//	ostringstream oss; oss<<x;
//	return oss.str();
//}

int main()
{
	for(int n,t;cin>>n>>t && n|t;){
		string src,dst; cin>>src>>dst;
		map<string,int> ntoi,freq;
		vector<Edge> es;
		rep(i,n){
			int m; cin>>m;
			vs ss(m); rep(j,m) cin>>ss[j];
			vi ds(m-1); rep(j,m-1) cin>>ds[j];
			for(auto& s:ss){
				if(!ntoi.count(s)) ntoi.insert(mp(s,ntoi.size()));
				int u=ntoi[s];
				s+=to_string(++freq[s]);
				ntoi.insert(mp(s,ntoi.size()));
				int v=ntoi[s];
				es.emplace_back(u,v,50000ll*t+1);
				es.emplace_back(v,u,50000ll*t+1);
			}
			rep(i,m-1){
				int u=ntoi[ss[i]],v=ntoi[ss[i+1]];
				es.emplace_back(u,v,100000ll*ds[i]);
				es.emplace_back(v,u,100000ll*ds[i]);
			}
		}
		
		assert(ntoi.count(src));
		assert(ntoi.count(dst));
		
		//for(auto p:ntoi) dump(p);
		//for(auto e:es) cout<<e.src<<' '<<e.dst<<' '<<e.weight<<endl;
		
		n=ntoi.size();
		Graph g(n);
		for(auto e:es) g[e.src].emplace_back(e.src,e.dst,e.weight);
		vl dist(n,INF);
		Dijkstra(g,ntoi[src],dist);
		
		ll d=dist[ntoi[dst]];
		if(d==INF){
			cout<<-1<<endl;
			continue;
		}
		int res=d/100000-t;
		int trans=(d%100000-2)/2;
		cout<<res<<' '<<trans<<endl;
	}
}

Measured memory_bytes: 50056
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

#define inRange(x, a, b) (a <= x && x <= b)
#define between(x, a, b) (a < x && x < b)

template<typename T> void swap(T &a, T &b){
	T temp = a;
	a = b;
	b = temp;
}

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

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

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

int func(int n, int i, int *l, int A, int B, int C, int a, int b, int c){
	if(i == n){
		if(min({a, b, c}) > 0){
			return abs(A - a) + abs(B - b) + abs(C - c) - 30;
		}
		else
			return 1000000000;
	}

	return min(min(func(n, i + 1, l, A, B, C, a, b, c), func(n, i + 1, l, A, B, C, a + l[i], b, c) + 10), min(func(n, i + 1, l, A, B, C, a, b + l[i], c) + 10, func(n, i + 1, l, A, B, C, a, b, c + l[i]) + 10));

}

int main(){

	int n, a, b, c;
	int l[8];

	cin >> n >> a >> b >> c;
	input(l, n);

	out(func(n, 0, l, a, b, c, 0, 0, 0));

	return 0;

}

Measured memory_bytes: 256
def bubbleSort(x):
    A = x[:]
    flag_stable = True
    
    for i in range(1, len(A)):
        for j in range(1, len(A) - i + 1):
            if  A[j - 1][1] > A[j][1]:
                A[j], A[j - 1] = A[j - 1], A[j]

                if not flag_stable:
                    continue

                if A[j - 1][1:] == A[j][1:]:
                    flag_stable = False

    return A, flag_stable

def selectionSort(x):
    A = x[:]
    flag_stable = True

    for i in range(len(A)):
        minj = i

        for j in range(i + 1, len(A)):

            if A[j][1] < A[minj][1]:
                minj = j

        if minj != i:
            A[i], A[minj] = A[minj], A[i]

            if not flag_stable:
                continue

            for k in range(i, minj):
                if A[k][1] == A[minj][1]:
                    flag_stable = False

    return A, flag_stable




N = int(input())
card = list(input().split())

card_bubbleSort, flag_stable_bubbleSort = bubbleSort(card)
card_selectionSort, flag_stable_selectionSort = selectionSort(card)


print(*card_bubbleSort)

if flag_stable_bubbleSort:
    print("Stable")
else:
    print("Not stable")

print(*card_selectionSort)

if flag_stable_selectionSort:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b,i,ans=0;
	cin>>k;
	cin>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			ans=1;
			break;
		}
	}
	if(ans==1)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
	return 0;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {

    int N; cin >> N;
    vector<int> V;
    forn(i, N) {
        double v; cin >> v;
        V.pb(v);
    }
    sort(V.begin(), V.end());
    double ans = V[0];
    for1(i, N-1) {
        ans = (ans+V[i])/2;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll = long long;
using P = pair<int,ll>;

const int N = 3005;
ll dp[N][N][4];
ll x[N][N];
int main() {
  int r,c,k;
  cin >> r >> c >> k;
  rep(_,k){
    int i,j,v;
    cin >> i >> j >> v;
    x[i-1][j-1] = v;
  }
  rep(i,r)rep(j,c){
    dp[i][j][3] = max(dp[i][j][3], dp[i][j][2]+x[i][j]);
    dp[i][j][2] = max(dp[i][j][2], dp[i][j][1]+x[i][j]);
    dp[i][j][1] = max(dp[i][j][1], dp[i][j][0]+x[i][j]);
    rep(t,4) dp[i][j+1][t] = max(dp[i][j+1][t], dp[i][j][t]);
    rep(t,4) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][t]);
  }
  ll ans = 0;
  rep(t,4) ans = max(ans,dp[r-1][c-1][t]);
  cout << ans << endl;
}


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

jobs = []

for i in range(n):
    array = list(map(int, input().split()))
    jobs.append(array)

jobs.sort(key=lambda x:x[1])

time = 0

for i, j in jobs:
    time += i
    if time <= j:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 53716
import sys
import heapq
input = sys.stdin.buffer.readline
def minus(x):
  return -x
N = int(input())
a = list(map(int, input().split()))
dpl = [0] * (N + 1)
dpr = [0] * (N + 1)
l = a[: N]
m = a[N: 2 * N]
r = list(map(minus, a[2 * N: ]))
heapq.heapify(l)
heapq.heapify(r)
dpl[0] = sum(l)
dpr[0] = sum(r)
for i in range(N):
  heapq.heappush(l, m[i])
  dpl[i + 1] = dpl[i] - heapq.heappop(l) + m[i]
  heapq.heappush(r, -m[-1 - i])
  dpr[i + 1] = dpr[i] - heapq.heappop(r) - m[-1 - i]
res = -float("inf")
for i in range(N + 1):
  j = N - i
  res = max(res, dpl[i] + dpr[j])
print(res)

Measured memory_bytes: 98092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
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<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int w;
  string S;
  cin >> S >> w;
  rep(i,S.size()) {
    if (i%w==0) cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll m=0;
    FOR(i,m,n-1){
        for(int j=1;j+i<n;j++){
        if(a[i]>a[i+j]+1){
            cout<<"No";
            return 0;
        }
        if(a[i]<a[i+j]){
            m=i+j;
            break;
        }
        if(j+i==n-1){
            cout<<"Yes";
            return 0;
        }
    }
   
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int MAXN = 110;
int main(){
  int N;
  int s[MAXN];
  int sum = 0, mins = 110;
  cin >> N;
  for (int i=0; i < N; i++){
    cin >> s[i];
    sum += s[i];
    if (s[i] < mins && s[i] % 10 != 0){
      mins = s[i];
    }
  }

  if (sum % 10 != 0){
    cout << sum << endl;
  }
  else if (mins != 110){
    cout << sum - mins << endl;
  }
  else{
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

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

	vector<int_least32_t> v( n );
	for(auto& x : v) {
		cin >> x;
	}

	for(int_least32_t i = v.size() - 1; i >= 0; i -= 2) {
		cout << v[i] << ' ';
	}
	if(n % 2 == 1) {
		for(auto i = 1U; i < v.size(); i+=2) {
			cout << v[i] << ' ';
		}
	}
	else {
		for(auto i = 0U; i < v.size(); i+=2) {
			cout << v[i] << ' ';
		}
	}
}


Measured memory_bytes: 2944
from sys import stdin
input = stdin.buffer.readline
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 61964
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

a,b,c=map(int,input().split())
for i in itertools.permutations([a,b,c],3):
    if i[0]==sum(i[1:]) or sum(i[:2])==i[2]:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 70252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll max(ll x, ll y){
    if(x>y)return x;
    return y;
}

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int i = 1;
    priority_queue<int> que;
    while(i*i <= m){
        if(m%i==0){
            que.push(i);
            que.push(m/i);
        }
        i++;
    }
    while(!que.empty()){
        int j = que.top();
        que.pop();
        if(m/j >= n){
            printf("%d\n", j);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main() {
  int M;
  ll K;
  cin >> M >> K;
  if(M == 0) {
    if(K == 0)
      cout << 0 << " " << 0 << endl;
    else
      cout << -1 << endl;
  } else if(M == 1) {
    if(K == 0)
      cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
    else
      cout << -1 << endl;
  } else {
    if(K < pow(2, M)) {
      for(int i=0; i<pow(2, M); i++)
	if(i != K)
	  cout << i << ' ';
      cout << K << ' ';
      for(int i=pow(2, M)-1; i>=0; i--)
	if(i != K)
	  cout << i << ' ';
      cout << K << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

int main(){
    int n;
    scanf("%d", &n);

    unsigned long a[n];
    for (int i = 0; i < n; i++) {
        scanf("%ld", &a[i]);
        if (a[i]%2 == 1){
            puts("0");
            return 0;
        }
    }

    for (int j = 0; 1; j++){
        for (int i = 0; i < n; i++){
            a[i]/=2;
            if (a[i]%2 == 1){
                printf("%d\n", ++j);
                return 0;
            }
        }
    }


}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, k;

int main() {
    cin >> n >> k;
    V<Pll> pos(n);
    REP(i, n) {
        ll x, y; cin >> x >> y;
        pos[i] = {x, y};
    }

    sort(ALL(pos));

    ll result = 5e18;
    REP(i, n) REP2(j, i+k, n+1) {
        V<Pll> v(pos.begin()+i, pos.begin()+j);
        sort(ALL(v), [](const Pll& a, const Pll& b) {
            return a.second < b.second;
        });
        ll mini = 1e18;
        REP(i2, (j-i)-k+1) {
            mini = min(mini, v[i2+k-1].second - v[i2].second);
        }
        result = min(result, mini * (pos[j-1].first - pos[i].first));
    }

    cout << result << '\n';

    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    count = 0
    ans = 0

    for i in s:
        if i == 'R':
            count += 1
            if ans < count:
                ans = count
        else:
            if ans < count:
                ans = count
            count = 0

    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define mod 1000000007
#define LL long long
using namespace std;
int n,m;
LL x[100005];
LL y[100005];

int main()
{
	IO
	cin>>n>>m;
	
	for(int i = 0; i < n; ++i){
		cin>>x[i];
		x[i] += 1000000000;
	}
	for(int i = 0; i < m; ++i){
		cin>>y[i];
		y[i] += 1000000000;
	}
	LL base = 0;
	LL height = 0;
	for(int i = 1; i < n; ++i){
		LL d = x[i]-x[i-1];
		base = (base + ((d*((LL)(n-i)))%mod + (((d*(LL)(n-i))%mod)*(LL)(i-1))%mod)%mod)%mod;
	}
	for(int i = 1; i < m; ++i){
		LL d = y[i]-y[i-1];
		height = (height + ((d*((LL)(m-i)))%mod + (((d*(LL)(m-i))%mod)*(LL)(i-1))%mod)%mod)%mod;
	}
	cout<<((base*height)%mod)<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

struct PP {
  int y, x, ny, nx;
};

int H, W;
int a[505][505];
vector<PP> ans;

void f(int y, int x, int ny,int nx) {
  if(ny == H) return;
  if(a[y][x] % 2) {
    a[y][x]--;
    a[ny][nx]++;
    ans.push_back({y+1, x+1, ny+1, nx+1});
  }
}

void visit(int y, int x) {
  if(y == H) return;
  if(y % 2) {
    if(x == 0) {
      int ny = y + 1;
      int nx = x;
      f(y, x, ny, nx);
      visit(ny, nx);
    } else {
      int ny = y;
      int nx = x - 1;
      f(y, x, ny, nx);
      visit(ny, nx);
    }
  } else {
    if(x == W - 1) {
      int ny = y + 1;
      int nx = x;
      f(y, x, ny, nx);
      visit(ny, nx);
    } else {
      int ny = y;
      int nx = x + 1;
      f(y, x, ny, nx);
      visit(ny, nx);
    }
  }
}

int main() {
  cin >> H >> W;
  rep(i, 0, H) rep(j, 0, W) cin >> a[i][j];
  visit(0, 0);
  cout << ans.size() << endl;
  for(auto p : ans) {
    cout << p.y << " ";
    cout << p.x << " ";
    cout << p.ny << " ";
    cout << p.nx << endl;
  }
  return 0;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
const int L = 128;
mt19937 rng(69696969);
string alphabet;

const string hidden = "Atcod3rIsGreat";
int getEditDistance(const string &s) {
    int n = s.size(); int m = hidden.size();
    vector< vector< int > >dp(n+1, vector< int >(m+1));
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (min(i, j)==0) dp[i][j] = max(i, j);
            else {
                dp[i][j] = min(dp[i-1][j], dp[i][j-1])+1;
                dp[i][j] = min(dp[i][j], dp[i-1][j-1]+(s[i-1]!=hidden[j-1]));
            }
        }
    }
    return dp[n][m];
}

int ask(string s) {
    cout << "? " << s << endl;
    int x;
    cin >> x;
//    x = getEditDistance(s);
//    cout << x << endl;
//    getchar();
    return x;
}

int len;
string combine(string s, string t) {
    string w(s);
    for (int i = 0, j = 0; i < t.size(); i++, j++) {
        bool last = j==w.size();
        w.insert(w.begin()+j, t[i]);
        if (last || ask(w) == len-w.size()) {
            ///fine
        } else {
            ///not fine
            i--;
            w.erase(w.begin()+j);
        }
    }
//    cout << "==> " << w << endl;
    return w;
}

int main() {
    alphabet.clear();
    for (char c = 'a'; c <= 'z'; c++) alphabet.push_back(c);
    for (char c = 'A'; c <= 'Z'; c++) alphabet.push_back(c);
    for (char c = '0'; c <= '9'; c++) alphabet.push_back(c);

    shuffle(alphabet.begin(), alphabet.end(), rng);
//    cout << alphabet << endl;

    int mn = L+10;
    vector< int >got(alphabet.size());
    for (int i = 0; i < alphabet.size(); i++) {
        string t = "";
        t += alphabet[i];
        got[i] = ask(t);
        mn = min(mn, got[i]);
    }

    len = mn+1;
    vector< string >w;
    for (int i = 0; i < alphabet.size(); i++) {
        if (got[i] > mn) continue;
        string t(len, alphabet[i]);
        int x = len-ask(t);
        t = string(x, alphabet[i]);
//        cout << "==> " << t << endl;
        w.push_back(t);
    }


    while (w.size() > 1) {
        sort(w.begin(), w.end(), [](const string &s, const string &t) {
            return s.size() > t.size();
        });
        string r = combine(w[w.size()-2], w[w.size()-1]);
        w.pop_back(); w.pop_back();
        w.push_back(r);
    }

    cout << "! " << w[0] << endl;

    return 0;
}


Measured memory_bytes: 3776
from itertools import permutations
n  = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
comb = list(permutations([i for i in range(1, n + 1)]))
comb.sort()
a = 0
b = 0

for i in range(len(comb)):
    if list(comb[i]) == P:
        a = i
    if list(comb[i]) == Q:
        b = i
ans = abs(a - b)
print(ans)

Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

string n;
int sum=0;
int32_t main(){
    cin>>n;
    for(char c:n){
	sum+=c-'0';
    }
    cout<<((sum==1)?10:sum)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7){
		cout<<"YES";
		return 0;
	}
	
	if(a==7&&b==5&&c==5){
		cout<<"YES";
		return 0;
	}
	
	if(a==5&&b==7&&c==5){
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=new int[n];
		int dp[]=new int[n+1];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		dp[1]=Math.abs(arr[0]-arr[1]);
		for(int i=2;i<n;i++)
		{
			int opt1=dp[i-2]+Math.abs(arr[i-2]-arr[i]);
			int opt2=dp[i-1]+Math.abs(arr[i]-arr[i-1]);
		//	System.out.println(opt1+" "+opt2);
			dp[i]=Math.min(opt1, opt2);
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 60296