akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

vector<vector<pair<int, int>>> tree;
vi color;
int n;

void paint(int i, int c) {
  color[i] = c;
  for(auto p : tree[i]) {
    if(color[p.first] == 0) {
      int nc = c * pow(-1, p.second);
      paint(p.first, nc);
    }
  }
}

int main() {
  cin >> n;
  tree.assign(n, {});
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    tree[u - 1].push_back(make_pair(v - 1, w));
    tree[v - 1].push_back(make_pair(u - 1, w));
  }
  color.assign(n, 0);
  paint(0, 1);
  rep(i, n) cout << (color[i] + 1) / 2 << endl;
}

Measured memory_bytes: 8192
#include <iostream>

using namespace std;

string _myStr;

void CParseIn(){
	cin >> _myStr;
}

void CoreCWriteOut(){
	cout << _myStr[0] << _myStr.size() - 2 << _myStr[_myStr.size() - 1] << endl;
}

int main(){
	CParseIn();
	CoreCWriteOut();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll h, w;
    cin >> h >> w;
    ll ans = 0;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    if(h % 2 == 0){
        ll foo = h / 2;
        ans = foo * w;
    }
    else{
        ll foo = (h + 1) / 2, bar = h / 2;
        if(w % 2 == 0){
            ll hoge = w / 2;
            ans = foo * hoge;
            ans += bar * hoge;
        }
        else{
            ll foo1 = (w + 1) / 2;
            ll bar1 = w / 2;
            ans = foo * foo1;
            ans += bar * bar1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];
char str1[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    long len=strlen(str);

    strcpy(str1, str);
    long cnt0=0, cnt1=0;
    {
        long i;
        for(i=1; i<len; i++) {
            if(str[i-1]==str[i]) {
                cnt0++;
                str[i]=(str[i]=='0')? '1': '0';
            }
        }
    }

    {
        long i;
        cnt1++;
        str[0]=(str[0]=='0')? '1': '0';
        for(i=1; i<len; i++) {
            if(str[i-1]==str[i]) {
                cnt1++;
                str[i]=(str[i]=='0')? '1': '0';
            }
        }
    }
    printf("%ld\n", MIN(cnt0,cnt1));
 
    return 0;
}


Measured memory_bytes: 384
use std::io;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();
    let _ = reader.read_line(&mut s);

    let v: Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let n = v[0];
    let x = v[1];

    s.clear();

    let _ = reader.read_line(&mut s);
    let xs: Vec<i32> = s
        .split_whitespace()
        .map(|e| (e.parse::<i32>().unwrap() - x).abs())
        .collect();

    let mut ans = xs.iter().max().unwrap().clone();

    if n == 1 {
        ans = ans.abs();
    } else {
        for i in 0..n {
            let gcd = gcd(ans, xs[i as usize]);
            if ans > gcd {
                ans = gcd;
            }
        }
    }
    println!("{}", ans);
}

fn gcd(x: i32, y: i32) -> i32 {
    if x % y == 0 {
        y
    } else {
        gcd(y, x % y)
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAX_V 100005
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)
    if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++)
    if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++)
    if(!used[v])dfs(v);
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)
    if(!used[vs[i]])rdfs(vs[i],k++);
  return k;
}

vector<int> G2[MAX_V];
vector<P> G3[MAX_V];
int usede[MAX_V];

void dfs2(int x){
  for(int i=0;i<G3[x].size();i++){
    if(usede[G3[x][i].second])continue;
    usede[G3[x][i].second]=true;
    add_edge(x,G3[x][i].first);
    dfs2(G3[x][i].first);
  }
}

int n,m,w[MAX_V],u,v;
int sum[MAX_V],f[MAX_V];
int used2[MAX_V],ans;

int dfs3(int x){
  if(used[x])return 0;
  used[x]=true;
  int r=0;
  for(int i=0;i<G2[x].size();i++)
    r|=dfs3(G2[x][i]);
  if(f[cmp[x]])r=1;
  if(!used2[cmp[x]]&&r){
    ans+=sum[cmp[x]];
    used2[cmp[x]]=1;
  }
  return r;
}

