akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s;
ll sum[200001] = {}, ten = 10, cnt[2019] = {}, ans = 0;

int main() {
	cin >> s;
	reverse(s.begin(), s.end());
	sum[0] = 0;
	rep(i, sz(s)) {
		sum[i + 1] = (sum[i] + ((s[i] - '0') * ten) % 2019) % 2019;
		ten *= 10;
		ten %= 2019;
	}
	rep(i, sz(s) + 1) {
		ans += cnt[sum[i]];
		cnt[sum[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5320
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();

        final Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.compute(in.nextInt(), (k, v) -> {
                if (v == null) {
                    return 1;
                }
                return v + 1;
            });
        }

        if (map.size() == 1) {
            if (map.keySet().contains(0)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            return;
        }

        if (n % 3 != 0) {
            System.out.println("No");
            return;
        }

        if (map.size() > 3) {
            System.out.println("No");
            return;
        }

        if (map.size() == 2) {
            if (map.keySet().contains(0) && map.get(0) == n / 3) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            return;
        }

        final Iterator<Integer> iterator = map.keySet().iterator();
        final Integer[] counts = map.values().toArray(new Integer[0]);
        if ((iterator.next() ^ iterator.next()) == iterator.next()
                && counts[0].intValue() == counts[1].intValue()
                && counts[0].intValue() == counts[2].intValue()) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int ans = 0;
  vector<char> A(N);
  for (int i = 0; i < N; i++) {
    if (T.at(i) == 'r') {
      if (i - K >= 0 && A.at(i - K) == 'p') {
        if (i + K >= N) {
          A.at(i) = 'r';
        }
        else {
          if (T.at(i + K) == 's') A.at(i) = 's';
          else A.at(i) = 'r';
        }
      }
      else {
        A.at(i) = 'p';
        ans += P;
      }
    }
    else if (T.at(i) == 's') {
      if (i - K >= 0 && A.at(i - K) == 'r') {
        if (i + K >= N) {
          A.at(i) = 's';
        }
        else {
          if (T.at(i + K) == 'p') A.at(i) = 'p';
          else A.at(i) = 's';
        }
      }
      else {
        A.at(i) = 'r';
        ans += R;
      }
    }
    else {
      if (i - K >= 0 && A.at(i - K) == 's') {
        if (i + K >= N) {
          A.at(i) = 'p';
        }
        else {
          if (T.at(i + K) == 'r') A.at(i) = 'r';
          else A.at(i) = 'p';
        }
      }
      else {
        A.at(i) = 's';
        ans += S;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int sum = 0;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y")
      sum = sum + 1;
  }
  if (sum > 0)
    cout << "Four";
  else
    cout << "Three";
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SyntheticKadomatsu solver = new SyntheticKadomatsu();
        solver.solve(1, in, out);
        out.close();
    }

    static class SyntheticKadomatsu {
        List<Integer> l;
        int n;
        int a;
        int b;
        int c;
        int result = Integer.MAX_VALUE;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            a = in.nextInt();
            b = in.nextInt();
            c = in.nextInt();
            l = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                l.add(in.nextInt());
            }
            recursive(10, 1, l.get(0), 0, 0);
            recursive(10, 1, 0, l.get(0), 0);
            recursive(10, 1, 0, 0, l.get(0));
            recursive(0, 1, 0, 0, 0);

            out.println(result);
        }

        public void recursive(int score, int num, int aa, int bb, int cc) {
            if (num == n) {
                if (aa == 0 || bb == 0 || cc == 0) {
                    return;
                }
                score += Math.abs(a - aa) + Math.abs(b - bb) + Math.abs(c - cc) - 30;
                result = Math.min(score, result);
                return;
            }
            recursive(score + 10, num + 1, aa + l.get(num), bb, cc);
            recursive(score + 10, num + 1, aa, bb + l.get(num), cc);
            recursive(score + 10, num + 1, aa, bb, cc + l.get(num));
            recursive(score, num + 1, aa, bb, cc);


        }

    }
}



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

double a,b,c,d;
signed main(){
	cin>>a>>b>>c>>d;
	printf("%.12lf\n",sqrt(pow(abs(a-c),2)+pow(abs(b-d),2)));
	return 0;
}


Measured memory_bytes: 3292
#include <stdio.h>
#include <math.h>

#define PI 3.14159265

int main(void) {
	double x = 0, y = 0;
	int s = 90, h, k;
	while (1) {
		scanf("%d,%d", &h, &k);
		if (!h && !k)
			break;
		x += cos(s * PI / 180) * (double)h;
		y += sin(s * PI / 180) * (double)h;
		s -= k;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 604
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

// Data :
type Data struct {
	day, pay int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	if p[i].pay == p[j].pay {
		return p[i].day > p[j].day
	}
	return p[i].pay > p[j].pay
}

//　セグメント木
const inf = -1

type segtree struct {
	n int
	v []int
	a []int // 加算値
}

func (s *segtree) init(n int) {
	N := 1
	for n > N {
		N *= 2
	}
	s.v = make([]int, N*2)
	s.a = make([]int, N*2)
	s.n = N
}

func (s *segtree) update() {
	K := s.n
	for K > 0 {
		K /= 2
		for i := K; i < 2*K; i++ {
			s.v[i] = s.compare(s.v[i*2], s.v[i*2+1])
		}
	}
}

func (s *segtree) lazyCalc(k int) {
	s.v[k] += s.a[k]
	if k < s.n {
		s.a[2*k] += s.a[k]
		s.a[2*k+1] += s.a[k]
	}
	s.a[k] = 0
}

func (s *segtree) compare(p, q int) int {
	if p < q {
		return q
	}
	return p
}

func (s *segtree) setSub(a, b, k, l, r, x int) {
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		s.a[k] += x
		s.lazyCalc(k)
	} else {
		s.lazyCalc(k)
		s.setSub(a, b, k*2, l, (l+r)/2, x)
		s.setSub(a, b, k*2+1, (l+r)/2, r, x)
		s.v[k] = s.compare(s.v[2*k], s.v[2*k+1])
	}
}

// set v[k] = val
func (s *segtree) set(a, b, x int) {
	s.setSub(a, b, 1, 0, s.n, x)
}

// querySub
func (s *segtree) querySub(a, b, k, l, r int) int {
	s.lazyCalc(k)
	if b <= l || r <= a {
		return inf
	}
	if a <= l && r <= b {
		return s.v[k] + s.a[k]
	}
	return s.compare(
		s.querySub(a, b, k*2, l, (l+r)/2),
		s.querySub(a, b, k*2+1, (l+r)/2, r))
}

// query([a,b) )
func (s *segtree) query(a, b int) int {
	return s.querySub(a, b, 1, 0, s.n)
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()

	J := make(Datas, N)
	n := make([]int, N)
	for i := 0; i < N; i++ {
		a, b := getInt(), getInt()
		J[i] = Data{a, b}
		n[i] = i
	}

	sort.Sort(J)
	// out(J)
	var s segtree
	s.init(N)
	for i := 0; i < M; i++ {
		s.set(i, i+1, i+1)
	}
	// out(s)
	// out(J)
	idx := 0
	ans := 0
L0:
	for i := 1; i <= M; i++ {
		for {
			if idx == len(J) {
				break L0
			}
			day := J[idx].day
			ret := s.query(0, M-day+1)
			if ret > 0 {
				s.set(ret-1, ret, -ret)
				ans += J[idx].pay
				// out(ret, J[idx])
				idx++
				break
			}
			idx++
		}
		// out(s)
		// out(day, M, M-day, "ret", ret)
		// out(ret, i, M)
	}
	out(ans)
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int M, K;
    cin >> M >> K;

    int ma = 1 << M;
    vector<int> ans;
    vector<bool> isused(ma);
    for (int i = 0; i < ma; ++i) {
        if (isused[i])
            continue;
        int tmp = K ^ i;
        if (tmp < ma) {
            ans.push_back(i);
            ans.push_back(tmp);
            isused[i] = isused[tmp] = true;
        }
    }

    if (K == 0) {
        for (int i = 0; i < ma * 2; ++i)
            cout << ans[i] << " ";
        cout << endl;
        return 0;
    }

    if (ma != ans.size() || ((ans.size() >> 1) & 1)) {
        cout << -1 << '\n';
        return 0;
    }
    
    for (int i = 0; i < ma; i += 2)
        cout << ans[i + 1] << " " << ans[i] << " ";
    for (int i = 0; i < ma; ++i)
        cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template <typename T> using V = vector<T>;

bool solve() {
    int N;
    cin >> N;
    if(!N) return false;
    V<V<int>> P(N);
    for(auto &&v : P) {
        int m;
        cin >> m;
        V<int> tmp(m);
        for(auto &&e : tmp) {
            cin >> e;
            e--;
        }
        v = tmp;
    }

    int K;
    cin >> K;
    V<int> L(K);
    for(auto &&e : L) {
        cin >> e;
        e--;
    }

    V<int> ok;
    for(int i = 0; i < N; i++) {
        bool aint = true;
        for(int e : L) {
            bool found = false;
            for(int f : P[i]) {
                if(e == f) found = true;
            }
            if(!found) aint = false;
        }
        if(aint) ok.push_back(i);
    }

    if(ok.size() == 1) cout << ok[0] + 1;
    else cout << -1;
    cout << endl;
    return true;
}

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



Measured memory_bytes: 3140
//
//  main.cpp
//  gcd
//
//  Created by Syngnath on 15/12/16.
//  Copyright ? 2015年 Syngnath. All rights reserved.
//
#include <iostream>
#include <cstdio>

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

int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b) != EOF)
    {
        int g = gcd(a,b);
        int l = a/g*b;
        printf("%d %d\n",g,l);
    }
}

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

int judge(string x, string y){
  if(x.size() > y.size()){
    return 1;
  }else if(x.size() < y.size()){
    return -1;
  }else{
    for(int i = 0; i < x.size(); i++){
      if(x[i] > y[i]){
	return 1;
      }else if(x[i] < y[i]){
	return -1;
      }else{
	continue;
      }
    }
    return 0;
  }
}

int main(){
  string N;
  int K;
  cin >> N >> K;
  ll len = N.size();
  int top = N[0] - '0';
  ll res = 0;
  if(K == 1){
    res += (len - 1) * 9;
    res += top;
  }
  if(K == 2){
    for(int i = 1; i < len-1; i++){
      res += 9 * 9 * i;
    }
    for(int i = 1; i < len; i++){
      for(int j = 1; j < 10; j++){
	for(int k = 1; k < 10; k++){
	  string tmp(len, '0');
	  tmp[0] = j + '0';
	  tmp[i] = k + '0';
	  if(judge(N, tmp) >= 0){
	    res++;
	  }
	}
      }
    }
  }
  if(K == 3){
    for(int i = 2; i < len - 1; i++){
      res += 9 * 9 * 9 * (i * (i-1)) / 2;
    }
    for(int i = 1; i < len; i++){
      for(int j = i + 1; j < len; j++){
	for(int a = 1; a < 10; a++){
	  for(int b = 1; b < 10; b++){
	    for(int c = 1; c < 10; c++){
	      string tmp(len, '0');
	      tmp[0] = a + '0';
	      tmp[i] = b + '0';
	      tmp[j] = c + '0';
	      if(judge(N, tmp) >= 0){
		res++;
	      }
	    }
	  }
	}
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n,q,ans=0;
    cin>>n;
    vector<long long int>a(1000000);
    vector<long long int>b(1000000);
    vector<long long int>c(1000000);
    vector<long long int>d(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+=a[i];
        d[a[i]]++;
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>b[i]>>c[i];
    }
    for(int i=0;i<q;i++){
        ans-=(d[b[i]]*b[i]);
        ans+=(d[b[i]]*c[i]);
        d[c[i]]+=d[b[i]];
        d[b[i]]=0;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 34404
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}

use std::cmp::{min};
use std::num;

fn main() {
    
    let s = read::<String>().chars().collect::<Vec<char>>();
    
    let mut table : [usize; 100000] = [0; 100000];
    
    let mut index = 0;
    loop {
        // r search
        let start_index = index;
        for i in index..s.len() {
            if s[i] == 'L' {break;}
            index += 1;
        };
        
        let stop_index = index;
        
        let r_cnt = stop_index - start_index;
        //println!("R CNT {}", r_cnt);
        //println!("FIN R INDEX {}", stop_index - 1);
        
        table[stop_index - 1] += r_cnt / 2 + r_cnt % 2;
        table[stop_index    ] += r_cnt / 2; 
        
        // l search
        
        let start_index = index;
         for i in index..s.len() {
            if s[i] == 'R' {break;}
            index += 1;
        };
        let stop_index = index;
        
        let l_cnt = stop_index - start_index;
        //println!("L CNT {}", l_cnt);
        //println!("FIN L INDEX {}", start_index);
        
        table[start_index - 1] += l_cnt / 2;
        table[start_index    ] += l_cnt / 2 + l_cnt % 2; 
        
        if index >= s.len() {break;}
    }
    
    for i in 0..s.len() {
        print!("{} ", table[i]);
    }
}

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

int main(){
  int m;
  cin>>m;
  set<string> S;
  string s;
  for(int i=0;i<m;i++){
    S.clear();
    cin>>s;
    for(int j=1;j<=s.size();j++){
      string x,y,z,w;
      x = s.substr(0,j);
      z = x;
      y = s.substr(j,s.size()-j);
      w = y;
      reverse(z.begin(),z.end());
      reverse(w.begin(),w.end());
      S.insert(x+y);
      S.insert(y+x);
      S.insert(x+w);
      S.insert(w+x);
      S.insert(z+y);
      S.insert(y+z);
      S.insert(z+w);
      S.insert(w+z);
    }
    cout<<S.size()<<endl;
  }
  return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

template<typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    SegmentTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(1 << i) | 0], node[(1 << i) | 1]);
        }
    }

    void set(int index, T value) {
        index += offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right]
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

int main() {
    ll N;
    cin >> N;
    auto func = [](ll a, ll b) {
        return a + b;
    };
    SegmentTree<ll> seg(func, 0);
    seg.init(N);
    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            ll s = seg.get(x, x);
            seg.set(x, y + s);
        }
        else {
            cout << seg.get(x, y) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4864
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();
		int numD = nextInt();

		out.println(numA * numB > numC * numD ? numA * numB : numC * numD);

	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	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;
	}

	private 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 int nextInt() {
		return Integer.parseInt(next());
	}

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

Measured memory_bytes: 21332
N = int(input())
G = []
for i in range(9):
    G.append([])
for i in G:
    for j in range(9):
        i.append([])

for i in range(1,N+1):
    if i % 10 == 0:
        continue
    x = list(str(i))
    A = int(x[0])
    B = int(x[len(x)-1])
    G[A-1][B-1].append(i)

ans = 0
for i in range(9):
    for j in range(9):
        ans += len(G[i][j]) * len(G[j][i])

print(ans)

Measured memory_bytes: 10644
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  print $ solve n k

solve :: Int -> Int -> Double
solve n k = foldr1 (+) [ go i | i <- [1..n] ] / (fromIntegral n)
  where
    go :: Int -> Double
    go i | i >= k    = 1.0
         | otherwise = go (i * 2) * 0.5

Measured memory_bytes: 2684
#include <stdio.h>

int main(void) {
	int a,b,c,d;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	printf("%d\n%d\n",(a+b+c+d)/60,(a+b+c+d)%60);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, k;
	cin >> n >> k;
	double ans = 0;
	REP(i, 1, n + 1)
	{
		int tmp_point = i;
		double tmp_ans = 1. / n;
		int frequency = 0;
		while (tmp_point < k)
		{
			tmp_point *= 2;
			frequency++;
		}
		tmp_ans *= 1. / pow(2, frequency);
		ans += tmp_ans;
	}
	cout << d20 << ans << endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	int n; cin >> n;
	double ans;
	if (n % 2 == 0) {
		COUT(0.5);
	}
	else {
		COUT((double)((double)(n / 2 + 1) / (double)n));
	}
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 256
n = int(input())
s = input()
h = [0]*(10**5)

k = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

for i in range(len(s)):
  h[i] = k[((k.index(s[i]))+n)%26]

for j in range(len(s)):
  print(h[j],end="")

print(end="")

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll fac[200000+1],ifac[200000+1];

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % mod;
        x = x*x % mod;
        n = n >> 1; 
    }
    return res;
}
ll comb(ll a,ll b){
    if(a==0 && b==0) return 1;
    if(a<b || a<0) return 0;
    ll tmp = ifac[a-b]*ifac[b] % mod;
    return tmp*fac[a] % mod;
}
void calc_fac(){
   fac[0] = 1;
   ifac[0] = 1;
   for(int i = 0;i < 200000;i ++){
       fac[i+1] = fac[i]*(i+1) % mod;
       ifac[i+1] = ifac[i]*mpow(i+1,mod-2) % mod;
   }
}

int main(){
    ll h,w,a,b,ans=0;
    cin >> h >> w >> a >> b;
    calc_fac();
    for(int i = 0;i < h-a;i ++){
        ans += comb(i+b-1,i)*comb(w+h-2-b-i,w-1-b);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
int main(){
string S;
cin>>S;
int x = ((int)(S[0]) - 48)*10+((int)(S[1]) - 48);
int y = ((int)(S[2]) - 48)*10+((int)(S[3]) - 48);

if((0<x&&x<13)&&(0<y&&y<13)){
  cout<<"AMBIGUOUS"<<endl;
}
else if(0<x&&x<13)
cout<<"MMYY"<<endl;
else if(0<y&&y<13)
cout<<"YYMM"<<endl;
else
cout<<"NA"<<endl;


}

Measured memory_bytes: 256
import sys
import copy
input = sys.stdin.readline

S=(input())

if S[0]=="R" and S[1]=="R" and S[2]=="R":
    print(3)
elif S[0]=="S" and S[1]=="S" and S[2]=="S":
    print(0)

elif S[0]=="R" and S[1]=="R" or S[1]=="R" and S[2]=="R" :
    print(2)
else:
    print(1)

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

int main()
{
  int K, A, B;

  cin >> K >> A >> B;

  bool flag = false;

  for (int i = A; i <= B; i++)
  {
    if (i % K == 0)
    {
      flag = true;
      break;
    }
  }

  if (flag)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3636
def main():
    points = int(input())
    info = []
    for _ in range(points):
        info.append(list(map(int, input().split())))
    info.sort(key=lambda x: x[2], reverse=True)
    is_answered = False
    for x in range(101):
        if is_answered:
            break
        for y in range(101):
            now_height = abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2]
            if all(info[i][2] == max(now_height - abs(x - info[i][0]) - abs(y - info[i][1]), 0) for i in range(1, points)):
                if now_height > 0:
                    print(x, y, now_height)
                    is_answered = True
                    break


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int gcd(int a,int b);
int main (){
    int a,b,c;
    while(cin >> a >>b){
        if(a<b){
            int tmp;
            tmp = a;
            a = b;
            b = tmp;
        }
        cout << gcd(a,b) << endl;
    }
}

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

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int L = 2*N-1;
		int[] a = new int[L];
		for(int i=0; i<L; i++)
			a[i] = sc.nextInt();
		
		int min = 1;
		int max = L;
		boolean b[] = new boolean[L];
		while(min+1 < max) {
			int mid = (min + max)/2;
			for(int i=0; i<L; i++)
				b[i] = a[i]>=mid;
			if(satisfy(b))
				min = mid;
			else
				max = mid;
		}
		System.out.println(min);
		
		sc.close();
	}
	
	static boolean satisfy(boolean[] b) {
		int L = b.length;
		int N = (L+1)/2;

		int l = N-1;
		while(l>0 && b[l]!=b[l-1])
			l--;

		int r = N-1;
		while(r<L-1 && b[r]!=b[r+1])
			r++;
		
		if(l>0) {
			if(r<L-1) {
				if(b[l]==b[r])
					return b[l];
				else
					return (l+r)/2>=N-1 ? b[l] : b[r];
			} else {
				return b[l];
			}
		} else if(r<L-1) {
			return b[r];
		} else {
			return b[N-1] ^ N%2==0;
		}
	}
}


Measured memory_bytes: 65556
N = int(input())
a = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for i in range(3)] for j in range(N + 1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k])

