akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 998244353
#define inf 100000000000000000
#define limit 200005
#define minval -100000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
lli v[3001][3001] = {}, memo[3001][3001][4];
int n, m;

lli dp(int i, int j, int k)
{
	if(i == n || j == m || k > 3)
		return minval;
	if(i == n-1 && j == m-1)
	{
		if(k < 3)
			return v[n-1][m-1];
		else
			return 0;
	}

	if(memo[i][j][k] != -1)
		return 	memo[i][j][k];


	lli ans = minval;
	ans = max(ans, v[i][j] + dp(i, j+1, k+1));
	if(k < 3)
		ans = max(ans, v[i][j] + dp(i+1, j, 0));
	ans = max(ans, dp(i, j+1, k));
	ans = max(ans, dp(i+1, j, 0));
	return memo[i][j][k] = ans;
}
void input()
{
	rep(i,3001)
		rep(j,3001)
			rep(k,4)
				memo[i][j][k] = -1;
	int k;
	cin >> n >> m >> k;
	rep(i,k)
	{
		int r, c, val;
		cin >> r >> c >> val;
		v[r-1][c-1] = val;
	}
	cout << dp(0,0,0) << '\n';
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 355784
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	
	vector<int> mel;
	mel.push_back(2);
	mel.push_back(1);
	mel.push_back(2);
	mel.push_back(1);
	mel.push_back(4);
	mel.push_back(1);
	mel.push_back(4);
	mel.push_back(1);
	
	typedef pair<int,int> pii;
	vector<int> in(8);
	while(cin>>in[0]){
		reps(i,1,8)cin>>in[i];
		
		vector<pii> cand;
			
		rep(i,mel.size()){
			int dist = 0;
			rep(j,mel.size()){
				dist += max(0,in[j]-mel[j]);
			}
			
			int sum = 0;
			rep(j,mel.size()){
				sum *= 10;
				sum += mel[j];
			}
			
			cand.push_back(pii(dist,sum));
			
			mel.push_back(mel[0]);
			mel.erase(mel.begin());
		}
		
		
		rep(j,cand.size()){
			//printf("%d %d !!!!#####\n",cand[j].first,cand[j].second);
		}
		sort(cand.begin(),cand.end());
		
		rep(j,cand.size()){
			//printf("%d %d !!!!\n",cand[j].first,cand[j].second);
		}
		int p = cand[0].second;
		vector<int> hoge;
		rep(i,mel.size()){
			hoge.push_back(p%10);
			p/=10;
		}
		
		rep(i,hoge.size()){
			if(i!=0)printf(" ");
			printf("%d",hoge[hoge.size()-1-i]);
		}puts("");
	}
	
	
	
}

Measured memory_bytes: 1204
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

ll Fac[int(5e5 + 5)], Inv[int(5e5 + 5)];

int main(){
  ll N, M; cin >> N >> M;

  Fac[0] = 1;
  for (ll i = 1; i <= M; i++){
    Fac[i] = Fac[i-1] * i % MOD;
  }
  for (ll i = 0; i <= M; i++){
    Inv[i] = Pow(Fac[i], MOD - 2);
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++){
    ll now = Fac[M] * Inv[M - i] % MOD;
    for (int j = 0; j < 2; j++){
      now *= Fac[M - i]; now %= MOD;
      now *= Inv[M - N]; now %= MOD;
    }
    now *= Fac[N]; now %= MOD;
    now *= Inv[i]; now %= MOD;
    now *= Inv[N - i]; now %= MOD;

    if (i % 2 == 0) ans += now;
    else ans -= now;

    ans %= MOD;
    if (ans < 0) ans += MOD;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 11336
# coding: utf-8
import math
N = int(input())
sta_info = []
for i in range(N-1):
    l = list(map(int,input().split()))
    sta_info.append(l)

for i in range(N-1):
    start = i
    t = 0
    ans = 0
    for j in range(i,N-1):
        c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2]
        #print('到着時 ' + str(t))
        if t <= s:
            t = s
            #print('!!!')
        else:
            n = math.ceil((t - s) / f)
            t += s + n * f - t
        #print('発車時 ' + str(t))
        t += c
        
    print(t)
print(0)


Measured memory_bytes: 3188
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
	let xn = get!(usize);
	let yn = get!(usize);
	let zn = get!(usize);
	let k = get!(usize);
    let mut xs = vec![];
    let mut ys = vec![];
    let mut zs = vec![];
    for _ in 0..xn {
    	xs.push(get!());
    }
    for _ in 0..yn {
    	ys.push(get!());
    }
    for _ in 0..zn {
    	zs.push(get!());
    }
    let mut us = vec![];
    for x in xs.iter() {
    	for y in ys.iter() {
        	us.push(-x-y);
        }
    }
    us.sort();
    let mut vs = vec![];
    for i in 0..std::cmp::min(us.len(), k) {
    	let u = us[i];
    	for z in zs.iter() {
        	vs.push(u-z);
        }
    }
    vs.sort();
    for i in 0..k {
    	println!("{}", -vs[i]);
    }
}

