akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  int s = 0;
  for(int i=1; i<n+1; ++i) {
    int sum = 0;
    int dig = 0;
    int num = i;
    while(num){
      dig = num % 10;
      sum = sum + dig;
      num = num / 10;
    }
    if( sum >= a && sum <= b){
      s += i;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll ab, bc, ca;
    cin >>ab>>bc>>ca;

    ll x = 0.5*(ab+bc+ca);

    cout << sqrt(x*(x-ab)*(x-bc)*(x-ca)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int a,b,num=0;
  scanf("%d%d",&a,&b);
  if(b/100==1){
    num=a*1000+b;
  }
  else if(b/10!=0){
    num=a*100+b;
  }
  else{
    num=a*10+b;
  }
  int x=sqrt(num);
  if(x*x==num){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        long x = 0;
        long y = 0;

        for (int i = k; i <= n; i+=k) {
            x++;
        }

        if (k % 2 == 0) {
            for (int i = k/2; i <= n; i+=k/2) {
                if (i%k == k/2)
                    y++;
            }
        }

        System.out.println(x*x*x + y*y*y);
    }
}


Measured memory_bytes: 23252
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,x;
	cin>>n;
	db s=0;
	for0(i,n){
		cin>>x;
		s += (1.0/x);
		}
	s = (1/s);
	pf("%.5lf\n",s);
	return 0;
}

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

class E
{
	static void Main()
	{
		Func<int> read = () => int.Parse(Console.ReadLine());
		var a = new int[read()].Select(_ => read()).ToArray();

		var l = new List<int>();
		for (int i = a.Length - 1; i >= 0; i--)
		{
			var v = a[i];
			var j = SearchForInsert(l, v);
			if (j < l.Count) l[j] = v;
			else l.Add(v);
		}
		Console.WriteLine(l.Count);
	}

	static int SearchForInsert(IList<int> l, int v) => l.Count > 0 ? SearchForInsert(l, v, 0, l.Count) : 0;
	static int SearchForInsert(IList<int> l, int v, int s, int c)
	{
		if (c == 1) return v < l[s] ? s : s + 1;
		int c2 = c / 2, s2 = s + c2;
		return v < l[s2] ? SearchForInsert(l, v, s, c2) : SearchForInsert(l, v, s2, c - c2);
	}
}


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

int main(){

long long N;
string S;
cin >> N >> S;

//.....####か全部'#'or'.'
//左の黒の数と右の白の数の合計が一番少なくなる境目があるはず（だよね？）



//白と黒の累積和を作る

vector<int>w_sum(N + 1);
vector<int>b_sum(N + 1);

w_sum.push_back(0);
b_sum.push_back(0);

    for(int i = 1; i < N + 1; i++){

        if(S.at(i - 1) == '.') {
            w_sum.at(i) = w_sum.at(i - 1) + 1;
            b_sum.at(i) = b_sum.at(i - 1);           
        }else if(S.at(i - 1) == '#'){
            w_sum.at(i) = w_sum.at(i - 1);
            b_sum.at(i) = b_sum.at(i - 1) + 1;            
        }
    }

//各境目の左の黒の数と右の白の数の合計を求める。（合計の最小値を保持しながら）

int ans = N;

for(int i = 0; i < N + 1; i++){ 
     
ans = min(ans, b_sum.at(i) + (w_sum.at(N) - w_sum.at(i)));

}

cout << ans << endl; 
}

Measured memory_bytes: 2948
#include<iostream>
#include<fstream>
#include<algorithm>

using namespace std;
char c;
int a[101][101];
int main()
{
  int n,m;    
  cin>>n>>m;
  for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	  {cin>>c;if(c=='#')a[i][j]=1;}
  for(int i=1;i<=n;i++)
  {
	for(int j=1;j<=m;j++)
	  if(a[i][j]==1)  {cout<<'#';continue;}
	    else
		  cout<<a[i][j-1]+a[i][j+1]+a[i-1][j]+a[i+1][j]+a[i+1][j+1]+a[i+1][j-1]+a[i-1][j+1]+a[i-1][j-1];
    cout<<endl;  
  }  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

approvedFlag = True
for i in range(n):
  if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
    approvedFlag = False

print("APPROVED" if approvedFlag else "DENIED")

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

int	main(void)
{
	int n;
	cin >> n;
	vector<int> sum(n);
	vector<int> diff(n);
	int x, y;
	for (int i = 0; i < n; i++)
	{
		cin >> x >> y;
		sum[i] = x + y;
		diff[i] = x - y;
	}
	sort(sum.begin(), sum.end());
	sort(diff.begin(), diff.end());
	cout << max((long long)sum[sum.size() - 1] - sum[0], (long long)diff[diff.size() - 1] - diff[0]) << endl;
}

Measured memory_bytes: 4820
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }.toMutableList()
    var ans = 0
    for (i in 1 until n) {
        if (t[i] == t[i - 1]) {
            t[i] = -1
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31520
n = int(input())
a = [int(x) for x in input().split()]

c = 0
for i in range(n):
    c += a[i] * (-2 * (i%2) + 1)

sol = [c]

for i in range(1,n):
    c = c * (-1) + 2 * a[i-1]
    sol.append(c)
    
print(' '.join(map(str, sol)))

Measured memory_bytes: 84452
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define int long long
#define N 300010
struct no{
	int k,b;
	int f(int x){return k*x+b;}
}st[N];
double xl(no a,no b){
	return (b.b-a.b)/double(a.k-b.k);
}
int f[N],g[N],a[N],v[N],h[N],n,tp;
void dp(int *f){
	for(int i=1;i<=n;i++)
		v[i]=v[i-1]+a[i];
	tp=1;
	st[1]=(no){0,0};
	for(int i=1;i<=n;i++){
		while(tp>1&&st[tp].f(i)<=st[tp-1].f(i))tp--;
		f[i]=max(st[tp].f(i)+(i*i+i)/2-v[i],f[i-1]);
		no x=(no){-i,f[i]+(i*i-i)/2+v[i]};
		while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--;
		st[++tp]=x;
	}
}
void fz(int l,int r){
	if(l==r){
		h[l]=1-a[l];
		return;
	}
	int md=(l+r)/2;
	fz(l,md);
	fz(md+1,r);
	tp=0;
	for(int i=l-1;i<md;i++){
		no x=(no){-i,f[i]+(i*i-i)/2+v[i]};
		while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--;
		st[++tp]=x;
	}
	int mx=-1e9;
	int s=1;
	for(int i=r;i>md;i--){
		while(s<tp&&xl(st[s],st[s+1])>=i)s++;
		mx=max(mx,st[s].f(i)+(i*i+i)/2-v[i]+g[i+1]);
		h[i]=max(h[i],mx);
	}
	tp=0;
	for(int i=md+1;i<=r;i++){
		no x=(no){-i,g[i+1]+(i*i+i)/2-v[i]};
		while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--;
		st[++tp]=x;
	}
	s=tp;
	mx=-1e9;
	for(int i=l-1;i<md;i++){
		while(s>1&&xl(st[s],st[s-1])<=i)s--;
		mx=max(mx,st[s].f(i)+(i*i-i)/2+v[i]+f[i]);
		h[i+1]=max(h[i+1],mx);
	}
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	dp(f);
	reverse(a+1,a+n+1);
	dp(g);
	reverse(a+1,a+n+1);
	reverse(g+1,g+n+1);
	for(int i=1;i<=n;i++)
		v[i]=v[i-1]+a[i];
	fz(1,n);
	int q,x,y;
	cin>>q;
	while(q--){
		cin>>x>>y;
		cout<<max(f[x-1]+g[x+1],h[x]-y+a[x])<<'\n';
	}
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;

int main()
{
    int n, k, index;
    long a[100005];
    long suma[100005];
    long ans[10];
    index = 0;
    REP(i, 10){
        cin >> n >> k;
        if(n == 0 && k == 0)
            break;
        REP(j, n)
            cin >> a[j];
        suma[0] = 0;
        REP(j, n)
            suma[j+1] = suma[j] + a[j];
        REP(j, n-k+1){
            if(j==0)
                ans[index] = suma[j+k] - suma[j];
            else{
                if(ans[index] < (suma[j+k] - suma[j]))
                    ans[index] = suma[j+k] - suma[j];
            }
        }
        index++;
    }
    REP(i, index)
        cout << ans[i] << endl;

    
    

    return 0;
}




Measured memory_bytes: 4548
let cnt = ref 0
let g = ref []

let print_list l =
  List.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) l;
  print_newline ()

let print_array a = Array.iter (fun n -> Printf.printf "%d\n" n) a

let insertion_sort a n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + g) <- v
    else (a.(j + g) <- a.(j); incr cnt; insert (j - g) v)
  in
  let rec doit i =
    if i >= n then ()
    else (insert (i - g) a.(i); doit (i + 1))
  in
  doit g

let rec power m = function
  | 0 -> 1
  | n when n mod 2 = 0 -> power (m * m) (n / 2)
  | n -> m * power m (n - 1)

let generate_g n =
  let rec doit i lst =
    if lst <> [] && List.hd lst > n then List.tl lst
    else doit (i + 1) ((power 4 i + 3 * power 2 (i - 1) + 1) :: lst)
  in
  doit 1 [1]

let shell_sort a n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in
  doit !g

let () =
  let n = read_int () in
  let a = Array.make n 0 in
  let rec doit i =
    if i >= n then ()
    else (a.(i) <- read_int (); doit (i + 1))
  in
  doit 0;
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  print_list !g;
  Printf.printf "%d\n" !cnt;
  print_array a

Measured memory_bytes: 12384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

signed main() {
    int h,w;
    cin >> h >> w;

    vector<int> cnt(26, 0);
    rep(i,h) rep(j,w){
        char c;
        cin >> c;
        cnt[c - 'a']++;
    }

    int four = 0, two = 0;
    for(int i = 0; i < 26; i++){
        four += cnt[i] / 4;
        cnt[i] %= 4;
        two += cnt[i] / 2;
    }

    four -= (h / 2) * (w / 2);
    if(four < 0) {
        cout << "No" << endl;
        return 0;
    }

    two += four * 2;
    if(h % 2 == 1) two -= (w / 2);
    if(w % 2 == 1) two -= (h / 2);

    if(two < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll ans = accumulate(a.begin(),a.end(),0LL);
    vector<ll>b,c;
    rep(i,n)if(a[i] < 0){
        b.push_back(a[i]);
    }else{
        c.push_back(a[i]);
    }
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    if(b.size()%2==0){
        cout << -accumulate(b.begin(),b.end(),0LL) + accumulate(c.begin(),c.end(),0LL) << endl;
        return 0;
    }
    ll sum = -accumulate(b.begin(),b.end(),0LL) + accumulate(c.begin(),c.end(),0LL);
    if(c.size()==0){
        cout << -ans + 2 * b.back() << endl;
        return 0;
    }
    ll d = 0;
    ll e = 0;
    if(c.size())d = c[0];
    if(b.size())e = b.back();
    sum -= d;
    
    sum += e;
    show(sum);
    cout << max({ans,sum+d+e,sum-d-e,-ans}) << endl;
}

Measured memory_bytes: 2424
#include <stdio.h>
void Print_a_Rectangle(unsigned int H, unsigned int W)
{
    unsigned short i,j;
    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            if((i+j)%2==0)
            {
                printf("#");
            }
            else
            {
                printf(".");
            }
        }
        printf("\n");
    }
}

int main()
{
    unsigned int H,W;
    while(1)
    {
        scanf("%d %d",&H,&W);
        if((H==0)&&(W==0))
        {
            break;
        }
        else
        {
            Print_a_Rectangle(H,W);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//子どもを全て記録してく？
//配列2*10^5の高さに2*10^5のデータは無理そう
//毎回DFSするか
//Q操作のたびに値を足していく、は避けられない？
//ああああ、まず自身だけ足すのか

vector<vector<ll>> T;
vector<ll> cnt;

void DFS(ll p, ll x, ll pre){
  for(ll n:T[p]){
    if(n==pre) continue;
    cnt[n]+=x;
    DFS(n,cnt[n],p);
  }
}

int main(){
  ll N,Q; cin>>N>>Q;
  T.assign(N+1, vector<ll>(0,0));
  cnt.assign(N+1,0);
  for(int i=0; i<N-1; i++){
    ll a,b; cin>>a>>b;
    T[a].emplace_back(b);
    T[b].emplace_back(a);
  }
  for(int i=0; i<Q; i++){
    ll p,x; cin>>p>>x;
    cnt[p]+=x;
  }
  DFS(1,cnt[1],0);
  for(int i=1; i<=N; i++){
    cout<<cnt[i];
    if(i<N)
      cout<<" ";
  }
}

Measured memory_bytes: 24320
#include<stdio.h>
int main(){
  int X,Y;
  scanf("%d",&X);
  scanf("%d",&Y);
  
  if(Y-2*X >= 0 && (Y-2*X) % 2 == 0){
   if(4*X-Y >= 0 && (4*X-Y) % 2 == 0){
  	printf("Yes\n");
   }else{
    printf("No\n"); 
   }
  }else{
   printf("No\n"); 
  }
 return 0; 
}

Measured memory_bytes: 1616
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int a[n][3];
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];

    int dp[n][3];
    rep(i,n) rep(j,3) dp[i][j] = 0;
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(int i=1; i<n; i++){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                dp[i][j] = max(dp[i-1][k]+a[i][j], dp[i][j]);
            }
        }
    }

    int res = 0;
    rep(j,3) res = max(res, dp[n-1][j]);
    cout << res << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int idx;
      cin >> idx; --idx;
      a[idx]++;
    }
  }

  int ans = 0;
  rep(i, m) {
    if (a[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a,b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


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

public class Main {
	static int n = 26, d;
	static int[] c;
	static int[][] s;

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		d = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		s = new int[d][n];
		for (int i = 0; i < d; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				s[i][j] = Integer.parseInt(sa[j]);
			}
		}
		br.close();

		int[] t = new int[d];
		int[] last = new int[n];
		for (int i = 0; i < d; i++) {
			int max = -1;
			int idx = -1;
			for (int j = 0; j < n; j++) {
				int val = s[i][j] + c[j] * (i + 1 - last[j]);
				if (val > max) {
					max = val;
					idx = j;
				}
			}
			t[i] = idx;
		}

		for (int i = 0; i < d; i++) {
			int max = Integer.MIN_VALUE;
			int idx = t[i];
			for (int j = 0; j < n; j++) {
				t[i] = j;
				int val = calc(t, i);
				if (val > max) {
					max = val;
					idx = j;
				}
			}
			t[i] = idx;
		}

		long mt = 0;
		while (System.currentTimeMillis() - start < 1900 - mt) {
			long l = System.currentTimeMillis();
			for (int i = 0; i < d; i++) {
				int max = Integer.MIN_VALUE;
				int idx = t[i];
				for (int j = 0; j < n; j++) {
					t[i] = j;
					int val = calc(t, d - 1);
					if (val > max) {
						max = val;
						idx = j;
					}
				}
				t[i] = idx;
			}
			mt = Math.max(mt, System.currentTimeMillis() - l);
		}

		for (int i = 0; i < d; i++) {
			System.out.println(t[i] + 1);
		}
	}

	static int calc(int[] t, int end) {
		int[] last = new int[n];
		int ret = 0;
		for (int i = 0; i <= end; i++) {
			ret += s[i][t[i]];
			last[t[i]] = i + 1;
			for (int j = 0; j < n; j++) {
				ret -= c[j] * (i + 1 - last[j]);
			}
		}
		return ret;
	}

//	static int[] calc(int[] t, int end) {
//		int[] last = new int[n];
//		int[] ret = new int[end];
//		for (int i = 0; i < end; i++) {
//			if (i > 0) {
//				ret[i] += ret[i - 1];
//			}
//			ret[i] += s[i][t[i]];
//			last[t[i]] = i + 1;
//			for (int j = 0; j < n; j++) {
//				ret[i] -= c[j] * (i + 1 - last[j]);
//			}
//		}
//		return ret;
//	}
}


Measured memory_bytes: 51872
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();

		if (x == 2 && y == 2) {
			System.out.println("Yes");
		} else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) &&( y == 1 || y == 3 || y == 5
				|| y == 7 || y == 8 || y == 10 || y == 12)) {
			System.out.println("Yes");
		} else if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std; 