print(max(dp[N]))

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

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

int32_t main()
{
    startup();
	
		 int n,d;
		 cin>>n>>d;
		 int ans=0;
		 for(int i=0 ; i<n ;++i)
		 {
		 	int x,y;
		 	cin>>x>>y;
		 	if((double)pow(x,2)+pow(y,2)<=pow(d,2)){
		 		ans++;
		 	}
		 }
		 cout<<ans;

    return 0;
}




Measured memory_bytes: 3608
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    n = s[-1]
    if int(n) in (2, 4, 5, 7, 9):
        print('hon')
    elif int(n) in (0, 1, 6, 8):
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

int n;

int cntdiv(int x) {
	int c = 0;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			if (i > 1) c++;
			if (i * i < x) c++;
		}
	}
	return c;
}

int tdiv(int x) {
	if (x == 1) return 0;
	// cerr << "td " << x << endl;
	int nn = n;
	while (nn % x == 0) nn /= x;
	return (nn % x) == 1;
}

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

	cin >> n;
	int ans = cntdiv(n - 1);
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans += tdiv(i);
			if (i * i < n) ans += tdiv(n / i);
		}
	}
	cout << ans << endl;
}


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

int main()
{
    // input
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    priority_queue<P> q;
    int b,c;
    rep(i,m){
        cin >> b >> c;
        q.push(make_pair(c,b));
    }

    // solve
    sort(ALL(a));
    ll ans = 0;
    b = q.top().second;
    c = q.top().first;
    q.pop();
    rep(i,n){
        if(c >= a[i]){
            ans += c;
            b--;
            if(b == 0){
                if(q.empty()){
                    c = 0;
                    b = 100005;
                }else{
                    b = q.top().second;
                    c = q.top().first;
                    q.pop();
                }
            }
        }else{
            ans += a[i];
        }
    }


    // output
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef tuple<int, int, int, int> T;

int H, W;
int a[510][510];
vector<T> ans;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i, H) rep(j, W) cin >> a[i][j];
    rep(i, H) {
        if (i%2==0) {
            rep(j, W) {
                if (i==H-1 && j==W-1) continue;
                int ni, nj;
                if (j==W-1) ni = i+1, nj = W-1;
                else ni = i, nj = j+1;
                if (a[i][j]%2==1) {
                    ans.pb(make_tuple(i+1, j+1, ni+1, nj+1));
                    a[ni][nj]++;
                }
            }
        }
        else {
            for (int j=W-1; j>=0; j--) {
                if (i==H-1 && j==0) continue;
                int ni, nj;
                if (j==0) ni = i+1, nj = 0;
                else ni = i, nj = j-1;
                if (a[i][j]%2==1) {
                    ans.pb(make_tuple(i+1, j+1, ni+1, nj+1));
                    a[ni][nj]++;
                }
            }
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i]) << " " << get<3>(ans[i]) << endl;
}

