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

using namespace std;
const int N = 2000+100;
typedef long long ll;
vector<int> r[N],c[N];
int n,m;
int cal(int a,int b){
	int res=0;
	int pos;
	if(r[a].size()==0){
		res+=m;
	}
	else{
			pos=lower_bound(r[a].begin(),r[a].end(),b)-r[a].begin();
			if(pos==(int)r[a].size()){
				res+=(m-1-b)+1;
			}
			else{
				res+=(r[a][pos]-1-b)+1;
			}
			if(pos==0){
				res+=(b);
			}
			else{
				res+=(b-r[a][pos-1]-1);
			}
	}
	if(c[b].size()==0) res+=n-1;
	else{
			pos=lower_bound(c[b].begin(),c[b].end(),a)-c[b].begin();
			if(pos==c[b].size()){
				res+=(n-1-(a+1))+1;
			}
			else{
				res+=(c[b][pos]-1-(a+1))+1;
			}
			if(pos==0){
				res+=(a);
			}
			else{
				res+=(a-c[b][pos-1]-1);
			} 
	}
	return res;
}
int main(){
	string s[N];
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#') r[i].push_back(j);
		}
	}
	for(int j=0;j<m;j++){
		for(int i=0;i<n;i++){
			if(s[i][j]=='#') c[j].push_back(i);
		}
	}
//	cout<<cal(2,5)<<endl;
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]!='#'){
				ans=max(ans,cal(i,j));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 36480
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n,k;
    while(cin>>n>>k){
        int arr[n];
        for(int i=0;i<n;i++)cin>>arr[i];
        sort(arr,arr+n);
        int ans=0;
        for(int i=0;i<k;i++){
            ans+=arr[i];
        }
        cout << ans << endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3640
#include <stdio.h>

typedef struct _dice {
	int label[6];
} DICE, *PDICE;

int rotation[6][5] =
	{
		{ /* N */ 1, 2, 6, 5},
		{ /* S */ 1, 5, 6, 2},
		{ /* E */ 1, 4, 6, 3},
		{ /* W */ 1, 3, 6, 4},
		{ /* L */ 2, 3, 5, 4},
		{ /* R */ 2, 4, 5, 3}
	};

int aid(int c) {
	switch (c) {
	case 'N': return 0;
	case 'S': return 1;
	case 'E': return 2;
	case 'W': return 3;
	case 'L': return 4;
	case 'R': return 5;
	default: return -1;
	}
}

void rotate(PDICE dice, int c) {
	int a = aid(c);
	int t, i;
	
	if (a < 0) {
		return;
	}
	
	t = dice->label[rotation[a][0] - 1];
	for (i = 0; i < 3; i++) {
		dice->label[rotation[a][i] - 1] =
			dice->label[rotation[a][i + 1] - 1];
	}
	dice->label[rotation[a][3] - 1] = t;
}

void fit(PDICE dice, int p, int n) {
	int i;
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'N');
	}
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'W');
	}
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'L');
	}
}

