akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1e9 + 7;
signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    cin >> A >> B;

    {
        auto tmp = A;
        sort(ALL(tmp));
        if (unique(ALL(tmp)) != tmp.end()) {
            cout << 0 << endl;
            return 0;
        }
        tmp = B;
        sort(ALL(tmp));
        if (unique(ALL(tmp)) != tmp.end()) {
            cout << 0 << endl;
            return 0;
        }
    }

    map<int, vector<pair<int, int>>> mp;
    REP(i, N) mp[A[i]].push_back({0, i});
    REP(j, M) mp[B[j]].push_back({1, j});

    int rows = 0, cols = 0;
    vector<bool> r(N), c(M);
    int ans = 1;
    int cnt = 0;
    REPR(x, N * M) {
        if (x == 0) break;
        if (CONTAIN(mp, x)) {
            FORE(tmp, mp[x]) {
                if (tmp.first) {
                    cols++;
                    c[tmp.second] = 1;
                } else {
                    rows++;
                    r[tmp.second] = 1;
                }
            }
            if (SZ(mp[x]) == 2) ans *= 1;
            else if (mp[x][0].first) ans *= rows;
            else ans *= cols;
        } else {
            ans *= rows * cols - cnt;
        }
        ans %= MOD;
        cnt++;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 512
n = gets.to_i
txys = [[0, 0, 0], *n.times.map { gets.split.map(&:to_i) }]

ans = "Yes"
n.times do |i|
  rt, rx, ry = txys[i + 1]
  lt, lx, ly = txys[i]

  t = rt - lt
  x = (rx - lx).abs
  y = (ry - ly).abs

  if x + y > t
    ans = "No"
    break
  end

  if t % 2 != (x + y) % 2
    ans = "No"
    break
  end
end

puts ans


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

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int MAX = 510000;

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 h,w,a,b;
     cin >>h>> w>> a >> b;
     COMinit();
     ll ans =0;
     for(int i = 0; i < h-a; ++i){
         ll tmp = COM(b-1+i, i);
         ll tmp2 = COM(w-1-b+h-1-i, h-1-i);
         ans += tmp * tmp2 % MOD;
         ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

string sousa(string s)
{
	int MAX = -1;
	FOR(i, 1, s.size())
	{
		string s1 = s.substr(0, i);
		string s2 = s.substr(i);
		MAX = max(MAX, stoi(s1)*stoi(s2));
	}
	return to_string(MAX);
}

int main()
{
	int n; cin >> n;
	REP(i, n)
	{
		string m;
		set<string> used;
		cin >> m;
		int cnt = 0;
		while (m.size() > 1)
		{
			m = sousa(m);
			if (used.count(m) == 1)
			{
				cout << -1 << endl;
				goto end;
			}
			else used.insert(m);
			cnt++;
		}
		cout << cnt << endl;
	end:;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int MAXN = 55556;
bitset<MAXN> bs;
int n;
vi primes, ans;

void sieve () {
    bs.set();
    bs[0] = bs[1] = false;
    for (ll i = 2; i < bs.size(); i++) {
        if (bs[i]) {
            for (ll j = i*i; j < bs.size(); j += i)
                bs[j] = false;
            if (i%10 == 1) primes.pb(i);
        }
    }
}

int main (void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;
    sieve();

    for (int i = 0; i < n; i++)
        cout << primes[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

void  solve(){
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";
    
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		shellSort(a,n);
	}
	
	static void writeln(int[] a,int n){
		for(int i=0;i<n;i++){
			System.out.println(a[i]);
		}
	}
	static int insertionSort(int[] a,int n,int g){
		int cnt=0;
		for(int i=g;i<n;i++){
			int key=a[i];
			int j=i-g;
			while(j>=0 && a[j]>key){
				a[j+g]=a[j];
				j=j-g;
				cnt++;
			}
			a[j+g]=key;
		}
		return cnt;
	}
	static void shellSort(int[] a,int n){
		int g=1;
		int m=1;
		int cnt=0;
		while(3*g+1<n){
			g=3*g+1;
			m++;
		}
		System.out.println(m);
		while(g>0){
			cnt=cnt+insertionSort(a,n,g);
			System.out.print(g);
			if(g!=1)System.out.print(" ");
			g=g/3;
		}
		System.out.println();
		System.out.println(cnt);
		writeln(a,n);
	}
}

Measured memory_bytes: 299456
#include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
int dp[2][1000001];
long long util(vector<int> adj[], int n, int u, int parent, int flag){
    if(dp[flag][u] != -1) return dp[flag][u];
    int white = 1;
    for(int i=0;i<adj[u].size();i++){
        int v = adj[u][i];
        if(v != parent) white = (white*(util(adj, n, v, u, 0)%MOD))%MOD;
    }
    int res = white;
    if(flag == 0){
        int black = 1;
        for(int i=0;i<adj[u].size();i++){
            int v = adj[u][i];
            if(v != parent) black = (black*(util(adj, n, v, u, 1)%MOD))%MOD;
        }
        res = (res + black)%MOD;
    }
    return dp[flag][u] = res;
}
int main(){
	int n;
	cin>>n;
    vector<int> adj[n];
    for(int i=0;i<n-1;i++){
        int xi, yi;
        cin>>xi>>yi;
        adj[xi-1].push_back(yi-1);
        adj[yi-1].push_back(xi-1);
    }
    memset(dp, -1, sizeof(dp));
    cout<<util(adj, n, 0, -1, 0);
	return 0;
}

Measured memory_bytes: 21888
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> H >> W;
	N = H * W;
	vector<vector<int>>v(H + 2, vector<int>(W + 2,MOD));
	vector<pair<int, int>>p(N + 1);
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> v[i][j];
			p[v[i][j]] = { i,j };
		}
	}
	int dir[] = { 0,1,0,-1,0 };
	int ans = 0;
	vector<int>ed(N + 1,1);
	for (int i = 2; i <= N; i++) {
		set<int>st;
		int y = p[i].first;
		int x = p[i].second;
		for (int j = 0; j < 4; j++) {
			int ny = y + dir[j];
			int nx = x + dir[j + 1];
			int num = v[ny][nx];
			if (num > i)continue;
			if (ed[num] == -1) {
				st.insert(-MOD);
				st.insert(MOD);
			}
			else {
				st.insert(ed[num]);
			}
		}
		if (st.size() > 1) {
			ed[i] = -1;
			ans++;
		}
		else if (st.size() == 1)ed[i] = *st.begin();
		else ed[i] = i;
		//cout << i << " " << ed[i] << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 18456
L,A,B,mod=map(int,input().split())
def f(l):
  return max(0,(10**l-A-1)//B+1)

def m(a,b):
  r=[[0]*len(b[0]) for i in range(len(a))]
  for i in range(len(a)):
    for k in range(len(b)):
      for j in range(len(b[0])):
        r[i][j]=(r[i][j]+a[i][k]*b[k][j])%mod
  return r

def p(a,n):
  r=[[0]*len(a) for i in range(len(a))]
  b=[]
  for i in range(len(a)):
    r[i][i]=1
    b.append(a[i][:])
  l=n
  while l>0:
    if l&1:
      r=m(b,r)
    b=m(b,b)
    l>>=1
  return r

X=[[0,0,1],[0,0,A],[0,0,0]]
Y,R,Z=0,1,0
while L:
  Y=[[1,0,0],[B,1,0],[0,1,pow(10,R,mod)]]
  Z=min(L,f(R)-f(R-1))
  L-=Z
  Y=p(Y,Z)
  X=m(Y,X)
  R+=1
print(X[2][2]%mod)


Measured memory_bytes: 73700
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define mod 1000000007
#define cbrt cbrtl
using namespace __gnu_pbds;
using namespace std;

int main()
{
  IOS

  ll a,b;
  cin>>a>>b;
  cout<<max(0LL,a-(2*b));
  return 0; 
  		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s[101];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,len;
    cin>>n>>len;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        cout <<s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  vector<pair<ll, ll>> aa(n), bb(n);

  aa[0] = {a[0], a[0]};
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i-1]) aa[i] = {a[i], a[i]};
    else aa[i] = {1, a[i]};
  }

  bb[n-1] = {b[n-1], b[n-1]};
  for (int i = n-2; i >= 0; i--) {
    if (i == 0 && n == 1) break;
    if (b[i] > b[i+1]) bb[i] = {b[i], b[i]};
    else bb[i] = {1, b[i]};
  }

  ll ans = 1;

  for (int i = 0; i < n; i++) {
    ll l = max(aa[i].first, bb[i].first);
    ll u = min(aa[i].second, bb[i].second);
    if (l > u) {
      cout << 0 << endl;
      return 0;
    }
    ans *= (u - l + 1);
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7928
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    a,b = invr()
    if abs(a - b) % 2 == 0:
        print((a + b) // 2)
    else:
        print("IMPOSSIBLE")
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

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

//シミュレーション用
void check(int a, int b){
    int A[a][b] = {};
    int dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
    int dy[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
    REP(i, a){
        REP(j, b){
            REP(k, 9){
                int nx, ny;
                nx = i + dx[k];
                ny = j + dy[k];
                if(nx < 0 or ny < 0 or nx >= a or ny >= b) continue;
                A[nx][ny]++;
            }
        }
    }
    REP(i, a){
        REP(j, b){
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
}

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

    long long n, m;
    cin >> n >> m;

    long long ans;
    if(n == 1 or m == 1){
        ans = max(1LL, max(n, m) - 2LL);
    }else{
        ans = (n - 2) * (m - 2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    for (int count = 1; count <= 10000; count++) {
        int num;
        cin >> num;
        
        if (num == 0) break;
        
        cout << "Case " << count << ": " << num << endl;
    }

    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000],s[110000];
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
    ll n,k,ans=0;
    cin>>n;
    rep(i,1,n+1){
        if(i%5!=0&&i%3!=0)ans+=i;
    }
    cout<<ans;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> E(N-1);
  vector<int> M(N+1);
  vector<int> nodec(N);  
  vector<int> edgec(N-1);  
  for (auto &[f,t]: E) {
    cin >> f >> t;
    ++M[--f];
    ++M[--t];
  }
 
  vector<int> I(N-1);
  iota(begin(I),end(I),0);
  sort(begin(I),end(I),[&](int i, int j){return E[i] < E[j];});
  int NC = *max_element(begin(M),end(M));
  cout << NC << endl;
  nodec[1] = 0;
  for (auto i: I) {
    auto [f,t] = E[i];
    nodec[f] %= NC;
    edgec[i] = nodec[t] = ++nodec[f];
  }
 
  for(auto c: edgec) cout << c << endl;
}

Measured memory_bytes: 5468
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)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;
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
set<string> st;
int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for (int i = 1; i <= min(10, n); i++) {
		for (int j = 0; j <= n - i; j++) {
			st.insert(s.substr(j, i));
		}
	}
	auto itr = st.begin();
	for (int i = 1; i < k; i++) {
		itr++;
	}
	cout << *itr << endl;
}


Measured memory_bytes: 6584
#include<bits/stdc++.h>
#define int long long

using namespace std ;
int a[1005] ;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ;

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

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

    int res =0;
    for (int i =0 ; i < k ; ++i)
    {
        res += a[i] ;
    }
    cout << res <<endl ;


}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll k,a,b;
    IN(k,a,b);
    bool f = false;
    rep(i,a,b+1){
        if(i%k==0) f = true;
    }
    if(f) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
   int X;
   cin>>X;
   if(X%7==4){
   cout<<"mon"<<endl;
   }
   else if(X%7==5){
   cout<<"tue"<<endl;
   }
   else if(X%7==6){
   cout<<"wed"<<endl;
   }
   else if(X%7==0){
   cout<<"thu"<<endl;
   }
   else if(X%7==1){
   cout<<"fri"<<endl;
   }
   else if(X%7==2){
   cout<<"sat"<<endl;
   }
   else if(X%7==3){
   cout<<"sun"<<endl;
   }
}


Measured memory_bytes: 3112
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            boolean[] numbers = new boolean[n];
            int index = 0;
            for (int i = 0; i < n; i++) {
                int counter = 0;
                while (counter < m) {
                    index =  (index + 1) % n;
                    if (!numbers[index]) {
                        counter++;
                    }
                }
                numbers[index] = true;
            }
            if (index == 0) {
                index = n;
            }
            System.out.println(index);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
package main

import "fmt"

type point struct {
	x int
	y int
}

const k = 3

func checkBingo(val []int, b map[int]bool) bool {
	cnt := 0
	for _, v := range val {
		if b[v] {
			cnt++
			if cnt == 3 {
				return true
			}
		}
	}
	return false
}

func main() {
	a := make(map[point]int)
	for i := 0; i < k; i++ {
		for j := 0; j < k; j++ {
			var tmp int
			fmt.Scan(&tmp)
			a[point{j, i}] = tmp
		}
	}

	var n int
	fmt.Scan(&n)
	b := make(map[int]bool, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		b[tmp] = true
	}

	for i := 0; i < k; i++ {
		valr := make([]int, k)
		valc := make([]int, k)
		for j := 0; j < k; j++ {
			valr[j] = a[point{j, i}]
			valc[j] = a[point{i, j}]
		}
		if checkBingo(valr, b) || checkBingo(valc, b) {
			fmt.Println("Yes")
			return
		}
	}

	vald1 := make([]int, k)
	vald1[0] = a[point{0, 0}]
	vald1[1] = a[point{1, 1}]
	vald1[2] = a[point{2, 2}]
	if checkBingo(vald1, b) {
		fmt.Println("Yes")
		return
	}

	vald2 := make([]int, k)
	vald2[0] = a[point{2, 0}]
	vald2[1] = a[point{1, 1}]
	vald2[2] = a[point{0, 2}]
	if checkBingo(vald2, b) {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}


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

void solve(long long N, std::vector<long double> p) {
  vector<double> dp(N + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < N; ++i) {
    auto currHead = p[i];
    auto currTail = 1 - p[i];
    for (int j = i + 1; j >= 0; j--) {
	dp[j] = (j > 0 ? dp[j - 1] * currHead : 0) + (dp[j] * currTail);
    }
  }
  double res = 0;
  for (int i = 0; i <= N; i++) {
    if (i > N - i) {
	res += dp[i];
    }
  }
  cout << setprecision(10) << res << "\n";
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long double> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%Lf", &p[i]);
  }
  solve(N, std::move(p));
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL; 
const int N=100005;
struct node { int y,next; } a[N<<1];
LL A[N];
int d[N],head[N],i,j,k,n,m,rt;
bool F;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	++d[x],++d[y],
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

void dfs(int w,int sp)
{
	if (d[w]==1) return;
	LL x=0,y=0;
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			dfs(c,j),
			x+=A[c],y=max(y,A[c]);
			if (!F) return;
		}
	LL z=x-A[w];
	if (z<0||(z<<1)>(y<=x-y?x:x-y<<1))
	{
		F=0;
		return;
	}
	A[w]=x-(z<<1);
}

int main()
{
	n=read(),k=1;
	for (i=1;i<=n;++i) A[i]=read();
	if (n==2)
	{
		puts(A[1]==A[2]?"YES":"NO");
		return 0;
	}
	for (i=1;i<n;++i) jb(read(),read());
	for (rt=1;d[rt]==1;++rt);
	F=1,dfs(rt,0);
	puts(F&&!A[rt]?"YES":"NO");
	return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  int ma = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      ma = max(ma,abs(a.at(i)-a.at(j)));
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=101;
const int modd=1e9+7;


int main(){
    int n;
    cin>>n;
    ll a[n];
    fo(i, n)cin>>a[i];
    ll dp[n+1][n+1]={0};
    /*
    fo(i, n)dp[i][i]=a[i];
    fo(i, n){
        fok(j,i+1, n){
            dp[i][j]=max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
        }
    }*/
    for(int ws=1;ws<=n;ws++){
        for(int i=0;i<n-ws+1;i++){
            int j=i+ws-1;
            if(i==j)dp[i][j]=a[i];
            else{
                dp[i][j]=max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
            }
        }
    }
    ll ans=dp[0][n-1];
    cout<<ans;
}

Measured memory_bytes: 73960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  double l;
  cin >> l;
  printf("%.12f", pow(l / 3, 3));
}

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

int main()
{
  long int H, N , x , sum = 0 ;
   cin>>H>>N;
   for(int i = 1; i<=N;i++)
   {
       cin>>x;
       sum+=x;

   }
   if(H<=sum)
   {
       cout<<"Yes"<<endl;
   }
   else if(H>sum)
   {
       cout<<"No"<<endl;
   }


    return 0;
}

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

int a[4];

int main() {
    string input;
    cin >> input;
    rep(i,4){
        a[i]=input[i]-'0';
    }
    rep(x,8){
        int sum=a[0];
        string s;
        s+= (char)('0'+a[0]); //不明
        rep(i,3){
            if(x&(1<<i)){
                sum+=a[i+1];
                s+='+';
                s+=(char)('0'+a[i+1]);
            } else{
                sum-=a[i+1];
                s+='-';
                s+=(char)('0'+a[i+1]);
            }
        }
        if(sum == 7){
            cout << s << "=7" << endl;
            return 0;
        }
    }
    
}

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

using namespace std;
using ll = long long;

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0)
      break;
    vector<vector<int>> mp(h, vector<int>(w));
    int ans = 0;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        cin >> mp[i][j];
    for (int i = 0; i < h - 2; i++)
      for (int j = 0; j < w - 2; j++) {
        for (int n = 3; n <= h - i; n++)
          for (int m = 3; m <= w - j; m++) {
            int mn = 100;
            bool ok = true;
            for (int k = 0; k < n; k++)
              mn = min(mn, mp[i + k][j]);
            for (int k = 0; k < n; k++)
              mn = min(mn, mp[i + k][j + m - 1]);
            for (int k = 0; k < m; k++)
              mn = min(mn, mp[i][j + k]);
            for (int k = 0; k < m; k++)
              mn = min(mn, mp[i + n - 1][j + k]);
            int sum = (n - 2) * (m - 2) * mn;
            for (int k = 1; k < n - 1; k++)
              for (int l = 1; l < m - 1; l++) {
                if (mn <= mp[i + k][j + l])
                  ok = false;
                sum -= mp[i + k][j + l];
              }
            if (ok)
              ans = max(ans, sum);
          }
      }
    cout << ans << endl;
  }
  return 0;
}


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

bool is_samestr(string S) {
    char fst = S[0];
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != fst) return false;
    }
    return true;
}

