akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  int n,k;
  cin >> n >> k;
  ll ans=0;
  rep(i,n){
    ll y=i+1;
    if(y<=k)continue;
    ll o=n%y;
    ll q=n/y;
    ll w=0;
    ans+=q*(y-k)+max(w,o-k+1);
  }
  if(k==0)ans-=n;
  cout << ans << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = struct { ll to, cost; };
bool operator<(const Edge &e1, const Edge &e2) {
  return (e1.cost != e2.cost) ? e1.cost > e2.cost : e1.to < e2.to;
}
template<class E>
using Graph = vector<vector<E>>;

struct Dijkstra {
  vector<ll> d;
  const ll INF = 1e15;
  template<class E>
    Dijkstra(const Graph<E> &G, ll s) {
      int N = G.size();
      priority_queue<Edge> pq;
      d.assign(N, INF); d[s] = 0;
      pq.push({s, 0});
      while (!pq.empty()) {
        Edge e = pq.top(); pq.pop();
        ll u = e.to;
        if (d[u] < e.cost) continue;
        for (auto&& v : G[u]) {
          if (d[v.to] > d[u] + v.cost) {
            d[v.to] = d[u] + v.cost;
            pq.push({v.to, d[v.to]});
          }
        }
      }
    }
};

int main() {
  int N; cin >> N;
  Graph<Edge> G(N);
  for (int i = 0; i < N - 1; ++i) {
    ll a, b, c; cin >> a >> b >> c;
    --a; --b;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  ll Q, K; cin >> Q >> K;
  --K;
  Dijkstra dijkstra(G, K);
  while (Q--) {
    ll x, y; cin >> x >> y;
    --x; --y;
    cout << dijkstra.d[x] + dijkstra.d[y] << endl;
  }
  return 0;
}


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

int main() {
	int argc;
    int numberOfButtons;
    cin >> numberOfButtons;
    vector<int> buttons(numberOfButtons);
    
    for (int button_i = 0; button_i < numberOfButtons; button_i++) {
        int nextButtonIndex;
        cin >> nextButtonIndex;
        nextButtonIndex--;
        buttons.at(button_i) = nextButtonIndex;
    }
    
    int currentButtonIndex = 0;
    for (int count = 0;; count++) {
        if (currentButtonIndex == 1) {  
            cout << count << endl;
            break;
        }

        if (count >= numberOfButtons) {
            cout << -1 << endl;
            break;
        }
        
        currentButtonIndex = buttons.at(currentButtonIndex);
    }
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll big = 10e12 + 11 ;

int  main (  ) {

    FASTIO ;

    string  s ;
    cin >> s ;

    if( s[ 2 ] == s[ 3 ] && s[ 4 ] == s[ 5 ] )cout << "Yes" ;
    else  cout << "No" ;


    return  0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    vi D(N); rep(i,N) cin >> D[i];
    rep(i,N) if(D[i]==0){
        cout << 0 << endl;
        return 0;
    }

    vi cnt(13,0);
    rep(i,N) cnt[D[i]]++;
    for(int i=0;i<=12;i++) if(cnt[i]>=3){
        cout << 0 << endl;
        return 0;
    }

    vector<bool> t(25,false);
    t[0] = true;
    vi D2;
    for(int i=0;i<=12;i++){
        if(cnt[i]==2){
            t[i] = t[24-i] = true;
        }else if(cnt[i]==1){
            D2.push_back(i);
        }
    }

    int M = D2.size();
    int ans = -1;
    for(int mask=0;mask<(1<<M);mask++){
        auto tmp(t);
        for(int i=0;i<M;i++){
            int ti;
            if(1 & (mask>>i)){
                ti = D2[i];
            }else{
                ti = 24 - D2[i];
            }
            tmp[ti]=true;
        }
        int min = 1000;
        rep(i,25) rep(j,25) if(i<j and tmp[i] and tmp[j]){
            min = std::min(min,std::min(j-i,24-(j-i)));
        }
        ans = max(ans,min);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vvi vector<vector<int>>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define INF 0x7FFFFFFF
    #define ALL(v) v.begin(), v.end()  //sort(ALL(v)) 昇順ソート sort(ALL(v),greater<int>())
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
    using namespace std;
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
     
    int main(){
      ios_base::sync_with_stdio(false);cin.tie(NULL);
      ll N,K,cost;
      cin >> N >> K;
      vector<ll> A(N);vector<ll> F(N);
      
      REP(i,N) cin >> A[i];
      REP(i,N) cin >> F[i];
      
      sort(ALL(A));
      sort(ALL(F),greater<ll>());
      
      ll l = 0, r = A[N-1] * F[0], m;
      
      while(l != r){
        m = (l+r)/2;
        cost = 0;
        REP(i,N){
          if(A[i] * F[i] > m) cost += A[i] - m / F[i];
        }
        if(cost <= K) r = m;
        else l = m+1;
      }
      cout << l;
      return 0;
    }

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n, m;
char c[55][55];
int dis[55][55];
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i) scanf("%s", c[i]);
	memset(dis, -1, sizeof dis);
	queue <pair <int, int> > q;
	dis[0][0] = 0;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		pair <int, int> p = q.front(); q.pop();
		int x = p.first, y = p.second;
		for (int i = 0; i < 4; ++ i) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 || ny < 0 || nx >= n || ny >= m) continue;
			if (c[nx][ny] == '#') continue;
			if (~dis[nx][ny]) continue;
			dis[nx][ny] = dis[x][y] + 1;
			q.push(make_pair(nx, ny));
		}
	}
	if (!~dis[n - 1][m - 1]) {
		puts("-1");
		return 0;
	}
	int cnt = 0;
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < m; ++ j) {
			cnt += c[i][j] == '.';
		}
	}
	printf("%d\n", cnt - dis[n - 1][m - 1] - 1);
	return 0;
}

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

