akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int t[3]={3,5,7};
vvi tmp;
vi ans;

void solve(int n,vi s){
  if(n==9){
    return;
  }
  rep(i,3){
    s.push_back(t[i]);
    tmp.push_back(s);
    solve(n+1,s);
    s.pop_back();
  }
}

int main(){
  int n,cnt=0;
  cin>>n;
  solve(0,{});
  ans.resize(tmp.size(),0);
  rep(i,tmp.size()){
    rep(j,tmp[i].size()){
      ans[i]+=tmp[i][j]*pow(10,tmp[i].size()-j-1);
    }
  }
  rep(i,tmp.size()){
    bool f1=false,f2=false,f3=false;
    if(ans[i]>n){
        continue;
    }
    rep(j,tmp[i].size()){
      if(tmp[i][j]==3) f1=true;
      if(tmp[i][j]==5) f2=true;
      if(tmp[i][j]==7) f3=true;
    }
    if(f1&&f2&&f3){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


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

int main() {
  int l = 0, r = 0, c = 0;
  string out;

  for (int i = 0; i < 4; i++){
    cin >> c;
    if (i < 2) {
      l += c;
    } else {
      r += c;
    }
  }
  if (l > r) {
    out = "Left";
  } else if (l < r) {
    out = "Right";
  } else {
    out = "Balanced";
  }
  cout << out << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int m = sc.nextInt();
    int[][] rows = new int[h][2];
    int[][] cols = new int[w][2];
    for (int i = 0; i < h; i++) rows[i][0] = i;
    for (int i = 0; i < w; i++) cols[i][0] = i;
    Set<Integer> bombs = new HashSet<>();
    for (int i = 0; i < m; i++) {
      int hi = sc.nextInt() - 1;
      int wi = sc.nextInt() - 1;
      bombs.add(hi * w + wi);
      rows[hi][1]++;
      cols[wi][1]++;
    }
    Arrays.sort(rows, (int[] a, int[] b) -> b[1] - a[1]);
    Arrays.sort(cols, (int[] a, int[] b) -> b[1] - a[1]);
    int maxRows = rows[0][1];
    int maxCols = cols[0][1];
    int result = 0;
    for (int i = 0; i < h && rows[i][1] == maxRows; i++) {
      for (int j = 0; j < w && cols[j][1] == maxCols; j++) {
        if (bombs.contains(rows[i][0] * w + cols[j][0])) {
          result = Math.max(result, maxRows + maxCols - 1);
          continue;
        }
        result = maxRows + maxCols;
        break;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 103724
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

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

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

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

vector<int> enum_div(int n){
  vector<int> ret;
  for(int i = 1 ; i*i <= n ; ++i){
    if(n%i == 0){
      ret.push_back(i);
      if(i != 1 && i*i != n){
        ret.push_back(n/i);
      }
    }
  }
  return ret;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;
  cin>>n;
  int c=0;
  for(int i=1;i<=n;++i){
    vector<int> l;
    l=enum_div(i);
    if(i%2==1&&l.size()==7) {
      c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int count = 0;
	vector<int> l;
	
	cin>>N;
	
	l.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>l[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			for(int k = j + 1; k < N; k++){
				if(l[i] == l[j]) continue;
				if(l[i] == l[k]) continue;
				if(l[k] == l[j]) continue;
				
				if(
				l[i] < l[j] + l[k] &&
				l[j] < l[i] + l[k] &&
				l[k] < l[j] + l[i]
				) count++;
			}
		}
	}
	
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


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

    private void run() throws IOException {
        boolean b = true;
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (b) {
            b = runOnce(reader);
        }

        reader.close();
    }

    private boolean runOnce(BufferedReader reader) throws IOException {
        final String[] params = reader.readLine().split(" ");
        int count = Integer.parseInt(params[0]);
        int length = Integer.parseInt(params[1]);
        if (count == 0 && length == 0) return false;
        final List<Ant> list = new ArrayList<Ant>(count);
        for (int i = 0; i < count; i++) {
            final Ant a = new Ant(reader.readLine().split(" "), i + 1);

            list.add(a);
        }
        exec(list, length);
        return true;
    }

    private void exec(List<Ant> ants, int length) {
        List<Ant> deleted = new ArrayList<Ant>();
        int count;
        for (count = 0; !ants.isEmpty(); count++) {
            deleted = update(ants, length);
        }

        int index = (deleted.size() == 2) ? (deleted.get(0).left ? deleted.get(0).index : deleted.get(1).index) : deleted.get(0).index;
        System.out.println(count + " " + index);
    }

    private List<Ant> update(List<Ant> ants, int length) {
        final Map<Integer, Ant> map = new HashMap<Integer, Ant>();
        final ArrayList<Ant> outList = new ArrayList<Ant>();
        final int size = ants.size();
        for (int i = 0; i < size; i++) {
            final Ant ant = ants.get(i);
            ant.position = ant.left ? ant.position - 1 : ant.position + 1;
            if(map.containsKey(ant.position)) {
                final Ant ant1 = map.get(ant.position);
                ant1.left = !ant1.left;
                ant.left = !ant.left;
            }
            map.put(ant.position, ant);
            if(ant.position == 0 || ant.position == length) {
                outList.add(ant);
            }
        }
        for (final Ant ant : outList) {
            ants.remove(ant);
        }
        return outList;
    }

    class Ant {
        int position;
        int index;
        boolean left;

        Ant(final String[] params, int index) {
            this.position = Integer.parseInt(params[1]);
            this.left = params[0].equals("L");
            this.index = index;
        }
    }
}

Measured memory_bytes: 28788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        for(int i = 0; i < N; i++) d[i] = sc.nextInt();

        //餅を昇順に並び替える
        Arrays.sort(d);
      
        //隣同士が異なればカウント（最低1個ある）
        int count = 1;
        for(int i = 0; i < N - 1; i++){
            if(d[i] != d[i+1]) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23636
# 日付を入力
d = int(input())

# 入力日付を基にクリスマスか等を判定
if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
elif d == 22:
    print("Christmas Eve Eve Eve")

Measured memory_bytes: 2940
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val sx = sc.nextInt()
    val sy = sc.nextInt()
    val tx = sc.nextInt()
    val ty = sc.nextInt()
    val start = Pair(1, 1)
    val target = Pair(tx - sx + start.first, ty - sy + start.second)

    val visited = Array(tx - sx + 3) { Array(ty - sy + 3) { false } }
    var now = start
    val dic = mutableMapOf<Char, Pair<Int, Int>>()
    var ans = ""

    dic['U'] = Pair(0, 1)
    dic['D'] = Pair(0, -1)
    dic['L'] = Pair(-1, 0)
    dic['R'] = Pair(1, 0)

    for (turn in 1..4) {
        var goal: Pair<Int, Int>
        if (turn % 2 == 1) {
            goal = target
        } else {
            goal = start
        }
        while (now != goal) {
            val cnddt = mutableListOf<Long>()
            for (k in "UDLR") {
                val nxt = Pair(now.first + dic[k]!!.first, now.second + dic[k]!!.second)
                if (nxt.first < 0 || target.first + 1 < nxt.first) {
                } else if (nxt.second < 0 || target.second + 1 < nxt.second) {
                } else if (nxt == goal || !visited[nxt.first][nxt.second]) {
                    cnddt.add((diff(nxt, goal) - diff(now, goal)) * 1000L + k.toByte())
                }
            }
            cnddt.sort()
            val k = ((cnddt[0] + 1000) % 1000).toChar()
            ans += k
            val nxt = Pair(now.first + dic[k]!!.first, now.second + dic[k]!!.second)
            visited[nxt.first][nxt.second] = true
            now = nxt
        }
    }
    println(ans)
}

fun diff(a: Pair<Int, Int>, b: Pair<Int, Int>): Int {
    return Math.abs(a.first - b.first) + Math.abs(a.second - b.second)
}


Measured memory_bytes: 141272
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d) cout << "Yes" << endl;
	else if (abs(b - a) <= d && abs(c - b) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
program main
  implicit none

  integer(16) :: a, b, c, k, ans, max
  integer :: i

  read(*,*) a, b, c, k

  if(mod(k,2) == 0) then
     ans = a - b
  else
     ans = b - a
  end if
  
  max = 1
  do i = 1, 18
     max = max * 10
  end do
    
  if (abs(a-b) > max) then
     write(*,*) 'Unfair'
  else   
     write(*,*) ans
  end if


  
end program main


  


Measured memory_bytes: 384
#include <stdio.h>
long long n,i,j,x;
int ans=0;

int main(void){
    scanf("%lld",&n);

    for(i = 2; i * i <= n; i++){
        
        //printf("%lld ", i);
        for(x = 0; n % i == 0; x++) { // 素数がいくつあるか確認
            n /= i; 
        }
        //printf("%lld ", x);

        for(j=0; j * (j + 1) / 2 <= x; j++); // 1,2,3,....の組を見つける 
        
        //printf("%lld\n", j - 1);
        ans += j - 1;
    }

    if (n - 1) ans += 1;

    printf("%d",ans);

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  string S;cin>>S;
  reverse(ALL(S));
  while(S.size()>0){
    if(S.size()>4){
      if(S.substr(0,5)=="maerd"||S.substr(0,5)=="esare")S=S.substr(5,S.size()-5);
      else if(S.size()>5){
        if(S.substr(0,6)=="resare")S=S.substr(6,S.size()-6);
        else if(S.size()>6&&S.substr(0,7)=="remaerd")S=S.substr(7,S.size()-7);
        else break;
      }
      else break;
    }
    else break;
  }
  if(S.size()>0)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll flag=0;
	for(ll i=0;i<n-k;i++)
	{
		if(a[i]>=a[i+k])
		flag=1;
		if(flag)
		cout<<"No"<<endl;
		else
		cout<<"Yes"<<endl;
		flag=0;
	
	}
	
	
	
	
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 5100
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

const mod = int(1e9) + 7

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	broken := make(map[int]bool, 0)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < M; i++ {
		broken[nextInt(sc)] = true
	}
	dp := make([]int, N+1)
	dp[0] = 1
	if !broken[1] {
		dp[1] = 1
	}
	for i := 2; i <= N; i++ {
		if !broken[i] {
			dp[i] = dp[i-1] + dp[i-2]
		}
		dp[i] %= mod
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn=1000007;
const int mod=1000007;

int a[1100];
int main()
{
    int n;
    cin>>n;
    int sum=0,ans=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int sol=sum;
    for(int i=0;i<n;i++)
    {
        ans=ans+a[i];
        sum=sum-a[i];
        sol=min(sol,abs(ans-sum));
    }
    cout<<sol;
    return 0;
}
/*

*/


Measured memory_bytes: 256
N,K= list(map(int,input().split(" ")))
nums = []
for i in range(N):
    nums.append(int(input()))
nums.sort()
r = 0
l = 0
ans = []
for i,num in enumerate(nums[:-(K-1)]):
    r = nums[i+K-1]
    l = num
    # print("l:",l,"//r:",r)
    ans.append(r-l)
print(min(ans))

Measured memory_bytes: 12056
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
int N;
ll f[1010100][2];
int Num[1100000],val[1010000],A[1010000];

int main(){
	cin>>N;
	for(rint i=1;i<=N;++i) cin>>A[i],val[i]=i;
	for(rint i=0;i<=N;++i) f[i][0]=f[i][1]=-1e18;
	f[0][0]=0;
	for(rint i=0;i<N;++i) {
		if(A[i+1]>=2) {
			f[i+1][1]=max(f[i+1][1],f[i][1]+1+(A[i+1]-2)/2);
		}
		if(A[i+1]>=1) {
			f[i+1][0]=max(f[i+1][0],f[i][1]+(A[i+1]-1)/2);
			f[i+1][1]=max(f[i+1][1],f[i][0]+1+(A[i+1]-1)/2);
		}
		f[i+1][0]=max(f[i+1][0],f[i][0]+A[i+1]/2);
	}
	cout<<f[N][0];
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

bool dp[82][82][128002];

void solve_abc_e() {
	ll h, w;
	ll ans = 0;

	cin >> h >> w;

	ll a[82][82], b[82][82], c[82][82];

	rep(i, 82)rep(j, 82) {
		a[i][j] = b[i][j] = c[i][j] = 0;
	}

	rep(i, h)rep(j, w) {
		cin >> a[i][j];
	}
	rep(i, h)rep(j, w) {
		cin >> b[i][j];
	}

	rep(i, h)rep(j, w) {
		c[i][j] = abs(a[i][j] - b[i][j]);

	}


	dp[0][0][c[0][0]] = true;
	rep(i, h)rep(j, w) {
		rep(p, 128001) {
			if (dp[i][j][p]) {
				dp[i + 1][j][abs(p + c[i + 1][j])] = true;
				dp[i + 1][j][abs(p - c[i + 1][j])] = true;
				dp[i][j + 1][abs(p + c[i][j + 1])] = true;
				dp[i][j + 1][abs(p - c[i][j + 1])] = true;
			}
		}
	}

	rep(p, 128001) {
		if (dp[h - 1][w - 1][p]) {
			cout << p << "\n";
			return;
		}
	}
}

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

	solve_abc_e();

	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	vi v;
	FOR(i, 1, 1000001) {
		v.push_back(i*(i + 1)*(i + 2) / 6);
		if (v[i - 1] >= 1000001)break;
	}
	int m = v.size();
	vi dp(1000001, INF);
	dp[0] = 0;
	REP(i, m) {
		REP(j, 1000000+ 1) {
			if (j >= v[i]) dp[j] = min(dp[j], dp[j - v[i]] + 1);
		}
	}
	vi dp2(1000001, INF);

	dp2[0] = 0;
	REP(i, m) {
		if (v[i] % 2 == 0) continue;

		REP(j, 1000000 + 1) {
			if (j >= v[i])dp2[j] = min(dp2[j], dp2[j - v[i]] + 1);
		}

	}
	int n;
	while (cin >> n, n) {
		cout << dp[n]<<" "<<dp2[n] << endl;
	}
}

Measured memory_bytes: 10588
#include <stdio.h>
int main(void){
    int a1, a2, a3, t;
    scanf("%d %d %d", &a1,&a2,&a3);
    if(a1 < a2){
        t = a1;
        a1 = a2;
        a2 = t;
    }
    if(a2 < a3){
        t = a2;
        a2 = a3;
        a3 = t;
    }
    if(a1 < a2){
        t = a1;
        a1 = a2;
        a2 = t;
    }
    printf("%d\n", (a1-a2)+(a2-a3));
    return 0;
}

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

int main()
{
	int a, b;
	string s, t, u;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		a = a - 1;
	}
	else {
		b = b - 1;
	}
	cout << a << " " <<b << endl;
}

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

void solve() {
	int n; cin >> n;
	vector<long long> a(n);
	rep(i, n) scanf("%lld", &a[i]);

	vector<long long> s(n + 1, 0);
	map<long long, long long> nums;
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
	for (int i = 0; i <= n; i++) nums[s[i]]++;

	long long res = 0;
	for (auto it : nums) {
		long long num = it.second;
		res += num * (num - 1) / 2;
	}

	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

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

    int R = 0;
    int G = 0;
    int B = 0;
    for(int i=0;i<N;i++){
        if(S.at(i)=='R')R++;
        if(S.at(i)=='G')G++;
        if(S.at(i)=='B')B++;
    }
    int ans = R*G*B;

    int index = 0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            int k = i+(j-i)*2; 
            if(k>=N)break;
            if(S.at(i)!=S.at(j)&&S.at(i)!=S.at(k)&&S.at(j)!=S.at(k))index++;
        }
    }
    cout<<ans-index<<endl;



    return 0;
}

Measured memory_bytes: 3616
require 'matrix'

def len3d(x, y)
  l2=0.0
  0.upto(3-1){|i|
    l2 += (x[i] - y[i])**2
  }
  return Math.sqrt(l2)
end

def heron(a,b,c)
  s = (a + b + c) / 2.0
  return  Math.sqrt(s*(s-a).abs*(s-b).abs*(s-c).abs)
end

Eps=1e-9
def solve(a,b,c,d,e)   # returns true if beam hits barrier.
  # a, b, c: Position vector of the barrier's apex triangle
  # d:Position vector of UAZ
  # e:Position vector of the enemy
  # Solve a + s*u + t*v = d + x*w. (0<x<1) if point P(d+xw)is in triangle ABC, the barrier repels the beam
  # returns true if repelled, else false
  u = c - a
  v = b - a
  w = e - d
  m = Matrix.columns([u, v, -w])

#  abort("Impssible case") if m.determinant.abs <Eps
  return false if m.determinant.abs <Eps
  parms = m.lup.solve(d - a)

  s = parms[0]
  t = parms[1]
  x = parms[2]
# point P is the intersect of a plane which includes triangle ABC and a line betweenn D and E.
  return false if x < 0 or x > 1.0
  p = d + x*w
# If the sum of the area of triangle PAC, PAB, PBC equals the are of the triangle ABC, the point P is inside triangle ABC.
  pa = len3d(a, p)
  pb = len3d(b, p)
  pc = len3d(c, p)

  ab = len3d(b, a)
  ac = len3d(c, a)
  bc = len3d(c, b)

  s0=heron(ab,ac,bc)
  s1=heron(pa,pc,ac)
  s2=heron(pa,pb,ab)
  s3=heron(pb,pc,bc)

  return  (s1+s2+s3-s0).abs <Eps
end

def main
  if true then
#  if false then
    fh=STDIN
  else
    #fh=open("in1_0115a.txt")
    #fh=open("in1_0115b.txt")
    fh=open("in1_0115c.txt")
  end
  d1,d2,d3=fh.gets.chomp.split.map{|x| x.to_i}
  e1,e2,e3=fh.gets.chomp.split.map{|x| x.to_i}
  a1,a2,a3=fh.gets.chomp.split.map{|x| x.to_i}
  b1,b2,b3=fh.gets.chomp.split.map{|x| x.to_i}
  c1,c2,c3=fh.gets.chomp.split.map{|x| x.to_i}

  d=Vector[d1,d2,d3]
  e=Vector[e1,e2,e3]
  a=Vector[a1,a2,a3]
  b=Vector[b1,b2,b3]
  c=Vector[c1,c2,c3]

  if solve(a,b,c,d,e) then
    puts "MISS"
  else
    puts "HIT"
  end

end

if $0 == __FILE__ then
  main
end

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s; cin >> s;
    int n = s.length();
    for(int i = 0; i < n; i++) if(s[i] == '?') s[i] = 'D';
    cout << s << endl;
    return 0;
    // int ans = 0;
    // for(int i = 0; i < n; i++) ans += s[i] == 'D';
    // for(int i = 0; i + 1 < n; i++) ans += (s[i] == 'P' && s[i + 1] == 'D');
    // cout << ans << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	string b("");
	int i;
	cin>>a;
	for(i=0;i<a.size();i++){
		if(a[i]=='B'){
			if(b!=""){
			    b.erase(b.size()-1);
			}	
		}else{
			b=b+a[i];
		}
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back


#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64_t
#endif

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int go(int x) {
	return (x * (x + 1)) / 2;
}

 main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), A = readInt(), B = readInt(), C = readInt(), D = readInt();
    ///A + 2 * A + 3 * A + 4 * A .... = A (1 + 2 + 3 ...)
    for (int i = 0; i < n; i++) {
    	if (C * (n - 1 - i) - D * i <= B - A && B - A <= - C * i + (n - 1 - i) * D) {
    	  	cout << "YES";
    	  	return 0;
    	} 
    } 
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static string S;
//    static int[] A;
    static int[] B;
//    static int[] C;
    static void INPUT()
    {
        S = NextString();
        //A = LineInt();
        //B = LineInt();
        //C = LineInt();
    }
    static void OUTPUT()
    {
        if(S == "Sunny")
            Console.WriteLine("Cloudy");
        if (S == "Cloudy")
            Console.WriteLine("Rainy");
        if (S == "Rainy")
            Console.WriteLine("Sunny");
    }

    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 11220
trade1 = {}
while True:
    try:
        c, d = map(int, input().split(","))
        if c in trade1.keys():
            trade1[c] += 1
        else:
            trade1[c] = 1
    except:
        break

trade2 = {}
while True:
    try:
        c, d = map(int, input().split(","))
        if c in trade2.keys():
            trade2[c] += 1
        else:
            trade2[c] = 1
    except:
        break

trade_tmp = {}
for c in trade1.keys():
    if c in trade2.keys():
        trade_tmp[c] = trade1[c] + trade2[c]
trade_all = sorted(trade_tmp.items(), key=lambda x: x[0])
for c in trade_all:
    print(c[0], c[1])



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

long long n;
vector<vector<unsigned long long>> res;
vector<long long> s, t;
vector<unsigned long long> u, v;

bool solve();

int main() {
  cin >> n;
  s.resize(n);
  t.resize(n);
  u.resize(n);
  v.resize(n);
  res.assign(n, vector<unsigned long long>(n, 0));
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i < n; ++i) cin >> t[i];
  for (int i = 0; i < n; ++i) cin >> u[i];
  for (int i = 0; i < n; ++i) cin >> v[i];
  if (solve()) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (j != 0) cout << " ";
        cout << res[i][j];
      }
      cout << endl;
    }
  } else
    cout << -1 << endl;
  return 0;
}

bool solve() {
  for (long long B = 0; B < 64; ++B) {
    vector<vector<long long>> tmp(n, vector<long long>(n, -1));
    vector<long long> r(n, 0), c(n, 0);
    for (int i = 0; i < n; ++i)
      if (s[i] != (u[i] >> B & 1)) {
        r[i] = 1;
        for (int j = 0; j < n; ++j) tmp[i][j] = (u[i] >> B & 1);
      }
    for (int j = 0; j < n; ++j)
      if (t[j] != (v[j] >> B & 1)) {
        c[j] = 1;
        for (int i = 0; i < n; ++i) {
          if (tmp[i][j] == 1 - (long long)(v[j] >> B & 1)) return 0;
          tmp[i][j] = (v[j] >> B & 1);
        }
      }
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) {
        if (s[i] == tmp[i][j]) r[i] = 1;
        if (t[j] == tmp[i][j]) c[j] = 1;
      }
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (r[i] + c[j] == 0 && s[i] == t[j] && tmp[i][j] < 0) {
          r[i] = c[j] = 1;
          tmp[i][j] = s[i];
        }

    while (1) {
      bool ch = 0;
      while (1) {
        ch = 0;
        for (int i = 0; i < n; ++i)
          for (int j = 0; j < n; ++j) {
            if (r[i] ^ c[j] && tmp[i][j] < 0) {
              if (!r[i]) {
                tmp[i][j] = s[i];
                r[i] = 1;
                ch = 1;
              } else {
                tmp[i][j] = t[j];
                c[j] = 1;
                ch = 1;
              }
            }
          }
        if (!ch) break;
      }
      ch = 0;
      for (int i = 0; i < n && !ch; ++i)
        for (int j = 0; j < n && !ch; ++j)
          if (tmp[i][j] < 0 && (r[i] + c[j] != 2)) {
            ch = 1;
            tmp[i][j] = s[i];
            r[i] = 1;
          }
      if (!ch) break;
    }
    for (int i = 0; i < n; ++i)
      if (r[i] + c[i] != 2) return 0;

    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (tmp[i][j] == 1) res[i][j] += 1ULL << B;
  }
  return 1;
}

Measured memory_bytes: 7436
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n, m = gets.chomp.split.map(&:to_i)

    nums = Array.new(n, 0)
    m.times do
      a, b = gets.chomp.split.map(&:to_i)
      nums[a-1] += 1
      nums[b-1] += 1
    end

    nums.each_with_index do |nn, i|
      puts nn
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    xss <- replicateM n $ fmap read . words <$> getLine :: IO [[Int]]
    let f [l, r] = r - l + 1
    print $ sum $ fmap f xss

Measured memory_bytes: 1660
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b;
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut a:usize = 0;
    if 1 <= n/100 && n/100 <=12 {
        a+=1;
    }
    if 1 <= n-(n/100)*100 && n-(n/100)*100 <= 12 {
        a+=2;
    }
    if a==0 {
        println!("NA");
    }
    else if a==1 {
        println!("MMYY");
    }
    else if a==2 {
        println!("YYMM");
    }
    else if a==3 {
        println!("AMBIGUOUS");
    }
}


