akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace  std;

const double cos60 = cos(M_PI / 3);
const double sin60 = sin(M_PI / 3);

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }

  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }
};

void fnInput(int& rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv(const StPnt& cnroPnt1, const StPnt& cnroPnt2, vector<StPnt>& rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos60 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin60 + rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin60 
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos60 + rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>>& rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>>& cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r=0, b=0;
    for(int i=0;i<n;++i){
        if(s[i] == 'R')r++;
        else b++;
    }

    cout << (r > b ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;

ll n,x=0,a,k;
int main() {
	isc;
	cin >> n >> k;
	ww(n--){
		cin >> a;
		if(a>=k)
			x++;
	}
	cout << x;
	return 0;
}



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

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n, y;
  cin >> n >> y;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n; j++) {
      if(i+j<=n) {
        int k = n-i-j;
        int s = 10000 * i + 5000 * j + 1000 * k;
        if (s == y) {
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  rep(i, n) {
    int a = A[i];
    if (a % 2 == 1) continue;
    if (a % 3 != 0 && a % 5 != 0) {
      cout << "DENIED" << endl;
      return;
    }
  }
  cout << "APPROVED" << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

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

		long[][] dig=new long[N-1][3];
		int C=0;
		int S=0;
		int F=0;
		long unko=0;
		for(int i=0; i<N-1; i++) {
			for(int j=0; j<3; j++) {
				dig[i][j]=sc.nextLong();
			}
		}
		for(int i=0; i<N-1; i++) {
			unko=0;
			for(int j=i; j<N-1; j++) {
				if(j==i) {
					unko+=dig[j][1];		//S足す
				}
				if(unko<dig[j][1]) {
					unko=dig[j][1];
				}
				unko=(unko+dig[j][2]-1)/dig[j][2]*dig[j][2];
				unko+=dig[j][0];
			}
			System.out.println(unko);
		}
		System.out.println("0");
	}
}

Measured memory_bytes: 27464
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toLong)

  val sorted = as.sorted.reverse
  val result = (0 until n)
                .map(_*2)
                .map(_+1)
                .map(sorted(_))
                .sum

  println(result)
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1), B(N);
  for (int i = 0; i < N+1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= B[i]) ans += B[i];
    else {
      ans += A[i];
      B[i] -= A[i];
      if (A[i+1] >= B[i]) {
        A[i+1] -= B[i];
        ans += B[i];
      }
      else {
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  int n; cin >> n;
  map<string, int> mp;
  ll ans = 0;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(mp[s]>0) ans+=mp[s];
    mp[s]++;
  }

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


Measured memory_bytes: 11368
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = input()[:-1]

  E = [0]
  for a in A:
    if a == 'E':
      E.append(E[-1]+1)
    else:
      E.append(E[-1])

  min_ = float('inf')
  for i in range(N):
    min_ = min(min_, (i-E[i])+(E[N]-E[i+1]))
  print(min_)


if(__name__ == '__main__'):
  main()

Measured memory_bytes: 21312
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
    int N;
    cin >> N;
 
    int l = (int)(N/1.08) - 5;
    int r = l + 10;
    bool check = false;
 
    for(int i=l; i<r; i++){
        if((int)(i*1.08) == N){
            cout << i << endl;
            check = true;
            break;
        }
    }
    if(check != true)
        printf(":(\n");
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
const int maxN = 610;

double p[maxN], exx[maxN];
vector<int> e[maxN], re[maxN];
int n, m;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        e[u].push_back(v);
        re[v].push_back(u);
    }
    p[1] = 1.0;
    for (int i = 1; i < n; i++)
    {
        double tmp = 1.0 / (double) e[i].size();
        for (auto to : e[i])
            p[to] += tmp * p[i];
    }
    if (false)
    for (int i = 1; i <= n; i++)
        printf("%d %f\n", i, p[i]);
    for (int i = n; i > 1; i--)
    {
        for (auto from : re[i])
            exx[from] += (exx[i] + 1.0) / (double)e[from].size();
    }
    if (false)
    for (int i = 1; i <= n; i++)
        printf("%d %f\n", i, exx[i]);
    double ans = 0;
    for (int i = 1; i < n; i++)
    {
        if ((int)e[i].size() <= 1) continue;
        double sume = 0, maxe = 0;
        for (auto to : e[i])
        {
            sume += exx[to];
            maxe = max(maxe, exx[to]);
        }
        ans = max(ans, p[i] * (exx[i] - (sume-maxe+e[i].size()-1) / (1.0*e[i].size() - 1.0)));
    }
    printf("%.10f\n", exx[1] - ans);
    return 0;
}
/*
4 6
1 4
2 3
1 3
1 2
3 4
2 4
*/