Measured memory_bytes: 44276
#include <iostream>
#include <vector>

using namespace std;

int swap_cnt = 0;
vector<int> store_num;
vector<int> store_step;

void InsertionSort(vector<int> &store_num, int num_cnt, int step)
{
    for (int i = step; i < num_cnt; i++)
    {
        int val = store_num[i];
        int j = i - step;
        while ((j >= 0) && (store_num[j] > val))
        {
            store_num[j + step] = store_num[j];
            j -= step;
            swap_cnt++;
        }
        store_num[j + step] = val;
    }
    
    return ;
}

void shellSort(vector<int> &num, int num_cnt)
{
    for (int step = 1; ; )
    {
        if (step > num_cnt)
        {
            break;
        }
        
        store_step.push_back(step);
        step = 3 * step + 1;
    }
    
    for (int i = (int)store_step.size() - 1; i >= 0; i--)
    {
        InsertionSort(num, num_cnt, store_step[i]);
    }
    
    return ;
}

int main()
{
    int num_cnt = 0;
    int tmp = 0;
    
    cin >> num_cnt;
    for (int i = 0; i < num_cnt; i++)
    {
        cin >> tmp;
        store_num.push_back(tmp);
    }
    
    shellSort(store_num, num_cnt);
    
    cout << store_step.size() << endl;
    for (int i = (int)store_step.size() - 1; i >= 0; i--)
    {
        cout << store_step[i];
        if (i != 0)
        {
            cout << " ";
        }
    }
    
    cout << endl;
    cout << swap_cnt << endl;
    for (auto i = store_num.begin(); i != store_num.end(); i++)
    {
        cout << *i << endl;
    }
    
    return 0;
}



Measured memory_bytes: 7064
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = float('-inf')
for i in range(1, 2 ** 10):
    p = 0
    for k in range(N):
        store = F[k]
        c = 0
        for j in range(10):
            if (i >> j) & 1 and F[k][j] == 1:
                c += 1
        p += P[k][c]
    ans = max(ans, p)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    ll sum = 0;
    vec a(N);
    rep(i,N){
        cin>>a[i];
        sum += a[i];
    }
    cin>>M;
    rep(i,M) {
        cin >> A >> B;
        --A;
        cout << sum - (a[A] - B) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
  long N,M;
  cin>>N>>M;
  if(2*N>M) {cout<<M/2;}
  else {
      long ans; ans=N; M=M-2*N; ans+=M/4; cout<<ans;
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    long long int n,i,cnt=0;
    cin>>n;
    long long int a[n+1];
    long long int b[n];
    for(i=0;i<(n+1);i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    cin>>b[i];
    for(i=0;i<n;i++)
    {
    	if((a[i]+a[i+1])<=b[i])
    	{
    		cnt+=(a[i]+a[i+1]);
    		a[i]=0;
    		a[i+1]=0;
		}
    	else if((a[i]+a[i+1])>b[i])
    	{
    		cnt+=b[i];
    		if(a[i]<=b[i])
    		{
    			b[i]-=a[i];
    			a[i]=0;
			}
			else if(a[i]>b[i])
			{
				a[i]-=b[i];
				b[i]=0;
			}
			if(b[i]>0)
			{
				a[i+1]-=b[i];
			}
			//cout<<a[i]<<" "<<a[i+1];
		}
		//cout<<"\n";
	}
	//for(i=0;i<(n+1);i++)
	//cout<<a[i]<<" ";
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){

  int h,w;

  while(true){
    cin >> h >> w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i%2==0){
          if(j%2==0){
            cout << "#";
          }else{
            cout << ".";
          }
        }else{
          if(j%2==0){
            cout << ".";
          }else{
            cout << "#";
          }
        }
      }
      cout <<endl;
    }
    cout <<endl;
  }

}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define pi M_PI