int main(void) {
    string S;
    cin >> S;
    string Orig = S;

    sort(S.begin(), S.end());

    int count = 1;
    char comp = S[0];
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != comp) {count++; comp = S[i];}
    }

    char ele[count];
    comp = S[0];
    int j = 0;
    ele[0] = comp;
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != comp) {j++; comp = S[i]; ele[j] = comp;}
    }

    string tempstr;
    int lcount, end;
    int min_count = 10000000;
    char cur_ele;
    for (int i = 0; i < count; ++i) {
        cur_ele = ele[i];
        tempstr = Orig;
        end = tempstr.length() - 1;
        lcount = 0;
        while (is_samestr(tempstr) != true) {
            for (int j = 0; j < end; ++j) {
                if (tempstr[j+1] == cur_ele) {tempstr[j] = cur_ele;}
            }
            tempstr.pop_back();
            lcount++; end--;
        }
        min_count = min(lcount, min_count);
    }
    cout << min_count << endl;
}

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

int main(){
   int n;
   cin >> n;
   int arr[n+5];
   int x = 0 , cnt = 0;
   for(int i = 1; i <= n; i++){
     cin >> arr[i];
     if(arr[i] >= x){
       x = arr[i];
       cnt++;
     }
   }
   cout << cnt << endl;
}

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