int maxs=0;
void dfs4(int x,int s){
  int flag=0;
  for(int i=0;i<G2[x].size();i++){
    if(used[G2[x][i]])continue;
    used[G2[x][i]]=true;
    flag=1;
    if(cmp[x]!=cmp[G2[x][i]]&&!used2[cmp[x]])
      dfs4(G2[x][i],s+sum[cmp[x]]);
    else dfs4(G2[x][i],s);
  }
  if(!flag&&!used2[cmp[x]])maxs=max(maxs,s+sum[cmp[x]]);
}

void solve(){
  dfs2(0);
  int K=scc();
  for(int i=0;i<V;i++){
    if(sum[cmp[i]])f[cmp[i]]=1;
    sum[cmp[i]]+=w[i];
  }
  memset(used,0,sizeof(used));
  dfs3(0);
  memset(used,0,sizeof(used));
  used[0]=true;
  dfs4(0,0);
  ans+=maxs;
  cout<<ans<<endl;
}

int main(){
  cin>>n>>m;
  V=n;
  for(int i=0;i<n;i++)cin>>w[i];
  for(int i=0;i<m;i++){
    cin>>u>>v;
    u--,v--;
    G2[u].push_back(v);
    G2[v].push_back(u);
    G3[u].push_back(P(v,i));
    G3[v].push_back(P(u,i));
  }
  solve();
  return 0;
}

Measured memory_bytes: 33176
import sys
readline = sys.stdin.buffer.readline

from collections import deque
import copy

def myinput():
    return map(int,readline().split())

def bfs(n,S_start):
    q = deque()
    q.append(S_start)
    count = 0
    while q:
        S = q.popleft()
        state = S[0]
        a = S[0][0]
        b = S[0][1]
        c = S[0][2]
        which = S[1]
        if len(state[0])==(n+1):
            return count 
        elif len(state[2])==(n+1):
            return count
        else:
            if which:
                if a[-1]>b[-1]:
                    state[1].append(state[0].pop())
                    count += 1
                    nS = [state, not which ]
                    q.append(nS)
                else:
                    state[0].append(state[1].pop())
                    count += 1
                    nS = [state, not which ]
                    q.append(nS)
            else:
                if b[-1]>c[-1]:
                    state[2].append(state[1].pop())
                    count += 1
                    nS = [state, not which ]
                    q.append(nS)
                else:
                    state[1].append(state[2].pop())
                    count += 1
                    nS = [state, not which ]
                    q.append(nS)
    return float("inf")
            
ls_ans = []
while True:
    n,m = myinput()
    if (n+m)==0:
        break
    state_start_1 = [ [0] + list(myinput())[1:] for _ in range(3) ]
    state_start_2 = copy.deepcopy(state_start_1)
    S1 = [state_start_1,True]
    S2 = [state_start_2,False]
    ans1 = bfs(n,S1)
    ans2 = bfs(n,S2)
    ans = min(ans1,ans2)
    if ans<=m:
        ls_ans.append(ans)
    else:
        ls_ans.append(-1)

for i in range(len(ls_ans)):
    print(ls_ans[i])


Measured memory_bytes: 6304
import static java.lang.System.out;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    int N = in.nextInt();
    int t = 0;
    int m = 0;
    int tmp = 0;
    for(int i = 0; i < N; i++) {
        tmp = in.nextInt();
        if(tmp > t) {
            t = tmp;
            m = in.nextInt();
        }
        else in.nextInt();
    }
    out.println(t + m);

	}
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



Measured memory_bytes: 22544
package main

import "fmt"

func main() {
	// Code for B - Ringo's Favorite Numbers
	var D, N int
	fmt.Scanf("%d %d", &D, &N)

	var number int = 0
	if N == 100 {
		number++
	}
	if D == 0 {
		fmt.Println(N + number)
	} else if D == 1 {

		fmt.Println((N + number) * 100)
	} else {
		fmt.Println((N + number) * 10000)
	}
}


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