ll N = pow(10,10);
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	ll arr[2*n];
	for(int i=0;i<2*n;i++){
		ll l;cin>>l;
		arr[i] = l;
	}
	sort(arr,arr+2*n);
	ll sum=0;
	for(int i=0;i<2*n;i+=2){
		sum += arr[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define int long long
#define lim 8001
#define M 82
using namespace std;
int h,w;
int a[M+2][M+2],b[M+2][M+2],dp[M+2][M+2][lim+2],vis[M+2][M+2];
void solve(int x,int y)
{
    if(x<h && x>=0 && y<w && y>=0)
    {
        if(vis[x][y])return;
        vis[x][y]=1;
        if(x==h-1 && y==w-1)
        {
            int tmp=abs(a[x][y]-b[x][y]);
            dp[x][y][tmp]=1;
        }
        else
        {
            solve(x+1,y);
            solve(x,y+1);
            int tmp=abs(a[x][y]-b[x][y]);
            if(x+1<h && x+1>=0 && y<w && y>=0)
            {
                for(int i=0;i<lim;i++)
                {
                    if(dp[x+1][y][i])
                    {
                        if(abs(i+tmp)<lim)
                        {
                            dp[x][y][abs(i+tmp)]=1;
                        }
                         if(abs(i-tmp)<lim)
                        {
                            dp[x][y][abs(i-tmp)]=1;
                        }
                    }
                }
            }
            if(x<h && x>=0 && y+1<w && y+1>=0)
            {
                for(int i=0;i<lim;i++)
                {
                      if(dp[x][y+1][i])
                      {
                          if(abs(i+tmp)<lim)
                          {
                              dp[x][y][abs(i+tmp)]=1;
                          }
                          if(abs(i-tmp)<lim)
                          {
                              dp[x][y][abs(i-tmp)]=1;
                          }
                      }
                }
            }
        }
    }
}
main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>b[i][j];
        }
    }
    solve(0,0);
    int ses=1e10;
    for(int i=0;i<6000;i++)
    {
        if(dp[0][0][i])
        {
            ses=i;
            break;
        }
    }
    cout<<ses<<endl;
    return 0;

}


