akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

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

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;

    string s;
    cin >> s;
    
    v_int b(n), w(n);
    irep(i,n) {
        if(s[i] == '#') {
            b[i]++;
        } else {
            w[i]++;
        }
    } 

    irep(i, n-1) {
        b[i+1] += b[i];
        w[i+1] += w[i];
    }
    //cout << b << endl; cout << w << endl;

    int ans = min(b[n-1], w[n-1]);
    irep(i, n-1) {
        chmin(ans, b[i]+(w[n-1]-w[i]));
    }
    cout << ans << endl;
    
    return 0;
}

/*atcoder*/


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

def resolve():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    ans = [[0]*W for _ in range(H)]
    if s[0][0]=='#':
        ans[0][0] = 1
    for i in range(1, W+H-1):
        for y in range(max(0, i-(W-1)), min(i+1, H)):
            x = i-y
            if y==0:
                if s[y][x-1]=='.' and s[y][x]=='#':
                    ans[y][x] = ans[y][x-1] + 1
                else:
                    ans[y][x] = ans[y][x-1]
            elif x==0:
                if s[y-1][x]=='.' and s[y][x]=='#':
                    ans[y][x] = ans[y-1][x] + 1
                else:
                    ans[y][x] = ans[y-1][x]
            else:
                if s[y][x]=='#':
                    ans[y][x] = min(ans[y-1][x]+(1 if s[y-1][x]=='.' else 0), ans[y][x-1]+(1 if s[y][x-1]=='.' else 0))
                else:
                    ans[y][x] = min(ans[y-1][x], ans[y][x-1])
    print(ans[-1][-1])

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3188
import java.util.Scanner;

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

		int[][] list = new int[a][b];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list[i][j] = scanner.nextInt();
			}
		}
		int[] list2 = new int[b];
		for (int i = 0; i < b; i++) {
			list2[i] = scanner.nextInt();
		}
		int sum;
		for (int i = 0; i < a; i++) {
			sum = 0;
			for (int j = 0; j < b; j++) {
				sum += list[i][j] * list2[j];
			}
			System.out.println(sum);
		}

	}
}


Measured memory_bytes: 41288
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	int A, B;
	std::cin >> A >> B;
	if (A >= 13)
	{
		std::cout << B << std::endl;
	}
	else if (A <= 5)
	{
		std::cout << 0 << std::endl;
	}
	else
	{
		std::cout << B / 2 << std::endl;
	}
}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  string ans=string(s.size(),'x');
  cout << ans << endl;
  return 0;
}

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

long long solve1(long long N, vector<long long> L, vector<long long> R){
	priority_queue<pair<long long,long long>> Q;
	priority_queue<pair<long long,long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> P;
	vector<bool> used(N);

	for(int i = 0; i < N; ++i) {
		Q.push(make_pair(L[i], i));
		P.push(make_pair(R[i], i));
	}

	long long res = 0, x = 0;
	for(int i = 0; !Q.empty() || !P.empty(); ++i) {
		if (i % 2 == 0) {
			while(!Q.empty() && (used[Q.top().second] || L[Q.top().second] <= x && x <= R[Q.top().second])) {
				Q.pop();
			}
			if(Q.empty()) continue;
			res += abs(Q.top().first - x);
			x = Q.top().first;
			used[Q.top().second] = true;
			Q.pop();
		} else {
			while(!P.empty() && (used[P.top().second] || L[P.top().second] <= x && x <= R[P.top().second])) {
				P.pop();
			}
			if(P.empty()) continue;
			res += abs(P.top().first - x);
			x = P.top().first;
			used[P.top().second] = true;
			P.pop();
		}
		//cerr << x << endl;
	}
	//cerr << endl;
	res += abs(x);

	return res;
}
void solve(long long N, vector<long long> L, vector<long long> R) {
	long long res = solve1(N, L, R);
	//cerr << res << endl;
	swap(L, R);
	for(int i = 0; i < N; ++i) {
		L[i] = -L[i];
		R[i] = -R[i];
	}
	res = max(res, solve1(N, L, R));
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> L(N-1+1);
	vector<long long> R(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&L[i]);
		scanf("%lld",&R[i]);
	}
	solve(N, L, R);
	return 0;
}