Measured memory_bytes: 8432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

void Main()
{
	int N;
	cin >> N;
	vector<int> H(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	vector<int> ans(N, 0);
	int ans_max = 0;

	for (int i = N - 2; i >= 0; i--) {
		if (H[i] >= H[i + 1]) {
			ans[i] = 1 + ans[i + 1];
		}
		ans_max = max(ans_max, ans[i]);
	}

	cout << ans_max;
}
 
int main()
{
	Main();
	return 0;
}



Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

N = int(input())
ad = [[] for _ in range(N)]
for _ in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1; b -= 1
    ad[a].append((b,c))
    ad[b].append((a,c))

Q,K = map(int,input().split())
K -= 1
query = [[int(e)-1 for e in input().split()] for _ in range(Q)]
dis = [0]*N

def dfs(v=K,d=0,pv=-1):
    for nv,nd in ad[v]:
        if nv == pv:
            continue
        dis[nv] = d+nd
        dfs(nv,d+nd,v)

dfs()
for x,y in query:
    ans = dis[x] + dis[y]
    print(ans)

Measured memory_bytes: 172844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  int l = s.size();
  int m = t.size();
  int res = -1;
  for(int i = 0; i <= (l - m); ++i){
    bool flag = true;
    for(int j = 0; j < m; ++j){
      if(s[i+j] == t[j] || s[i+j] == '?'){
        continue;
      }else{
        flag = false;
      }
    }
    if(flag){
      res = i;
    }
  }
  if(res != -1){
    string ans = s;
    for(int i = res; i < res + m; ++i){
      ans[i] = t[i-res];
    }
    for(int i = 0; i < l; ++i){
      if(ans[i] == '?') ans[i] = 'a';
    }
    cout << ans << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }
}