int main(void) {
	DICE dice;
	int i, j, ch;
	int q, f, t;
	
	for (i = 0; i < 6; i++) {
		scanf("%d", &dice.label[i]);
	}
	
	scanf("%d", &q);
	
	for (i = 0; i < q; i ++) {
		scanf("%d %d", &t, &f);
		fit(&dice, 0, t);
		for (j = 0; j < 4; j++) {
			if (dice.label[1] == f) {
				break;
			}
			rotate(&dice, 'L');
		}
		printf("%d\n", dice.label[2]);
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),w=nxtl();
    vector <vector <ll> > v;
    vector <ll> row;
    v.resize(4,row);
    ll base;
    for(int i=0;i<n;i++)
    {
        ll x=nxtl(),y=nxtl();
        if(i==0)
            base=x;
        v[x-base].push_back(y);
    }
    for(int i=0;i<4;i++)
        sort(all(v[i]),greater<int>());
    ll test=0;
    ll a=0;
    for(int i=0;i<=v[0].size();i++){
        if(i>0)
            a+=v[0][i-1];
        ll b=0;
        for(int j=0;j<=v[1].size();j++)
        {
            if(j>0)
                b+=v[1][j-1];
            ll c=0;
            for(int k=0;k<=v[2].size();k++)
            {
                if(k>0)
                    c+=v[2][k-1];
                ll d=0;
                for(int l=0;l<=v[3].size();l++)
                {
                    if(l>0)
                        d+=v[3][l-1];
                    //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
                    if(base*i+(base+1)*j+(base+2)*k+(base+3)*l<=w&&test<a+b+c+d)
                        test=a+b+c+d;

                }
            }
        }
    }

    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    int64 tmp=0,ans=0;
    cin>>N;
    vector<string> s(N);
    for(int64 i=0;i<N;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    // for(int64 i=0;i<N;i++){
    //     cout<<s[i]<<endl;
    // }
    for(int64 i=1;i<N;i++){
        if(s[i]==s[i-1]){
            tmp++;
        }else{
            for(int64 j=0;j<=tmp;j++){
                ans+=j;
            }
            tmp=0;
        }
    }
    for(int64 j=0;j<=tmp;j++){
        ans+=j;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using P = pair<int,int>;
const int MAX = 7e2;
const int INF = 1e9;

vector<int> g[MAX];
vector<int> color(MAX,0);

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

bool dfs(int v, int c){
  color[v] = c;
  rep(i,g[v].size()){
    if(color[g[v][i]] == c) return false;
    if(color[g[v][i]] == 0 && !dfs(g[v][i],-c)) return false; 
  }
  return true;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n,vector<int>(n,0));
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    d[a][b] = 1;
    d[b][a] = 1;
  }
  Union_Find uf(n);
  rep(i,n) {
    for(int j = i+1; j < n; j++) {
      if(!d[i][j]) {
        g[i].push_back(j);
        g[j].push_back(i);
        uf.unite(i,j);
      }
    }
  }
  rep(i,n) {
    if(!color[i]) {
      bool f = dfs(i,1);
      if(!f) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  vector<P> v(n,P(0,0));
  rep(i,n) {
    if(color[i] == 1) v[uf.find(i)].first++;
    else v[uf.find(i)].second++;
  }
  vector<vector<bool>> dp(n+1,vector<bool>(n+1,false));
  dp[0][0] = true;
  rep(i,n) {
    rep(j,n) {
      if(dp[i][j]) {
        dp[i+1][j+v[i].first] = true;
        dp[i+1][j+v[i].second] = true;
      }
    }
  }
  int ans = INF;
  rep(i,n+1) {
    if(dp[n][i]) ans = min(ans,i*(i-1)/2 + (n-i)*(n-i-1)/2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
/**
 *   @FileName	e.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.02 21:30:07
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

vector<int> a;
int n,k;

bool f(int x) {
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (a[i] + x - 1) / x - 1;
    }
    return ans <= k;
}
int main() {
    cin >> n;
    cin >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int l = 0, r = 1000000001;
    while(r - l > 1) {
        int mid = l + (r - l) / 2;
        if (f(mid)) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+5,mod=1e9+7;
int n;
ll a[N],b[60];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        for(int j=0;j<60;j++)
            if(a[i]>>j&1) b[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<60;j++)
            if(a[i]>>j&1) b[j]--;
        for(int j=0;j<60;j++)
            if(a[i]>>j&1)
            	ans=(ans+(1ll<<j)%mod*(n-i-b[j])%mod)%mod;
        else
            ans=(ans+(1ll<<j)%mod*b[j]%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0; 
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define loop(i, s, n) for(int i = s; i < n; i++)
#define min(x, y) (x) > (y) ? (y) : (x)
#define max(x, y) (x) < (y) ? (y) : (x)
#define print_vec(X) loop(i, 0, X.size()) cout << X[i] << "\n"

int main()
{
        boost;

        int n, d, counter = 0;
        cin >> n >> d;

        v(v(int)) coordinates(n, v(int)(d));

        loop(i, 0, n)
                loop(j, 0, d)
                        cin >> coordinates[i][j];

        loop(i, 0, n)
                loop(j, i + 1, n)
                {
                        int dist = 0;
                        loop(k, 0, d)
                                dist += pow(coordinates[i][k] - coordinates[j][k], 2);
                        int root = sqrt(dist);
                        if(root*root == dist)
                                counter++;
                }
        cout << counter << "\n";
        return 0;
}


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

int main(){
	int n,i,hit,total;

	while(cin>>n,n){
		hit=total=0;
		for(i=0;i<(n/4);i++){
			cin>>hit;
			total+=hit;
		}
		cout<<total<<endl;
	}

	return(0);
}

Measured memory_bytes: 3008
using System;
class Program
{
    static void Main(string[] args)
    {
        var t = Read(2);
        var n = t[0]; var f = t[1];
        var x = Read(n);
        for(int i = 0; i < n; i++)
        {
            x[i] = abs(x[i]-f);
        }
        Write(gcd(x));
    }

    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(long n) { Console.WriteLine(n.ToString()); return; }
    static string ReadStr() { return Console.ReadLine(); }
    static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
    static long Read() { return long.Parse(Console.ReadLine()); }
    static long[] Read(long n)
    {
        long[] p = new long[n];
        string[] t = Console.ReadLine().Split(' ');
        for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
        return p;
    }
    static long abs(long n) { return (n > 0) ? n : -n; }
    static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
    static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static long lcm(long a, long b) { return a * b / gcd(a, b); }
    static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
    static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
    static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
    static string clip(string s, int start, int count)
    {
        if (start + count < s.Length) { s = s.Remove(start + count); }
        if (start > 0) { s = s.Remove(0, start); }
        return s;
    }
    static long ConvToLong(string n, int b)
    {
        long m = 0; long t = 1;
        for (int i = n.Length - 1; i >= 0; i--)
        {
            int k = int.Parse(n[i].ToString());
            m += t * k;
            t *= b;
        }
        return m;
    }
}


Measured memory_bytes: 20832
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int K = in.i();
        int[] A = in.ii(N);
        int l = 1;
        int r = A[0];
        for (int i = 1; i < A.length; i++) {
            int a = A[i];
            if (r < a) {
                r = a;
            }
        }
        while (l < r) {
            int m = (l + r) / 2;
            int k = 0;
            for (int i = 0; i < A.length; i++) {
                k += (A[i] - 1) / m;
            }
            if (k <= K) {
                r = m;
            } else {
                l = m + 1;
            }
        }
        out.println(r);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 35860
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9;

int N, M;

int main() {
    cin >> N >> M;
    vector<pair<int, int> > A(N);
    for (int i = 0; i < N; i++) {
        int a,b;
        cin >> a >> b;
        A[i] = make_pair(a,b);
    }
    sort(A.begin(),A.end());
    ll res = 0;
    for (int i = 0; i < N; i++) {
        int t = min(A[i].second, M);
        if (t == M) {
            res += (ll) t * A[i].first;
            break;
        }
        res += (ll) t * A[i].first;
        M -= t;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

    int L;
    cin >> L;
    int N = 0;
    int pow = 1;
    while (pow <= L) pow *= 2, ++N;
    int M = (N-1)*2 + __builtin_popcount(L) - 1;
        
    cout << N << " " << M << endl;
    for (int i = 0; i < N-1; ++i) {
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        cout << i+1 << " " << i+2 << " " << (1<<i) << endl;
    }
    int cur = 1<<(N-1);
    for (int i = N-2; i >= 0; --i) {
        if (L & (1<<i)) {
            cout << i+1 << " " << N << " " << cur << endl;
            cur += (1<<(i));
        }
    }


}

Measured memory_bytes: 3620
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool canReach(string s, int fm, int to) {
    assert(s[fm] == '.' && s[to] == '.');
    int p = fm;
    while (p < to) {
        if (p + 2 <= to && s[p + 2] == '.') p += 2;
        else if (s[p + 1] == '.') p++;
        else return false;
    }
    return true;
}

bool canJumpOver(string s, int lo, int hi) {
    int n = cast(int)s.length;
    for (int i = lo; i <= hi; i++) {
        if (i + 2 >= n) break;
        if (s[i..i+3] == "...") return true;
    }
    return false;
}

bool calc(string s, int a, int b, int c, int d) {
    int n = cast(int)s.length;
    bool reachOk = canReach(s, a, c) && canReach(s, b, d);
    // a, b の移動は独立している
    if (c < d) return reachOk;
    // a は b を追い越す必要がある
    return reachOk && canJumpOver(s, b-1, d-1);
}

void main() {
    int n, a, b, c, d; scan(n, a, b, c, d);
    string s = read!string;
    writeln(calc(s, a-1, b-1, c-1, d-1) ? "Yes" : "No");
}


Measured memory_bytes: 2684
n=int(input())
a=list(map(int,input().split()))
odd=[]
for i in range(0,n,2):
    odd.append(a[i])
even=[]
for i in range(1,n,2):
    even.append(a[i])

so=sum(odd)
eo=sum(even)

tmp=so-eo
ans=[str(tmp)]
for i in range(n-1):
    tmp-=a[i]
    tmp=-tmp
    tmp+=a[i]
    ans.append(str(tmp))

print(' '.join(ans))


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

int main () {
    int N, K;
    int sum = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if (sum * 2 < sum + K) {
            sum = sum * 2;
        }
        else {
            sum = sum + K;
        }
    }
    cout << sum << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main(void){
	ll len[3];
	rep(i,3) cin >> len[i];
	sort(len,len+3);
	if(len[0]%2==0||len[1]%2==0||len[2]%2==0)	
		cout << 0 << endl;
	else
		cout << len[0]*len[1] << endl;
	return 0;
}

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

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int T;
int Xa, Ya, Ra, Xb, Yb, Rb;

double yosupot(double a, double b)
{
	return sqrt(a * a + b * b);
}
int main()
{
	const double PI = acos(-1);
	scanf("%d", &T);
	for (; T--;) {
		scanf("%d%d%d%d%d%d", &Xa, &Ya, &Ra, &Xb, &Yb, &Rb);

		double x0 = 0;
		double x1 = yosupot(Xa - Xb, Ya - Yb);
		double r0 = Ra;
		double r1 = Rb;
		
		double a = (x1 + r1) - (x0 + r0);
		double b = (x0 + r0);
		double c = (x1 + r1);
		double d = (x0 - r0) - (x1 - r1);
		double e = (x1 - r1);
		double f = (x0 - r0);

		double p = 1 / a - 1 / d;
		double q = (e + f) / d - (b + c) / a;
		double r = (b * c / a) - (e * f / d);

		double x = (-q + sqrt(q * q - 4 * p * r)) / (2 * p);
		
		double rd0 = fabs(1 / (x0 + r0 - x) - 1 / (x0 - r0 - x)) / 2;
		double rd1 = fabs(1 / (x1 + r1 - x) - 1 / (x1 - r1 - x)) / 2;
		if (rd0 > rd1) swap(rd0, rd1);
		double ang = asin((rd1 - rd0) / (rd1 + rd0));
		int ans = (int)(PI / ang);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 640
// Enjoy your stay.

#include <bits/stdc++.h>

#define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it)
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,a[22],L[22],H[22];

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

    cin>>N;
    rep(i,N)cin>>a[i];
    double lo = 0, hi = 1;
    rep(_,40){
        double mi = (lo+hi)/2;
        rep(i,N){
            L[i] = ceil(a[i] * (1 - mi));
            H[i] = floor(a[i] * (1 + mi));
        }
        set<int> cur,nx;
        rep2(i,L[0],H[0]+1){
            cur.insert(i);
        }
        rep2(i,1,N){
            if(sz(cur) == 0)break;
            nx.clear();
            ECH(it, cur){
                int t = *it;
                for(int k = (L[i] + t - 1) / t * t;
                    k <= H[i] / t * t; k += t){
                    //if(!memo[k]){
                        nx.insert(k);
                        //memo[k] = 1;
                    //}
                }
            }
            cur = nx;
        }
        if(sz(cur)) hi = mi;
        else lo = mi;
    }
    cout<<fixed<<setprecision(16)<<hi<<endl;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;

int main(){
    int n;
    cin>>n;
   
    deque<int> b;
    REP(i,n){
        int a;
        cin>>a;
        if(i%2)b.push_front(a);
        else b.push_back(a);
    }
    V c;
    for(auto &it:b)c.pb(it);
    if(n%2)reverse(ALL(c));
    REP(i,n)cout<<" "+(!i)<<c[i];cout<<endl;
    
    return 0;
}


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

int main()
{
  int N;scanf("%d",&N);
  int X[N],L[N];pair<int,int> endstart[N];
  for(int i=0;i<N;i++)
  {
    scanf("%d %d",&X[i],&L[i]);
    endstart[i].first=X[i]+L[i];
    endstart[i].second=X[i]-L[i];
  }
  sort(endstart,endstart+N);
  int ans=1,t=endstart[0].first;
  for(int i=1;i<N;i++)
  {
    if(t<=endstart[i].second){ans++;t=endstart[i].first;}
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 5384
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int a, b, c, d, aans, bans;
	cin >> a >> b >> c >> d;
	aans = a * b;
	bans = c * d;
	if (aans >= bans)
		cout << aans << endl;
	else
		cout << bans << endl;
	return 0;
}
	
	

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int a, b, c, d, e, f, g;
string s, t;

int main(void)
{
	cin >> a;
	cin >> b;
	cin >> c;
	/*cin >> d;
	cin >> e;
	cin >> f;*/
	
	//cin >> s;
	//cin >> t;
	
	int x, y, z;
	
	cout << (a-b+1)*(a-c+1) << endl;
	
	return 0;
}

Measured memory_bytes: 768
def solve():
    from sys import stdin
    f_i = stdin
    
    N, K = map(int, f_i.readline().split())
    R, S, P = map(int, f_i.readline().split())
    T = f_i.readline().rstrip()
    
    pair = {'r': 0, 's': 1, 'p': 2}
    point = {1: R, 2: S, 0: P}
    
    score = sum(point[pair[c]] for c in T) # full score
    
    for k in range(K):
        H = [pair[h] for h in T[k::K]] + [None]
        pre_h = None
        for h, next_h in zip(H, H[1:]):
            if h == pre_h:
                score -= point[h]
                h = (h + 1) % 3
                if h == next_h:
                    h = (h + 1) % 3
            pre_h = h
    
    print(score)

solve()

Measured memory_bytes: 4860
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
p = [a, b, c, d, e]

mi = [a%10,b%10,c%10,d%10,e%10]
mm = [i for i in mi if i != 0]
mm.sort()
sum = 0
for i in range(5):
	if p[i]%10 != 0:
		sum += (p[i]//10+1)*10
	else:
		sum += p[i]//10*10
if (mm):
	sum -= 10- mm[0]
print (sum)

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

const int MAXN = 2e5+5;

long long A[MAXN];
long long B[MAXN];

int main()
{
    int N, M, K;
    scanf("%d %d %d", &N, &M, &K);

    for(int i = 1; i <= N; ++i)
    {
        scanf("%lld", A+i);
        A[i] += A[i-1];
    }


    for(int i = 1; i <= M; ++i)
    {
        scanf("%lld", B+i);
        B[i] += B[i-1];
    }


    int ans = 0;

    for(int i = 0; i <= N; ++i)
    {
        if(K < A[i])
            break;

        int j = upper_bound(B, B + M + 1, K - A[i]) - B - 1;
        ans = max(ans, i + j);
    }

    cout << ans << endl;


    return 0;
}
/*
4 6 7 5
*/


Measured memory_bytes: 6808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,ans;
    int ar[2345];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n);
    ans=ar[n-1]-ar[0];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
ll min(ll a, ll b){return a < b ? a : b;}
int main(){
    int n;
    scanf("%d",&n);
    ll a[n + 1], b[n + 1];
    for(int i = 0; i <= n; i++)
        scanf("%lld",&a[i]);
    b[0] = 1;
    for(int i = 0; i <= n; i++){
        if(b[i] < a[i]){
            puts("-1");
            return 0;
        }
        if(i == n)
            break;
        b[i] -= a[i];
        b[i + 1] = min(1LL << 60 , b[i] * 2);
    }
    ll ans = a[n], now = a[n];
    for(int i = n - 1; i >= 0; i--){
        ans += min(b[i], now) + a[i];
        now += a[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3256
$n = gets.chomp.to_i
$f,$p,$ans = [],[],-1000000000
$n.times do |i|
  $f[i]=gets.chomp.split(" ").map(&:to_i)
end
$n.times do |i|
  $p[i]=gets.chomp.split(" ").map(&:to_i)
end

def dec(o)
  pr=0
  $n.times do |i|
    c,tmp = 0,o
    10.times do |j|
      c+=1 if tmp%10 ==1 && $f[i][j] == 1
      tmp /=10
    end
    pr+=$p[i][c]
  end
  $ans=[pr, $ans].max  
end

def df(i, o)
  if i==10 then
    dec(o) if o!=0
  else
  df(i+1, o*10)
  df(i+1, o*10+1)
  end
end

df(0, 0)
puts $ans

Measured memory_bytes: 1916
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

yen_min = float('inf')
for bit in range(2 ** n):
    array = []
    for i in range(n):
        if bit>>i & 1:
            array.append(i)
    check = [0]*(m+1)
    for i in array:
        for j in range(m+1):
            check[j] += ca[i][j]
    flag = True
    for i in range(1,m+1):
        if check[i] < x:
            flag = False
    if flag:
        yen_min = min(yen_min, check[0])
if yen_min == float('inf'):
    print(-1)
else:
    print(yen_min)

Measured memory_bytes: 9140
#!/usr/bin/env python3

import sys
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


A, B = map(int, input().split())

gc = gcd(A, B)
LCM = A * B // gc

print(LCM)



Measured memory_bytes: 9092
a=[[] for i in range(3)]
a[0]=list(map(int,input().split()))
a[1]=list(map(int,input().split()))
a[2]=list(map(int,input().split()))
dic={}
for i in range(3):
    for j in range(3):
        dic[a[i][j]]=0
n=int(input())
for i in range(n):
    b=int(input())
    if b in dic:
        dic[b]=1

def ans():
    for i in range(3):
        y=0
        t=0
        for j in range(3):
            if dic[a[i][j]]:
                y+=1
                
            if dic[a[j][i]]:
                t+=1
        if y==3 or t==3:
            print("Yes")
            return
    if dic[a[0][0]]+dic[a[1][1]]+dic[a[2][2]]==3 or dic[a[0][2]]+dic[a[1][1]]+dic[a[2][0]]==3:
        print("Yes")
        return
    print("No")
    
ans()


Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int a;
  int b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mxn = 100005;
int n, W, w[105], v[105];
ll ff[105][mxn];

void solution()
{
  for(int i = 1; i <= n; i++)
  {
    for(int j = 1; j <= W; j++) 
    {
      ff[i][j] = ff[i - 1][j];
      if( w[i] <= j )
        ff[i][j] = max(ff[i][j], v[i] + ff[i - 1][j - w[i]]);
    }
  }
}

int main() 
{
  scanf("%d %d", &n, &W);
  for(int i = 1; i <= n; i++)
  {
    scanf("%d %d", w + i, v + i);
  }
  solution();
  printf("%lld\n", ff[n][W]);
  return 0;
}

Measured memory_bytes: 79360
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");

		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		int c = Integer.parseInt(cut[2]);

		System.out.println(Math.abs(a - b) <= Math.abs(a - c) ? "A" : "B");
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

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

    vi funami(n), used(n, 1);
    rep(i, n) {
        int cnt = 0, p = -1;
        rep(j, n) {
            cnt += used[j];
            if (cnt == data[j] && used[j]) {
                p = j;
            }
        }
        if (p != -1) {
            funami[i] = data[p];
            used[p] = 0;
        } else {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    reverse(all(funami));
    rep(i, n) {
        std::cout << funami[i] << std::endl;
    }

    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
map<string,int> restaurant;
vector<pair<int,int> > G[101]; //score, number

int main(void) {
    cin>>N;

    string s;
    int p;
    for(int i = 1;i <= N;i++) {
        cin>>s>>p;
        if(restaurant.count(s) == 0) {
            restaurant[s] = restaurant.size();
        }
        G[restaurant[s]].push_back(make_pair(p,i));
    }

    for(int i = 0;i < N;i++) {
        sort(G[i].begin(),G[i].end(),greater<pair<int,int> >());
    }

    for(auto it:restaurant) {
        for(int j = 0;j < G[it.second].size();j++) {
            cout<<G[it.second][j].second<<endl;
        }
    }

    return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define df 0
using namespace std;
typedef long int li;

int main(){
  int n; cin >> n;
  std::vector<li> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  std::sort(a.begin(),a.end());
  li s=0,cnt=0;
for(int i=0;i<n;i++){
  if(df)printf("%d %d:",s,2*a[i]);
    if(2*s<a[i])cnt=0;
    s+=a[i];
    cnt++;
    if(df)printf("%d %d/ ",s,cnt);
  }
  cout << cnt;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 998244353;



int main()
{
    IOS
    int n;
    cin >> n;
    ll mx = 0;
    vector<ll> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    vector<int> cnt(mx+1);
    for(auto val : a) {
        for(int j=val;j<=mx;j+=val) cnt[j]++;
    }
    int res = 0;
    for(auto val : a) if(cnt[val] == 1) res++;
    cout << res << endl;
    return 0; 
}



Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

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

int h,w;
vector<vector<char>> d(410, vector<char>(410,'?'));
vector<vector<bool>> used(410, vector<bool>(410,false));

ll bfs(int x, int y){
  ll wh=0,bl=1;
  queue<P> q;
  q.push({x,y});
  used[x][y]=true;

  while(!q.empty()){
    P p = q.front(); q.pop();
    rep(i,4){
      int nx = p.F+dx[i], ny = p.S+dy[i];
      if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
      if(used[nx][ny]) continue;
      if(d[p.F][p.S]==d[nx][ny]) continue;
      q.push({nx,ny});
      used[nx][ny] = true;
      if(d[nx][ny]=='.'){ wh++; } else { bl++; }
    }
  }
  return wh*bl;
}

int main() {
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> d[i][j];

  ll ans = 0;
  rep(i,h)rep(j,w)if(d[i][j]=='#' && !used[i][j]){
    ans += bfs(i,j);
  }

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

Measured memory_bytes: 512
import scala.io.StdIn

object Main extends App {
  def fun(o: Char, operand: Int): Int = {
    if (o == '+') {
      operand + 1
    } else if (o == '-') {
      operand - 1
    } else {
      operand
    }
  }

  val a = StdIn.readLine.toCharArray
  var r = 0
  r = fun(a(0), r)
  r = fun(a(1), r)
  r = fun(a(2), r)
  r = fun(a(3), r)
  println(r)
}

Measured memory_bytes: 25420
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

int mb[1000000+9];
int main(){
    GO();
    int n;
    cin>>n;int cnt=0;
    for(int i=1;i<=n;i++){
        int rem=n-i;
        if(i==rem||mb[i]||rem==0) continue;
        mb[rem]=1;
        cnt++;
    }
    cout<<cnt<<endl;
}

































Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    int bad = 0,good = 0;
    rep(i,n){
        int x; cin >> x;
        if(x % 4 == 0) good++;
        if(x % 2 != 0) bad++;
    }
    if(bad-n%2-good <= 0) yes();
    else no();
    return 0;
}


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

int N, D, X;


int main(){

	cin >> N;
	cin >> D >> X;
	int A[N];
	int ans=X;
	for(int i=0; i<N;i++) {
		cin >> A[i];
		int tmp = A[i];
		A[i]++;
		ans++;
		while(A[i]<=D){
			// cout << A[i] << endl;
			ans++;
			A[i]+=tmp;
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vector<pair<int, int>> index(q);
    rep(i,q) {
        cin >> index[i].first >> index[i].second;
        index[i].first--; index[i].second--;
    }
    // 左にAがあるCの数を数える
    vector<int> cnt(n,0);
    for (int i = 1; i < n; i++)
    {
        if (s[i-1] == 'A' && s[i] == 'C')
        {
            cnt[i]++;
        }
        cnt[i] += cnt[i-1];
    }
    
    rep(i,q) {
        int ans = cnt[index[i].second] - cnt[index[i].first];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
int  main()
{
	char s1[10],s2[10];
	int num=0;
	scanf("%s%s",s1,s2);
	for(int i=0;i<3;i++)
	{
		if(s1[i]==s2[i])num++; 
	}
	printf("%d\n",num);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int MAX_N = 400;
const ll INF = 1e18;

int N;
vector<ll> a;
ll memo[MAX_N + 1][MAX_N + 1];
ll SUM[MAX_N+ 10];

ll rec(int l, int r){
    if(r - l == 0) return 0;
    if(memo[l][r] != 0) return memo[l][r];

    ll ans = INF;
    for(int md = l; md < r; md++){
        chmin(ans, rec(l, md) + rec(md + 1, r) + SUM[r] - SUM[l-1]);
    }
    return memo[l][r] = ans;
}

int main(){
    cin >> N;
    a.resize(N+1);
    a[0] = 0;
    for(int i = 1; i <= N; i++) cin >> a[i];
    for(int i = 0; i <= N; i++){
        if(i == 0) SUM[i] = 0;
        else SUM[i] = SUM[i-1] + a[i];
    }

    cout << rec(1, N) << endl;
}

Measured memory_bytes: 1536
while(True):
    try: p,q = map(int,input().split())
    except: break
    ansstr = ""
    checked = [p%q]
    while(True):
        ans,p = divmod(p*10,q)
        ansstr += str(ans)
        if p == 0:
            print(ansstr)
            break
        if p in checked:
            ansind = checked.index(p)
            print(ansstr)
            print(" "*(ansind)+"^"*(len(checked)-ansind))
            break
        else: checked.append(p)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e=0,f=0;
  vector<string> s;
  string w;
  bool ans=true;
  cin >>a;
  cin >>w;
  s.push_back(w);
  for(int n=1;n<a;n++){
      cin >>w;
      for(int n=0;n<s.size();n++){
	  if(w==s[n]) ans=false;
      }
      if(s[s.size()-1][s[s.size()-1].size()-1]!=w[0]) ans=false;
      s.push_back(w);
  }
  if(ans) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
#define db long double
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=3010;
const db Pi=acos(-1.0);
struct Point {
    db x,y;
    Point(db x=0,db y=0): x(x),y(y) {}
    friend Point operator +(Point A,Point B) { return Point(A.x+B.x,A.y+B.y); }
    friend Point operator -(Point A,Point B) { return Point(A.x-B.x,A.y-B.y); }
    friend Point operator *(Point A,db B) { return Point(A.x*B,A.y*B); }
    friend Point operator /(Point A,db B) { return Point(A.x/B,A.y/B); }
    db dis() { return sqrt(x*x+y*y); }
    db dis2() { return x*x+y*y; }
};
int n;
db L,T[N<<1];
inline Point get(db ag) { return Point(cos(ag*2*Pi/L),sin(ag*2*Pi/L)); }
int main() {
    rd(n); scanf("%Lf",&L);
    for(int i=1;i<=n;++i) scanf("%Lf",&T[i]),T[i+n]=T[i]+L;
    Point ans;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=i+n-2;++j)
			ans=ans+get((T[i]+T[j])/2)*(n-(j-i+1));
	ans=ans/((ll)n*(n-1)*(n-2)/6);
	printf("%.10Lf %.10Lf",ans);
	return 0;
}

Measured memory_bytes: 384