int main(){
  int h, w;
  while(1){
    cin >> h >> w;
    if(h + w == 0) return 0;
    else{
      REP(i, h){
        REP(j, w){
          if(i == 0 || i == h - 1 || j == 0 || j == w - 1) cout << "#";
          else cout << ".";
        }
        cout << endl;
      }
      cout << endl;
    }
  }
}



Measured memory_bytes: 3108
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()

	sort.Ints(a)
	sum := 0
	for i := N; i < 3*N; i+=2 {
		sum += a[i]
	}
	fmt.Println(sum)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, y;
    cin >> n >> y;
    
    bool flag = false;
    int a, b, c;
    REP(i,2001) {
        for (int j = 0; j + i <= n; j++) {
            if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
                flag = true;
                a = i; b = j; c = n - i - j;
            }
        }
    }
    
    if (flag) {
        cout << a << " " << b << " " << c << endl;
    } else {
        cout << "-1 -1 -1" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int N;
	while(scanf("%d",&N),N){
		int array[128];
		rep(i,N){
			scanf("%d",&array[i]);
		}
		int M;
		scanf("%d",&M);
		int l = 0;
		int r = N;
		int cnt = 0;
		while(l < r){
			cnt++;
			int med = (l+r-1)/2;
			if(array[med] == M)break;
			if(array[med] > M)r = med;
			else l = med+1;
		}
		printf("%d\n",cnt);
	}
    return 0;
}

Measured memory_bytes: 1188
N = int(input())
S = [int(c) for c in input()]

count = 0

for x100 in range(10):
    if x100 in S[:N-2]:
        ind_100 = S.index(x100)
        
        for x10 in range(10):
            if x10 in S[ind_100+1:N-1]:
                ind_10 = S[ind_100+1:N-1].index(x10) + ind_100 + 1
                
                for x1 in range(10):
                    if x1 in S[ind_10 + 1:]:
                        count += 1
print(count)    

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

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double rad = abs(30*H-5.5*M) * M_PI / 180;
    double a = sin(rad) * A;
    double b = B - cos(rad) * A;
    double ans = sqrt(a*a + b*b);
    printf("%.10f\n", ans);
}

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

void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

void solve()
{

  int n;cin>>n;
  int ans=0,ele;
  for(int i=0;i<n;i++)
  {
  	cin>>ele;
  	if(ele&1 && (i+1)&1)ans++;
  }
  cout<<ans;
}

