akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <random>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#else
    //freopen("sabotage.in", "r", stdin);
    //freopen("sabotage.out", "w", stdout);
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


const int MOD=1e9+7,N=1e5+100,oo=1e12+10,A=26,M=(1<<14);


void smain() {

    int n,m;
    cin>>n>>m;
    int ans=1900*m+(n-m)*100;
    for(int i=0;i<m;i++){
        ans*=2;
    }
    cout<<ans;
}



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp92 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (N == 2) {
                Console.WriteLine(X[1]);
                Console.WriteLine(X[0]);
                return;
            }

            var X_sorted = X.OrderBy(x => x).ToArray();

            //まずは、元の数列の中央値を求める
            int median = X_sorted[N / 2];

            int before_median = X_sorted[(N / 2) - 1];

            for (int i = 0; i < N; i++) {
                if (X[i] < median) {
                    Console.WriteLine(median);
                } else {
                    Console.WriteLine(before_median);
                }


            }


        }
    }
}


Measured memory_bytes: 41156
import heapq

N,M = map(int, input().split())
A_lis = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A_lis)

def discount(A_lis):
    popped = heapq.heappop(A_lis)
    heapq.heappush(A_lis,popped/2)
    return A_lis

for i in range(M):
    A_lis = discount(A_lis)
ans = 0
for i in A_lis:
    ans += int(i)
print(ans*(-1))


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

int n,m;
vector<int> a[9];
vector<bool> vis(9,false);
ll ans = 0;

void dfs(int node){
    if(vis[node]){
        return ;
    }
    vis[node]=true;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            break;
        }
        if(i==n){
            ans++;
        }
    }
    for(int i=0;i<a[node].size();i++){
        dfs(a[node][i]);
    }
    vis[node]=false;
}