using namespace std;

int main (void) {
    int N, M;
    cin >> N >> M;

    /* 県ごとの市のマップ */
    map<int, vector<pair<int, int>>> city_map;
    int p, y;
    for ( int i=0; i<M; i++ ) {
        cin >> p >> y;
        city_map[p].push_back(make_pair(y, i));
    }

    /* 元 index 順に <県 No., 市の順番> を格納する */
    vector<pair<int, int>> ans(M);

    int pref, original_idx;
    vector<pair<int, int>> cities;
    /* 県をすべて巡回する */
    for ( pair<int, vector<pair<int, int>>> itr : city_map ) {
        pref = itr.first;
        cities = itr.second;
        /* 市を年順に並び替える */
        sort(cities.begin(), cities.end());
        /* 各県の市を年順に巡回する */
        for ( int i=0; i<(int)cities.size(); i++ ) {
            original_idx = cities.at(i).second;
            ans[original_idx] = make_pair(pref, i + 1);
        }
    }

    for ( int i=0; i<M; i++ )
        printf("%06d%06d\n", ans.at(i).first, ans.at(i).second);

    return 0;
}


Measured memory_bytes: 13184
N = int(input())

A = [int(i) for i in input().split()]

ans = 1

if min(A) == 0:
    ans = 0
else:
    for i in range(N):
        ans = ans * A[i]
        if (ans > 10 ** 18):
            ans = -1
            break

print(ans)

Measured memory_bytes: 21480
s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
tmp = [0]*26
for i in range(len(s)):
  if tmp[al.index(s[i])] == 0:
    tmp[al.index(s[i])] = 1
  else:
    tmp[al.index(s[i])] = 0
if 1 in tmp:
  print('No')
else:
  print('Yes')

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