int32_t main()
{
    fastio();
    // int t;cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    int n; scanf("%d", &n);
    ll a[n + 5];
    for (int i = 0; i <= n; i++) scanf("%lld", &a[i]);

    ll c[n + 5];
    c[n] = a[n];
    for (int i = n - 1; i >= 0; i--) {
        c[i] = a[i] + c[i + 1];
    }

    if (n == 0) {
        if (a[0] > 1) {
            puts("-1");
            return 0;
        }

        printf("%lld\n", a[0]);
        return 0;
    } else {
        if (a[0] != 0) {
            puts("-1");
            return 0;
        }
    }

    ll last = 1;
    ll ans = 1;

    for (int i = 1; i <= n; i++) {
        if (last < 0) {
            ans = -1;
            break;
        }

        ll cur = 2 * last;
        cur = min(cur, c[i]);

        if (cur - a[i] >= 0) {
            ans += cur;
            last = cur - a[i];
        } else {
            ans = -1;
            break;
        }
    }

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

Measured memory_bytes: 5280
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x, t;
	cin >> x >> t;
	if (x > t)
		cout << x - t << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 256
N = input()
if N.endswith('2') == True or N.endswith('4') == True or N.endswith('5') == True or N.endswith('7') == True or N.endswith('9') == True:
    print('hon')
elif N.endswith('0') == True or N.endswith('1') == True or N.endswith('6') == True or N.endswith('8') == True:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9016
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  int n;cin>>s>>n;
  vector<int> a;
  for(int i = 0; s.size() > i; i++){
    a.push_back('z'-s[i]+1);
  }
  for(int i = 0; s.size()-1 > i; i++){
    //cerr << n << " " << a[i] << " -> ";
    if((a[i]!='z'-'a'+1) && (!(n-a[i] < 0)))n-=a[i],a[i]=26;
    //cerr << n << " " << a[i] << endl;
    cout << (char)('z'-a[i]+1);
  }
  cout << (char)(s[s.size()-1]+(n%26)-((s[s.size()-1]+(n%26)) > 'z' ? 26 : 0)) << endl;
}
  


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