int main(){

    cin >> n >> m;

    rep(i,m){
        int s,t;
        cin >> s >> t;
        a[s].push_back(t);
        a[t].push_back(s);
    }

    dfs(1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
/*
   created: 2020-8
   @verified:
   部分文字列の判定を高速に動かす
 
   query(l,r)=hash[l,r)
   lcp(rhT,a,b)=Longest Common Prefix of S[a:] and T[b:], O(logN)
 */
struct RollingHash{
    static const int base1=1009,base2=2009;
    static const int MOD1=1e9+7,MOD2=1e9+9;
    vector<long long> hash1,hash2,pow1,pow2;
    RollingHash(const string &s /* ここを変える */){
        int sz=(int)s.size();
        hash1.assign(sz+1,0); hash2.assign(sz+1,0);
        pow1.assign(sz+1,1); pow2.assign(sz+1,1);
        for(int i=0;i<sz;i++){
            hash1[i+1]=(hash1[i]*base1+s[i]) % MOD1;
            hash2[i+1]=(hash2[i]*base2+s[i]) % MOD2;
            pow1[i+1]=(pow1[i]*base1) % MOD1;
            pow2[i+1]=(pow2[i]*base2) % MOD2;
        }
    }
    inline pair<long long,long long> query(int l,int r)const{
        long long ret1=hash1[r]-hash1[l]*pow1[r-l]%MOD1;
        ret1=(ret1+MOD1)%MOD1;
        long long ret2=hash2[r]-hash2[l]*pow2[r-l]%MOD2;
        ret2=(ret2+MOD2)%MOD2;
        return {ret1,ret2};
    }
    inline int lcp(const RollingHash &t,int a,int b)const{
        int len=min((int)hash1.size()-a,(int)hash2.size()-b);
        int ok=-1,ng=len+1;
        while(ng-ok>1){
            int mid=(ng+ok)/2;
            if(query(a,a+mid)==t.query(b,b+mid)) ok=mid;
            else ng=mid;
        }
        return ok;
    }
};

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; string s;
    cin >> n >> s;
    RollingHash rh1(s);
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int ln=rh1.lcp(rh1,i,j);
            chmin(ln,j-i);
            chmax(ans,ln);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
 
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a[5];
    rep(i,5) cin >> a[i];

    int index = 0;
    int min = 9;
    rep(i,5) {
        if (a[i] % 10 <= min && a[i] % 10 != 0) {
            min = a[i] % 10;
            index = i;
        }
    }

    ll sum = 0;
    rep(i,5) {
        if (i != index) {
            int digit1 = a[i] % 10;
            if (digit1 != 0) sum += a[i] + 10 - digit1;
            else sum += a[i];
        } else {
            sum += a[i];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        int total=0;
        int max=0;
        int a[]=new int[150];
        int b[]=new int[150];
        for(int i=0;i<n;i++){
            a[(int)s.charAt(i)]++;
        }
        for(int i=0;i<n;i++){
            a[(int)s.charAt(i)]--;
            b[(int)s.charAt(i)]++;
            for(int k=0;k<150;k++){
                if(a[k]>0 &&b[k]>0) total++;
            }
            if(total>max) max=total;
            total=0;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    // ll a,b,c;
    // string s;
    // cin >> s;
    ll n;
    cin >> n;

    ll dig = 1; //桁数
    ll tmp = n; 
    for (ll i = 0; i < 10; i++){
      if (tmp/10 >0){
        dig++;
        tmp/=10;
      }
    }


  ll ans = 0;


  ans = n;
  if (dig%2==0){
    n = pow(10,dig-1) - 1;
    dig--;
    ans = n;
  }
   cerr << dig <<endl;
  cerr << ans <<endl;
  

    for (ll i = dig; i >0; i--){
      if (i%2==0){
        ans-= ((pow(10,i) -1) - pow(10,i-1) +1 ); 
      }
    }
    

  cout << ans;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int nmax=40,abmax=10,inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(void){
	int n,ma,mb;
	cin >> n >> ma >> mb;
 
	for(int i=0;i<n;++i){
		cin >> a[i] >> b[i] >> c[i];
	}

	for(int i = 0; i <= n; ++i){
		for(int ca = 0; ca <= nmax*abmax; ++ca){
			for(int cb = 0; cb <= nmax*abmax; ++cb){
				dp[i][ca][cb]=inf;
			}
		}
	}
 
	dp[0][0][0]=0;
 
	for(int i = 0; i < n; ++i){
		for(int ca = 0; ca <= nmax*abmax; ++ca){
			for(int cb = 0; cb <= nmax*abmax; ++cb){
				if(dp[i][ca][cb]==inf) continue;
				dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
			}
		}
	}

	int ans=inf;
	for(int ca = 1; ca <= nmax*abmax; ++ca){
		for(int cb = 1; cb <= nmax*abmax; ++cb){
			if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
		}
	} 
	
	if(ans==inf) ans=-1;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 25984
import heapq

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

a = list(map(int,input().split()))

a = [-1*i for i in a]

heapq.heapify(a)

count = 0

while count < m:
    item = heapq.heappop(a)
    item= abs(item)
    discount_item = item//2
    heapq.heappush(a,-1*discount_item)
    count += 1

print(abs(sum(a)))

Measured memory_bytes: 92444
N, K, T, U, V, L = map(int, input().split())
Dlist = []
for i in range(N):
    Dlist.append(int(input()))

t = 0       # 経過時間
v = U       # 速度（初期値はU）
timer = 0
Sto = 0     # 手持ちのにんじん

for i in range(1,L+1):
    t += 1/v
    if v==V:
        timer += 1/v
    if i in Dlist:
        Sto += 1
        if v==U:
            v = V
            Sto -= 1
            timer = 0
        elif timer<T:
            if Sto>K:
                Sto -= 1
                timer = 0
        elif Sto>0:
            Sto -= 1
            timer = 0
        else:
            v = U
    else:
        if v==V:
            if Sto>0 and timer>T-1/V:
                v = V
                timer = 0
                Sto -= 1
            elif Sto==0:
                if timer>T-1/V:
                    v = U
print(f'{t:.9f}')


Measured memory_bytes: 5640
//TLE

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

bool isEnd( vector<int> vec ){
	int finish[30] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3};
	for( int i = 0; i < 30; i++ )
		if( vec[i] != finish[i] )
			return false;
	return true;
}
vector<int> rot( vector<int> vec, int type ){
	switch(type){
	case 0:
		swap(vec[0], vec[23]);
		swap(vec[3], vec[26]);
		swap(vec[6], vec[29]);
		swap(vec[15], vec[17]);
		swap(vec[9], vec[20]);
		break;
	case 1:
		swap(vec[2], vec[21]);
		swap(vec[5], vec[24]);
		swap(vec[8], vec[27]);
		swap(vec[12], vec[14]);
		swap(vec[11], vec[18]);
		break;
	case 2:
		swap(vec[6], vec[21]);
		swap(vec[7], vec[22]);
		swap(vec[8], vec[23]);
		swap(vec[9], vec[11]);
		swap(vec[12], vec[17]);
		break;
	case 3:
		swap(vec[0], vec[27]);
		swap(vec[1], vec[28]);
		swap(vec[2], vec[29]);
		swap(vec[18], vec[20]);
		swap(vec[14], vec[15]);
		break;
	}
	return vec;
}
void disp( vector<int> vec ){
	for( int i = 0; i < 30; i++ )
		cout << vec[i] << " ";
	cout << endl;
}

int dfs( vector<int> vec, int dep ){
	if( isEnd( vec ) )
		return dep;
	if( dep >= 8 )
		return 8;
		
	int ans = 514;
	for( int i = 0; i < 4; i++ ){
		vec = rot( vec, i );
		ans = min( ans, dfs(vec, dep + 1) );
		vec = rot( vec, i );
	}
	return ans;
}

int main()
{
	int n;
	cin >> n;
	for( int i = 0; i < n; i++ ){
		vector<int> vec;
		for( int j = 0; j < 30; j++ ){
			int t;
			cin >> t;
			vec.push_back(t);
		}
		cout << dfs(vec, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const int MAXN = 5 * 1e5+5;


string s1, s2;

int cont[MAXN], ac[MAXN], l, c;
char m[25][25];
int dist[25][25];

int x[] = {1, -1, 0, 0};
int y[] = {0, 0, 1, -1};

int ans = 1;

void bfs(pii a) {
	queue<pii> fila;
	fila.push(a);
	for(int i = 0; i < l; i++)
		for(int j = 0; j < c; j++)
			dist[i][j] = INF;
			
	dist[a.f][a.s] = 0;
	
	while(!fila.empty()) {
		pii atual = fila.front();
		fila.pop();
		
		for(int i = 0; i < 4; i++) {
			int ni = atual.f + x[i], nj = atual.s + y[i];
			if(ni < 0 or ni >= l or nj < 0 or nj >= c or m[ni][nj] == '#') continue;
			if(dist[atual.f][atual.s] + 1 < dist[ni][nj]) {
				dist[ni][nj] = dist[atual.f][atual.s]+1;
				fila.push({ni, nj});
			}
		}
	}
	
	int xd = 0;
	
	for(int i = 0; i < l; i++)
		for(int j = 0; j < c; j++) {
			if(m[i][j] == '#') continue;
			xd = max(xd, dist[i][j]);
		}
	
	ans = max(xd, ans);
	
}

int32_t main() {
	cin >> l >> c;
	
	for(int i = 0; i < l; i++)
		for(int j = 0; j < c; j++)
			cin >> m[i][j];
	
	for(int i = 0; i < l; i++)
		for(int j = 0; j < c; j++) {
			if(m[i][j] != '#') bfs({i, j});
		}
			
	cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
import heapq as hp

H, W = map(int, input().split())
s = np.array([list(input()) for _ in range(H)])
s = np.pad(s, 1, "constant")
visited = np.zeros_like(s, dtype=np.bool)

dist = np.inf

h = []
hp.heappush(h, (0, 1, 1))

while h:
    d, x, y = hp.heappop(h)
    if x == H and y == W:
        dist = d
        break
    for dx, dy in [[0, 1], [1, 0], [-1, 0], [0, -1]]:
        nx = x + dx
        ny = y + dy
        if s[nx, ny] == "." and not visited[nx, ny]:
            visited[nx, ny] = True
            hp.heappush(h, (d + 1, nx, ny))

if dist == np.inf:
    print(-1)
else:
    print((s == ".").sum() - dist - 1)

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;


int main()
{
  int N;
  string s;
  long long res=0;
  cin >> N;

  unordered_map <string, int> map;

  rep(i,N) {
    cin >> s;
    sort(s.begin(),s.end());
    if(map.find(s) != map.end()){
      map[s]++;
    }
    else {
      map[s]=1;
    }
  }
  
  for(auto itr = map.begin(); itr != map.end(); ++itr){
    long long num = itr->second;
    if(num>1) res += num * (num-1)/2;
  }

  cout << res << endl;
}



Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    string a[3] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    if (!s.compare("Sunny"))
        cout << a[1] << '\n';
    else if (!s.compare("Cloudy"))
        cout << a[2] << '\n';
    else
        cout << a[0] << '\n';
    return 0;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var b = [0];
  var ans = 0;
  for(var i = 0; i < n; i++){
    b[i+1] = b[i] + a[i];
  }
  b.sort((a,b)=>a-b);
  var t = b[0], u = 1;
  for(i = 1; i <= n; i++){
    if(t === b[i])u++;
    else{
      ans += u * (u-1) / 2;
      u = 1;
      t = b[i];
    }
  }
  return ans + u * (u-1) / 2;
}

Measured memory_bytes: 62900
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
vector<ll> printDivisors(ll n)
{
	vector<ll> a;

	// Note that this loop runs till square root
	for (ll i = 1; i <= sqrt(n); i++)
	{
		if (n % i == 0)
		{
			// If divisors are equal, print only one
			if (n / i == i)
				// printf("%d ", i);
				a.push_back(i);

			else // Otherwise print both
				// printf("%d %d ", i, n/i);
			{
				a.push_back(i);
				a.push_back(n / i);
			}
		}
	}
	return a;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin >> t;
	while (t--) {
		ll a, b;
		cin >> a >> b;
		vector<ll> adiv, bdiv;
		adiv = printDivisors(a);
		bdiv = printDivisors(b);
		// sort(adiv.begin(), adiv.end());
		// sort(bdiv.begin(), bdiv.end());

		map<int, int> m;
		vector<ll> val;
		for (int i = 0; i < adiv.size(); ++i)
		{
			m[adiv[i]]++;
		}
		for (int i = 0; i < bdiv.size(); ++i)
		{
			// m[bdiv[i]]++;
			if (m[bdiv[i]] > 0)val.push_back(bdiv[i]);
		}

		int nn = val.size();
		vector<int> dp(nn, 1);

		for (int i = 0; i < nn; i++) {
			for (int j = 0; j < nn; j++) {
				if (i != j) {
					if (val[i] % val[j] == 0 && val[j] != 1) {
						dp[i]++;
					}
				}
			}
		}
		int chk = 0;
		for (int i = 0; i < dp.size(); i++) {
			// cout << dp[i] << " ";
			if (dp[i] == 1) {
				chk++;
			}
		}
		// cout << endl;
		cout << chk;
	}
	return 0;
}

Measured memory_bytes: 4080
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main() {
    int h, w;
    cin >> h >> w;
    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            string s;
            cin >> s;
            if(s=="snuke") {
                cout << (char)('A'+j) << i+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
num,max=-1,-1
n.times do
    x,y=gets.chomp.split(nil).map(&:to_i)
    if(max<y)
        max=y
        num=x
    elsif (max==y)&&(x<num)
        num=x
    end
end
puts "#{num} #{max}"

Measured memory_bytes: 6104
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
 
const int MAXN = 2e5+3;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    LL N, a, b;
    cin >> N >> a >> b;
    if((b-a)%2 == 0) {
        cout << (b-a)/2 << endl;
    } else {
        cout << (b-a-1)/2 + 1 + min(a-1,N-b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k){
		cout<<n*x<<endl;
		
	}
	
	else if(n>=k){
		cout<<k*x+(n-k)*y<<endl;
		
	}
	
}

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

int main(){
    int n ;
    long long k;
    cin >> n >> k;
    vector<long long> p(n),c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        p[i] --;
    }    
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    
    long long ans = -pow(10,10);
    for (int i = 0; i < n; i++)
    {
        vector<long long> v(n);
        long long count  = -pow(10,10);
        long long sum = 0;
        int num = i;
        for (int j = 0; j < k; j++)
        {
            sum += c[p[num]];
            num = p[num];
            count = max(count,sum);
            v[j] = count;
            int x = count;

            if(num == i){
                int t = k%(j+1);
                if(sum >= 0){
                    count = sum*(k/(j+1));
                    if(t != 0){
                        count += v[t-1];
                    }
                    int numnum = i;
                    long long countcount = -pow(10,10);
                    long long sumsum = 0;
                    for (int jj = 0; jj < j+t; jj++)
                    {
                        sumsum += c[p[numnum]];
                        numnum = p[numnum];
                        countcount = max(countcount,sumsum);
                    }
                    count = max(count, countcount+ sum*(k/(j+1)-1));
                    
                    
                }
                break;
            }
        }
        ans = max(ans,count);
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
def power(x, n, m)
    n == 0 ? 1 : ((n.odd? ? x : 1) * power(x ** 2 % m, n / 2, m) % m)
end

n, k = gets.split.map(&:to_i)
memo = Array.new(k + 1, 0)
m = 10 ** 9 + 7
ans = 0
k.downto(1) do |i|
    x = k / i
    c = power(x, n, m)
    2.upto(x) {|j| c -= memo[j * i]}
    ans = (ans + (memo[i] = c) * i) % m
end

puts ans

Measured memory_bytes: 15060
#include <cstdio>
#include <algorithm>
using namespace std;

const int C=55440;
int sum[4][24];
int lsum[C],table[4]={13,17,19,23};

int main(){
    int N;
    for(;;){
        scanf("%d",&N);
        if(N==0) break;
        for(int i=0;i<4;i++){
            fill(sum[i],sum[i]+24,0);
        }
        fill(lsum,lsum+C,0);
        for(int i=0;i<N;i++){
            int d,t;
            scanf("%d%d",&d,&t);
            int now[24];
            for(int j=0;j<d;j++){
                scanf("%d",&now[j]);
            }
            rotate(now,now+t,now+d);
            if(find(table,end(table),d)!=end(table)){
                int at=find(table,end(table),d)-table;
                for(int j=0;j<d;j++){
                    sum[at][j]+=now[j];
                }
            }else{
                for(int j=0;j<C/d;j++){
                    for(int k=0;k<d;k++){
                        lsum[j*d+k]+=now[k];
                    }
                }
            }
        }
        int ret=*max_element(lsum,lsum+C);
        for(int j=0;j<4;j++){
            ret+=*max_element(sum[j],sum[j]+table[j]);
        }
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 1248
N = int(input())
day=[[int(i) for i in input().split()] for _ in range(N)]

dp=[[],[],[]]
for i in range(3):
    for j in range(N):
        dp[i].append(0)

dp[0][0]=day[0][0]
dp[1][0]=day[0][1]
dp[2][0]=day[0][2]

for i in range(1,N):
    for j in range(3):
        dp[j][i]=max(dp[(1+j)%3][i-1]+day[i][j],dp[(2+j)%3][i-1]+day[i][j])
print(max(dp[0][-1], dp[1][-1], dp[2][-1]))




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

//setprecision()<<

using namespace std;

bool jdream(string &s,int i,int size,string dream){
    if(i+4>size-1){
        cout<<"NO"<<endl;
        return false;
    }
    for(int j=0;j<5;j++){
        if(s.at(i+j)!=dream.at(j)){
            cout<<"NO"<<endl;
            return false;
        }
    }
    return true;
}

bool jerase(string &s,int i,int size,string erase){
    if(i+4>size-1){
        cout<<"NO"<<endl;
        return false;
    }
    for(int j=0;j<5;j++){
        if(s.at(i+j)!=erase.at(j)){
            cout<<"NO"<<endl;
            return false;
        }
    }
    return true;
}

bool jdreamer(string &s,int i,int size,string dreamer){
    if(i+6>size-1){
        return false;
    }
    for(int j=0;j<7;j++){
        if(s.at(i+j)!=dreamer.at(j)){
            return false;
        }
    }
    return true;
}

bool jeraser(string &s,int i,int size,string eraser){
    if(i+5>size-1){
        return false;
    }
    for(int j=0;j<6;j++){
        if(s.at(i+j)!=eraser.at(j)){
            return false;
        }
    }
    return true;
}

signed main() {
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    string dream="maerd";
    string dreamer="remaerd";
    string eraser="resare";
    string erase="esare";

    int i=0;
    while(i<s.size()){
        if(s.at(i)=='m'){
            if(jdream(s,i,s.size(),dream)){
                i+=5;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
        else if(s.at(i)=='e'){
            if(jerase(s,i,s.size(),erase)){
                i+=5;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
        else if(s.at(i)=='r'){
            if(jdreamer(s,i,s.size(),dreamer)){
                i+=7;
                continue;
            }
            else if(jeraser(s,i,s.size(),eraser)){
                i+=6;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }

    if(i==s.size()){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = n;
	FOR(i,0,n-1){
		if(s[i] != s[i+1]){
			ans = min(ans, max(i+1, n-i-1));
		}
	}
	ANS(ans);
	return 0;
}


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

int main() {
  int N,G = 0; 
  cin >> N;
  int N2 = N;
  for (int i = 0; i < 9; i++){
    G += N % 10;
    N = N / 10;
  }
  if (N2 % G == 0){
    cout << "Yes"<< endl;
  }else{
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 3536
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){

string s;
cin>>s;
sort(s.begin(), s.end());
if (s[0]==s[1] && s[2]==s[3]){
    if (s[0]==s[2]){
        cout<<"No";

    }
    else{
        cout<<"Yes";
    }
}
else{
    cout<<"No";
}



return 0;
}


Measured memory_bytes: 3632
def isPrime(num):
	if num <= 1:
		return False

	elif num == 2 or num == 3:
		return True

	elif num % 2 == 0:
		return False

	else:
		count = 3

		while True:
			if num % count and count ** 2 <= num:
				count += 2
				continue

			elif num % count == 0:
				return False

			else:
				break

		return True


if __name__ == '__main__':
	count = 0
	N = int(input())
	
	for i in range(N):
		i = int(input())

		if isPrime(i):
			count += 1

	print(count)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  
  int sum = 0;
    for(int i = 0; i < N - 1; i++){
      sum += v.at(i);
    }
  if(v.at(N - 1) < sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }

}

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

using namespace std;

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

  int n;
  cin >> n;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    --a;
    ans += a;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] number = new int[100001];
	long sum =0;
	for (int i=0;i<N;i++) {
	    int A = sc.nextInt();
	    sum += A;
	    number[A]++;
	}
	int Q = sc.nextInt();
	StringBuilder sb = new StringBuilder();
	for (int i=0;i<Q;i++) {
	    int B = sc.nextInt();
	    int C = sc.nextInt();
	    sum = sum - number[B]*(B-C);
	    
	    if (i == Q-1) {
		sb.append(sum);
	    } else {
		sb.append(sum + "\r\n");
	    }
	    number[C] += number[B];
	    number[B] = 0;
	}
	System.out.print(sb.toString());
    }
}


Measured memory_bytes: 63620
#include <stdio.h>

int main()
{
   int    hour, minute, second;
   int    inp;

   scanf("%d\n", &inp);

   hour = inp / (60 * 60);
   inp -= hour * 60 * 60;
   minute = inp / 60;
   inp -= minute * 60;
   second = inp;

   printf("%d:%d:%d\n", hour, minute, second);

   return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,k; cin>>n>>k;
    ll res=0;
    while(n>0){
        n/=k; res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  if(n==3 || n==5 || n==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll n,x;
vector<ll> le;
vector<ll> p;
ll f(ll x,ll n){
    if(x==0){
        return 0;
    }else if(n==0){
        return 1;
    }else if(2*x<le[n]){
        return f(x-1,n-1);
    }else{
        return p[n-1]+1+f(x-le[n-1]-2,n-1);
    }
}


int main() {
    cin >> n >> x;
    //vector<ll> le(n+1);
    le.push_back(1);
    Rep(i,n){
        le.push_back(2*le.back()+3);
    }
    p.push_back(1);
    Rep(i,n){
        p.push_back(2*p.back()+1);
    }
    ll res=0;
    res = f(x,n);
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int a[3];

    int max_n=0,max_i;
    for(int i=0;i<3;i++){
        cin>>a[i];
        if(max_n<a[i]){
            max_n=a[i];
            max_i=i;
        }
    }
    int K;
    cin>>K;
    for(int i=0;i<K;i++){
        a[max_i]*=2;
    }

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

    return 0;
}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long i64;
typedef vector<i64> vec;
typedef vector<vec> mat;
i64 MOD;
//A * B
mat mat_mul(const mat& A, const mat& B) {
    mat C(A.size(), vec(B.size()));
    for(size_t i = 0; i < A.size(); ++i)
      for(size_t k = 0; k < B.size(); ++k)
        for(size_t j = 0; j < B[0].size(); ++j)
          C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
    return C;
}
//A ^ n
mat mat_pow(mat A, i64 n, i64 mod) {
    MOD = mod;
    mat B(A.size(), vec(A.size(), 0LL));
    for(size_t i = 0; i < A.size(); ++i) B[i][i] = 1LL;
    while(n > 0) {
        if(n & 1LL) B = mat_mul(B, A);
        A = mat_mul(A, A);
        n >>= 1LL;
    }
    return B;
}

int main() {
    int n, mod, a, b, c, t;
    while(cin >> n >> mod >> a >> b >> c >> t && n) {
        mat B(n, vec(n, 0));
        vec A(n, 0);
        
        for(auto& x : A) cin >> x;
        for(int i : in(n)) {
            if(i > 0)
                B[i][i - 1] = a;
            B[i][i] = b;
            if(i < n - 1)
                B[i][i + 1] = c;
        }
        B = mat_pow(B, t, mod);
        for(int i : in(n)) {
            i64 ans = 0LL;
            for(int j : in(n)) (ans += B[i][j] * A[j]) %= mod;
            cout << ans << (i < n - 1 ? ' ' : '\n');
        }
    }
    return 0;
}

Measured memory_bytes: 3148
N,M = map(int,input().split(' '))
vals = [list(map(int,input().split(' '))) for i in range(N)]

ans = []
for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			d = [i*x+j*y+k*z for x,y,z in vals]
			d.sort(reverse = True)
			ans.append(sum(d[:M]))

print(max(ans))







Measured memory_bytes: 3316
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}
vector<int> g[MAXN];
int used[MAXN];


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), m = readInt();
    for (int i = 1; i <= m; i++) {
    	int u = readInt(), v = readInt();
    	g[u].pb(v);
    	g[v].pb(u);
    }
    deque <int> ans;
    ans.pb(1);
    used[1] = 1;
    while(true) {
    	bool ok = 0;
    	int k = ans[0];
    	for (int i : g[k]) {
			if (!used[i]) {
				ans.push_front(i);
				used[i] = 1;
				ok = 1;
				break;
			}
		}
		if (ok) {
			continue;
		}
		k = ans[ans.size() - 1];
    	for (int i : g[k]) {
			if (!used[i]) {
				ans.pb(i);
				used[i] = 1;
				ok = 1;
				break;
			}
		}
		if (ok) {
			continue;
		}		
		break;
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
    	cout << ans[i] << ' ';
    }
    return 0;
}

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

int main(){
	int k;
	cin >> k;
	if(k%2 == 0) cout << (k/2) * (k/2) << endl;
	else cout << (k/2) * (k - k/2) << endl;

}

Measured memory_bytes: 256
N=int(input())
x=[0]*N
y=[0]*N
h=[0]*N
t=[0]*N
for i in range(N):
  x[i],y[i],h[i]=map(int,input().split())
  t[i]=[x[i],y[i],h[i]]

t.sort(key=lambda x:x[2],reverse=True)

for i in range(101):
  for j in range(101):
    ans=[]
    for k in t:
      d = abs(k[0]-i)+ abs(k[1]-j)
      h_tmp = d + k[2]
      if ans==[]:
        ans.append(k+[d,h_tmp])
      else:
        if d>ans[-1][-1] and k[2]==0:
          pass
        else:
          if h_tmp!=ans[-1][-1]:
            break
    else:
      print(i,j,ans[-1][-1])
      exit()


Measured memory_bytes: 3064
def f(x):
    return pow(x, 5) - pow(x - 1, 5)


x = int(input())

a_mx = 1
while f(a_mx) < x:
    a_mx += 1

a_mn = 0
while f(a_mn) < x:
    a_mn -= 1

b_mx = a_mx - 1
b_mn = a_mn - 1

for a in range(a_mn, a_mx + 1):
    for b in range(b_mn, b_mx + 1):
        if pow(a, 5) - pow(b, 5) == x:
            print(a, b)
            exit()


Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(int n) {
	if (n <= 0) return 1;
	if (n == 1) return 2;
	if (n == 2) return 3;
	if (n == 3) return 5;
	if (n == 4) return 8;
	if (n == 5) return 13;
	if (n == 6) return 21;
	return 1;
}

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	const int mod = 1e9 + 7;
	vector<long long int> v1(w + 1, 0), v2;
	v1[1] = 1;
	for (int i = 1; i <= h; i++) {
		v2 = vector<long long int>(w + 1, 0);
		for (int j = 1; j <= w; j++) {
			if (v1[j] == 0) continue;
			if (j > 1) {
				v2[j - 1] += v1[j] * f(j - 3) % mod * f(w - j - 1) % mod;
				v2[j - 1] %= mod;
			}
			if (j < w) {
				v2[j + 1] += v1[j] * f(j - 2) % mod * f(w - j - 2) % mod;
				v2[j + 1] %= mod;
			}
			v2[j] += v1[j] * f(j - 2) % mod * f(w - j - 1) % mod;
			v2[j] %= mod;
		}
		v1 = v2;
	}
	cout << v1[k] << endl;
}


Measured memory_bytes: 3640
A, B, M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())
x, y, c = [], [], []
for _ in range(M):
    xa, ya, ca = map(int, input().split())
    x += [xa]; y += [ya]; c += [ca]
mi = min(a[x[i]-1] + b[y[i]-1] - c[i] for i in range(M))
print(min(mi, min(a)+min(b)))

Measured memory_bytes: 25004
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(n,vector<int>(m));
  rep(i,n)rep(j,m) cin>>vec[i][j], vec[i][j]--;

  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  if(m==1){
    cout << n << endl;
    return 0;
  }

  vector<bool> used(m,false);
  vector<vector<int>> keep(m);
  vector<int> p(n,0);
  rep(i,n) keep[vec[i][0]].pb(i);
  set<pair<int,int>> nums;
  rep(i,m) if(keep[i].size()>0) nums.insert(mp(keep[i].size(), i));

  int ans = n;
  while( true ){
    pair<int,int> pr = *(--end(nums));
    ans = min(ans, pr.fi);
    nums.erase(pr);
    used[pr.se] = true;
    for(auto i : keep[pr.se]){
      while(p[i] < m && used[vec[i][p[i]]]) p[i]++;
      if(p[i]==m){
        cout << ans << endl;
        return 0;
      }
      int x = vec[i][p[i]];
      nums.insert(mp(keep[x].size()+1, x));
      if(keep[x].size()>0){
        nums.erase(mp(keep[x].size(), x));
      }
      keep[x].pb(i);
    }
  }

  assert(false);

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
template <typename T, class F = function<T(const T&, const T&)>>
struct SparseTable {
	int n;
	vector<vector<T>> mat;
	F func;
	SparseTable(const vector<T>& a, const F& f) : func(f) {
		n = a.size();
		int maxLog = 32 - __builtin_clz(n);
		mat.resize(maxLog);
		mat[0] = a;
		for (int j = 1; j < maxLog; ++j) {
			mat[j].resize(n - (1 << j) + 1);
			for (int i = 0; i <= n - (1 << j); ++i) {
				mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
			}
		}
	}
	T query(int from, int to) const {
		assert(0 <= from && from <= to && to <= n - 1);
		int lg = 31 - __builtin_clz(to - from + 1);
		return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
	}
};
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> A(n), fr(n), ba(n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	auto f = [&](vector<int>& amt) {
		SparseTable<int> st(A, [&](int i, int j) { return min(i, j); });
		for (int i = n - 1; i >= 0; --i) {
			amt[i] = (i == n - 1 || A[i] > A[i + 1]) ? 1 : amt[i + 1] + 1;
		}
		for (int i = 0; i + k - 1 < n; ++i) {
			int lo = 0, hi = min(amt[i], k);
			while (lo < hi) {
				int m = (lo + hi + 1) / 2;
				int mnRest = m == k ? INT_MAX : st.query(i + m, i + k - 1);
				if (A[i + m - 1] > mnRest) hi = m - 1;
				else lo = m;
			}
			amt[i] = lo;
		}
	};
	f(fr);
	reverse(A.begin(), A.end());
	for (int& x : A) x = -x;
	f(ba);
	set<pair<int, int>> S;
	for (int i = 0; i < n; ++i) {
		int j = i + k - 1;
		if (j >= n) break;
		if (fr[i] == k) S.insert({-1, -1});
		else {
			assert(fr[i] + ba[n - 1 - j] < k);
			S.insert({i + fr[i], j - ba[n - 1 - j]});
		}
	}
	printf("%d\n", S.size());
}

Measured memory_bytes: 18844
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
  int S;
  char c[100001];
  long long int mod[14];
  long long int next_mod[14];

  scanf("%s", c);
  S = strlen(c);
  for (int i=0; i<=13; i++) mod[i] = 0;

  mod[0] = 1;
  for (int i=0; i<S; i++) {
    for(int j=0; j<=13; j++) next_mod[j] = 0;
    for (int j=0; j<=9; j++) {
      if(c[i] == '?' || c[i] == j + '0') {
        for (int k=0; k<=13; k++) {
          int num;
          num = k * 10 + j;
          next_mod[num % 13] += mod[k];
          next_mod[num % 13] %= 1000000007;
        }
      }
    }
    for(int j=0; j<=13; j++) mod[j] = next_mod[j];
  }

  cout << mod[5] << endl;
}

Measured memory_bytes: 512