Measured memory_bytes: 422272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int d;
    cin>>d;
    vector<int> c(26);
    rep(i,26){
        cin>>c[i];
    }
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    vector<int> last(d,0);
    rep(i,d){
        int cnt=-INF;
        int ans;
        rep(t,26){
            int now=0;
            now+=s[i][t];
            int tmp=last[t];
            last[t]=i+1;
            rep(j,26){
                now-=c[j]*(i+1-last[j]);
            }
            last[t]=tmp;
            if(chmax(cnt,now)){
                ans=t+1;
            }
        }
        cout<<ans<<endl;
    }   
}

Measured memory_bytes: 3732
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    
    long ans = a * c > a * d ? a * c : a * d;
    ans = b * c > ans ? b * c : ans;
    ans = b * d > ans ? b * d : ans;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 35776
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int k = sc.NextInt();
        string s = sc.Next();
        if (s.Length <= k)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine($"{s.Substring(0, k)}...");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

ab=ab[::-1]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
        
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n) #初期化
result=[]
all_iland=n*(n-1)//2

for item in ab[0:-1]:
    a=item[0]-1
    b=item[1]-1
    if uf.same(a,b):
        i=1
    else:
        a_size=uf.size(a)
        b_size=uf.size(b)

        all_iland+=a_size*(a_size-1)//2+b_size*(b_size-1)//2
        uf.union(a,b)

        a_size=uf.size(a)
        all_iland-=a_size*(a_size-1)//2
    result.append(all_iland)


