akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
void solve(){
    double a, b;
    cin >> a >> b;
    cout << a / b;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>

using namespace std;

int main(int argc, char const *argv[])
{
	long long int x,y;
	long long int res;

	cin >> x >> y;

	while(x<=y){
		x = x*2;
		res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    ll ans = 0;
    for (int a = 1; a <= n; a++) {
        if (n % a == 0)
            ans += max(0, n/a - 1);
        else 
            ans += max(0, n/a);
    }

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

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;
char C[100000];
char C2[100000];

void merge(int A[], int left, int mid, int right){
  int n1=mid-left,n2=right-mid,L[100000],R[100000];
  char Lc[100000]={},Rc[100000]={};
  for(int i=0;i<n1;i++){L[i] = A[left+i];Lc[i] = C2[left+i];}
  for(int i=0;i<n2;i++){R[i] = A[mid+i];Rc[i] = C2[mid+i];}
  L[n1]=R[n2]=INT_MAX;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]) {
      A[k]=L[i];
      C2[k]=Lc[i];
      i++;
    }
    else {
      A[k]=R[j];
      C2[k]=Rc[j];
      j++;
    }
  }
}
void mergeSort(int A[], int left, int right){
  if(left+1<right){
    int mid = (left + right) / 2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

void bsort(int  A[],int n){
  bool flag = 1;
  while(flag){
    flag = 0;
    for(int j = n-1; j >= 1; j--){
      if(A[j] < A[j-1]){
	swap(A[j],A[j-1]);
	swap(C2[j],C2[j-1]);
	flag = 1;
      }
    }
  }
}

int partition(int A[], int p, int r){
  int x=A[r], i=p-1;
  for(int j=p;j<r;j++)
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
      swap(C[i],C[j]);
    }
  swap(A[i+1],A[r]);
  swap(C[i+1],C[r]);
  return i+1;
}
void quicksort(int A[], int p, int r){
  if(p<r){
    int q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
int main(){
  int n,A[100000],B[100000];
  bool check=true;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>C[i]>>A[i];
    B[i]=A[i];
    C2[i]=C[i];
  }
  mergeSort(B,0,n);
  //bsort(B,n);
  quicksort(A,0,n-1);
  for(int i=0;i<n;i++)if(C[i]!=C2[i]){check=false;break;}
  if(check)cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  for(int i=0;i<n;i++){
    cout<<C[i]<<" "<<A[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin>>N;
	int ans = 0;
	FOR(i,1,N+1){
		if(10<=i&&i<=99)continue;
		if(1000<=i&&i<=9999)continue;
		if(100000<=i&&i<=999999)continue;
		ans += 1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
 
N, K = map(int, input().split())
 
ans = [0] * (10**5+1)
for i in range(N):
    a, b = map(int, input().split())
    ans[a] += b
 
remain = K
for i in range(10**5+1):
    if ans[i] == 0:
        continue
 
    remain -= ans[i]
    if remain <= 0:
        print(i)
        exit()

Measured memory_bytes: 5744
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Sum(A []int) int {
  S := 0
  for _, a := range A {
    S += a
  }
  return S
}

func Min(a, b int) int {
  if a < b { return a }
  return b
}

func main() {
  NM := NextIntVec()
  N := NM[0]
  M := NM[1]
  A := make([]int, M)
  K := make([]int, M)
  for i := range A {
    AB := NextIntVec()
    A[i] = AB[0]
    C := NextIntVec()
    for _, c := range C {
      K[i] += 1 << uint(c - 1)
    }
  }
  S := Sum(A)
  L := 1 << uint(N)
  DP := make([][]int, M + 1)
  for i := range DP {
    DP[i] = make([]int, L)
    for j := 0; j < L; j++ {
      DP[i][j] = S + 1
    }
  }
  DP[0][0] = 0
  for i := 0; i < M; i++ {
    for j := 0; j < L; j++ {
      DP[i + 1][j] = Min(DP[i][j], DP[i + 1][j])
      DP[i + 1][j | K[i]] = Min(DP[i][j] + A[i], DP[i + 1][j | K[i]])
    }
  }
  ans := DP[M][L - 1]
  if S < ans { ans = -1 }
  Write(ans)
  Output()
}

Measured memory_bytes: 33920
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll w,h,n,i,ans=0;
    scanf("%lld%lld%lld",&w,&h,&n);
    ll x[n],y[n],a[n],l,r,u,d;
    for(i=0;i<n;i++){
        scanf("%lld%lld%lld",&x[i],&y[i],&a[i]);
    }
    // for(i=0;i<w;i++){
    //     for(j=0;j<h;j++){
    //         color[w][h]=0;
    //     }
    // }
    l=0;
    r=w;
    d=0;
    u=h;
    for(i=0;i<n;i++){
        if(a[i]==1){
            // for(j=0;j<x[i];j++){
            //     for(k=0;k<h;k++){
            //         color[j][k]=1;
            //     }
            // }
            l=max2(l,x[i]);
        }
        if(a[i]==2){
            // for(j=x[i]+1;j<w;j++){
            //     for(k=0;k<h;k++){
            //         color[j][k]=1;
            //     }
            // }
            r=min2(r,x[i]);
        }
        if(a[i]==3){
            // for(j=0;j<w;j++){
            //     for(k=0;k<y[i];k++){
            //         color[j][k]=1;
            //     }
            // }
            d=max2(d,y[i]);
        }
        if(a[i]==4){
            // for(j=0;j<w;j++){
            //     for(k=y[i]+1;k<h;k++){
            //         color[j][k]=1;
            //     }
            // }
            u=min2(u,y[i]);
        }
    }
    // for(i=0;i<w;i++){
    //     for(j=0;j<h;j++){
    //         if(color[i][j]==0) ans++;
    //     }
    // }
    if(l<r && d<u) ans=(r-l)*(u-d);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    ans = 0
    n_white = 0
    for s in S[::-1]:
        if s == "W":
            n_white += 1
        else:
            ans += n_white

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

const int mod = 1e9+7;

int cnt[100005];

int ans;

int n;

void solve() {
    scanf("%d", &n);

    for (int i = 1, x; i <= n; ++i) {
        scanf("%d", &x);
        ++cnt[x];
    }

    ans = 1;

    for (int i = n - 1; i >= 0; i -= 2) {
        if (cnt[i] != 1 + (i > 0)) {
            printf("0\n");
            return;
        }

        ans *= cnt[i];
        ans %= mod;
    }

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

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
use strict;
use warnings;

my $n = int <>;

my %ans_list = ();

for (my $x = 1; $x <= 10**2; ++$x) {
    for (my $y = 1; $y <= 10**2; ++$y) {
        for (my $z = 1; $z <= 10**2; ++$z) {
            $ans_list{($x+$y+$z)**2-($x*$y + $y*$z + $z*$x)} += 1;
        }
    }
}

for (1..$n) {
    print( ((exists $ans_list{$_}) ? $ans_list{$_} : 0)."\n");
}

Measured memory_bytes: 9772
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
// set:T,map:f  TxT→T =(T,f)
// set:E,map:h ExE→E =(E,h)
//map: g:TxE→T
//1-index
template<typename T,typename E>
struct lazysegtree{
using F=function<T(T,T)>;
using G=function<T(T,E)>;
using H=function<E(E,E)>;
int n,height;
F f;G g;H h;T t;E e;
vector<T> dat;
vector<E> laz;
lazysegtree(int n_,F f,G g,H h,T t,E e):f(f),g(g),h(h),t(t),e(e){
    n=1;height=0;
    while(n<n_)n*=2,height++;
    dat.assign(2*n,t);
    laz.assign(2*n,e);
}
lazysegtree(int n_,vector<T> &v,F f,G g,H h,T t,E e):f(f),g(g),h(h),t(t),e(e){
    n=1;height=0;
    while(n<n_)n*=2,height++;
    dat.assign(2*n,t);
    for(int i=n;i-(n-2)<v.size();i++)dat[i]=v[i-(n-2)];
    for(int i=n-1;i>0;i--)dat[i]=f(dat[i*2+1],dat[i*2+2]);
    laz.assign(2*n,e);
}
inline T reflect(int k){
    return (laz[k]==e?dat[k]:g(dat[k],laz[k]));
}
inline void eval(int k){
    if(laz[k]==e)return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    dat[k]=reflect(k);
    laz[k]=e;
}
inline void thrust(int k){
    for(int i=height;i>0;i--)eval(k>>i);
}
inline void recalc(int k){
    while(k>>=1)dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
}
void update(int a,int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
        if(l&1)laz[l]=h(laz[l],x),l++;
        if(r&1)--r,laz[r]=h(laz[r],x);
    }
recalc(a);
recalc(b);
}
void set_val(int a,T x){
    thrust(a+=n);
    dat[a]=x;laz[a]=e;
    recalc(a);
}
T query(int a,int b){
    thrust(a+=n);
    thrust(b+=n-1);
    T vl=t,vr=t;
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
        if(l&1)vl=f(vl,reflect(l++));
        if(r&1)vr=f(reflect(--r),vr);
    }
    return f(vl,vr);
}
};
int main(){
ll n,q;
cin>>n>>q;
auto f=[](P a,P b){return P(a.fi+b.fi,a.se+b.se);};
auto g=[](P a,ll b){return P(a.fi+a.se*b,a.se);};
auto h=[](ll a,ll b){return a+b;};
V<P> element(n,P(0,1));
lazysegtree<P,ll> tree(n,element,f,g,h,P(0,1),0);
int c;
while(q--){
    cin>>c;
    if(c){
        int s,t;
        cin>>s>>t;
        s--;t--;
        cout<<tree.query(s,t+1).fi<<endl;
    }
    else{
        int s,t;ll x;
        cin>>s>>t>>x;
        s--;t--;
        tree.update(s,t+1,x);
    }
}
}


Measured memory_bytes: 10412
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on
const string YES = "Yes";
const string NO = "No";

void solve(std::string S) {
  // solver code

  if (S == "AAA" || S == "BBB") {
    cout << NO << endl;
  } else {
    cout << YES << endl;
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,m;
	cin>>n>>m;
	if(n==1){
		if(m==1){
			cout<<1<<endl;
		}else if(m==2){
			cout<<0<<endl;
		}else{
			cout<<m-2<<endl;
		}
	}else if(n==2){
		if(m==1){
			cout<<0<<endl;
		}else{
			cout<<0<<endl;
		}
	}else{
		if(m==1){
			cout<<n-2<<endl;
		}else if(m==2){
			cout<<0<<endl;
		}else{
			cout<<(n-2)*(m-2)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    k-=q;
    vector<ll> a(n,k);
    rep(i,q){
        int x;
        cin>>x;
        --x;
        a[x]++;
    }
    rep(i,n){
        cout<<(a[i]>0?"Yes":"No")<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int[][] land = new int[12][12];
		int count = 0;
		ArrayList<Integer> islandCount = new ArrayList<>();

		while (in.hasNext()) {

			for (int i = 0; i < 12; i++) {

				String a = in.next();

				for (int j = 0; j < 12; j++) {

					char b = a.charAt(j);
					int c = Integer.parseInt(b + "");
					land[i][j] = c;

				}
			}

			for (int i = 0; i < 12; i++) {

				for (int j = 0; j < 12; j++) {

					if (land[i][j] == 1) {

						island(land, i, j);

						count++;

					}
				}
			}

			System.out.println(count);
			count = 0;

		}

	}

	private static void island(int[][] land, int i, int j) {

		if (land[i][j] == 1) {

			land[i][j] = 0;

			if (i > 0) {

				island(land, i - 1, j);

			}

			if (i < 11) {

				island(land, i + 1, j);

			}

			if (j > 0) {

				island(land, i, j - 1);

			}

			
			if (j < 11) {

				island(land, i, j + 1);

			}

		} else {

			return;

		}

		/*
		 * if(land[i + 1][j] == 0 && land[i - 1][j] == 0 && land[i][j + 1] == 0 &&
		 * land[i][j - 1] == 0) {
		 *
		 * land[i][j] = 0;
		 *
		 * } else if(land[i + 1][j] == 1 || land[i - 1][j] != 0 || land[i][j + 1] != 0
		 * || land[i][j - 1] != 0){
		 *
		 * island(land, i + 1, j);
		 *
		 * } else if(land[j + 1][j] == 1 && land[i + 1][j] == 0 || land[i - 1][j] != 0
		 * || land[i][j - 1] != 0) {
		 *
		 * island(land, i, j + 1);
		 *
		 * } else if(land[i][j - 1] == 1 && land[i + 1][j] == 0 || land[i - 1][j] != 0
		 * || land[i][j - 1] != 0){
		 *
		 * island(land, i, j - 1);
		 *
		 * } else if(land[i][i - 1] == 1 && land[i + 1][j] == 0 || land[i][j + 1] != 0
		 * || land[i][j - 1] != 0){
		 *
		 * island(land, i - 1, j);
		 *
		 * }
		 *
		 * land[i][j] = 0;
		 */

	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll n, k;
  cin >> n >> k;
  vector<ll> H(n);
  rep(i, n) cin >> H[i];

  sort(begin(H), end(H));
  ll sum = 0;
  for (ll i = 0; i < n - k; i++)
  {
    sum += H[i];
  }

  cout << sum << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc138/tasks/abc138_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red") << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : C - Fennec vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; cin >> N >> K;
	vector<int> v;
	rep(i, N) { int t; cin >> t; v.pb(t); }
	sort(all(v));
	ll ans = 0;
	rep(i, N-K) ans += v[i];
	cout << ans << endl;
}



Measured memory_bytes: 1400
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


city_num, start_pos = list(map(int, input().split()))
city_list = list(map(int, input().split()))

# スタート位置を入れて
city_list.append(start_pos)
# 昇順に並び替え
city_list.sort()

# city毎の距離のリストを生成する
distance_list = [city_list[i+1] - city_list[i] for i in range(city_num)]

# 距離が一つならそれを出力
if len(distance_list) == 1:
    print(distance_list[0])
    exit()

# 昇順に並び替え
distance_list.sort()

# 最大公約数を求める
max_gcd = gcd(distance_list[0], distance_list[1])
for i in range(2, len(distance_list)):
    max_gcd = gcd(max_gcd, distance_list[i])

# 出力
print(max_gcd)


Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int x,y,t;
	cin>>n;
	t=1;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		y=x;
		cin>>x;
		if(t&&x==y)
		{
			ans++;
			t=0;
		}
		else
		t=1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main () {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int maxh = 0;
    long long ans = 0;
    for(int i = 0; i < N; i++) {
        if(maxh > A.at(i)) {
            ans += maxh - A.at(i);
        } else {
            maxh = max(maxh, A.at(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
def A(i,x):
 while i<n+2:t[i]+=x;i+=i&-i
(n,q),c,*z=[[*map(int,t.split())]for t in open(0)]
a=[0]*q
j,*b=t=[0]*(n+2)
for i,(l,r)in sorted(zip(range(q),z),key=lambda x:x[1][1]):
 while j<r:d=c[j];j+=1;A(b[d]+1,1);b[d]=j;A(j+1,-1)
 while l:a[i]+=t[l];l-=l&-l
print(*a)

Measured memory_bytes: 242992
#include <bits/stdc++.h>
using namespace std;
long long digit(long long n) {
    long long r = 0;
    while (n != 0)
    {
        r++;
        n /= 10;
    }
    return r;
}
int main() {
    long long n, d;
    cin >> n;
    d = digit(n);
    for (long long i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
            d = min(d, max(digit(i), digit(n / i)));
    }
    cout << d;
}

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

int main () {

int n, count = 0;

while(cin >> n){

    for (int a = 0; a < 10 && a <= n; a++){
        for (int b = 0; b < 10 && b <= n-a; b++){
            for (int c = 0; c < 10 && c <= n-a-b; c++){
                if (n-a-b-c >=0 && n-a-b-c < 10) {
                    count++;
                }
            }
        }
    }


    cout << count << endl;

    count = 0;


}



    return 0;

}

Measured memory_bytes: 1160
// Copyright 2015 KanatoNagayama
#include <iostream>
#include <vector>
using std :: cout;
using std :: cin;
using std :: endl;
using std :: vector;
int main() {
  vector<int> v(100000);
  int i = 0;
  while(true) {
    cin >> v[i];
    if(v[i] == 0)
      break;
    i++;  
  }
  for (int k = 0; k < i; k++) {
  cout << "Case " << k + 1 << ": " <<  v[k] << endl;
  }
  return 0;
}

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

using namespace std;

template <typename T, typename = typename std::enable_if<
                          std::is_integral<T>::value, T>::type>
vector<pair<T, int>> prime_factorize(T n) {
  vector<pair<T, int>> cnts{};
  if (n == 1) {
    return cnts;
  }

  T a = 2;
  while (n >= a * a) {
    int cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }

    if (cnt > 0) {
      cnts.push_back({a, cnt});
    }

    a++;
  }

  if (n != 1) {
    cnts.push_back({n, 1});
  }

  return cnts;
}

using ll = long long;
int main(int argc, const char *argv[]) {
  ll n, p;
  cin >> n >> p;

  auto factors = prime_factorize(p);

  vector<ll> elms;
  for (int i = 0; i < factors.size(); ++i) {
    if (factors[i].second >= n) {
      elms.push_back(pow(factors[i].first, factors[i].second / n));
    }
  }

  ll ans = 1;
  for (int i = 0; i < elms.size(); ++i) {
    ans *= elms[i];
  }

  cout << ans << '\n';
}

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

vector<long long> enum_divisors(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N, M; cin >> N >> M;
    long long ans = 1;
    for (long long d: enum_divisors(M)) {
        if (d * N <= M) ans = max(ans, d);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        char c = scan.next().charAt(0);
        
        if (Character.isUpperCase(c)){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35472
#include <bits/stdc++.h>
using namespace std;
#define ll long double 
#define LL long long int 
#define PI 3.141592653589

int main()
{
	 
	 LL n;

	 cin>>n;
	 LL a[n];
	 for (int i = 0; i < n; ++i)
	 {
	 	cin>>a[i];
	 }
	 ll mul=1;
	 for (int i = 0; i < n; ++i)
	 {
	 	if(a[i]==0)
	 	{
	 		cout<<0;
	 		return 0;
	 	}
	 }


	  for (int i = 0; i < n; ++i)
	 {
	 	mul*=a[i];
	 	if(mul > 1000000000000000000 or mul<0)
	 	{
	 		cout<<-1;
            return 0;

	 	}
            
	 }

	 cout<<(LL)mul;
	 

	return 0;
}

Measured memory_bytes: 4392
v = list(map(int, input().split()))
while v[0]!=0 or v[1]!=0:
    for i in range(v[0]):
        for j in range(v[1]):
            if (i+j)%2==0:
                print ("#", end="")
            else:
                print (".", end="")
        print ()
    print ()
    v = list(map(int, input().split()))


Measured memory_bytes: 7000
//      whn6325689
//		Mr.Phoebe
//		http://blog.csdn.net/u013007900
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
#include <functional>
#include <numeric>
#pragma comment(linker, "/STACK:1024000000,1024000000")


using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef complex<ld> point;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;

#define CLR(x,y) memset(x,y,sizeof(x))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define MID(x,y) (x+((y-x)>>1))
#define eps 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LLINF 1LL<<62

template<class T>
inline bool read(T &n)
{
    T x = 0, tmp = 1;
    char c = getchar();
    while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
    if(c == EOF) return false;
    if(c == '-') c = getchar(), tmp = -1;
    while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar();
    n = x*tmp;
    return true;
}
template <class T>
inline void write(T n)
{
    if(n < 0)
    {
        putchar('-');
        n = -n;
    }
    int len = 0,data[20];
    while(n)
    {
        data[len++] = n%10;
        n /= 10;
    }
    if(!len) data[len++] = 0;
    while(len--) putchar(data[len]+48);
}
//-----------------------------------

const int MAXN=26*26;

int b[MAXN][MAXN],ans[MAXN];
int a[MAXN][MAXN];

int Guass(int n)
{
	int i,j,p,row=0,col=0;
	for(;row<n&&col<n;row++,col++)
	{
		for(i=row,p=row;i<n;i++)
			if(a[i][col])
			{p=i;break;}
		if(p!=row)
			for(j=col;j<=n;j++)
				swap(a[p][j],a[row][j]);
		if(!a[row][col]) 
		{
			row--;
			continue;
		}
		for(i=row+1;i<n;i++)
			if(a[i][col])
			for(j=col+1;j<=n;j++)
				a[i][j]^=a[row][j];
	}
	for(i=row;i<n;i++)
		if(a[i][n]) return 0;
	return 1;
}

int main()
{
//	freopen("data.txt","r",stdin);
	int n,m,d;
	while(read(m)&&read(n)&&read(d)&&(n+m+d))
	{
		CLR(a,0);
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				read(b[i][j]);
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
			{
				a[i*m+j][n*m]=b[i][j];
				a[i*m+j][i*m+j]=1;
				for(int x=0;x<n;x++)
					for(int y=0;y<m;y++)
						if(abs(x-i)+abs(y-j)==d)
							a[i*m+j][x*m+y]=1;
			}
		if(Guass(n*m))
			puts("1");
		else
			puts("0");
	}
	return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>

int main(){
  int x, y;  scanf("%d %d", &x, &y);
  int t, k;
  int ans = 0;
  if((y-x*2)%2==0 && (x*4-y)%2==0){
    t = (x*4-y)/2;
    k = (y-x*2)/2;
    if(t>=0 && k>=0)  ans = 1;
  }
  
  


  if(ans)  printf("Yes\n");
  else     printf("No\n");

  return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int R; cin >> R;
	double ans = M_PI * (double)R * 2.;
	printf("%.4lf\n", ans);

	return 0;
}


Measured memory_bytes: 3764
import std.stdio;
import std.bigint;
import std.array;
import std.string;
import std.regex;
import std.conv;
void main(){
  string s;
  while(s=chomp(readln()),s){
    string a,b,c;
    a=s.split("+")[0];
    b=s.split("+")[1].split("=")[0];
    c=s.split("=")[1];
    bool NA=true;
    for(int i=0;i<10;++i){
      string sa,sb,sc;
      sa=replace(a,"X", to!string(i));
      sb=replace(b,"X", to!string(i));
      sc=replace(c,"X", to!string(i));
      if(i==0&&!(sa[0]!='0'||(sa[0]=='0'&&sa.length==1))||!(sb[0]!='0'||(sb[0]=='0'&&sb.length==1))||!(sc[0]!='0'||(sc[0]=='0'&&sc.length==1))) continue;
      BigInt aa,bb,cc;
      aa=BigInt(sa);
      bb=BigInt(sb);
      cc=BigInt(sc);
      if(cc==aa+bb){NA=false;writeln(to!string(i));break;}
    }
    if(NA)writeln("NA");
  }
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
#define int long long
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    for (int i = 0; i < v.size(); ++i)
      os << v[i] << " ";
    os << '\n';
  }
  return os;
}
int fac[1000001];
int phi[1000001];
void pre()
{
    int i, j;
    for(i=1;i<=1000000;i++)
        phi[i] = i;
    for(i=2;i<=1000000;i++)
    {
        if(phi[i] == i)
        {
            for(j=i;j<=1000000;j+=i)
                phi[j] = i;
        }
    }
    fac[1] = 1;
    for(i=2;i<=1000000;i++)
    {
        int ele = i, prod = 1;
        while(ele > 1)
        {
            int cnt = 0, j = phi[ele];
            while(ele%j == 0)
            {
                ele = ele/j;
                cnt++;
            }
            prod = prod*(cnt+1);
        }
        fac[i] = prod;
    }
}
signed main() {
    pre();
    int n;
    cin >> n;
    int c;
    int ans = 0;
    for(c=1;c<n;c++)
    {
        int num = n - c;
        ans+=fac[num];
    }
    cout << ans;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll N,ans=0;
    cin >> N;
    for(ll i=1; i<=N; i++){
        ll cnt=0;
        for(ll k=1; k<=i; k++){
            if(i%k==0 && k&2!=0) cnt++;
        }
        if(cnt==8) ans++;
        
    }

    cout << ans << endl;
 
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int x,y,a,b,c,p[100005],q[100005],r[100005],ans;
void solve(){
    cin>>x>>y>>a>>b>>c;
    rep(i,0,a) cin>>p[i];
    rep(i,0,b) cin>>q[i];
    rep(i,0,c) cin>>r[i];
    sort(p,p+a);
    reverse(p,p+a);
    sort(q,q+b);
    reverse(q,q+b);
    sort(r,r+c);
    reverse(r,r+c);
    vi v;
    rep(i,0,x) v.pb(p[i]);   
    rep(i,0,y) v.pb(q[i]);
    rep(i,0,min(x+y,c)) v.pb(r[i]);
    sort(all(v));
    reverse(all(v));
    rep(i,0,x+y) ans+=v[i];
    cout<<ans<<endl;   
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 8304
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s = read_vec::<u64>();
    let ans = (s[0] +s[1])% 24;
    println!("{}",ans);
} 

Measured memory_bytes: 4476
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l , n;
    scanf("%d %d",&n,&l);
    string s[105];
    int a[105];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        a[i]=(int)s[i][0];
    }
    sort(s+0,s+n);
    for(int i=0;i<n;i++)
    cout<<s[i];
}

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


int main()
{
   int a,b,c,d,e;
   cin >> a >> b >> c >> d >> e;
   int nums[5] = {a,b,c,d,e};
   for(int i=0; i<5; i++)
   {
   	    if(nums[i] != i+1)
   	    {
   	        cout << i+1;	
		}
   }
   
   
   return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  ldouble l;
  while (scanf("%Lf", &l) != EOF)
  {
    ldouble a = l/3;
    printf("%.15Lf\n", a*a*a);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL
using namespace std;

int main()
{
	int n;
	long long int a, b, s[100000], sinv[100000];
	scanf("%d %lld %lld", &n, &a, &b);
	if(n==1){
		printf("%d\n", 2);
		return 0;
	}
	for(int i=0; i<n; i++){
		scanf("%lld", &s[i]);
	}
	for(int i=0; i<n; i++){
		sinv[n-1-i]=-s[i];
	}
	int e1[100000]={}, e2[100000]={};
	for(int i=0; i<n-1; i++){
		if(s[i+1]-s[i]>=a) e1[i]=1;
		if(s[i+1]-s[i]>=b) e2[i]=1;
	}
	int x1[100000], i1=0;
	for(int i=1; i<n; i++){
		if(e1[i-1]==0){
			i1=i;
		}
		x1[i]=i1;
	}
	int y1[100000];
	i1=0;
	for(int i=1; i<n; i++){
		if(e2[i-1]==0){
			i1=i;
		}
		y1[i]=i1;
	}
	int x2[100000], y2[100000];
	for(int i=1; i<n; i++){
		int l=lower_bound(sinv, sinv+n, a-s[i])-sinv;
		x2[i]=n-1-l;
		l=lower_bound(sinv, sinv+n, b-s[i])-sinv;
		y2[i]=n-1-l;
	}
	long long int xy[100000], yx[100000], sum1[100000], sum2[100000];
	sum1[0]=0;
	sum2[0]=0;
	for(int i=1; i<n; i++){
		if(i==1){
			xy[1]=1;
			yx[1]=1;
			sum1[1]=1;
			sum2[1]=1;
		}else{
			int m1=max(1, x1[i-1]);
			int m2=min(i-1, y2[i]+1);
			if(m1>m2){
				xy[i]=0;
			}else{
				xy[i]=(sum2[m2]-sum2[m1-1]%MOD+MOD)%MOD;
			}
			if(x1[i-1]==0) xy[i]++;

			m1=max(1, y1[i-1]);
			m2=min(i-1, x2[i]+1);
			if(m1>m2){
				yx[i]=0;
			}else{
				yx[i]=(sum1[m2]-sum1[m1-1]%MOD+MOD)%MOD;
			}
			if(y1[i-1]==0) yx[i]++;

			sum1[i]=(sum1[i-1]+xy[i])%MOD;
			sum2[i]=(sum2[i-1]+yx[i])%MOD;
		}
	}

	long long int ans=0;
	ans=sum2[n-1]-sum2[max(0, x1[n-1]-1)]%MOD+MOD+sum1[n-1]-sum1[max(0, y1[n-1]-1)]%MOD+MOD;
	if(x1[n-1]==0) ans++;
	if(y1[n-1]==0) ans++;
	ans=ans%MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
#define LOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL
bool vis[maxn],ok = true;
vector<int> a[maxn];
int n,m;
vector<pair<int,int>>   e;
vector<int> st;
int pa[maxn],d[maxn];
vector<int> best;
int p = 9999999;

int main(){
    scanf("%d%d",&n,&m);
    int u,v;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        a[u].push_back(v);
        e.emplace_back(u,v);
    }
    for(auto i:e){
       // eprintf("hey \n");
        for(int j=1;j<=n;j++)
            vis[j] = false,d[j] = maxn,pa[j] = 0;
        queue<int> q;
        q.push(i.second);
        d[i.second] = 0;
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(auto j:a[cur]){
                if(d[j] > d[cur] + 1){
                    pa[j] = cur;
                    d[j] = d[cur] + 1;
                    q.push(j);
                }
            }
        }
        if(d[i.first] !=maxn && d[i.first] < p){
            p = d[i.first];
            st.clear();
            int x = i.first;
            st.push_back(x);
            while(x != i.second){
                x = pa[x];
                st.push_back(x);
            }
            best = st;
        }
    }
   // cerr << "ans ...\n";
    if(p ==9999999)return !printf("-1");
    printf("%d\n",(int)best.size());
    for(auto i:best){
        printf("%d\n",i);
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define MOD (1000000007)
int main(){
  #define int long
  int n,m,a=-1;
  cin>>n>>m;
  vector<int> dp(n+1,0);
  dp[0]=1;
  for(int i=1;i<=n;++i){
    if(a==-1)cin>>a;
    if(i==a){
      dp[a]=-1;
      a=-1;
    }
    else{
      dp[i]=((i-1>=0&&dp[i-1]>=0?dp[i-1]:0)%MOD+(i-2>=0&&dp[i-2]>=0?dp[i-2]:0)%MOD)%MOD;
    }
  }
  cout<<dp[n];
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main()
{
	char S[4];
	scanf("%s", S);
	if (S[0] == 'S' && S[1] == 'U') printf("7\n");
	else if (S[1] == 'A') printf("1\n");
	else if (S[1] == 'R') printf("2\n");
	else if (S[1] == 'H') printf("3\n");
	else if (S[1] == 'E') printf("4\n");
	else if (S[1] == 'U') printf("5\n");
	else printf("6\n");
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 1620
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    string s[n];
    ll time[n];
    for(int i=0;i<n;++i) {
        cin>>s[i]>>time[i];
    }
    string p;
    cin>>p;
    ll ans = 0;
    int f = 1;
    for(int i=0;i<n;++i) {

        if(f == 0) {
            ans += time[i];
        }
        if(s[i] == p)
            f = 0;
    } 
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100000;
const int NIL = -1;
int n;
vector<int> G[MAX];
int color[MAX];
void dfs(int r,int c) {
    if(color[r] == NIL) color[r] = c;
    for(int i = 0;i < G[r].size();i++) {
        int v = G[r][i];
        if(color[v] == NIL) dfs(v,c);
    }
}
void assignColor() {
    int id = 1;
    for(int i = 0;i < n;++i) color[i] = NIL;
    for(int u = 0;u < n;u++) if(color[u] == NIL) dfs(u,id++);
}
int main() {
    int s,t,m,q;
    scanf("%d%d",&n,&m);
    for(int i = 0;i < m;++i) {
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    scanf("%d",&q);
    for(int i = 0;i < q;++i) {
        scanf("%d%d",&s,&t);
        if(color[s] == color[t]) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 13660
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	int a,b;
	while( cin>>a>>b ){
		int road=a+b-1;
		cout<<a*b-road<<endl;
}
	return 0;
	}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int M;

  std::cin >> M;

  std::cout << 48 - M << std::endl;

  return 0;
}


Measured memory_bytes: 888
// D.

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL h, w, d;
	cin >> h >> w >> d;
	vector<vector<LL>> a(h, vector<LL>(w));
	vector<LL> sum(h * w + 1);
	vector<pair<int, int>> pos(h * w + 1);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> a[i][j];
			pos[a[i][j]] = { i, j };
		}
	}
	for (LL i = h * w - d; i >= 0; --i) {
		sum[i] = sum[i + d] + abs(pos[i + d].first - pos[i].first) + abs(pos[i + d].second - pos[i].second);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int l, r;
		cin >> l >> r;
		cout << (sum[l] - sum[r]) << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
List=list(input())
a=List[0]
b=List[1]
c=List[2]
d=List[3]
if a==b and c==d and a!=c:
    print("Yes")
elif a==c and b==d and a!=b:
    print("Yes")
elif a==d and b==c and a!=b:
    print("Yes")
else:print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<complex>
#define INF 10000000
#define pb push_back
using namespace std;
typedef complex<double> Point;
const double PI=4*atan(1);
vector<vector<Point> > p;
int n,s,g;
double dot(Point a, Point b){
    return real(conj(a)*b);
}
double cross(Point a, Point b){
    return imag(conj(a)*b);
}
double dlp(Point a, Point b, Point c) {
  if(dot(b-a,c-a)<=0)return abs(c-a);
  if(dot(a-b,c-b)<=0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
int iil(Point a1,Point a2,Point b1,Point b2){
	return (cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<=0)&&(cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<=0);
}
double dll(Point a1,Point a2,Point a3,Point a4){
    if(iil(a1,a2,a3,a4))
        return 0.0;
	return min(min(dlp(a1,a2,a3),dlp(a1,a2,a4)),min(dlp(a3,a4,a1),dlp(a3,a4,a2)));
}
double cal(int a,int b){
    double ret=INF;
    for(int i=0;i<5;i++)
        for(int j=2;j<4&&i+j<5;j++)
            for(int k=0;k<5;k++)
                for(int l=2;l<4&&k+l<5;l++)
                	ret=min(dll(p[a][i],p[a][i+j],p[b][k],p[b][k+l]),ret);
    return ret;
}
int main(){
    while(cin>>n>>s>>g,n||s||g){
    	p=vector<vector<Point> >(n,vector<Point>(5));
        for(int i=0;i<n;i++){
            double x,y,a,r;
            cin>>x>>y>>a>>r;
            for(int j=0;j<5;j++){
            	p[i][j]=Point(x,y)+polar(r,(a+72.0*j+90)*PI/180.0);
            }
        }
        vector<vector<double> > cost(n,vector<double>(n,INF));
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
            	if(i==j){
            		cost[i][j]=0;
            		continue;
            	}
                cost[i][j]=cost[j][i]=cal(i,j);
            }
        }
    	for(int k=0;k<n;k++){
    		for(int i=0;i<n;i++){
    			for(int j=0;j<n;j++){
    				cost[i][j]=min(cost[i][k]+cost[k][j],cost[i][j]);
    			}
    		}
    	}
    	printf("%.8lf\n",cost[s-1][g-1]);
    }
    return 0;
}

Measured memory_bytes: 1092
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vector<int> color(N, -1);
    function<bool(int, int, int)> dfs = [&](int v, int p, int c) {
      color[v] = c;
      for (int u : G[v]) {
        if (u == p) continue;
        if (color[u] != -1) {
          if (color[u] == c) {
            return false;
          }
        } else {
          if (not dfs(u, v, c ^ 1)) {
            return false;
          }
        }
      }
      return true;
    };
    bool bipartite = dfs(0, -1, 0);
    ll res;
    if (!bipartite) {
      res = 1ll * N * (N - 1) / 2 - M;
    } else {
      int W = 0, B = 0;
      for (int i = 0; i < N; i++) {
        if (color[i] == 0)
          ++W;
        else
          ++B;
      }
      res = 1ll * W * B - M;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 1){
				System.out.println(0);
			}else{
				if(n % 2 != 0){
					n += 1;
				}
				int halfN = n/2;
				int[] v = new int[n];
				for(int i=0;i < halfN;i++){
					v[i] = 1;
				}
				int p = 3;
				while(true){
					if(p*p > n){
						break;
					}else{
						if(v[(p-1)/2] == 0){
							p += 2;
						}else{
							int t = p*p;
							while(t < n){
								v[(t-1)/2] = 0;
								t += 2*p;
							}
							p += 2;
						}
					}
				}
				int count = 0;
				for(int i = 0;i < halfN;i++){
					if(v[i] == 1){
						count++;
					}
				}
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 16000