int main(void){
  int n; cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s; cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto& p : mp){
    ll s = p.second;
    ans += s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  int count = s.size() / 2;
  int ans = 0;
  rep(i, count){
    if(s[i] != s[s.size() - i -1]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 760
def main():
    n = int(input())
    l = list(map(int,input().strip().split()))

    if n < 3:
        print(0)
        return
        
    count = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            for c in range(b+1,n):
                if ((l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and l[a] + l[c] > l[b])and 
                    (l[a] != l[b] and l[b] != l[c] and l[a] != l[c])):
                    count += 1

    print(count)
main()



Measured memory_bytes: 9204
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter
from itertools import accumulate

def main():
    N, K = LI()
    S = SI()
    cnts = []
    pre = '1'
    cnt = 0
    # 0 start bin
    for s in S:
        if s != pre:
            cnts.append(cnt)
            cnt = 0
            pre = s
        cnt += 1
    cnts.append(cnt)
    acc = [0] + list(accumulate(cnts))
    ans = 0
    for i in range(0, len(acc) - 1, 2):
        tmp = acc[min(len(acc) - 1, i + 2 * K + 1)] - acc[i]
        ans = max(tmp, ans)
        if len(acc) < i + 2 * K + 1:
            break

    return ans

print(main())

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

int main() {
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    double S = W * H / 2;

    printf("%.10f", S);

    if (x == W / 2 && y == H / 2) {
        cout << " " << 1 << endl;
    }

    else {
        cout << " " << 0 << endl;
    }


}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(n);
  
  rep(i, n) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  
  ll ans = 0;
  rep(i, n) {
    if(m - ab[i].second > 0) {
      m -= ab[i].second;
      ans += ll(ab[i].first) * ab[i].second;
    }
    else {
      ans += m*ll(ab[i].first);
      m -= ab[i].second;
    }
    
    if(m <= 0) {
      printf("%ld\n", ans);
      return 0;
    }
  }
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
	int n, a[100], b[100], ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (a[i] >= b[i]) ans += a[i] - b[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool {return abs(i) < abs(j);});
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

//出力するよ
void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<s[i];
        //if(i==index) cout<<"["<<s[i]<<"]";
        //cout<<s[i].first<<" "<<s[i].second<<endl;//<<endl;
    }
    cout<<endl;
}

int partition(vector<pair<char,int>> &a,int p,int r){
    int x=a[r].second;
    int i=p-1;
    for(int j=p;j<(r);j++){
        if(a[j].second<=x){
            i++;
            pair<char,int> key=a[i];
            a[i]=a[j];
            a[j]=key;
        }
    }
    pair<char,int> key=a[i+1];
    a[i+1]=a[r];
    a[r]=key;
    return i+1;
}

void quickSort(vector<pair<char,int>> &a,int p,int r){
    if(p<r){
        int q=partition(a,p,r);
        quickSort(a,p,q-1);
        quickSort(a,q+1,r);
    }
}

void merge(vector<pair<char,int>> &a,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    vector<pair<char,int>> l(n1+1);
    vector<pair<char,int>> r(n2+1);
    for(int i=0;i<n1;i++) l[i]=a[left+i];
    for(int i=0;i<n2;i++) r[i]=a[mid+i];

    l[n1]=make_pair('A',pow(10,10));
    r[n2]=make_pair('A',pow(10,10));
    int i=0,j=0;

    for(int k=left;k<right;k++){
        //ここが比較しているところ
        //cnt++;
        if(l[i].second<=r[j].second){
            a[k]=l[i];
            i++;
        }else{
            a[k]=r[j];
            j++;
        }
    }
}

void mergeSort(vector<pair<char,int>> &a,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

void countingSort(vector<int> a,vector<int> &b,int k){
    vector<int> c(k+1);
    int n=a.size();
    for(int i=0;i<=k;i++){
        c[i]=0;
    }

    //各値の出現数を記録する
    for(int i=0;i<n;i++){
        c[a[i]]++;
    }

    //ciにi以下の要素数を記録する
    for(int i=1;i<=k;i++){
        c[i]+=c[i-1];
    }

    for(int i=n-1;i>=0;i--){
        b[c[a[i]]-1]=a[i];
        c[a[i]]--;
    }
}

signed main(){
    int n; cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }

    countingSort(a,b,10000);
    output(b);
}


Measured memory_bytes: 49880
package main

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

var num int

func main() {
	fmt.Scan(&num)
	ele := numScan(num)
	ans := calc(ele)

	fmt.Printf("%d", int(ans))
}

func numScan(num int) []float64 {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ss := strings.Split(sc.Text(), " ")

	element := []float64{}
	for _, i := range ss {
		m, _ := strconv.ParseFloat(i, 64)
		element = append(element, m)
		//fmt.Printf("%f", element)
	}
	return element
}

func calc(element []float64) float64 {
	ans := math.MaxFloat64
	for i := -100; i <= 100; i++ {
		r := 0.0
		for _, x := range element {
			r += math.Pow(x-float64(i), 2)
		}
		if ans > r {
			ans = r
		}
	}
	return ans
}


Measured memory_bytes: 1860
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int H, W;
    cin >> H >> W;
    FOR(i, 0, H) {
        string row;
        cin >> row;
        cout << row << endl << row << endl;
    }
    return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int N, d[100], sum=0;
scanf("%d", &N);
for(int i=0;i<N;i++){
scanf("%d", &d[i]);
};
for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
        if(i!=j){
    sum+=d[i]*d[j];
        }
    }
}
printf("%d", sum/2);
return 0;
}

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

using namespace std;

int main() {
    int N;
    int total_min = 1000000;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; ++i) cin >> W[i];
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < N; ++j) {
            int under_sum, top_sum;
            under_sum = accumulate(W.begin(), W.begin() + j + 1, 0);
            top_sum = accumulate(W.begin() + j + 1, W.end(), 0);
            int total = abs(under_sum - top_sum);
            if (total_min > total) total_min = total;
        }
    }
    cout << total_min << endl;
}

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

