akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
  ll n;cin>>n;
  if(n==0)cout<<1;
  else cout<<0;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Graph vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    ll ans = 0;
    for(int i = 0;i < N;i++){
        cin >> V[i];
    }
    for(int i = 0;i < N;i++){
        cin >> C[i];
        if(V[i] - C[i] > 0){
            ans += V[i] - C[i];
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_S = 8000;
bool dp[MAX_S+1][MAX_S+1];
int size;
string S;
int x, y;


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

  cin >> S;
  cin >> x >> y;
  size = S.size();

  bool first = false;
  vector<int> xv,yv;
  int count = 0, tmp = 0;
  for (int i = 0; i < size; ++i) {
    if (S[i] == 'F') ++tmp;
    if (S[i] == 'T' || i+1 == size) {
      if (count%2 == 0) xv.push_back(tmp);
      else yv.push_back(tmp);
      tmp = 0;
    }
    if (S[i] == 'T') ++count;
  }

  bool judge;
  if (xv.size() == 1) {
    if (x == xv[0]) judge = true;
    else judge = false;
  } else {
    dp[1][xv[1]] = true;
    for (int i = 2; i < xv.size(); ++i) {
      for (int j = 0; j <= size; ++j) {
        dp[i][j] = dp[i-1][abs(j-xv[i])];
        if (abs(j+xv[i]) <= size) dp[i][j] |= dp[i-1][abs(j+xv[i])];
      }
    }
    judge = dp[xv.size()-1][abs(x-xv[0])];
  }


  if (yv.size() == 0) {
    if (judge && y == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }

  memset(dp, false, sizeof(dp));
  dp[0][yv[0]] = true;
  for (int i = 1; i < yv.size(); ++i) {
    for (int j = 0; j <= size; ++j) {
      dp[i][j] = dp[i-1][abs(j-yv[i])];
      if (abs(j+yv[i]) <= size) dp[i][j] |= dp[i-1][abs(j+yv[i])];
    }
  }
  judge &= dp[yv.size()-1][abs(y)];

  if (judge) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int cnt=0,i;
    for(i=0; i<s.size()/2; i++)
    {
        //cout<<s[i]<<" "<<s[s.size()-i-1]<<endl;
       if(s[i]==s[s.size()-i-1])
        {

        }
        else
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    if N * 2 > M {
        println!("{}", M / 2);
    } else {
        println!("{}", N + ((M - (2 * N)) / 4));
    }
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int arr[2][N] , n , k , l , a , b , sz[2][N];
map<pair<int,int> , int > mp;

void init(int id){
	for(int i = 1 ; i < N ; ++i){
		arr[id][i] = i; 
		sz[id][i] = 1;
	}
}

int root(int id , int i){
	while(arr[id][i] != i)
		i = arr[id][i];
	return i;
}

void uni(int id , int a , int b){

	int ra = root(id , a);
	int rb = root(id , b);
	if(ra != rb){
		if(sz[id][ra] < sz[id][rb]){
			arr[id][ra] = rb;
			sz[id][rb] += sz[id][ra];	
		}
		else{
			arr[id][rb] = ra;
			sz[id][ra] += sz[id][rb];
		}
	}
}

int32_t main(){
	boost;
       //code
	init(0);
	init(1);


	cin >> n >> k >> l;

	for(int i = 0 ; i < k ; ++i){
		cin >> a >> b;
		uni(0,a,b);
	}


	for(int i = 0 ; i < l ; ++i){
		cin >> a >> b;    	
		uni(1,a,b);
	}

	for(int i = 1 ; i <= n ; ++i){
		mp[{root(0,i) , root(1,i)}]++;
	}

	for(int i = 1 ; i <= n ; ++i){
		cout << mp[{root(0,i) , root(1,i)}] << " ";
	}
	return 0;
}


Measured memory_bytes: 18304
def main():
    A = int(input())
    B = int(input())
    if (A==1 and B==2) or (A==2 and B==1):
        print(3)
    elif (A==1 and B==3) or (A==3 and B==1):
        print(2)
    else:
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[10^^5] XS, LS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (i, x; readln.split.to!(int[])) {
        XS[i] = x;
    }

    if (N >= M) {
        writeln("0");
        return;
    }
    
    sort(XS[0..M]);
    foreach (i; 0..M-1) {
        LS[i] = abs(XS[i] - XS[i+1]);
    }
    sort!"a > b"(LS[0..M-1]);

    writeln(reduce!"a + b"(0, LS[N-1..$]));
}

Measured memory_bytes: 5192
W,H,N = map(int,input().rstrip().split(" "))
T = 0
B = H
R = W
L = 0
for i in range(N):
    x,y,a = map(int,input().rstrip().split(" "))
    if a == 1:
        L = max(L,x)
    elif a == 2:
        R = min(R,x)
    elif a == 3:
        T = max(T,y)
    elif a == 4:
        B = min(B,y)
print(max((B - T),0) * max((R - L),0))

Measured memory_bytes: 9220
key = ".,!? -abc-def-ghi-jkl-mno-pqrs-tuv-wxyz".split("-")

gets.to_i.times {
  inp = gets.split(//).map{|i|i.to_i}
  x = t = 0
  while x < inp.length
    if inp[x] == 0 && t != 0
      case inp[x-1]
      when 1
        print key[inp[x-1]-1][(t-1)%5]
      when 2..6, 8
        print key[inp[x-1]-1][(t-1)%3]
      when 7, 9
        print key[inp[x-1]-1][(t-1)%4]
      end
      t = 0
    elsif inp[x] != 0
      t += 1
    end
    x += 1
  end
  print "\n"
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k%2){
        cout << b - a << endl;
    }else{
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3624
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
// ここから
function main(){
  for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
    var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
    var longest = inputArray[2];
    var middle = inputArray[1];
    var shortest = inputArray[0];
 
      console.log((longest*longest -  middle*middle - shortest*shortest) ? 'NO' : 'YES');
  }
}

Measured memory_bytes: 10372
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k;
const int K=15;
const ll MOD=998244353;
int intervals[K][2];
const int N=2e5+5;
ll seg[4*N];

void update(int index,ll data,int segindex,int l,int r)
{
    if(l==r){
        seg[segindex]=data%MOD;
        return ;
    }
    int mid=(l+r)/2;
    if(index<=mid){
        update(index,data,2*segindex+1,l,mid);
    }else{
        update(index,data,2*segindex+2,mid+1,r);
    }
    seg[segindex]=seg[2*segindex+1]+seg[2*segindex+2]%MOD;
}

ll query(int index,int l,int r,int ql,int qr)
{
    if(l>=ql && r<=qr)  return seg[index];
    if(l>qr || r<ql)    return 0ll;
    int mid=(l+r)/2;
    ll q1=query(2*index+1,l,mid,ql,qr);
    ll q2=query(2*index+2,mid+1,r,ql,qr);
    return q1+q2%MOD;
}

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE    
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout); 
    #endif

    cin>>n>>k;
    for(int i=0;i<k;i++)    cin>>intervals[i][0]>>intervals[i][1];
    ll dp[n]={0};
    dp[n-1]=1;
    update(n-1,dp[n-1],0,0,n-1);
    
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<k;j++){
            int start=i+intervals[j][0];
            if(start>=n)    continue;
            int end=min(n-1,i+intervals[j][1]);
            dp[i]+=query(0,0,n-1,start,end);
            dp[i]%=MOD;
        }
        update(i,dp[i],0,0,n-1);
    }
    cout<<dp[0]<<"\n";  
}       

