akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


struct Mo{
  using F = function<void(int)>;
  vector<int> l,r,ord;
  int n,wid,nl,nr,ptr;
  F expandL,expandR;
  F shrinkL,shrinkR;
  Mo(int n,int wid,F expandL,F expandR,F shrinkL,F shrinkR):
    n(n),wid(wid),nl(0),nr(0),ptr(0),
    expandL(expandL),expandR(expandR),shrinkL(shrinkL),shrinkR(shrinkR){}
  Mo(int n,int wid,F expand,F shrink){
    *this = Mo(n,wid,expand,expand,shrink,shrink);
  }
  // add queries [l, r)
  inline void add(int a,int b){
    l.emplace_back(a);
    r.emplace_back(b);
  }
  // after all add()
  void build(){
    ord.resize(l.size());
    iota(ALL(ord),0);
    sort(ALL(ord),[&](int a,int b){
      if(l[a]/wid != l[b]/wid)return l[a] < l[b];
      if(r[a] == r[b])return l[a] < l[b];
      return bool((r[a] < r[b])^((l[a]/wid) & 1));
    });
  }
  inline int process(){
    if(ptr == (int)ord.size())return -1;
    const int idx = ord[ptr++];
    while(nl > l[idx])expandL(--nl);
    while(nr < r[idx])expandR(nr++);
    while(nl < l[idx])shrinkL(nl++);
    while(nr > r[idx])shrinkR(--nr);
    return idx;
  }
};


int main(){
  
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,Q;
  cin >> n >> Q;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  int sum = 0;
  vector<int> cnt(n+1);
  auto expand = [&](int k){
    sum += cnt[v[k]]++==0;
  };
  auto shrink = [&](int k){
    sum-=--cnt[v[k]]==0;
  };
  Mo mo(n,1000,expand,shrink);
  rep(_,Q){
    int a,b;cin >> a >> b;
    mo.add(--a,b);
  }
  vector<int> res(Q);
  mo.build();
  rep(_,Q){
    int idx = mo.process();
    res[idx] = sum;
  }
  rep(i,Q)cout << res[i] << "\n";



  return 0;
}