for item in result[::-1]:
    print(item)

print(n*(n-1)//2)






#uf.union(0, 2)#グループを併合
#uf.find(0) #親要素が変える






Measured memory_bytes: 133336
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;

const int INF = 1e+8;
int N, M, L;

struct edge{
	int to, d, cost;
	edge(int to_, int d_, int cost_){
		to = to_; d = d_; cost = cost_;
	}
};
struct State{
	int cost, l, v;
	State(int cost_, int l_, int v_){
		cost = cost_; l = l_; v = v_;
	}
};
bool operator<(const State &a, const State &b){
	if( a.cost < b.cost ) return false;
	if( a.cost > b.cost ) return true;
	if( a.l < b.l ) return true;
	if( a.l > b.l ) return false;
	return a.v < b.v;
}
vector<edge> G[101];

void add_edge(int u, int v, int d, int cost){
	G[u].push_back( edge(v, d, cost) );
	G[v].push_back( edge(u, d, cost) );
}

// dp[l][v] := テ、ツスツソテ」ツ?」テ」ツ?淌、ツコツ暗ァツョツ療」ツ??l テ」ツ?ァテゥツ?づァツつケテ」ツ??v テ」ツ?ョテ」ツ?ィテ」ツ?催」ツ?ョティツ・ツイテ」ツつ湘」ツつ古」ツ?淌ヲツ閉オテ」ツ?ョテヲツ閉ー
int dp[101][101];

int dijkstra(){
	for(int i=0 ; i < 101 ; i++ ){
		for(int j=0 ; j < 101 ; j++ ){
			dp[i][j] = INF;
		}
	}
	priority_queue<State> q;
	q.push( State(0, 0, 0) );
	dp[0][0] = 0;
	
	int res = INF;
	while( !q.empty() ){
		int cost = q.top().cost, l = q.top().l, v = q.top().v;
		q.pop();
		if( v == N-1 ){
			res = min(res, cost);
			continue;
		}
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			int to = G[v][i].to, d = G[v][i].d;
			
			// テ」ツ?甘ゥツ?妥」ツつ津、ツスツソテ」ツ??
			if( l + d <= L ){
				int next_l = l + d;
				int next_cost = cost;
				if( next_cost < dp[next_l][to] ){
					dp[next_l][to] = next_cost;
					q.push( State(next_cost, next_l, to) );
				}
			}
			// テ」ツ?甘ゥツ?妥」ツつ津、ツスツソテ」ツつ湘」ツ?ェテ」ツ??
			int next_cost = cost + G[v][i].cost;
			if( next_cost < dp[l][to] ){
				dp[l][to] = next_cost;
				q.push( State(next_cost, l, to) );
			}
		}
	}
	return res;
}