Measured memory_bytes: 3532
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    c=[parseMap(split(readline())) for i in 1:3]
    ans="No"
    for a1 in -100:100
        for a2 in -100:100
            for a3 in -100:100
                flg=true
                for i in 1:3
                    if !(c[i][1]-a1==c[i][2]-a2==c[i][3]-a3)
                        flg=false
                    end
                end
                if flg
                    ans="Yes"
                end
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 167452
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

int dp[50000];
int main(){
    int n,m,c;
    cin>>n>>m;
    rep(i,n+1) dp[i]=1000100010;
    dp[0]=0;
    rep(i,m){
        cin>>c;
        for(int j=0;j+c<=n;++j) dp[c+j]=min(dp[c+j],dp[j]+1);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 3288
<?php
fscanf(STDIN, "%d %d %d %d %d", $a, $b, $c, $x, $y);
$c *= 2;
$z = min($x, $y);
$s1 = $a * $x + $b * $y;
$s2 = $c * max($x, $y);
$s3 = $a * ($x - $z) + $b * ($y - $z) + $c * $z;
echo min($s1, $s2, $s3);

Measured memory_bytes: 4728
#include <stdio.h>


int main(void){
	int m, n, now, ans, sai;
	int sugoroku[1030];


	while (true){
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0){ break; }

		// テ」ツδ榲」ツつケテ」ツ?ョテ・ツ按敕ヲツ慊淌・ツ個?
		for (int i = 0; i < 1020; i++){ sugoroku[i] = 0; }

		// テ・ツ青?」ツδ榲」ツつケテ」ツ?ョテヲツδ?・ツ?アテ」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
		for (int i = 0; i < n; i++){ scanf("%d", &sugoroku[i]); }

		// テ・ツ青?」ツつオテ」ツつ、テ」ツつウテ」ツδュテ」ツ?ョテヲツδ?・ツ?アテ」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
		now = 0;
		ans = 0;
		for (int i = 0; i < m; i++){
			scanf("%d", &sai);
			if (ans == 0){
				now += sai;
				now += sugoroku[now];
				if (now >= (n - 1)){ ans = i; }
			}
		}
		printf("%d\n", ans + 1);
	}


	return 0;
}

Measured memory_bytes: 1028
import kotlin.math.sqrt


fun main (args:Array<String>){
    val box = readLine()!!.toLong()
//    var boxIList : MutableSet<Int> = mutableSetOf()
//    var boxJList : MutableSet<Int> = mutableSetOf()
    var boxList : MutableSet<Long> = mutableSetOf()
    val boxSqrt = sqrt(box.toDouble()).toLong()
    for(i in 1L..boxSqrt){
            if (box % i == 0L) {
                boxList.add((i + (box/i-2)).toLong())
           }
    }
//    if(boxList.size % 2 == 0){
//        print(boxList.elementAt(boxList.size/2) + boxList.elementAt(boxList.size/2-1) -2)
//        return
//    }
//    print(boxList.elementAt(boxList.size / 2 * 2 -2))
//    println(boxIList)
//    println(boxJList)
    println(boxList.min())
}


Measured memory_bytes: 36960
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, k;
    cin >> n >> k;
    vll h(n + 1);
    for(ll i = 1; i <= n; i++) cin >> h[i];

    vvll dp(n + 1, vll(n - k + 1, INFL));
    if(n == k) { cout << 0 << endl; return; }
    for(ll i = 1; i <= n; i++) dp[i][1] = h[i];

    for(ll i = 0; i < n; i++) {
        for(ll j = 1; j < n - k; j++) {
            for(ll l = 0; l <= i; l++) {
                chmin(dp[i + 1][j + 1], dp[l][j] + max(h[i + 1] - h[l], 0ll));
            }
        }
    }

    ll ans = INFL;
    for(ll i = 0; i <= n; i++) chmin(ans, dp[i][n - k]);
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 1024
N = int(input())
CSF = list(list(map(int,input().split()))for i in range(N-1))

ans = [0]*N
for i in range(N-1):
    time = 0
    for j in range(i,N-1):
        time = max(time,CSF[j][1]) # 開通待ち
        time += (CSF[j][1]-time)%CSF[j][2] # 待ち時間
        time += CSF[j][0] # 移動時間
    ans[i] = time
for i in ans:
    print(i)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,k,ans;
    cin >> a>>b>>c>>d>>e;
    int iti[5];
    iti[0] = a%10;
    iti[1] = b%10;
    iti[2] = c%10;
    iti[3] = d%10;
    iti[4] = e%10;
    int dif = 0;
    int mini = 100;
    int ind = 10;
    bool flag = true;
    for(int i= 0;i<5;i++){
        if(iti[i]!=0){
        dif += 10-iti[i];
        flag = false;
        }
        if(mini > iti[i] && iti[i] != 0){
            mini = iti[i];
            ind = i;
        }
    }
    int amari = 10-iti[ind];

    if(!flag){
    cout << a+b+c+d+e+ dif-amari;
    }else{
        //cerr<< "hoge";
        cout << a+b+c+d+e;
    }
    
    //cout << ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lp(i,n) for(int i=0;i<(n);i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define double long double
#define floot10 cout<<fixed<<setprecision(15)
#define Int long long
#define hogea pair<pair<int,int>,int>
#define all(v) v.begin(),v.end()
#define MAX_NODE 10000000
#define double long double
double PI = acos(-1);

struct RMQ{
  static const int MAX_N = 1 << 18;
  int n,dat[2*MAX_N-1];
  RMQ(){}
  RMQ(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++) dat[i]=0;
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return -1;
    if(a<=l&&r<=b) return dat[k];
    else{
      int vl=query(a,b,k*2+1,l,(l+r)/2);
      int vr=query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr);
    }
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

signed main(){
  floot10;
  int x,y,gx,gy;
  cin>>x>>y>>gx>>gy;
  if(y>gy){
    swap(x,gx);
    swap(y,gy);
  }
  int minix=min(x,gx);
  int maxix=max(x,gx);
  int dmaxi=min(maxix-minix,gy-y)+1;
  int base=maxix-minix+gy-y;
  base*=100;
  if(x==gx){
    int n;
    cin>>n;
    lp(i,n){
      int a,b;
      cin>>a>>b;
      if(a==x&&y<=b&&b<=gy){
        cout<<base+11.41592653589793238<<endl;
        return 0;
      }
    }
    cout<<base<<endl;
    return 0;
  }
  if(y==gy){
    int n;
    cin>>n;
    lp(i,n){
      int a,b;
      cin>>a>>b;
      if(b==y&&minix<=a&&a<=maxix){
        cout<<base+11.41592653589793238<<endl;
        return 0;
      }
    }
    cout<<base<<endl;
    return 0;
  }
  int n;
  cin>>n;
  vector<pair<int,int>> v;
  vector<pair<int,int>> za;
  lp(i,n){
    int a,b;
    cin>>a>>b;
    if(minix>a||maxix<a)continue;
    if(y>b||gy<b)continue;
    v.push_back({b,a});
    za.push_back({a,b});
  }
  sort(all(v));
  sort(all(za));
  RMQ rmq(v.size()+100);
  map<int,int> xp;
  lp(i,za.size()){
    xp[za[i].first]=i+1;
  }
  int ans=0;
  if(x<gx){
    lp(i,v.size()){
      int nowx=xp[v[i].second];
      int maxi=rmq.query(0,nowx);
      rmq.update(nowx,maxi+1);
      ans=max(maxi+1,ans);
    }
  }else{
    reverse(all(v));
    lp(i,v.size()){
      int nowx=xp[v[i].second];
      int maxi=rmq.query(0,nowx);
      rmq.update(nowx,maxi+1);
      //cout<<i<<" "<<nowx<<" "<<maxi<<endl;
      ans=max(maxi+1,ans);
    }
  }
  if(ans==0){
    cout<<base<<endl;
    return 0;
  }
  double hoge=(double)ans*((2*PI*10.0)/4.0-20);
  if(ans==dmaxi){
    hoge+=(2*PI*10.0)/4.0;
  }
  cout<<(int)(base+(double)hoge);
  hoge*=-1;
  cout<<".";
  lp(i,20){
    hoge*=10;
    int gg=hoge;
    gg%=10;
    cout<<10-gg-1;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 24924
#include <stdio.h>

void trace(int *A, int n){
	for(int i = 0; i < n; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}

	printf("\n");
}

int main(){
	int i, j, v, n, A[100];

	scanf("%d", &n);

	for(i = 0; i < n; i++)
		scanf("%d", A + i);

	trace(A, n);

	for(i = 1; i < n; i++){
		v = A[i];
		j = i - 1;

		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		trace(A, n);
	}

	return 0;
}



Measured memory_bytes: 2140
n = int(input())
sl = []
for i in range(n):
  s = int(input())
  sl.append(s)

nmul = []
for i in range(n):
  if sl[i] % 10 != 0:
    nmul.append(sl[i])

for i in range(n):
  ssl = sum(sl)
  if ssl % 10 == 0:
    if len(nmul) != 0:
      subm = ssl - min(nmul)
      print(subm)
    else:
      print(0)
    break
  else:
    print(sum(sl))
    break

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

int main() {
	int h, w; cin >> h >> w;
	vector<string> c(h);
	for (int i = 0; i < h; ++i) {
		cin >> c[i];
	}
	vector<vector<vector<int> > > cost(w-1, vector<vector<int> >(h+1, vector<int>(h+1, 0)));
	
	for (int i = 0; i < w-1; ++i) {
		for (int D = -h; D < h+1; ++D) {
			if (D < 0) {
				int d = -D;
				cost[i][h-d][h] = 0;
				for (int j = h-d-1; j >= 0; --j) {
					int plus;
					if (c[h-j-1][i] == c[h-j-d-1][i+1]) plus = 1;
					else plus = 0;
					cost[i][j][j+d] = cost[i][j+1][j+d+1] + plus;
				}
			} else {
				int d = D;
				cost[i][h][h-d] = 0;
				for (int j = h-d-1; j >= 0; --j) {
					int plus;
					if (c[h-j-1][i+1] == c[h-j-d-1][i]) plus = 1;
					else plus = 0;
					cost[i][j+d][j] = cost[i][j+d+1][j+1] + plus;
				}
			}
		}
	}

	vector<vector<vector<int> > > dp(w-1, vector<vector<int> >(h+1, vector<int>(h+1, 1000000)));
	for (int i = 0; i < w-1; ++i) {
		dp[i][0][0] = 0;
		for (int j = 0; j < h+1; ++j) {
			for (int k = 0; k < h+1; ++k) {
				if (j > 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j-1][k] + cost[i][j-1][k]);
				if (k > 0) dp[i][j][k] = min(dp[i][j][k], dp[i][j][k-1] + cost[i][j][k-1]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < w-1; ++i) ans += dp[i][h][h];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 218752
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

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

struct Point{
    int y;
    int x;
};
int calc(Point const& s,Point const& t){
    int dx=s.x-t.x;
    int dy=s.y-t.y;
    if(dx<0)dx*=-1;
    if(dy<0)dy*=-1;
    int ans=dx+dy;
    return ans;
}
signed main(){
    int h,w,d;cin>>h>>w>>d;
    vector<Point> map(h*w+1);
    rep1(i,h){
        rep1(j,w){
            int buf;cin>>buf;
            map[buf].y=i;
            map[buf].x=j;
        }
    }
    //予め距離を計算する
    vector<int> dist(h*w+1,0);
    vector<int> sum(h*w+1,0);
    int sup=h*w/d+1;
    for(int i=1;i<=d;i++){
        int buf=i;
        for(int j=0;j<sup;j++){
            if(buf+d>h*w)break;
            dist[buf+d]+=calc(map[buf],map[buf+d]);
            sum[buf+d]=sum[buf]+dist[buf+d];
            buf+=d;
        }
    }

    int q;cin>>q;
    vector<int> ans(q,0);
    rep(i,q){
        int l,r;cin>>l>>r;
        ans[i]=sum[r]-sum[l];
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    //cout<<endl;
    rep1(i,h*w){
        //cout<<i<<" "<<map[i].x<<" "<<map[i].y<<endl;
    }
    return 0;
}

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

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

    int x, y;
    cin >> x >> y;
    int step = 0;

    for(int i = 1; i < n; i++){
        int dx, dy;
        cin >> dx >> dy;

        int tmp = (x-dx)*(y-dy);
        if(tmp > 0){
            step += max(abs(x-dx), abs(y-dy));
        }else if(tmp == 0){
            step += max(abs(x-dx), abs(y-dy));
        }else if(tmp < 0){
            step += abs(x-dx) + abs(y-dy);
        }

        x = dx;
        y = dy;
    }

    cout << step << endl;

    return 0;
}


Measured memory_bytes: 3108