akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       unordered_map<int,int> mp;
       int arr[n];
       rep(i,0,n)
       cin>>arr[i];
       rep(i,0,n)
       {
           int ct = 0;
           int x = arr[i];
           for(int i=2;i*i<=x;++i)
           {

               if(x%i==0)
               {
                  ct = 0;
                 while(x%i==0)
                 {
                     ct++;
                     x/=i;
                 }
                 mp[i]= max(mp[i],ct);mp[i]= max(mp[i],ct);
               }

           }
           if(x!=1)
            mp[x] = max(mp[x],1LL);
       }
       int lcm = 1;
       for(auto x:mp)
        lcm = (lcm*powmod(x.ff,x.ss))%mod;
        int ans = 0;
        rep(i,0,n)
       {
           ans = (ans + (lcm*powmod(arr[i],mod-2))%mod)%mod;
       }
        cout<<ans<<el;
    }


        return 0;
    }


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<string.h>
#include<stack>
#include<functional>
using namespace std;

signed main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d; cin >> c >> d;
		c--;
		if (c & 1) {
			cout << (c + 1) * 127 - d << endl;
		}
		else {
			cout << c * 127 + d << endl;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int P, Q, R;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> P >> Q >> R;

  int ans = min(P + Q, Q + R);
  ans = min(ans, R + P);

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

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

ll dp[3001][3001];
ll a[3001];
ll fun(int i,int j,bool flag)
{
    if(i == j)
    {
        if(flag)
            return a[i];
        else
            return -a[i];
    }
    if(dp[i][j] != -1)
        return dp[i][j];
    if(flag)
        return dp[i][j] = max(a[i]+fun(i+1,j,!flag),a[j]+fun(i,j-1,!flag));
    return dp[i][j] = min(-a[i]+fun(i+1,j,!flag),-a[j]+fun(i,j-1,!flag));
}
int main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<fun(0,n-1,true)<<endl;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int N;
VI F(100100),S(100100);
VVI X(100100);

void dfs(int B){
  if(B==0) F[0]=0;
  rep(i,X[B].size()){
    if(F[X[B][i]]==-1){
      F[X[B][i]]=F[B]+1;
      dfs(X[B][i]);
    }
  }
}

void dfs2(int B){
  if(B==N-1) S[N-1]=0;
  rep(i,X[B].size()){
    if(S[X[B][i]]==-1){
      S[X[B][i]]=S[B]+1;
      dfs2(X[B][i]);
    }
  }
}

int main(){
  cin>>N;
  VI A(N-1),B(N-1);
  rep(i,N-1) cin>>A[i]>>B[i];
  rep(i,N-1){
    X[A[i]-1].pb(B[i]-1);
    X[B[i]-1].pb(A[i]-1);
  }
  rep(i,100100) F[i]=-1;
  rep(i,100100) S[i]=-1;
  dfs(0);
  dfs2(N-1);
  int ans=0;
  rep(i,N) if(F[i]<=S[i]) ans++;
  if(ans>N-ans) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main(void) {
	int n, i, x, maximum;
	int pre[1024], now[1024];
	char in[1024];

	while (1) {
		scanf("%d ", &n);
		if (!n)
			break;

		for (i = 0; i < n+1; i++) {
			pre[i] = now[i] = 0;
		}
		maximum = 0;

		for (i = 0; i < n; i++) {
			scanf("%s ", in);
			for (x = 1; x < n+1; x++) {
				if (in[x-1] == '.') {
					now[x] = pre[x-1] < pre[x] ? pre[x-1] : pre[x];
					now[x] = now[x-1] < now[x] ? now[x-1] : now[x];
					now[x]++;
					if (maximum < now[x]) {
						maximum = now[x];
					}
				}
			}
			for (x = 1; x < n+1; x++) {
				pre[x] = now[x];
				now[x] = 0;
			}
		}
		printf("%d\n", maximum);
	}
	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int L;
  while(cin>>L,L){
    int n,m;
    cin>>n>>m;
    vector<int> d(n);
    REP(i,n-1){
      cin>>d[i+1];
    }
    sort(d.begin(),d.end());
    int ans = 0;
    REP(i,m){
      int k;
      cin>>k;
      vector<int>::iterator it = lower_bound(d.begin(),d.end(),k);
      int idx = distance(d.begin(), it);
      if(idx != n)ans += min(abs(k-d[idx-1]), abs(k-d[idx]));
      else ans += min(abs(k-d[idx-1]), L-k);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1328
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2


fun solve(N: Long): String {
    var res = ('a' + ((N-1)%26).toInt()).toString()

    var n = N - 1
    var base = 26L
    while (true) {
        n -= base

        if (n<0) break
        val m = n / base

        val c = 'a' + (m%26).toInt()
        res = c + res

        base *= 26L
    }

    return res
}


fun main(args: Array<String>){
    val N = readLong()

    val ans = solve(N)

    println(ans)
}


Measured memory_bytes: 34172
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cstdio>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

struct Node {
  int to;
  int idx;
  int flow;
  Node(int to,int idx,int flow) :
    to(to),idx(idx),flow(flow) {}
};

class FordFulkerson {
private:
  vector<Node>* _graph;
  bool* _used;
  int _size;

  int dfs(int src,int flow,int sink){
    if(src == sink) return flow;

    _used[src] = true;
    for(int i= 0;i < _graph[src].size();i++){
      Node& e = _graph[src][i];
      if(_used[e.to]) continue;
      if(e.flow <= 0) continue;
      int d = dfs(e.to,min(flow,e.flow),sink);
      if(d <= 0) continue;

      Node& rev_e = _graph[e.to][e.idx];
      e.flow -= d;
      rev_e.flow += d;
      return d;
    }
    return 0;
  }

public:  
  FordFulkerson(int n) {
    _size = n;
    _graph = new vector<Node>[_size];
    _used = new bool[_size];
  }
  FordFulkerson(const FordFulkerson& f){
    _size = f.size();
    _graph = new vector<Node>[_size];
    _used = new bool[_size];
    fill((bool*)_used,(bool*)_used + _size,false);

    for(int i = 0; i < f.size(); i++){
      for(int j = 0; j < f.graph()[i].size(); j++){
        _graph[i].push_back(f.graph()[i][j]);
      }
    }
  }

  void add_edge(int from,int to,int flow) {
    _graph[from].push_back(Node(to,_graph[to].size(),flow));
    _graph[to].push_back(Node(from,_graph[from].size()-1,flow));
  }

  int compute_maxflow(int src,int sink){
    int res = 0;

    while(true){
      fill((bool*)_used,(bool*)_used + _size,false);
      int tmp = dfs(src,numeric_limits<int>::max(),sink);
      if(tmp == 0) break;
      res += tmp;
    }
    return res;
  }

  int size() const{
    return _size;
  }
  vector<Node>* graph() const{
    return _graph;
  }
};

int main(){
  int num_of_houses;
  int num_of_paths;
  while(~scanf("%d %d",&num_of_houses,&num_of_paths)){
    if(num_of_houses == 0 && num_of_paths == 0) break;

    FordFulkerson ff(num_of_houses);
    int bonus = 0;

    for(int path_i = 0; path_i < num_of_paths; path_i++){
      int from,to;
      int cost;
      scanf("%d %d %d",&from,&to,&cost);
      if(cost < 0) bonus += cost; 
      ff.add_edge(from,to,max(0,cost));
    }

    int res = numeric_limits<int>::max();

    for(int house_i = 1; house_i< num_of_houses; house_i++){
      FordFulkerson tmp(ff);
      res = min(res,tmp.compute_maxflow(0,house_i));
    }
    printf("%d\n",bonus + res);
  }
}

Measured memory_bytes: 24904
#include <stdio.h>

int main(void){
	char C[2][4];
	int i;
	for(i=0;i<2;i++) scanf("%c%c%c%c",&C[i][0],&C[i][1],&C[i][2],&C[1][3]);
	for(i=0;i<3;i++){
		if(C[0][i]!=C[1][2-i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

int main(){
    int N, T; cin >> N >> T;
    long long ans=0;
    vector<int> t(N+1);  
    for(int i = 0; i < N; i++) cin >> t[i];
    t[N] += t[N-1]+T+1; // T以上なら何でも
    for(int i = 0; i < N; i++) ans += min(T, t[i+1]-t[i]);
    cout << ans << endl;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll count;
  string s;
  bool ac = true;
  cin >> s;
  if (s[0] != 'A')
	ac = false;
  else{
	forll(i, 1, s.size()){
	  if (s[i] == 'C' && i > 1 && i < s.size()-1){
		count += 1;
	  }else{
		if (s[i] >= 'A' and s[i] <='Z'){
		  ac = false;
		  break;
		}
	  }
	}
	if (count != 1)
	  ac = false;
  }
  
  if (ac == true)
	cout << "AC" << endl;
  else
	cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int a[200005];
bool b[200005], stable[200005];

bool check(int x)
{
	for(int i = 1; i <= 2*n-1; i++) b[i] = (a[i] >= x);
	for(int i = 1; i <= 2*n-1; i++){
		stable[i] = (i-1 >= 1 && b[i-1] == b[i] || i+1 <= 2*n-1 && b[i+1] == b[i]); 
	}
	if(stable[n]) return b[n];
	
	for(int i = 1; i <= n-1; i++){
		if(stable[n-i] || stable[n+i]) return b[n-i];
	}
	if((n-1)%2) return !b[n];
	else return b[n];
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= 2*n-1; i++) cin >> a[i];
	
	int ub = 2*n, lb = 1, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(check(mid)) lb = mid;
		else ub = mid;
	}
	cout << lb << endl;
	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int a,b,c;
  a=N/100, b=(N/10)%10, c=N%10;
  
  if (a == 7 || b == 7 || c == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define brep(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define MAX 100005
int gcd(int a,int b){

	int c = max(a,b);
	int d = min(a,b);
	if(d == 0) return c;
	if(d == 1) return 1;
	return gcd(c%d,d);
}

int main(){
	int n,k,temp;
	cin >> n >> k;
	int a,b;
	int tgcd = 0;
	int maxi = -1;
	rep(i,0,n){
		cin >> temp;
		maxi = max(maxi,temp);
		tgcd = gcd(tgcd,temp);
	}
	if(k > maxi){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	if(tgcd == 1){
		cout << "POSSIBLE" << endl;
		return 0;
	}
	if(gcd(tgcd,k) != 1){
		cout << "POSSIBLE" << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}
		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    long long N,A,B,C,ans=0;

    cin >> N >> A >> B;

    C= A+B;

    ans += N/C * A;

    ans += min(N%C,A);

    cout << ans;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

ll a[500];
ll dp[405][405];


int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	forn(i, 0, n - 1){
		cin >> a[i];
	}
	forn(diff, 1, n){
		forn(s, 0, n - 1){
			int e = s + diff;
			if(e > n - 1) break;
			ll &ans = dp[s][e];
			ll ls = 0;
			ll rs = 0;
			forn(i, s, e){
				rs += a[i];
			}
			ans = 1e18;
			forn(i, s, e - 1){
				ls += a[i];
				rs -= a[i];
				ans = min(ans, ls + rs + dp[s][i] + dp[i + 1][e]);
			}
		}
	}	
	cout << dp[0][n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int n, m;
vector<int> p1, p2;
int main()
{
  while(cin >> n >> m && n && m){
    p1.clear();
    p2.clear();
     
    //chap1
    p1.push_back(0);
    for(int i = 0; i < n; i++){
      int p;
      cin >> p;
      p1.push_back(p);
    }
 
    //chap2
    for(int i = 0; i <= n; i++)
      for(int j = i; j <= n; j++)
    p2.push_back(p1[i] + p1[j]);
 
    sort(p2.begin(), p2.begin() + p2.size());
 
    //chap3
    int ans = 0;
    for(int i = 0; i < p2.size(); i++){
      vector<int>::iterator count2 = upper_bound(p2.begin(), p2.end(), m - p2[i]);
      if(count2 != p2.begin())
    ans = max(ans, *(count2 - 1) + p2[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
a,b,c,x,y = list(map(int, input().split()))

s = [0,0,0]

s[0] = x*a + y*b

c_half_num = min(x,y)
s[1] = max((x-c_half_num),0)*a + max((y-c_half_num),0)*b + c_half_num*(c*2)

c_half_num = max(x,y)
s[2] = c_half_num * (c*2)

print(min(s))

Measured memory_bytes: 3064
n=gets.to_i

set = []
n.times{
    set << gets.chomp!
}
t = gets.chomp!

l = 0
r = 0
set.each{|e|
    l+=1 if e.gsub('?','a') <= t
    r+=1 if e.gsub('?','z') < t
}

puts ((r+1)..(l+1)).to_a*" "
    

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

int main() {
  // 科目の数Nを受け取る
  int A,B,C;
  cin >> A >> B >> C;
  if(A == B && B == C){
    cout << "No" << endl;
  }else if(A == B && A != C){
    cout << "Yes" << endl;
  }else if(A == C && B != C){
    cout << "Yes" << endl;
  }else if(B == C && B != A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define MAXN 1010
#define N 1010
#define LOGN 20
#define buli(x) (__builtin_popcountll(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
const ll mod = 1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define int long long
int a, b, c, d, n;
ll fat[N], ifat[N], mat[N][N];
int dp[N][N], dp2[N][N];
void pre(){
    rep(i,0,MAXN){
        mat[i][0]=mat[i][i]=1;
        rep(j,0,i){
            mat[i][j]=(mat[i-1][j]+mat[i-1][j-1])%mod;
        }
    }
}

ll comb(int x, int y){
    return mat[x][y]%mod;
}

ll solve2(int qt, int t){
    if(qt == 1) return 1;
    if(dp2[qt][t]!=-1)return dp2[qt][t];
    ll ans =0;
    ans = (solve2(qt-1,t)*comb(qt*t, t))%mod;
    ans%=mod;
    return dp2[qt][t]=ans;
}

int solve(int p, int t){
    if(p == 0)return 1;
    if(t >b)return 0;
    if(dp[p][t]!=-1)return dp[p][t];
    ll ans=0;
    ans += solve(p,t+1);
    ans%=mod;
    for (int i = c; i <= d && i * t <= p; i++){
        ll temp = solve(p - (i * t), t + 1) %mod;
        temp = (temp * comb(p,t*i))%mod;
        temp = (temp * solve2(i, t))%mod;
        temp = (temp * ifat[i])%mod;
        ans = (ans + temp)%mod;
    }
    return dp[p][t]=ans;
}

int32_t main()
{
    fat[0]=1; 
    rep(i,1,MAXN)fat[i]= (fat[i-1]*i)%mod;
    rep(i,0,MAXN)ifat[i]=powmod(fat[i],mod-2);
    gn(n); gn(a);gn(b);gn(c);gn(d); 
    pre();
    clr(dp, -1);
    clr(dp2, -1);
    printf("%lld\n", solve(n, a));
    return 0;
}












































Measured memory_bytes: 24192
#include<stdio.h>

main(){
	int a, b, c, i, count;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(i = a; i <= b; i++){
		if(c%i == 0)
			 count ++;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#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 all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n, k;
    cin >> n >> k;
    vector<ll> list(n);
    rep(i, n){
        cin >> list[i];
    }
    sort(all(list));
    ll diff, mn = inf;
    rep(i, n - k + 1){
        diff = list[i + k - 1] - list[i];
        mn = min(mn, diff);
    }
    cout << mn << endl;
}

Measured memory_bytes: 1024
from collections import deque
n=int(input())
A=list(map(int,input().split()))
q=deque()
for i in range(n):
    if n%2!=i%2:
        q.appendleft(A[i])
    else:
        q.append(A[i])

#print(q)
l=list(q)

print(" ".join(map(str,l)))


Measured memory_bytes: 30660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("input15.txt","w",stdout);
    int n,x,y,i;
    cin>>n;
    int mxx=-1e9,mnx=1e9,mxy=-1e9,mny=1e9;
    for(i=0; i<n; i++)
    {
        cin>>x>>y;
        mxx = max(mxx,x+y);
        mnx = min(mnx,x+y);

        mxy = max(mxy,x-y);
        mny = min(mny,x-y);
    }
    cout<<max(mxx-mnx,mxy-mny)<<endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b && b<c){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26252
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D=0;
  str N;
  cin>>A;
  vector<char>S(100);
  rep(0,A){
    cin>>S.at(i);
    if(S.at(i)=='Y')D+=1;
  }
  if(D>0)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#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"

using namespace std;

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

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

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

	cin >> N >> L >> R;
	if (N == 1) {
		cout << "YES\n";
		cout << L << " " << R << endl;
		return 0;
	}
	H = L;
	W = R;
	for (int i = 0; i < 20; i++) {
		if (H % 2 != W % 2)K++;
		H /= 2;
		W /= 2;
	}
	if (K % 2 == 0) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	if (K == 1) {
		vector<int>dif((1 << N));
		for (int i = 1; i < 1 << N; i++) {
			int box = i;
			while (box % 2 == 0) {
				box /= 2;
				dif[i]++;
			}
		}
		dif[0] = N - 1;
		vector<int>ans(1, L);
		vector<int>ret;
		for (int i = 0; i < 1 << N; i++) {
			if (abs(L - R) == 1 << (dif[i])) {
				for (int j = 0; j < (1 << N) - 1; j++) {
					L ^= (1 << dif[(i + j + 1) % (1 << N)]);
					ans.push_back(L);
					ret.push_back(dif[(i + j + 1) % (1 << N)]);
				}
				break;
			}
		}
		for (auto i : ans)cout << i << " ";
		cout << endl;
		return 0;
	}
	vector<int>bag;
	H = L;
	W = R;
	for (int i = 0; i < 20; i++) {
		if (H % 2 != W % 2)bag.push_back(i);
		H /= 2;
		W /= 2;
	}
	vector<int>dif((1 << N));
	for (int i = 1; i < 1 << N; i++) {
		int box = i;
		while (box % 2 == 0) {
			box /= 2;
			dif[i]++;
		}
	}
	dif[0] = N - 1;
	vector<int>converter(N);
	vector<int>used(N);
	int index = N - 1;
	for (int i = 0; i < bag.size(); i++) {
		converter[index--] = bag[i];
		used[bag[i]]++;
	}
	for (int i = 0; i < N; i++) {
		if (!used[i]) {
			converter[index--] = i;
		}
	}
	for (auto &i : dif)i = converter[i];
	//for (int i = 1; i < dif.size(); i++)cout << dif[i] << endl;
	for (int i = 1; i < bag.size(); i += 2) {
		for (int j = 1; j < dif.size(); j++) {
			if (dif[j] == bag[i]) {
				dif[j] = bag[i + 1];
				dif[j / 2] = bag[i];
				dif[j * 3 / 2] = bag[i];
				break;
			}
		}
	}
	cout << L;
	for (int i = 1; i < dif.size(); i++) {
		L ^= (1 << dif[i]);
		cout << " " << L;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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

int main(){
    int n, k;
    cin>>n>>k;
    vector<int> vec(n, 0);
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        vec[a-1]++;
    }
    sort(vec.begin(), vec.end());
    int ans=0;
    for(int i=0; i<n-k; i++){
        ans+=vec[i];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())

MOD = 10 ** 9 + 7
prime_factors = []
i = 2
while i ** 2 <= m:
    ext = 0
    while m % i == 0:
        ext += 1
        m //= i
    if ext:
        prime_factors.append((i, ext))
    i += 1
if m != 1:
    prime_factors.append((m, 1))

ans = 1
for pf, num in prime_factors:
    denominator = 1
    numerator = 1
    for i in range(num):
        denominator *= (i+1)
        numerator *= (num + (n-1)) - i
    ans = (ans * (numerator // denominator)) % MOD
print(ans)


Measured memory_bytes: 63584
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int sum1 = 0, sum2 = 0, in;
	for(int i = 0; i < 4; i ++){
		cin >> in;
		sum1 += in;
	}
	for(int i = 0; i < 4; i ++){
		cin >> in;
		sum2 += in;
	}
	cout << max(sum1, sum2) << endl;

	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main(){
    int N;
    cin >> N;
    int p[55];
    for(int i = 1;i <= N;i++){
        cin >> p[i];
    }
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= N;j++){
            swap(p[i], p[j]);
            int count = 0;
            for(int k = 1;k <= N;k++){
                if(p[k] == k){count++;}
            }
            if(count == N){cout << "YES";return 0;
            }
            swap(p[i], p[j]);
        }
    }
    cout << "NO";
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	vii a(4);
	rep1(i, 30000) {
		if (i % 2 == 0 && i % 3 == 0) {
			a[0].push_back(i);
		}
		if (i % 2 == 0 && i % 3 == 1) {
			a[1].push_back(i);
		}
		if (i % 2 == 0 && i % 3 == 2) {
			a[2].push_back(i);
		}
		if (i % 2 == 1 && i % 3 == 0) {
			a[3].push_back(i);
		}
	}
	vi idx(4);
	cout << "2 3 4 9 ";
	idx[1] = idx[2] = 1;
	idx[3] = 2;
	int cnt = 4;
	vi ans;
	while (idx[3] < 4999 && cnt + 2 <= n) {
		cout << a[3][idx[3]] << " ";
		ans.push_back(a[3][idx[3]]);
		idx[3]++;
		cout << a[3][idx[3]] << " ";
		ans.push_back(a[3][idx[3]]);
		idx[3]++;
		cnt += 2;
	}
	while (idx[1] < 5000 && cnt + 2 <= n) {
		cout << a[1][idx[1]] << " " << a[2][idx[2]] << " ";
		ans.push_back(a[1][idx[1]]);
		ans.push_back(a[2][idx[2]]);
		idx[1]++; idx[2]++;
		cnt += 2;
	}
	while (idx[0] < 5000 && cnt < n) {
		cout << a[0][idx[0]] << " ";
		ans.push_back(a[0][idx[0]]);
		idx[0]++;
		cnt++;
	}
	cout << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


int main(void){
    char s[205];
    int i, j;
    int flag;
    int ans = 0;
    int len;
    scanf("%s", s);
    len = strlen(s);


    for (i = 1; i < len/2; i++){
        flag = 1;
        for (j = 0; j < i; j++){
            if (s[j] != s[i+j]){
                flag = 0;
            }
        }
        if (flag == 1){
            ans = i*2;
        }
    }

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


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int ta = 0, iwa = n;
	for (int i = 0; i < 10; i++) {
		ta += iwa % 10;
		iwa /= 10;
	}
	if (n%ta == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}



/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 1e5 + 9;

bool can(int n, vector<int> &arr, int br){
	int left = n - br;
	int curr = 1;
	int ans = 0;
	for(int i =0 ;i < n; i++){
		if(arr[i] == curr) curr++;
		else ans++;
	}
	if(curr <= left) return 0;
	return 1;
}
int main()
{
    IO;
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i =0 ;i < n; i++){
		cin>>arr[i];
	} 
	int low = 0, hi = n-1;
	while(low <hi){
		int mid = (low+hi)/2;
		if(can(n, arr, mid)){
			hi = mid;
		}else low = mid +1;
		
	}
	if(can(n, arr, low))cout<<low;
	else cout<<-1;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int a[15];
int main() {
	int m1, m2, n1, n2;
	int cnt = 0;
	cin >> m1 >> n1 >> m2 >> n2;
	a[1] = 31;
	a[2] = 28;
	a[3] = 31;
	a[4] = 30;
	a[5] = 31;
	a[6] = 30;
	a[7] = 31;
	a[8] = 31;
	a[9] = 30;
	a[10] = 31;
	a[11] = 30;
	a[12] = 31;
	if (a[m1] == n1)
		return cout << 1, 0;
	else if (a[m1] != n1)
		return cout << 0, 0;
}

Measured memory_bytes: 256
from collections import deque, defaultdict

def main():
    N, M = tuple(int(c) for c in input().split(' '))
    #A = [None]
    #B = [None]
    R = defaultdict(set)
    for _ in range(M):
        a, b = tuple(int(c) for c in input().split(' '))
        R[a].add(b)
        R[b].add(a)

    D = [0]*(N+1)  #これから決めていく方向
    D[1] = -1
    traced = set()
    traced.add(1)

    #幅優先探索
    q = deque((1, x) for x in R[1])
    #print(q)
    while(True):
        if(len(q) <= 0):
            #print('D:', D)
            #print('done.')
            break
        pos, x = q.popleft()
        if x == 1:
            continue
        if D[x] == 0:
            assert not x in traced
            D[x] = pos
            traced.add(x)
            #print(f'direction: {pos}<-{x}')
            t = [(x, y) for y in R[x]]
            for x, y in t:
                if not y in traced:
                    q.append((x, y))
            #print((pos, x), '->', q)
        elif D[x] == pos:
            assert x in traced
            continue
        else:
            #print(f'already {D[x]}<-{x}, so ignored {pos}<-{x}')
            continue
            #print('No')  #これでいいか？
            #exit()
    print('Yes')
    for i in range(2, len(D)):
        print(D[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 78352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    String S = sc.next();
    StringBuilder SS = new StringBuilder(S);
    if (S.length() > K) {
      SS = SS.replace(K,S.length(),"...");
    } 
    System.out.println(SS);
  }
}

Measured memory_bytes: 35800
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint H, W;
	cin >> H >> W;

	if (H == 1 || W == 1)
	{
		cout << 1 << endl;
		return;
	}

	if ((H % 2 == 1) && (W % 2 == 1))
		cout << (H * W) / 2 + 1 << endl;
	else
		cout << (H * W) / 2 << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int X, Y;
    cin >> X >> Y;
    if (X < Y) swap(X, Y);
    if (X <= 1 && Y <= 1) {
        cout << "Brown" << endl;
        return 0;
    }
    if (X == 2 && Y == 1) {
        cout << "Brown" << endl;
        return 0;
    }

    if (abs(X - Y) <= 1) {
        cout << "Brown" << endl;
        return 0;
    }

    cout << "Alice" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var str string
	fmt.Scan(&str)

	var q int
	fmt.Scan(&q)

	for i := 0; i < q; i++ {
		var c string
		fmt.Scan(&c)

		switch c {
		case "print":
			var a, b int
			fmt.Scan(&a, &b)
			fmt.Printf("%s\n", str[a:b+1])
		case "reverse":
			var a, b int
			fmt.Scan(&a, &b)
			buf := make([]rune, len(str))
			j := b
			for i, v := range str {
				if a <= i && i <= b {
					buf[j] = v
					if j != 0 {
						j--
					}
				} else {
					buf[i] = v
				}
			}
			str = string(buf)
		case "replace":
			var a, b int
			var p string
			fmt.Scan(&a, &b, &p)
			str = str[0:a] + p + str[b+1:len(str)]
		}
	}
}



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

const int MAX_H = 210;
const int MAX_W = 210;

ll a[MAX_H][MAX_W];

void init(int H, int W){
	for(int i = 0;i <= H;i++){
		for(int j = 1;j <= W;j++){
			a[i][j] += a[i][j - 1];
		}
	}
	for(int j = 0;j <= W;j++){
		for(int i = 1;i <= H;i++){
			a[i][j] += a[i - 1][j];
		}
	}
}

ll sum(int li, int lj, int ri, int rj){
	return a[ri][rj] - a[ri][lj] - a[li][rj] + a[li][lj];
}

ll calc(int li, int lj, int ri, int rj, int n){
	if(n == 1) return sum(li, lj, ri, rj);
	ll res = 0;
	for(int i = li;i <= ri;i++){
		for(int j = 1;j < n;j++){
			res = max(res, min(calc(li, lj, i, rj, j), calc(i, lj, ri, rj, n - j)));
		}
	}
	for(int j = lj;j <= rj;j++){
		for(int i = 1;i < n;i++){
			res = max(res, min(calc(li, lj, ri, j, i), calc(li, j, ri, rj, n - i)));
		}
	}
	return res;
}

bool judge(int H, int W, int m){
	if(m == 0) return true;
	for(int i = 1;i <= H;i++){
		int j = 0;
		while(j <= W && sum(0, 0,i, j) < m) ++j;
		if(j > W) continue;
		int k = 0;
		while(k <= i && sum(0, j, k, W) < m) ++k;
		if(k > i) continue;
		int l = j;
		while(l <= W && sum(i, 0, H, l) < m) ++l;
		if(l > W) continue;
		if(sum(k, l, H, W) >= m) return true;
	}
	for(int i = 1;i <= W;i++){
		int j = 0;
		while(j <= H && sum(0, 0, j, i) < m) ++j;
		if(j > H) continue;
		int k = 0;
		while(k <= i && sum(j, 0, H, k) < m) ++k;
		if(k > i) continue;
		int l = j;
		while(l <= H && sum(0, i, l, W) < m) ++l;
		if(l > H) continue;
		if(sum(l, k, H, W) >= m) return true;
	}
	return false;
}

int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			cin >> a[i + 1][j + 1];
		}
	}
	init(H, W);
	ll res = calc(0, 0, H, W, N);
	if(N == 4){
		ll lb = 0, ub = 1e9;
		while(ub - lb > 1){
			ll m = (lb + ub) >> 1;
			if(judge(H, W, m)){
				lb = m;
			}
			else{
				ub = m;
			}
		}
		res = max(res, lb);
	}
	cout << res << endl;
}



Measured memory_bytes: 3440
N=int(input())
if N>=64:
    print(64)
elif 32<=N and N<64:
    print(32)
elif 16<=N and N<32:
    print(16)
elif 8<=N and N<16:
    print(8)
elif 4<=N and N<8:
    print(4)
elif 2<=N and N<4:
    print(2)
else:
    print(1)
    

Measured memory_bytes: 3060
import numpy as np
h,w=map(int,input().split())
a=np.array([ list(input()) for i in range(h)])
count=0
d_w=[]
d_h=[]
for i in range(0,h):
  count=0
  for j in range(0,w):
    if a[i][j]==".":
      count+=1
  if count==w:
    d_w.append(i)
for i in range(0,w):
  count=0
  for j in range(0,h):
    if a[j][i]==".":
      count+=1
  if count==h:
    d_h.append(i)
a=np.delete(a,d_w,0)
a=np.delete(a,d_h,1)
for i in a:
  print("".join(i))

Measured memory_bytes: 12528
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		int n=getInt();
		String in=s.next();
		List<Integer>l=new ArrayList<>();
		for(int i=0;i<n;++i){
			if(i==n-1||in.charAt(i)!=in.charAt(i+1)) {
				l.add(1);
			}else {
				l.add(2);
				++i;
			}
		}
		long r=l.get(0)==1?3:6,mod=1000000007;
		for(int i=1;i<l.size();++i) {
			if(l.get(i-1)==1&&l.get(i)==1) {
				r*=2;
			}
			if(l.get(i-1)==1&&l.get(i)==2) {
				r*=2;
			}
			if(l.get(i-1)==2&&l.get(i)==2) {
				r*=3;
			}
			r%=mod;
		}
		System.out.println(r);
	}
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll L[200005];
ll R[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    memset(R, 0, sizeof(R));
    for (ll i = N - 1; i >= 0; --i) {
        R[i] = std::max(R[i], R[i + 1]);
        if (S[i] == 'o') {
            ll x = i + C + 1;
            if (x <= N)
                R[i] = std::max(R[i], R[x] + 1);
            else
                R[i] = 1;
        }
    }

    vector<ll> v;
    ll index = 0;
    ll n = 0;
    while (index < N) {
        if (S[index] == 'x') {
            index++;
            continue;
        }
        if (n + R[index + 1] < K)
            v.push_back(index + 1);
        n++;
        index += C + 1;
    }
    REP(i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6948
from collections import deque
n,m=map(int,input().split())
if m==0:
  print(-1)
  exit()
path=[[] for _ in range(3*n)]
for i in range(m):
  u,v=map(int,input().split())
  path[3*(u-1)].append(3*(v-1)+1)
  path[3*(u-1)+1].append(3*(v-1)+2)
  path[3*(u-1)+2].append(3*(v-1))
s,t=map(int,input().split())
s-=1
t-=1
visited=[0]*(3*m)
q=deque([3*s])
visited[3*s]=1
while q:
  x=q.popleft()
  if x%3==0 and x//3==t:
    print(visited[x]//3)
    exit()
  for i in path[x]:
    if visited[i]==0:
      visited[i]=visited[x]+1
      q.append(i)
print(-1)

Measured memory_bytes: 60144
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 08:53:27 2020

@author: asaka
"""

N, M = map(int, input().split())
H = list( map(int, input().split()) )
A = []
for m in range(M):
    A.append( list( map(lambda x: x-1, list(map(int, input().split()))) ) )
    
K = [1]*N

for m in range(M):
    if H[ A[m][1] ] >= H[ A[m][0] ] and K[A[m][0]] ==1 :
        K[A[m][0]] -= 1
            
    if H[ A[m][0] ] >= H[ A[m][1] ] and K[A[m][1]] ==1:
        K[A[m][1]] -= 1
            
print(sum(K))

Measured memory_bytes: 96884
#include<bits/stdc++.h>
using namespace std;
int solve(int a){
	int curr = 0;
	int counter = 1;
	while(curr<=a) curr+=counter++;
	return counter-2;
}
int main(){
	long long n;
	cin>>n;
	vector<int>primes;
	for(long long i=2; i*i<=n; i++){
		if(n%i==0){
			int counter = 0;
			while(n%i==0){
				counter++;
				n/=i;
			}
			primes.push_back(counter);
		}
	} 
	if(n!=1) primes.push_back(1);
	int ret = 0;
	for(int i=0; i<primes.size(); i++){
		ret+=solve(primes[i]);
	}
	cout<<ret;
}

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

int main(){
    using namespace std;
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if(s==u) a--;
    else if(t==u) b--;
    cout << a << " "  << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int N, a, b, c, d, p1, p2;

int main()
{
    cin >> N;
    vector<pair<pair<int, int>, int>> x, y;
    WeightedGraph<int> G(N);

    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        a--, b--;
        x.emplace_back(make_pair(a, b), i);
        y.emplace_back(make_pair(b, a), i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = 0; i + 1 < N; i++)
    {
        a = x[i].first.first, b = x[i].first.second, c = x[i + 1].first.first, d = x[i + 1].first.second;
        int p1 = x[i].second, p2 = x[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));
    }

    for (int i = 0; i + 1 < N; i++)
    {
        a = y[i].first.first, b = y[i].first.second, c = y[i + 1].first.first, d = y[i + 1].first.second, p1 = y[i].second, p2 = y[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));
    }

    cout << Prim(G) << endl;
}

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

using namespace std;

int D;
string c;

int main () {

    cin >> D;

    if (D == 22){
        c = "Christmas Eve Eve Eve";
    }
    else if (D == 23){
        c = "Christmas Eve Eve";
    }
    else if (D == 24){
        c = "Christmas Eve";
    }
  	else if (D == 25){
      	c = "Christmas";
    }
  
    cout << c << "\n";

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
using namespace std;
int main()

{
    int N, count = 0, count1 = 0;
    cin >> N;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
        if (a[i] % 4 == 0)
        {
            count++;
        }
        else if (a[i] % 2 == 0)
        {
            count1++;
        }
    }
    if (N / 2 > count + count1 / 2)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 640