int main() {
    using T = tuple<int, int, int>;
    set<T> s;
    
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a[3];
        for (int j = 0; j < 3; ++j) cin >> a[j];
        sort(a, a + 3);
        s.insert(tie(a[0], a[1], a[2]));
    }
    cout << n - s.size() << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,x,cnt=0,tmp;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0;i<n;i++){
        cin >> tmp;
        m.at(i) = tmp;
        x -= tmp;
        cnt++;
    }
    sort(m.begin(),m.end());
    while(x>=0){
        x -= m.at(0);
        if(x>=0)
            cnt++;
    }
    cout << cnt << endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 3'000'000 + 6;

i64 T;
i64 n;
i64 a[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    cin >> n;
    i64 R = 0;

    R += n / 500 * 1000;
    n %= 500;
    R += n / 5 * 5;

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 256
// List of Top 3 Hills
#include <stdio.h>

int main(void)
{
	int high_data[10];
	int i, j;
	
	for (i = 0; i < 10; i++)scanf("%d", &high_data[i]);
	
	for (i = 0; i < 10; i++){
		for (j = i + 1; j < 10; j++){
			if (high_data[i] < high_data[j]){
				high_data[i] ^= high_data[j];
				high_data[j] ^= high_data[i];
				high_data[i] ^= high_data[j];
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", high_data[i]);
	}
	
	return (0);
}

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

typedef long long LL;
const int MAXN=1e5+5;

int ans,x[MAXN],y[MAXN];
int n,m,r; 

int main(){
	cin>>n;
	memset(x,0,sizeof(x));
	for(int i=1;i<=n;i++){
		int a; cin>>a;
		x[a]++;
	}
	int ans=0;
	for(int i=0;i<=1e5-3;i++){
		ans=max(ans,x[i]+x[i+1]+x[i+2]);
	}
	cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll k, x;
  cin >> k >> x;

  cout << (500 * k >= x ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,n,k,a[200][3],x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)for(j=0;j<3;j++)scanf("%d",&a[i][j]);
	for(i=0;i<3;i++)for(j=0;j<n;j++)for(k=j;k<n;k++)if(a[j][i]%100==a[k][i]%100 && j!=k)a[j][i]+=100,a[k][i]+=100;
	for(i=0;i<n;i++)for(j=0;j<3;j++)if(a[i][j]>100)a[i][j]=0;
	for(i=0;i<n;i++)printf("%d\n",a[i][0]+a[i][1]+a[i][2]);
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int digit_sum(long int n) {
    int ret = 0;
    long cur = n;
    while(cur != 0) {
        ret += cur % 10;
        cur = cur / 10;
    }
    return ret;
}

int main(void) {
    long n,ret = 0;
    int a,b;
    cin >> n >> a >> b;
    for(long i = 1;i <= n;i++) {
        int r = digit_sum(i);
        if(r >= a && r <= b)
            ret += i;
    }
    cout << ret << endl;
}


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

using namespace std;

int main()
{

    int N;
    int M;

    cin >> N;
    cin >> M;

    if (N == M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;

}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if( a + b + c == max( { a, b, c } ) * 2 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N, ans;
    cin >> N;

    if(N % 2 == 0){
        ans = N / 2;
    }else{
        ans = N / 2 + 1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll l,r,d;
    cin>>l>>r>>d;
    ll count=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        count++;
    }
    cout<<count;



    
    return 0;
}

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

int main(){
  string S,T;
  cin >>S>>T;
  
  int len = S.size();
  
  bool flag = false;
  
  rep(i,0,len){
    if(S==T){
      flag = true;
      break;
    }
    S = S.back() + S.substr(0,len-1);   
  }
  
  string ans;
  if(flag) ans = "Yes";
  else ans = "No";
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();
    sc.close();

    String ans = Z + " " + X + " " + Y;
    System.out.println(ans);
  }
}

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

#define                                 pai                                         acos(-1)
#define                                 ll                                          long long
#define                                 pb                                          push_back
#define                                 mp                                          make_pair
#define                                 pll                                         pair<ll,ll>
#define                                 sz(a)                                       (ll)a.size()
#define                                 endl                                        "\n"
#define                                 gcd(a, b)                                   __gcd(a, b)
#define                                 lcm(a, b)                                   (((a)*(b))/gcd(a,b))
#define                                 all(vec)                                    vec.begin(),vec.end()
#define                                 ms(a, b)                                    memset(a,b,sizeof(a))
#define                                 TEST_CASE(t)                                for(int www=1;www<=t;www++)
#define                                 PRINT_CASE                                  printf("Case %d: ",z)
#define                                 fii                                         freopen("input.txt","r",stdin);
#define                                 foo                                         freopen("output.txt","w",stdout);
#define                                 fast                                        ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);



vector<ll>adj[200007];
bool visited[200007];

ll cnt=0;
void dfs(ll s)
{
    cnt++;
    visited[s]=true;
    //cout<<s<<"==="<<visit[s]<<endl;
    for(ll i=0;i<adj[s].size();i++)
    {
        ll u=adj[s][i];
        if(visited[u]==false)
        {
            dfs(u);
        }
    }
}
int  main()
{
    ll i,j,k,a,b,c,d=0,n,m,t,h,u,v,x,y,z;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll mx=0;
    ms(visited,false);

    for(i=1;i<=n;i++)
    {
        cnt=0;
        if(visited[i]==false)
        {
           dfs(i);
        }
        mx=max(mx,cnt);
    }
    cout<<mx<<endl;
    return 0;
}




Measured memory_bytes: 20896
#include<stdio.h>

int main()
{
  int N;
  int n;
  int f=0;
  scanf("%d",&N);
  n=N;
  while(1){
    f+=n%10;
    if(n/10==0){
      break;
    } else if(n/10!=0){
      n/=10;
    }
  }
  if(N%f==0){
    printf("Yes");
  } else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1716
#include <cstdio>
#include <cmath>
using namespace std;
int n, s, a[100005], d[100005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=1; i<=n; i++) {
		scanf("%d", &a[i]);
		s += d[i] = abs(a[i] - a[i-1]);
	}
	s += d[n+1] = abs(a[n]);
	for(i=1; i<=n; i++) {
		printf("%d\n", s - d[i] - d[i+1] + (int)abs(a[i-1]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
//			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back()){++it;v2.pop_back();}
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it)
			m=*it++,
			x+=*it-m;
	}
}

Measured memory_bytes: 0
def c_lower():
    N = int(input())
    H = [int(i) for i in input().split()] + [float('inf')]

    can_move = []
    tmp = 0
    for i in range(N):
        if H[i] >= H[i + 1]:
            tmp += 1
        else:
            can_move.append(tmp)
            tmp = 0
    return max(can_move)

print(c_lower())

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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,n+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
//#define int ll

bool Fcomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.F < secondElof.F;}
bool Scomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.S < secondElof.S;}

//**********

signed main(void) {
    
    int a,b,c,x,y;
    
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);

    int cc = 0;
    if(a+b>2*c) cc = 1;

    int na,nb,nc;
    
    if(x>y && cc) {
        nb = 0;
        nc = y*2;
        if(a<2*c) {na = x-y;}
        else {na = 0; nc += (x-y)*2;}
    }
    else if(cc) {
        na = 0;
        nc = x*2;
        if(b<2*c) {nb = y-x;}
        else {nb = 0; nc += (y-x)*2;}
    } else {
        na = x;
        nb = y;
        nc = 0;
    }
    int ans = a*na+b*nb+c*nc;
    
    printf("%d\n",ans);
    
    return 0;
    
}







Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];
	ll res = n;
	rep(i, n)rep(j, n)
	{
		if (i == j)continue;
		ll p = x[i] - x[j];
		ll q = y[i] - y[j];
		ll cnt = n;
		rep(a, n)rep(b, n)
		{
			if (x[a] == x[b] - p && y[a] == y[b] - q)--cnt;
		}
		res = min(res, cnt);
	}
	cout << res << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

map<PLL, int> visited;
map<int64, int> vx, vy;
map<int64, set<int64>> cx, cy;
int64 cx_v = 0, cy_v = 0;

int64 dfs(int64 x, int64 y) {
  if (visited[PLL(x, y)]) return 0;
  visited[PLL(x, y)] = 1;
  int64 cnt = 1;
  if (!vx[x]) {
    cx_v++;
    vx[x] = 1;
  }
  if (!vy[y]) {
    cy_v++;
    vy[y] = 1;
  }
  int64 yy = *cx[x].begin();
  while (1) {
    auto itr = cx[x].lower_bound(yy);
    if (itr == cx[x].end()) break;
    yy = *itr;
    cx[x].erase(yy);
    cnt += dfs(x, yy);
  }
  int64 xx = *cy[y].begin();
  while (1) {
    auto itr = cy[y].lower_bound(xx);
    if (itr == cy[y].end()) break;
    xx = *itr;
    cy[y].erase(xx);
    cnt += dfs(xx, y);
  }
  return cnt;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  vector<int64> x(N), y(N);
  REP(i, N) {
    cin >> x[i] >> y[i];
    cx[x[i]].insert(y[i]);
    cy[y[i]].insert(x[i]);
  }
  int64 res = 0;
  REP(i, N) {
    cx_v = 0; cy_v = 0;
    int64 cnt = dfs(x[i], y[i]);
    res += cx_v * cy_v - cnt;
  }
  cout << res << endl;
}


Measured memory_bytes: 39936
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int , int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define fl(i , n) for(int i = 0;i<n;i++)


int main()
{	
	fastio;
    int a , b;
    cin>>a>>b;

    int ans =(b-1)/(a-1);
    
    if((b-1)%(a-1) > 0)ans++;

    cout<<ans<<endl;

    

	return 0;
}

Measured memory_bytes: 256
N = int(input())
d = [0] * N
for i in range(N):
  d[i] = int(input())

d.sort(reverse=True)
  
res = 0
cur_diameter = max(d) + 1
for i in range(N):
  if d[i] < cur_diameter:
    res += 1
    cur_diameter = d[i]

print(res)


Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
dp = [- 1]*N
dp[-1] = 0
for i in range(N - 2, - 1, - 1):
    if H[i] >= H[i + 1]:
        dp[i] = dp[i + 1] + 1
    else:
        dp[i] = 0
print(max(dp))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int t=1;
	while(t--){
		int n,m;
		cin>>n;
		double a[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i+1];

		double dp[n+1][n+1];
		memset(dp,0,sizeof(dp));
		
		dp[0][0]=1.0;
		
		for(int i=1;i<=n;i++){
			for(int j=0;j<=n;j++){
				dp[i][j]=dp[i-1][j]*(1.0-a[i]);
				if(j-1>=0)
					dp[i][j]+=dp[i-1][j-1]*a[i];
			}
		}
		
		double ans=0;
		for(int i=(n+1)/2;i<=n;i++)
			ans+=dp[n][i];
		cout<<setprecision(12)<<ans<<endl;

	}
	return 0;
}
	


Measured memory_bytes: 70528
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  string S;
  cin >> S;

  int len = S.length();
  int ans = 1e9;
  for(int i = 0; i < len-2; i++){
    int sum = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
    if(ans > abs(sum-753)) ans = abs(sum-753);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  #define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N,M;
  cin>>N>>M;
  vector<int> a(M),b(M-1);
  if(M==1 || M<=N)
    cout<<0;
  else{
    rep(i,M)
      cin>>a[i];
    sort(a.begin(),a.end());
    rep(i,M-1)
      b[i]=a[i+1]-a[i];
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    /*rep(i,M)
      cout<<b[i]<<endl;*/
    rep(i,N-1)
      b[i]=0;
    int answer=0;
    rep(i,M-1){
      answer+=b[i];
    }
    cout<<answer;
  }
  

}

Measured memory_bytes: 1024
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  console.log(input[0]*input[1]/2+' '+(((input[2]===input[0]/2)&&(input[3]===input[1]/2))?1:0));
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 7628