int main(){
	while( cin >> N >> M >> L , N || M || L ){
		for(int i=0 ; i < 101 ; i++ ) G[i].clear();
		
		for(int i=0 ; i < M ; i++ ){
			int A, B, C, D;
			cin >> A >> B >> C >> D;
			A--; B--;
			add_edge(A, B, C, D);
		}
		cout << dijkstra() << endl;
	}
}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  
  vector<int> D;
  for(int i=0; i<N; ++i){
    int a;
    cin>>a;
    D.push_back(a);
  }
  
  sort(D.begin(),D.end());
  
  ans=D.at(N/2)-D.at(N/2-1);
  
  if(D.at(N/2-1)==D.at(N/2)) ans=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;


string des = "11100000111";

int A,B,N;

bool truth(int a, int b) {
    if (a == b) return 1;
    cout << "? " << a << " " << b << endl;
    char c; cin >> c;
    
    /*if (des[a] == '1') {
        if (des[b] == '1') c = 'Y';
        else c = 'N';
    } else {
        c = 'N';
        //if (rand()&1) c = 'Y';
        //else c = 'N';
    }
    cout << "HI " << c << "\n";*/
    
    if (c == 'Y') return 1;
    return 0;
}

int main() {
    srand(time(0));
    cin >> A >> B; N = A+B;
    if (A <= B) {
        cout << "Impossible";
        exit(0);
    }
    pi cur = {0,0};
    F0R(i,N) {
        if (cur.s == 0) cur = {i,1};
        else {
            if (truth(i,cur.f)) cur.s ++;
            else cur.s --;
        }
    }
    string ans;
    F0R(i,N) if (truth(cur.f,i)) ans += '1';
    else ans += '0';
    cout << "! " << ans << endl;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int delim = 0;
  for(int i = 0; i < n - 1; ++i){
    if(s[i] != s[i + 1]) delim++;
  }
  cout << n - 1 - max(0, (delim - 2 * k)) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vec vector
#define pb push_back
#define pop pop_back
#define STF() shrink_to_fit()
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define arrin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define arrout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
//ll mod = 1000000007;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	ll n;
	cin >> n;
	vec <ll> v(n);
	vecin(v, n, 0);
	ll maxe = v[0], total = 0;
	FOR(i, 1, n) {
		if (v[i] < v[i - 1]) {
			total += v[i - 1] - v[i];
			v[i] = v[i - 1];
		}
		else maxe = v[i];
	}
	cout << total << endl;
}


