akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline int fastpo(int x, int n, int mod) {
	int res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}

const int N = 505;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dis[N][N], a[N][N];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			dis[i][j] = min(min(min(i, j), (n - i + 1)), n - j + 1);
		}
	}
	int ans = 0;
	for(int i = 1; i <= n * n; i++) {
		int x;
		scanf("%d", &x);
		int y = (x - 1) % n + 1;
		x = (x + (n - 1)) / n;
		ans += dis[x][y] - 1;
		dis[x][y]--;
		static vector<pair<int, int >> q;
		q.clear();
		a[x][y] = 1;
		q.push_back({x, y});
		for(int op = 0; op < (int)q.size(); op++) {
			int x = q[op].fi, y = q[op].se;
			for(int d = 0; d < 4; d++) {
				int X = dx[d] + x, Y = dy[d] + y;
				if(1 <= X && X <= n && 1 <= Y && Y <= n) {
					if(dis[X][Y] > dis[x][y] + (a[X][Y] == 0)) {
						dis[X][Y] = dis[x][y] + (a[X][Y] == 0);
						q.push_back({X, Y});
					}
				}
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			printf("%d ", dis[i][j]);
		}
		printf("\n");
	}*/
	
	cout << ans << endl;
}




Measured memory_bytes: 7228
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;

#define LL long long

const int N=1e5+50;
int n,L[N],R[N];
LL ans,tl,tr,lq,rq;
priority_queue < LL,vector<LL>,less<LL> > Left; 
priority_queue < LL,vector<LL>,greater<LL> > Right;

template<typename elemType>
inline void Read(elemType &T){
    elemType X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    T=(w?-X:X);
}