Measured memory_bytes: 10508
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("2");
            WillReturn.Add("3");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("2");
            WillReturn.Add("5");
            WillReturn.Add("10");
            WillReturn.Add("1000000000000000000");
            WillReturn.Add("1000000000000000000");
            //1000000000000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] TArr = InputList.Skip(1).Select(X => long.Parse(X)).Distinct().ToArray();

        long AnswerLCM = TArr[0];
        for (int I = 1; I <= TArr.GetUpperBound(0); I++) {
            long CurrGCD = DeriveGCD(AnswerLCM,TArr[I]);
            AnswerLCM = AnswerLCM * (TArr[I] / CurrGCD);
        }
        Console.WriteLine(AnswerLCM);

        //long AllGCD = TArr[0];
        //for (int I = 1; I <= TArr.GetUpperBound(0); I++) {
        //    AllGCD = DeriveGCD(AllGCD, TArr[I]);
        //}

        //long AnswerLCM = 1;
        //for (int I = 0; I <= TArr.GetUpperBound(0); I++) {
        //    AnswerLCM *= (TArr[I] / AllGCD);
        //}
        //Console.WriteLine(AnswerLCM * AllGCD);
    }

    //ユークリッドの互除法で2数の最大公約数を求める
    static long DeriveGCD(long pVal1, long pVal2)
    {
        long WarareruKazu = pVal2;
        long WaruKazu = pVal1;

        while (true) {
            long Amari = WarareruKazu % WaruKazu;
            if (Amari == 0) return WaruKazu;
            WarareruKazu = WaruKazu;
            WaruKazu = Amari;
        }
    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n;
    cin >> n;
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j <= 14; j++) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define debug(x) cout<< #x <<" : "<< x << endl;
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n);
#define int long long

const int INF = (1<<30);
const int MOD = (int)1e9 + 7;

const int MAX = 510;

#define x0 first.first.first
#define y0 first.first.second
#define x1 first.second.first
#define y1 first.second.second

int con;
vector<vector<int>> field;
vector<int> ans;

void solve(vector<pair<pair<pair<int,int>,pair<int,int>>,int>> p){
    if(p.size() == 0) return;
    
    sort(p.begin(), p.end());

    ans.push_back(p[0].second);

    // cout<<"id =  "<<p[0].second<<" size"<<p.size()<<" "<<p[0].x0<<" "<<p[0].y0<<" "<<p[0].x1<<" "<<p[0].y1<<endl;

    int num1 = p[0].x0, num2 = p[0].x1;
    
    for(int i = p[0].x1+1; i < MAX; i++){
        if(i == 501 || field[p[0].y1][i] != 0 && field[p[0].y1-1][i] != 0 && field[p[0].y1][i] == field[p[0].y1-1][i]){
            // cout<<"i = "<<i<<" "<<p[0].y1<<" [][] "<<field[p[0].y1+1][i]<<" "<<field[p[0].y1][i]<<endl;
            num2 = i-1;
            break;
        }
    }

    vector<pair<pair<pair<int,int>,pair<int,int>>,int>> b, c;
    for(int i = 1; i < p.size(); i++){
        // cout<<"i = "<<i<<" "<<num1<<" "<< p[i].x0<<" "<<p[i].x1<<" "<<num2<<"   <><> "<<p[i].y1<<" <= "<<p[0].y1<<endl;
        if(num1 <= p[i].x0 && p[i].x1 <= num2 &&p[i].y1 <= p[0].y1) b.push_back(p[i]);
        else c.push_back(p[i]);
    }

    solve(b);
    solve(c);
    
}

