akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
                ans += gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans;


    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


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

int main(){
    int N, K;  cin >> N >> K;
    vector<priority_queue<ll>> sushi(N);
    for(int i=0; i<N; i++){
        ll t, d;  cin >> t >> d;
        sushi[t-1].push(d);
    }

    priority_queue<ll> delicious;
    priority_queue<ll> other;
    for(int i=0; i<N; i++){
        if(!sushi[i].empty()){
            delicious.push(sushi[i].top());
            sushi[i].pop();
            while(!sushi[i].empty()){
                other.push(sushi[i].top());
                sushi[i].pop();
            }
        }
    }

    vector<ll> dsum;
    dsum.push_back(delicious.top());
    delicious.pop();
    while(!delicious.empty()){
        dsum.push_back(dsum.back() + delicious.top());
        delicious.pop();
    }

    vector<ll> osum;
    if(!other.empty()){
        osum.push_back(other.top());
        other.pop();
    }
    while(!other.empty()){
        osum.push_back(osum.back() + other.top());
        other.pop();
    }

    ll ans = 0;
    for(ll x=1; x<=K; x++){
        if(x > dsum.size()) break;
        if(K-x > osum.size()) continue;

        if(x<K) ans = max(ans, dsum[x-1] + osum[K-x-1] + x*x);
        else ans = max(ans, dsum[x-1] + x*x);
    }
    cout << ans << endl;
}


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

typedef pair<int,int> P;
const int INF = 1<<30;

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


int main(){
    int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    int n;cin >> n;
    set<P> st;
    for (int i = 0; i < n; i++) {
        int x,y;
        cin >> x >> y;
        st.insert({y,x});
    }
    int lx,ly;cin >> lx >> ly;
    deque<pair<pair<int,P>,P>> q;
    bool dp[202][202][6][2];
    memset(dp,false,sizeof(dp));
    q.push_back({{0,{0,0}},{sy,sx}});
    while(!q.empty()){
        int t = q.front().first.first;
        int d = q.front().first.second.second;
        int f = q.front().first.second.first;
        int u = q.front().second.second;
        int v = q.front().second.first;
        q.pop_front();
        if(v==gy&&u==gx){
            cout << d << endl;
            return 0;
        }
        if(dp[v+100][u+100][t][f]) continue;
        dp[v+100][u+100][t][f]=true;
        int s=abs(u)*abs(v)*t%6;
        for (int i = 0; i < 6; i++) {
            int nx = u + dx[(u+1000)%2][i];
            int ny = v + dy[(u+1000)%2][i];
            if(-lx<=nx&&nx<=lx&&-ly<=ny&&ny<=ly){
                if(st.find({ny,nx})==st.end()){
                    if(s==i) q.push_front({{(t+1)%6,{f,d}},{ny,nx}});
                    else q.push_back({{(t+1)%6,{f,d+1}},{ny,nx}});
                }
            }
        }
        if(!f) q.push_back({{(t+1)%6,{1,d+1}},{v,u}});
    }
    cout << "-1" << endl;
    return 0;
}



Measured memory_bytes: 5108
#include <stdlib.h>
#include <stdio.h>

int INFTY = 1000000000;
int counter;

void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    for(int i=0; i<n1; i++){
        L[i] = A[left + i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    int i = 0;
    int j = 0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i = i + 1;
            counter = counter + 1;
        }
        else{
            A[k] = R[j];
            j = j + 1;
            counter = counter + 1;
        }
    }
}

void mergeSort(int A[], int left, int right){
    if(left+1 < right){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(int argc, char** argv) {
    int N = 0;
    scanf("%d",&N);
    int arr[N];
    for(int i=0; i<N; i++){
        scanf("%d", &arr[i]);
    }

    mergeSort(arr, 0, N);

    for(int k=0; k<N-1; k++){
        printf("%d ",arr[k]);
    }
    printf("%d\n", arr[N-1]);
    printf("%d\n", counter);
    return 0;
}



Measured memory_bytes: 5608
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int l = a + k - 1;
	int r = b - k + 1;

	if (l >= r) {
		for (int i = a; i < b+1; i++) {
			cout << i << endl;
		}

		return 0;
	}

	for (int i = a; i < l+1; i++) {
		cout << i << endl;
	}

	for (int i = r; i < b+1; i++) {
		cout << i << endl;
	}


	return 0;
}

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

int main()
{
    cin >> K;
    int x = 7 % K;
    set<int> s;
    int i = 1;
    while (s.count(x) == 0)
    {
        if (x == 0)
        {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % K;
        ++i;
    }
    cout << -1 << endl;
}


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

int main(){
  int num, h, m, s;

  cin >> num;

  h=num/3600;
  m=(num%3600)/60;
  s=(num%3600)%60;

  cout << h << ":" << m << ":" << s << endl;
  
  return 0;
}

Measured memory_bytes: 3068
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }


vector<int> par, siz;

int find(int x) {
	return x == par[x] ? x : par[x] = find(par[x]);
}

bool same(int x, int y) {
	return find(x) == find(y);
}

void unify(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) return;
	if (siz[x] < siz[y]) {
		siz[y] += siz[x];
		par[x] = y;
	}
	else {
		siz[x] += siz[y];
		par[y] = x;
	}
}

