akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static int C(int i) {
		int ans=0;
		for(int j=1;j<=i;j++) {
			if(i%j==0) {
				ans++;
			}
		}
		return ans==8&&i%2==1?1:0;
	}
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int ans=0;
	for(int i=0;i<=a;i++) {
		ans+=C(i);
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n;
	cin>>n;
	ll a[n+1][n+1]={};
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
		cin>>a[i][j];
	}
	ll s[((1<<n)+1)]={};
	ll dp[((1<<n)+1)]={};
	for(ll i=0;i<(1<<n);i++){
		for(ll j=0;j<n;j++){
			for(ll k=j+1;k<n;k++){
				if((i & (1<<j)) && (i & (1<<k)))
				s[i]+=a[j][k];
			}
		}
		dp[i]=s[i];
	}
	for(ll i=1;i<(1<<n);i++){
		for(ll j=i;j>0;j=((j-1) & i)){
				dp[i]=max(dp[i],dp[j]+dp[(i^j)]);
		}
	}
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(int i = 0; i < n; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull MOD = 1000'000'007;

int main(){
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    auto A = read<ll>(N);
    sort(A.begin(), A.end());
    v<ll> area(N);
    ll thr = A[N - P];
    for(ll i = N - P - 1; i >= 0; --i){
        area[i] = area[i + 1] + thr - A[i];
    }
    V = max(0LL, V - P);
    
    ll i = 0;
    for(; i < N - P; ++i)
    {
        ll a = A[i] + M;
        if(a < thr) continue;
        ll arthr = max(V - i, 0LL) * M;
        ll ar = area[i + 1] + (a - thr) * (N - P - i);
        if(ar >= arthr) break;
    }
    write(N - i);
}



Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n, m int
	var days int
	fmt.Scan(&n, &m)
	for i := 0; i < m; i++ {
		fmt.Scan(&days)
		n -= days
		if n < 0 {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(n)
}

Measured memory_bytes: 2328
s = input()
q = int(input())

for _ in range(q):
    i = input().split()
    op, a, b = i[0], int(i[1]), int(i[2])
    
    if op == 'print':
        print(s[a:b+1])
        
    elif op == 'reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]

    elif op == 'replace':
        p = i[3]
        s = s[:a] + p + s[b+1:]


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

int n, m, i, a, b, ans, ball[200005];
bool red[200005];

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

	cin >> n >> m;
	for (i=1; i<=n; i++) {
		ball[i]=1;
	}
	red[1]=true;
	for (i=1; i<=m; i++) {
		cin >> a >> b;
		if (red[a]==true) {
			red[b]=true;
		}
		ball[a]--;
		ball[b]++;
		if (ball[a]==0) {
			red[a]=false;
		}
	}
	for (i=1; i<=n; i++) {
		if (red[i]==true) {
			ans++;
		}
	}
	cout << ans;

}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
vector< pair <long long,int> > vep;
int main()
{
    int n,m;
    long long sum=0;
    scanf("%d%d",&n,&m);
    long long a[n+1];
    int b[n+1];
    for(int i=0; i<n; i++)
    {
        scanf("%lld%d",&a[i],&b[i]);
        vep.push_back( make_pair(a[i],b[i]) );
    }
    sort(vep.begin(), vep.end());
    for(int i=0; i<n; i++)
    {
        int deck=1;
        if(vep[i].second<=m)
        {
            while(deck<=vep[i].second)
            {
                sum+=vep[i].first;
                ++deck;
            }
        }
        if(vep[i].second>m)
        {
            while(deck<=m)
            {
                sum+=vep[i].first;
                ++deck;
            }
        }
        m-=(deck-1);
        if(m==0)break;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3188
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt()
	set := make(map[int]int)
	set[A]++
	set[B]++
	set[C]++

	if set[5] == 2 && set[7] == 1 {
		fmt.Fprintln(wtr, "YES")
	} else {
		fmt.Fprintln(wtr, "NO")
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int n; 
    cin >> n;
    long double a[n];
    rep(i,n) cin >> a[i];
    long double p = 1;
    rep(i,n){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){
        p*=a[i];
        if(p>1e18){
            cout << -1 << endl;
            return 0;
        }
    }
    long long ans = p;
    cout << ans << endl;

}

Measured memory_bytes: 5348
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key)
    {
      if(k < u->key )u = u->left;
      else u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y != NIL || x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL)
    {
      x = y->left;
    }
  else
    {
      x = y->right;
    }

  if(x != NIL)
    {
      x->parent = y->parent;
    }
  
  if(y->parent == NIL)
    root = x;
  else
    {
      if(y == y->parent->left)
	{
	  y->parent->left = x;
	}
      else
	{
	  y->parent->right = x;
	}
    }
  if(y != z)
    z->key = y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if( z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right; 
	}
    }
  z->parent = y;
  if(y == NIL)
    root = z;
  else
    {
      if(z->key < y->key)
	{
	  y->left=z;
	}
      else
	{
	  y->right = z;
	}
    }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25164
def euc(i, j):
    if i > j:
        i, j = j, i
    while j%i != 0:
        k = j - i
        if k > i:
            i, k = k, i
        j = i%k
        if j == 0:
            return(k)
        i = k
        if i > j:
            i, j = j, i
    return i


N = int(input())
sum = 0
for i in range(1, N + 1):
    for j in range(1, N + 1): 
        ij = euc(i, j)
        for k in range(1, N + 1):
            sum += euc(ij, k)
print(sum)

#print(euc(2, 3))


Measured memory_bytes: 9204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC083A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            d = int.Parse(word[3]);

            if (a + b > c + d)
                Console.WriteLine("Left");
            else if (a + b == c + d)
                Console.WriteLine("Balanced");
            else
                Console.WriteLine("Right");
        }
    }
}


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