signed main(){
    int t = 0;

    while(true){
        vector<pair<pair<pair<int,int>,pair<int,int>>,int>> p;
        int n;

        

        cin>>n;

        if(!n) break;

        if(t++) cout<<endl;
        p.resize(n);
        
        ans.clear();
        //ns.resize(n+1);
        
        field.clear();
        field.resize(MAX, vector<int>(MAX, 0));
    
        for(int i = 0; i < n; i++){
            cin>>p[i].x0>>p[i].y0>>p[i].x1>>p[i].y1;

            p[i].second =  i+1;
            if(p[i].x0 > p[i].x1){
                swap(p[i].first.first, p[i].first.second);
            }

            if(p[i].y0 > p[i].y1){
                swap(p[i].y0, p[i].y1);
            }

        
            for(int j = p[i].y0; j < p[i].y1; j++){
                for(int k = p[i].x0; k < p[i].x1; k++){
                    field[j][k] = i+1;
                }
            }
        }

        solve(p);

        vector<int> test(ans);

        for(int i = 0; i < ans.size(); i++){
            test[ans[i]-1] = i;
        }
        for(int i = 0; i < ans.size(); i++){
               cout<<test[i]+1<<endl;
        }
        //cout<<endl;
    }
   

    return 0;
}



Measured memory_bytes: 4936
n = int(input())
a = list(map(int, input().split()))
lis = [0 for i in range(n+1)]
lis[0] = 3
fl = True
ans = 1
for i in range(n):
  if i < a[i]:
    print(0)
    fl = False
    break
  else:
    k =  lis[a[i]] - lis[a[i]+1]
    ans *= k
    lis[a[i]+1] += 1
if fl:
  print(ans%1000000007)

Measured memory_bytes: 14056
n,m = map(int,input().split())
mod = 10**9+7

def factorial(n):
    res = 1
    for i in range(2,n+1):
        res *= i
        res %= mod
    return res

if n==m:
    print((2*factorial(n)**2)%mod)
elif n==m+1:
    print((n*factorial(m)**2)%mod)
elif n+1==m:
    print((m*factorial(n)**2)%mod)
else:
    print(0)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var ls = new List<int>();
        for (int i = 0; i < n; i++)
        {
            ls.Add(sc.NextInt());
        }

        var ans = new int[n];
        for (int i = 0; i < n; i++)
        {
            bool f = false;
            for (int j = ls.Count - 1; j >= 0; j--)
            {
                if (ls[j] == j + 1)
                {
                    ans[n - i - 1] = j + 1;
                    ls.RemoveAt(j);
                    f = true;
                    break;
                }
            }

            if (!f)
            {
                Console.WriteLine("-1");
                return;
            }
        }
        Console.WriteLine(string.Join("\n",ans));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

int main(){

  int N,M;
  cin>>N>>M;
  vec c(M);
  vec s(M);
  vec ans(N,-1);
  int af = 0;
  rep(i,M){
    cin>>s.at(i)>>c.at(i);
    if(ans.at(s.at(i)-1)==-1){
      ans.at(s.at(i)-1)=c.at(i);
    }else if(ans.at(s.at(i)-1)!=c.at(i)){
      af = 1;
    }
  }
  if(N>1&&ans.at(0)==0)af=1;

  if(af ==1){
    cout<<"-1"<<endl;
  }else{
    if(N==1){
      if(ans.at(0)==-1)ans.at(0)=0;
      cout<<ans.at(0)<<endl;
    }else{
    rep(i,N){
      if(ans.at(i)==-1)ans.at(i)=0;
    }
    if(ans.at(0)==0)ans.at(0)=1;
    rep(i,N){
      cout<<ans.at(i);
    }
    cout<<endl;
    }
  }

}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int N,X,T,i,j;
  scanf("%d %d %d",&N,&X,&T);
  i=N/X;
  j=i*T;
  if(N%X==0){
    printf("%d",j);
  }
  else{
    printf("%d",j+T);
  }
  return 0;
}