int main()
{
    int num[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> num[i];
    }
    sort(num, num + 3);
    cout << num[2] * 10 + num[1] + num[0];
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 128

void insertionSort(int *A, int N);

int main(void){
  int i, N, A[SIZE] = {0};
  scanf("%d", &N);
  for (i = 0; i < N; i++)
    scanf("%d", &A[i]);

  // output step 0
  for (i = 0; i < N; i++) {
    printf("%d", A[i]);
    if(i != N - 1)
      printf(" ");
  }
  printf("\n");
    
  insertionSort(A, N);
  return 0;
}

void insertionSort(int *A, int N){
  int i, j, k, v;
  for (i = 1; i <= N - 1; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

    // output each step
    for (k = 0; k < N; k++) {
      printf("%d", A[k]);
      if(k != N - 1)
	printf(" ");
    }
    printf("\n");
  }
}

Measured memory_bytes: 600
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int main(void){
  int N;
  cin>>N;
  priority_queue<long> a;
  long A;
  rep(i, N) {
    cin >> A;
    a.push(A); a.push(A-1); a.push(A+1);
  }
  long tmp1, tmp2;
  long count = 1, ans = 0;
  while(!a.empty()){
    tmp1 = a.top();
    a.pop();
    tmp2 = a.top();
    if (tmp1 == tmp2) count++;
    else {
      ans = max(ans, count);
      count = 1;
    }
  }
  cout << ans << endl;
     
  }
  
  
   


Measured memory_bytes: 6000
#include<iostream>

int main(){

    int a,b;
    std::cin>>a>>b;

    int coin=0;

    for(int i=0;i<2;i++){
        if(a>=b){
            coin+=a;
            a--;

        }else{  
            coin+=b;
            b--;
        }
    }

    std::cout<<coin<<std::endl;
    return 0;
}

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

const int MAX = 5 * 1e5 + 1;

struct Query {
  int l, r, idx;
};

bool cmp(Query x, Query y) { return x.r < y.r; }

void update(int idx, int val, int bit[], int n) {
  for (; idx <= n; idx += idx & -idx) bit[idx] += val;
}

int query(int idx, int bit[], int n) {
  int sum = 0;
  for (; idx > 0; idx -= idx & -idx) sum += bit[idx];
  return sum;
}

void answeringQueries(vector<int> arr, int n, vector<Query> queries, int q) {
  int bit[n + 1];
  memset(bit, 0, sizeof(bit));

  int last_visit[MAX];
  memset(last_visit, -1, sizeof(last_visit));

  int ans[q];
  int query_counter = 0;
  for (int i = 0; i < n; i++) {
    if (last_visit[arr[i]] != -1) update(last_visit[arr[i]] + 1, -1, bit, n);

    last_visit[arr[i]] = i;
    update(i + 1, 1, bit, n);

    while (query_counter < q && queries[query_counter].r == i) {
      ans[queries[query_counter].idx] =
          query(queries[query_counter].r + 1, bit, n) -
          query(queries[query_counter].l, bit, n);
      query_counter++;
    }
  }

  for (int i = 0; i < q; i++) cout << ans[i] << endl;
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  vector<Query> queries;
  for (int &x : a) cin >> x;
  int i = 0;
  while (i < q) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    queries.push_back({l, r, i});
    i++;
  }
  sort(queries.begin(), queries.end(), cmp);
  answeringQueries(a, n, queries, q);
  return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 100005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007



int main()
{
	FAST;
	int n, m;
	cin >> n >> m;
	int a[n+5][m+6];
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j ++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	
	for(int i = 0; i < n-1; i ++){
		int x = 0;
		for(int j = i + 1; j < n; j ++){
			for(int z = 0; z < m; z ++){
				x += (a[i][z] - a[j][z])*(a[i][z] - a[j][z]);
			}
			if(floor(sqrt(x)) == ceil(sqrt(x))){
				ans ++;
			}
			x = 0;
		}
	}
	cout << ans;
	return 0;
	
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for (int i = 0; 2 * i <= y; i++){
    for (int j = 0; 2 * i + 4 * j <= y; j++){
      if (2 * i + 4 * j == y && i + j == x){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
  int n;
  double num;

  cin >> n;

  vector<int> a(n);

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  num = a.at(0);
  for (int i = 1; i < n; i++) {
   num = (num + a.at(i)) / 2.0;
  }

  cout << num << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N; cin >> N;
  vector<ll> A,B;
  rep(i,N){
    ll a,b; cin >> a >> b;
    A.pb(a);
    B.pb(b);
  }

  ll ans = 0;
  ll now = 0;
  for(ll i = A.size()-1; i >=0; i--){
    A[i] += now;
    if(A[i] % B[i] == 0) continue;
    ll add = (A[i]/B[i] +1) * B[i] - A[i];
    now += add;
    ans += add;
      
  }
  cout << ans << endl;
  


  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int X,t;
    cin >>X>>t;
    cout << max(0,X-t) << endl;



}


Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,K = MI()
A = LI()

left = 0
right = max(A)  # 可能
while left + 1 < right:
    mid = (left + right)//2
    if sum((A[i]+mid-1)//mid - 1 for i in range(N)) <= K:
        right = mid
    else:
        left = mid
print(right)



Measured memory_bytes: 93792
N = int(input())
csum = list(0 for _ in range(2000+1))
L = []
cmax1, cmax2 = 0, 0
for l in map(int,input().split()):
    L.append(l)
    csum[l] += 1
    if cmax2 < l: cmax2 = l
    if cmax1 < l: cmax1, cmax2 = l, cmax1
for i in range(1,cmax1+cmax2+1): csum[i] += csum[i-1]
ans = 0
for ib in range(N):
    b = L[ib]
    for ia in range(ib):
        a = L[ia]
        minL, maxL = abs(a-b), a+b
        ans += csum[maxL-1] - csum[minL]
        if minL < a < maxL: ans -= 1
        if minL < b < maxL: ans -= 1
print(ans//3)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>v(N-1),u(N-1);
  for(int i=0;i<N-1;i++)cin>>v[i]>>u[i];
  vector<vector<int>>G(N);

  ll VV=0;
  for(int i=0;i<N-1;i++){
    int V=v[i];
    int U=u[i];
    if(V>U)swap(V,U);
    VV+=V*(N-U+1);
  }
  ll E=0;
  for(int i=0;i<N;i++){
    E+=(i+1)*(N-i);
  }
  cout<<E-VV<<endl;

  return 0;
}


Measured memory_bytes: 11108
#include <iostream>
//#include <string>
#include <algorithm>
//#include <functional>
//#include <array>
#include <math.h>
using namespace std;
typedef long long ll;

/*
array<ll,3> loop(array<ll, 3> ary) {
	array<ll, 3> rtn;
	//n -= (n / m)*m;
	rtn[0] = ary[1]	+ ary[2];
	rtn[1] = ary[0] + ary[2];
	rtn[2] = ary[0] + ary[1];
	return rtn;
}
ll min_ary(array<ll, 3> ary) {
	return min({ary[0], ary[1], ary[2]});
}*/
/*
ll loop(ll n, ll m, ll k) {
if (k == 1) {
return n % m;
}
else if (k % 2 == 0) {
ll t = loop(n, m, k / 2);
return t * t%m;
}
else {
return loop(n, m, k - 1)*n%m;
}
}
*/
int main() {
	//int n;
	//cin >> n;
	//string s[110];
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (abs(a - b) >= 1000000000000000000) {
		cout << "Unfair" << endl;
	}
	else if (k % 2 == 0) {
		cout << a - b << endl;
	}
	else {
		cout << b - a << endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

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

  if (S == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	bool ok = (a[0] == 0);
	for (int i = 1; i < N; ++i) {
		if (a[i] > a[i - 1]) {
			ok = ok && (a[i] == a[i - 1] + 1);
		}
	}

	if (!ok) {
		cout << -1 << endl;
		return 0;
	}

	a.push_back(-1);
	Int ans = 0;
	for (int i = 0; i + 1 < a.size(); ++i) {
		if (a[i] >= a[i + 1]) { ans += a[i]; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
def sum(n):
    num = 0
    while True:
        num += int(n%10)
        n = int(n/10)
        if n == 0:
            break
    return num

def main():
    N,A,B = [int(_) for _ in input().split(" ")]
    sum_num = 0

    for n in range(1, N+1):
        num = sum(n)

        if num >= A and num <= B:
            sum_num += n

    print(sum_num)

main()

Measured memory_bytes: 3060
def main():
    n = int(input())
    sub = 1
    a_ls = list(map(int, input().split()))
    for i in range(n):
        if a_ls[i] == 0:
            print(0)
            return
    for i in range(n):
        sub*=a_ls[i]
        if 10**18 < sub:
            print(-1)
            return
    print(sub)
if __name__ == '__main__':
    main()


Measured memory_bytes: 21540
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int a,i,t=0,k,b;
    cin>>a;
    while(a--)
    {
        k=0;
        cin>>b;
        for(i=2;i<=sqrt(b);i++)
        {
            if(b%i==0)
            {
                k=1;
            }
        }
        if(k==0)
        {
            t++;
        }
    }
    cout<<t<<endl;
}



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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=(a);i<int(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  int n,tmp=0,ans=inf;std::cin >> n;
  vi a(n); rep(i,n) std::cin >> a[i];
  loop(i,-100,101){
    tmp=0;
    rep(j,n) tmp+= (a[j]-i)*(a[j]-i);
    if(tmp<ans) ans=tmp;
  }
  std::cout << ans << std::endl;
}


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

int main() {
 int A,B,H,M;
 double x,y,z,t;
  const double PI = acos(-1);
  cin>> A;
  cin>> B;
  cin>> H;
  cin>> M;
  x=6*M;
  y=30*H+0.5*M;
  
  if(x<=y){
    z=y-x;
  }else{
    z=x-y;
  }
  t=sqrt(A*A+B*B-2*A*B*cos(z*acos(-1)/180));
  cout << std::fixed << std::setprecision(20) << t << endl;
}
  
 

Measured memory_bytes: 4184
#include <stdio.h>
int main(void){
    int i;
    int j = 0;
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    for(i = a; i <= b; i++){
        if(c%i == 0)
            j += 1;
    }
    printf("%d\n", j);
    return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
//	ios::sync_with_stdio(false);
	ll a, v, b, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	ll cnt = abs(a - b);
	ll cmt = v - w;
	if (cmt <= 0)
		cout << "NO" << endl;
	else {
		ll p = cnt/cmt;
		if (cnt % cmt != 0)
			p++;
		if (p <= t)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
		return 0;
}

Measured memory_bytes: 3040
def into_ruiseki(a):
	n = len(a)
	ret = [0 for i in range(n + 1)]
	for i in range(n):
		ret[i + 1] = ret[i] + a[i]
	return ret

n = int(input())
a = list(map(int, input().split()))

b = sorted(into_ruiseki(a))
# print("b =", b)
ans = 0
cnt = 1
for i in range(1, n + 1):
	if b[i] == b[i - 1]:
		cnt += 1
	else:
		ans += cnt * (cnt - 1) // 2
		cnt = 1
ans += cnt * (cnt - 1) // 2
print(ans)

Measured memory_bytes: 109452
#include <iostream>
#include <utility>

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    int n;
    cin >> n;
    cin >> s;
    int c[2][2] ={{0,0},{0,0}};//E:0 W:1
    for(int i = 1;i < n;i++){
        if(s[i] == 'E')
            c[1][0]++;
        else
            c[1][1]++;
    }
    int minc = c[1][0];
    for(int i = 0;i < n - 1;i++){
        if(s[i] == 'E')
            c[0][0]++;
        else
            c[0][1]++;
        if(s[i+1] == 'E')
            c[1][0]--;
        else
            c[1][1]--;
        minc = min(minc,c[1][0] + c[0][1]);
    }
    cout << minc << endl;
    return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int (a);i<int(b);i++)
#define F(i,a,b) for(int (i)=int(a);i>=int (b);i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vt vector
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
typedef pair<int,int> ii;
const double pi=acos(-1.0);
const double eps=1e-5;
const int N=1e6+6,mod=1e9+7,INF=1<<30;
char s[1002][1002];
int d[1002][1002];
int n,m,k;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
bool pd(int x,int y){
	if(x>0&&x<=n&&y>0&&y<=m&&s[x][y]!='#') return 1;
	return 0;
}
void solve()
{
	int ans=0;
	cin>>n>>m;
	queue<ii> qu;
	ms(d,-1);
	f(i,1,n){
		f(j,1,m){
			cin>>s[i][j];
			if(s[i][j]=='#'){
				qu.push(ii(i,j));
				d[i][j]=0;
			}
		}
	}
	while(!qu.empty()){
		int x=qu.front().fi,y=qu.front().se;
		qu.pop();
		ff(i,0,4){
			int nx=x+dx[i],ny=y+dy[i];
			if(!pd(nx,ny)) continue;
			if(d[nx][ny]==-1){
				d[nx][ny]=d[x][y]+1;
				ans=max(ans,d[nx][ny]);
				qu.push(ii(nx,ny));
			}
		}
	}
	cout<<ans;

}int main(){
	solve();
	return 0;
}












Measured memory_bytes: 13328
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    map<int, int> A;
    rep(i,n){
        A.emplace(i+1,0);
    }
    rep(i,n-1){
        int a; cin >> a;
        
        A[a]++;
        
    }
    
    for (auto itr = A.begin(); itr != A.end(); itr++) {
        cout << itr->second << endl;
    }
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 13032
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class modint {
public:
	ll val;
	modint(ll a) {
		val = a % mod;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % mod);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	modint operator/(const modint& r) {
		return modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}

};

//素因数分解
unordered_map<ll, ll> p_f(ll n) {
	unordered_map<ll, ll> ans;
	for (ll i = 2; i < sqrt(n) + 1; i++) {
		if (n == 1)break;
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1)ans[n]++;
	return ans;
}

modint<MOD> pf_to_int(unordered_map<ll, ll>& x) {
	modint<MOD> ret = 1;
	for (auto itr = x.begin(); itr != x.end(); itr++) {
		ret *= modpow(modint<MOD>((*itr).first), (*itr).second);
	}
	return ret;
}

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N, 0);
	for (int i = 0; i < N; i++)cin >> a[i];

	vector<unordered_map<ll, ll>> pfa(N);
	for (int i = 0; i < N; i++) {
		pfa[i] = p_f(a[i]);
	}

	unordered_map<ll, ll> lcm;
	for (int i = 0; i < N; i++) {
		for (auto itr = pfa[i].begin(); itr != pfa[i].end(); itr++) {
			lcm[(*itr).first] = max(lcm[(*itr).first], (*itr).second);
		}
	}

	unordered_map<ll, ll> tmp = lcm;
	modint<MOD> ans(0);
	for (int i = 0; i < N; i++) {
		for (auto itr = pfa[i].begin(); itr != pfa[i].end(); itr++) {
			tmp[(*itr).first] = tmp[(*itr).first] - (*itr).second;
		}
		ans += pf_to_int(tmp);
		for (auto itr = pfa[i].begin(); itr != pfa[i].end(); itr++) {
			tmp[(*itr).first] = tmp[(*itr).first] + (*itr).second;
		}
	}


	cout << ans.val << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(int argc, char const *argv[]) {
  double r, area, circum;
  cin >> r;
  area = r*r*M_PI;
  circum = 2*r*M_PI;
  printf("%lf %lf",area, circum);
  return 0;
}

Measured memory_bytes: 3204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
string a,b;
int main()
{
	int m,n,i,j,t,k;
	cin>>a>>b;
	for(i=0;i<a.size();i++)
	{
		if(a[i]!=b[i]) break;
	}
	if(i==a.size()) cout<<"Yes";
	else cout<<"No";
 } 

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int n;
  string s;
  cin>>n;
  rep(i,n){
    int maxi,mini;
    cin>>s;
    sort(all(s));
    mini=atoi(s.c_str());
    reverse(all(s));
    maxi=atoi(s.c_str());
    cout<<maxi-mini<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

ll fast_pow(ll a, ll n, ll mod = MOD){
    if(n == 0) return 1;
    //べき数nが奇数, aを前にだして, a^n-1の気持ちに
    if(n % 2 == 1){
        return a * fast_pow(a, n - 1) % mod;
    }else{
        //べき数nが偶数のとき，べき数を半分にして, aをまとめる. べき数を半分にする
        return fast_pow(a * a % mod, n / 2) % mod;
    }
}
 
int main() {
    //頂点数
    ll N, M;
    cin >> N >> M;

    //コスト
    vector<ll > A(M,0);
    //入力個数
    vector<ll > B(M,0);
    //箱との対応
    vector<ll > C(M,0);

    for(ll i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        for(ll j = 0; j < B[i]; j++){
            ll t; cin >> t;
            t--;
            //ビットに表した時の数
            C[i] += 1<<t;
        }
    }

    //2^12 = 4096 最大
    ll limit = fast_pow(2, 12);
    vector<vector<ll > > dp(M + 1919, vector<ll >(limit, INF));
    dp[0][0] = 0;

    for(ll i = 0; i < M; i++){
        for(ll j = 0; j < (1<<N); j++){
            if(dp[i][j] == INF) continue;
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

            ll next = j | C[i];

            dp[i + 1][next] = min(dp[i][j] + A[i],  dp[i + 1][next]);
            
            //cout << next << " " << dp[i + 1][next] << endl;
        }        
    }

    //(1<<N)-1 全部立っていますか？
    if(dp[M][(1<<N)-1] == INF){
        cout << -1 << endl;
    }else{
        cout << dp[M][(1<<N)-1] << endl;
    }

    
}

Measured memory_bytes: 93824
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    string a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=0;i<a.size();i++)
        if(a[i]!=b[i])
        ans++;
    cout << ans;

	return 0;
}



Measured memory_bytes: 6136
S = [int(i) for i in list(str(input()))]
bad_ = 0
for i in range(len(S)):
  if i == 0:
    if S[0] == S[1]:
      print("Bad")
      bad_ += 1
      break
  else:
    if S[i] == S[i-1]:
      print("Bad")
      bad_ += 1
      break

if bad_ == 0:
  print("Good")
  

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int cell[30][30];
int main(){
	while(true){
		char dum;
		int x,y,size;
		cin >> x;
		if(cin.eof())break;
		cin >> dum;
		x +=10;
		cin >> y;
		y +=10;
		cin >> dum;
		cin >> size;
		if(size == 1){
			cell[x][y-1]++;cell[x-1][y]++;cell[x][y]++;cell[x+1][y]++;cell[x][y+1]++;
		}
		else if(size == 2){
			for(int i= -1;i<=1;i++)
				for(int j = -1;j<=1;j++)
					cell[x+i][y+j]++;
		
		}
		else
		{
			for(int i= -1;i<=1;i++)
				for(int j = -1;j<=1;j++)cell[x+i][y+j]++;
			cell[x][y-2]++;cell[x-2][y]++;cell[x+2][y]++;cell[x][y+2]++;
		}
	}
	int max = 0,empty = 0;
	for(int i=10;i<=19;i++)
		for(int j = 10;j<=19;j++)
		{
			if(cell[i][j] == 0) empty++;
			else if(max < cell[i][j]) max=cell[i][j];
		}
	cout << empty << endl;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define N 100
#define D 100001
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int n,hp[N],m,mp[N],damage[N],minc;
int dpAll[D],dpSin[D];
string name,target[N];
ll ans;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)cin>>hp[i];
    cin>>m;
    for(int i=0;i<m;i++)
      cin>>name>>mp[i]>>target[i]>>damage[i];
    for(int i=0;i<D;i++)dpAll[i]=dpSin[i]=INF;
    dpAll[0]=dpSin[0]=0;
    for(int i=0;i<D;i++){
      if(dpAll[i]==INF)continue;
      for(int j=0;j<m;j++){
	if(target[j]!="All")continue;
	if(i+damage[j]<D)
	  dpAll[i+damage[j]]=min(dpAll[i+damage[j]],dpAll[i]+mp[j]);
	else
	  dpAll[D-1]=min(dpAll[D-1],dpAll[i]+mp[j]);
      }
    }
    for(int i=0;i<D;i++){
      if(dpSin[i]==INF)continue;
      for(int j=0;j<m;j++){
	if(target[j]!="Single")continue;
	if(i+damage[j]<D)
	  dpSin[i+damage[j]]=min(dpSin[i+damage[j]],dpSin[i]+mp[j]);
	else
	  dpSin[D-1]=min(dpSin[D-1],dpSin[i]+mp[j]);
      }
    }
    minc=INF;
    for(int i=D-1;i>=0;i--){
      minc=min(minc,dpSin[i]);
      dpSin[i]=minc;
    }
    ans=INF;
    for(int i=0;i<D;i++){
      if(dpAll[i]==INF)continue;
      ll cnt=dpAll[i];
      for(int j=0;j<n;j++){
	int k=hp[j]-i;
	if(k<0)k=0;
	cnt+=dpSin[k];
      }
      ans=min(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2000
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    // input
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X), B(Y), C(Z);
    REP (i, X) cin >> A[i];
    REP (i, Y) cin >> B[i];
    REP (i, Z) cin >> C[i];

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    // A+Bが大きいほうからK個選ぶ
    vector<ll> AB;
    for (auto e : A ) {
        for (auto f : B) {
            AB.push_back(e+f);
        }
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    while (AB.size() > K) {
        AB.pop_back();
    }

    // (A+B)+Cをする
    vector<ll> ABC;
    for (auto e : AB) {
        for (auto f : C) {
            ABC.push_back(e+f);
        }
    }

    sort(ABC.begin(), ABC.end(), greater<ll>());

    // output
    REP (i, K) {
        cout << ABC[i] << "\n";
    }
}

Measured memory_bytes: 43368
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for (int i=0; i<4; i++)reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i=0; i<S.size();){
        bool can2 = false;
        for(int j=0; j<4; j++){
            string d = divide[j];
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }

        if(can2 == false){
            can = false;
            break;
        }
    }
    if(can)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#include <bits/stdc++.h>
 
int main() {
    int n;
	string s;
	cin >> n >> s;
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (j - k != i - j && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}

Measured memory_bytes: 3724
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int)1e5 + 5;
int n, k, ans;
int p[maxn];
vector<int> g[maxn];

bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
    scanf("%d", &p[i]);
    p[i]--;
  }
  return true;
}

int dfs(int v) {
  int res = 0;
  for (int i = 0; i < sz(g[v]); i++) {
    res = max(res, dfs(g[v][i]) + 1);
  }
  if (res == k - 1 && p[v] != 0) {
    ans++;
    return -1;
  }
  return res;
}

void solve() {
  ans = 0;
  if (p[0] != 0) {
    ans++;
    p[0] = 0;
  }
  for (int i = 1; i < n; i++) {
    g[p[i]].push_back(i);
  }
  dfs(0);
  printf("%d\n", ans);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 12416
// Problem : D - Water Bottle
// Contest : AtCoder - AtCoder Beginner Contest 144
// URL : https://atcoder.jp/contests/abc144/tasks/abc144_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
const ld PI = acos(-1);
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ld f(ld a,ld b,ld x)
{
	ld ans;
	if(a*a*b/2.0 <= x)
	{
		ans=atan(2*(a*a*b - x)/(a*a*a));
	}
	else
	{
		ans=PI/2 - atan(2*x/(b*b*a));
	}
	return ans;
}
void solve()
{
    ld a,b,x;
    cin>>a>>b>>x;
    cout<< fixed << setprecision(10)<<f(a,b,x)*180.0/PI;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256