int main(){
  int n,p;
  cin>>n>>p;
  int vec[n];
  long long int dp[n][2];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  if(vec[0]%2==0){
    dp[0][0]=2;
    dp[0][1]=0;
  }
  else{
    dp[0][0]=1;
    dp[0][1]=1;
  }
  if(n==1){
    cout<<dp[n-1][p]<<endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(vec[i]%2==0){
      dp[i][0]=2*dp[i-1][0];
      dp[i][1]=2*dp[i-1][1];
    }
    else{
      dp[i][0]=dp[i-1][1]+dp[i-1][0];
      dp[i][1]=dp[i-1][1]+dp[i-1][0];
    }
  }
  cout<<dp[n-1][p]<<endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    private static final int MOD = (int) 1e9 + 7;

    public static void main(String[] args) throws FileNotFoundException {
        //Scanner in = new Scanner(new File(args[0]));
        //PrintWriter out = new PrintWriter(new File(args[1]));
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt(), m = in.nextInt();
        while (n != 0 && m != 0) {
            int[] max = new int[m];
            for (int i = 0; i < n; i++) {
                int d = in.nextInt() - 1;
                max[d] = Math.max(max[d], in.nextInt());
            }
            long ans = 0;
            for (int i = 0; i < m; i++) {
                ans += max[i];
            }
            out.println(ans);
            n = in.nextInt();
            m = in.nextInt();
        }


        out.close();
    }

    private static class Task {
        int d, p;

        public Task(int d, int p) {
            this.d = d;
            this.p = p;
        }
    }
}



Measured memory_bytes: 35288
N,K=map(int, raw_input().split())
S=raw_input()

if "0" not in S:
	print len(S)
	quit()
L=[]
if S[0]=="0": L.append(0)
for i,x in enumerate(S):
	if i==0:
		cnt=1
	else:
		if prev==x:
			cnt+=1
		else:
			L.append(cnt)
			cnt=1
	prev=x
else:
	L.append(cnt)

if S[-1]=="0": L.append(0)

LSUM=[0]
for x in L:
	LSUM.append(LSUM[-1]+x)

K=min(K,len(L)/2)

ans=0
len_lsum=len(LSUM)
for l in range(0,len_lsum,2):
	r=l+2*K+1
	if r < len_lsum:
		ans=max(ans , LSUM[r]-LSUM[l])

print ans



Measured memory_bytes: 44524
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
    int a=in(),b=in(),c=0,i;
    for(i=1;i<a;i++)c++;
    if(a<=b)c++;
    print(c);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define L long long