Measured memory_bytes: 1736
/** goto 文は、C/C++言語などで使うことのできる文で、実行されると無条件に指定されたラベルに処理が飛びます。
 * 例えば goto CHECK_NUM; という文が実行されると、プログラムの中で CHECK_NUM: と書かれた行に処理が移ります。
 * この機能を使って、繰り返し処理なども実現することができます。
 * 一方、goto 文は自由度が高すぎ、プログラムの可読性に影響するため、可能な限り使わないことが推奨されています。
 * 次のC++言語のプログラムと同じ動作をするプログラムを作成してください。ただし、goto 文は使わないで実装してみましょう。
 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 処理を繰り返す

		int intN = sc.nextInt();
		int i = 0;
		int x = 0;
		for (i = 1; i <= intN; i++) {
			if (i % 3 == 0) {
				System.out.print(" " + i);
			} else if (i % 10 == 3) {
				System.out.print(" " + i);
			} else if (i / 1000 == 3) {
				System.out.print(" " + i);
			} else if ((x = i % 1000) / 100 == 3) {
				System.out.print(" " + i);
			} else if ((x = x % 100) / 10 == 3) {
				System.out.print(" " + i);
			}
		}
		System.out.println();
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  cout << 180*(n-2) << endl;
  return 0;
}


Measured memory_bytes: 256
n1, n2 = [int(i) for i in input().split()]

n3 = [int(j) for j in input().split()]

c4 = 1
n5 = 0

for i6 in range(n1):
    n5 += n3[i6]
    if n5 <= n2:
        c4 += 1
    else:
        break

print(c4)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		try {
			s = br.readLine().trim();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		if(9 < s.length()) {
			System.out.println("NO");
			return;
		}
		
		Pattern p = Pattern.compile("^A?KIHA?BA?RA?");
		if ( p.matcher(s).find() ) System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
	     String[] chars = new Scanner(System.in).nextLine().split(" ");
	     Stack<String> stack = new Stack<String>();
	     for(String s: chars) {
	    	 if(s.equals("+")) {
	    		 int b = Integer.valueOf(stack.pop()), a = Integer.valueOf(stack.pop());
	    		 stack.push(Integer.toString(a+b));
	    	 }
	    	 else if(s.equals("-")) {
	    		 int b = Integer.valueOf(stack.pop()), a = Integer.valueOf(stack.pop());
	    		 stack.push(Integer.toString(a-b));
	    	 }
	    	 else if(s.equals("*")) {
	    		 int b = Integer.valueOf(stack.pop()), a = Integer.valueOf(stack.pop());
	    		 stack.push(Integer.toString(a*b));
	    	 }
	    	 else {
	    		 stack.push(s);
	    	 }
	     }
	     System.out.println(stack.pop());
	}

}



Measured memory_bytes: 26200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, t;
	cin>>n>>t;
	P p[3030];
	for(int i=0; i<n; i++){
		int a, b;
		cin>>a>>b;
		p[i]=P(a, b);
	}
	sort(p, p+n);
	int a[3030], b[3030];
	for(int i=0; i<n; i++) a[i]=p[i].first, b[i]=p[i].second;
	int dp[3030][3030];
	for(int i=0; i<=n; i++) for(int j=0; j<t; j++) dp[i][j]=-1;
	dp[0][0]=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<t; j++){
			if(dp[i][j]<0) continue;
			dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
			if(j+a[i]<t) dp[i+1][j+a[i]]=max(dp[i+1][j+a[i]], dp[i][j]+b[i]);
		}
	}
	int ans=0;
	for(int i=0; i<n; i++){
		int mx=*max_element(b+i, b+n);
		for(int j=0; j<t; j++){
			if(dp[i][j]>=0) ans=max(ans, mx+dp[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define pb push_back
  #define f first
  #define se second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    ll n,W;    cin>>n>>W;
    vll v(101),w(101);        vector<vll> dp(101,vll(100001));

    v[0]=inf; w[0]=inf;
    for (ll i = 0; i < n+1; ++i)
    {
      for (ll j = 0; j < 100001; ++j)
      {
        dp[i][j]=inf;
      }
    }
    for (ll i = 1; i < n+1; ++i){
      cin>>w[i]>>v[i];
       // dp[0][i] will be infinite because it is not possible. We have already initialized it inf.
    }    
    dp[1][0]=0;
    dp[0][0]=0;
    dp[1][v[1]]=w[1]; // here I was making error. I was using v[0] & w[0] which is incorrect becuase 
                      // I'am using 1 based indexing.
    
    for (ll i = 2; i < n+1; ++i) // when starting loop from 1 the above 2 dp conditions become useless
    {
      dp[i][0]=0;
      
      for (ll j = 1; j < 100001; ++j)
      {
        dp[i][j]=dp[i-1][j];

        if(j-v[i]>=0){ // maxm weight can be 0.
          dp[i][j]=min(dp[i][j],w[i]+dp[i-1][j-v[i]]);
        }
      }
    }
    for(ll i=100000; i>=0; i--){ // max element can be 0. This loop is important in this question
      if(dp[n][i]<=W)   {
        cout<<i; break; }
    }
    return 0;
  }

Measured memory_bytes: 83188
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>


//Hang in there!

using namespace std;


int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << (W * H) / 2 << " " ;
	if (W / 2 == x && H / 2 == y) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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



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

    int N,Q;
    cin>>N>>Q;

    fenwick_tree<int> fw(N);
    rep(i,N){
        int a;
        cin>>a;
        fw.add(i,a);
    }
    rep(i,Q){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0){
            fw.add(b,c);
        }else{
            int ans=fw.sum(b,c);
            cout<<ans<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8244
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        UnionFind unionFind = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            unionFind.unite(scanner.nextInt() - 1, scanner.nextInt() - 1);
            scanner.next();
        }

        System.out.println(unionFind.parents);
    }

    static class UnionFind {
        int parents;
        private int[] parent;

        UnionFind(int n) {
            parents = n;
            parent = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }
        }

        int root(int n) {
            while (parent[n] != n) {
                n = parent[n] = parent[parent[n]];
            }
            return n;
        }

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                parents--;
                parent[x] = y;
            }
        }

        boolean same(int x, int y) {
            return root(x) == root(y);
        }
    }
}

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

using namespace std;

map<long long, long long> mp;

long long dfs(long long h)
{
    if (h == 1) return 1;
    if (!mp.count(h)) {
        mp[h] = 1 + 2ll * dfs(h/2);
    }
    
    return mp[h];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long h;
    cin >> h;
    cout << dfs(h) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin>>k;
  ll ans = 0;
  FOR(i,1,k+1)FOR(j,1,k+1) {
    int tmp = gcd(i,j);
    FOR(l,1,k+1) {
      ans += gcd(tmp,l);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[a],cnt=a;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	for(int i=a-1;i>=0;i--){
		for(int j=0;j<i;j++){
			if(b[i]<b[j]){
				cnt--;
				break;
			}
		}
	}
	cout<<cnt;
}
//FELAROSSO 2019

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,l,r,ans=0;//???
	cin>>n;//????
	for (i=1;i<=n;i++)//??????
	{
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// 2020-09-19 21:00:00
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    cout << s << "es"s << '\n';
  } else {
    cout << s << "s"s << '\n';
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

typedef struct{
  double x;
  double y;
}Point;

void kock(int,Point,Point);

int main(){
  int n;
  Point p1={0,0},p2={100,0};

  scanf("%d",&n);
  printf("%f %f\n",p1.x,p2.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  return 0;
}

void kock(int n, Point p1, Point p2){
  Point s,t,u;

  if(n==0) return;
  
  s.x = (2.0*p1.x+1.0*p2.x)/3.0;
  s.y = (2.0*p1.y+1.0*p2.y)/3.0;
  t.x = (1.0*p1.x+2.0*p2.x)/3.0;
  t.y = (1.0*p1.y+2.0*p2.y)/3.0;
  
  u.x = (t.x-s.x)*cos(60*M_PI/180.0)-(t.y-s.y)*sin(60*M_PI/180.0)+s.x;
  u.y = (t.x-s.x)*sin(60*M_PI/180.0)+(t.y-s.y)*cos(60*M_PI/180.0)+s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);

  return;
}

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

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

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sum(n + 1, 0);
    for(int i = 0; i < n; ++i)  sum[i + 1] = sum[i] + a[i];
    int left = 0;
    for(int i = n - 2; i >= 0; --i){
        if(2 * sum[i + 1] < a[i + 1]){
            left = i + 1;
            break;
        }
    }
    cout << n - left << endl;
}

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

using namespace std;

#define INF 2<<29
#define F first
#define S second

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

int main(){
  int k,x;
  scanf("%d %d",&k,&x);

  for(int i=x-k+1;i<x+k;i++){
    if(i==x+k-1) printf("%d\n",i);
    else printf("%d ",i);
  }
  
  return 0;
}



Measured memory_bytes: 256
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

----------
-- main --
----------
main :: IO ()
main = newYear

newYear :: IO ()
newYear = do
  m :: Int <- readLn
  print $ 48 - m

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;
ll dp[1005][1005];

int main()
{
    ll h,w;
    cin>>h>>w;
    char a[h+5][w+5];
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>>a[i][j];
        }
    }

    dp[0][0]=1;
    for (int i=0; i<h; i++)
    {
        for (int j=0; j<w; j++)
        {
            if(a[i][j]=='.')
            {
                if(i-1>=0)
                    dp[i][j]+=dp[i-1][j];
                dp[i][j]%=mod;
                if(j-1>=0)
                    dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }

    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/

    cout<<dp[h-1][w-1]<<endl;

    return 0;
}


Measured memory_bytes: 12360
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			for(int i = 0;i < n;i++){
				int start = scan.nextInt();
				int end = scan.nextInt();
				String ans = "";
				if(start == end){
					System.out.println(start);
					continue;
				}
				if(start < end){
					for(int j = start;j < end;j++){
						ans += String.valueOf(j) + " ";
					}
					ans += end;
				}else if(start <= 5 && end <= 5){
					for(int j = start;j > end;j--){
						ans += String.valueOf(j) + " ";
					}
					ans += end;
				}else if(start > 5 && end > 5){
					for(int j = start;j < 10;j++){
						ans += String.valueOf(j) + " ";
					}
					for(int j = 5;j >= 0;j--){
						ans += String.valueOf(j) + " ";
					}
					for(int j = 1;j < end;j++){
						ans += String.valueOf(j) + " ";
					}
					ans += end;
				}else{
					for(int j = start;j < 10;j++){
						ans += String.valueOf(j) + " ";
					}
					for(int j = 5;j > end;j--){
						ans += String.valueOf(j) + " ";
					}
					ans += end;
				}
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 17188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return g > p.g;
    }
    int k, g;
};

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

    int T;
    cin >> T;

    while (T--) {
        int n;
        cin >> n;

        ll s = 0;
        vector<P> p[2];
        for (int i = 0; i < n; i++) {
            int k, l, r;
            cin >> k >> l >> r;

            s += min(l, r);
            int g = l - r;
            p[g < 0].push_back({ g < 0 ? n - k : k, abs(g) });
        }
        for (int h = 0; h < 2; h++) {
            sort(p[h].begin(), p[h].end());
            int m = p[h].size();
            set<int> st;
            for (int i = 0; i < m; i++) {
                st.insert(i);
            }
            for (int i = 0; i < m; i++) {
                auto it = st.lower_bound(p[h][i].k);
                if (it == st.begin()) continue;
                st.erase(--it);
                s += p[h][i].g;
            }
        }
        cout << s << '\n';
    }

    return 0;
}

Measured memory_bytes: 9612
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	if (b > n) {
		cout << a * n / b << endl;
		return 0;
	}
	else {
		ll x = b - 1;
		cout << a * x / b << endl;
		return 0;
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M; cin >> N >> M;
    vector<pair<ll,ll> > x(N);
    vector<pair<ll,ll> > c(M);
    for(int i=0;i<N;i++){
        ll a,b; cin >> a >> b;
        x[i] = make_pair(a,b);
    }
    for(int i=0;i<M;i++){
        ll a,b; cin >> a >> b;
        c[i] = make_pair(a,b);
    }
    
    for(int i=0;i<N;i++){
        int out=-1;
        ll m=LNF;
        ll a=x[i].first;
        ll b=x[i].second;
        for(int j=0;j<M;j++){
            if(m>abs(a-c[j].first)+abs(b-c[j].second)){
                out = j+1;
                m=abs(a-c[j].first)+abs(b-c[j].second);
            }
        }
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
const int INF = 1e9;
const long long INFLL = 1LL<<60;

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

  string s;
  cin >> s;

  int ans = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != s[i-1]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import sys
from collections import Counter
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
C=Counter(L)
x=0
for a in C.values():
  x += int(a*(a-1)/2)  
for K in range(N):
  print(x-C[L[K]]+1)

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

int main(){
  int N;
  scanf("%d", &N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice, bob;
  alice = 0;
  bob = 0;
  for (int i = 0; i< N; i++) {
    if (i % 2 == 0){
      alice += a[i];
    }
    else{
      bob += a[i];
    }
  }
  printf("%d\n", alice - bob);
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=0;i<=(n);i++)

int main(){
	int x[5];
	int y[5];
	int ans;
	int tmp = 0;

	rep(i, 5){
		cin >> x[i];
		y[i] = x[i] % 10;
	}

	sort(x, x + 5);

	rep(i, 5){
		for(int j = i; j < 5; j++){
			if (y[i] > y[j]){
				swap(x[i], x[j]);
				swap(y[i], y[j]);
			}
		}
	}

	rep(i, 5){
		if(y[0] == 0){
			rep(i, 4){
				y[i] = y[i + 1];
			}
			y[4] = 0;
		}
	}

	for (int i = 1; i < 5; i++){
		if(y[i])
			ans += x[i] - y[i] + 10;
		else
			ans += x[i];
	}

	ans += x[0];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
xs = sorted(x, reverse = True)
med1 = xs[n//2 - 1]
med2 = xs[n//2]
for i in range(n):
    if x[i] < med1:
        print(med1)
    else:
        print(med2)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int X; cin >> X;
    FOR(N,1,1e5){
       if(N*(N+1)/2 >= X){
           cout << N << endl;
           return 0;
       }
        
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 2020*3;
ll dp[2][MN];
ll tot[MN];
ll M;
ll mul(ll a, ll b) {
	return (a*b)%M;
}
ll cf[MN][MN];
ll ch(ll n, ll k) {
	if(k > n || k < 0) return 0;
	if(k >= n || k == 0) return 1;
	if(cf[n][k] != -1) return cf[n][k];
	ll res = ch(n-1,k-1)+ch(n-1,k);
	if(res >= M) {res -= M;}
	return cf[n][k] = res;
}
int main() {
	ll n;
	cin >> n >> M;
	memset(cf,-1,sizeof(cf));
	int cu = 0;
	memset(dp,0,sizeof(dp));
	memset(tot,0,sizeof(tot));
	dp[cu][0] = 1;
	tot[0] += dp[cu][0];
	for(int i=0;i<n;i++) {
		int nu = 1-cu;
		memset(dp[nu],0,sizeof(dp[nu]));
		for(int j=0;j<=3*n;j++) {
			dp[nu][j+2] += mul(j+1,dp[cu][j]);
			if(dp[nu][j+2] >= M) {dp[nu][j+2] -= M;}
			dp[nu][j+3] += mul((j+2)*(j+1),dp[cu][j]);
			if(dp[nu][j+3] >= M) {dp[nu][j+3] -= M;}
		}
		for(int j=0;j<=3*n;j++) {
			tot[j] += dp[nu][j];
			if(tot[j] >= M) {tot[j] -= M;}
		}
		cu = nu;
	}
	ll res = 0;
	for(int i=0;i<=3*n;i++) {
		res += mul(ch(3*n,i),tot[i]);
	}
	cout << res%M << '\n';
}


Measured memory_bytes: 287616
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
  return 0;
}


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

class UnionFind
{
  public:
    vector<long long> root;

    UnionFind(long long N)
    {
        root = vector<long long>(N + 1, -1);
    }

    long long find_root(long long A)
    {
        if (root[A] < 0)
        {
            return A;
        }
        else
        {
            root[A] = find_root(root[A]);
        }
        return root[A];
    }

    long long rank(long long A)
    {
        return -root[find_root(A)];
    }

    bool unite(long long A, long long B)
    {
        A = find_root(A);
        B = find_root(B);
        if (A == B)
        {
            return false;
        }

        if (rank(A) < rank(B))
        {
            swap(A, B);
        }

        root[A] += root[B];
        root[B] = A;

        return true;
    }
};

int main()
{
    long long N, M;
    cin >> N >> M;

    long long A[M];
    long long B[M];
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
    }

    UnionFind unionfind(N);
    long long ans[M + 1] = {};
    ans[M] = N * (N - 1) / 2;
    for (int i = M - 1; i > 0; i--)
    {
        ans[i] = ans[i + 1];
        if (unionfind.find_root(A[i]) != unionfind.find_root(B[i]))
        {
            ans[i] -= unionfind.rank(A[i]) * unionfind.rank(B[i]);
            unionfind.unite(A[i], B[i]);
        }
    }

    for (int i = 1; i <= M; i++)
    {
        cout << ans[i] << endl;
    }
}


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

spy = sorted(py)

signate = {}
cnt = 0
last_p = 0
for p, y in spy:
    pref = "{:06}".format(p)
    if last_p == p:
        cnt += 1
    else:
        last_p = p
        cnt = 1
    year = "{:06}".format(cnt)
    signate["{}-{}".format(p, y)] = pref+year

for p, y in py:
    print(signate['{}-{}'.format(p, y)])


Measured memory_bytes: 49168
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
int main (){
  string a, b;
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<char>());
  cout << (a < b ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	map<char,int> mp;
	map<char,int> mpt;
	for(int i=0;i<26;i++){
		mp['a'+i]=50;
		mpt['a'+i]=0;
	}
	
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j<s.size();j++){
			mpt[s[j]]++;
		}
		for(int j=0;j<26;j++){
			char at='a'+j;
			//cout<<at<<" "<<mp[at]<<" "<<mpt[at]<<endl;
			mp['a'+j]=min(mp['a'+j],mpt['a'+j]);
			mpt['a'+j]=0;
		}
	}
	
	for(int i=0;i<26;i++){
		char at='a'+i;
		//cout<<at<<mp[at]<<endl;
		for(int j=0;j<mp[at];j++){
			cout<<at;
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int sec=Integer.parseInt(reader.readLine());
        int h=sec/3600;
        int m=(sec%3600)/60;
        int s=(sec%60);
        System.out.println(Integer.toString(h) + ":" + Integer.toString(m) +":" +Integer.toString(s));
	}
}

Measured memory_bytes: 24428