int fsz(int x) {
	return siz[find(x)];
}

void solve(int tcn) {
	int n, m;
	cin >> n >> m;
	par = vector<int>(n);
	siz = vector<int>(n);
	F0R(i, n) {
		par[i] = i;
		siz[i] = 1;
	}
	F0R(i, m) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		unify(u, v);
	}
	set<int> seen;
	vector<int> sizes;
	F0R(i, n) {
		int x = find(i);
		if (seen.find(x) != seen.end()) {
			continue;
		}
		else {
			sizes.pb(fsz(x));
		}
		seen.insert(x);
	}
	sort(all(sizes));
	int ans = sizes[sz(sizes) - 1];
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 15004
import java.util.Arrays;
import java.util.Scanner;
 
class Main{
	
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
 
        //一行目をインプット
        int n = scan.nextInt();
        int[] S = new int[n];
        for (int i=0; i<n; i++) {
            S[i] = scan.nextInt();
        }
 
        //二行目をインプット
        int q = scan.nextInt();
        int[] T = new int[q];
        for (int i=0; i<q; i++) {
            T[i] = scan.nextInt();
        }
         
        Arrays.sort(S);
        Arrays.sort(T);
        int count =0;
        if(n < q){
        	
        	for(int i = 0; i < n;i++){
        		for(int j = 0;j < q;j++){
        			if(S[i] == T[j]){
        				count++;
        				break;
        			}
        		}
        	}
        }
        
        if(q < n){
        	for(int i = 0; i < q;i++){
        		for(int j = 0;j < n;j++){
        			if(S[j] == T[i]){
        				count++;
        				break;
        			}
        		}
        	}
        }
        
        /*
        
        int count = 0;
        for (int i=0; i<q; i++) {
            if(Arrays.binarySearch(S,T[i]) >= 0)
                count++;
        }
        */
 