Measured memory_bytes: 15708
#include <bits/stdc++.h>
using namespace std;
int n,a[3],x,y;
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    sort (a,a+3);
    for (int i=1;i<3;i++)
    {
        x+=abs(a[i]-a[i-1]);
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		
		int ans = -1;
		
		for(int i = 1; i<1500; i++) {
			if(i*8/100 == A && i*10/100 == B) {
				ans = i;
				break;
			} 
		}
				
		System.out.print(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 35728
#include <cstdio>
#include <cstdint>
#include <utility>
#include <algorithm>
#include <vector>

int main() {
  intmax_t n;
  scanf("%jd", &n);

  if (n % 2 != 0) return puts("0"), 0;
  if (n == 0) return puts("0"), 0;
  n /= 2;

  intmax_t res = 0;
  for (intmax_t fivepow = 5; true;) {
    res += n / fivepow;
    if (__builtin_mul_overflow(fivepow, 5, &fivepow)) break;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        if(s == 1) {
            System.out.println(4);
            return;
        }
        if(s == 2) {
            System.out.println(4);
            return;
        }
        int ans = 1;
        while(true) {
            if(s == 1) {
                ans++;
                break;
            }
            if(s % 2 == 0) {
                s /= 2;
            } else {
                s = s * 3 + 1;
            }
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35664
#include <iostream>

using namespace std;

int main()
{
    int N,sum=0;
    cin >> N;
    int *X;
    X = new int[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
        sum+=X[i];
    }
    int p;
    if(sum%N>N/2){
        p = sum/N+1;
    }else{
        p = sum/N;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        ans += (X[i]-p)*(X[i]-p);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
stop = false
max = 0
l = s.length
l.downto(1){|x|
    0.upto(l - x){|y|
        if ((s[y, x].split("")) - ["A","C","G","T"]).length == 0
            max = x
            stop = true
            break
        end
    }
    break if stop
}
puts max

Measured memory_bytes: 1788
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int M = nextInt();

		int[][] AB = new int[N][2];
		for(int i=0;i<N;i++) {
			AB[i] = nextIntArray(2);
		}
		Arrays.sort(AB,(a1,a2)->Integer.compare(a2[1],a1[1]));
		Arrays.sort(AB,(a1,a2)->Integer.compare(a1[0],a2[0]));

		List<Integer> list = new ArrayList<Integer>();
		long sum = 0;
		int AB_i = 0;
		for(int l=1;l<=M;l++) {
			int Search_l = -1;
			while(AB_i<N&&AB[AB_i][0]==l) {
				int Insert_i = Search(list ,AB[AB_i][1],Search_l);
				list.add(Insert_i,AB[AB_i][1]);
				AB_i++;
			}

			if(list.size()>0) {
				sum+=list.get(0);
				list.remove(0);
			}
		}

		out.println(sum);
	}

	//二部探索
	static int Search(List<Integer> list, int k, int Search_l) {
		int l = Search_l;
		int r = list.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(list.get(mid) <= k) r = mid;
			else l = mid;
		}
		return r;
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mod = 1e9+7;

const int nax = 1001;
char grid[nax][nax];

void add_self(int &a, int b){
    a = a + b;
    if(a >= mod) a -= mod;
}

void solve(){
    int h, w;
    cin>>h>>w;
    vector<vector<int>> dp(h, vector<int>(w, 0));
    fr(i, h) fr(j, w) cin>>grid[i][j];

    dp[0][0] = 1;
    for(int row = 0; row < h; row++){
        for(int col = 0; col < w; col++){
            for(auto r2: {row, row+1}){
                int c2 = col;
                if(r2 == row){
                    c2 = col+1;
                }
                if(r2 < h && c2 < w && grid[r2][c2] == '.'){
                    add_self(dp[r2][c2], dp[row][col]);
                }

            }
        }
    }

    cout<<dp[h-1][w-1];

}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
s=set()
for i, ai in enumerate(A):
    if ai in s:
        print("NO"); exit()
    else:
        s.add(ai)
print("YES")

Measured memory_bytes: 89456
#include<stdio.h>

int main(void){
    int n, m;
    long long int dp[100001];
    scanf("%d%d",&n,&m);
    int a[100001];
    for(int i=0;i<m;i++){
        scanf("%d",&a[i]);
    }
    int k=0;
    for(int i=0;i<n+1;i++){
        if(i==0){dp[i]=1;}
        else if(i==a[k]){dp[i]=0;k++;}
        else if(i==1){dp[i]=1;}
        else{
            dp[i] = (dp[i-1] + dp[i-2])%1000000007;
        }     
    }
    printf("%lld\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n, 0);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    int ret = 0;
    for (int i = 1; i < n; ++i)
    {
        if (a[i - 1] == a[i])
        {
            a[i] = -i;
            ret++;
        }
    }
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()
x = input()

ct = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ct += 1

print ct

Measured memory_bytes: 2568
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}

	count := 0
	for i := 1; i < n-1; i++ {
		first, middle, last := arr[i-1], arr[i], arr[i+1]
		if (first < middle && middle < last) || (first > middle && middle > last) {
			count++
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 512
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        n: i64,
        p: [i64; n]
    }

    let mut l = vec![0; 102usize];
    let mut t = vec![];
    for i in 0..n as usize {
        l[p[i] as usize] += 1;
    }
    for i in 0..102usize {
        if l[i] == 0 {
            t.push(i as i64);
        }
    }

    // for i in 0..t.len() {
    //     println!("{}", t[i]);
    // }

    let mut idx = 0;
    for i in 0..t.len() {
        if (t[idx] as i64 - x).abs() > (t[i] as i64 - x).abs() {
            idx = i;
            // ans = t[i]
        }
    }
    println!("{}", t[idx]);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define ps(x,y)         fixed<<setprecision(y)<<x
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    const int MAX=1000000+5;
    int p[MAX]={0};

     int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}
    bool isPrime(int n) 
    { 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
    } 
    int mm[200000+5];
    int vis[200000+5]={0};
    signed main() {

 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
   // cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        int cnt=n*3+m;
        cout<<cnt/2<<endl;       
    }
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long int n,x=0;
cin>>n;

    x=n/15;
    x*=200;
    n*=800;
    cout<<n-x<<"\n";


    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    int n,two=0,four=0;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]%4==0){
            four++;
        }
        if(a[i]%2==0){
            two++;
        }
    }
    two=two-four;
    if(n%2==0||n%2==1){
        if((two/2)+four>=n/2){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
}

Measured memory_bytes: 640
# cf16-exhibition-final-openC - Cheating Nim
import sys
input = sys.stdin.readline


def main():
    # player is second move -> make xor 0
    N = int(input())
    A = sorted(map(int, [input() for _ in range(N)]), reverse=1)
    ans, x, flg = 0, 0, [0] * 30
    for i in A:
        x ^= i
        p = bin(i ^ i - 1)[::-1].rfind("1")
        flg[p] = 1
    for i in range(29, -1, -1):
        p = 2 ** i
        if x & p:  # i-th bit is on
            if flg[i]:  # possible to erase i-th bit of x
                x ^= p - 1
                ans += 1
            else:
                print(-1)
                return
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14264
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

bool check(vector<int> a, vector<int> x) {
  int N = (int)x.size();
  vector<int> y(N);
  vector<int> count(N+1);
  for (int i = 0; i < N * N; i++) {
    count[ a[i] ]++;
    if (count[a[i]] == a[i]) {
      y[a[i] - 1] = i+1;
    }
  }
  // REP(i, N) cout << y[i] << " "; cout << endl;
  return x == y;
}

vector<int> indexSort(vector<int> x) {
  int N = (int)x.size();
  vector< pair<int,int> > v;
  REP(i, N) v.emplace_back(x[i], i);
  sort(v.begin(), v.end());
  vector<int> res;
  REP(i, N) res.emplace_back(v[i].second);
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  REP(i, N) cin >> x[i];
  vector<int> ans(N * N, -1);
  REP(i, N) ans[x[i] - 1] = (i+1);
  // REP(i, N * N) cout << ans[i] << " "; cout << endl;

  vector<int> r = indexSort(x);

  for (int iii = 0; iii < N; iii++) {
    int i = r[iii] + 1;
    int p = 0;
    for (int j = 0; j < N*N && p < i-1; j++) if (ans[j] == -1) { ans[j] = i; p++; }
  }
  for (int iii = N-1; iii >= 0; iii--) {
    int i = r[iii] + 1;
    int p = 0;
    for (int j = N*N-1; j >= 0 && p < N-i; j--) if (ans[j] == -1) { ans[j] = i; p++; }
  }
  if (check(ans, x)) {
    printf("Yes\n");
    REP(i, N * N) {
      if (i > 0) printf(" ");
      printf("%d", ans[i]);
    }
    printf("\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2176
import math
N = int(input())
x = list(map(int, (input()).split()))

hoge = math.floor(N/2)

y = sorted(x)
A = y[hoge]
B = y[hoge-1]

for i in range(N):
	if A <= x[i]:
		print(B)
	else:
		print(A)

Measured memory_bytes: 25220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#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++)
#define _GLIBCXX_DEBUG
int main()
{
    string s;
    cin>>s;
    rep(i,s.size())s[i]='x';
    cout<<s<<endl;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

P = [int(i) for i in read().split()]
ans=sum(P)
for i in itertools.combinations(P,len(P)-1):
    ans=min(ans,sum(i))

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
int mod = 0;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 55;

int n;
int a[N];

int main() {
    cin >> n;
    FOR(i, 1, n+1) cin >> a[i];
    int posi = max_element(a+1, a+1+n) - a;
    int negi = min_element(a+1, a+1+n) - a;
    cout << n-1 + n-1 << '\n';
    if(a[posi] >= -a[negi]) {
        FOR(i, 1, n+1) {
            if (i != posi) {
                cout << posi << ' ' << i << '\n';
            }
        }
        FOR(i, 1, n) {
            cout << i << ' ' << i+1 << endl;
        }
    } else {
        FOR(i, 1, n+1) {
            if (i != negi) {
                cout << negi << ' ' << i << '\n';
            }
        }
        for(int i = n; i >= 2; i--) {
            cout << i << ' ' << i-1 << '\n';
        }
    }
}






























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

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

    int n;
    cin >> n;
    int k = 0;
    int m = n;
    while(m != 0){
        k += m % 10;
        m /= 10;
    }
    if(n % k == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print(7)
if S == 'MON':
    print(6)
if S == 'TUE':
    print(5)
if S == 'WED':
    print(4)
if S == 'THU':
    print(3)
if S == 'FRI':
    print(2)
if S == 'SAT':
    print(1)

Measured memory_bytes: 9036
function moduloexponentiation(a, b, m)
    ret = 1
    a = a%m
    while b > 0
        if b&1 == 1
            ret *= a
            ret %= m
        end
        b = b >> 1
        a = (a*a) % m
    end
    ret
end

function solve()
    n, k = [parse(Int, x) for x in split(readline())]
    m = 1000000007
    ret = 0
    numsequence = zeros(Int, k)
    for c=k:-1:1
        ns = moduloexponentiation(k÷c, n, m)
        for i=2:(k÷c)
            ns -= numsequence[c*i]
            while ns < 0
                ns += m
            end
        end
        ns %= m
        numsequence[c] = ns
        ret += ns*c
        ret %= m
    end
    ret
end

println(solve())

Measured memory_bytes: 166904
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		while(true){
			int n = s.nextInt();
			if(n == 0)	break;
			int[] stu = new int[n];
			int sum = 0;
			for(int i = 0;i < n;i++){
				stu[i] = s.nextInt();
				sum+=stu[i];
			}
			double m = ((double) sum) / n;
			double a = 0;
			for(int i = 0;i < n;i++){
				a += (stu[i] - m) * (stu[i] - m);
			}
			a /= n;
			a = Math.sqrt(a);
			System.out.println(a);
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 31460
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[SIZE];

int main() {
  int H, N;

  cin >> H >> N;

  for (int i=0; i<=H; i++)
    dp[i] = LLINF;

  dp[0] = 0;

  for (int i=0; i<N; i++) {
    int A, B;
    cin >> A >> B;

    for (int j=0; j<H; j++) {
      dp[min(j+A, H)] = min(dp[min(j+A, H)], dp[j] + B);
    }
  }

  cout << dp[H] << endl;

  return 0;
}


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

# define F first
# define S second
# define mp make_pair
# define pii pair<int,int>

# define long long long
# define pb push_back
# define sz(a) (int)(a.size())

# define y1     tipa_y1
# define left   tipa_left
# define right  tipa_right

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 4611686018427387903;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
}
int n, m;
            
int a[Sz], b[Sz], c[Sz], d[Sz];

inline int dist (int i, int j) {
  return abs (a[i] - c[j]) + abs (b[i] - d[j]);
}
int main()
{
  Read_rap ();
  cin >> n >> m;
  for (int i = 1;i <= n;i ++) 
    cin >> a[i] >> b[i];

  for (int i = 1;i <= m;i ++)
    cin >> c[i] >> d[i];
  for (int i = 1;i <= n;i ++) {
    int mn = MX, ind = 0;
    for (int j = 1;j <= m;j ++) {
      if (mn > dist (i, j)) {
        mn = dist (i, j);
        ind = j;
      }
    }
    cout << ind << endl;
  }



  return 0;
}









// Coded by Z...


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define sint(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 52;
const int dx[] = {1,1,1,0,0,-1,-1,-1};
const int dy[] = {1,0,-1,1,-1,1,0,-1};

int flag[MAX_N][MAX_N];
int w,h;

void dfs(int u,int v)
{
    flag[u][v] = 0;
    rep(i,8){
        int nu = u + dx[i],nv = v + dy[i];
        if(0 <= nu && nu < h && 0 <= nv && nv < w && flag[nu][nv]){
            dfs(nu,nv);
        }
    }
    return;
}

int main()
{
    while(1){
        cin >> w >> h;
        if(w == 0){
            break;
        }
        rep(i,h){
            rep(j,w){
                cin >> flag[i][j];
            }
        }
        int ans = 0;
        rep(i,h){
            rep(j,w){
                if(flag[i][j] != 0){
                    dfs(i,j);
                    ans++;
                }
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3204
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL n,a[100010],b[100010],c[200010],sum[200010];
LL t1=0,t2=0,ans;
int main()
{
	scanf("%lld",&n);
	for(LL i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a[i],&b[i]);
		c[i]=a[i];c[n+i]=b[i];
		t1+=a[i];t2+=b[i];
	}
	sort(c+1,c+2*n+1);
	ans=min(t1,t2);
	for(LL i=1;i<=2*n;i++) sum[i]=sum[i-1]+c[i];
	for(LL i=1;i<=n;i++)
	{
		LL x=a[i],y=b[i];
		if(x>y) swap(x,y);
		if(lower_bound(c+1,c+2*n+1,x)-c<=n-2)
		{
			if(lower_bound(c+1,c+2*n+1,y)-c<=n-1) ans=min(ans,sum[n]);
			else ans=min(ans,sum[n-1]+y);
		}
		else ans=min(ans,sum[n-2]+x+y);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4992
def main():
	n, m = map(int, input().split())
	print(f(n-1)^f(m))

def f(n: int) -> int:
	if n < 0: 
		return 0
	if n % 4 == 0:
		return n
	if n % 4 == 1:
		return 1
	if n % 4 == 2:
		return n^1
	if n % 4 == 3:
		return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	double a,b,t,now=0,ans=0;
	cin>>a>>b>>t;
	while(1){
		now+=a;
		if(now<=t+0.5){
			ans+=b;
		}else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=*pos+val;}
//const long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll n;cin>>n;
    ll k=0;
    rep(i,1,1000){
        if(i*(i+1)==2*n){
            k=i;
            break;
        }
    }
    if(k==0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    cout<<k+1<<endl;
    vector<int>v[k+1];
    int p=1,q=k;
    rep(i,0,k){
        rep(j,p,q)v[i].pb(j);
        rep(j,i+1,k)v[j].pb(p+j-(i+1));
        p=q+1;
        q=q+(k-i-1);
    }
    rep(i,0,k){
        cout<<k<<" ";
        for(auto x:v[i])cout<<x<<" ";
        cout<<endl;
    }
    
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);


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

int main() {
  int N;
  cin >> N;
  long long int ans = 1;
  for (int i = 1; i <= N; i++) ans = ((ans % 1000000007) * (i % 1000000007)) % 1000000007;
  cout << ans << endl;
  return 0;
}

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

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

template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int> > c(10, vector<int>(10, 0));
    rep(i, 10) {
        rep(j, 10) {
            cin >> c[i][j];
        }
    }
    // view(c);
    vector<vector<int> > A(H, vector<int>(W, 0));
    unordered_map<int, int> m;
    rep(i, H) {
        rep(j, W) {
            int temp;
            cin >> temp;
            A[i][j] = temp;
            if (m.count(temp) == 0) {
                m[temp] = 1;
            } else {
                m[temp]++;
            }
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
                // cout << c[i][j] << " ";
            }
            // cout << endl;
        }
    }
    // view(c);
    // cout << endl;
    // view(c);
    // cout << endl;
    // view(A);
    int total = 0;
    // for (auto it = m.begin(); it != m.end(); it++) {
    //     if (it->first == -1 || it->first == 1) continue;
    //     else {
    //         int temp_min, temp_pos;
    //         temp_pos = it->first;
    //         while (temp_pos != 1) {
    //             this_thread::sleep_for(chrono::seconds(1));
    //             int temp_next;
    //             temp_next = min_element(c[temp_pos].begin(), c[temp_pos].end(),
    //                 [](int a, int b) {return (a == 0) ? false : (b == 0) || a < b;}) - c[temp_pos].begin();
    //             view(c[temp_pos][temp_next]);
    //             temp_min += c[temp_pos][temp_next];
    //             temp_pos = temp_next;
    //         }
    //         if (temp_min < c[it->first][1]) {
    //             total += it->second * temp_min;
    //         } else {
    //             total += it->second * c[it->first][1];
    //         }
    //     }
    //     // cout << it->first << " " << it->second << endl;
    // }
    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->first == -1 || it->first == 1) continue;
        // cout << it->first << " " << it->second << endl;
        total += it->second * c[it->first][1];
    }
    cout << total << endl;

}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define MAX 2000000

int A[MAX];
int size;

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if(l <= size && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= size && A[r] > A[largest])largest = r;
  if(largest != i){
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}
int extract(){
  int i;
  if(size < 1)return -2000000000;
  i = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return i;
}

void increaseK(int i,int k){
  int num;
  if(k < A[i])return;
  A[i] = k;
  while(i > 1 && A[i/2] < A[i]){
    num = A[i];
    A[i] = A[i/2];
    A[i/2] = num;
    i = i/2;
  }
}

void insert(int k){
  size++;
  A[size] = -2000000000;
  increaseK(size, k);
}

int main(){
  char array[20];
  int k;
  while(1){
    scanf("%s",array);
    if(array[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else if(strcmp(array,"extract")==0){
      printf("%d\n",extract());
    }
    else break;
  }
}



Measured memory_bytes: 5648
def main():
    n = int(input())
    p = list(map(int,input().split()))
    p_sort = sorted(p)
    flg = 0
    for i in range(n):
        if p[i]!=p_sort[i]:
            flg +=1
    if flg==2 or flg ==0:
        print("YES")
    else:
        print("NO")

    
if __name__ == '__main__':
    main()

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

int main() {
  int r;

  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	cout<<3*n*n;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxn=1e6+5;
char ss[maxn];
ll f[2*maxn],inv[2*maxn];
ll quick_pow(ll a,int times)
{
    ll res=1;
    while(times)
    {
        if(times&1) res=(res*a)%mod;
        a=(a*a)%mod; times>>=1;
    }
    return res;
}
ll binom(int a,int b)
{
    return f[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
    int k;
    scanf("%d",&k);
    scanf("%s",ss);
    int s=(int)strlen(ss);
    int len=k+s;
    f[0]=1;
    for(int i=1;i<=len;i++)
        f[i]=(f[i-1]*i)%mod;
    inv[len]=quick_pow(f[len],(int)mod-2);
    for(int i=len-1;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%mod;
    ll ans=0;
    for(int i=s;i<=len;i++)
    {
        ll cur=1;
        int front=i-s,back=len-i;
        cur=cur*quick_pow(25,front)%mod*quick_pow(26,back)%mod;
        cur=cur*binom(i-1,s-1)%mod;
        ans=(ans+cur)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}
/*
5
oof
 
37564
whydidyoudesertme
 */


Measured memory_bytes: 36068
#include <iostream>
#include <cstdio>
using namespace std;
long long a[310][310];
bool b[310][310];
int main() {

//	freopen("4.in","r",stdin);

	long long n,ans=0;
	int i,j,k;

	scanf("%lld",&n);

	for(i=1; i<=n; i++) {
		for(j=1; j<=n; j++) {
			scanf("%lld",&a[i][j]);
		}
	}

	for(i=1; i<=n; i++) {
		for(j=1; j<=n; j++) {
			for(k=1; k<=n; k++) {
				if(i!=j&&j!=k&&k!=i) {
					if(a[i][j]==a[i][k]+a[k][j]) b[i][j]=1;
					if(a[i][j]>a[i][k]+a[k][j]) {
						printf("-1");
						return 0;
					}
				}
			}
		}
	}

	for(i=1; i<=n; i++) {
		for(j=1; j<=n; j++) {
			if(!b[i][j]) ans+=a[i][j];
		}
	}
	
	printf("%lld",ans/2);

	return 0;
}

Measured memory_bytes: 1024
def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    N = I()
    A = LI()
    ans = -inf

    S = [0]*(N+1)
    fr = [-1]*N
    best = -1

    for i,a in enumerate(A):
        S[i] = a
        for j in range(i):
            if ((i-j)%2==0):
                if (S[j]+a>S[i]):
                    fr[i] = j
                    S[i] = S[j] + a
            if (S[i]>ans):
                ans = S[i]
                best = i
    #print(best)
    V = []
    for i in range(best+1,N)[::-1]:
        V.append(i+1)
    i = best
    while(fr[i]>=0):
        f = fr[i]
        #print(i,f)
        while(f<i):
            V.append(1+(i+f)//2)
            i -= 2
    for _ in range(i):
        V.append(1)

    print(ans)
    print(len(V))
    for v in V:
        print(v)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main()
{
    int k,s;
    std::cin >> k >> s;


    int count=0;
    for (int x=0; x<=k; x++){
        for (int y=0; y<=k; y++){
            int sum=x+y;
            int z=s-sum;
            // std::cout << x << "," << y << "," << z << std::endl;
            if(0 <= z && z <= k) {
                count++;
            }
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
#include <climits>

typedef std::vector<int> liste;
typedef liste::const_iterator iter;

void print_array(liste list) {
    for(int i = 0; i < list.size(); ++i){
        if(i>0) std::cout << " ";
        std::cout << list[i];
    }
    std::cout << std::endl;
}

void merge(liste& A,int left,int mid,int right,int& comp) {
    int n1 = mid - left;
    int n2 = right - mid;
    iter firstL = A.begin() + left;
    iter lastL = A.begin() + left + n1;
    liste L(firstL, lastL);
    iter firstR = A.begin() + mid;
    iter lastR = A.begin() + mid + n2;
    liste R(firstR, lastR);
    
    int INFTY = INT_MAX;
    L.push_back(INFTY);
    R.push_back(INFTY);
    int i = 0;
    int j = 0;
    for(int k=left; k<right;k++) {
        comp++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(liste& A,int left,int right,int& comp) {
    if (left+1 < right) {
        int mid = floor((left + right)/2);
        mergeSort(A, left, mid, comp);
        mergeSort(A, mid, right, comp);
        merge(A, left, mid, right, comp);
    }
}    
    
int main(void){
        
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int value;
    liste list;
    int n;
    std::cin >> n;
    for(int i=0; i<n; i++) {
        std::cin >> value;
        list.push_back(value);
    } 
    
    int comp=0;
    mergeSort(list,0,list.size(),comp);
    print_array(list);
    std::cout << comp << std::endl;
    return 0;
}

Measured memory_bytes: 6948
using System;
namespace kozaiyApp
{
    public class B
    {
        static void Main()
        {
            ulong x = ulong.Parse(Console.ReadLine());
            ulong c = 100;

            for (ulong i = 1; i <= 1000000000000000000; i++)
            {
                c = (ulong)(c + (c * 0.01));
                if (c >= x)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 27600
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
    vector<char> a(6) ;
    for(auto& x : a) cin >> x ;
    if(a[2]==a[3] && a[4]==a[5]){
        cout << "Yes\n" ;
    }else cout << "No\n" ;

}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")




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

	int n, i, j, k;
	cin >> n;
	for (i = 0; i < n; i++) cout << "ACL";
	cout << "\n";

	return 0;
}




Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll findNumberOfTriangles(int arr[], int n) 
{ 
    // Count of triangles 
    ll count = 0;   
    // The three loops select three 
    // different values from array 
	sort(arr,arr+n);
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
            // The innermost loop checks for 
            // the triangle property 
            for (int k = j + 1; k < n; k++) 
                // Sum of two sides is greater 
                // than the third 
                if ( 
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i]&&arr[i]!=arr[j]&&arr[i]!=arr[k]&&arr[j]!=arr[k]) 
                    count++; 
        } 
    } 
    return count; 
} 
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i]; 
  }
 cout<<findNumberOfTriangles(a,n)<<"\n";
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k,a);
    k -= min(k,a);

    if(k<=0){
        cout << ans << endl;
        return 0;
    }

    ans += min(k,b)*0;
    k-= min(k,b);
    if(k<=0){
        cout << ans << endl;
        return 0;
    }

    ans += min(k,c)*-1;
    k-=min(k,c);

    if(k<=0){
        cout << ans << endl;
    }
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		boolean isApproved = true;
		for(int i = 0; i < n; i++) {
			int x = scan.nextInt();
			if(x % 2 == 0) {
				if(x % 3 == 0 || x % 5 == 0) continue;
			} else {
				continue;
			}
			isApproved = false;
		}
		if(isApproved) System.out.println("APPROVED");
		else System.out.println("DENIED");
		scan.close();
	}

}


Measured memory_bytes: 21844
data = list(map(int,input().split()))
w = data[0]
h = data[1]
x = data[2]
y = data[3]
if x == w/2 and y == h/2:
        print(str(w*h/2)+" "+"1")
else:
        print(str(w*h/2)+" "+"0")

Measured memory_bytes: 3060
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

char s[N];
int n;

bool check(char *a,int len) {
	for(int i=0;i<len;i++)
		if(a[i]^a[len-i-1]) return 0;
	return 1;
}

bool pd() {
	if((n&1)==1||n==0) return 0;
	int m=n>>1;
	return check(s,n+1)&&check(s,m)&&check(s+m+1,m);
}
	
int main() {
	scanf("%s",s); n=strlen(s)-1;
	puts(pd()?"Yes":"No");
	return 0;
}


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


int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort( a , a+n);
    int ans = a[n/2  ] - a[n/2 -1 ];
    cout<<ans;
}

Measured memory_bytes: 4000
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		long sum = 0;
		for(int i = 0; i < m; i++){
		    sum += sc.nextInt();
		}
		
		// 計算
		long result = -1;
		result= max(n-sum, -1);
		
		
		// 出力
		System.out.println(result);
	}
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H,W,N;
int sr,sc;
string S,T;

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

    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> S >> T;

    bool ans = true;

    int l = 0, r = W+1;

    for (int i = N-1;i >= 0;i--){
        if(T[i] == 'L'){
            r = min(r+1,W+1);
        }else if(T[i] == 'R'){
            l = max(l-1,0);
        }
        if(l+1 >= r) ans = false;
        if(S[i] == 'L'){
            l++;
        }else if(S[i] == 'R'){
            r--;
        }
        if(l+1 >= r) ans = false;
    }

    if(!(sc < r && sc > l)) ans = false;

    l = 0, r = H+1;

    for (int i = N-1;i >= 0;i--){
        if(T[i] == 'U'){
            r = min(r+1,H+1);
        }else if(T[i] == 'D'){
            l = max(l-1,0);
        }
        if(l+1 >= r) ans = false;
        if(S[i] == 'U'){
            l++;
        }else if(S[i] == 'D'){
            r--;
        }
        if(l+1 >= r) ans = false;
    }

    if(!(sr < r && sr > l)) ans = false;

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;

}

Measured memory_bytes: 920