akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s = input()
l = [0]*7
pm = [ '+', '-' ]

for i in range(0,len(s)):
  
  l[i*2]=s[i]

exp=""

def opeval(x,op,y):
  res = 0
  if op == '+':
    res = x + y
  else:
    res = x - y
  return res

def walk(l):
  res = int(l[0])
  for i in range(0,len(l)-2,2):
    res = opeval( res, l[i+1], int(l[i+2]))
    
  return res

for i in range(0,2):
  l[1]=pm[i]
  for j in range(0,2):
    l[3]=pm[j]
    for k in range(0,2):
      l[5]=pm[k]
      res=walk(l)
      if res==7:
        exp = ''.join(l)
        exp = exp + '=7'
    


print(exp)


Measured memory_bytes: 3064
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]

li2 = []
for i in range(n):
    li2.append([li[i][0]-li[i][1],li[i][0]+li[i][1]])

li2.sort()

nw = li2[0][1]
ans = 1
for i in range(1,n):
    if li2[i][0] >= nw:
        ans += 1
        nw = li2[i][1]
    elif li2[i][1] < nw:
        nw = li2[i][1]


print(ans)

Measured memory_bytes: 41440
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    int n; 
    cin >> n;
    char s[n];
    rep(i,n) cin >> s[i];

    bool p, w, g, y;
    p = w = g = y = false;
    rep(i,n) {
        if (s[i] == 'P') p = true;
        else if (s[i] == 'W') w = true;
        else if (s[i] == 'G') g = true;
        else y = true;
    }
    
    int cnt = 0;
    if (p) ++cnt;
    if (w) ++cnt;
    if (g) ++cnt;
    if (y) ++cnt;

    if (cnt == 3) cout << "Three" << endl;
    if (cnt == 4) cout << "Four" << endl;



}




//              g++ -std=c++1z






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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<i64> x(N),y(N);
    rep(i,0,N){
        cin >> x[i] >> y[i];
    }

    if(N==1){
        cout << 1 << endl;
        return;
    }

    vector<pair<i64,i64>> d;
    rep(i,0,N){
        rep(j,0,N){
            if(i==j) continue;
            d.emplace_back(make_pair(x[i]-x[j],y[i]-y[j]));
        }
    }

    i64 ans=inf64;
    rep(i,0,d.size()){
        i64 cost=N;
        rep(j,0,N){
            rep(k,0,N){
                if(j==k) continue;
                if(x[j]-x[k]==d[i].first and y[j]-y[k]==d[i].second){
                    --cost;
                }
            }
        }
        chmin(ans,cost);
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 384
N,K = list(map(int,input().split(" ")))
Vs = list(map(int,input().split(" ")))
rev = Vs[::-1]
ans = -(10e15)
for b in range(K+1):
    lr = min(K - b,N)
    for l in range(lr + 1):
        rlim = min(lr - l,N)
        for r in range(rlim+1):
            temoti = []
            temoti.extend(Vs[:l])
            temoti.extend(rev[:r])
            temoti.sort()
            tempans = sum(temoti)
            toridasi = 0
            for num in temoti:
                if toridasi == b: #上限回数取り出してたら終わり
                    break
                if num < 0:
                    tempans -= num
                    toridasi += 1
                else:
                    break

            if tempans > ans:
                ans = tempans
print(ans)

Measured memory_bytes: 47580
#include<bits/stdc++.h>
#define f first

#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;

double n,a,b,c,ans;

int main(){

	ios::sync_with_stdio(0);
	
	cin>>n;
	a=n/3;
	ans=a*a*a;
	printf("%.10f\n",ans);
	
	return 0;
}



Measured memory_bytes: 256
import sys
from math import cos
import math


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)
MOD = 10 ** 9 + 7


def main():
    A, B, H, M = map(int, input().split())
    diff = 30 * H
    if M < diff / 5.5:
        D = diff - 5.5 * M
    else:
        D = 5.5 * M - diff
    print((A ** 2 + B ** 2 - 2 * A * B * cos(math.radians(D))) ** (1 / 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9540
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] a=br.readLine().split(" ");
        double x1=Double.parseDouble(a[0]);
        double y1=Double.parseDouble(a[1]);
        double x2=Double.parseDouble(a[2]);
        double y2=Double.parseDouble(a[3]);
        System.out.printf("%.8f", Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2)));
	}
}