/*
10 33
3 7
5 10
8 9
1 10
4 6
2 5
1 7
6 10
1 4
1 3
8 10
1 5
2 6
6 9
5 6
5 8
3 6
4 8
2 7
2 9
6 7
1 2
5 9
6 8
9 10
3 9
7 8
4 5
2 10
5 7
3 5
4 7
4 9
*/


Measured memory_bytes: 2560
n,y = [int(x) for x in input().split()]
flag = False

for i in range(n+1):
  for j in range(n+1):
    if n-i-j>=0 and 10000*i + 5000*j + 1000*(n-i-j) == y :
      print(i,j,n-i-j)
      flag = True
      break
  if flag:
    break

if not flag:
  print(-1,-1,-1)

Measured memory_bytes: 40812
import sys
for n in sys.stdin:
    n=int(n)
    count=0
    for i1 in xrange(10):
        for i2 in xrange(10):
            for i3 in xrange(10):
                for i4 in xrange(10):
                    if(i1+i2+i3+i4 == n): count+=1
    print count

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 3005;

/* ...o(^-^)o... */
lint dp[MAX][MAX];

int main(){
    int n; cin >> n;
    vector<lint> a(n); rep(i, n) cin >> a[i];

    // dp[i][j] := 区間[i,j)から出発して、最前を尽くした時のX-Yの値
    // N-(j-i)が偶数 => max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1])
    // N-(j-i)が奇数 => min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1])

    repn(l, n){
        rep(i, n){
            int j = i+l;
            if(j>n) continue;
            if((n+j+i)%2==0) dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
            else dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
        }
    }

    out(dp[0][n]);
}