        System.out.println(count);
    }
}



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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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() {
  string s;
  cin >> s;
  rep(i, s.length()) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
/*

*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;

template<class Monoid>
struct SWAG{
    //情報
    const vector<Monoid> &v;
    //function
    const function<Monoid(Monoid,Monoid)> &op;
    //単位元
    Monoid unit;
    //SWAG    
    Monoid front;
    stack<Monoid> back;
    //尺取りに使う
    int l,r;
    int sz;

    SWAG(vector<Monoid> &v,function<Monoid(Monoid,Monoid)> op,Monoid unit) 
            :v(v),op(op),unit(unit),front(unit),l(0),r(0),sz(v.size()){};

    //右に進んだ場合の値
    inline Monoid isR(){
        if(back.empty()){
            return op(front,v[r]);
        } 
        return op(op(front,v[r]),back.top());
    }
    inline Monoid value(){
        if(back.empty()){
            return front;
        } 
        return op(front,back.top());
    }
    inline Monoid Right(){
        front=op(front,v[r++]);
        if(back.empty()) return front;
        return op(back.top(),front);
    }

    inline Monoid Left(){
        if(back.empty()){
            Monoid tmp=unit;
            for(int u=r-1;u>l;u--){
                back.emplace(tmp=op(tmp,v[u]));
            }
            front=unit;
        }else back.pop();
        l++;
        if(back.empty()) return front;
        return op(back.top(),front);
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(20);
    int N,S;
    cin>>N>>S;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    auto op=[](int a,int b){
        return a+b;
    };
    int l=0,r=0;
    SWAG<int> swag(a,op,0);
    int ret=N+10;
    while(l<N){
        while(r<N && swag.isR()<S){
            swag.Right();
            r++;
        }
        if(r<N) ret=min(ret,r-l+1);
        if(r==l) swag.Right(),r++;
        swag.Left(),l++;
    }
    if(ret==N+10) cout<<0<<endl;
    else cout<<ret<<endl;
      

}

//DSL3C
/*signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(20);
    int N,Q;
    cin>>N>>Q;
    vector<ll> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    auto op=[](ll a,ll b){
        return a+b;
    };
    while(Q--){
        ll x;
        cin>>x;
        int l=0,r=0;
        SWAG<ll> swag(a,op,0);
        ll ret=;
        while(l<N){
            while(r<N && swag.isR()<=x){
                swag.Right();
                r++;
            }
            ret+=r-l;
            if(r==l) swag.Right(),r++;
            swag.Left(),l++;
        }
        cout<<ret<<endl;
    }    
}*/


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

int main() {
    long long N;
    cin >> N;
    vector <long long> P(N);
    long long ans=0;
    long long m=1000000;
    for (long long i=0; i<N; i++) {
        long long tmp;
        cin >> tmp;
        if (m>tmp) {
            ans++;
        }
        m = min(m, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define ll long long int
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define outi(a) printf("%lld\n",(a))
#define ind(a) scanf("%lf", (a))
using namespace std;

int read()
{
  char c = getchar_unlocked();
  while(c < '0' || c > '9')
  c = getchar();
  int sum = 0;
  while(c >= '0' && c <= '9')
  sum = sum*10 + c - '0', c = getchar_unlocked();
  return sum;
}

int main()
{
 //reopen("input.txt", "r", stdin);
  string str1, str2;
  cin >> str1 >> str2;
  str1 += str1;
  int c = str2.size();
  rep(i, str1.size())
  if(str1.substr(i, c) == str2)
  {
    cout << "Yes" << endl;
    goto hell;
  }
  cout << "No" << endl;
hell:;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first 
#define s second 
#define int long long
#define pb push_back
#define mp make_pair
const int Max = 1000000000000000000LL;
int32_t main(){
     int n;
     cin>>n;
     int arr[n];
     for(int i = 0 ; i < n ;i++)cin>>arr[i];
     sort(arr , arr+n);
     int val = 1;
     for(int i = 0 ; i < n ;i++){
             if(arr[i] == 0){
                 cout<<"0"<<endl;
                 return 0;
             }
            if(arr[i] > Max/val){
                   cout<<"-1"<<endl;
                   return 0;
            }
            val = val*arr[i];
     }
     cout<<val<<endl;
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=505;
int p[250005],n;
int d[250005];
int dst[Maxn][Maxn];
int o[Maxn][Maxn];
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n*n;i++){
		scanf("%d",&p[i]);
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			dst[i][j]=min(min(i-1,j-1),min(n-i,n-j));
			o[i][j]=1;
		}
	}
	int ans=0;
	queue<pair<int,int> > Q;
	for (int i=1;i<=n*n;i++){
		int pos=p[i];
		int x=(pos-1)/n+1,y=(pos-1)%n+1;
		ans+=dst[x][y];
		dst[x][y]--;
		o[x][y]=0;
		Q.push(mp(x,y));
		while (!Q.empty()){
			int X=Q.front().first,Y=Q.front().second;
			Q.pop();
			for (int i=0;i<4;i++){
				int nx=X+dx[i],ny=Y+dy[i];
				if (nx>=1 && nx<=n && ny>=1 && ny<=n){
					if (dst[nx][ny]>dst[X][Y]+o[nx][ny]){
						dst[nx][ny]=dst[X][Y]+o[nx][ny];
						Q.push(mp(nx,ny));
					}
				}
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6736
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;

void trace(int A[], int N){ 
    int i;
    for (i=0;i<N;i++){
        if(i>0) cout << " ";
        cout << A[i];
    }   
    cout << endl;
}

void selectionSort(int A[],int N){ 
    int sw = 0;
    for (int i=0;i<N;i++){
        int minj = i;
        for (int j=i;j<N;j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i],A[minj]);
            sw++;
        }
    }   
    trace(A,N);
    cout << sw << endl;
}
int main(){
    int n,A[MAX];
    cin >> n;
    for (int i=0;i<n;i++) cin >> A[i];
    selectionSort(A,n);
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);

    rep(i,n)cin >> a[i]>> b[i] >> c[i];
    
    Graf dp(n+1,vector<int>(3));
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    for(int i=1;i<=n;++i){
        dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
        dp[i][1]=max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
        dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
    }
    int ans=max(dp[n][0],dp[n][1]);
    ans=max(ans,dp[n][2]);
    cout << ans << endl;
}

Measured memory_bytes: 9780
import math
A,B,N = map(int,input().split())
def func(x):
    return math.floor((A*x)/B) - A * math.floor(x/B)

if N < B:
    print(func(N))
    exit()
    
ans = []
for i in range(B-100,B+100):
    ans.append(func(i))
    
print(max(ans))

Measured memory_bytes: 62196
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())
cnt = B - A + 1
all_range = B // C + B // D - B // lcm(C , D)
sub_end = A - 1
sub_range = sub_end // C + sub_end // D - sub_end // lcm(C , D)
print(cnt - (all_range - sub_range))

Measured memory_bytes: 3064
from itertools import permutations as per
n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans = 0

for l in per(range(n)):
    if l[0] != 0:
        continue
    flag = 1
    for i in range(n-1):
        if l[i+1] not in g[l[i]]:
            flag = 0
            break
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 73756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  ll A, B; cin >> A >> B;
  for (ll i = 1; i <= 1000000; i++) {
    if (i * 8 / 100 == A && i * 10 / 100 == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
ABCD = [[int(x) for x in input().split()] for i in range(Q)]

ans=0
for A in itertools.combinations_with_replacement([m for m in range(1,M+1)], N):
  ans2=0
  for (a,b,c,d) in ABCD:
    if A[b-1]-A[a-1]==c:
      ans2+=d
  ans=max(ans, ans2)
print(ans)


Measured memory_bytes: 9160
#include <stdio.h>

int main()
{
  int n,i,j,num[100],minj,tmp,cnt=0;
  scanf("%d",&n);
  for(i=0;i<=n-1;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if(num[j]<num[minj]){
	minj=j;
      }
    }
    if(num[i]>num[minj]){
      tmp=num[i];
      num[i]=num[minj];
      num[minj]=tmp;
      cnt++;
    }
  }
  for(i=0;i<=n-1;i++){
    if(i==0) printf("%d",num[i]);
    else printf(" %d",num[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}



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

int main() {
    int h, w;
    cin >> h >> w;
    char g[h][w];
    rep(y, h) rep(x, w) cin >> g[y][x];

    int rm_col[h] = {0}, rm_row[w] = {0};
    rep(y, h) {
        bool rm = true;
        rep(x, w) if (g[y][x] == '#') rm = false;
        if (rm) rm_col[y] = 1;
    }
    rep(x, w) {
        bool rm = true;
        rep(y, h) if (g[y][x] == '#') rm = false;
        if (rm) rm_row[x] = 1;
    }

    rep(y, h) {
        if (rm_col[y]) continue;
        rep(x, w) {
            if (rm_row[x]) continue;
            cout << g[y][x];
        }
        cout << endl;
    }

    return 0;
}


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

int main()
{
  int n, s;
  int i, j;

  scanf("%d", &n);

  for (i = 0; i < n; i++){
    scanf("%d", &s);
    printf("Case %d:\n", i + 1);
    for (j = 0; j < 10; j++){
      char conv[9], res[5];
      sprintf(conv, "%08d", s * s);
      strcpy(res, conv + 2);
      res[4] = '\0';
      s = atoi(res);
      printf("%d\n", s);
    }
  }

  return (0);
}

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

// int/long:            -2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int     gcd(int A, int B) {
        while (0!=B) {
                A %=B;
                swap(A, B);
        }
        return A;
}
*/

#define MOD 1000000007

int     main() {
        int a, b;
        cin >>a >>b;
        if (a>b)
                cout <<"a > b" <<endl;
        else if (a<b)
                cout <<"a < b" <<endl;
        else
                cout <<"a == b" <<endl;
        return 0;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] list = new int[n];
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            list[i] = value;
            queue.add(value);
        }

        for (int i = 0; i < n; i++) {
            if (queue.peek() != list[i]) {
                System.out.println(queue.peek());
            } else {
                int max = queue.peek();
                queue.poll();
                System.out.println(queue.peek());
                queue.add(max);
            }
        }
    }
}

Measured memory_bytes: 100772
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<int> num;
	int i = 0;
	while(i < s.length()){
		int cnt = 1;
		while(s[i] == s[i + 1]){
			cnt++;
			i++;
		}
		num.push_back(cnt);
		i++;
	}
	int sum[num.size() + 1] = {};
	REP(i,num.size()){
		sum[i + 1] = sum[i] + num[i];
	}
	int ans = 0;
	if(s[0] == '0'){
		int left = 0;
		int right = min(left + 2 * k, (int)num.size());
		ans = max(ans, sum[right] - sum[left]);
		for(int left = 1; left < num.size() + 1; left += 2){
			int right = min(left + 2 * k + 1, (int)num.size());
			ans = max(ans, sum[right] - sum[left]);
		}
	}else{
		for(int left = 0; left < num.size() + 1; left += 2){
			int right = min(left + 2 * k + 1, (int)num.size());
			ans = max(ans, sum[right] - sum[left]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1272
#include <iostream>
#include <map>

using namespace std;

string compute(int i){

  string S = "";
  while(i){
    S = static_cast<char>(i % 2 + '0') + S;
    i /= 2;
  }
  while(S.size() < 5 ){
    S = '0' + S;
  }
  return S;
}

int main(void){

  map<char,string> input;
  map<string,char> output;
  
  output["101"] = ' ';
  output["000000"] = '\'';
  output["000011"] = ',';
  output["10010001"] = '-';
  output["010001"] = '.';
  output["000001"] = '?';
  output["100101"] = 'A';
  output["10011010"] = 'B';
  output["0101"] = 'C';
  output["0001"] = 'D';
  output["110"] = 'E';
  output["01001"] = 'F';
  output["10011011"] = 'G';
  output["010000"] = 'H';
  output["0111"] = 'I';
  output["10011000"] = 'J';
  output["0110"] = 'K';
  output["00100"] = 'L';
  output["10011001"] = 'M';
  output["10011110"] = 'N';
  output["00101"] = 'O';
  output["111"] = 'P';
  output["10011111"] = 'Q';
  output["1000"] = 'R';
  output["00110"] = 'S';
  output["00111"] = 'T';
  output["10011100"] = 'U';
  output["10011101"] = 'V';
  output["000010"] = 'W';
  output["10010010"] = 'X';
  output["10010011"] = 'Y';
  output["10010000"] = 'Z';

  for( int i = 0 ; i < 26 ; i++ ){
    input['A' + i ] = compute(i);
  }
  // 表 A ~ Z は２進数表示
  input[' '] = "11010";
  input['.'] = "11011";
  input[','] = "11100";
  input['-'] = "11101";
  input['\''] = "11110";
  input['?'] = "11111";

  string s;
  while( getline(cin , s) ){
    string c = "";
    // 文字を１と０に変換
    for( int i = 0 ; i < s.size() ; i++ ){
      c += input[s[i]];
    }

    // １文字どとに繋げていって、一致したら
    // tempをリセットし、ansにoutputを付け加える
    
    string temp = "", ans = "";
    for( int i = 0 ; i < c.size() ; i++ ){
      temp += c[i];
      if( output[temp] ){ // outputがあるのか１文字ごとに確認
	ans += output[temp];
	temp = "";
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ll a[100005],s=0,ans=0;
rep(i,0,n-1)cin>>a[i];

s=a[0];


	ll x=1,y=1;
	if(a[0]<=0)
	{
		s=1;
		x=abs(1-a[0]);
	}
	else
	{
		x=0;
		s=a[0];
	}
	rep(i,1,n-1)
	{
		ll s1=a[i]+s;
		if(((s/abs(s))*s1)>=0)
		{
			s=s/abs(s)*-1;
			x+=abs(s1-s);
		}
		else
		s=s1;
	}
	if(a[0]>=0)
	{
		s=-1;
		y=abs(-1-a[0]);
	}
	else
	{
		s=a[0];
		y=0;
	}
	rep(i,1,n-1)
	{
		ll s1=a[i]+s;
		if(((s/abs(s))*s1)>=0)
		{
			s=s/abs(s)*-1;
			y+=abs(s1-s);
		}
		else
		s=s1;
	}
	ans=min(x,y);
	ol(ans);



return 0;
}


Measured memory_bytes: 1024
import numpy as np
M = 10**9+7
N = int(input())
A = np.array(list(map(int,input().split())),dtype='int64')
ans = 0

maxA = np.amax(A)
K = len(str(bin(maxA)))-2

for k in range(K):
    N1 = 0
    N1 = np.sum((A >> k) & 1)
    N0 = N-N1
    ans += (((1<<k)%M) *N0%M) *N1%M
    ans %= M

print(ans)

Measured memory_bytes: 48824
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(d2==1) cout<<"1";
    else cout<<"0";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int a, p;
    scanf("%d %d", &a, &p);
    p += 3 * a;
    printf("%d\n", p / 2);
    return 0;
}


Measured memory_bytes: 256
# C - Half and Half

A, B, C, X, Y = map(int, input().split())

ans = A*X + B*Y
if A+B > C*2:
    m = min(X, Y)
    ans -= (A+B-(C*2)) * m
    X -= m
    Y -= m
if X > 0 and A > C*2:
    ans -= (A-(C*2)) * X
    Y -= X
if Y > 0 and B > C*2:
    ans -= (B-(C*2)) * Y
    Y -= Y

print(ans)

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

int main(){
  int N,K;
  cin >>N>>K;
  vector<int> p(N,0);
  vector<int> q(N,0);
  int j;
  rep(i,N){
    cin >>j;
    --j;
    p[j]+=1;
    q[j]=1;
  }
  int ans=0;
  sort(q.begin(),q.end());
  sort(p.begin(),p.end());
  int A=accumulate(q.begin(),q.end(),0);
  int i=0;
  while(A>K){
    A-=q[i];
    ans+=p[i];
    ++i;
  }
  cout << ans<<endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    String a = sc.next();
    int length = a.length();
    int result = 1000;
    for (int i = 0; i < length - 2; i++) {
        String v = a.substring(i,i+3);
        int val = Integer.valueOf(v);
        result = Math.min(result, Math.abs(val - 753));
    }
    // 出力
    System.out.println(result);
  } 
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxx = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll base = 311;
const ll base1 = 113;
ll t, T, n, m, k, tong, r, ans, mx, mn, x, y;
string s, s1, s2, ss;
ll a[maxx], b[maxx], pw[maxx], pw1[maxx], st[maxx], st1[maxx];
bool check(ll v)
{
    if(v < 2)return false;
    for(int i = 2; i <= v / i; i ++)
        if(v % i == 0)return false;
    return true;
}
ll hs(ll hh[maxx], ll pw[maxx], ll i, ll j)
{
    return (hh[j] - hh[i-1] * pw[j - i + 1] + maxx * maxx) % maxx;
}
void sol()
{
    cin >> n >> k;
    ans = 0;
    for(int i = k; i <= n + 1; i ++)
    {
        x = i - 1;
        x = x * i / 2;
        y = n + (n - i + 1);
        y = y * i / 2;
        ans += (y - x + 1);
        ans %= mod;
    }
    cout << ans;

}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    sol();
}
/*
using namespace std;
const ll maxn=3e5+1;
const ll maxx=1e13;
const ll mod=1e9+7;
const ll mod1=998244353;

//vector <ll> adj[maxn];
set<ll> adj1[maxn];
//vector<ll> ans;
//bool kt[maxn];
ll n,m,e,k;
ll d=0;
set<ll> pt;
set<ll> adj[maxn];
ll cnt=0;
void dfs(ll u)
{
    cnt++;
    pt.erase(pt.find(u));
    ll pre=0;
    auto it=pt.begin();
    while (it!=pt.end())
    {
        it=pt.upper_bound(pre);
        while (adj[u].find(*it)!=adj[u].end()&&it!=pt.end())
        {
            it++;
        }
        if ( it!=pt.end() )
        {
            pre=*it;
            dfs(*it);
        }
    }
}
int main()
{
    // freopen("test.txt","r",stdin);
    // freopen("CHEMIST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for (int i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].insert(y);
        adj[y].insert(x);


    }
    for (int i=1;i<=n;i++)pt.insert(i);
    vector<ll> ans;
    for (int i=1;i<=n;i++)
    {
        if (pt.find(i)!=pt.end())
        {
            cnt=0;
            dfs(i);
            ans.pb(cnt);
        }
    }
    sort(all(ans));
    cout <<ans.size()<<endl;
    for (auto p:ans)
    {
        cout <<p<<" ";
    }

}
*/


Measured memory_bytes: 3636
#include <stdio.h>

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int A,B;
  scanf("%d%d",&A,&B);

  int ans;
  if(A == B) ans = A+B;
  else ans = max(A,B)*2-1;

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

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s,t;
  cin >> s >> t;
  if (s == t.substr(0,s.size()))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans;
	if(abs(a-b)%2){
		ans=min(a-1,n-b)+(b-a+1)/2;
	}else ans=abs(a-b)/2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

n=int(input())
l=[]
for i in range(1,10):
    if 6**i>n:
        break
    l.append(6**i)
for i in range(1,10):
    if 9**i>n:
        break
    l.append(9**i)

l.sort()

if n in l:
    print(1)
    exit()

inf=float("inf")
dp=[inf]*(n+1)

def dfs(n):
    if dp[n]!=inf:
        return dp[n]
    if n<6:
        return n
    m=inf
    for d in l:
        if n-d<0:
            break
        m=min(m,dfs(n-d)+1)
    dp[n]=m
    return m

print(dfs(n))


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

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for(int i = 0; i < N; i++){
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());
	while(v.size() > 2){
		double index_0 = (v.at(0) + v.at(1)) / 2;
		v.erase(v.begin() + 0);
		v.erase(v.begin() + 0);
		v.insert(v.begin() + 0, index_0);
	}
	cout << (v.at(0) + v.at(1)) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

snuke = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuke[j - 1] += 1

ans = 0
for i in snuke:
    if i == 0:
        ans += 1

print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;

bool ada[200];

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int x, n;
  cin >> x >> n;
  vector<int> ve;

  if(n == 0) {
    cout << x << '\n';
    return 0;
  }

  for(int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    ada[k] = true;
  }

  int mn = 200, ans = 200;
  for(int i = x; i <= 101; i++) {
    if(!ada[i]) {
      if(i - x <= mn && i < ans) {
        ans = i;
        mn = i - x;
        break;
      }
    }
  }
  for(int i = x; i >= 0; i--) {
    if(!ada[i]) {
      if(x - i <= mn && i < ans) {
        ans = i;
        mn = x - i;
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int n=(int)s.size();
  int k;cin>>k;
  vector<int> fi(26, -1);
  for(int i=0;i<n;i++){
  	char c=s[i];
    if(fi[int(c-'a')]==-1)fi[int(c-'a')]=i;
  }
  for(int i=0;i<26;i++){
    if(fi[i]==-1)continue;
  	if(n-fi[i]>=k){
      string ans;
      vector<string> tmp;
      for(int j=fi[i];j<n-k+1;j++){
      	if(s[j]==char('a'+i))tmp.push_back(s.substr(j, k));
      }
      sort(tmp.begin(), tmp.end());
      cout<<tmp[0]<<endl;
      return 0;
    }else{
      k-=n-fi[i];
    }
  }
}


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

int main() {
    string S;
    cin >> S;

    int n = S.size();
    long long res = 0;
    for (int i = 0; i < (1 << (n - 1)); i++) {
        int start = 0;
        for (int j = 0; j < n - 1; j++) {
            if ((i >> j) & 1) {
                res += stoll(S.substr(start, j - start + 1));
                start = j + 1;
            }
        }
        res += stoll(S.substr(start, n - start));
    }
    cout << res << endl;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int A; cin >> A;
	char op; cin >> op;
	int B; cin >> B;
	
	if(op=='+') cout << A+B;
	else cout << A-B;
	
	return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  int T;
  T = A - N % 500;
  if( T >= 0){
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
s=input()
a=[0 for i in range(n)]
east,west =0,0
for i in range(n):
    a[i]+=west
    if s[i]=="W":
        west+=1
for i in range(n-1,-1,-1):
    a[i]+=east
    if s[i]=="E":
        east+=1
print(min(a))


Measured memory_bytes: 15520
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] k = new int[n];
        for(int i = 0;i < n; i++){
            k[i] = sc.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 1; i <= 100; i++){
            int tmp = 0;
            for(int j : k){
                tmp += Math.pow(Math.abs(i-j),2);
            }
            ans = Math.min(ans,tmp);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
H, W = map(int, input().split())

temp = ['.'] * (W + 2)
S = [temp]

for _ in range(H):
    S.append(['.'] + list(input()) + ['.'])

S.append(temp)

output = []

for i in range(1, H + 1):
    temp = []
    for j in range(1, W + 1):
        s = str(S[i-1][j-1:j+2].count('#') + S[i+1][j-1:j+2].count('#') + (S[i][j-1] + S[i][j+1]).count('#'))
        temp.append('#' if S[i][j] == '#' else s)
    output.append(temp)
for line in output:
    print(''.join(line))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX (int)(2*1e5+10)

signed  main(){
  int N, A[MAX], a[MAX];
  int ans = 0, b;
  
  cin>>N;

  for(int i = 1; i <= N; i++){
    cin>>A[i];
    a[i] = A[i];
    A[i] -= i;
  }

  sort(A+1,A+N+1);
  b = A[(N+1)/2];
  for(int i = 1; i <= N; i++){
    ans += abs(a[i]-(b+i));
  }
  //cout<<b<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
def modpow(x,p,mod):
    ret=1
    for i in range(64):
        if (1<<i)&p:
            ret=ret*x%mod
        x=x*x%mod
    return ret

def inverse_table(n,mod):
    table=[]
    for i in range(0,n+1):
        table.append(modpow(i,mod-2,mod))
    return table

def factorial_table(n,mod):
    table=[1]
    for i in range(1,n+1):
        table.append(table[-1]*i%mod)
    return table

def inverse_factorial_table(n,it,mod):
    table=[1]
    for i in range(1,n+1):
        table.append(table[-1]*it[i]%mod)
    return table

it=inverse_table(10**5,1000000007)
ft=factorial_table(10**5,1000000007)
ift=inverse_factorial_table(10**5,it,1000000007)
def c(n,k,it,ft,mod):
    return ft[n]*ift[k]*ift[(n-k)]%mod
n,k=map(int,input().split())
a=sorted(map(int,input().split()))
hoge=[]
while True:
    hoge.append(c(n-1,k-1,it,ft,1000000007))
    if n-1==k-1:
        break
    n-=1
ans=0
for i in range(len(hoge)):
    ans-=hoge[i]*a[i]%1000000007
    ans+=hoge[i]*a[-i-1]%1000000007
    ans%=1000000007
print(ans)



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

int main() {
  int N,count=0,max=0;
  string S;
  cin >> S;
    
  N=S.size();
  for(int i=0;i<N;i++){
      if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='T'||S.at(i)=='G'){
          count++;
          if(max<count)
            max=count;
      }
      else{
          
          count=0;
      }      
            
  }
  cout<<max<<endl;      
	      
} 

Measured memory_bytes: 256
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define MOD 1000000007

const long long INF = 10000000000000000;

using namespace std;

int N;
string s;

bool hoge(char s1, char s2){
	vector<char> ans(N);
	ans[0]=s1;
	ans[1]=s2;
	for(int i=1;i<=N;i++){
		if(s[i%N]=='o'){
			if(ans[i%N]=='S') ans[(i+1)%N]=ans[(i-1)%N];
			else ans[(i-1)%N]=='S'? ans[(i+1)%N]='W':ans[(i+1)%N]='S';
		}else{
			if(ans[i%N]=='S') ans[(i-1)%N]=='S'? ans[(i+1)%N]='W':ans[(i+1)%N]='S';
			else ans[(i+1)%N]=ans[(i-1)%N];
		}
	}

	if(ans[0]==s1 && ans[1]==s2){
		for(int k=0;k<N;k++){
			cout<<ans[k];
		}
		cout<<endl;
		return true;
	}
	return false;
}

int main(){
	
	cin>>N;
	cin>>s;
	//cout<<hoge('S','S')<<endl;
	if(hoge('S','S')) return 0;
	if(hoge('S','W')) return 0;
	if(hoge('W','S')) return 0;
	if(hoge('W','W')) return 0;

	cout<<"-1"<<endl;

	return 0;
}




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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = (2 * Math.PI) * (sc.nextDouble() / 360);
        
        double height = b * Math.sin(c);
        double space = height * a / 2;
        double length = a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(c));
        
        System.out.println(space);
        System.out.println(length);
        System.out.println(height);
    }

}



Measured memory_bytes: 27992
import java.util.Scanner;

public class Main {
	static int cc1 = 0;
	static int cc2 = 0;

	public static void main(String[] args) {
		doIt();
	}
	static void doIt(){
		Scanner sc = new Scanner(System.in);
		int q1 = sc.nextInt();
		while(0 < q1){
			int b = sc.nextInt();
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int q2 = sc.nextInt();
			int max = q2, min = 0, mid = 0;
			while(min < max){
				mid = (max + min) / 2;
				if(check(mid, q1, b, c1, c2)){
					if(min == mid) {
						if(check(mid + 1, q1, b, c1, c2)) max = mid + 1;
						else max = mid;
						break;
					}
					else min = mid;
				}
				else max = mid - 1;
				//System.out.println("min = " + min + ", max = " + max + ",m = " + mid);
			}
			if(max < 1) System.out.println("NA");
			else  System.out.println(cc1 + " " + cc2);
			q1 = sc.nextInt();
		}
	}

	static boolean check(int m, int q1, int b, int c1, int c2){
		boolean ret = false;
		int money = b - c1*m;
		if(money < 0) return false;
		int nml = money / c2;
		if(q1 <= m + nml){
			ret = true;
			cc1 = m;
			cc2 = nml;
		}	
		return ret;
	}

}

Measured memory_bytes: 12000
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)
func main(){
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	ss := strings.Split(sc.Text()," ")
	a,_ := strconv.Atoi(ss[0])
	b,_ := strconv.Atoi(ss[1])

	i := b-a
	sum := 0
	for n := 0; n < i; n++ {
		sum+=n
	}
	fmt.Println(sum-a)
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  int min_cost=10000000000000;
  for(int P=X.at(0);P<X.at(N-1)+1;P++){
    int cost=0;
    for(int i=0;i<N;i++){
      cost+=(X.at(i)-P)*(X.at(i)-P);
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(abs(b-a)+w*t > v*t)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}
 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

    double ans;
    if(x >= a * a * b / 2) ans = atan(2.0 * (a * a * b - x) / (a * a * a)) * 180.0 / PI;
    else ans = (PI / 2 - atan(2 * x / (a * b * b))) * 180.0 / PI;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long t,a;
  cin >> t >> a;
  for( int i = 1 ; i <N; i++){
     long long T,A;
     cin >>T>>A;
     long long k1=((t+T-1)/T); 
     long long k2=((a+A-1)/A);
     if( k2<k1 )swap(k1,k2);
     if( k1*T>t && k1*A>a){
      t=k1*T,a=k1*A;
     }
     else{
      t=k2*T,a=k2*A;
     }
     //cout << t1 <<"-" << a1 << endl;
     //cout << t2 <<"-" << a2 << endl;
     //cout << t <<" "<< a << endl;
  }
  cout << t+a<<endl;
  return 0;
}


Measured memory_bytes: 256