Measured memory_bytes: 17000
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
vector<ll> res(0);
void yakusuu(ll n){
	for(ll i=1;i*i<=n;i++){
	    if(n%i==0){
            res.pb(i);
            if(i!=n/i) res.pb(n/i);
	    }
	}
	return ;
}
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  vll a(0,0);
  rep(i,n+1){
    if(i%2){
      yakusuu(i);
      if(sz(res)==8)ans++;
      res=a;
    }
  }
  COUT(ans);
}

Measured memory_bytes: 3640
A, B, K = map(int, input().split())

ans = set()
for i in range(0, K):
    if A + i <= B:
        ans.add(A + i)
    if B - i >= A:
        ans.add(B - i)
ans = list(ans)
ans.sort()
for i in ans:
    print(i)


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

struct UnionFind {
  vector<int> parent;
  vector<int> size;

  UnionFind(int n) : parent(n, -1), size(n, 1) {}

  int find(int i) {
    if (parent[i] == -1) {
      return i;
    }
    return parent[i] = find(parent[i]);
  }

  int get_size(int i) {
    return size[find(i)];
  }
  void unite(int i, int j) {
    i = find(i);
    j = find(j);
    if (i == j) {
      return;
    }
    if (size[i] < size[j]) {
      parent[i] = j;
      size[j] += size[i];
    } else {
      parent[j] = i;
      size[i] += size[j];
    }
  }
};