Measured memory_bytes: 70016
/*input
15 9
dnsusrayukuaiia
dujrunuma
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	REP(i,__gcd(n,m)){
		if(s[n/__gcd(n,m)*i]!=t[m/__gcd(n,m)*i]){
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<(ll)n*m/__gcd(n,m);

	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> stone_heights(N + 1);
    vector<int> best(N + 1);
    for (int n = 1; n <= N; n++) {
        cin >> stone_heights[n];
    }
    best[1] = 0;
    best[2] = abs(stone_heights[2] - stone_heights[1]);
    for (int n = 3; n <= N; n++) {
        best[n] = min(best[n - 1] + abs(stone_heights[n] - stone_heights[n - 1]),
                      best[n - 2] + abs(stone_heights[n] - stone_heights[n - 2]));
    }
    cout << best.back() << endl;
}


Measured memory_bytes: 1024
package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	a := scanInts(n)

	x := make([]int, 0)
	y := make([]int, 0)
	
	sort.Ints(a)

	for i := 0; i < n-2; i++ {
		if a[i] < 0 {
			if a[i+1] > 0 {
				x = append(x,a[i])
				y = append(y,a[i+1])
				a[i+1] = a[i] - a[i+1]
			} else {
				x = append(x,a[n-1])
				y = append(y,a[i])
				a[n-1] -= a[i]
			}
		} else {
			x = append(x,a[i])
			y = append(y,a[i+1])
			a[i+1] = a[i] - a[i+1]
		}
	}

	x = append(x,a[n-1])
	y = append(y,a[n-2])
	a[n-1] -= a[n-2]

	fmt.Println(a[n-1])
	for i := 0; i < len(x); i++ {
		fmt.Println(x[i],y[i])
	}

}


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

int main(void)
{
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    vector<tuple<int, int, int>> candidates;

    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    auto element = max_element(h.begin(), h.end());
    int index = distance(h.begin(), element);
    vector<int> cx;
    vector<int> cy;
    vector<int> ch;
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int ch = h[index] + abs(x[index] - cx) + abs(y[index] - cy);
            candidates.push_back(make_tuple(cx, cy, ch));
        }
    }
    for (auto& candidate : candidates) {
        int cx = get<0>(candidate);
        int cy = get<1>(candidate);
        int ch = get<2>(candidate);
        for (int i = 0; i < N; i++) {
            if (max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
                break;
            }
            if (i == N-1) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main (){
    int n ;
    cin >> n ;
    multiset<int> s1 ;
    multiset<int> s2 ;
    rep(i, n){
        ll x, y ;
        cin >> x >> y ;
        s1.insert(x - y) ;
        s2.insert(x + y) ;
    }
    ll ans = max(*s1.rbegin() - *s1.begin(), *s2.rbegin() - *s2.begin()) ;
    cout << ans << endl ;
}

Measured memory_bytes: 22320
#include <iostream>
using namespace std;
int main(){
	int n;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		double dydx1=(y2-y1)/(x2-x1),dydx2=(y4-y3)/(x4-x3);
		if(dydx1==dydx2)cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  string str;
  int shuffle, tmp, h;
  for(;;){
    cin >> str;
    if(str == "-"){ break; }
    cin >> shuffle;
    h = 0;
    for(int i = 0; i < shuffle; i++){
      cin >> tmp;
      h += tmp;
    }
    h = h % str.length();
    cout << str.substr(h) << str.substr(0, h) << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

int main(){
    int k;
    int a,b,path=0;
    cin >> k;
    cin >> a >> b;

    for(int i=a;i<b+1;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            path = 1;
            break;
        }
    }

    if(path==0){
        cout<<"NG"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3552
n = int(input())
ten = []
notten = []
for _ in range(n):
  s = int(input())
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if notten and sum(notten) % 10 == 0:
  print(ans - min(notten))
elif ans % 10 == 0:
  print(0)
else:
  print(ans)
  

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

int main( void )
{
    ll x,a,b;
    cin >> x >> a >> b;
    
    if ( -a + b <= 0 )
        cout << "delicious" << endl;
    else if ( -a + b <= x )
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    int n;
    cin>>n;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(i<10&&(n/i)<10)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;




}














Measured memory_bytes: 3680
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if (N == 0) break;
			boolean[][] g = new boolean[N][N];
			for (int i = 0; i < M; ++i) {
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				g[a][b] = g[b][a] = true;
			}
			ArrayList<Integer> fr = new ArrayList<Integer>();
			for (int i = 0; i < N; ++i) {
				if (g[0][i]) fr.add(i);
			}
			fr.add(0);
			BitSet bs = new BitSet(N);
			for (int f : fr) {
				for (int i = 0; i < N; ++i) {
					if (g[f][i]) bs.set(i);
				}
			}
			bs.clear(0);
			System.out.println(bs.cardinality());
		}
	}

}

Measured memory_bytes: 13000
# コンテスト終了後にkyopro_friendsの解説を見て実装した
# 高さ1として各行をやったあとに埋まってない行を上か下からコピーする

h, w, k = map(int, input().split())
table = []
result_table = [["-" for _ in range(w)] for _ in range(h)]
for _ in range(h):
    table.append(list(input()))

# 盤を埋める数
c = 1
for y in range(h):
    line = table[y]
    idx = 0
    if "#" not in line:
        continue
    # 行の残りの部分に#があれば更新する
    while True:
        if "#" in line[idx:]:
            tmp = idx
            idx = line.index("#")
            line[idx] = "済"
            idx += 1
            for j in range(tmp, idx):
                result_table[y][j] = str(c)
            c += 1
        else:
            break
    # 残ってるところを現在のc-1で埋める（上のほうで次のループに備えて+1してるぶんを相殺）
    for j in range(w):
        if result_table[y][j] == "-":
            result_table[y][j] = str(c - 1)

# この時点で残ってるのは`-`で埋まった列
# これは上か下からコピーする 今回は両方からコピーするので番兵がてら最終行と最初の行を増やしとく
# まず下から
result_table.append(result_table[-1])

for i in range(h - 1, -1, -1):
    if result_table[i] == ["-"] * w:
        result_table[i] = result_table[i + 1]

result_table = result_table[:-1]

# 次に上から だるいのでreverse
result_table = result_table[::-1]
result_table.append(result_table[-1])

for i in range(h - 1, -1, -1):
    if result_table[i] == ["-"] * w:
        result_table[i] = result_table[i + 1]

result_table = result_table[:-1]
result_table = result_table[::-1]

for t in result_table:
    print(" ".join(t))

# test
# 3 7 7
# #...#.#
# ..#...#
# .#..#..


# test
# 4 7 6
# .#.#...
# ...#.#.
# .......
# #..#...

# test
# 4 5 4
# .#.#.
# ...#.
# #....
# .....

# test
# 5 5 6
# .....
# #...#
# ...##
# .#.#.
# .....


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);

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

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ll center_a = (n & 1) ? a[n / 2] : (a[n / 2 - 1] + a[n / 2]);
	ll center_b = (n & 1) ? b[n / 2] : (b[n / 2 - 1] + b[n / 2]);

	cout << abs(center_b - center_a) + 1;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, ans;
signed main () {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int t = n / i;
        if (n % i == 0) t--;
        ans += t;
    }
    return printf ("%lld\n", ans), 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment

const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}
double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  return fabs(sum) / 2;
};

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0)
      ans.push_back(crossPoint(L(A,B), l));
  }
  return ans;
}

int n,m;
vector<P> mp;
double calc(int idx,vector<P>g){
  for(int i=0;i<m;i++){
    if(i==idx)continue;
    P t=mp[idx]-mp[i];
    P a=P(abs(t)/2,1)*t/abs(t)+mp[i];
    P b=P(abs(t)/2,-1)*t/abs(t)+mp[i];
    if(ccw(a,b,mp[idx])<0)swap(a,b);
    g=convex_cut(g,L(a,b));
  }
  return area(g);
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)break;
  vector<P> pl(n);
  mp.resize(m);
  for(int i=0,x,y;i<n;i++)cin>>x>>y,pl[i]=P(x,y);
  for(int i=0,x,y;i<m;i++)cin>>x>>y,mp[i]=P(x,y);
  for(int i=0;i<m;i++)printf("%.10f\n",calc(i,pl));
  }
  return 0;

}

Measured memory_bytes: 3072
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') counter++;
  if (s[1] == '1') counter++;
  if (s[2] == '1') counter++;
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);    
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> cum;
    int c=0;
    cum.push_back(0);
    for (int i=1;i<n;i++) {
        if(s[i-1]=='A' && s[i]=='C') c++;
        cum.push_back(c);
    }

    int l,r;
    for (int i=0;i<q;i++) {
        cin >> l >> r;
        cout << (cum.at(r-1) - cum.at(l-1)) << "\n";
    }
    cout << flush;
    return 0;
}

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

int main() {
	string a;
	cin >> a;
	if (a == "a" || a == "i" || a == "u" || a == "e" || a == "o") {
		cout << "vowel";
	}
	else {
		cout << "consonant";
	}
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli dp[4][3100][3100];
lli item[3100][3100];

void func(long long R, long long C, long long K, std::vector<long long> r, std::vector<long long> c, std::vector<long long> v){

    REP(i,0,R){
        REP(j,0,C){
            REP(k,0,3){
                //取らない
                chmax(dp[0][i+1][j],dp[k][i][j]);
                chmax(dp[k][i][j+1],dp[k][i][j]);

                //取る,i増やす場合はkをリセットできる
                chmax(dp[0][i+1][j],dp[k][i][j]+item[i][j]);
                chmax(dp[k+1][i][j+1],dp[k][i][j]+item[i][j]);
            }
        }
    }
    lli ans = 0;
    REP(i,0,R+1){
        REP(j,0,C+1){
            REP(k,0,4){
                chmax(ans,dp[k][i][j]);
            }
        }
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long R;
    scanf("%lld",&R);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> r(K);
    std::vector<long long> c(K);
    std::vector<long long> v(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&r[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&v[i]);
        
        r[i]--,c[i]--;
        item[r[i]][c[i]] = v[i];
    }
    func(R, C, K, std::move(r), std::move(c), std::move(v));
    return 0;
}


Measured memory_bytes: 370636
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,k,t;
	while(cin>>n>>k,n){
		vector<int> cd(n+1);
		rep(i,k)cin>>t,cd[t]=1;
		
		int pjnt=0,jnt=0,mx=0;
		rep(i,n){
			if(cd[i+1]){
				jnt++;
				if(jnt+(pjnt+1)*cd[0]>mx)mx=jnt+(pjnt+1)*cd[0];
			}else {
				pjnt=jnt,jnt=0;
				if(pjnt+cd[0]>mx)mx=jnt+cd[0];
			}
		}
		cout<<mx<<endl;
	}
	return 0;
}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, a;
    cin >> n >> a;
    string s;
    cin >> s;
    if (s[a - 1] >= 'A' && s[a - 1] <= 'Z') {
        s[a - 1] = s[a - 1] + 32;
    }
    cout << s;
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    sort(v.begin(),v.end());
    ll s=0;
    for(ll i=0;i<(n-1);i++)
    {
        s+=v[i];
    }
    if(s>v[n-1])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define WHITE 0
#define VISITED 1
#define CANDIDATE 2

int n;

int prim(vvi &g) {
  vi d(n, INT_MAX), s(n, WHITE), p(n, -1); 
  d[0] = 0;

  int total = 0;
  while (true) {
    int min_cost = INT_MAX, u;
    rep(i, n) {
      if (s[i] != VISITED && d[i] < min_cost) {
        min_cost = d[i];
        u = i;
      }
    }

    if (min_cost == INT_MAX) break;

    s[u] = VISITED;
    if (p[u] != -1) total += g[p[u]][u];

    rep(v, n) {
      if (s[v] != VISITED && g[u][v] != -1) {
        if (g[u][v] < d[v]) {
          d[v] = g[u][v];
          p[v] = u;
          s[v] = CANDIDATE;
        }
      }
    }
  }

  return total;
}

int main() {
  cin >> n;

  vvi g(n, vi(n, -1));
  rep(i, n) {
    rep(j, n) {
      int c;
      cin >> c;

      g[i][j] = c == -1 ? INT_MAX : c;
    }
  }
  
  int total = prim(g);
  cout << total << endl;
}



Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

void solve(){
  int n; cin >> n;
  int d[n]; for(int i = 0; i < n; i++) cin >> d[i];
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if(a<b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }else{
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    LL N;
    cin >> N;
    map<LL, LL> m;
    LL A;
    REP(i, N)
    {
        cin >> A;
        ++m[A];
    }
    int cnt = 0;
    LL h, w;
    for (map<LL, LL>::reverse_iterator it = m.rbegin(); it != m.rend(); ++it)
    {
        if (cnt == 0)
        {
            if (it->second >= 2)
            {
                it->second -= 2;
                ++cnt;
                h = it->first;
            }
        }

        if (cnt == 1)
        {
            if (it->second >= 2)
            {
                it->second -= 2;
                ++cnt;
                w = it->first;
                break;
            }
        }
    }
    if (cnt == 2)
    {
        cout << h * w << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


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

int main(){
    int n;
    vector<int> coin = {500,100,50,10,5,1};
    while(cin >> n, n){
        n = 1000-n;
        int ans = 0;
        for(auto c : coin){
            ans += n/c;
            n %= c;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
n = int(input())

ar = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]

dp = [float('inf')]*101000
dp[0] = 0

for i in range(1, n+1):
    mins = float('inf')
    for a in ar:
        if i >= a:
            # i円の最小操作回数 = min(i-1円の最小操作回数+1, i-ar[j]円の最小操作回数+1
            mins = min(mins, min(dp[i-1] + 1, dp[i-a]+1))
    dp[i] = mins
print(dp[n])

Measured memory_bytes: 3828
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32)::n,i,j,ap1,ap2
    integer(int32), allocatable:: a(:)
    logical:: is_pairwise_coprime, is_setwise_coprime
    logical,allocatable:: emerged(:)

    ! input -------------------------------------------------------------------
    read*, n
    allocate(a(n))
    read*, a(:)
    allocate(emerged(maxval(a)), source=.false.)

    ! Determine if it is pairwise coprime -------------------------------------
    is_pairwise_coprime = .true.
    do i=1,n
        j=1
        do while(j*j <= a(i))
            if (mod(a(i),j) == 0) then
                ap1 = a(i)/j
                ap2 = j
                if (emerged(ap1) .and. ap1 > 1) is_pairwise_coprime = .false.
                if (emerged(ap2) .and. ap2 > 1) is_pairwise_coprime = .false.
                emerged(ap1) = .true.
                emerged(ap2) = .true.
            end if
            if (.not. is_pairwise_coprime) exit ! pruning
            j=j+1
        end do
        if (.not. is_pairwise_coprime) exit ! pruning
    end do


    ! Determine if it is a setwise coprime --------------------------------------
    ap1 = a(1)
    do i=2,n
        ap1 = gcd(ap1,a(i))
    end do
    is_setwise_coprime = ap1 == 1

    ! output
    if (is_pairwise_coprime) then
        print'(a)', "pairwise coprime"
    else if (is_setwise_coprime) then
        print'(a)', "setwise coprime"
    else
        print'(a)', "not coprime"
    end if
contains
    function lcm(ap1,ap2) result(ret)
        integer(int32):: ap1,ap2,ret
        ret=ap1*ap2/gcd(ap1,ap2)
    end function
    recursive function gcd(ap1,ap2) result(ret)
        integer(int32):: ap1,ap2,ret
    
        if (mod(ap1,ap2) == 0) then
            ret = ap2
            return
        end if
    
        ret = gcd(ap2,mod(ap1,ap2))
    end function
end program main

Measured memory_bytes: 10800
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,l,q;
ll x[500005],y[500005],z[500005];
bool dp[205][205];
char s[500005];
bool flag,dame;

ll  fact[400005];
ll rfact[400005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<400000; i++){
        fact[i] = (fact[i-1]*i) % mod;
        rfact[i] = rui(fact[i],mod - 2);
    }
}
ll ncr(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;
}

int main(){
	b = 0;
	for(i=0;i<5;i++){
		cin >> a;
		ans += ((a+9)/10)*10;
		b = max(b,((a+9)/10)*10 - a);
	}
	p(ans - b);


	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    for(ll i = 0;i < 8;i++) {
        ll sum = S[0] - '0';
        for(ll j = 0;j < 3;j++) {
            if(i & (1 << j)) sum += S[j + 1] - '0';
            else sum -= S[j + 1] - '0';
        }
        if(sum == 7) {
            cout << S[0];
            for(ll j = 0;j < 3;j++) {
                if(i & (1 << j)) cout << '+' << S[j + 1];
                else cout << '-' << S[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
    int64_t n, m;
    cin >> n >> m;
    int64_t a[200010]; 
    int64_t b[200010];  //sorted
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    vector<pair<int64_t, int64_t> > pairs(n);
  
    for(int i=0; i<n; i++){
        pairs[i] = make_pair(a[i], b[i]);
    }

    // firstが小さい順、secondが小さい順にソート
    sort(pairs.begin(), pairs.end());

    // for(int i=0; i<n; i++){
    //     printf("(%d,%d) ", pairs[i].first, pairs[i].second);
    // }

    int64_t ans = 0;
    int64_t pairN = 0;
    for(int i=0; i<m; i++){
        if(pairs[pairN].second > 0){
            ans += pairs[pairN].first;
            pairs[pairN].second--;
        }else{
            pairN++;
            i--;
        }
    }

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

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
ll n;
ll a[100010][4];
ll dp[100010][4];
ll getans(ll i,ll k)
{
if(i>n)
{
	return 0;
}
if(dp[i][k]!=-1)
{
	return dp[i][k];
}
ll ans=0;
for(ll p=1;p<=3;p++)
{
	if(k!=p)
	ans=max(ans,getans(i+1,p)+a[i][p]);
}
return dp[i][k]=ans;
}
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
cin>>n;
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=3;j++)
	cin>>a[i][j];
}
memset(dp,-1,sizeof(dp));
cout<<getans(1,0)<<endl;
}




Measured memory_bytes: 16044
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, k, x;
    while (cin >> n >> k) {
        int ans = 0;
        while (n--) {
            cin >> x;
            if (2*x < 2*abs(k-x))
                ans += 2*x;
            else
                ans += 2*abs(k-x);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>
using namespace std;
vector<pair<int,int> > g[110000];
vector<pair<int,int> > G[310000];
int v[310000];
int ijk[310000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		g[p].push_back(make_pair(r,i));
		g[q].push_back(make_pair(r,i));
		G[i].push_back(make_pair(b+p,0));
		G[i].push_back(make_pair(b+q,0));
		G[b+p].push_back(make_pair(i,1));
		G[b+q].push_back(make_pair(i,1));
	}
	for(int i=0;i<a;i++){
		if(g[i].size()==0)continue;
		std::sort(g[i].begin(),g[i].end());
		int st=0;
		for(int j=0;j<g[i].size();j++){
			if(j&&g[i][j].first!=g[i][j-1].first){
				for(int k=st;k<j-1;k++){
					G[g[i][k].second].push_back(make_pair(g[i][k+1].second,0));
				}
				G[g[i][j-1].second].push_back(make_pair(g[i][st].second,0));
				st=j;
			}
		}
		for(int k=st;k<g[i].size()-1;k++){
			G[g[i][k].second].push_back(make_pair(g[i][k+1].second,0));
		}
		G[g[i][g[i].size()-1].second].push_back(make_pair(g[i][st].second,0));
	}
	for(int i=0;i<310000;i++)ijk[i]=999999999;
	ijk[b]=0;
	priority_queue<pair<int,int> > Q;
	Q.push(make_pair(0,b));
	while(Q.size()){
		int cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;
		for(int i=0;i<G[at].size();i++){
			int to=G[at][i].first;
			int tc=cost+G[at][i].second;
			if(!v[to]&&ijk[to]>tc){
				ijk[to]=tc;Q.push(make_pair(-tc,to));
			}
		}
	}
	if(ijk[b+a-1]>99999999)printf("-1\n");
	else printf("%d\n",ijk[b+a-1]);
}

Measured memory_bytes: 37368
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 100100;
const long long mod = 1e9 + 7;

vector<int>  g[MSIZE];

long long dp[MSIZE][2]; // [w, b]

void Dfs(int f, int p = -1) {
    dp[f][0] = dp[f][1] = 1;
    for (int v : g[f]) {
        if (v == p) continue;
        Dfs(v, f);
        dp[f][0] *= dp[v][1] + dp[v][0];
        dp[f][0] %= mod;
        dp[f][1] *= dp[v][0];
        dp[f][1] %= mod;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int f, t;
        cin >> f >> t;
        f--, t--;
        g[f].push_back(t);
        g[t].push_back(f);
    }
    Dfs(0);
    cout << (dp[0][0] + dp[0][1]) % mod << endl;
}


Measured memory_bytes: 14208
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26488
s = input()
l = []
point = 0
for i in range(len(s)):
    if s[i:i+1] == "L" and s[i+1:i+2] == "R":
        l.append(s[point:i+1])
        point = i+1
l.append(s[point:])
#print(l)
ans = []
for i in range(len(l)):
  #  print(i)
  #  print(l[i])
    long = len(l[i])
 #   print(long)
    a = [0] * long
    for j in range(long):
        if l[i][j:j+1] == "R" and l[i][j+1:j+2] =="L":
            R = j
            L = j+1
            break
    if R%2 == 0:    
        a[R] = long-long//2
        a[L] = long//2
    else:
        a[L] = long-long//2
        a[R] = long//2
    for j in range(long):
        ans.append(str(a[j]))
 #   print(a)
print(" ".join(ans))

Measured memory_bytes: 52592
#include<stdio.h>

int main()
{
	int n,t;
	int i,j;
	int c=0;
	int g=0;
	int min;
	
	if(scanf("%d %d",&n,&t) < 2) {
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
	}
	
	int a[n];
	
	for(i=0;i<n;i++){
		if(scanf("%d",&a[i]) < 1) {
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
		}
	}
	
	min = a[0];
	for(i=1;i<n;i++){
		if(min>a[i]){
			min=a[i];
		}else if(a[i]-min>g){
			c=1;
			g=a[i]-min;
		}else if(a[i]-min==g){
			c++;
		}
	}
	
	printf("%d\n",c);
	
	
	return 0;
}

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

int main(){
    int x,ans=0;

    cin >> x;

    if(x < 600) ans = 8;
    else if(x < 800) ans = 7;
    else if(x < 1000) ans = 6;
    else if(x < 1200) ans = 5;
    else if(x < 1400) ans = 4;
    else if(x < 1600) ans = 3;
    else if(x < 1800) ans = 2;
    else ans = 1;


    cout << ans << endl;
}

Measured memory_bytes: 3620