int main(int argc, char **argv)
{
	ll n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	sort(v.begin(), v.end());

	std::cout << v[n/2] - v[n/2-1]<< std::endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,d,a;
	cin>>n>>d>>a;
	vector<pair<int,int> > monsters;	
	for(int i=0;i<n;i++){
		int x,h;
		cin>>x>>h;
		h = (h+a-1)/a;
		monsters.emplace_back(x,h);
	}
	sort(monsters.begin(),monsters.end());
	ll ans = 0;
	ll h = 0;
	ll my_health;
	vector<ll> change(n+1,0);
	
	for(int i=0;i<n;i++){
		h += change[i];
		my_health = monsters[i].second - h;
		if(my_health<=0)
			continue;
		int st = 0, en = n-1;
		int ok = -1;
		
		while(st<=en){
			int mid = st + (en-st)/2;
			if(monsters[mid].first<=(monsters[i].first+(ll)2*d)){
				ok = mid;
				st = mid+1;
			}
			else en = mid-1;
		}
		change[ok+1] -= my_health;
		h += my_health;
		ans += my_health;
	}
	cout<<ans;
	return 0;
}


































Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<bool>G(N,true);
  for(int X=0;X<N;X++){
    int S;cin>>S;
    if(X+1==S){
      G[X]=false;
    }
  }
  int U=0;
  long long K=0;
  for(int X=0;X<N;X++){
    if(X!=0&&G[X]==true&&G[X-1]==false){
      K+=(U+1)/2;
      U=0;
    }
    else if(G[X]==false){
      U++;
    }
  }
  K+=(U+1)/2;
  cout<<K<<endl;
}