using namespace std;
L l,r;
inline L calc(int i,L l,L r,bool t)
{
	if(l==-1 && r==-1)
	  return 0;
	if(t && r==-1)
	  return 0;
	if(i==-1)
	  return 1;
	if(r==-1)
	  {
	   if(l==-1)
	     return 0;
	   if(l==0)
	     return 1;
	   int k;
	   for(k=i;!(l&(1ll<<k));k--);
	   return (1ll<<k+1);
	  }
	if(!r)
	  return (1ll<<i+1);
	L k=0;
	k+=calc(i-1,min(l,(1ll<<i)-1),r<(1ll<<i)?r:-1,t);
	if(r<=(1ll<<i))
	  k+=calc(i-1,min(l,(1ll<<i)-1),0,0);
	else if(l>=(1ll<<i))
	  k+=calc(i-1,min(l,(1ll<<i)-1),r-(1ll<<i),t);
	else
	  k+=calc(i-1,min(l,(1ll<<i)-1),r-(1ll<<i),1);
	return k;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%lld%lld",&l,&r);
	if(l==r)
	  {
	   printf("1\n");
	   return 0;
	  }
	for(i=60;(l&(1ll<<i))==(r&(1ll<<i));i--)
	  if(l&(1ll<<i))
	    l-=1ll<<i,r-=1ll<<i;
	printf("%lld\n",calc(i-1,r-(1ll<<i),l,0)+calc(i-1,-1,l,0));
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int x,y;
	
	while(1){
		scanf("%d %d\n",&x,&y);
		if(x==0 & y==0)
			break;
		if(x>y)
			printf("%d %d\n",y,x);
		else
			printf("%d %d\n",x,y);
		
	}
	return 0;
}

Measured memory_bytes: 604
/*

A try towards peace

*/

#include <bits/stdc++.h>
using namespace std;
#define yo long long int
#define lo mp::cpp_int
#define pb push_back
#define pob pop_back
#define mp make_pair
#define endl "\n"
#define ce(x) cout << x <<"\n"
#define fill(s,v) memset(s,v,sizeof(s))
#define speed  { ios_base::sync_with_stdio(false); cin.tie(0); }
#define for2(i,a,b) for(yo i=a;i<b;i++)
#define for3(i,a,b) for(yo i=a;i<=b;i++)
#define for1(a,b) for(yo i=a;i<b;i++)
#define deb(x) cout<<#x<<" "<<x<<endl; 
#define INFINITE 1000000009
#define ull unsigned long long int
#define take(a,n) for(yo pp=0;pp<n;pp++) { cin>>a[pp]; }
#define take2(a,n) for(yo p=0;p<n;p++) { yo temp;cin>>temp;a.pb(temp); }
#define show(a,n) for(yo p=0;p<n;p++) cout<<a[p]<<" ";
#define _ <<" "<<
#define nl cout<<endl;
#define sq(x) ((x)*(x))
#define call(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define lld long double
#define tc(tt) \
    yo tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) 
 
yo dx[] = {1, 0, -1, 0};
yo dy[] = {0, 1, 0, -1};
const yo N = 1000*1000+5;
const yo size = 1000*100*2+5;
const yo mod = 1000*1000*1000+7;
 