Measured memory_bytes: 2052
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];

    ll ans = 1;

    if (D[0] != 0) {
        ans = 0;
    }

    sort(all(D));
    if (D[1] == 0) {
        ans = 0;
    }

    int prec = 1;
    for (int i = 1, j; i < N; i = j) {
        for (j = i + 1; j < N; ++j) {
            if (D[j] != D[i]) break;
        }

        if (D[i] != D[i - 1] + 1) {
            ans = 0;
        }

        ans = ans * mpow(prec, j - i) % MOD;

        prec = j - i;
    }

    write(ans);
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	char input[101];
	string str;
	int n;

	scanf("%s", input);
	str = input;
	n = str.size();

	for (int i = 0; i < n / 2; i++)
	{
		if (str[i] != str[n - i - 1])
		{
			printf("No\n");

			return 0;
		}
	}

	for (int i = 0; i < n / 2; i++)
	{
		if (str[i] != str[n / 2 - i - 1])
		{
			printf("No\n");

			return 0;
		}
	}

	/*
	for (int i = n / 2 + 1; i < n; i++)
	{
		if (str[i] != str[n - i - 1])
		{
			printf("No\n");

			return 0;
		}
	}
	*/

	printf("Yes\n");

	return 0;
}

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

static const long long inf (1e18);

