akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void output_yn(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}


int main()
{
	int cnt, max = 0;
	string s, t;
	cin >> s >> t;

	for (int i = 0; i <= s.size() - t.size(); i++) {
		cnt = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] == t[j])
				cnt++;
		}
		if (cnt > max)
			max = cnt;
	}

	cout << t.size() - max << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1') count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
using namespace std;

char s[55][55];
int a[55][55];

int main(){
	int n,m;
	while(scanf("%d%d",&n,&m)==2){
		memset(a,0,sizeof(a));
		memset(s,0,sizeof(s));
		for(int i=1;i<=n;i++)	scanf("%s",s[i]+1);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(s[i][j]=='#'){
					a[i-1][j-1]++;
					a[i-1][j]++;
					a[i+1][j]++;
					a[i][j-1]++;
					a[i][j+1]++;
					a[i+1][j+1]++;
					a[i+1][j-1]++;
					a[i-1][j+1]++;
				}
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(s[i][j]=='#')	printf("#");
				else printf("%d",a[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if (c - a - b > 0 && (c-a-b)*(c-a-b)-4*a*b>0) {
		cout << "Yes\n";
	}
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const int MAX = 100000;

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

  V<int> l(q), r(q);
  rep(i, q) cin >> l[i] >> r[i];

  V<int> F(MAX + 10);
  for (int i = 2; i <= MAX; i++) {
    for (int j = i; j <= MAX; j += i) F[j]++;
  }

  int c = 0;
  V<int> cnt(MAX + 10);
  for (int i = 1; i <= MAX; i += 2) {
    if (F[i] == 1) {
      if (F[(i + 1) / 2] == 1) c++;
    }
    cnt[i] = c;
  }

  rep(i, q) {
    int ans = cnt[r[i]] - cnt[l[i] - 2];
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 4840
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n;
    cin  >> n;
    int i = 1;
    while(i <= n){
        i *= 2;
    }
    cout << i / 2;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    ll l[100002], r[100002];
    for(int i = 0; i < n; i++){
        cin >> l[i] >> r[i];
    }
    sort(l, l + n, greater<ll>());
    sort(r, r + n);
    ll ans1 = 0;
    ll t = 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            if(l[0] < 0){
                t = 0;
                if(r[0] > 0) break;
                ans1 = -r[0];
            }
            else{
                t = l[0];
                if(r[0] > l[0]) break;
                ans1 = l[0] * 2 - r[0];
            }
            t = -r[0];
        }
        else{
            if(l[i] < r[i - 1]) break;
            ans1 += l[i] - r[i - 1];
            t = l[i];
            if(l[i] < r[i]) break;
            ans1 += l[i] - r[i];
            t = -r[i];
        }
    }
    ans1 += abs(t);
    ll ans2 = 0;
    t = 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            if(r[0] > 0){
                t = 0;
                if(l[0] < 0) break;
                ans2 = l[0];
            }
            else{
                t = -r[0];
                if(r[0] > l[0]) break;
                ans2 = l[0] - r[0] * 2;
            }
            t = l[0];
        }
        else{
            if(l[i - 1] < r[i]) break;
            ans2 += l[i - 1] - r[i];
            t = -r[i];
            if(l[i] < r[i]) break;
            ans2 += l[i] - r[i];
            t = l[i];
        }
    }
    ans2 += abs(t);
    cout << max(ans1, ans2) << endl;
}

Measured memory_bytes: 1792
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
main=do
 [n,q]<-map read.words<$>getLine
 s<-getLine
 lr<-replicateM q (map(read.BS.unpack).BS.words<$>BS.getLine)
 mapM_ print (f q lr (array(0,n)((0,0):(zip[1..n](g n s 0)))))
  where g 1 _ i = [i]
        g n ('A':'C':s) i = (i+1):(g(n-1)('C':s)(i+1))
        g n (a:s) i = i:(g(n-1)s i)
        f 0 _ _ = []
        f q ([l,r]:lr) ac = (ac!(r-1)-ac!(l-1)):(f(q-1)lr ac)