int main(){
	char s[6];
	int i;
	for(i=0; i<6; i++){
		cin >> s[i];
	}
	
	if(s[2]==s[3] && s[4]==s[5])	cout << "Yes" << endl;
	else				cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

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

using namespace std;

int main()
{
	int n,m;
	double g[100][100];
	double dp[100][100];

	while(cin >> n >> m)
	{
		if(n == 0 && m == 0) break;
	
		memset(g,0,sizeof(g));
		memset(dp,0,sizeof(dp));
		
		rep(i,n)
		{
			rep(j,n)
			{
				cin >> g[i][j];
			}
		}

		rep(i,m) rep(j,n) dp[i][j] = 0;

		rep(i,n) dp[0][i] = 1;

		REP(i,1,m)
		{
			rep(j,n)
			{
				rep(k,n)
				{
					dp[i][j] = max(dp[i][j],dp[i-1][k]*g[k][j]);
				}
			}
		}

		double ans = 0;
		rep(i,n)
		{
			ans = max(ans,dp[m-1][i]);
		}

		cout << fixed;
		cout.precision(2);
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1452
n = gets.to_i
arr = Array.new
while line = $stdin.gets
arr.push(line.to_i)
end
if arr[0]>arr[1] then
  max1 = 0
  max2 = 1
else
  max1 = 1
  max2 = 0
end

(n-2).times{|t|
  if arr[t+2] > arr[max2] and arr[t+2] > arr[max1]then
    max2 = max1
    max1 = t+2
  elsif arr[t+2] > arr[max2] then
    max2 = t+2
  end
}
n.times{|t|
  if t == max1 then
    puts arr[max2]
  else
    puts arr[max1]
  end
}

Measured memory_bytes: 4988
#include <stdio.h>
int main()
{
	long long a,b;
	char c;
		scanf("%lld",&a);
		scanf(" %c ",&c);
		scanf("%lld",&b);
		if(c=='-')
		{
			printf("%lld\n",a-b);
		}
		else
		{
			printf("%lld\n",a+b);
		}
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b;
    cin >> a >> b;

    if ( a + b == 15){
        cout << "+" << endl;
    }
    else if (a * b == 15){
        cout << "*" << endl;
    }
    else {
        cout << "x" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
typedef pair <lli,lli> pll;
 
 
lli countGreater(lli arr[], lli n, lli k) 
{ 
    lli l = 0; 
    lli r = n - 1; 
  
    lli leftGreater = n; 
  
    while (l <= r) { 
        lli m = l + (r - l) / 2; 
  

        if (arr[m] > k) { 
            leftGreater = m; 
            r = m - 1; 
        } 

        else
            l = m + 1; 
    } 
  
    return (n - leftGreater); 
}
 
bool is_palin(string input)
{
    if (input == string(input.rbegin(), input.rend())) 
        return true;
    return false;
}
void solve()
{
    lli x,y,a1,b1,c1;
    cin>>x>>y>>a1>>b1>>c1;
    lli a[a1];
    forz(i,a1) cin>>a[i];
    lli b[b1];
    forz(i,b1) cin>>b[i];
    lli c[c1];
    forz(i,c1) cin>>c[i];
    sort(a,a+a1);
    sort(b,b+b1);
    sort(c,c+c1);
    reverse(a,a+a1);
    reverse(b,b+b1);
    reverse(c,c+c1);
    vector<lli> v;
    forz(i,x)
    v.pb(a[i]);
    forz(i,y)
    v.pb(b[i]);
    forz(i,c1)
    v.pb(c[i]);
    sort(v.be,v.en);
    reverse(v.be,v.en);
    lli sum =0;
    forz(i,x+y)
    {
        sum+=v[i];
    }
    cout<<sum;
}
 
int main()
{
    kira; 
 
    lli t=1; //cin>>t;
    while(t--)
    {
        solve();
    }
    
    return 0;
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		
		System.out.println(Math.max(A+B,Math.max(A-B,A*B)));

	}

}

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

const int N = 30;

char s[N];
int cnt[N];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	if (n < 26){
		for (int i = 0; i < n; ++ i){
			++ cnt[s[i] - 'a'];
		}
		for (int i = 0; i < 26; ++ i){
			if (!cnt[i]){
				printf("%s%c", s, i + 'a');
				return 0;
			}
		}
	}
	for (int i = 25; i; -- i){
		if (s[i] > s[i - 1]){
			int min = INT_MAX;
			for (int j = i; j < 26; ++ j){
				if (s[j] > s[i - 1]){
					min = std::min(min, (int) s[j]);
				}
			}
			for (int j = 0; j < i - 1; ++ j){
				putchar(s[j]);
			}
			putchar(min);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);

        //var ans = new int[m][];
        var clear = new int[n];
        var waco = new int[n];

        var cAC = 0;
        var cWA = 0;
        
        for(int i=0; i<m; i++) {
            spl   = input.ReadLine().Split(' ');
            //ans[i] = new int[2];
            //ans[i][0] = int.Parse(spl[0]);
            //ans[i][0] = spl[1] == "AC" ? 1 : 0;
            var p = int.Parse(spl[0])-1;
            var s = spl[1];

            if(s == "AC") {
                if (clear[p] == 0) {
                    clear[p] = 1;
                    cAC++;
                    cWA += waco[p];
                }
            } else { //WA
                if(clear[p] == 0) {
                    waco[p]++;
                }
            }
        }

        return cAC + " " + cWA;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n)cin >> h[i];
    vector<int> dp(n, 1001001001);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i+j >= n)continue;
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 3952
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 
const int MAXN = 1e6 + 10;
const int MOD = 10000000;
const int inf = 0x3f3f3f3f;

int c;

int main(){
	char s[3];
	cin.getline(s,3);
	if(s[1]=='B')cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 100005
#define ll long long

#define DEBUG
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << "  "
#else
#define debug(x) ;
#endif
string s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    int  f = 0;
    if(s.length()==6){
        if(s[2]==s[3]&&s[4]==s[5])
            f = 1;
    }
    cout<<(f?"Yes\n":"No\n");
    
    
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
v = []
for i in range(n):
    v.append(list(map(int,input().split(" "))))
for i in range(1,n):
    e = sorted(v[i-1][:])
    m1 = e[2]
    m2 = e[1]
    for j in range(3):
        if m1 == v[i-1][j]:
            v[i][j] += m2
        else: v[i][j] += m1
print(max(v[n-1]))
    
    

Measured memory_bytes: 32424
import itertools

n = list(i for i in range(1, int(input()) + 1))
s1 = tuple(map(int, input().split()))
s2 = tuple(map(int, input().split()))
a, b = 0, 0
perm = list(itertools.permutations(n))
for i, v in enumerate(perm, start=1):
    if v == s1:
        a += i
    if v == s2:
        b = i

print(abs(a - b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, answer;
  cin >> n;
  answer = 0;
  vector<int> A(n);
  vector<int> B(n - 1);
  for (int i = 0; i < n - 1; i++)
    cin >> B.at(i);//入力完了
  A.at(0) = B.at(0);//A1はB1
  for (int i = 0; i < n - 2; i++){
  A.at(i + 1) = min(B.at(i), B.at(i + 1));
  }
  A.at(n - 1) = B.at(n - 2);
  for ( int i = 0; i < n; i++)
    answer += A.at(i);
	cout << answer << endl;  
}



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

using namespace std;
using ll = long long;

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

int q[200];
vector<vector<int>> ar;

int calc(int start) {
	int beg = 0;
	int end = 1;
	q[0] = start;
	int mark[200] = {};
	mark[start] = 1;
	while (beg < end) {
		int cur = q[beg++];
		for (int to: ar[cur]) {
			if (mark[to]) {
				if (abs(mark[to] - mark[cur]) != 1) {
					return -1;
				}
				continue;
			}
			q[end++] = to;
			mark[to] = mark[cur] + 1;
		}
	}
	return mark[q[end - 1]];
}

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ar.resize(n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = i + 1; j < n; ++j) {
			if (s[j] == '1') {
				ar[i].push_back(j);
				ar[j].push_back(i);
			}
		}
	}
	int ans = -1;
	for (int i = 0; i < n; ++i) {
		ans = max(ans, calc(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

int gcd(int m, int n) {
	return n == 0 ? m : gcd(n, m % n);
}
signed main() {
	int n = in(), x = in();
	vector<int>c(n);
	REP(i, n) {
		scanf("%d", &c[i]);
		c[i] = abs(c[i] - x);
	}
	int ans = c[0];
	REP(i, n) {
		ans = gcd(ans, c[i]);
	}
	cout << ans << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,k;
    int h[100003];
    Scd2(n,k);
    Rep(i,n) Scd(h[i]);
    sort(h,h+n);

    int ans = INF;
    k--;
    Repe(i,n,k){
        ans = min( ans , h[i] - h[i-k] );
    }

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

    return 0;
}



Measured memory_bytes: 640
temp = list(map(int,input().split()))
K = temp[0]
S = temp[1]
newK = K+1
cnt = 0
minlim = S-K
maxlim = S
for x in range(0, newK):
    for y in range(0, newK):
        if minlim <= x+y and x+y <= maxlim:
            cnt += 1
print(str(cnt))

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static Dictionary<int, int> dic;

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var dic = new Dictionary<int, int>();
        Action<int, int> Add = (key, value) => {
            if (dic.ContainsKey(key)) dic[key] += value;
            else dic[key] = 1;
        };
        Func<int, int> Get = (key) => {
            if (dic.ContainsKey(key)) return dic[key];
            else return 0;
        };

        foreach(var a in ary) {
            Add(a, 1);
        }

        for(int i= n-1; i >= 1; i-=2) {
            if(Get(i) == 2) {
            } else {
                return 0;
            }
        }

        if(n % 2 == 1) {
            if(Get(0) == 0) return 0;
        }

        return ModPow(2, n/2);
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % Mod;
            }
            x1 = (x1 * x1) % Mod;
            x2 /= 2;
        }
        return ans % Mod;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 21728
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
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;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 

int main(){
  int a[3];
  rep(i, 3)
    cin >> a[i];
  sort(a, a+3);
  int ans = 2*a[2] - a[1] - a[0];
  if(ans%2==1)
    ans += 3;
  cout << ans/2 << endl;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long> A(N);

    int minus_num = 0;
    long min_abs_value = 10000000009;
    for(int i = 0; i < N; i++){
	long v;
	cin >> v;
	A.at(i) = v;
	if(v < 0){
	    minus_num++;
	}
	min_abs_value = min(min_abs_value, abs(v));
    }

    long ans = 0;
    for(int i = 0; i < N; i++){
	ans += abs(A.at(i));
    }

    if(minus_num % 2 == 1){
	ans -= min_abs_value*2;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 1024
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = []

for i in range(1, 2**10):
    C = [0] * N
    for j in range(10):
        if (i >> j) & 1 == 1:
            for k, f in enumerate(F):
                if f[j] == 1:
                    C[k] += 1
    pro = 0
    for c, p in zip(C, P):
        pro += p[c]
    ans.append(pro)

print(max(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	double r;
	cin >> r;
	printf("%.15f\n", r*2*pi);

	please AC;
}
//参考：---;


Measured memory_bytes: 3788
#include<vector>
#include"algorithm"
#include"iostream"
//#define l long long int 
typedef long long int l;
using namespace std;
//column name to number

//number to column name
int main()
{
    vector<int> v;
    l n;
    cin>>n;
    while(n>0)
    {
        if(n%26==0) v.push_back(26); //to avoid 26/26=1(a),infact it should be (26)z
        else v.push_back(n%26);
        if(n%26==0) {n/=26; --n;} //same as above
        else n/=26;
    }
    reverse(v.begin(),v.end());
    for(auto &it : v)
        cout<<(char)(it+96);

}


Measured memory_bytes: 3592
#include <stdio.h>
int n, s, c;
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &s);
		printf("Case %d:\n", i + 1);
		for(int j = 0; j < 10; j++) {
			s = s * s / 100 % 10000;
			printf("%d\n", s);
		}
	}
	return 0;
}

Measured memory_bytes: 2604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
 
#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};


int main(){
	int num;
	cin>>num;
	int n=num;
	ll dp[num+1][4];
	memset(dp,0,sizeof(dp));
	dp[0][1]=dp[0][2]=dp[0][3]=0;
	ll i=1;
	ll a,b,c;
	while(num--){
		cin>>a>>b>>c;
		dp[i][1] = max(dp[i-1][2],dp[i-1][3])+a;
		dp[i][2] = max(dp[i-1][1],dp[i-1][3])+b;
		dp[i][3] = max(dp[i-1][1],dp[i-1][2])+c;
		i++;
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll l;
	cin>>l;
	double k = l*1.0;
	double c = k/3.0;
	printf("%.12f\n",c*c*c);
	return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int n,m;
	cin >> n >> m;
	int a[n+1];
	FO(i,1,n+1){
		cin >> a[i];
	}
	int u,v;
	int ok[n+1];
	FE(i,0,n)ok[i] = -1;
	
	FO(i,0,m){
		cin >> u >> v;
		if(a[u] > a[v]){
			ok[v] = 0;
			if(ok[u] != 0)ok[u] = 1;
		}else if(a[u] < a[v]){
			ok[u] = 0;
			if(ok[v] != 0)ok[v] = 1;
		}else{
			ok[u] = 0;
			ok[v] = 0;
		}
	}
	int ans = 0;
	FE(i,1,n){
		//cout << i << " " << ok[i] << endl;
		if(ok[i] == 1 or ok[i] == -1)ans++;
	}
	cout << ans << endl;
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


Measured memory_bytes: 5216
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

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

  vi a(n+1);
  vi b(n);
  ll sum = 0;
  rep(i,n+1){
    cin >> a.at(i);
    sum += a.at(i);
  }
  rep(i,n) cin >> b.at(i);

  rep(i,n){
    a.at(i) = max(a.at(i), 0);
    if (a.at(i) >= b.at(i)) a.at(i) -= b.at(i);
    else {
      a.at(i+1) -= b.at(i) - a.at(i);
      a.at(i) = 0;
    }
  }
  ll res = 0;
  rep(i,n+1){
    a.at(i) = max(a.at(i), 0);
    res += a.at(i);
    //printf("a.at(%d)=%d\n", i, a.at(i));
  }
  //printf("sum: %ld, res:%ld\n", sum, res);

  ll ans = sum - res;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
import math

def rotate(x, y):
  r3 = math.sqrt(3)
  x2 = x / 2 - y * r3 / 2
  y2 = x * r3 / 2 + y / 2
  return x2, y2

def divide(a, b):
  m1 = [(b[0] - a[0]) / 3 + a[0], (b[1] - a[1]) / 3 + a[1]]
  m2 = [(b[0] - a[0]) * 2 / 3 + a[0], (b[1] - a[1]) * 2 / 3 + a[1]]
  r = rotate(m2[0] - m1[0], m2[1] - m1[1])
  m = [m1[0] + r[0], m1[1] + r[1]]
  return (a, m1, m, m2, b)

n = int(input())
arr = ([0, 0], [100, 0])

for i in range(n):
  tmp = []
  for j in range(len(arr) - 1):
    r = divide(arr[j], arr[j + 1])
    if j > 0: r = r[1:]
    tmp += r
  arr = tmp

for a in arr:
  print(" ".join(map(lambda x: str(round(x, 8)), a)))

Measured memory_bytes: 8276
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

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


n = set(S())
if '7' in n:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 76688
#include<stdio.h>
int main()
{
    int a, b, c;
    int count_5=0;
    int count_7 = 0;
    scanf("%d %d %d",&a,&b, &c);
    
    if (a == 5)
    {
        count_5++;
    }
    if (b == 5)
    {
        count_5++;
    }
    if (c == 5)
    {
        count_5++;
    }
    if (a == 7)
    {
        count_7++;
    }
    if (b == 7)
    {
        count_7++;
    }
    if (c == 7)
    {
        count_7++;
    }

    if (count_5 == 2 && count_7 == 1)
    {
        printf("YES\n");    
    }
    else
    {
        printf("NO\n");
    }


    return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	unordered_map<int,int>m;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		++m[a];
	}
	int64_t ans=0;
	for(auto&&i:m){
		if(i.first==i.second)continue;
		if(i.second>i.first)ans+=i.second-i.first;
		else ans+=i.second;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 7272
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int d,t,s;
    cin>>d>>t>>s;

    if(d>t*s) cout<<"No"<<endl;

    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3136
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	LL k;
	cin >> k;
	k++;

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

	int p[40];
	for (int l = 0; l < 40; l += 2) {
		LL m0 = 1LL << l;
		LL m1 = m0 << 1;
		LL c = 0;
		for (int i = 0; i < n; i++) {
			c += ((a[i] & m0) > 0) + ((LL)((a[i] & m1) > 0) << 32);
		}
		*(LL *)(p + l) = c;
	}

	function < LL(LL, int, int) > f = [&](LL t, int h, int b) {
		LL s = 0, s1 = 0;
		for (int l = h - 1; l >= 0; l--) {
			LL m = 1LL << l;
			LL c = p[l];
			if (c < n - c && (t ^ m) < k) {
				if (b)
					s1 = max(s1, f(t, l, 0) + s + (c << l));
				t ^= m;
				s += (n - c) << l;
			}
			else {
				s += c << l;
			}
		}
		return max(s, s1);
	};

	cout << f(0, 40, 1) << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int A, B, K;
  cin >> A >> B >> K;
  
  if(A+B-K<0) cout << 0 << " " << 0;
  else if (A-K>0) cout << A-K << " " << B;
  else cout << 0 << " " << A+B-K;
  
  return 0;
      
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;

const int N = 200005;

int main() {
   string s, t;
   cin >> s >> t;
   sort(s.begin(), s.end());
   sort(t.rbegin(), t.rend());
   if(s < t) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
   return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;


#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	if(n%2)
	{
		cout<<n/2+1<<endl;
	}
	else cout<<n/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
queue<int> tab[1002];
int vis[1002];
int idx=1;
int main(){
	boost;
	int n,a;
	cin>>n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n-1; ++j)
		{
			cin>>a;
			a--;
			tab[i].push(a);
		}
	int comp=(n*(n-1LL))/2LL;
	//debug(comp);
	int ans=0;
	while(comp){
		bool f=0;
		for (int i = 0; i < n; ++i)
		{
			if(vis[i]==idx||tab[i].empty())continue;
			int adv=tab[i].front();
			if(vis[adv]!=idx&&!tab[adv].empty()&&tab[adv].front()==i){
				tab[i].pop();
				tab[adv].pop();
				vis[adv]=vis[i]=idx;
				f=1;
				comp--;
			}
			if(!comp)break;
		}
		if(!f)break;
		ans++,idx++;
	}
	if(!comp)cout<<ans;
	else cout<<-1;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 6784
from array import array
def main():
  s = input()
  t = input()
  slen = len(s)
  tlen = len(t)
  dp = [array('L', [0 for j in range(tlen + 1)]) for i in range(slen + 1)]
  for i in range(slen):
    dpi1 = dp[i + 1]
    for j in range(tlen):
      if s[i] == t[j]:
        dpi1[j + 1] = max(dpi1[j + 1], dp[i][j] + 1, dpi1[j], dp[i][j + 1])
      else:
        dpi1[j + 1] = max(dpi1[j + 1], dpi1[j], dp[i][j + 1])
  result = ''
  i = slen
  j = tlen
  while i > 0 and j > 0:
    if dp[i - 1][j] == dp[i][j]:
      i -= 1
    elif dp[i][j - 1] == dp[i][j]:
      j -= 1
    else:
      result = s[i - 1] + result
      i -= 1
      j -= 1
  print(result)
main()


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

int n,m;
int a[200][200],sum1[300],sum2[300];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;cin>>c;
			a[i][j]= c=='#' ? 1 : 0;
			sum1[i]+=a[i][j];
			sum2[j]+=a[i][j];
		}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(!sum1[i] || !sum2[j])continue;
			printf(a[i][j]==1 ? "#" : ".");
		}
		if(!sum1[i])continue;
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
   ll a=n/k,b=n/(k/2)-n/k;
   ans+=a*a*a;
   if(k%2==0)ans+=b*b*b;
cout<<ans;
}

Measured memory_bytes: 256