int main(){
    long long N;
    cin >> N;
    priority_queue<long long, vector<long long>, greater<int> > que1;
    priority_queue<long long> que2;

    long long A[3*N+1];

    for(long long i=1;i<=N*3;i++){
        cin >> A[i];
    }

    long long sum1[2*N+1];
    sum1[0]=0;

    for(long long i=1;i<=N;i++){
        sum1[i]=sum1[i-1]+A[i];
        que1.push(A[i]);
    }

    for(long long i=N+1;i<=2*N;i++){
        sum1[i]=sum1[i-1]+A[i];
        que1.push(A[i]);
        sum1[i]-=que1.top();
        que1.pop();
    }

    reverse(A+1,A+N*3+1);

    long long sum2[2*N+1];
    sum2[0]=0;

    for(long long i=1;i<=N;i++){
        sum2[i]=sum2[i-1]+A[i];
        que2.push(A[i]);
    }

    for(long long i=N+1;i<=2*N;i++){
        sum2[i]=sum2[i-1]+A[i];
        que2.push(A[i]);
        sum2[i]-=que2.top();
        que2.pop();
    }

    long long ans=-inf;

    for(long long i=N;i<=2*N;i++){
        ans=max(ans,sum1[i]-sum2[N*3-i]);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 7412
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(new Main().solve());
    }
    
    // パラメタ渡しもちゃんとクラス作るのも面倒なので手抜き
    // 必要な値はここで全部取ってしまう
    Scanner sc = new Scanner(System.in);
    // int n = Integer.parseInt(sc.next());
    // {sc.nextLine();}
    int[] a = IntStream.range(0, 5).map(i -> Integer.parseInt(sc.next())).toArray();
    // int k =  Integer.parseInt(sc.next());
    String solve() {
        IntStream.of(a).sorted();
        // 端数が一番小さいのを除外
        // それ以外は切り上げの和を取る
        int min = 10;
        int sum = 0;
        for(int i = 0; i < 5; i++) {
            // 末尾
            int ii = a[i] % 10;
            if(0 < ii && ii < min) {
                min = ii;
            }
            if(ii == 0) {
                sum += a[i];
            } else {
                sum += (a[i] / 10) * 10 + 10;
            }
            
        }
        // if(min == 10) {
        //     min = 0;
        // }
        return ""+(sum - (10 - min));
    }
    
}
// public class Main {
//     public static void main(String[] args) throws Exception {
//         Scanner sc = new Scanner(System.in);
//         int a = sc.nextInt();
//         int b = sc.nextInt();
//         int c = sc.nextInt();
//         int d = sc.nextInt();
//         int e = sc.nextInt();
        