Measured memory_bytes: 4732
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
vector<LL> a;
map<LL, LL> b;
/**********************************************/

int main(){
    cin >> n;
    a.resize(n+5);
    REP(i, n) cin >> a[i];
        sort(a.begin(), a.end(), std::greater<LL>());
    
    LL pre = -1;
    LL tmp = -1;
    int cnt = 0;
    REP(i, n){
        if(cnt == 1 && pre == a[i]){
            LL ans = tmp * a[i];
            cout << ans << endl;
            return 0;
        }else if(cnt == 0 && pre == a[i]){
            tmp = a[i];
            pre = -1;
            cnt++;
        }else{
            pre = a[i];
        }
    }

    cout << 0 << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long lint;

int main()
{
	char s[4096], t[4096];
	static int dp[2][4096];
	
	while (scanf("%s", s) == 1){
		scanf("%s", t);
		
		memset(dp, 0, sizeof(dp));
		
		int ans = 0;
		
		for (int i = 1; s[i - 1]; i++){
			for (int j = 1; t[j - 1]; j++){
				if (s[i - 1] == t[j - 1])
					dp[i & 1][j] = dp[(i - 1) & 1][j - 1] + 1;
				else dp[i & 1][j] = 0;
				ans = max(ans, dp[i & 1][j]);
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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


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


void solve() {
	int n; cin >> n;
	int h[20]; rep(i, n) cin >> h[i];
	int Mh = 0;
	int ans = 0;
	rep(i, n) {
		if (h[i] >= Mh) ans++;
		Mh = max(Mh, h[i]);
	}
	cout << ans << endl;
}

int main() {


	solve();


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 10000000000000
#define mod1 998244353
#define Mmax 1000005
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
bool comp(pair<li,pair<li,li>>a,pair<li,pair<li,li>>b)
{
  if(a.first<b.first)
  return 1;
  else if(a.first>b.first)
  return 0;
  else
  {
    return a.second.first<b.second.first;
  }
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=(ans%mod)*(x%mod)%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
li modInverse(li n)
{
    return mpow(n, mod-2);
}

li nCrModPFermat(li n, li r,li x,li y,li z)
{
   // Base case
   if (r==0)
      return 1;
    // li fac[n+1];
    // fac[0] = 1;
    // for (int i=1 ; i<=n; i++)
    //     fac[i] = fac[i-1]*i%mod;
    return (x* modInverse(y) % mod *modInverse(z) % mod) % mod;
}
void bfs(vector<li>v[],li visit[],li s,li ans[])
{
  deque<li>q;
  q.push_back(s);
  visit[s]=1;
  while(!q.empty())
  {
    li x=q.front();
    q.pop_front();
    for(auto i=v[x].begin();i!=v[x].end();i++)
    {
      if(!visit[*i])
      {
        q.push_back(*i);
        visit[*i]=1;
      }
    }
  }
}
void buildtree(int*tree,int*arr,int start,int end,int treeNode)
{
  if(start<end)
  {
    int mid=start+(end-start)/2;
    buildtree(tree,arr,start,mid,2*treeNode);
    buildtree(tree,arr,mid+1,end,2*treeNode+1);
    tree[treeNode]=tree[2*treeNode]+tree[2*treeNode+1];
  }
}
void update(int*tree,int*arr,int start,int end,int pos,int val,int treeNode)
{
  if(start==end)
  tree[treeNode]=val;
  else
  {
    int mid=start+(end-start)/2;
    if(pos<=mid)
    update(tree,arr,start,mid,pos,val,2*treeNode);
    else
    update(tree,arr,mid+1,end,pos,val,2*treeNode+1);
    tree[treeNode]=tree[2*treeNode]+tree[2*treeNode+1];
  }
}

void dfs(vector<li>v[],li visit[],li s,li c[],li ans[],map<li,li>*m,li pred[])
{
    visit[s]=1;
     (*m)[c[s]]++;
    for(auto i=v[s].begin();i!=v[s].end();i++)
      {
        if(!visit[*i])
        {pred[*i]=s;
           dfs(v,visit,*i,c,ans,m,pred);
        }
      }
      if((*m)[c[pred[s]]]==1)
    ans[s]=(*m).size()-1;
    else
    ans[s]=(*m).size();
}
vector<li>factor(li n)
{
  vector<li>v;
  if(n%2==0)
  {
    while(n%2==0)
    {n/=2;
    v.push_back(2);
    }
  }
  for(li i=3;i<=sqrt(n);i+=2)
  {
    if(n%i==0)
    {
      while(n%i==0)
      {n/=i;
      v.push_back(i);
      }
    }
  }
  if(n>1)
  v.push_back(n);
  return v;
}
int main()
{
// li t,i,j;
// cin>>t;
// while(t--)
// {
//
//   cout<<endl;
// }
li n,m,i,j,x,y;
cin>>n>>m;
vector<li>v[n];
li a[n];
for(i=0;i<n;i++)
cin>>a[i];
while(m--)
{
  cin>>x>>y;
  v[x-1].push_back(y-1);
  v[y-1].push_back(x-1);
}
li ans=0;
for(i=0;i<n;i++)
{
  li ma=0;
  for(j=0;j<v[i].size();j++)
  ma=max(ma,a[v[i][j]]);
  if(ma<a[i])
  ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 10236
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll X;
	cin >> X;

	ll ans1;
	ll ans2;

	for (ll b = 0; b*b*b*b <= X; b++) {
		for (ll a = 0; a*a*a*a <= X; a++) {
			if (a*a*a*a*a - b*b*b*b*b == X) { ans1 = a; ans2 = b; }
			if (a*a*a*a*a + b*b*b*b*b == X) { ans1 = a; ans2 = -b; }
		}
	}

	cout << ans1 << " " << ans2 << endl;
	
	system("PAUSE");
}


Measured memory_bytes: 3684
N,M=gets.chomp.split(" ").map(&:to_i);
H=gets.chomp.split(" ").map(&:to_i);
#line = readlines.split(" ").map(&:to_i)
line = M.times.map { gets.split.map(&:to_i) }
#N = 6
#M = 5
#H=[8,6,9,1,2,1]
#line = [[1,3],[4,2],[4,3],[4,6],[4,6]]
clist=Array.new(N)
i=0
while i<line.length
  if H[line[i][0]-1]>H[line[i][1]-1]
    #H[i][1]番目はない
    clist[line[i][1]-1]="no"
  elsif H[line[i][0]-1]<H[line[i][1]-1]
    #H[i][0]番目はない
    clist[line[i][0]-1]="no"
  elsif H[line[i][0]-1]==H[line[i][1]-1] && clist[line[i][0]-1]="no" 
    clist[line[i][1]-1]="no"
  elsif H[line[i][0]-1]==H[line[i][1]-1] && clist[line[i][1]-1]="no" 
    clist[line[i][0]-1]="no"
  end
  i+=1
end
count = 0

j=0
while j < clist.length
  if clist[j].nil?
    count+=1
  end
  j+=1
end

p count

Measured memory_bytes: 24976
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,k,l,rem=0,rem1=0;
    cin>>n;
    rem=n/500;
//    cout<<rem<<endl;
    n=n-(rem*500);
    rem1=n/5;
//    cout<<rem1<<endl;
    l=(rem*1000)+rem1*5;
    cout<<l<<endl;
}


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

int main(){
  int n;
   cin >> n;
  int ans=0;
  for(int i=0; i<n; i++){
    lli p;
  cin >> p;
  
   while(p%2==0){
     p /= 2;
     ans++;
   }
  }
  
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
constexpr double eps=1e-10;
signed main(){
    int n;
    double x[50],y[50];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i]>>y[i];
    double ans=mod;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            for(int k=0;k<j;k++){
                double a=x[i],b=y[i],c=x[j],d=y[j],e=x[k],f=y[k];
                double py=((e-a)*(a*a+b*b-c*c-d*d)-(c-a)*(a*a+b*b-e*e-f*f))/(2*(e-a)*(b-d)-2*(c-a)*(b-f));
                double px;
                if(c==a)
                    px=(2*(b-f)*py-a*a-b*b+e*e+f*f)/(2*(e-a));
                else
                    px=(2*(b-d)*py-a*a-b*b+c*c+d*d)/(2*(c-a));
                double r=hypot(px-a,py-b);
                bool ok=1;
                for(int l=0;l<n;l++)
                    if(r-hypot(px-x[l],py-y[l])<-eps)
                        ok=0;
                if(ok)
                    ans=min(ans,r);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            double a=x[i],b=y[i],c=x[j],d=y[j];
            double px=(a+c)/2,py=(b+d)/2;
            double r=hypot(px-a,py-b);
            bool ok=1;
            for(int k=0;k<n;k++)
                if(r-hypot(px-x[k],py-y[k])<-eps)
                    ok=0;
            if(ok)
                ans=min(ans,r);
        }
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
d = 0
for i in range(0, n):
  if a[i:i+1] != b[i:i+1] and b[i:i+1] != c[i:i+1] and a[i:i+1] != c[i:i+1]:
    d += 2
  if a[i:i+1] == b[i:i+1] and b[i:i+1] == c[i:i+1] and a[i:i+1] == c[i:i+1]:
    d += 0
  if a[i:i+1] != b[i:i+1] and b[i:i+1] == c[i:i+1] and c[i:i+1] != a[i:i+1]:
    d += 1
  if a[i:i+1] == b[i:i+1] and b[i:i+1] != c[i:i+1] and c[i:i+1] != a[i:i+1]:
    d += 1
  if a[i:i+1] != b[i:i+1] and b[i:i+1] != c[i:i+1] and c[i:i+1] == a[i:i+1]:
    d += 1
print(d)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 2003;
bitset<N> beat[N], dpl[N], dpr[N];
int n, ans;
char s[N];
int main(){
	scanf("%d", &n);
	for(Rint i = 2;i <= n;i ++){
		scanf("%s", s + 1);
		for(Rint j = 1;j < i;j ++)
			if(s[j] != '0') beat[i].set(j);
			else beat[j].set(i);
	}
	for(Rint i = 1;i <= n;i ++) dpl[i][i] = dpr[i][i] = 1;
	for(Rint len = 1;len < n;len ++)
		for(Rint i = 1;i <= n - len;i ++){
			int j = i + len;
			if((dpl[j] & dpr[i + 1] & beat[i]).any()) dpl[j].set(i);
			if((dpl[j - 1] & dpr[i] & beat[j]).any()) dpr[i].set(j);
		}
	for(Rint i = 1;i <= n;i ++) if(dpr[1][i] && dpl[n][i]) ++ ans;
	printf("%d", ans);
}

Measured memory_bytes: 1792