int main() {
    Read(n);
    for(register int i=1;i<=n;++i){
        Read(L[i]);Read(R[i]);
        L[i]=R[i]-L[i];
    }
    Left.push(R[1]);
    Right.push(R[1]);
    
    for(register int i=2;i<=n;++i){
        tl-=L[i-1];
        tr+=L[i];
        lq=Left.top()+tl;
        rq=Right.top()+tr;
        if(lq<=R[i] && R[i]<=rq){
            Left.push(R[i]-tl);
            Right.push(R[i]-tr);
        }
        else if(R[i]>=lq){
            ans+=R[i]-rq;
            Right.pop();
            Left.push(rq-tl);
            Right.push(R[i]-tr);
            Right.push(R[i]-tr);
        }
        else{
            ans+=lq-R[i];
            Left.pop();
            Right.push(lq-tr);
            Left.push(R[i]-tl);
            Left.push(R[i]-tl);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int r = 0;
  int b = 0;
  
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') r++;
    else if (s[i] == 'B') b++;
  }
  
  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    for b in range(N // 7, -1, -1):
        a = N - 7 * b
        if a % 4 == 0:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()


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

int main() {
	int n; cin >> n;
	vector<int> p(n); rep(i, n) { cin >> p[i]; }

	int c = 0;
	int checkedIdx = n;
	for (int i = 1; i < n; i++) {
		if (p[i - 1] > p[i]) {
			c++;
			if (c == 2) {
				swap(p[checkedIdx], p[i]);
				i = 1;
			}
			else if (c == 1) {
				checkedIdx = i - 1;
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	if (c == 1) cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int ans=0;
int n;
int a;
int main()
{
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
    return 0;
    return 0;
}


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

using namespace std;
long long knapSack(long long W, long long wt[], long long val[], int n)
{
   long long i, w;
   long long K[n+1][W+1];

   // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}
int main(){

    int n;
    cin>>n;
    long long w;
    cin>>w;
    long long wt[n],val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    cout<<knapSack(w,wt,val,n);
}


Measured memory_bytes: 79104
func main() {
    let input_N = Int(readLine()!)!
    let input_aN = readLine()!.split(separator: " ").map {Int($0)!}
    var count = 0
    input_aN.enumerated().forEach({ n, x in
        if (n+1) % 2 == 1 && x % 2 == 1{
            count += 1
        }
    })
    print(count)
}

main()



Measured memory_bytes: 8268
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll k;
      string s;
      cin>>k>>s;
      if(s.length()<=k) {cout<<s;return 0;}
      else
      {
        s=s.substr(0,k);
        cout<<s<<"...";

      }
    }
    return 0;
   }

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

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

const int INF = 1000000007;

int main(void){
	P p[110], q[110];
	set<P> stR, stB;
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second;
	for(int i=0;i<n;i++) cin>>q[i].first>>q[i].second;

	for(int i=0;i<n;i++){
		stR.insert(p[i]);
		stB.insert(q[i]);
	}


	//cout<<endl<<endl;
	int cnt=0;

	for(auto iteB=stB.begin(); iteB != stB.end(); iteB++){
		int maxy=-1;
		auto itemaxy = stR.begin();
		for(auto iteR=stR.begin(); iteR != stR.end();iteR++){
			if(iteR->second < iteB->second && iteR->first < iteB->first){
				if (maxy < iteR->second) {
					maxy = iteR->second;
					itemaxy = iteR;
				}
			}
			//cout << iteR->second << " " << iteB->second << "   " << iteR->first << " " << iteB->first << "  " << maxy << endl;
		}
		if(maxy != -1){
			//cout<<itemaxy->first<<" "<<itemaxy->second<< "  " << iteB->first << " " << iteB->second << endl; 

			stR.erase(itemaxy);
			//stB.erase(iteB);
			cnt++;
		}
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, n; cin >> h >> n;
	vector<int>dp(h + 1, INF);
	dp[0] = 0;
	rep(i, n) {
		int a, b; cin >> a >> b;
		rep(j, h) {
			int nj = min(j + a, h);
			chmin(dp[nj], dp[j] + b);
		}
	}
	cout << dp[h] << endl;
	return 0;
}

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

const double pi = acos(-1);
const double eps = 0.0000000001;

double a, b, x;

double func(double theta) {
    if (theta > pi / 2.0) {
        return 0.0;
    }
    double r;
    if (b / tan(theta) > a) {
        r = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        r = a * b * b / tan(theta) / 2.0;
    }
    return r;
}

int main() {
    cout << fixed << setprecision(10);
    cin >> a >> b >> x;
    double ok = pi / 2.0;
    double ng =  0.0;
    rep(i, (int)1e6) {
        double mid = (ok + ng) / 2.0;
        if (func(mid) < x) ok = mid;
        else ng = mid;
    }
    cout << ok / pi * 180 << endl;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,f,e) for(int (i)=(f); (i)<(e); (i)++)
#define repr(i,e,f) for(int (i)=(e-1); (i)>=(f); (i)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

template<typename T> istream &operator >> (istream &is, vector<T> &vec){ for (T& v : vec) is >> v; return is; }
template<typename T> ostream &operator << (ostream &os, const vector<T> &vec){ for (auto v : vec) os << v << " "; return os; }
// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    cin >> A;
    rep(i,0,N) A.push_back(A[i] + K);
    int ans = 1e9;
    rep(i,0,N){
        ans = min(ans, A[i + N - 1] - A[i]); 
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1804
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N = inputInt()
	A = inputList()

	flg = False

	for i in A:
		if i % 2 == 0:
			if i % 3 == 0 or i % 5 == 0:
				pass
			else:
				flg = True

	if flg:
		print("DENIED")
	else:
		print("APPROVED")

if __name__ == "__main__":
	main()


Measured memory_bytes: 40496
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int h,w,x,y,nx,ny;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w) cin>>a[i][j];
  
  int ans=1;
  rep(i,h)rep(j,w){//strart:(i,j)
     if(a[i][j]=='#') continue;
    queue<P> q;
    vec2(seen,h,w);
    q.push(P(i,j));
    while(q.size()){
    	x=q.front().second;y=q.front().first;
      q.pop();
      rep(k,4){
        nx=x+dx[k];ny=y+dy[k];
      	if(nx<0 || ny<0 || nx>=w || ny>=h || a[ny][nx]=='#' ||seen[ny][nx]>0) continue;
        if(nx==j && ny==i) continue;
        seen[ny][nx]=seen[y][x]+1;
        q.push(P(ny,nx));
      }
    }
    rep(k,h)rep(l,w) ans =max(ans,seen[k][l]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int cnt=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='+')cnt++;
			else cnt--;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 25172
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
int a[maxn];

int32_t main(){
    migmig
    cin >> n;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i];
    sort(a , a + n);
    if(a[n-1] - a[0] > 1)
        dokme("No");
    for(int i = 1 ; i < n ; i ++)
        a[i]-=a[0];
    int cnt[] = {1 , 0 };
    for(int i = 1 ; i < n ; i ++)
        cnt[a[i]]++;
    if(cnt[0] == n){
        if(a[0] == n-1)
            dokme("Yes");
        if(a[0]*2 <= n)
            dokme("Yes");
        dokme("No");
    }
    n--;
    if(cnt[0]+1 <= a[n]+a[0])
        if(cnt[0]+cnt[1]/2 >= a[n]+a[0])
            dokme("Yes");
    dokme("No");
    return(0);
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> A(N + 1);
    A[0] = 0;
    A[1] = 0;
    for (int i = 1; i < N; i++) {
        if (S[i-1]=='A' && S[i]=='C') {
            A[i+1] = A[i] + 1;
        } else {
            A[i+1] = A[i];
        }
    }

    // rep(i, N+1) {
    //     cout << A[i] << " ";
    // }
    // cout << endl;

    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << A[r] - A[l] << endl;
    }
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,m;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if(s.at(i) == 'B'){
      if(m.size() > 0){
        m.pop_back();
      }
    }
    else m.push_back(s[i]);
  }
        
  cout << m << endl;
  
}
  

Measured memory_bytes: 3600
/**
 * author  : UshanGhosh
 * created : 2020-09-19 18:19:17
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (int)1e9+7
#define    inf     (long long)1e18
#define    endl    '\n'

bool hsh[2000000];

int divCount(int n) 
{ 
    int total = 1; 
    for (int p = 2; p*p <= n; p++) { 
        if (hsh[p]) { 
            int count = 0; 
            if (n % p == 0) { 
                while (n % p == 0) { 
                    n = n / p; 
                    count++; 
                } 
                total = total * (count + 1); 
            } 
        } 
    }
    if(n!=1) total*=2;
    return total;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    ll ans = 0;
    memset(hsh, true, sizeof(hsh)); 
    for (int p = 2; p * p < n; p++) 
        if (hsh[p] == true) 
            for (int i = p * 2; i < n; i += p) 
                hsh[i] = false;
    for(i=1;i<n;i++){
        ll nn = n-i;
        ans+=divCount(nn);
    }
    cout<<ans<<"\n";
}

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

long dp[110][100010];
int w[110], v[110];

int main()
{
    int N, W; cin>>N>>W;
    for(int i=0; i<N; ++i) cin>>w[i]>>v[i];

    for(int i=0; i<=N; ++i)
        for(int j=0; j<=100000; ++j)
            dp[i][j]=1L<<50;

    dp[0][0]=0;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<=100000; ++j) {
            dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
            if (j>=v[i])
                dp[i+1][j]=min(dp[i+1][j], dp[i][j-v[i]]+w[i]);
        }
    }

    long res=0;
    for(int i=0; i<=100000; ++i) if (dp[N][i]<=W) res=i;
    cout<<res<<endl;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e6 + 100;
constexpr int MOD = 1e9 + 7;

int fac[N], inv[N];

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        b >>= 1;
    }
    return res;
}

int C(int n, int m){
    if(m < 0 or m > n) return 0;
    return 1LL * fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

void Init(){
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;
    inv[N - 1] = binpow(fac[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) inv[i] = 1LL * inv[i + 1] * (i + 1) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Init();
    int s; 
    cin >> s;
    long long ans = 0;
    for (int i = 1; i <= s / 3; i++) {
        (ans += C(s - 3 * i + i - 1, i - 1)) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11464
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    let q: Vec<usize> = read().split(' ').map(|x| x.parse().unwrap()).collect();
    let (n, k) = (q[0], q[1]);
    let mut h: Vec<usize> = (0..n).map(|_| read().parse().unwrap()).collect();
    h.sort();

    let mut ans: usize = 9_000_000_000;
    for i in 0..(n - k + 1) {
        ans = std::cmp::min(ans, h[i + k - 1] - h[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int to=0;
	int a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		a[i]*=2;
		if(i%2==0)
		to+=a[i];
		else
		to-=a[i];
	}
	cout<<to/2<<" ";int pr=to/2;
	for(int i=0;i<n-1;++i)
	{
		cout<<a[i]-pr<<" ";
		pr=a[i]-pr;
	}
}

Measured memory_bytes: 2176
// ------------------------------------
// Date:2018/ 2/22
// Problem:ABC 043 BeTogether c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define POW(x) (x)*(x)

using ll = long long;

int main()
{
  int N,tmp,min = 1e9;
  cin >> N;
  vector<int> a(N);
  REP(i,N) {
    cin >> a[i];
  }
  sort(ALL(a));
  if (a[0] == a[N-1]) min = 0;
  FOR (i,a[0],a[N-1]) {
    tmp = 0;
    REP(j,N) {
      tmp += POW(a[j]-i);
    }
    min = std::min(tmp,min);
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> str(N);
  map<string, long long > m;
  for(int i = 0; i < N; i++){
    cin >> str.at(i);
    sort(str[i].begin(), str[i].end());
    m[str[i]]++;
  }
  long long  ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    long long  t = itr->second;
    ans += t * (t-1) / 2;
  }

  cout << ans << endl;
  
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
string s;
ll qu;
/******* define variable end *******/
ll solve()
{
    cin >> s;
    cin >> qu;
    string mae = "";
    string usiro = "";
    ll kaisuu = 0;
    for (ll i = 0; i < qu; i++)
    {
        string t;
        cin >> t;
        if (t == "1")
        {
            kaisuu++;
        }
        else
        {
            string c;
            string f;
            cin >> c >> f;
            if (c == "1")
            {
                if (kaisuu % 2 == 1)
                {
                    usiro = usiro + f;
                }
                else
                {
                    mae = f + mae;
                }
            }
            else
            {
                if (kaisuu % 2 == 1)
            {
                    mae = f + mae;
                }
                else
                {
                    usiro = usiro + f;
                }
            }
        }
    }
    if (kaisuu % 2 == 1)
    {
        reverse(s.begin(), s.end());
        reverse(mae.begin(), mae.end());
        reverse(usiro.begin(), usiro.end());
        cout << usiro << s << mae << endl;
    }
    else
    {
        cout <<mae <<  s << usiro << endl;
    }

    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 1108
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import time
s = time.time()
import math
K = Int()
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += math.gcd(math.gcd(i,j),k)
g = time.time()

#print(g-s)
print(ans)

Measured memory_bytes: 68944
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define ii pair<int, int>
#define debug(index, num) cerr << "Case #" << index << ": " << num << endl
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
const ll MOD = 998244353;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, x;
    cin >> n >> x;
    vector<ll> val(n+1, 0), wei(n+1, 0);
    for(int i = 1; i <= n; i++) cin >> wei[i] >> val[i];
    vector<vector<ll>> dp(n+1, vector<ll> (x+1, 0));
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= x; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }
            if(wei[i] <= j) {
                dp[i][j] = max(val[i] + dp[i-1][j-wei[i]], dp[i-1][j]);
                continue;
            }
            dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][x];
} 

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

int main(){
    string s,t;
    cin>>s>>t;
    size_t l=s.length();
    bool flag=false;
    rep(i,l){
        if(s==t){
            flag=true;
            break;
        }
        s=s.back()+s.substr(0,l-1);
    }
    if(flag) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3620
"""
i=7
bin_i=format(i,'b')
bin_i='0'+bin_i
print(bin_i)
"""
d,g=map(int,input().split())
#d=int(input())
#g=int(input())
p=[0]*d
c=[0]*d
res=pow(10,7)
"""
初期化パターン
p=[0]*d
"""
for i in range(d):
    p[i],c[i]=map(int,input().split())
    #p.append(int(input()))
    #c.insert(i,int(input()))

for bit in range(1<<d):
    #print(bit)
    score=0
    num=0
    for i in range(d):
        if(bit & (1<<i)):
            score+=c[i]+p[i]*100*(i+1)
            num+=p[i]
    if(score>=g):
        res=min(res,num)
    else:
        for i in range(d-1,-1,-1):               
            if(bit & (1<<i)):
                continue
            for j in range(0,p[i]):
                if(score>=g):
                    break                    
                score+= 100*(i+1)
                num+=1
        res=min(res,num)
print(res)

        

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

using namespace std;

int main(){
    
    pair<int, int> a1[100000];
    pair<int, int> a2[100000];
    
    for (int i = 0; i < 100000; i++) {
        a1[i].second = i;
        a1[i].first = 0;
        a2[i].second = i;
        a2[i].first = 0;
    }
    
    
    int n;
    cin >> n;

    
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        
        if (i%2 == 0) {
            a1[v-1].first -= 1;
        }else{
            a2[v-1].first -= 1;
        }
    }
    
    sort(a1, a1+100000);
    sort(a2, a2+100000);
    
    
    
    int ans = 0;
    
    if (a1[0].second != a2[0].second) {
        ans = n + a1[0].first + a2[0].first;
        
    }else{
        if (a1[1].first >= a2[1].first) {
            
            ans = n + a1[0].first + a2[1].first;
        }else{
            
            ans = n + a1[1].first + a2[0].first;
        }
        
    }

    cout << ans << endl;
    
}



Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


signed main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << (regex_match(s, regex("(dream(er)?|eraser?)*")) ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 41040
#include <iostream>
#include <string>

using namespace std;

int func(char w)
{
  char n = '0';
  for(int i = 2; i <= 10; i++){
    if(w == (char)(n+i)){
      return i;
    }
  }

  return 1;
}

int main()
{
  int n, s, t, v;
  string s1, s2;
  char w = '0';
  cin >> n;
  while(n--){
    cin >> s1 >> s2;
    s = t = 0;

    for(int i = 0; i < s1.size(); i++){
      v = func(s1[i]);
      if(v > 1){
	i++;
      }
      if(s1[i] == 'm'){
	s += v*1000;
      } else if(s1[i] == 'c'){
	s += v*100;
      } else if(s1[i] == 'x'){
	s += v*10;
      } else if(s1[i] == 'i'){
	s += v;
      }
    }

    for(int i = 0; i < s2.size(); i++){
      v = func(s2[i]);
      if(v > 1){
	i++;
      }
      if(s2[i] == 'm'){
	t += v*1000;
      } else if(s2[i] == 'c'){
	t += v*100;
      } else if(s2[i] == 'x'){
	t += v*10;
      } else if(s2[i] == 'i'){
	t += v;
      }
    }
    s += t;
    s1 = "";

    v = s/1000;
    if(v > 0){;
      if(v > 1){
	s1 += (char)(w+v);
      }
      s1 += 'm';
      s -= v*1000;
    }
    v = s/100;
    if(v > 0){
      if(v > 1){
	s1 += (char)(w+v);
      }      
      s1 += 'c';
      s -= v*100;
    }
    v = s/10;
    if(v > 0){
      if(v > 1){
	s1 += (char)(w+v);
      }
      s1 += 'x';
      s -= v*10;
    }
    if(s > 0){
      if(s > 1){
	s1 += (char)(w+s);
      }
      s1 += 'i';
    }

    cout << s1 << endl;
  }

  return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------

int x[10],y[10];

double distance(int i,int j){
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

signed main(){
    CIN(N);
    RepS(i,1,N) cin>>x[i]>>y[i];
    double sum=0.0;
    vi v(N);
    rep(i,N)v[i]=i+1;
    do{
        rep(i,N-1) sum+=distance(v[i],v[i+1]);
    }while(next_permutation(all(v)));
    
    int num = 1;
    RepS(i,2,N) num*=i;
    printf("%.10f\n",sum/num);
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),T=in();
	int min_cost = 1e9;
	REP(i,N){
		int c=in(),t=in();
		if(t<=T) min_cost = min(min_cost,c);
	}
	cout << (min_cost==1e9 ? "TLE" : to_string(min_cost)) << endl;
	return 0;
}


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

int main (){
  int N,P;
  cin>>N>>P;
  int x,y=0;
  while(P%2==0){
    P/=2;
    x++;
  }
  for(int i=0;i<N-1;i++){
    int Q;
    cin>>Q;
    while(Q%2==0){
      Q/=2;
      y++;
    }
    if(y<x){
      x=y;
    }
    y=0;
  }
  cout<<x<<endl;
}
    


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(unsigned short *A, unsigned short *B, int C[], int n){
  int i;

  for(i = 0; i <= VMAX; i++) C[i] = 0;

  for(i = 0; i < n; i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }

  for(i = 1; i <= VMAX; i++){
    C[i] = C[i] + C[i-1];
  }

  for(i = 1; i <= n; i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  CountingSort(A, B, C, n);

  printf("%d", B[1]);
  for(i = 2; i <= n; i++){
    printf(" %d", B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9596
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    int ans=1e9;
	ll L,R;
    cin>>L>>R;
    if((R-L)>2019){
        cout<<0<<endl;
        return 0;
    }else{
        for(ll i=L;i<=R;i++){
            for(ll j=i+1;j<=R;j++){
                ll a=i%2019;
                ll b=j%2019;
                int c=(a*b)%2019;
                ans=min(ans,c);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        string s, t;
        cin >> s >> t;
        ll n = s.size();
        ll tlen = t.size();
        ll ans = INF;
        for(i = 0; i <= n - tlen; i++){
            ll cnt = 0;
            for(j = i; j < i + tlen; j++){
                if(s[j] != t[j - i]){
                    cnt++;
                }
                else{
                }
            }
            ans = min(ans , cnt);
        }
        cout << ans;
    }
    return 0;
}

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

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

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

int main(){
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	double w,s,con,tmp=0,tma=a,tmb=0;
	double mxcn=100.*e/(100+e);
	for(int i=0;i<f/a+1;i++)
	for(int j=0;j<f/b+1;j++)
	for(int k=0;k<f/c+1;k++)
	for(int l=0;l<f/d+1;l++){
		w = a*i+b*j;
		s = c*k+d*l;
		con = 100. * (s)/(w+s);
		if(w+s>f||con>mxcn)
			continue;
		if(tmp<con){
			tmp=con;
			tma=w+s;
			tmb=s;
		}
	}
	cout << tma << " " << tmb << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
long long int mod(long long int a){
	if(a<0) return -1*a;
	return a;
}
int main(){
	long long int a,b;
	cin>>a>>b;
	if(a%3==0 || b%3==0){
		cout<<0;
		return 0;
	}
	long long int mi=10000000000;
	for(int i=1;i<=a/2;i++){
		ll int x1 = i*b;
		ll int x2 = ((a-i))*(b/2);
		ll int x3=x2;
		if(b%2==1) x3+=a-i;
		if(mi>max(x1,max(x2,x3)) - min(x1,min(x2,x3)))
			mi=max(x1,max(x2,x3)) - min(x1,min(x2,x3));
	}
	for(int i=1;i<=b/2;i++){
		ll int x1 = i*a;
		ll int x2 = ((b-i))*(a/2);
		ll int x3=x2;
		if(a%2==1) x3+=b-i;
		if(mi>max(x1,max(x2,x3)) - min(x1,min(x2,x3)))
			mi=max(x1,max(x2,x3)) - min(x1,min(x2,x3));
	}
	for(int i=1;i<=b/2;i++){
		ll int x1=i*a;
		ll int x2= ((b-i)/2) * a;
		ll int x3=x2;
		if((b-i)%2==1) x3+=a;
		if(mi>max(x1,max(x2,x3)) - min(x1,min(x2,x3)))
			mi=max(x1,max(x2,x3)) - min(x1,min(x2,x3));
	}
	for(int i=1;i<=a/2;i++){
		ll int x1=i*b;
		ll int x2= ((a-i)/2) * b;
		ll int x3=x2;
		if((a-i)%2==1) x3+=b;
		if(mi>max(x1,max(x2,x3)) - min(x1,min(x2,x3)))
			mi=max(x1,max(x2,x3)) - min(x1,min(x2,x3));
	}
	cout<<mi;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    int N;
    void solve()
    {
        var S = cin.next;
        N = S.Length;
        for (int i = 0; i < N - 8; i++)
        {
            Write(S[i]);
        }
        WriteLine();
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    //vector<bool>change(n,true);
    for(int i=0;i<k;i++){
    	int b[n+1]={0};
    	bool b1=true;
    	for(int j=0;j<n;j++){
    		b[max(0ll,j-a[j])]++;
    		b[min(n,j+a[j]+1)]--;
    	}
    	int x=0;
    	for(int j=0;j<n;j++){
    		x+=b[j];
    		if(a[j]!=x)b1=false;
    		
    		a[j]=x;
    	}
    	if(b1)break;
    }
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<long long> all(n);
  for (int i = 0; i < n; i++) {
    cin >> all[i];
  }
  sort(all.begin(), all.end(), [&](int a, int b) {
    return abs(a) > abs(b);
  });
  int flag = 0, pi = -1, pj = -1, ni = -1, nj = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (all[i] < 0);
    flag ^= (all[i] < 0 && i < k);
    if (all[i] < 0) {
      if (i >= k && nj == -1) nj = i;
      else if (i < k) ni = i;
    } else {
      if (i >= k && pj == -1) pj = i;
      else if (i < k) pi = i;
    }
  }
  if (flag && cnt == n) {
    reverse(all.begin(), all.end());
  } else if (flag) {
    if (pi  != -1 && nj != -1 && ni != -1 && pj != -1) {
      if (all[nj] * all[ni] > all[pi] * all[pj]) {
        swap(all[pi], all[nj]);
      } else {
        swap(all[ni], all[pj]);
      }
    } else if (pi  != -1 && nj != -1) {
      swap(all[pi], all[nj]);
    } else if (ni != -1 && pj != -1) {
      swap(all[ni], all[pj]);
    }
  }
  const long long mod = 1e9 + 7;
  long long ans = 1;
  for (int i = 0; i < k; i++) {
    ans = ans * all[i] % mod;
    ans = (ans + mod) % mod;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	int A[2][N], DP[2][N];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			if (i == 0 && j == 0) {
				DP[i][j] = A[i][j];
			} else if (i == 0) {
				DP[i][j] = DP[i][j - 1] + A[i][j];
			} else if (j == 0) {
				DP[i][j] = DP[i - 1][j] + A[i][j];
			} else {
				DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]) + A[i][j];
			}
		}
	}

	cout << DP[1][N - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<vector<char>, int>::iterator;

int main() {
	long L, R;
	cin >> L >> R;

	const long MOD = 2019;

	long R2 = 0;
	if (L + MOD <= R) {
		R2 = L + MOD;
	}
	else {
		R2 = R;
	}

	long minmod = MOD;
	long mini = 0;
	long minj = 0;
	for (long i = L; i != R2; ++i) {
		for (long j = i + 1; j != R2 + 1; ++j) {
			long iamari = i % MOD;
			long jamari = j % MOD;
			long amari = (iamari * jamari) % MOD;
			if (minmod > amari) {
				minmod = amari;
				mini = i;
				minj = j;
			}
		}
	}

	cout << minmod << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    }
}


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

int main(){
	long long N;
	__int128 ans = 1;
	cin >> N;

	bool ng = false;
	bool zero = false;
	for(long long i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		if(tmp == 0) {
			zero = true;
		}

		__int128 a = tmp;

		ans *= a;
		if(ans > 1000000000000000000) {
			ng = true;
		}
	}

	if(zero) {
		cout << 0 << endl;
	} else if(ng) {
		cout << -1 << endl;
	} else {
		long long hoge = ans;
		cout << hoge << endl;
	}

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int N;

  
int main() {
  
  cin >> N;
  v(string) A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int ans = 0;
  rep(i,N) {
    bool ok = true;
    rep(x,N) {
      rep(y,N) {
        if(A[x][y] != A[y][x]) {
          ok = false;
          break;
        }
      }
    }
    if(ok) ans++;
    rotate(A.begin(),A.begin()+1,A.end());
  }
  cout << ans * N << endl;
  return 0;
}

Measured memory_bytes: 384