Measured memory_bytes: 9228
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
S = raw_input()
first = int(S[0]) * 10 + int(S[1])
second = int(S[2]) * 10 + int(S[3])
if 1 <= first <= 12 and 1 <= second <= 12:
    print 'AMBIGUOUS'
elif 1 <= first <= 12:
    print 'MMYY'
elif 1 <= second <= 12:
    print 'YYMM'
else:
    print 'NA'


Measured memory_bytes: 2688
#include<stdio.h>
int main(){
  int n,ans=0;
  scanf("%d",&n);
  long l[n+1];
  for(int i=1;i<=n;i++){scanf("%ld",&l[i]);}
  
  for(int a=1;a<=n-2;a++){
    for(int b=a+1;b<=n-1;b++){
      for(int c=b+1;c<=n;c++){
        if(l[a]!=l[b] && l[b]!=l[c] && l[c]!=l[a] && l[a]<l[b]+l[c] &&l[b]<l[a]+l[c] &&l[c]<l[b]+l[a])ans+=1;
      }
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;


int32_t main(){

string s;cin>>s;
int n=s.size();
if(n<6)cout<<"No"<<endl;
else{
if(s[2]==s[3]  && s[5]==s[4])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

}

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

void operation(int* stack, int* top, int(*fnc)(int, int))
{
  if (*top < 2) throw runtime_error("Error!");

  --(*top);
  stack[*top - 1] = fnc(stack[*top - 1], stack[*top]);
}

int main()
{
  int stack[110];
  char S[10];
  int top = 0;
  try
  {
    while (std::cin >> S)
    {
      if (S[0] == '+') operation(stack, &top, [](int a, int b) { return a + b; });
      else if (S[0] == '-') operation(stack, &top, [](int a, int b) { return a - b; });
      else if (S[0] == '*') operation(stack, &top, [](int a, int b) { return a * b; });
      else stack[top++] = atoi(S);
    }
  }
  catch (const exception& e)
  {
    cout << e.what() << endl;
    exit(1);
  } 

  std::cout << stack[--top] << std::endl;
  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
int a[10050],now_dir;
int n,m,k,b[105][105];

int main(){
	
	int i,j,x,y;
	scanf("%d%d%d",&n,&m,&k);
	for(i=x=y=1;i<=k;i++){
		scanf("%d",&j);
		while(j--){
			b[x][y]=i;
			int tx=x+dx[now_dir],ty=y+dy[now_dir];
			if(tx<1||tx>n||ty<1||ty>m||b[tx][ty])
				now_dir=(now_dir+1)%4;
			x+=dx[now_dir],y+=dy[now_dir];
		}
	}
	
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)
			cout<<b[i][j]<<' ';
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 384
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[200007],b[200007];
bool cmp(int x,int y){
    return x>y;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    long long k;
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    for(int i=1;i<=n;++i)
        cin>>b[i];
    sort(a+1,a+1+n,cmp);
    sort(b+1,b+1+n);
    long long l=0,r=1e12;
    long long ans=-1;
    while(l<=r){
        long long mid=(l+r)>>1;
        long long tamp=0;
        for(int i=1;i<=n&&tamp<=k;++i)
            if(1ll*a[i]*b[i]>mid)
                tamp+=a[i]-mid/b[i];
        if(tamp<=k){
            ans=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        vll a(5);
        rep(i, 5) cin >> a[i];
        sort(a.begin(), a.end());

        ll ans = ll_inf;
        do {
            ll tmp = 0;
            rep(i, 5) {
                if (tmp % 10 == 0) tmp += a[i];
                else tmp += (10 - tmp % 10), tmp += a[i];
            }
            ans = min(tmp, ans);
        } while (next_permutation(a.begin(), a.end()));
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  while(cin>>n,n){
    int a[1001];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
     
    int ans=1e9;
    for(int i=1;i<n;i++)ans=min(ans,a[i]-a[i-1]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3128
//AtCoder ABC070 B - Two Switches
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll ans=0;
    ll base=min(B-A,D-C);
    if(A>D||C>B){
        //0
    } else if(B>D){
		ans = min(D - A, base);
	} else {
    	ans = min(B - C, base);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
     public static void main(String [] args){
          Scanner sc=new Scanner(System.in);
          int a=sc.nextInt();
          int b=sc.nextInt();
          int c=sc.nextInt();
          int x;
          if(a>=b && b>=c){
               x=a*10+b;
               System.out.print(x+c);
          }
          else if(a>=b&&c>=b&&a>=c){
               x=a*10+c;
               System.out.print(x+b);
          }
          else if(b>=a&&a>=c){
               x=b*10+a;
               System.out.print(x+c);
          }
          else if(b>=a&&c>=a&&b>=c){
               x=b*10+c;
               System.out.print(x+a);
          }
          else if(c>=a&&a>=b){
               x=c*10+a;
               System.out.print(x+b);
          }
          else if(c>=a&&b>=a&&c>=b){
               x=c*10+b;
               System.out.print(x+a);
          }      
     }
}

Measured memory_bytes: 21844
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/05/20 20:45:24
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;

template <long long MOD>
class modular {
 private:
  long long val_;

 public:
  constexpr modular() : val_(0) {}
  constexpr modular(long long v) : val_(v%MOD) {
    if (val_ < 0) val_ += MOD;
  }

  constexpr long long val() const { return val_; }
  constexpr modular operator+(modular x) const { return (val() + x.val())%MOD; }
  constexpr modular operator+=(modular x) { return *this = *this + x; }
  constexpr modular operator++() { return *this += 1; }
  constexpr modular operator++(int) { modular c = *this; ++(*this); return c; }
  constexpr modular operator-(modular x) const { return (val() + MOD - x.val())%MOD; }
  constexpr modular operator-=(modular x) { return *this = *this - x; }
  constexpr modular operator--() { return *this -= 1; }
  constexpr modular operator--(int) { modular c = *this; --(*this); return c; }
  constexpr modular operator*(modular x) const { return (val() * x.val())%MOD; }
  constexpr modular operator*=(modular x) { return *this = *this * x; }
  friend constexpr modular pow(modular x, long long p) {
    modular t = 1;
    modular u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr modular operator/(modular x) const { return *this * pow(modular{x}, MOD-2); }
  constexpr modular operator/=(modular x) { return *this = *this / x; }

  constexpr bool operator==(modular x) const { return val() == x.val(); }
  constexpr bool operator!=(modular x) const { return val() != x.val(); }
  constexpr bool operator<(modular x) const { return val() < x.val(); };
  constexpr bool operator<=(modular x) const { return val() <= x.val(); };
  constexpr bool operator>(modular x) const { return val() > x.val(); };
  constexpr bool operator>=(modular x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, const modular& x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, modular& x) {
    return is >> x.val_;
  }

};

constexpr long long MOD = 1e9+7;
using mint = modular<MOD>;

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

  int n,k; cin>>n>>k;
  vector<int> V(n); for (auto& v:V) cin>>v;
  sort(V.begin(), V.end());
  mint ans = 1;
  long long d = 1;
  int s = 0;
  if (k%2 == 1) {
    ans = V.back();
    if (V.back() < 0)
      d = -1;
    s++;
    V.pop_back();
  }
  int l = 0, r = V.size()-1;
  while (s < k) {
    auto a = (long long)V[l]*V[l+1];
    auto b = (long long)V[r]*V[r-1];
    if (a*d > b*d) {
      ans *= a;
      l+=2;
    } else {
      ans *= b;
      r-=2;
    }
    s += 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[10];//字符串
    cin>>s;
    int a,b,c,d;
    a=s[0]-'0';//分离
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    for(int i=43;i<=45;i+=2){//本来准备用‘+’，‘-’的，后来想了想还是没用
        for(int j=43;j<=45;j+=2){
            for(int k=43;k<=45;k+=2){
                int ans=a;
                if(i==43){//厚颜无耻的判断
                    ans+=b;
                }
                else{
                    ans-=b;
                }
                if(j==43){
                    ans+=c;
                }
                else{
                    ans-=c;
                }
                if(k==43){
                    ans+=d;
                }
                else{
                    ans-=d;
                }
                if(ans==7){
                    cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;//只要输出一种
                    return 0;
                }
            }
        }
    }
    //cout<<int('-');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int last,x,n,c[200019];
ll ans;

int main() {
  cin >> n;
  ans=1;
  last=-1;

  for(int i=0; i<n; i++){c[i]=0;}
  
  for(int i=0; i<n; i++){
    cin >> x;
    if(x==last){continue;}
    last=x;
    ans = (ans+c[x])%1000000007;
    c[x]=ans;
  }

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

Measured memory_bytes: 1152
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
signed main() {
    ll n; cin >> n;
    vl cnt(1010);
    for(int i = 2; i <= n; i++) {
        int now =i;
        for(int j = 2; j <= now; j++) {
            while(now > 0 && now % j == 0) {
                cnt[j]++;
                now /= j;
            }
        }
    }
    ll ans = 1;
    rep(i,n+1)ans = ans*(cnt[i]+1)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var data = new Dictionary<long, long>();

            for (int i = 0; i < n; i++)
            {
                if (data.ContainsKey(a[i]))
                    data[a[i]]++;
                else
                    data.Add(a[i], 1);
            }
            var sort = data.OrderByDescending(x => x.Key);
            long ans = 0;
        
            long y = 0;
            foreach(KeyValuePair<long,long> x in sort)
            {
                if (y == 0 && x.Value >= 4)
                {
                    ans = x.Key * x.Key;
                    break;
                }
                if (x.Value >= 2)
                {
                    if (y == 0)
                        y = x.Key;
                    else
                    {
                        ans = y * x.Key;
                        break;
                    }
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 30432
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
    int n,s1,s2,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    s1=0;
    s2=0;
    for(i=n-1;i>=0;i=i-2)
    {
        s1=s1+a[i];
        if(i-1>=0)
            s2=s2+a[i-1];
    }
    printf("%d\n",s1-s2);
    return 0;
}


Measured memory_bytes: 128
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;

vector<ll> v[2003];
bool vis[2003];
ll level[2003];
ll dis[2003];
ll n, x, y;

ll mat[2001][2001];

void bfs(ll s)
{
    mem0(level);
	queue<ll> q;
	q.push(s);
	vis[s] = 1;
	while(!q.empty()){
		ll p = q.front();
		q.pop();
		for(auto i : v[p]){
			if(vis[i]) continue;
			level[i] = level[p] + 1;
			q.push(i);
			vis[i] = 1;
		}
	}

    repp(i, 1, n) mat[i][s] = mat[s][i] = level[i];
    // repp(i, 1, n) cout << level[i] << " "; cout << endl;
    // repp(i, 0, 1000) dis[level[i]]++;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    cin >> n >> x >> y;
    repp(i, 1, n - 1){
        v[i].pb(i + 1);
        v[i + 1].pb(i);
    }
    v[x].pb(y);
    v[y].pb(x);

    repp(i, 1, n){
        mem0(vis);
        bfs(i);
    }

    repp(i, 1, n) repp(j, 1, n) if(i <= j) dis[mat[i][j]]++;

    rep(i, 1, n) cout << dis[i] << endl;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

vll v(100);
ll n, a, tot, res = 0;
ll dp[99][99][3000];

ll call(ll pos, ll cnt, ll sum){
    if(pos >= n) return 0;
    if(dp[pos][cnt][sum] != -1) return dp[pos][cnt][sum];
    
    ll val1 = 0, val2 = 0, val3 = 0;
    ll totSum = v[pos] + sum;
    if(a * (cnt + 1) == totSum){
        val1 = 1 + call(pos + 1, cnt + 1, sum + v[pos]);
    } else {
        val2 += call(pos + 1, cnt + 1, sum + v[pos]);
    }
    val3 += call(pos + 1, cnt, sum);
    return dp[pos][cnt][sum] = val1 + val2 + val3;
}

int main(){
    #ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif
        cin >> n >> a;
        v.resize(n);

        FOR(i, 0, n) cin >> v[i];
        MEM(dp, -1);
        cout << call(0, 0, 0) << endl;
 
    #ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif

    return 0;
}

Measured memory_bytes: 233288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;



int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll>a(26,1);
  for(int i=0; i<n; i++){
    a[s[i]-'a']++;
  }
  
  //for(int i=0; i<26; i++) cout << a[i] << endl;
  
  ll ans = 1;
  for(int i=0; i<26; i++){
    ans*=a[i];
    ans%=mod;
  }
  
  cout << ans-1 << endl;
  
}
       
        
      
  
    


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cnt=0;
	if(s[2]==s[3]){

		cnt++;
	}
	if(s[4]==s[5]){
		
		cnt++;
	}
	if(cnt==2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
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;
}
ll f[110][26][26];
ll g[32][26][26],a[26][26],c[26][26];
char S[110];
int m,n;
int main() {
	scanf("%s",S+1); n=strlen(S+1);
	rd(m);
	for(int j=0;j<26;++j) {
		f[1][j][j]=(((int)S[1])!=(j+'a'));
		for(int k=0;k<26;++k) if(j!=k) f[1][j][k]=1e9;
		for(int i=2;i<=n;++i)
			for(int k=0;k<26;++k) {
				f[i][j][k]=1e18;
				for(int l=0;l<26;++l)
					if(k!=l) f[i][j][k]=min(f[i][j][k],f[i-1][j][l]);
				f[i][j][k]+=(((int)S[i])!=(k+'a'));
			}
	}
//	ll mi1=1e9; int p1=0,p2=0;
//	for(int j=0;j<26;++j)
//		for(int k=0;k<26;++k)
//			if(j!=k&&f[n][j][k]<mi1) mi1=f[n][j][k],p1=j,p2=k;
//	int q1=0,q2=1;
//	if(f[n][q1][q1]>f[n][q2][q2]) swap(q1,q2);
//	for(int j=2;j<26;++j)
//		if(f[n][j][j]<f[n][q1][q1]) q2=q1,q1=j;
//		else if(f[n][j][j]<f[n][q2][q2]) q2=j;
//	ll ans1=k*mi1,ans2=(k+1>>1)*f[n][q1][q1]+(k>>1)*f[n][q2][q2];
//	printf("%lld",min(ans1,ans2));
	memset(g,0x3f,sizeof(g));
	for(int j=0;j<26;++j)
		for(int k=0;k<26;++k)
			g[0][j][k]=f[n][j][k];
	int t=0;
	for(t=1;(1ll<<t)<=m;++t)
		for(int i=0;i<26;++i)
			for(int j=0;j<26;++j)
				for(int k=0;k<26;++k) if(j!=k)
					for(int l=0;l<26;++l)
						g[t][i][l]=min(g[t][i][l],g[t-1][i][j]+g[t-1][k][l]);
	for(int i=0;i<26;++i) for(int j=0;j<26;++j) a[i][j]=i==j?0:1e18;
	for(--t;t>=0;--t) if((1<<t)&m) {
		memset(c,0x3f,sizeof(c));
		for(int i=0;i<26;++i)
			for(int j=0;j<26;++j)
				for(int k=0;k<26;++k) if(j!=k)
					for(int l=0;l<26;++l)
						c[i][l]=min(c[i][l],g[t][i][j]+a[k][l]);
		memcpy(a,c,sizeof(c));
	}
	ll ans=1e18;
	for(int i=0;i<26;++i) for(int j=0;j<26;++j) ans=min(ans,a[i][j]);
	printf("%lld",ans);
}
/*
aba
4
*/

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

using namespace std;

typedef long long ll;
ll mod = 1000000007;
ll N_max = 100000;

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	std::vector<int> A(N,0);
	for (int i = 0; i <N; i++)
	{
		int value;
		cin >> value;
		A[value] += 1;
	}
	// for (int i = 0; i < N; ++i)
	// {
	// 	cout << A[i] << ":";
	// }
	// cout << endl;

	ll ans = 1;

	if (N%2 == 0){ 
		//cout << "even" << endl;
		for (int i = 0; i <N; i++)
		{
			if ( i%2 == 0 && A[i] == 0){
				ans = (ans * 2) % mod ;
			}
			else if(i%2 == 1 && A[i] == 2){
				continue;
			}
			else{
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else{
		//cout << "odd" << endl;
		for (int i = 0; i < N; i++)
		{
			if (i == 0 && A[i] == 1)continue;
			else if(i % 2 == 0 && A[i] == 2){
				ans = (ans *2) % mod;
				//cout << "ans = " << ans << endl;
			}
			else if(i % 2 == 1 && A[i] == 0)continue;
			else{
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<bool> via1(n,false),via2(n,false);
  
  for(int i=0;i<m;i++){
   int a,b;
    cin >> a >>b;
    if(a==1) via1[b-1]=true;
    if(b==1) via1[a-1]=true;
    if(a==n) via2[b-1]=true;
    if(b==n) via2[a-1]=true;
  }
 
  for(int i=1;i<n-1;i++){
   if(via1[i]&&via2[i]) {cout << "POSSIBLE" << endl;
                             return 0;
                        }
  }
  cout << "IMPOSSIBLE" << endl;
  
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
#define lowbit(x) (x)&(-x)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
int n, op , l , r , pos;
struct BIT{
    int len;
    char a[maxn];
    int c[maxn][26];
    void insert(int id , int x , int v){
        for(int i = id; i <= len; i+= lowbit(i)){
            c[i][x] += v;
        }return ;
    }
    int query(int id , int x){
        int ans = 0;
        for(int i = id; i; i-=lowbit(i)){
            ans += c[i][x];
        }
        return ans;
    }
}T;
int main()
{
    cin >> T.len;
    for(int i = 1; i <= T.len;i++)cin>>T.a[i];
    for(int i = 1; i <= T.len ; i++){
        int zz = T.a[i] - 'a';
        T.insert(i , zz , 1);
    }
    CASET{
        cin >> op;
        if(op == 1){
            char ch;
            cin >> pos >> ch;
            //更新
            T.insert(pos , T.a[pos]-'a',-1);
            T.insert(pos , ch-'a', 1);
            T.a[pos] = ch;
        }else{
            cin >> l >>r;
            int res = 0;
            for(int i = 0; i < 26;i++){
                if(T.query(r,i) - T.query(l-1,i))res++;
            }cout << res << endl;
        }
    }
}

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

using namespace std;

int N, a[100009];

void Ans (int win)
{
    if (win == 1) printf ("First\n");
    else printf ("Second\n");
    exit (0);
}

int gcd (int a, int b)
{
    int r;
    while (b)
        r = a % b, a = b, b = r;
    return a;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
int mv = 1;
while (1)
{
    int cntEven = 0, cntOdd = 0;
    for (int i=1; i<=N; i++)
        if (a[i] > 1)
            cntOdd += (a[i] & 1), cntEven += ((a[i] & 1) ^ 1);
    if (cntEven % 2 == 1) Ans (mv);
    if (cntEven == N - 1 && cntOdd == 1)
    {
        for (int i=1; i<=N; i++)
            if (a[i] & 1)
            {
                a[i] --;
                break;
            }
        int g = a[1];
        for (int i=2; i<=N; i++)
            g = gcd (g, a[i]);
        for (int i=1; i<=N; i++)
            a[i] /= g;
    }
    else Ans (3 - mv);
    mv = 3 - mv;
}
return 0;
}


Measured memory_bytes: 640
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
m = [2001] * n
f = [0] * n
sum = 0

m[0] = 0
f[0] = 1
v = 0

for i in range(n-1) :
    for j in range(n) :
        if (a[v][j] < m[j]) & (f[j] == 0) & (a[v][j] != -1):
            m[j] = a[v][j]
    
    min = 2001
    minj = 0
    for j in range(n) :
        if (m[j] < min) & (f[j] == 0):
            min = m[j]
            minj = j
    
    v = minj
    f[minj] = 1
    sum += min

print(sum)


Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  string s;
  cin >> s;
  rep(i, 3) {
    if (s[i] == '1') s[i] = '9';
    else s[i] = '1';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int h[N],a[N],b[N],s[N];
int main(){
	int x;
	scanf("%d",&x);
for(int  i=120;i>-120;i--){
	for(int  j=i-1;j>-120;j--){
		if(i*i*i*i*i-j*j*j*j*j==x){printf("%d %d",i,j);
		return 0;}
	}
}
return 0;
}


Measured memory_bytes: 3824
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))


N= input_one_number()
A = input_multiple_number_as_list()

if N == 0 and A[0] == 1:
	print(1)
	exit(0)
elif A[0] > 0:
	print(-1)
	exit(0)

edamax = [1]*(N+1)
for i in range(N):
	edamax[i+1] = edamax[i]*2 - A[i+1]

eda = A[-1]
ans = eda
for i in range(N):

	if eda > edamax[N+1-2-i]:
		if (eda+1)//2  > edamax[N+1-2-i]:
			print(-1)
			exit(0)
		else:
			eda = edamax[N+1-2-i]
	ans += eda
	eda += A[N+1-2-i]
	ans += A[N+1-2-i]



print(ans)




Measured memory_bytes: 668712
H, W = map(int,input().split())
a = [0]*H
for i in range(H):
    a[i] = list(map(int,input().split()))

ans = []
for y in range(H):
    for x in range(W-1):
        if a[y][x] % 2 == 1:
            a[y][x] -= 1
            a[y][x+1] += 1
            ans.append([y+1,x+1,y+1,x+2])

for i in range(H-1):
    if a[i][-1] % 2 == 1:
        a[i][-1] -= 1
        a[i+1][-1] += 1
        ans.append([i+1,W,i+2,W])

print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 30264
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int gaku;
    double w,h;
	while(scanf("%d,%lf,%lf",&gaku,&w,&h) != EOF){
	    int bmi = w / (h * h);
        bmi >= 25 ? cout << gaku << endl:cout << "";
	}
	return 0;
}

Measured memory_bytes: 1232
n = int(input())
A = []
for i in range(2):
    A.append(list(map(int, input().split())))

start = sum(A[0]) + A[1][-1]
B = [start]
for i in range(n - 1):
    start = start - A[0][-1 - i] + A[1][-2 - i]
    B.append(start)
print(max(B))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll ans=0;
    ll memory;
    cin>>memory;
    for(int i=1;i<N;i++){
        ll X;
        cin>>X;
        ans+=min((X-memory)*A,B);
        memory=X;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const double PI = acos(-1);

int main (){
    string s;
    int n;
    cin >> s;
    n = s.size();

    int l = 0, r = n-1, ans = 0; 
    while (l < r){
        if (s[l] != s[r]) ans++;
        l++, r--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 2566: Restore Calculation
// 2018.1.8 bal4u@uu

#include <stdio.h>
#include <string.h>

#define M 1000000007

int sz;
int a[52][10], b[52][10], c[52][10];
int ha[52], hb[52], hc[52];
int dp[52][2];

void pb(int a[52][10], int *h, char *p)
{
	int i, j, k;
	char *q = p;

	while (*p > ' ') p++; sz = p-q;
	i = 0; while (--p >= q) {
		h[i] = 0;
		if (*p != '?') a[i][0] = *p & 0xf, h[i]++;
		else { k = (p == q), j = 10-k; while (j--) a[i][j] = k, k++, h[i]++; }
		i++;
	}
}

int main()
{
	int i, k, aa, bb, cc, sum, dig, ca;
	char buf[55];

	while (fgets(buf, 55, stdin) && *buf != '0') {
		pb(a, ha, buf);
		fgets(buf, 55, stdin), pb(b, hb, buf);
		fgets(buf, 55, stdin), pb(c, hc, buf);

		memset(dp, 0, sizeof(dp));
	    dp[0][0] = 1;

		for (i = 0; i < sz; i++) for (k = 0; k < 2; k++) {
			for (aa = 0; aa < ha[i]; aa++) for (bb = 0; bb < hb[i]; bb++) for (cc = 0; cc < hc[i]; cc++) {
		        sum = a[i][aa] + b[i][bb] + k;
				dig = sum % 10, ca = sum / 10;
				if (dig == c[i][cc]) {
					dp[i+1][ca] += dp[i][k];
					if (dp[i+1][ca] >= M) dp[i+1][ca] -= M;
		        }
			}
		}
		printf("%d\n", dp[sz][0]);
	}
	return 0;
}



Measured memory_bytes: 1764
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
const ll mod=1e9+7;

bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}


void solve(){

    ll k,n;
    cin>>k>>n;

    intarr(a,n);
    sort(a,a+n);    
    ll ans=0;

    for(ll i=1;i<n;i++){
        ans= max(ans, a[i]-a[i-1]);
    }


    ll mx= k+a[0]-a[n-1];
    ans= max(ans,mx);
    cout<<k-ans;

    return;
}

int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 
    return 0;
}       

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    string af = "abcdefghijklmnopqrstuvwxyz";
    char c = '.';

    for (int i = 0; i < af.size(); ++i) {
        if (s.find(af[i]) == string::npos) {
            c = af[i];
            break;
        }
    }
    if (c == '.') cout << "None" << endl;
    else cout << c << endl;

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<stack>

using namespace std;

const int weight[10] ={1,2,4,8,16,32,64,128,256,512};

int main(void){
	int n;
	while(scanf("%d", &n) != EOF){
		stack<int> s;
		
		for(int i = 9; i >= 0; i--){
			if(n >= weight[i]){
				n-=weight[i];
				s.push(weight[i]);
			}
		}
		while(!s.empty()){
			printf("%d",s.top());
			s.pop();
			if(!s.empty())printf(" ");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
#ABC90 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


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

ans = 0
for i in range(1,n+1):
    p = n//i
    r = n%i
    ans += p*max(0,i-k) + max(0,r-k+1)
if k == 0:
    ans = n**2
print(ans)


Measured memory_bytes: 39408
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define repn(i,a,b) for (int i=(a);i>=(b);i--)
#define repq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define be begin()
#define en end()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll modInverse(ll a, ll m) 
{ ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0; while (a > 1){ ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } 
    if (x < 0) x += m0; return x; 
}
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;}
    return res;

}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<ll>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    ll n;
    cin>>n;
    ll a[n];ll x=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        x = x^a[i];
    }
    for(int i=0;i<n;i++)
    {
        
        cout<<(x^a[i])<<" ";
    }






}

int main() 
{ 
    


    solve();

        
    
    
    return 0; 
} 

Measured memory_bytes: 5088
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct bity
{
	#define d 63
	vector<ll> wek;
	bity(){}
	bity(int v)
	{
		wek.resize((v/d)+2, 0);
	}
	void ustaw(int v)
	{
		wek[v/d]|=(1LL<<(v%d));
	}
	void zeruj()
	{
		fill(wek.begin(), wek.end(), 0);
	}
	int licz()
	{
		int ret=0;
		for (const ll &i : wek)
			ret+=__builtin_popcountll(i);
		return ret;
	}
};
 
void oruj(bity &a, const bity &b)
{
	int r=min(a.wek.size(), b.wek.size());
	for (int i=0; i<r; i++)
		a.wek[i]|=b.wek[i];
}

int n;
char f[505][505];
bity B[10][505];
ll ans;
int C[10];
int cur[10];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",&f[i]);
	rep(i,n)rep(j,n)if(f[i][j]!='#')C[f[i][j]-'0']++;
	rep(x,10) rep(i,n) B[x][i] = bity(C[x]+5);
	for(int i=0;i<2*n-1;i++){
		for(int j=min(i,n-1);j>=max(0,i-n+1);j--){
			int x = j, y = i-j;
			if(f[x][y] != '#'){
				if(x) rep(w,10) oruj(B[w][x],B[w][x-1]);
				rep(w,10) ans += 1LL*w*(f[x][y]-'0')*(B[w][x].licz());
				B[f[x][y]-'0'][x].ustaw(cur[f[x][y]-'0']++);
			}
			else{
				rep(w,10) B[w][x].zeruj();
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 16256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	if nextString() == nextString() {
		fmt.Println("H")
	} else {
		fmt.Println("D")
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

// ---------- Util.


Measured memory_bytes: 640