yo gcd(yo a, yo b){if(!b)return a;return gcd(b, a % b);} 
yo power_mod(yo x,yo y,yo p){yo res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
yo lcm(yo a, yo b){return (a*b)/gcd(a, b);}
yo sumofdigits(yo n){yo out=0;while(n){out+=(n%10);n/=10;}return out;}
bool isPrime(yo n){if (n <= 1)  return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false; for (yo i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;} 
yo power(yo a,yo b){if(b==0)return 1;if(b&1)return a*power(a,b-1);yo res=power(a,b/2);return res*res;}
yo log(yo d){return log2(d);}
bool isPower(yo x, yo y){if(x==1) return (y==1); yo pow=1; while(pow<y) pow*=x; return(pow == y);}  
bool compare (const pair<yo,yo> &i,const pair<yo,yo> &j){return i.first < j.first;}
yo i,j;

lld polygonArea(lld X[], lld Y[], yo n) 
{   
    lld area = 0.0; 
    yo j = n - 1; 
    for (yo i = 0; i < n; i++) 
    { 
        area += (X[j] + X[i]) * (Y[j] - Y[i]); 
        j = i;  
    }    
    return abs(area); 
} 
bool prime[100200];
vector<yo> dp;
 
void SieveOfEratosthenes(yo n) 
{   
    for (yo p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for ( i=p*p; i<=n; i += p) 
                prime[i] = false;   
        } 
    } 
  
    for (yo p=2; p<=n; p++)  
       if (prime[p]) 
          dp.pb(p); 
} 

int main ()
{
    yo k,x; cin>>k>>x;
    yo temp=500*k;
    if(temp>=x) cout<<"Yes";
    else cout<<"No";
    nl


}
/*


200560490130



*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
	
	
	public static void main(String[] args) {
		
		FastScanner fs = new FastScanner();
		int a=fs.nextInt(), b=fs.nextInt(), c=fs.nextInt(), d=fs.nextInt();
		long product=0l;
		if(b<=0 && d<=0)
		{
			product = (long)a*c;
			System.out.println(product);
			return;
		}
		if(b>=0 && d>=0)
		{
			product = Math.max((long)a*c, (long)b*d);
			System.out.println(product);
			return;
		}
		if(b>=0 && c<=0)
		{
			product = Math.max((long)d*a,(long)c*a);
			System.out.println(product);
			return;
		}
		if(a<=0 && d>=0)
		{
			product = Math.max((long)b*c,(long)a*c);
			System.out.println(product);
			return;
		}
		
	}
	
	
	
	static class FastScanner 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	

}


Measured memory_bytes: 32812
#include <stdio.h>
int main(){
	int i = 1;
	int x,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x = i;
		if(x%3 == 0){
			printf(" %d",i);
		}else{
			while(x != 0){
				if(x % 10 == 3){
					printf(" %d",i);
					break;
				}else{
					x = x/10;
				}
			}
		}
	}
	printf("\n");
}

Measured memory_bytes: 1028
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String str = sc.next();
   String str2 = sc.next();
   int count = 0;
 for (int i = 0; i < str.length(); i++) {
	if(str.charAt(i) == str2.charAt(i)){
       count++;
    } 
   
  }
    System.out.print(count);
 }
}

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


void solve(long long X, long long A, long long B){
	 cout << (X - A) % B << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    int ans=0;
    cin >>n;
    int bef;
    int a,b;
    vector<vector<int>>data(n,vector<int>(2,0));
    rep(i,n){
        cin>>bef;
        rep(j,bef){
            cin>>a>>b;
            a--;
            
            if(b==0){//not ture
                data[i][0]|=(1<<a);
            }else{
                data[i][1]|=(1<<a);
            }
            
        }
    }
    bool can=true;
    rep(bit,1<<n){
        can=true;
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
                can&=((data[i][1]&bit) ==data[i][1]);
                can&=((data[i][0]&(~bit))==data[i][0]);
            }
        }
        if(can){
            chmax(ans,__builtin_popcount(bit));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

void yes() {
	cout << "Yes" << endl;
	exit(0);
}

void no() {
	cout << "No" << endl;
	exit(0);
}

const int N = 1e5 + 5;
int a[N];

void solve() {
	string s;
	cin >> s;
	int ca = 0;
	int n = s.size();
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'A') {
			ca++;
		}
		else if(i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
			ans += ca;
			i++;
		}
		else {
			ca = 0;
		}
	}
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		// cout << "Case #" << tt << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 720
#入力
S = list(input())

N = len(S)
count_1010 = 0
count_0101 = 0
#処理 初めの数字について場合分け
#1始まり 1010...
for i in range(N):
    #奇数文字目 (1になる)
    if i % 2 == 0:
        if S[i] != "1":
            count_1010 += 1
    #偶数文字目 (0になる)
    else:
        if S[i] != "0":
            count_1010 += 1

#0始まり 0101...
for j in range(N):
    #奇数文字目 (0になる)
    if j % 2 == 0:
        if S[j] != "0":
            count_0101 += 1
    #偶数文字目 (1になる)
    else:
        if S[j] != "1":
            count_0101 += 1

#出力
print(min(count_0101, count_1010))

Measured memory_bytes: 3956
#include<stdio.h>
int main()
{
  int h,n;
  int all[100006];
  int max=0;
  scanf("%d %d",&h,&n);
  for(int i = 1;i<=n;i++)
    scanf("%d",&all[i]);
  for(int i = 1;i<=n;i++)
  {
    max+=all[i];
    if(max>=h)
    {
      printf("Yes");
      return 0;
    }
  }
    printf("No");
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int h, w;
  cin >> h >> w;
  string a[110];
  rep(i,h) cin >> a[i];
  int okx[110] = {};
  int oky[110] = {};
  rep(i,h){
    rep(j,w){
      if(a[i][j] == '#'){
        okx[i] = 1;
        oky[j] = 1;
      }
    }
  }
  rep(i,h){
    if(okx[i]){
      rep(j,w){
        if(oky[j]){
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}



Measured memory_bytes: 256
def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        A -= 1
    else:
        B -=1
    ans = [A, B]
    print(*ans)

# print(solve())

# def solve()が@return voidのとき
solve()

Measured memory_bytes: 2940
#include <stdio.h>
long long ans, n, x;
long long l[100002], r[100002];
int id[100001];
int main() {
	scanf("%lld", &n);
	l[0] = 0;
	r[n + 1] = n + 1;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &x);
		id[x] = i;
		l[i] = i - 1;
		r[i] = i + 1;
	}
	for (int i = 1; i <= n; i++) {
		x = id[i];
		ans += ((l[x] - l[l[x]]) * (r[x] - x) + (r[r[x]] - r[x]) * (x - l[x])) * i;
		r[l[x]] = r[x];
		l[r[x]] = l[x];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2176
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
bool canh[200010],cant[200010];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if (a==1) canh[b]=1;
		if (b==n) cant[a]=1;
	}
	bool f=0;
	for (int i=2;i<n;i++){
		f|=(canh[i]&cant[i]);
	}
	if (!f) printf("IM");
	printf("POSSIBLE");
	return 0;
}

Measured memory_bytes: 640
h,w = map(int,input().split())
li,li2 = [],[]
for i in range(h):
    a = list(input())
    if "#" in a:
        li.append(a)
for i in range(len(li)):
    for j in range(w):
        if li[i][j] == ".":
            li[i][j] = 0
        elif li[i][j] == "#":
            li[i][j] = 1

li = list(zip(*li))
for i in range(len(li)):
    if 1 in li[i]:
        li2.append(li[i])
li2 = list(zip(*li2))
for i in range(len(li2)):
    li2[i] = list(li2[i])
for i in range(len(li2)):
    for j in range(len(li2[i])):
        if li2[i][j] == 0:
            li2[i][j] = "."
        elif li2[i][j] == 1:
            li2[i][j] = "#"
for i in range(len(li2)):
    print("".join(li2[i]))

Measured memory_bytes: 3316
#include <cstdio>

typedef long long LL;

const int MAXN = 4005;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

template<typename _T>
_T MIN( const _T a, const _T b )
{
	return a < b ? a : b;
}

int q[MAXN];
int a[MAXN];
int N, x;

LL calc( const int l )
{
	LL ret = 1ll * l * x;
	int h = 1, t = 0, r = 1;
	for( int i = 1 ; i <= N ; i ++ )
	{
		while( h <= t && q[h] < i ) h ++;
		for( ; r <= i + l ; r ++ )
		{
			while( h <= t && a[q[t]] >= a[r] )
				t --;
			q[++ t] = r;
		}
		ret += a[q[h]];
	}
	return ret;
}

int main()
{
	read( N ), read( x );
	for( int i = 1 ; i <= N ; i ++ ) read( a[i] ), a[i + N] = a[i];
	LL ans = 1e18;
	for( int i = 0 ; i < N ; i ++ )
		ans = MIN( ans, calc( i ) );
	write( ans ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 1552
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k; cin>>n>>k;
	ll a[200020];
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n-k; i++){
		if(a[i]<a[i+k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int ans = 0;
vector<vector<bool>> g;
void dfs(int v, int n, vector<bool> visited) {
    if (count(all(visited), true) == n) {
        ++ans;
        return;
    }
    for (int to=0; to<n; ++to) {
        if (!g[v][to]) continue;
        if (visited[to]) continue;
        visited[to] = true;
        dfs(to, n, visited);
        visited[to] = false;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    g = vector<vector<bool>>(n, vector<bool>(n));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a][b] = g[b][a] = true;
    }
    vector<bool> visited(n);
    visited[0] = true;
    dfs(0, n, visited);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  vector<string> S(H);
  rep(i,0,H) cin>>S[i];
  vi P={0,1,0,-1},R={1,0,-1,0};
  int ans=0;
  vector<vector<bool>> F(H,vector<bool>(W,1));
  rep(i,0,H){
    rep(j,0,W){
      if(F[i][j]){
        queue<pii> Q;
        Q.push(mp(i,j));
        F[i][j]=0;
        int C=0,D=0;
        while(Q.size()>0){
          int X=Q.front().first,Y=Q.front().second;
          Q.pop();
          C++;
          if(S[X][Y]=='.') D++;
          rep(k,0,4){
            int A=P[k]+X,B=R[k]+Y;
            if(0<=A&&A<H&&0<=B&&B<W&&S[X][Y]!=S[A][B]&&F[A][B]){
              Q.push(mp(A,B));
              F[A][B]=0;
            }
          }
        }
        ans+=(C-D)*D;
      }
    }
  }
  cout<<ans<<endl;
  }



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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
//////////////////////////////////////////////////////////
//______________________________________________________//
//    ____           __                                 //
//    /   )          / |                                //
//---/__ /-----__---/__|----__----__----__------__--_/_-//
//  /    )   /___) /   |  /   ' /   ' /___)   /   ) /   //
//_/____/___(___ _/____|_(___ _(___ _(___ ___/___/_(_ __//
//                                          /           //
//                                         /            //
//////////////////////////////////////////////////////////
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <iterator>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;const int INF=1001001001;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {

  ll n;
  cin>>n;
  ll sum=0;
  for(ll i=1;i<n+1;i++){
    if(i%3!=0 && i%5!=0){
      sum+=i;
    }
  }
  cout<<sum<<endl;

return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define ALL(x) x.begin(),x.end()

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

bool used[200000];

int calcInitial(int n, vector<int> & vec) {
  rep(i,n) if( !vec[i] ) used[i] = true;
  int cnt = 0;
  rep(i,n) {
    if( used[i] ) continue;
    ++cnt;
    while( i + 1 < n && !used[i+1] ) {
      ++i;
    }
  }
  return cnt;
}

void compute(int n,vector<int> &vec) {
  map<int,deque<int>> mp;
  rep(i,n) mp[vec[i]].push_back(i);
  int cnt = calcInitial(n, vec);
  vector<int> st = vec;
  sort(ALL(st));
  st.erase(unique(ALL(st)),st.end());
  int maxi = cnt;
  rep(i,(int)st.size()) {
    int v = st[i];
    if( v == 0 ) continue;
    deque<int> &deq = mp[v];
    while( !deq.empty() ) {
      int p = deq.front(); deq.pop_front();
      used[p] = true;
      if( p-1 >= 0 && p + 1 < n && !used[p-1] && !used[p+1] && vec[p+1] > vec[p] && vec[p-1] > vec[p] ) {
	++cnt;
      }
      if( ( ( p-1 >= 0 && used[p-1] ) || p-1 < 0 ) && ( ( p + 1 < n && used[p+1] ) || p+1 >= n ) ) {
	--cnt;
      }
    }
    maxi = max(maxi,cnt);
  }
  cout << maxi << endl;
  assert( cnt == 0 );
}

vector<int> compress(int n, vector<int> &vec) {
  vector<int> wec;
  rep(i,n) if( i-1 < 0 || vec[i-1] != vec[i] ) wec.push_back(vec[i]);
  return wec;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) cin >> vec[i];
  vector<int> wec = compress(n,vec);
  compute((int)wec.size(), wec);
  return 0;
}



Measured memory_bytes: 76020
#include<iostream>
#include<queue>
using namespace std;
#include<stdio.h>
int main(void)
{
	while (1)
	{
		int a, b, i,j, n, x, y, m[18][18] = { 0 }, u= 0;
		pair<int, int> g, h;
		queue<pair<int, int> > q;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
		{
			break;
		}
		for (i = 0; i <= a + 1; i++)
		{
			for (j = 0; j <= b + 1; j++)
			{
				if(i==0||i==a+1||j==0||j==b+1)
				{
					m[i][j] = 1;
				}
			}
		}
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d%d", &x, &y);
			m[x][y] = 1;
		}
		g.first = a;
		g.second = b;
		h.first = 1;
		h.second = 1;
		q.push(h);
		while (!q.empty())
		{
			h = q.front();
			q.pop();
			if (m[h.first + 1][h.second] != 1)
			{
				h.first++;
				q.push(h);
				h.first--;
			}
			if (m[h.first][h.second + 1] != 1)
			{
				h.second++;
				q.push(h);
				h.second--;
			}
			if (h == g)
			{
				u++;
			}
		}
		printf("%d\n", u);
	}
	return 0;
}

Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 
 
 
main()
{
    string s,t;
    cin>>s>>t;
    int m=s.size(),n=t.size();
    int ans=1e9;
    for(int i=0;i<m-n+1;i++)
    {
        int count=0;
        string a = s.substr(i,n);
        for(int j=0;j<n;j++)
        {
            if(a[j]!=t[j])
            {
                count++;
            }
        }
        ans = min(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long x[101010],v[101010];
long long sum1[101010],sum2[101010];
long long ma1[101010],ma2[101010];
int main()
{
	int n;
	long long c;
	long long ans=0;
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&v[i]);
	sum1[0]=sum2[n+1]=0;
	for(int i=1;i<=n;i++)
		sum1[i]=sum1[i-1]+v[i];
	for(int i=n;i>=1;i--)
		sum2[i]=sum2[i+1]+v[i];
	ma1[1]=sum1[1]-x[1];
	ma2[n]=sum2[n]-c+x[n];
	for(int i=2;i<=n;i++)
		ma1[i]=max(ma1[i-1],sum1[i]-x[i]);
	for(int i=n-1;i>=1;i--)
		ma2[i]=max(ma2[i+1],sum2[i]-c+x[i]);
	ans=max(ma1[n],ma2[1]);
	for(int i=1;i<n;i++)
		ans=max(ans,sum1[i]+ma2[i+1]-x[i]*2);
	for(int i=n;i>1;i--)
		ans=max(ans,sum2[i]+ma1[i-1]-(c-x[i])*2);
	printf("%lld",max((long long)0,ans));
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,now=0,mx=0;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
        if(i){
            if(vec.at(i)<=vec.at(i-1)){
                now++;
              	mx=max(mx,now);
            }
            else{
                now=0;
            }
        }
    }
    cout << mx << endl;
}

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

N = int(input())
S = input()
Q = int(input())
k = list(map(int, input().split()))

DM_total = [(0,0,0)]
C_list = []

for i in range(N):
	if S[i] == "D":
		DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
	elif S[i] == "M":
		DM_total.append((DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0]))
	else:
		DM_total.append(DM_total[-1])
	if S[i] == "C":
		C_list.append(i)

ans_list = [0]*Q
for q in range(Q):
	for c in C_list:
		if k[q] > c:
			ans_list[q] += DM_total[c + 1][2]
		else:
			ans_list[q] += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
			ans_list[q] -= DM_total[c + 1 - k[q]][0] * (DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1])

for q in range(Q):
	print(ans_list[q])

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;

    int preaji = n * (l - 1) + n * (n + 1) / 2;
    int eat;
    if (l >= 0) {
        eat = 1;
    } else if (l - 1 + n <= 0) {
        eat = n;
    } else {
        cout << preaji << ln;
        return 0;
    }
    cout << preaji - (l + eat - 1) << ln;

    return 0;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let sr=[],c=0,ans=0
  for(let i=0;i<n;i++){
    sr.push(ts().split('').sort().join(''))
  }
  sr=sr.sort()
  for(let i=0;i<n-1;i++){
    if(sr[i]==sr[i+1])c++
    else{
      ans+=(c*(c+1))/2
      c=0
    }
  }
  if(c){
    ans+=(c*(c+1))/2
    c=0
  }
  to(ans)
}
main()


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

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}


int main()
{
    /*A
    string s;
    cin>>s;
    bool flag = 0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==s[i+1])
        {
            flag = 1;
        }
    }
    if(flag)
    {
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
    */
    /*B
    int n,l;
    cin>>n>>l;
    vector <int> a(n);
    int sum=0;
    int minv=1000;
    int key=0;
    for(int i=0;i<n;i++)
    {
        a[i]=l+i;
        if(minv>abs(a[i]))
        {
            minv = abs(a[i]);
            key = a[i];
        }
        sum+=l+i;
    }
    cout<<sum-key<<endl;
    */

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll total,count1,count2 =0;
    count1 = b/c+b/d-b/lcm(c,d);
    count2 = (a-1)/c+(a-1)/d-(a-1)/lcm(c,d);
    total = b-(a-1)-(count1-count2);
    cout<<total<<endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a;
	string b;
	cin>>a>>b;
	int c=0,d=0;
	for(int i=0;i<a;i++){
		if(b[i]=='R')
			c++;
		else
			d++;
	}
	if(c>d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256