Measured memory_bytes: 3616
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = sorted(readLine_int_list(),reverse=True)
    a.append(-1)
    pair = []
    ans = 0
    t = 1
    
    for i in range(n):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
                if len(pair) == 2:
                    ans = pair[0] * pair[1]
                    break
            t = 1
        
        if t > 3:
            if pair:
                ans = max(a[i-1]*a[i], pair[0]*a[i])
            else:
                ans = a[i]**2
            break

        
        

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14624
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi 3.14159
int32_t main()
{
    IOS
 
	
	double n;
	cin>>n;
	cout<<setprecision(10)<<fixed<<2*pi*n<<endl;
}       

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
void secondsort(vector<pair<int, int>> &x) {
	sort(x.begin(), x.end(), [](pair<int, int> &a, pair<int, int> &b) {return a.second < b.second; });
}
int main() {
	cin >> N >> C;
	int MX = 1e5 + 10;
	vector<vector<int>> imos(C + 1, vector<int>(MX, 0));
	int maxt = 0;
	for (int i = 0; i < N; i++) {
		int l, r, c;
		cin >> l >> r >> c;
		imos[c][l]++, imos[c][r+1]--;
	}
	for (int c = 1; c <= C; c++) {
		for (int i = 1; i <= MX; i++) {
			imos[c][i] += imos[c][i - 1];
		}
		for (int i = 1; i <= MX; i++)if (imos[c][i])imos[c][i] = 1;
	}
	for (int i = 1; i <= MX; i++) {
		ll tmp = 0;
		for (int c = 1; c <= C; c++)tmp += imos[c][i];
		ans = max(tmp, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int h, w, ans;
string s[2005];
int g[2005][2005];
int a[2005][2005], b[2005][2005], c[2005][2005], d[2005][2005];

int main() {

	cin >> h >> w;

	rep(i, h)cin >> s[i];

	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '.')g[i + 1][j + 1]++;
		}
	}

	rrep(i, h) {
		rrep(j, w) {
			if (g[i][j] != 0)a[i][j] = a[i][j - 1] + 1;
		}
		for (int j = w; j > 0; j--) {
			if (g[i][j] != 0)b[i][j] = b[i][j + 1] + 1;
		}
	}

	rrep(i, w) {
		rrep(j, h) {
			if (g[j][i] != 0)c[j][i] = c[j - 1][i] + 1;
		}
		for (int j = h; j > 0; j--) {
			if (g[j][i] != 0)d[j][i] = d[j + 1][i] + 1;
		}
	}

	rrep(i, h) {
		rrep(j, w) {
			ans = max(ans, a[i][j] + b[i][j] + c[i][j] + d[i][j] - 3);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 84864
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val a, b, k = sc.nextLong
  val notEnough = (a - k) >= 0
  val ta = if (notEnough) a - k else 0
  val ans1 = if(ta > 0) ta else 0
  val ao = if (notEnough) b else b - (k - a)
  val ans2 = if(ao > 0) ao else 0
  println(ans1 + " " + ans2)
}


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

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

  if(a == b) {
    for(int i = 0; i < a; i++) {
      cout << a;
    }
    return 0;
  }

  if(a < b) {
    for(int i = 0; i < b; i++) {
      cout << a;
    }
  }else {
    for(int i = 0; i < a; i++) {
      cout << b;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
signed main()
{
    fastio;
    R(n);RA(a,n);
    int p[n+2];
    reset(p);
    frr(i,n,1)
    {
        p[i]=(p[i+1]+a[i])%mod;
       // cout<<p[i]<<endl;
    }
    int ans=0;
    fr(i,1,n+1)
    {
        ans=(ans+(a[i]*p[i+1])%mod)%mod;
    }
    cout<<ans<<endl;

}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
	// freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
  int n = s.size(), tmp = 0, sum = 0;
  for (int bit = 0; bit < (1 << (n - 1)); bit++) {
    for (int i = 0; i < n; i++) {
      tmp = tmp * 10 + (s[i] - '0');
      if ((1 << i) & bit || i == n - 1) {
        sum += tmp; tmp = 0;
      }
    }
  }
  cout << sum << '\n';
}


Measured memory_bytes: 256
n = int(input())
a_l = list(map(int, input().split()))
import numpy as np
ave_a = np.mean(a_l)
a_l2 = [ (i, abs(j-ave_a)) for i,j in enumerate(a_l) ]
a_l3 = sorted(a_l2, key=lambda x: x[1])
print(a_l3[0][0])

Measured memory_bytes: 12440
#include "bits/stdc++.h"
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
#define fr(i,a,b) for(int i =a;i<b;i++)
#define pb push_back
#define fi first
#define se second
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>

bool debug = 1;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define prinpar(a) if(debug) printf("%d/%d\n", (a.fi), (a.se))
#define separa() if(debug) cout << endl

const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double eps = 1e-9;
using namespace std;
#define N 100100

template <typename T, typename R> struct flowNet {
	
	int n, m;
	T inf;
	vector<pii> adj[N], parent;
	vector<T> flow, cap;

	flowNet(int n, T inf): n(n), m(0), inf(inf) {
		parent = vector<pii>(n+2, {0,0});
	}

	int addEdge(int a, int b, T c) {
		adj[a].pb({b, m});
		flow.pb(0);
		cap.pb(c);
		adj[b].pb({b, m|1});
		cap.pb(0);
		flow.pb(0);
		m += 2;
	}

	void incFlow(int id, int f) { flow[id] += f; flow[id|1] -= f; }
	int canPass(int id) { return cap[id] - flow[id]; }
	
	T augment(int s, int t) {
		bfs(s);
		if(parent[t].fi == -1) return 0;
		int x = t;
		T pathFlow = inf;
		while(x != s) {
			pathFlow = min(pathFlow, canPass(parent[x].se));
			x = parent[x].fi;
		}

		x = t;
		while(x != s) {
			incFlow(parent[x].se, pathFlow);
			x = parent[x].fi;
		}
		return pathFlow;
	}

	void bfs(int s) {
		queue<int> fila;
		for(int i=0;i<parent.size();i++) parent[i] = {-1,-1};
		fila.push(s);
		while(!fila.empty()) {
			int u = fila.front(); fila.pop();
			for(auto v : adj[u]) {
				if(parent[v.fi].fi == -1 && canPass(v.se) > 0) {
					parent[v.fi] = {u, v.se};
					fila.push(v.fi);
				}
			}
		}
	}

	R maxFlow(int s, int t) {
		R res = 0;
		int improv = augment(s,t);
		while(improv > 0) {
			res += improv;
			improv = augment(s,t);
		}
		return res;
	}
};

int deg[N];

int main () {


	int n,m;

	cin >> n >> m;

	int a,b;
	flowNet<int,int> f(n, 10000000); 
	for(int i=0;i<m;i++) {
		cin >> a >> b;
		f.addEdge(a,b,1);
		f.addEdge(b,a,1);
		deg[a]++;
		deg[b]++;
	}

	int plus6 = 0, plus4 = 0;

	vector<int> p4;
	for(int i=1;i<=n;i++) {
		if(deg[i] % 2) {
			printf("No\n");
			return 0;
		}
		if(deg[i] >= 4) {
			plus4++;
			p4.pb(i);
		}
		if(deg[i] >= 6) plus6++;
	}

	if(plus6 > 0) {
		printf("Yes\n");
		return 0;
	}

	if(plus4 >= 3) {
		printf("Yes\n");
		return 0;
	}

	
	if(plus4 == 2) {
		int mf = f.maxFlow(p4[0], p4[1]);
		if(mf == 2) {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;

}





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

int main(){
    int k, s;
    cin >> k >> s;
    int count = 0;
    for(int x = k; x >= 0; x--){
        for(int y = k; y >= 0; y--){
            if(s - x - y >= 0 && s - x - y <= k){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
typedef long long int lli;
int lli_compare(const void*a,const void*b){return *(lli*)a-*(lli*)b;}
int main(void)
{
    lli n,m;
    lli a[100000];
    lli sa[100000],ans=0;

    scanf("%lld %lld",&n,&m);
    for(lli i=0;i<m;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,m,sizeof(lli),lli_compare);
    for(lli i=0;i<m-1;i++){
        sa[i]=a[i+1]-a[i];
    }
    qsort(sa,m-1,sizeof(lli),lli_compare);
    for(lli i=0;i<m-n;i++){
        ans+=sa[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2540