int main() {
  int n, m;
  cin>>n>>m;
  UnionFind uf(n);
  pair<int, int> p[m];
  for (int i=0; i<m; i++) {
    cin>>p[i].first>>p[i].second;
    --p[i].first;
    --p[i].second;
  }
  long long sum = 1LL * n * (n - 1) / 2;
  long long ans[m];
  for (int i=m-1; i>=0; i--) {
    ans[i] = sum;
    int a = p[i].first;
    int b = p[i].second;
    if (uf.find(a) != uf.find(b)) {
      long long size_a = uf.get_size(a);
      long long size_b = uf.get_size(b);
      sum -= size_a * size_b;
      uf.unite(a, b);
    }
  }
  for (int i=0; i<m; i++) {
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9+21;
const long long LINF = (long long) 1e18;
const long double PI = 2 * acos((long double)0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define Mahmud main()
#define endl "\n"
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define alla(arr,n) arr,arr+n
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define pb push_back
///Debug
#define dbg1(x) std::cerr<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<','<<#z<<"="<<(z)<<endl;
#define dbgArr(arr,n) cerr<<#arr<<"=["; printArray(arr,n,0,93); cerr<<endl;
///traversing
#define rep(n) for(int i=0;i<n;++i)
#define trv(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();++i)
///necessary functions
inline ll Int()
{
    ll _x=0,_tmp=1;
    char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar(), _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}
inline long double Double()
{
    long double d;
    scanf("%Lf",&d);
    return d;
}
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int ton(string x)
{
    int y;
    std::istringstream ss(x);
    ss >> y;
    return y;
}
template<typename T>
string tostring(T x)
{
    ostringstream ss;
    ss << x ;
    return ss.str();
}

///Current Code vars
#define N 100010
long long n,k,c,d;
int arr[N+1],brr[N+1];
///Current Code functions

string s;
long long ans;

void dfs(int now)
{
    ans++;
    if(now==2)
    {
        cout<<ans<<endl;
        exit(0);
    }
    brr[now] = 1;
    int to = arr[now];
    if(brr[to]==1)
    {
        puts("-1");
        exit(0);
    }
    dfs(to);
}

void solve()
{
    n = Int();
    for(int i=1;i<=n;++i)
    {
        arr[i] = Int();
    }
    ans = -1;
    dfs(1);
}

int Mahmud
{
    // ios_base::sync_with_stdio(0); //cin.tie(0);
  //#ifdef _LOCAL_
    //freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
  //while(1)
    solve();
  //#ifdef _LOCAL_
    //printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
  //#endif
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	ll now=0;
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	for(int i=a.size()-1;i>=0;i--){
		a[i]+=now;
		if(a[i]%b[i]==0);
		else now+=(a[i]/b[i]+1)*b[i]-a[i];
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 1792
N,M,X = gets.split.map(&:to_i)
Books = $<.map{|ln|
	c,*a = ln.split.map(&:to_i)
}
p (1..N).map{|n|
	Books.combination(n).map{|books|
		books.shift.zip(*books).map(&:sum)
	}.select{|c,*a|
		a.all?{|_| X<=_ }
	}.map{|c,| c }.min
}.compact.min||-1


Measured memory_bytes: 14972
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;



class Main {

	public static void main(String[] argv){

		Scanner sc = new Scanner(System.in);

		String s1 = sc.nextLine();

		sc.close();

		String s2 = "CODEFESTIVAL2016";

		char[] c1 = s1.toCharArray();
		char[] c2 = s2.toCharArray();

		int count = 0;
		for(int i = 0;i<c1.length;i++){
			if(c1[i] != c2[i]) count++;
		}

		System.out.println(count);

	}


}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 9684
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    string s;
    unordered_map<string, int> vote;
    int max_freq = 0;
    for(int i = 0; i < n; i++) {
        cin >> s;
        vote[s] += 1;
        max_freq = max(max_freq, vote[s]);
    }
    vector<string> ans;
    for(auto p: vote) {
        if (p.second == max_freq) {
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(), ans.end());
    for(string out: ans)
        cout << out << endl;
    return 0;
}



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

int main()
{
  	int i,j,k;
  	string s,p,ans = "No";
  
 	cin >> s >> p;
   	
  	s += s;
  
  	for(i = 0;i < s.length();i++){
      k = i;
      for(j = 0;j < p.length() && k < s.length();j++){
        if(s.at(k) != p.at(j))
          break;
        k++;
      }
      if(j == p.length()){
        ans = "Yes";
        break;
      }
    }
	cout << ans << endl;
  
}


Measured memory_bytes: 3220
X = int(input())

is_prime_num_list = [True] * 100005
is_prime_num_list[0] = False
is_prime_num_list[1] = False

for i in range(2, X + 1):
    if is_prime_num_list[i] == True:

        # iの倍数番目をFalseにする
        for j in range(2 * i, 100005, i):
            is_prime_num_list[j] = False

prime_num_list = [i for i, j in enumerate(is_prime_num_list) if i >= X and j == True]

print(min(prime_num_list))


'''
if is_prime_num_list[X] == True:
    print(X)
    exit()
'''

'''
while True:
    X += 1
    is_target = True
    for i in prime_num_list:
        if X % i == 0:
            is_target = False
            break

    if is_target:
        print(X)
        exit()
'''
    
    




        







Measured memory_bytes: 5784
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    double a, l, x;
    while (cin >> a >> l >> x) {
        double dM = l * sqrt(x*x+2*l*x) * 0.5;
        double A = a * sqrt(l*l - a*a*0.25) * 0.5;
        printf("%.8lf\n", dM + A);
    }
    return 0;
}

Measured memory_bytes: 1240
import collections
t = []
for i in range(3):
    a,b = map(int,input().split())
    t.append(a)
    t.append(b)
    
c = collections.Counter(t)

cv = []
for v in c.values():
    cv.append(v)
cv.sort()

if cv == [1,1,2,2]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3444
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


int main(int argc, char const *argv[]) {
    // code
    int x;
    cin >> x;
    int ans = x / 500 * 1000 + (x % 500 / 5 * 5);
    cout << ans << endl;
    return 0;
}


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

bool judgeExtra( int* r, int j )
{
    for( int i = 0; i < j; i++ )
        if( r[i] == r[j] )
            return true;
    return false;
}

int main()
{
    int a, b, r[100];
    string s, t;

    while( cin >> a >> b )
    {
        s = "";
        t = "";
        for( int i = 0; i < 100; i++ )
             r[i] = 0;
        
        int j = 0;
        bool judge = true;
        while( 1 )
        {
            s += ( a / b ) + '0';
            t += ' ';

            if( a % b != 0 )
            {
                r[j] = a % b;
                int cnt = 0;
                if( judgeExtra( r, j ) )
                {
                    t[j] = '^';
                    for( int i = j - 1; i >= 0; i-- )
                    {
                        if( r[i] == a % b )
                            break;
                        else
                            t[i] = '^';
                    }
                    break;
                }
                a = ( a % b ) * 10;
                j++;
            }
            else
            {
                judge = false;
                break;
            }
        }
        for( int i = 1; i < s.size(); i++ )
            cout << s[i];
        cout << endl;

        if( judge )
        {
            for( int i = 1; i < t.size(); i++ )
                cout << t[i];
            cout << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3160
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define    endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define PI 3.141592653589793
#define N  2005
bitset<N*N> dp;


void solve()
{
    ll n;
    cin>>n;
    ll x,sum=0;
    dp[0]=1;
    rep(i,0,n)
    {
        cin>>x;
        dp= (dp<<x) | dp;
        sum+=x;
    }
    sum=(sum+1)/2;
    while(!dp[sum]) sum++;
    cout<<sum<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn=1e6+10;
const int mod=1000000000+7;
const double eps=1e-6;


int main() {
   // freopen("test.txt","r",stdin);
   int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}
/*
500 500 1
YES
2
1 RDU
1 R

*/


Measured memory_bytes: 256
/*2020/03/16 ABC 051*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;  


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    const int dx = tx - sx, dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long k, j, b[100002]={0};

int main(void)
{
  int n, a, t, i;
  scanf("%d %lld", &n, &k);

  while(n--){
    scanf("%d", &a);
    scanf("%d", &t);
    b[a] += t;
  }

  j = 0;
  for(i = 1; i < 100001; i++){
    j += b[i];
    if(j >= k){
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
int main() {
    int n, x;
    cin >> n >> x;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i] -= x;
        c[i] = abs(c[i]);
    }
    int g = c[0];
    for (int i = 1; i < n; i++) {
        g = gcd(g, c[i]);
    }

    cout << g << endl;
    return 0;
}

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

int d;
vector<int> c;
vector< vector<int> > s;

int satisfaction(const vector<int>& t) {
  vector<int> last(26, -1);
  int ans = 0;
  for (int i = 0; i < (int) t.size(); i++) {
    ans += s[i][t[i]];
    last[t[i]] = i;
    for (int j = 0; j < 26; j++) {
      ans -= c[j] * (i - last[j]);
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> d;
  c.resize(26);
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  s.assign(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> t;
  for (int i = 0; i < d; i++) {
    vector<int> tmp = t;
    vector<int> best = {-1};
    for (int j = 0; j < 26; j++) {
      tmp.push_back(j);
      if (best[0] == -1 || satisfaction(tmp) > satisfaction(best)) {
        best = tmp;
      }
      tmp.pop_back();
    }
    swap(t, best);
  }
  for (auto& x : t) {
    cout << x + 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 3796
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  ll n,x;
  cin>>n>>x;
  ll arr[n];
  rep(i,0,n) cin>>arr[i];
  ll ans=1;
  ll d=0;
  for(int i=0;i<n;i++){
    d=d+arr[i];
    if(d<=x) ans++;
    else break;
  }
  cout<<ans;
  
  }

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, X;
    cin >> N >> X;
    int d = 0;
    int counter = 1;
    bool ok=true;
    REP(i, N)
    {
        int l;
        cin >> l;
        d += l;
        if (d > X) 
        {
            cout << counter << endl;
            ok=false;
            break;
        }
        counter++;
    }
    if (ok) cout << counter << endl;



    return 0;
}



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


int main() {

  int m,d;
  cin>>m>>d;

  int cnt=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      int d1=j%10;
      int d10=j/10;
      if((d1>=2)&&(d10>=2)&&(d1*d10==i)){
        cnt++;
      }
    }
  }

  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let (n, a, b) = parse_triple::<u32, u32, u32>();

    println(std::cmp::min(n * a, b));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#define input_int(a) scanf("%d", &a);
#define input_char(a) scanf("%s", a);

int min(int a, int b) {
	if(a > b) return b;
	return a;
}

int max(int a, int b) {
	if(a > b) return a;
	return b;
}

int main() {
	int a, b;
	input_int(a);
	input_int(b);
	int ans = 0;
	if(a <= b) ans++;
	ans += a - 1;
	printf("%d\n", ans);


	//char buffer[128];
	//scanf("%s", buffer);
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    int s = b - a;
    int i = 1, t = 0;
    while(i < s){
        t += i;
        i++;
    }
    cout << t - a << endl;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <algorithm>
 
long long N, A, B;
 
int main(void){
    // Here your code !
    scanf("%lld%lld%lld",&N,&A,&B);
 
    long long D = B - A;
 
    if (D < 0) {printf("%d\n", 0);}
    else if (D == 0 && N >= 1) printf("%d\n", 1);
    else if (D > 0 && N == 1) printf("%d\n", 0);
    else if (D > 0 && N != 1) printf("%lld\n", (1 + (N - 2) * D));
 
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	
	int m;
	
	string s;
	
	
	cin >> m;
	FOR(i, 1, m) {
		cin >> s;
		int pos = 0;
		int count = 0;
		string p, q;
		vector<string>dp(1000,"-");
		FOR(t, 1, s.size() - 1) {
			p = s.substr(0, t);
			q = s.substr(t);
			dp[pos] = p + q;
			pos++;
			dp[pos] = q + p;
			pos++;
			reverse(p.begin(), p.end());
			dp[pos] = p + q;
			pos++;
			dp[pos] = q + p;
			pos++;
			reverse(q.begin(), q.end());
			dp[pos] = p + q;
			pos++;
			dp[pos] = q + p;
			pos++;
			reverse(p.begin(), p.end());
			dp[pos] = p + q;
			pos++;
			dp[pos] = q + p;
			pos++;
		}
		/*FOR(u, 0, 999) {
			cout << dp[u] << endl;
		}*/
		sort(dp.begin(), dp.end());
		FOR(u, 0, 999) {
			FOR(r, u + 1, 999) {
				if (dp[u] == dp[r]) {
					dp[r] = "-";
				}
			}
		}
		FOR(u, 0, 999) {
			if (dp[u] != "-") {
				count++;
			}
		}
		cout << count << endl;
	}

}


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

int main(){
  while(1){
    int i,n;
    int point;
    cin >> n;
    if(n==0)break;
    int total = 0;
    for(i = 1; i <= n/4; i++){
      cin >> point;
      total+=point;
    }
    cout << total << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.io.*;
class Program{
    boolean fact(int n){
        int count = 0;
        for(int i=1;i<=Math.sqrt(n);i++){
            if (n%i==0){
                if (i!=Math.sqrt(n)) count+=2;
                else{
                    if (Math.pow(Math.sqrt(n),2)==n) count+=1;
                    else count+=2;
                }
            }
        }
        if (count==8) return true;
        else return false;
    }
}
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        Program obj = new Program();
        int count= 0, N = Integer.parseInt(in.readLine());
        for(int i = 1;i<=N;i++){
            if(i%2==1){
                if(obj.fact(i)) count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

struct dice{
    int number[6];
};

int main(void){
    int diceNumber;
    char order[120];
    struct dice x;
    
    fgets(order, 120, stdin);
    sscanf(order, "%d %d %d %d %d %d",
           &x.number[0], &x.number[1], &x.number[2], &x.number[3], &x.number[4], &x.number[5]);
    fgets(order, 120, stdin);
    for(int t = 0; order[t] != '\n'; t++){
        if(order[t] == 'N'){
            diceNumber = x.number[0];
            x.number[0] = x.number[1];
            x.number[1] = x.number[5];
            x.number[5] = x.number[4];
            x.number[4] = diceNumber;
        }else if(order[t] == 'S'){
            diceNumber = x.number[0];
            x.number[0] = x.number[4];
            x.number[4] = x.number[5];
            x.number[5] = x.number[1];
            x.number[1] = diceNumber;
        }else if(order[t] == 'E'){
            diceNumber = x.number[0];
            x.number[0] = x.number[3];
            x.number[3] = x.number[5];
            x.number[5] = x.number[2];
            x.number[2] = diceNumber;
        }else if(order[t] == 'W'){
            diceNumber = x.number[0];
            x.number[0] = x.number[2];
            x.number[2] = x.number[5];
            x.number[5] = x.number[3];
            x.number[3] = diceNumber;
        }
    }
    printf("%d\n", x.number[0]);
    return 0;
}


Measured memory_bytes: 2056
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()

	s := make([]string, h)
	for i := 0; i < h; i++ {
		s[i] = scanString()
	}

	q := queue{point{0,0,1}}
	done := make([][]bool, h)
	for i := 0; i < h; i++ {
		done[i] = make([]bool, w)
	}

	cnt := 0

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if s[i][j] == '.' {
				cnt++
			}
		}
	}

	done[0][0] = true

	for q.Len() != 0 {
		next := q.Pop()
		for i := 0; i < 4; i++ {
			nx, ny := next.x+dx[i], next.y+dy[i]
			if 0<=nx && nx<w && 0<=ny && ny<h {
				if nx == w-1 && ny == h-1 {
					fmt.Fprintln(wr, cnt-next.d-1)
					return
				}
				if done[ny][nx] || s[ny][nx] == '#' {
					continue
				}

				q.Push(point{ny,nx,next.d+1})
				done[ny][nx] = true
			}
		}
	}

	fmt.Fprintln(wr, -1)
}

var dx, dy = []int{1,0,-1,0}, []int{0,-1,0,1}

type point struct {
	y int
	x int
	d int
}

type queue []point

func (q queue) Len() int { return len(q) }
func (q *queue) Push(a point) { *q = append(*q, a) }
func (q *queue) Pop() point {
	res := (*q)[0]; *q = (*q)[1:]; return res
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int x[110], sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum += (2 * min(x[i], abs(k - x[i])));
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void test_cases(){
    int n;
    cin >> n;
    int cnt = 0;
    bool flag = 0;
    for(int i = 0; i < n; i++){
        int a;
        int b;
        cin >> a >> b;
        if(a == b){
            cnt++;
        }
        else{
            cnt = 0;
        }
        if(cnt == 3){
            flag = 1;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt = 1;
//    cin >> tt;
    while(tt--){
        test_cases();
    }
    return 0;
}


Measured memory_bytes: 3648
# cook your dish here
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ass = 0
while len(a)>= 1:
    if a[0]<= x and len(a)>= 2:
        x = x -a[0]
        ass += 1
        del a[0]
    elif a[0] == x:
        ass += 1
        del a[0]
    else:
        break
print(ass)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
	using namespace std;
	int main()
	{
		int n, W;
		cin>>n>>W;
		vector<long long> weight, price;
		for(int i=0;i<n;i++)
		{
			int a,b;
			cin>>a>>b;
			weight.push_back(a);
			price.push_back(b);
		}
		long long dp[n+1][W+1];
		for (int i = 0; i <= n; i++) 
  		{ 
       		for (int w = 0; w <= W; w++) 
       		{ 
            	if (i==0 || w==0) 
                	dp[i][w] = 0; 
           		else if (weight[i-1] <= w) 
                	dp[i][w] = max(price[i-1] + dp[i-1][w-weight[i-1]],  dp[i-1][w]); 
           		else
                	dp[i][w] = dp[i-1][w]; 
       		} 
   		} 
  
		cout<<dp[n][W]<<endl;
		return 0;
	}

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

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

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

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

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

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}
public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i] = fs.nextInt();

        long sum =0;
        int min = Integer.MAX_VALUE;
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(a[i] < 0)cnt++;
            sum+=Math.abs(a[i]);
            min = Math.min(min,Math.abs(a[i]));
        }

        if(cnt%2==0){
            System.out.println(sum);
        }else{
            System.out.println(sum-2*min);
        }
    }
}

Measured memory_bytes: 22816
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

signed main() {
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1) {
    if(a==b) {
      cout<<"1"<<endl;
    }
    else {
      cout<<"0"<<endl;
    }
  }
  else if(a>b) {
    cout<<"0"<<endl;
  }
  else {
    cout<<(n-2)*(b-a)+1<<endl;
  }
}

Measured memory_bytes: 256
p ->(n) {
    res = 100000
    n.times do
        res = ->(x){
            x += ( x * 0.05 ).to_i
            if x % 1000 > 0 then x += 1000 - x % 1000 end
            x
        }.call res
    end
    res
}.call gets.to_i

Measured memory_bytes: 6116
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#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, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vl A(5);
  REP(i, 5) cin >> A[i];
  ll last = 0;
  ll po = 10;
  REP(i, 5) {
    if (A[i] % 10 != 0 && A[i] % 10 < po) {
      last = i;
      po = A[i] % 10;
    }
  }
  ll ans = 0;
  REP(i, 5) {
    if (i == last)
      continue;
    else
      ans += 10 * ceil((double)A[i] / (double)10);
  }
  ans += A[last];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int m = in.nextInt();
        System.out.println(n*m-(n+m)+1);
    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		int n = sc.nextInt();

		int count = 0;
		for (int i = 0; i < n; i++) {
			char[] c_str = str.toCharArray();
			char[] input = sc.next().toCharArray();

			for (int j = 0; j < input.length; j++) {
				boolean flag = true;
				for (int k = 0; k < c_str.length; k++) {
					if (input[(j + k) % input.length] != c_str[k]) {
						flag = false;
						break;
					}
				}

				if (flag) {
					count++;
					break;
				}
			}

		}

		System.out.println(count);

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int cnt[500050];
char s[500050];
int ans[500050];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++)if(s[i]=='0')cnt[i]=i;
		else cnt[i]=cnt[i-1];
	for(int i=1;i<=n;i++){
		ans[i]=ans[i-1];
		if(s[i]=='1'){
			if(s[i-1]=='0'&&s[i-2]=='1'){
				ans[i]=max(ans[i],ans[cnt[i-2]]+i-2-cnt[i-2]);
				ans[i]=max(ans[i],ans[cnt[i-2]+1]+i-2-cnt[i-2]-1);}
			if(s[cnt[i]-1]=='1'){
				ans[i]=max(ans[i],ans[cnt[i]-2]+i-cnt[i]);}}}
	cout<<ans[n];
	
	return 0;
 } 

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

int main()
{
    int k, sum = 0, n;
    cin >> n >> k;

    for(int i=1; i<1000; i++){
		sum = pow(k, i);
		//cout << sum << endl;
		if(sum > n){
			cout << i;
			return 0;
		}
    }


    return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let [r, c] = input[0].split(' ').map(Number)
let num = [];
for (let i = 1; i < input.length; i++) {
    let tmp = input[i].split(' ').map(Number);
    num.push(tmp);
}
for (i = 0; i < r; i++) {
    let sum = num[i].reduce((a,x) => a+=x,0);
    num[i].push(sum);
    console.log(num[i].join(' '));
}

let sumLine = [];
for (i = 0; i <= c; i++) {
    let tmp = 0;
    for (let j = 0; j < r; j++) {
         tmp = tmp + num[j][i];
    }
    sumLine.push(tmp);
}
    console.log(sumLine.join(' '));


Measured memory_bytes: 17868
#include <iostream>

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

int main(){
    ll a, b;
    cin >> a >> b;
    cout << a * b << ' ' << 2 * (a + b) << endl;
    return 0;
}



Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class AX {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a, b; cin >> a >> b;
      int ret = max(a*b, a-b);
      chmax(ret, a+b);
      cout << ret << endl;
    }
};

signed main() {
  AX solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256