//         IntStream.of(a, b, c, d, e).
//         int k = sc.nextInt();
//         System.out.println();
//     }
    
//     // // パラメタ渡しもちゃんとクラス作るのも面倒なので手抜き
//     // // 必要な値はここで全部取ってしまう
//     // Scanner sc = new Scanner(System.in);
//     // int n = Integer.parseInt(sc.next());
//     // {sc.nextLine();}
//     // int[] a = IntStream.range(0, n).map(i -> Integer.parseInt(sc.next())).toArray();
    
//     // String solve() {
//     //     return n + "" + Arrays.toString(a);
//     // }
    
// }


Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y;
    while (1)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        if (x > y)
            swap(x, y);
        cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<queue>
#define INF 2e9
using namespace std;

void Dikstra(const vector<vector<pair<int, int> > >& G, vector<int>& d){
    d[0] = 0;
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > PQ;
    PQ.push(make_pair(0, 0));
    vector<bool> is_black(d.size(), false);
    is_black[0] = true;
    while (!PQ.empty()) {
        int t = PQ.top().second;
        PQ.pop();
        is_black[t] = true;
        for (int i = 0; i < G[t].size(); i++) {
            int v = G[t][i].first;
            int w = G[t][i].second;
            if (!is_black[v] && d[t] + w < d[v]) {
                d[v] = d[t] + w;
                PQ.push(make_pair(d[v], v));
            }
        }
    }

}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > G(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u].push_back(make_pair(v, c));
        }
    }
    vector<int> d(n, INF);
    Dikstra(G, d);
    for (int i = 0; i < n; i++) {
       cout << i << " " << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// 素数かどうかの判定
bool IsPrime(ll num){
    if(num<2) return false;
    else if(num==2) return true;
    else if(num%2==0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for(ll i=3; i<=sqrtNum; i+=2){
        if(num%i==0) return false;
    }
    return true;
}


signed main() {
	ll n,m,k; cin>>n>>m>>k;
	VL a(n+1,0LL),b(m+1,0LL);
	rep(i,n){
		ll u; cin>>u;
		a[i+1]=a[i]+u;
	}
	rep(i,m){
		ll u; cin>>u;
		b[i+1]=b[i]+u;
	}
	cerr<<"INPUT DONE"<<endl;
	ll ans=0LL;
	int j=m;
	rep(i,n+1){
		if(a[i]>k) break;
		while(a[i]+b[j]>k) j--;
		chmax(ans,i+j);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
//#define EPS 0.000000001
using namespace std;


#define EPS 0.000001


typedef vector<double> V;
typedef vector<V> MATRIX;

int d;
double ans_array[8],POW[8][6];


MATRIX gauss_jordan(MATRIX A){

	MATRIX ret(1,V(d+1));
	for(int col = 0; col < d+1; col++){
		ret[0][col] = (double)BIG_NUM;
	}

	int base_row;

	MATRIX B(d+2,V(d+2));
	for(int row = 0; row < d+2; row++){
		for(int col = 0; col < d+2; col++){
			B[row][col] = A[row][col];
		}
	}

	for(int i = 0; i < d+1; i++){

		base_row = i;

		for(int row = i+1; row < d+1; row++){
			if(fabs(B[row][i]) > fabs(B[base_row][i])){
				base_row = row;
			}
		}

		if(i != base_row){
			swap(B[i],B[base_row]);
		}

		if(fabs(B[i][i]) < EPS)return ret;

		for(int col = i+1; col < d+2; col++){
			B[i][col] /= B[i][i];
		}

		for(int row = 0; row < d+1; row++){
			if(row == i)continue;

			for(int col = i+1; col < d+2; col++){
				B[row][col] -= B[row][i]*B[i][col];
			}
		}
	}

	double check = 0;
	for(int i = 0;i < d+1;i++){
		check += A[d+1][i]*B[i][d+1];
	}
	if(fabs(check-A[d+1][d+1]) > 0.1)return ret;

	for(int row = 0; row < d+1; row++){
		ret[0][row] = B[row][d+1];
	}
	return ret;
}


void func(){

	for(int i = 0; i <= d+2; i++){
		scanf("%lf",&ans_array[i]);
	}

	int index,wrong_num,ans;
	double tmp;

	MATRIX ret(1,V(d+1));
	MATRIX A(d+2,V(d+2));

	for(int i = 0; i <= d+2; i++){
		index = 0;
		for(int k = 0; k <= d+2; k++){
			if(k == i)continue;

			for(int col = 0; col < d+1; col++){
				A[index][col] = POW[k][col];
			}

			A[index][d+1] = ans_array[k];
			index++;
		}

		ret = gauss_jordan(A);

		wrong_num = 0;
		for(int k = 0; k <= d+2; k++){
			tmp = 0;
			for(int a = 0; a <= d; a++){
				tmp += ret[0][a]*POW[k][a];
			}

			if(fabs(tmp-ans_array[k]) > 0.1){
				wrong_num++;
				ans = k;
			}
		}
		if(wrong_num == 1){
			printf("%d\n",ans);
			return;
		}
	}
}

void makePOW(){

	for(int i = 0; i < 8; i++){
		for(int k = 0; k <= 5; k++){
			POW[i][k] = pow(i,k);
		}
	}
}

int main(){

	makePOW();

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

		func();
	}

	return 0;
}



Measured memory_bytes: 3324
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;

    // 約数を得る
    ll ans = 10000000000000;
    ll a = -1, b = -1;
    ll loop = ll(sqrt(double(N)) + 1);
    //rep(i, loop)
    for(ll i=1;i*i<=N;++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            chmin(ans, i + j - 2);
        }
    }
    //
    cout << ans;

    return 0;
}

Measured memory_bytes: 3156