Measured memory_bytes: 40956
#157
def main():
    N, M = map(int,input().split())
    num = [-1]*N
    for i in range(M):
        s, c = map(int,input().split())
        if(s==1 and c==0 and N!=1):
            print(-1)
            return
        if(num[s-1]==-1 or num[s-1]==c):
            num[s-1] = c
        else:
            print(-1)
            return
    result = ''
    for i in range(N):
        if(num[i]!=-1):
            result+=str(num[i])
        else:
            if(N==1):
                result+='0'
            elif(i==0):
                result+='1'
            else:
                result+='0'
    print(result)

main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<map>
#include<string>
using namespace std;
typedef pair<long long,int> P;
int str[40];
vector<string> se[40];
vector<int> e[40];
map<string,int> ct;
map<long long,int> dp[2];//00010:0がunused 1がused
int main(){
	int n;
	int i,j;
	while(1){
	scanf("%d",&n);
	if(n==0)return 0;
	dp[0].clear();
	dp[1].clear();	
	ct.clear();
	for(i=0;i<n;i++){
		se[i].clear();
		e[i].clear();
	}
	for(i=0;i<n;i++){
		char s[20];
		string name;
		scanf(" %s",s);
		name.append(s);
		ct[name]=i;
		int a,b;
		scanf("%d %d",&a,&b);
		str[i]=a;
		for(j=0;j<b;j++){
			name.clear();
			scanf(" %s",s);
			name.append(s);
			se[i].push_back(name);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<se[i].size();j++){
			e[i].push_back(ct[se[i][j]]);
		}
	}
	long long use=0;
	for(j=0;j<e[0].size();j++)use|=(long long)1<<(e[0][j]-1);
	dp[1][use]=str[0];
	for(i=1;i<n;i++){
		long long use=0;
		for(j=0;j<e[i].size();j++)if(e[i][j]>=i+1)use|=(long long)1<<(e[i][j]-i-1);
		dp[(i+1)%2].clear();
		map<long long,int>::iterator it;
		for(it=dp[i%2].begin();it!=dp[i%2].end();it++){
			P p=*it;
			long long used=p.first;
			int mx=p.second;
			dp[(i+1)%2][used>>1]=max(dp[(i+1)%2][used>>1],mx);
			if(!(used&1))dp[(i+1)%2][(used>>1)|use]=max(dp[(i+1)%2][(used>>1)|use],mx+str[i]);
		}
	}
	printf("%d\n",dp[n%2][0]);
	}
}

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

int main()
{
  int k, s, ans = 0;
  
  cin >> k >> s;
  
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int c = s - a - b;
      if (c >= 0 && c <= k) {
        ans++;
      }
    }
  }
  
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for ( int j = 0; j < 3; j++){
    for ( int i = 0; i < n; i++){
      if ( j == 0){
        cin >> a[i];
      } else if ( j == 1 ){
        cin >> b[i];
      } else {
        cin >> c[i];
      }
    }
  }
  sort(a, a+n);
  sort(b, b+n);
  sort(c, c+n);
  long long bc[n], cc[n];
  bc[0] = lower_bound(a, a+n,  b[0]) - a ;
  for ( int i = 1; i < n; i++){
    bc[i] = bc[i-1] + (long long)(lower_bound(a, a+n,  b[i]) - a);
  }
  for ( int i = 0; i < n; i++){
    int idx = (long long)(lower_bound(b, b+n,  c[i]) - b ) - 1;
    if ( idx >= 0){
     cc[i] = bc[idx];
    }else {
      cc[i] = 0;
    }
  }
  long long sum = 0;
  for ( int i = 0; i < n; i++){
    sum += cc[i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include <complex>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}


typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		vector<P> panai;
		for(int i=0;i<a;i++){
			double b,c;
			scanf("%lf,%lf",&b,&c);
			panai.push_back(complex<double>(b,c));
		}
		printf("%d\n",a-convex_hull(panai).size());
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    
    int p_1 = a * n;
    int p_2 = b;
    
    if(p_1 > p_2) cout << p_2 << endl;
    else if(p_1 < p_2) cout << p_1 << endl;
    else cout << p_1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  ll k;
  cin>>n>>k;
  ll a[n],f[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>f[i];
  }
  sort(a,a+n);sort(f,f+n,greater<ll>());
  ll ng=-1,ok=1e13;
  while(ok-ng>1){
    ll mid=(ng+ok)/2;
    ll temp=0;
    for(int i=0;i<n;i++){
      if(mid<a[i]*f[i]){
        temp+=(a[i]*f[i]-mid+f[i]-1)/f[i];
      }
    }
    if(temp<=k) ok=mid;
    else ng=mid;
    //cout<<ng<<' '<<ok<<endl;
  }
  cout<<ok<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

int main()
{
    int N;

    cin >> N;

    vector<ll> A(N);

    ll highest = 0;

    ll sum = 0;


    ll zero =0;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];

        sum += max(highest - A[i], zero);

        if (highest < A[i])
        {

            highest = A[i];
        }
    }


    cout << sum << endl;


    return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

int n;
int a[maxn];
int ans[maxn];

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=n;i>=1;i--)
    {
        int sum=0;
        for (int j=i*2;j<=n;j+=i) sum^=ans[j];
        ans[i]=(sum^a[i]);
    }
    vector<int> v;
    for (int i=1;i<=n;i++) if (ans[i]==1) v.pb(i);
    cout<<sz(v)<<endl;
    for (int i:v) cout<<i<<' ';
}



Measured memory_bytes: 6520
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int dp[45];
  dp[0]=dp[1]=1;
  for(int i=2;i<=45;i++) dp[i]=dp[i-1]+dp[i-2];

  cout<<dp[n]<<endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> X, std::vector<long long> Y){
    bool is_odd = (abs(X[0]) + abs(Y[0])) % 2;
    REP(i, N){
        if(is_odd != (abs(X[i]) + abs(Y[i])) % 2) {
            cout << -1 << endl;
            return;
        }
    }

    VLL move_list;
    if(!is_odd) move_list.PB(1);
    REP(i, 31) move_list.PB(1LL << i);

    cout << move_list.size() << endl;
    cout << move_list[0];
    REP1(i, move_list.size()) cout << " " << move_list[i];
    cout << endl;

    REP(i, N) {
        stack<char> st;
        RREP(j, move_list.size()-1){
            if(abs(X[i]) > abs(Y[i])){
                if(X[i] < 0) {
                    X[i] += move_list[j];
                    st.push('L');
                }else{
                    X[i] -= move_list[j];
                    st.push('R');
                }
            }else{
                if(Y[i] < 0){
                    Y[i] += move_list[j];
                    st.push('D');
                }else{
                    Y[i] -= move_list[j];
                    st.push('U');
                }
            }
        }

        while(!st.empty()){
            cout<< st.top();
            st.pop();
        }

        cout << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.util.BitSet;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        BTouitsu solver = new BTouitsu();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTouitsu {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.NextInt();
            char[] a = in.next().toCharArray(), b = in.next().toCharArray(), c = in.next().toCharArray();
            int res = 0;
            for (int i = 0; i < n; i++) {
                BitSet d = new BitSet(26);
                d.set(a[i]);
                d.set(b[i]);
                d.set(c[i]);
                int x = d.cardinality();
                x -= 1;
                res += x;
            }
            out.println(res);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(Writer out) {
            super(out);
        }

        public OutputWriter(File file) throws FileNotFoundException {
            super(file);
        }

        public OutputWriter(OutputStream out) {
            super(out);
        }

    }
}



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

int main(){

  ll sx,sy,tx,ty;
  cin >>sx>>sy>>tx>>ty;
  string s;

  for (ll i = 0; i < ty-sy; i++) {
    s.push_back('U');
  }

  for (ll i = 0; i < tx-sx; i++) {
    s.push_back('R');
  }

  for (ll i = 0; i < ty-sy; i++) {
    s.push_back('D');
  }

  for (ll i = 0; i < tx-sx; i++) {
    s.push_back('L');
  }

  s.push_back('L');


  for (ll i = 0; i < 1 +  ty-sy; i++) {
    s.push_back('U');
  }

  for (ll i = 0; i < 1 +  tx-sx; i++) {
    s.push_back('R');
  }

  s.push_back('D');
  s.push_back('R');

  for (ll i = 0; i < 1 +  ty-sy; i++) {
    s.push_back('D');
  }

  for (ll i = 0; i < 1 +  tx-sx; i++) {
    s.push_back('L');
  }

  s.push_back('U');


  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007 
using namespace std;
void solve(){
   ll n;
   cin>>n;
   ll a[n+1];
   ll b[n+1];
   ll c[n+1];
   for(ll i=1;i<=n;i++){
      cin>>a[i]>>b[i]>>c[i];
   }
   ll dp[n+1][3];
   dp[1][0]=a[1];
   dp[1][1]=b[1];
   dp[1][2]=c[1];
   for(ll i=2;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
   }
   cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 8304
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
int main(void){
    uint_fast16_t n;
    scanf("%" SCNuFAST16 "",&n);
    uint_fast64_t a[n];
    for(uint_fast16_t i=0;i<n;i++){
        scanf("%" SCNuFAST64 "",&a[i]);
        if(!a[i]){puts("0");exit(0);}
    }
    uint_fast64_t p=1;
    for(uint_fast16_t i=0;i<n;i++)if(a[i]>1000000000000000000/p){puts("-1\n");exit(0);}else p*=a[i];
    printf("%" PRIuFAST64 "\n",p);
    exit(0);
}


Measured memory_bytes: 2428
A=input()
d={}
for i in A:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1

flag=0

for num,i in enumerate(d.values()):
    #print(i)
    if i!=2:
        break
    if num==len(d)-1:
        flag=1
    
if flag==1:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;
    ll ary[n];
    rep(i,n) cin >> ary[i];
    sort(ary, ary+n, greater<ll>());
    // rep(i,n) cout << ary[i] << " ";
    ll ans = 0;
    REP(i,k,n)
    {
        ans += ary[i];
    }
    cout << ans << endl;
    
    
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,x;
    cin>>k>>x;
    if(500*k>=x)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 256
function compute(input){
	const arr = input.split(' ')
    const a = parseInt(arr[0])
    const b = parseInt(arr[1])
    console.log((a % 2 === 0 || b % 2 === 0 )? 'Even' : 'Odd')
}


compute(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var b = Console.ReadLine();
    char a3 = b[2];
    char a4 = b[3];
    char a5 = b[4];
    char a6 = b[5];
    if(a3 == a4&& a5 == a6){
      Console.WriteLine("Yes");
    }
    else{
      Console.WriteLine("No");
    }
  
      
  }
}

Measured memory_bytes: 11092
import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(N):
    t[i+1] = t[i]+(1 if S[i-1:i+1]=='AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(int(t[r]-t[l]))

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

int main() {
   string s1,s2,s3;
   cin >> s1 >> s2 >> s3;
   char a,b,c;
   a = s1.at(0) - 32;
   b = s2.at(0) - 32;
   c = s3.at(0) - 32;
   cout << a << b << c <<endl;
}

Measured memory_bytes: 3560
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

struct Point {double x, y;};

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s, t, u;
  double th =  M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main() {
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}


Measured memory_bytes: 2756
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x1=sc.nextInt();
    int y1=sc.nextInt();
    int x2=sc.nextInt();
    int y2=sc.nextInt();
    int dx=x2-x1;
    int dy=y2-y1;
    int x3=x2-dy;
    int y3=y2+dx;
    int x4=x3-dx;
    int y4=y3-dy;
    System.out.println(x3+" "+y3+" "+x4+" "+y4);
  }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define N 1100000
#define L 1000000
#define eps 1e-7
#define inf 1e9+7
#define db double
#define ll long long
#define ldb long double
using namespace std;
inline int read()
{
    char ch=0;
    int x=0,flag=1;
    while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*flag;
}
int main()
{
	ll a=read(),b=read(),c=read();
	if(c<=b+1)
	{
		cout<<b+c;
		return 0;
	}
	else
	{
		if(c-b<=a+1)cout<<b+c;
		else cout<<2*b+a+1;
		return 0;
	}
	return 0;
}

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

typedef long long ll;

const int MN = 200010;

int L, N;
int X[MN];
ll psum[MN], ans;

ll calc(int l, int r) {
    return psum[r] - (l? psum[l - 1] : 0);
}

void solve() {
    ans = max(ans, 1LL * L - X[0]);
    for(int i = 0; i < N; i++) {
        psum[i] = X[i];
        if(i) psum[i] += psum[i - 1];
    }
    for(int i = 0; i < N / 2; i++) {
        ll tmp = 0;
        tmp += 2 * psum[i];
        tmp += 2 * (1LL * L * i - calc(i + 2, 2 * i + 1)) + (L - X[i + 1]);
        ans = max(ans, tmp);

        tmp = 0;
        tmp += (i? 2 * psum[i - 1] : 0);
        tmp += X[i];
        tmp += 2 * (1LL * L * (i + 1) - calc(i + 1, 2 * i + 1));
        ans = max(ans, tmp);

        if(2 * i + 2 < N) {
            tmp = 0;
            tmp += 2 * psum[i];
            tmp += 2 * (1LL * L * (i + 1) - calc(i + 2, 2 * i + 2));
            tmp += (L - X[i + 1]);
            ans = max(ans, tmp);
        }
    }
}

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

    for(int i = 0; i < N; i++) {
        scanf("%d", &X[i]);
    }

    solve();
    for(int i = 0; i < N; i++) {
        X[i] = L - X[i];
    }
    reverse(X, X + N);
    solve();

    printf("%lld", ans);
}


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

const int N = 511;

struct Num {
  int val, pos;
  bool operator < (Num t) { return pos < t.pos; }
};

int n, res[N * N];
Num num[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    num[i].val = i;
    scanf("%d", &num[i].pos);
  }
  sort(num + 1, num + n + 1);
  for (int i = 1, t = 0; i <= n; ++i) {
    res[num[i].pos] = num[i].val;
    for (int j = 1; j < num[i].val; ++j) {
      while (res[++t]);
      if (t > num[i].pos) return !puts("No");
      res[t] = num[i].val;
    }
  }
  for (int i = n, t = n * n + 1; i >= 1; --i) {
    for (int j = 1; j <= n - num[i].val; ++j) {
      while (res[--t]);
      if (t < num[i].pos) return !puts("No");
      res[t] = num[i].val;
    }
  }
  puts("Yes");
  for (int i = 1; i <= n * n; ++i) printf("%d ", res[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 2176
N, M = map(int, input().split())
AB = []

for _ in range(N):
    AB_i = list(map(int, input().split()))
    AB.append(AB_i)
    
AB_sorted = sorted(AB)

num = 0
paied = 0

for AB_i in AB_sorted:
    a = AB_i[0]
    b = AB_i[1]
    
    paied += a * b
    num += b
    
    if num >= M:
        paied -= (num - M) * a
        break

print(paied)


Measured memory_bytes: 28656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long a, b, c, d;

	std::cin >> a >> b >> c >> d;

	long long takahashi = std::ceil(1.0 * c / b);
	long long aoki = std::ceil(1.0 * a / d);

	if (takahashi <= aoki) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, T;
  cin >> N >> T;
  vi32 A(N);
  cin >> A;
  int mi = 2e9;
  int cn = 0, diff = 0;
  rep(i, N) {
    if (mi > A[i]) {
      mi = A[i];
      continue;
    }
    if (A[i] - mi == diff) cn++;
    if (A[i] - mi > diff) {
      diff = A[i] - mi;
      cn = 1;
    }
  }
  cout << cn << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i64 dp[410][410];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n;
  cin >> n;
  vi64 a(n);
  vi64 sums(n + 1);
  rep(i, n) cin >> a[i];
  rep(l, 410) rep(r, 410) dp[l][r] = 1e18;
  partial_sum(all(a), sums.begin() + 1);
  reps(g, n) rep(l, n) {
    int r = min(n, l + g);
    if (l + 1 == r) {
      dp[l][r] = 0;
      continue;
    } else if (l + 2 == r) {
      dp[l][r] = a[l] + a[l + 1];
      continue;
    }
    repi(m, l + 1, r) {
      amin(dp[l][r], dp[l][m] + dp[m][r] + sums[r] - sums[l]);
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

int main(void) {
  priority_queue<int> PQ;
  
  int target;
  char command[8];
  
  while(1) {
    scanf("%s", command);
    if(command[0] == 'e' && command[1] == 'n') {
      break;
    }
    if(command[0] == 'i') {
      scanf("%d", &target);
      PQ.push(target);
    }
    else {
      printf("%d\n", PQ.top());
      PQ.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 5264
n=int(input())
s=input()
cnt=0

for i in range(10):
  for j in range(10):
    for k in range(10):
      x=s.find(str(i))
      if x!=-1:
        y=s.find(str(j),x+1)
        if y!=-1:
          z=s.find(str(k),y+1)
          if z!=-1:
            cnt+=1
print(cnt)

Measured memory_bytes: 3060
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iterator>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
    long long int n1=0,n=0,a=0,b=0,c=0,i,j=0,k,m=0,m1=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,x=0,y=0;
    cin>>a>>b>>c;
    a1=a+b+c;
    if(a1>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }


    return 0;


}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for (int i=0; i<N; i++)
            bit |= sc.nextInt();
        System.out.println(Integer.numberOfTrailingZeros(bit));


    }
}

Measured memory_bytes: 22996
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  ans = n / 500 * 1000;
  n %= 500;
  ans += n / 5 * 5;
  Cout(ans);
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	VL sk(n+2), zk(n+2);
	rep(i, n) sk[a[i]]++;
	for(auto x :sk) cerr<<x<<" "; dbg();
	ll sm = 0;
	rep(i, n+1){
		sm += sk[i] * (sk[i]-1) /2;
	}
	//dbg(sm);
	rep(i, n){
		ll x = sk[a[i]];
		ll w = x*(x-1)/2;
		ll z = sm - w;
		x -=1; 
		z += x*(x-1)/2;
		cout << z <<"\n";
		
	}
	
	return 0;


}


Measured memory_bytes: 6528
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
using namespace std;
 
int main(void){
  	int a,b,result=0;
	cin>>a>>b;
  	rep(i,2){
    	if(a>b){
          result+=a;
          a--;
        }else {
          result += b;
          b--;
        }
    }
 	cout<<result;
    return 0;
}

Measured memory_bytes: 256
#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<string,int>;

int main(){
  int n,d;
  cin >> n >> d;
  int x[n+10][d+10];
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i,n-1){
    for(int j = i+1;j < n;++j){
      int dis = 0;
      rep(k,d){
        dis += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      for(int l = 1;l*l <= dis;++l){
        if(l*l == dis) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int h,w;
    char str[100][100];
    int map[100][100]={{}};

    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",str[i]);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str[i][j]=='.'){
                map[i][j]=-1;
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            if(str[i][j]=='#'){
                if(str[i][j]==str[i][j+1]){
                    map[i][j]=map[i][j+1]=1;
                }
            }
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h-1;j++){
            if(str[j][i]=='#'){
                if(str[j][i]==str[j+1][i]){
                    map[j][i]=map[j+1][i]=1;
                }
            }
        }
    }
   
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(map[i][j]==0){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll n,m;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        m=n%1000;
        cout<<1000-m;
    }
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b>=0)
		cout<<(a+2*b-1)*a/2-b<<endl;
	else if(a+b-1>=0)
		cout<<(a+2*b-1)*a/2<<endl;
	else
		cout<<(a+2*b-1)*a/2-a-b+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))
import math
    
N, K = mi()
A = li()
 
#light = [0] * (N+2)
#A = [0] + A + [0]
#print(math.log(N, 2))
'''
thre = 0
for i in range(N):
    if A[i] < i:
        thre = max(thre, i-A[i])
'''
if K > pow(N, 0.5) + 1:
        for i in range(N):
            print(N, '', end='')
        print()
        exit()
 
 
for i in range(K):
    new = [0] * (N+1)
    for j in range(N):
        new[max(j-A[j], 0)] += 1
        new[min(j+A[j]+1, N)] += -1
        #print(new)
    new = list(accumulate(new))
    A = new[:N]
 
for i in range(N):
    print(A[i], '', end='')
print()

Measured memory_bytes: 182096
def find_root(x):
    if parent[x] == x:
        return x
    else:
        return find_root(parent[x])


# x,yの属する集合の併合
def unite(x, y):
    x = find_root(x)
    y = find_root(y)

    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
            size[y] += size[x]
        else:
            parent[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1


# xとyが同じグループかどうか判定
def same(x, y):
    return find_root(x) == find_root(y)


N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

parent = [i for i in range(N)]  # 根
rank = [1] * N  # 深さ
size = [1] * N  # iを根とするグループのサイズ

edge = [[xy[M - 1 - i][0] - 1, xy[M - 1 - i][1] - 1] for i in range(M)]
for i in range(M):
    a = find_root(edge[i][0])
    b = find_root(edge[i][1])
    unite(a, b)

ans = 0
for i in range(N):
    if p[i]-1 == i or same(p[i]-1, i):
        ans += 1
print(ans)

Measured memory_bytes: 50340
#include<stdio.h>

int main()
{
	int H,W,h,w;
	(void)scanf("%d %d",&H,&W);
	(void)getchar();
	(void)scanf("%d %d",&h,&w);

	printf("%d\n",( H - h ) * ( W - w ));
  return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100000;
const long long MOD = (int)1e9 + 7;
long long a[N+1];

int main(){
	int n, m;
	a[0] = 1;
	rep(i,1,N+1) a[i] = (ll)i * a[i-1] % MOD;
	while(cin >> n >> m) {
		if(n < m - 1 || m < n - 1) {
			cout << 0 << endl;
			continue;
		}
		int c = min(n, m);
		int d = max(n, m);
		long long ans = a[d];
		rep(i,1,c+1) ans = ans * i % MOD;
		if(c == d) ans = ans * (ll)2 % MOD;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

const int MX = 200000;
bool sieve[MX];

void prepare() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if ( ! sieve[i]) {
            for (int j=i*i; j<MX; j+=i) {
                sieve[j] = true;
            }
        }
    }
}

int main() {
    prepare();
    int n;
    while (cin >> n, n) {
        long long sum = 0;
        for (int i=0; 0<n; ++i) {
            if ( ! sieve[i]) {
                sum += i;
                n --;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1360
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

# INF = 10**10
# grief = INF
# for b in set(a):
#     tmp = sum([abs(ai - b) for ai in a])
#     if tmp < grief:
#         bb = b
#         grief = tmp

# print(grief)  # running time limit error

a.sort()
med = a[len(a) // 2]
grief = sum([abs(ai - med) for ai in a])
print(grief)


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main(){
	ll k;
	cin >> k;
	set<ll> Q;
	ll a = 0;
	ll i = 0;
	while(Q.find(a) == Q.end()){
		Q.insert(a);
		a = a*10 + 7;
		i++;
		a %= k;
		if(a == 0) break;
	}
	if(a == 0) cout << i << endl;
	if(a != 0) cout << -1 << endl;
}


Measured memory_bytes: 50492
d,g=map(int,input().split())
L=[]

for i in range(d):
    L.append([int(i) for i in input().split()])

C=[L[i][0]*(i+1)*100 for i in range(d)]

import itertools
itr=list(itertools.product([0,1],repeat=d))

def calc(key,g):
    cnt=0
    sco=0
    for i in range(d):
        if key[i]==1:
            cnt+=L[i][0]
            sco+=L[i][0]*(i+1)*100+L[i][1]
    rem=g-sco
    #print(rem)
    if rem<=0:
        return cnt
    for i in range(d-1,-1,-1):
        if key[i]==0:
            if rem-L[i][0]*(i+1)*100<=0:
                return cnt+((rem-1)//((i+1)*100))+1
            else:
                rem-=L[i][0]*(i+1)*100
                cnt+=L[i][0]
    return 10**7

ans=10**7
for key in itr:
    #print(key,calc(key,g),ans)
    ans=min(calc(key,g),ans)
print(ans)
    

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll a;
	cin >> a;
	string B;
	cin >> B;
	ll b;
	b = 100 * (B[0]-'0') + 10 * (B[2] - '0')+ 1 * (B[3] - '0');
	cout << (a * b) / 100 << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int x = 0;
	REP(i, n)x = gcd(x, v[i]);
	cout << x << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 200100;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = power(fact[b], mod-2);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r or r < 0 ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();
	ll n, a, b;
	cin >> n >> a >> b;
	ll x = 1;
	ll y = 1;
	for( ll k = n-a+1; k <= n; ++k ){
		x *= k;
		x %= mod;
	}
	x *= fact_inv[a];
	x %= mod;
	for( ll k = n-b+1; k <= n; ++k ){
		y *= k;
		y %= mod;
	}
	y *= fact_inv[b];
	y %= mod;
	cout << (power(2, n)-1-x-y+mod+mod+mod+mod)%mod << endl;
}

Measured memory_bytes: 6732